X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=ecdeb9817914276c59c1ed4f00a2c703a41bcee7;hb=6721aa2039d9e4e7af548a03aabbb4f73483de0d;hp=334c5c1b7fa72b8db45cb552736fcf07becc58af;hpb=83efa7dcd9771008e7600b4c35db0dde6e0bc995;p=quassel.git diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 334c5c1b..ecdeb981 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -26,6 +26,7 @@ # include # include # include +# include # include # include #endif @@ -46,7 +47,6 @@ #include "bufferviewoverlayfilter.h" #include "bufferwidget.h" #include "channellistdlg.h" -#include "chatlinemodel.h" #include "chatmonitorfilter.h" #include "chatmonitorview.h" #include "chatview.h" @@ -70,6 +70,7 @@ #include "irclistmodel.h" #include "ircconnectionwizard.h" #include "legacysystemtray.h" +#include "messagemodel.h" #include "msgprocessorstatuswidget.h" #include "nicklistwidget.h" #include "qtuiapplication.h" @@ -184,6 +185,7 @@ void MainWin::init() { setupNickWidget(); setupInputWidget(); setupChatMonitor(); + setupViewMenuTail(); setupStatusBar(); setupToolBars(); setupSystray(); @@ -340,17 +342,41 @@ void MainWin::setupActions() { coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll, 0, 0))->setCheckable(true); +#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, @@ -425,7 +451,11 @@ void MainWin::setupActions() { coll->addAction("NextBufferView", new Action(SmallIcon("go-next-view"), tr("Activate Next Chat List"), coll, this, SLOT(nextBufferView()), QKeySequence(QKeySequence::Forward))); coll->addAction("PreviousBufferView", new Action(SmallIcon("go-previous-view"), tr("Activate Previous Chat List"), coll, - this, SLOT(previousBufferView()), QKeySequence(QKeySequence::Back))); + this, SLOT(previousBufferView()), QKeySequence::Back)); + coll->addAction("NextBuffer", new Action(SmallIcon("go-down"), tr("Go to Next Chat"), coll, + 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))); } void MainWin::setupMenus() { @@ -671,6 +701,18 @@ void MainWin::previousBufferView() { changeActiveBufferView(true); } +void MainWin::nextBuffer() { + BufferView *view = activeBufferView(); + if(view) + view->nextBuffer(); +} + +void MainWin::previousBuffer() { + BufferView *view = activeBufferView(); + if(view) + view->previousBuffer(); +} + void MainWin::showNotificationsDlg() { SettingsPageDlg dlg(new NotificationsSettingsPage(this), this); dlg.exec(); @@ -721,6 +763,8 @@ void MainWin::setupNickWidget() { } void MainWin::setupChatMonitor() { +// FIXME QML +#ifndef HAVE_QML VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this); dock->setObjectName("ChatMonitorDock"); @@ -734,6 +778,7 @@ void MainWin::setupChatMonitor() { addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical); _viewMenu->addAction(dock->toggleViewAction()); dock->toggleViewAction()->setText(tr("Show Chat Monitor")); +#endif } void MainWin::setupInputWidget() { @@ -774,6 +819,11 @@ void MainWin::setupTopicWidget() { dock->toggleViewAction()->setText(tr("Show Topic Line")); } +void MainWin::setupViewMenuTail() { + _viewMenu->addSeparator(); + _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullscreen")); +} + void MainWin::setupTitleSetter() { _titleSetter.setModel(Client::bufferModel()); _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel()); @@ -896,10 +946,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); + } } } @@ -952,7 +1005,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(); } @@ -1142,6 +1202,13 @@ void MainWin::showShortcutsDlg() { #endif } +void MainWin::toggleFullscreen() { + if(isFullScreen()) + showNormal(); + else + showFullScreen(); +} + /********************************************************************************************************/ bool MainWin::event(QEvent *event) { @@ -1186,16 +1253,16 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { bool hasFocus = QApplication::activeWindow() != 0; for(int i = start; i <= end; i++) { - QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn); + QModelIndex idx = Client::messageModel()->index(i, MessageModel::ContentsColumn); if(!idx.isValid()) { qDebug() << "MainWin::messagesInserted(): Invalid model index!"; continue; } - Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt(); + Message::Flags flags = (Message::Flags)idx.data(MessageModel::FlagsRole).toInt(); if(flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self)) continue; - BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value(); + BufferId bufId = idx.data(MessageModel::BufferIdRole).value(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); if(hasFocus && bufId == Client::bufferModel()->currentBuffer()) @@ -1205,9 +1272,9 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { && !(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value(), Client::networkModel()->networkName(bufId)))) { - QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); - QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); - QString contents = idx.data(ChatLineModel::DisplayRole).toString(); + QModelIndex senderIdx = Client::messageModel()->index(i, MessageModel::SenderColumn); + QString sender = senderIdx.data(MessageModel::EditRole).toString(); + QString contents = idx.data(MessageModel::DisplayRole).toString(); AbstractNotificationBackend::NotificationType type; if(bufType == BufferInfo::QueryBuffer && !hasFocus) @@ -1263,6 +1330,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"));