From e5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Thu, 19 Jun 2014 15:28:50 +0200 Subject: NEW feature: Possible to delete offline client by drag and drop to trash, which is positioned in the right bottom corner of manager. --- gui/server_normal/mainwindow.ui | 29 +- icons/trash.svg | 1187 ++++++++++++++++++++++++++ pvsmgr.qrc | 1 + src/server/connectionframe/connectionframe.h | 1 + src/server/mainwindow/mainwindow.cpp | 47 +- src/server/mainwindow/mainwindow.h | 2 + 6 files changed, 1260 insertions(+), 7 deletions(-) create mode 100644 icons/trash.svg diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui index 6d29c97..8ab1c05 100644 --- a/gui/server_normal/mainwindow.ui +++ b/gui/server_normal/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 838 - 607 + 1246 + 858 @@ -46,6 +46,28 @@ 2 + + + + 10 + 10 + 111 + 121 + + + + false + + + + + + :/trash + + + true + + @@ -181,7 +203,7 @@ - + :/reset:/reset @@ -218,7 +240,6 @@ - diff --git a/icons/trash.svg b/icons/trash.svg new file mode 100644 index 0000000..e217a09 --- /dev/null +++ b/icons/trash.svg @@ -0,0 +1,1187 @@ + + + + + trash + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + trash + + + hrum + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pvsmgr.qrc b/pvsmgr.qrc index 3837cee..40df258 100644 --- a/pvsmgr.qrc +++ b/pvsmgr.qrc @@ -15,6 +15,7 @@ icons/keyboard_key.svg icons/student2tutor_extension.svg icons/help.svg + icons/trash.svg AUTHORS TRANSLATION build/pvsmgr_de_DE.qm diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 353ebb8..5a4e1df 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -51,6 +51,7 @@ public: const QPixmap& getFramePixmap() const { return _remoteScreen; } void setSize(int width, int height); + const inline QPoint& getPreviousPosition() const { return _previousPosition; } void assignClient(Client *client); void setSelection(bool selected); const inline bool isSelected() const { return _isSelected; } diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index bbabc66..a52690f 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -44,6 +44,8 @@ const QString MainWindow::sStrSourceOffline = tr("The projection source is offli const QString MainWindow::sStrDestNdef = tr("Please select a projection destination."); const QString MainWindow::sStrDestOffline = tr("The projection destination is offline."); const QString MainWindow::sStrSourceDestSame = tr("Selected projection target is tutor."); +const QString MainWindow::sStrClientOnline = tr("Selected client is currently online."); +const QString MainWindow::sStrNoDestAv = tr("No projection destination available."); /***************************************************************************//** * Initialize MainWindow and ListenServer. @@ -78,6 +80,9 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : ui->action_Exit->setStatusTip(tr("Exit")); ui->action_Lock->setStatusTip(tr("Lock or Unlock all Clients")); + _tileWidth = 10; + _tileHeight = 10; + // Initialize FileDownloader. if (!ipListUrl.isEmpty()) { @@ -125,9 +130,6 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : setUnifiedTitleAndToolBarOnMac(true); this->showMaximized(); // show the Mainwindow maximized - _tileWidth = 10; - _tileHeight = 10; - _listenServer = new ListenServer(CLIENT_PORT); connect(_listenServer, SIGNAL(newClient(Client*)), this, SLOT(onClientConnected(Client*))); _discoveryListener = new DiscoveryListener(); @@ -369,6 +371,14 @@ void MainWindow::resizeEvent(QResizeEvent* e) (*it)->move((oldpos.x() / _tileWidth) * nw, (oldpos.y() / _tileHeight) * nh); (*it)->setSize(nw, nh); } + + // Resize trash and set position. + const int width = ui->frmRoom->geometry().width() - (nw + 1); + const int height = ui->frmRoom->geometry().height() - (nh + 1); + ui->trash->move(width, height); + ui->trash->resize(nw, nh); + // qDebug() << "Trash pos: " << ui->trash->pos(); + _tileWidth = nw; _tileHeight = nh; } @@ -449,6 +459,35 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) y = 0; 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)) + { + // Do not offer deleting online client. + if (frame->client() != NULL) + { + QMessageBox::critical(this, tr("Selection"), sStrClientOnline); + frame->move(frame->getPreviousPosition()); + return; + } + else + { + 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; + } + } + } qDebug("Move D"); frame->move(x, y); savePosition(frame); @@ -600,6 +639,8 @@ void MainWindow::onButtonTutorToAll() QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); + else if (_clientFrames.size() == 1) + QMessageBox::critical(this, tr("Projection"), sStrNoDestAv); else changeProjection(getTutorFrame()->client(), Mode::Broadcast); } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 851dc84..524a0b1 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -69,6 +69,8 @@ private: static const QString sStrDestNdef; static const QString sStrDestOffline; static const QString sStrSourceDestSame; + static const QString sStrClientOnline; + static const QString sStrNoDestAv; void placeFrameInFreeSlot(ConnectionFrame* frame); ConnectionFrame* createFrame(); -- cgit v1.2.3-55-g7522