X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=f31354c7f8bd8dd4fb11712731c2e9bae509d565;hp=2c9e0f74eeb09f3e6d0552af7dc727c329fda546;hb=fed4298befe8e00a082b9f96bc166368faffb54b;hpb=c230f7bd892b78b09710cf5746c2bf12a73d6b9b diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 2c9e0f74..f31354c7 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -37,6 +37,7 @@ #include "awaylogview.h" #include "action.h" #include "actioncollection.h" +#include "bufferhotlistfilter.h" #include "buffermodel.h" #include "bufferview.h" #include "bufferviewoverlay.h" @@ -58,6 +59,7 @@ #include "debugbufferviewoverlay.h" #include "debuglogwidget.h" #include "debugmessagemodelfilter.h" +#include "flatproxymodel.h" #include "iconloader.h" #include "inputwidget.h" #include "inputline.h" @@ -133,8 +135,6 @@ MainWin::MainWin(QWidget *parent) installEventFilter(new JumpKeyHandler(this)); QtUiApplication* app = qobject_cast qApp; - connect(app, SIGNAL(saveStateToSession(const QString&)), SLOT(saveStateToSession(const QString&))); - connect(app, SIGNAL(saveStateToSessionSettings(SessionSettings&)), SLOT(saveStateToSessionSettings(SessionSettings&))); connect(app, SIGNAL(aboutToQuit()), SLOT(aboutToQuit())); } @@ -165,6 +165,7 @@ void MainWin::init() { setupToolBars(); setupSystray(); setupTitleSetter(); + setupHotList(); #ifndef HAVE_KDE QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); @@ -211,15 +212,21 @@ void MainWin::saveStateToSettings(UiSettings &s) { s.setValue("MainWinState", saveState()); s.setValue("MainWinGeometry", saveGeometry()); s.setValue("MainWinMinimized", isMinimized()); + s.setValue("MainWinMaximized", isMaximized()); s.setValue("MainWinHidden", _isHidden); } void MainWin::restoreStateFromSettings(UiSettings &s) { + _normalSize = s.value("MainWinSize", size()).toSize(); + _normalPos = s.value("MainWinPos", pos()).toPoint(); + bool maximized = s.value("MainWinMaximized", false).toBool(); + restoreGeometry(s.value("MainWinGeometry").toByteArray()); - if(isMaximized()) { + + if(maximized) { // restoreGeometry() fails if the windows was maximized, so we resize and position explicitly - resize(s.value("MainWinSize", QSize(800, 500)).toSize()); - move(s.value("MainWinPos").toPoint()); + resize(_normalSize); + move(_normalPos); } restoreState(s.value("MainWinState").toByteArray()); @@ -229,6 +236,8 @@ void MainWin::restoreStateFromSettings(UiSettings &s) { hideToTray(); else if(s.value("MainWinMinimized").toBool()) showMinimized(); + else if(maximized) + showMaximized(); else show(); } @@ -293,8 +302,14 @@ void MainWin::setupActions() { this, SLOT(on_actionDebugBufferViewOverlay_triggered()))); coll->addAction("DebugMessageModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &MessageModel"), coll, this, SLOT(on_actionDebugMessageModel_triggered()))); + coll->addAction("DebugHotList", new Action(SmallIcon("tools-report-bug"), tr("Debug &HotList"), coll, + this, SLOT(on_actionDebugHotList_triggered()))); coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll, this, SLOT(on_actionDebugLog_triggered()))); + + // Navigation + coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot buffer"), coll, + this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A))); } void MainWin::setupMenus() { @@ -353,6 +368,7 @@ void MainWin::setupMenus() { _helpDebugMenu->addAction(coll->action("DebugNetworkModel")); _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay")); _helpDebugMenu->addAction(coll->action("DebugMessageModel")); + _helpDebugMenu->addAction(coll->action("DebugHotList")); _helpDebugMenu->addAction(coll->action("DebugLog")); } @@ -576,6 +592,12 @@ void MainWin::setupStatusBar() { connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool))); } +void MainWin::setupHotList() { + FlatProxyModel *flatProxy = new FlatProxyModel(this); + flatProxy->setSourceModel(Client::bufferModel()); + _bufferHotList = new BufferHotListFilter(flatProxy); +} + void MainWin::saveStatusBarStatus(bool enabled) { QtUiSettings uiSettings; uiSettings.setValue("ShowStatusBar", enabled); @@ -810,22 +832,22 @@ void MainWin::moveEvent(QMoveEvent *event) { if(!(windowState() & Qt::WindowMaximized)) _normalPos = event->pos(); - event->ignore(); + QMainWindow::moveEvent(event); } void MainWin::resizeEvent(QResizeEvent *event) { if(!(windowState() & Qt::WindowMaximized)) _normalSize = event->size(); - event->ignore(); + QMainWindow::resizeEvent(event); } void MainWin::closeEvent(QCloseEvent *event) { QtUiSettings s; QtUiApplication* app = qobject_cast qApp; Q_ASSERT(app); - if(!app->aboutToQuit() && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { - toggleMinimizedToTray(); + if(!app->isAboutToQuit() && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { + hideToTray(); event->ignore(); } else { event->accept(); @@ -834,23 +856,12 @@ void MainWin::closeEvent(QCloseEvent *event) { } void MainWin::changeEvent(QEvent *event) { - if(event->type() == QEvent::WindowStateChange) { - if(windowState() & Qt::WindowMinimized) { - QtUiSettings s; - if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) { - hideToTray(); - event->accept(); - return; - } - } - } - #ifdef Q_WS_WIN - else if(event->type() == QEvent::ActivationChange) + if(event->type() == QEvent::ActivationChange) dwTickCount = GetTickCount(); // needed for toggleMinimizedToTray() #endif - event->ignore(); + QMainWindow::changeEvent(event); } void MainWin::hideToTray() { @@ -897,7 +908,8 @@ void MainWin::forceActivated() { setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); } - move(frameGeometry().topLeft()); // avoid placement policies + // this does not actually work on all platforms... and causes more evil than good + // move(frameGeometry().topLeft()); // avoid placement policies show(); raise(); activateWindow(); @@ -1007,6 +1019,15 @@ void MainWin::connectOrDisconnectFromNet() { else net->requestDisconnect(); } +void MainWin::on_jumpHotBuffer_triggered() { + if(!_bufferHotList->rowCount()) + return; + + QModelIndex topIndex = _bufferHotList->index(0, 0); + BufferId bufferId = _bufferHotList->data(topIndex, NetworkModel::BufferIdRole).value(); + Client::bufferModel()->switchToBuffer(bufferId); +} + void MainWin::on_actionDebugNetworkModel_triggered() { QTreeView *view = new QTreeView; view->setAttribute(Qt::WA_DeleteOnClose); @@ -1019,6 +1040,13 @@ void MainWin::on_actionDebugNetworkModel_triggered() { view->show(); } +void MainWin::on_actionDebugHotList_triggered() { + QTreeView *view = new QTreeView; + view->setAttribute(Qt::WA_DeleteOnClose); + view->setModel(_bufferHotList); + view->show(); +} + void MainWin::on_actionDebugBufferViewOverlay_triggered() { DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(0); overlay->setAttribute(Qt::WA_DeleteOnClose); @@ -1041,24 +1069,6 @@ void MainWin::on_actionDebugLog_triggered() { logWidget->show(); } -// FIXME -void MainWin::saveStateToSession(const QString &sessionId) { - return; - SessionSettings s(sessionId); - - s.setValue("MainWinSize", size()); - s.setValue("MainWinPos", pos()); - s.setValue("MainWinState", saveState()); -} - -// FIXME -void MainWin::saveStateToSessionSettings(SessionSettings & s) -{ - s.setValue("MainWinSize", size()); - s.setValue("MainWinPos", pos()); - s.setValue("MainWinState", saveState()); -} - void MainWin::showStatusBarMessage(const QString &message) { statusBar()->showMessage(message, 10000); }