X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=f40aa9c9a5af24c12d1f3dac13fa77cc4b40064c;hp=398f0a836600c8a64a2721f30b84d27a00635634;hb=9f33f6e471dedbefe7bbe336a40312894628afe1;hpb=15d94f850d7e82b9f9f65ec162d9db13f750d23f diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 398f0a83..f40aa9c9 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -26,6 +26,7 @@ # include # include # include +# include # include # include #endif @@ -340,20 +341,42 @@ void MainWin::setupActions() { coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll, 0, 0))->setCheckable(true); - coll->addAction("ToggleFullscreen", new Action(SmallIcon("window_fullscreen"), tr("&Fullscreen mode"), coll, - this, SLOT(toggleFullscreen()), QKeySequence(Qt::Key_F11))); + +#ifdef HAVE_KDE + QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(toggleFullscreen()), this, coll); +#else + QAction *fullScreenAct = new Action(SmallIcon("view-fullscreen"), tr("&Full Screen Mode"), coll, + this, SLOT(toggleFullscreen()), QKeySequence(Qt::Key_F11)); + fullScreenAct->setCheckable(true); +#endif + coll->addAction("ToggleFullscreen", fullScreenAct); // Settings - coll->addAction("ConfigureShortcuts", new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll, - this, SLOT(showShortcutsDlg()))); - coll->addAction("ConfigureQuassel", new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll, - this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7))); + QAction *configureShortcutsAct = new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll, + this, SLOT(showShortcutsDlg())); + configureShortcutsAct->setMenuRole(QAction::NoRole); + coll->addAction("ConfigureShortcuts", configureShortcutsAct); + + #ifdef Q_WS_MAC + QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll, + this, SLOT(showSettingsDlg())); + configureQuasselAct->setMenuRole(QAction::PreferencesRole); + #else + QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll, + this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7)); + #endif + coll->addAction("ConfigureQuassel", configureQuasselAct); // Help - coll->addAction("AboutQuassel", new Action(SmallIcon("quassel"), tr("&About Quassel"), coll, - this, SLOT(showAboutDlg()))); - coll->addAction("AboutQt", new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll, - qApp, SLOT(aboutQt()))); + QAction *aboutQuasselAct = new Action(SmallIcon("quassel"), tr("&About Quassel"), coll, + this, SLOT(showAboutDlg())); + aboutQuasselAct->setMenuRole(QAction::AboutRole); + coll->addAction("AboutQuassel", aboutQuasselAct); + + QAction *aboutQtAct = new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll, + qApp, SLOT(aboutQt())); + aboutQtAct->setMenuRole(QAction::AboutQtRole); + coll->addAction("AboutQt", aboutQtAct); coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll, this, SLOT(on_actionDebugNetworkModel_triggered()))); coll->addAction("DebugBufferViewOverlay", new Action(SmallIcon("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll, @@ -433,6 +456,8 @@ void MainWin::setupActions() { this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down))); coll->addAction("PreviousBuffer", new Action(SmallIcon("go-up"), tr("Go to Previous Chat"), coll, this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up))); + coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll, + this, SLOT(hideCurrentBuffer()), QKeySequence(Qt::ControlModifier + Qt::Key_W))); } void MainWin::setupMenus() { @@ -690,6 +715,12 @@ void MainWin::previousBuffer() { view->previousBuffer(); } +void MainWin::hideCurrentBuffer() { + BufferView *view = activeBufferView(); + if(view) + view->hideCurrentBuffer(); +} + void MainWin::showNotificationsDlg() { SettingsPageDlg dlg(new NotificationsSettingsPage(this), this); dlg.exec(); @@ -920,10 +951,13 @@ void MainWin::setConnectedState() { wizard->show(); } else { - QtUiSettings s; - BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt()); - if(lastUsedBufferId.isValid()) - Client::bufferModel()->switchToBuffer(lastUsedBufferId); + // Monolithic always preselects last used buffer - Client only if the connection died + if(Client::coreConnection()->wasReconnect() || Quassel::runMode() == Quassel::Monolithic) { + QtUiSettings s; + BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt()); + if(lastUsedBufferId.isValid()) + Client::bufferModel()->switchToBuffer(lastUsedBufferId); + } } } @@ -976,7 +1010,14 @@ void MainWin::disconnectedFromCore() { } } + // store last active buffer QtUiSettings s; + BufferId lastBufId = _bufferWidget->currentBuffer(); + if(lastBufId.isValid()) { + s.setValue("LastUsedBufferId", lastBufId.toInt()); + // clear the current selection + Client::bufferModel()->standardSelectionModel()->clearSelection(); + } restoreState(s.value("MainWinState").toByteArray()); setDisconnectedState(); } @@ -1167,18 +1208,10 @@ void MainWin::showShortcutsDlg() { } void MainWin::toggleFullscreen() { - QAction *action = QtUi::actionCollection("General")->action("ToggleFullscreen"); - - if(isFullScreen()) { + if(isFullScreen()) showNormal(); - action->setIcon(SmallIcon("window_fullscreen")); - action->setText(tr("&Fullscreen mode")); - } - else { + else showFullScreen(); - action->setIcon(SmallIcon("window_nofullscreen")); - action->setText(tr("&Normal mode")); - } } /********************************************************************************************************/ @@ -1302,6 +1335,14 @@ void MainWin::clientNetworkUpdated() { switch(net->connectionState()) { case Network::Initialized: action->setIcon(SmallIcon("network-connect")); + // if we have no currently selected buffer, jump to the first connecting statusbuffer + if(!bufferWidget()->currentBuffer().isValid()) { + QModelIndex idx = Client::networkModel()->networkIndex(net->networkId()); + if(idx.isValid()) { + BufferId statusBufferId = idx.data(NetworkModel::BufferIdRole).value(); + Client::bufferModel()->switchToBuffer(statusBufferId); + } + } break; case Network::Disconnected: action->setIcon(SmallIcon("network-disconnect"));