summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-19 17:20:30 +0200
committerSimon Rettberg2018-07-19 17:20:30 +0200
commit87eaae3e4e2f6d542956df870609b798b9fa9d26 (patch)
tree9cc85ec51589e1e7b14dae7e05a059b15a8cf8d2 /src/server/mainwindow/mainwindow.cpp
parent[server] SessionNameWindow: Set focus to text box on open (diff)
downloadpvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.tar.gz
pvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.tar.xz
pvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.zip
[server] Offer deleting temp. clients on session name change
If the user changes the session name, we now ask whether to disconnect and delete all clients that just connected via session name and don't belong to the currently loaded room layout.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp80
1 files changed, 34 insertions, 46 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 568896c..6fc80f3 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -79,9 +79,9 @@ MainWindow::MainWindow(QWidget* parent) :
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
- _helpWindow->setWindowTitle("Help");
+ _helpWindow->setWindowTitle(tr("Help"));
_reloadWindow = new ReloadRoomWindow(this);
- _reloadWindow->setWindowTitle("Reload Room");
+ _reloadWindow->setWindowTitle(tr("Reload Room"));
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
@@ -174,9 +174,7 @@ MainWindow::MainWindow(QWidget* parent) :
_discoveryListener = new DiscoveryListener();
// Finally
- _countSessionNameUpdate = 0;
this->onSessionNameUpdate(); // Just make lable visible.
- _countSessionNameUpdate = 0;
reloadCurrentRoom();
}
@@ -341,29 +339,15 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPi
* Also connect signals frameMoved() and clicked() with slots.
* @return ConnectionFrame*
*/
-ConnectionFrame* MainWindow::createFrame()
+ConnectionFrame* MainWindow::createFrame(const QString &computerId, const QPoint* gridPosition, bool fromRoomplan)
{
- ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom);
- // Move to any free tile
- placeFrameInFreeSlot(cf);
- _clientFrames.append(cf);
- cf->show();
- connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
- connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *)));
- return cf;
-}
-
-/***************************************************************************//**
- * Create new Frame.
- * Create new frame and add to current available frame list.
- * Also connect signals frameMoved() and clicked() with slots.
- * @return ConnectionFrame*
- */
-ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint gridPosition)
-{
- ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom);
+ ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom, fromRoomplan);
+ if (gridPosition == NULL) {
+ placeFrameInFreeSlot(cf);
+ } else {
+ cf->setGridPosition(*gridPosition);
+ }
cf->setComputerId(computerId);
- cf->setGridPosition(gridPosition);
_clientFrames.append(cf);
cf->show();
connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
@@ -670,13 +654,6 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
*/
void MainWindow::onSessionNameClick()
{
- _countSessionNameUpdate++;
- if (_countSessionNameUpdate > 1) {
- int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to change SessionName again?\n"
- "All Clients will be deleted afterwards."), 0, 1, 2);
- if (ret != 1)
- return;
- }
_sessionNameWindow->show((serverApp->sessionName()));
}
@@ -685,18 +662,33 @@ void MainWindow::onSessionNameClick()
*/
void MainWindow::onSessionNameUpdate()
{
- // Stop all projections and clear all clients, which where connected to old sessionName.
+ _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(serverApp->sessionName()));
+ bool haveAdditionalClient = false;
+ for (QMutableListIterator<ConnectionFrame*> it(_clientFrames); it.hasNext(); ) {
+ if (!it.next()->isFromRoomplan()) {
+ haveAdditionalClient = true;
+ break;
+ }
+ }
+ if (!haveAdditionalClient)
+ return; // No additional client exists, don't ask about reset
+ // Current layout contains additional clients (voa session name), ask to delete
+ QMessageBox::StandardButton ret = QMessageBox::question(this,
+ tr("Question"), tr("Do you want to delete and disconnect any clients\n"
+ "not belonging to the current room layout?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ if (ret != QMessageBox::Ok)
+ return;
+ // Stop all projections and clear all clients, which were connected to old sessionName.
reset();
- if (_countSessionNameUpdate > 1) {
- {
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- (*it)->hide();
- (*it)->deleteLater();
- }
- _clientFrames.clear();
+ for (QMutableListIterator<ConnectionFrame*> it(_clientFrames); it.hasNext(); ) {
+ ConnectionFrame *cf = it.next();
+ if (!cf->isFromRoomplan()) {
+ cf->hide();
+ cf->deleteLater();
+ it.remove();
}
}
- _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(serverApp->sessionName()));
}
/***************************************************************************//**
@@ -763,7 +755,7 @@ void MainWindow::reloadCurrentRoom()
QString computerId = it.key();
QPoint pos = it.value();
- ConnectionFrame *cf = createFrame(computerId, pos);
+ ConnectionFrame *cf = createFrame(computerId, &pos, true);
onPlaceFrame(cf);
if (computerId == room->tutorIP) {
qDebug() << "set computer with id " << computerId << " as tutor per configuration";
@@ -1172,9 +1164,6 @@ void MainWindow::onClientAuthenticated(Client* client)
ConnectionFrame *existing = NULL;
ConnectionFrame *cf = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- // qDebug() << "Existing frame ip: " << (*it)->computerId();
- // qDebug() << "New Clients ip: " << client->ip();
- // qDebug() << ((*it)->computerId() == client->ip());
if ((*it)->computerId() == client->ip()) {
existing = *it;
}
@@ -1189,7 +1178,6 @@ void MainWindow::onClientAuthenticated(Client* client)
cf->assignClient(client);
connect(client, SIGNAL(disconnected()), this, SLOT(clientCountChanged()));
- //resizeEvent(NULL); // This is where all the positioning should be
tellClientCurrentSituation(client);
clientCountChanged();
}