From 254c7fb41a96f42ef4049d5a495e47fad2e3e983 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 29 Jul 2014 15:31:56 +0200 Subject: Fixed bug, that frame moved on (0,0) is asked to be deleted. --- src/server/mainwindow/mainwindow.cpp | 51 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') 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 { -- cgit v1.2.3-55-g7522