diff options
author | Björn Hagemeister | 2014-07-29 15:31:56 +0200 |
---|---|---|
committer | Björn Hagemeister | 2014-07-29 15:31:56 +0200 |
commit | 254c7fb41a96f42ef4049d5a495e47fad2e3e983 (patch) | |
tree | fb5540996acdb0d8a91cc4a7d9447f7dd2cb8015 /src | |
parent | Read the configfile and place the frames according to the coordinates (diff) | |
download | pvs2-254c7fb41a96f42ef4049d5a495e47fad2e3e983.tar.gz pvs2-254c7fb41a96f42ef4049d5a495e47fad2e3e983.tar.xz pvs2-254c7fb41a96f42ef4049d5a495e47fad2e3e983.zip |
Fixed bug, that frame moved on (0,0) is asked to be deleted.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 2 | ||||
-rw-r--r-- | src/server/connectionframe/connectionframe.h | 2 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 51 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.h | 2 |
4 files changed, 30 insertions, 27 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index 1bf6fb6..39aba12 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -188,7 +188,7 @@ void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) if ((this->pos() - _previousPosition).manhattanLength() > _startDragDistance ) { qDebug("Moved"); - emit frameMoved(this); + emit frameMoved(true, this); } else { diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index faa1390..3f1815b 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -78,7 +78,7 @@ protected: void timerEvent(QTimerEvent* event); signals: - void frameMoved(ConnectionFrame* frame); + void frameMoved(bool activateTrash, ConnectionFrame* frame); void doubleClicked(ConnectionFrame* frame); void clicked(ConnectionFrame* frame); diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 55e4bce..82981b1 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -209,8 +209,8 @@ ConnectionFrame* MainWindow::createFrame() ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, _tileWidth, _tileHeight); _clientFrames.append(cf); cf->show(); - connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *))); - connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *))); + connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *))); + connect(cf, SIGNAL(clicked(bool, ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *))); return cf; } @@ -228,7 +228,7 @@ ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint position) cf->setCurrentPosition(position); _clientFrames.append(cf); cf->show(); - connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *))); + connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *))); connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *))); return cf; } @@ -346,7 +346,7 @@ void MainWindow::tryToUseRoomTemplate() ConnectionFrame *cf = createFrame(conf.value("ip").toString(), coord); cf->move(cf->getCurrentPosition()); - onPlaceFrame(cf); + onPlaceFrame(false, cf); } conf.endArray(); } @@ -525,7 +525,7 @@ void MainWindow::onTutorListDownloaded(QByteArray& tutorList) * Place Frame to from user specified position. * @param frame */ -void MainWindow::onPlaceFrame(ConnectionFrame* frame) +void MainWindow::onPlaceFrame(bool activateTrash, ConnectionFrame* frame) { if (_tilesX <= 0 || _tilesY <= 0) return; @@ -542,31 +542,34 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) else if (y > s.height() - _tileHeight) y = (_tilesY - 1) * _tileHeight; - const QRect &trashCenter = ui->trash->geometry(); - // Check if x coordinate is in trash position. - if (trashCenter.contains(p)) + // Check if x coordinate is in trash position. Check only if activateTrash = true! + if (activateTrash) { - // Do not offer deleting online client. - if (frame->client() != NULL) - { - QMessageBox::critical(this, tr("Selection"), sStrClientOnline); - frame->move(frame->getPreviousPosition()); - return; - } - else + const QRect &trashCenter = ui->trash->geometry(); + if (trashCenter.contains(p)) { - int ret = QMessageBox::question(this, "Warning", "Sure, You want to delete selected client?", 0, 1, 2); - if (ret == 1) + // Do not offer deleting online client. + if (frame->client() != NULL) { - frame->hide(); - frame->deleteLater(); - _clientFrames.removeOne(frame); + QMessageBox::critical(this, tr("Selection"), sStrClientOnline); + frame->move(frame->getPreviousPosition()); return; } else { - frame->move(frame->getPreviousPosition()); - return; + int ret = QMessageBox::question(this, "Warning", "Sure, You want to delete selected client?", 0, 1, 2); + if (ret == 1) + { + frame->hide(); + frame->deleteLater(); + _clientFrames.removeOne(frame); + return; + } + else + { + frame->move(frame->getPreviousPosition()); + return; + } } } } @@ -1027,7 +1030,7 @@ void MainWindow::onClientAuthenticated(Client* client) y = 0; qDebug("Move E"); cf->move(x * _tileWidth, y * _tileHeight); - onPlaceFrame(cf); + onPlaceFrame(true, cf); } else { diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index acecc28..1990fe6 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -111,7 +111,7 @@ protected slots: void DisableButtons(); void EnableButtons(); // connection frame - void onPlaceFrame(ConnectionFrame* frame); + void onPlaceFrame(bool activateTrash, ConnectionFrame* frame); void onFrameClicked(ConnectionFrame* frame); // Net void onClientConnected(Client* client); |