summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-04-27 18:34:13 +0200
committerChristian Klinger2016-04-27 18:34:13 +0200
commite3130a1c53676e090c9af4bc6234c9688865438b (patch)
tree0478bce41e34c060c11d1a59a7a6f05de72ec84e /src/server/mainwindow/mainwindow.cpp
parentdelete button in the toolbar. (diff)
downloadpvs2-e3130a1c53676e090c9af4bc6234c9688865438b.tar.gz
pvs2-e3130a1c53676e090c9af4bc6234c9688865438b.tar.xz
pvs2-e3130a1c53676e090c9af4bc6234c9688865438b.zip
lock/unlocking of context-sensitive buttons.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 3719d2a..67dee8a 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -112,6 +112,15 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
connect(ui->actionReload_Room_Configuration, SIGNAL(triggered()), this, SLOT(onButtonReloadRoomConfig()));
connect(ui->action_DeleteClient, SIGNAL(triggered()), this, SLOT(onDeleteClient()));
+ /* disable context-sensitive buttons by default */
+ _contextButtons
+ << ui->action_DeleteClient
+ << ui->action_StudentToTutor
+ << ui->action_StudentToTutorExclusive
+ << ui->action_SetAsTutor;
+
+ lockContextButtons();
+
/* Stuff for the button lock */
//Setup a timeout
_buttonLockTimer = new QTimer(this);
@@ -235,8 +244,9 @@ ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint pxCoord, QPo
{
// Allocate and resize
Room* room = Global::getRooms()[Global::getCurrentRoom()];
- int width = getTileWidthPx() * room->clientSize.width();
- int height = getTileHeightPx() * room->clientSize.height();
+ qDebug() << "createFrame, access room: " << room;
+ int width = getTileWidthPx() * (room == NULL ? 1 : room->clientSize.width());
+ int height = getTileHeightPx() * (room == NULL ? 1 : room->clientSize.height());
ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height);
cf->setComputerId(computerId);
@@ -555,6 +565,20 @@ void MainWindow::resizeEvent(QResizeEvent* e)
}
}
+
+void MainWindow::lockContextButtons() {
+ qDebug() << "LOCK";
+ for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
+ (*it)->setEnabled(false);
+ }
+}
+
+void MainWindow::unlockContextButtons() {
+ qDebug() << "UNLOCK";
+ for (auto it = _contextButtons.begin(); it != _contextButtons.end(); ++it) {
+ (*it)->setEnabled(true);
+ }
+}
/***************************************************************************//**
* Handle Mouse Release Event.
* Check if click was inside the frame and if that is the case, set the selection of each connected
@@ -572,6 +596,7 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e)
const QSize frame(ui->frmRoom->size());
if (frame.width() > pos.x() && frame.height() > pos.y())
{
+ lockContextButtons();
if (getSelectedFrame() != NULL)
{
getSelectedFrame()->setSelection(false);
@@ -667,6 +692,8 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
frame->setSelection(true);
qDebug() << "ID of frame: " << frame->computerId();
qDebug() << "ID of selectedFrame: " << getSelectedFrame()->computerId();
+
+ unlockContextButtons();
}
/***************************************************************************//**
@@ -1307,6 +1334,7 @@ void MainWindow::onVncClientStateChange(Client* client)
*/
void MainWindow::DisableButtons()
{
+ qDebug() << "DisableButtons()";
_buttonLockTimer->start();
foreach (QAction* a, _lockingButtons)
a->setDisabled(true);
@@ -1317,6 +1345,7 @@ void MainWindow::DisableButtons()
*/
void MainWindow::EnableButtons()
{
+ qDebug() << "EnableButtons()";
_buttonLockTimer->stop();
foreach (QAction* a, _lockingButtons)
a->setEnabled(true);
@@ -1340,6 +1369,7 @@ void MainWindow::onDeleteClient() {
frame->hide();
frame->deleteLater();
_clientFrames.removeOne(frame);
+ lockContextButtons();
return;
} else {
frame->move(frame->getPreviousPosition());