/***************************************************************************
- * Copyright (C) 2005-2010 by the Quassel Project *
+ * Copyright (C) 2005-2012 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
***************************************************************************/
#include "mainwin.h"
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QStatusBar>
+#include <QToolBar>
+
#ifdef HAVE_KDE
# include <KAction>
# include <KActionCollection>
# include <KMenuBar>
# include <KShortcutsDialog>
# include <KStatusBar>
+# include <KToggleFullScreenAction>
# include <KToolBar>
# include <KWindowSystem>
#endif
setupNickWidget();
setupInputWidget();
setupChatMonitor();
+ setupViewMenuTail();
setupStatusBar();
setupToolBars();
setupSystray();
if(Client::isConnected())
icon = DesktopIcon("quassel", size);
else
- icon = DesktopIcon("quassel_inactive", size);
+ icon = DesktopIcon("quassel-inactive", size);
setWindowIcon(icon);
qApp->setWindowIcon(icon);
}
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,
coll->addAction("ReloadStyle", new Action(SmallIcon("view-refresh"), tr("Reload Stylesheet"), coll,
QtUi::style(), SLOT(reload()), QKeySequence::Refresh));
+ coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
+ this, SLOT(hideCurrentBuffer()), QKeySequence::Close));
+
// Navigation
coll = QtUi::actionCollection("Navigation", tr("Navigation"));
view->previousBuffer();
}
+void MainWin::hideCurrentBuffer() {
+ BufferView *view = activeBufferView();
+ if(view)
+ view->hideCurrentBuffer();
+}
+
void MainWin::showNotificationsDlg() {
SettingsPageDlg dlg(new NotificationsSettingsPage(this), this);
dlg.exec();
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());
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);
+ }
}
}
}
}
+ // 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();
}
#endif
}
+void MainWin::toggleFullscreen() {
+ if(isFullScreen())
+ showNormal();
+ else
+ showFullScreen();
+}
+
/********************************************************************************************************/
bool MainWin::event(QEvent *event) {
BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
+ // check if bufferId belongs to the shown chatlists
+ if(!(Client::bufferViewOverlay()->bufferIds().contains(bufId) ||
+ Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId)))
+ continue;
+
+ // check if it's the buffer currently displayed
if(hasFocus && bufId == Client::bufferModel()->currentBuffer())
continue;
- if((flags & Message::Highlight || bufType == BufferInfo::QueryBuffer)
- && !(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(),
- 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();
- AbstractNotificationBackend::NotificationType type;
-
- if(bufType == BufferInfo::QueryBuffer && !hasFocus)
- type = AbstractNotificationBackend::PrivMsg;
- else if(bufType == BufferInfo::QueryBuffer && hasFocus)
- type = AbstractNotificationBackend::PrivMsgFocused;
- else if(flags & Message::Highlight && !hasFocus)
- type = AbstractNotificationBackend::Highlight;
- else
- type = AbstractNotificationBackend::HighlightFocused;
-
- QtUi::instance()->invokeNotification(bufId, type, sender, contents);
- }
+ // only show notifications for higlights or queries
+ if(bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight))
+ continue;
+
+ // and of course: don't notify for ignored messages
+ if(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(), Client::networkModel()->networkName(bufId)))
+ continue;
+
+ // seems like we have a legit notification candidate!
+ QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
+ QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
+ QString contents = idx.data(ChatLineModel::DisplayRole).toString();
+ AbstractNotificationBackend::NotificationType type;
+
+ if(bufType == BufferInfo::QueryBuffer && !hasFocus)
+ type = AbstractNotificationBackend::PrivMsg;
+ else if(bufType == BufferInfo::QueryBuffer && hasFocus)
+ type = AbstractNotificationBackend::PrivMsgFocused;
+ else if(flags & Message::Highlight && !hasFocus)
+ type = AbstractNotificationBackend::Highlight;
+ else
+ type = AbstractNotificationBackend::HighlightFocused;
+
+ QtUi::instance()->invokeNotification(bufId, type, sender, contents);
}
}
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<BufferId>();
+ Client::bufferModel()->switchToBuffer(statusBufferId);
+ }
+ }
break;
case Network::Disconnected:
action->setIcon(SmallIcon("network-disconnect"));