From e3130a1c53676e090c9af4bc6234c9688865438b Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Wed, 27 Apr 2016 18:34:13 +0200 Subject: lock/unlocking of context-sensitive buttons. --- src/server/mainwindow/mainwindow.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') 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()); -- cgit v1.2.3-55-g7522