summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-06-19 15:28:50 +0200
committerBjörn Hagemeister2014-06-19 15:28:50 +0200
commite5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b (patch)
tree8bfb349231269ead74ee7407f2a1a587113123f1 /src/server/mainwindow/mainwindow.cpp
parentDelete connected clients and connectionFrames after sessionName has changed. (diff)
downloadpvs2-e5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b.tar.gz
pvs2-e5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b.tar.xz
pvs2-e5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b.zip
NEW feature: Possible to delete offline client by drag and drop to trash, which is positioned in the right bottom corner of manager.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp47
1 files changed, 44 insertions, 3 deletions
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);
}