From 0a2dfff7f51fa484d4a05067bddd847803227846 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Fri, 16 May 2014 13:54:46 +0200 Subject: 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 --- gui/server_normal/mainwindow.ui | 16 +++----- src/server/mainwindow/mainwindow.cpp | 79 ++++++------------------------------ src/server/mainwindow/mainwindow.h | 2 - 3 files changed, 18 insertions(+), 79 deletions(-) diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui index 22e1b45..fab8440 100644 --- a/gui/server_normal/mainwindow.ui +++ b/gui/server_normal/mainwindow.ui @@ -53,12 +53,6 @@ - - - 129000 - 12900 - - toolBar @@ -71,11 +65,11 @@ false - - Qt::ToolButtonIconOnly - - - false + + + 64 + 64 + LeftToolBarArea 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::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::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 diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 5dd177d..d688b5e 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -47,7 +47,6 @@ private: // Internal stuff QList _clientFrames; - int _timerId, _timerTimeout; ListenServer *_listenServer; DiscoveryListener *_discoveryListener; FileDownloader _fileDownloader; @@ -75,7 +74,6 @@ private: void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *e); void mouseReleaseEvent(QMouseEvent* e); - void timerEvent(QTimerEvent* event); protected slots: -- cgit v1.2.3-55-g7522