diff options
author | Manuel Schneider | 2014-05-16 13:54:46 +0200 |
---|---|---|
committer | Manuel Schneider | 2014-05-16 13:54:46 +0200 |
commit | 0a2dfff7f51fa484d4a05067bddd847803227846 (patch) | |
tree | 917854bcd0e866824ff4a3562837d0671ba668d3 /src/server/mainwindow/mainwindow.cpp | |
parent | Several changes: (diff) | |
download | pvs2-0a2dfff7f51fa484d4a05067bddd847803227846.tar.gz pvs2-0a2dfff7f51fa484d4a05067bddd847803227846.tar.xz pvs2-0a2dfff7f51fa484d4a05067bddd847803227846.zip |
Make toolbar static on left side
* Redudce unnecessary codebase by dropping curious nested timerId & timerTimeout
* Use the resizeEvent properly
* Make size of buttons static
* Drop unnecesary ui properties
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 79 |
1 files changed, 13 insertions, 66 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index ca9ecca..e7b5148 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -36,6 +36,7 @@ // Auto-generated ui class #include "ui_mainwindow.h" + const QString MainWindow::sStrTutorNdef = tr("No tutor defined."); const QString MainWindow::sStrTutorOffline = tr("Tutor is offline."); const QString MainWindow::sStrSourceNdef = tr("Please select a projection source."); @@ -130,17 +131,12 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : _tileWidth = 10; _tileHeight = 10; - _timerId = 0; - _timerTimeout = 0; - _listenServer = new ListenServer(CLIENT_PORT); connect(_listenServer, SIGNAL(newClient(Client*)), this, SLOT(onClientConnected(Client*))); _discoveryListener = new DiscoveryListener(); // Finally this->onSessionNameUpdate(); - _timerId = startTimer(10); - _timerTimeout = 8; } MainWindow::~MainWindow() @@ -289,12 +285,20 @@ void MainWindow::changeEvent(QEvent* e) */ void MainWindow::resizeEvent(QResizeEvent* e) { - QMainWindow::resizeEvent(e); - if (_timerId == 0) + // Resize all connection windows + if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100 || _tilesX <= 0 || _tilesY <= 0) + return; + const int nw = ui->frmRoom->size().width() / _tilesX; + const int nh = ui->frmRoom->size().height() / _tilesY; + for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it) { - _timerId = startTimer(5); + const QPoint &oldpos = (*it)->frameGeometry().topLeft(); + qDebug("Move C"); + (*it)->move((oldpos.x() / _tileWidth) * nw, (oldpos.y() / _tileHeight) * nh); + (*it)->setSize(nw, nh); } - _timerTimeout = 8; + _tileWidth = nw; + _tileHeight = nh; } /***************************************************************************//** @@ -321,63 +325,6 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) } } -/***************************************************************************//** - * Handle TimerEvent. - * If timerId of event equals _timerId reduce _timerTimeout by 1. - * If _timerTimeout equals 1 move toolbar if necessary, otherwise kill timer. - * @param event - */ -void MainWindow::timerEvent(QTimerEvent* event) -{ - if (event->timerId() == _timerId) - { - _timerTimeout -= 1; - if (_timerTimeout == 1) - { - // Move toolbar if necessary - const int iconSize = this->size().width() / 30 + 14; - const int barSpace = ui->toolBar->actions().size() * (iconSize + 8); - const Qt::ToolBarArea area = - (barSpace < this->size().height() ? Qt::LeftToolBarArea : Qt::TopToolBarArea); - if (_tbIconSize != iconSize) - { - _tbIconSize = iconSize; - ui->toolBar->setIconSize(QSize(iconSize, iconSize)); - } - if (_tbArea != area) - { - _tbArea = area; - this->addToolBar(area, ui->toolBar); - } - return; - } - // Kill timer when done - if (_timerTimeout <= 0) - { - killTimer(_timerId); - _timerId = 0; - // Resize all connection windows - if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100 || _tilesX <= 0 || _tilesY <= 0) - return; - const int nw = ui->frmRoom->size().width() / _tilesX; - const int nh = ui->frmRoom->size().height() / _tilesY; - for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it) - { - const QPoint &oldpos = (*it)->frameGeometry().topLeft(); - qDebug("Move C"); - (*it)->move((oldpos.x() / _tileWidth) * nw, (oldpos.y() / _tileHeight) * nh); - (*it)->setSize(nw, nh); - } - _tileWidth = nw; - _tileHeight = nh; - } - } - else - { - // Unknown timer ID, kill - killTimer(event->timerId()); - } -} /* * Slots |