/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#endif
#include "aboutdlg.h"
+#include "awaylogfilter.h"
+#include "awaylogview.h"
#include "action.h"
#include "actioncollection.h"
#include "buffermodel.h"
#include "clientbacklogmanager.h"
#include "coreinfodlg.h"
#include "coreconnectdlg.h"
+#include "contextmenuactionprovider.h"
#include "debuglogwidget.h"
#include "debugmessagemodelfilter.h"
#include "iconloader.h"
sslLabel(new QLabel()),
msgProcessorStatusWidget(new MsgProcessorStatusWidget()),
_titleSetter(this),
- _trayIcon(new QSystemTrayIcon(this))
+ _trayIcon(new QSystemTrayIcon(this)),
+ _awayLog(0)
{
QtUiSettings uiSettings;
QString style = uiSettings.value("Style", QString()).toString();
connect(QApplication::instance(), SIGNAL(aboutToQuit()), SLOT(saveLayout()));
connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
- connect(Client::mainUi()->actionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
+ connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
// Setup Dock Areas
setDockNestingEnabled(true);
connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockDockPositions_toggled(bool)));
coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll,
- 0, 0, tr("Ctrl+F")))->setCheckable(true);
+ 0, 0, tr("Ctrl+F")))->setCheckable(true);
+ coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
+ this, SLOT(showAwayLog())));
coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
0, 0))->setCheckable(true);
_bufferViewsMenu->addAction(coll->action("ConfigureBufferViews"));
_viewMenu->addSeparator();
_viewMenu->addAction(coll->action("ToggleSearchBar"));
+
+ coreAction = coll->action("ShowAwayLog");
+ flagRemoteCoreOnly(coreAction);
+ _viewMenu->addAction(coreAction);
+
_viewMenu->addAction(coll->action("ToggleStatusBar"));
_viewMenu->addSeparator();
_viewMenu->addAction(coll->action("LockDockPositions"));
void MainWin::setupStatusBar() {
// MessageProcessor progress
statusBar()->addPermanentWidget(msgProcessorStatusWidget);
- connect(Client::messageProcessor(), SIGNAL(progressUpdated(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
// Core Lag:
updateLagIndicator();
connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), this, SLOT(updateLagIndicator(int)));
// SSL indicator
- connect(Client::instance(), SIGNAL(securedConnection()), this, SLOT(securedConnection()));
sslLabel->setPixmap(QPixmap());
statusBar()->addPermanentWidget(sslLabel);
sslLabel->hide();
connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool)));
connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool)));
-
- connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
- connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
}
void MainWin::saveStatusBarStatus(bool enabled) {
}
#ifndef Q_WS_MAC
- connect(systemTrayIcon(), SIGNAL(activated( QSystemTrayIcon::ActivationReason )),
- this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason )));
+ connect(systemTrayIcon(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
#endif
-
}
void MainWin::changeEvent(QEvent *event) {
if(windowState() & Qt::WindowMinimized) {
QtUiSettings s;
if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) {
- toggleVisibility();
- event->ignore();
+ hideToTray();
+ event->accept();
}
}
}
action->setVisible(!Client::internalCore());
}
+ disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+ disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ if(!Client::internalCore()) {
+ connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+ connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
+ }
+
// _viewMenu->setEnabled(true);
if(!Client::internalCore())
statusBar()->showMessage(tr("Connected to core."));
- if(sslLabel->width() == 0)
+ if(Client::signalProxy()->isSecure()) {
+ sslLabel->setPixmap(SmallIcon("security-high"));
+ } else {
sslLabel->setPixmap(SmallIcon("security-low"));
+ }
sslLabel->setVisible(!Client::internalCore());
coreLagLabel->setVisible(!Client::internalCore());
coreLagLabel->setText(text);
}
-
-void MainWin::securedConnection() {
- // todo: make status bar entry
- sslLabel->setPixmap(SmallIcon("security-high"));
-}
-
void MainWin::disconnectedFromCore() {
// save core specific layout and remove bufferviews;
saveLayout();
CoreInfoDlg(this).exec();
}
+void MainWin::showAwayLog() {
+ if(_awayLog)
+ return;
+ AwayLogFilter *filter = new AwayLogFilter(Client::messageModel());
+ _awayLog = new AwayLogView(filter, 0);
+ filter->setParent(_awayLog);
+ connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed()));
+ _awayLog->setAttribute(Qt::WA_DeleteOnClose);
+ _awayLog->show();
+}
+
+void MainWin::awayLogDestroyed() {
+ _awayLog = 0;
+}
+
void MainWin::showSettingsDlg() {
SettingsDlg *dlg = new SettingsDlg();
void MainWin::closeEvent(QCloseEvent *event) {
QtUiSettings s;
- if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) {
- toggleVisibility();
+ QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
+ Q_ASSERT(app);
+ if(!app->aboutToQuit() && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) {
+ toggleMinimizedToTray();
event->ignore();
} else {
event->accept();
}
}
-void MainWin::systrayActivated( QSystemTrayIcon::ActivationReason activationReason) {
+void MainWin::systrayActivated(QSystemTrayIcon::ActivationReason activationReason) {
if(activationReason == QSystemTrayIcon::Trigger) {
- toggleVisibility();
+ toggleMinimizedToTray();
}
}
-void MainWin::toggleVisibility() {
- if(isHidden() /*|| !isActiveWindow()*/) {
- show();
- if(isMinimized()) {
- if(isMaximized())
- showMaximized();
- else
- showNormal();
- }
+void MainWin::hideToTray() {
+ if(!systemTrayIcon()->isSystemTrayAvailable()) {
+ qWarning() << Q_FUNC_INFO << "was called with no SystemTray available!";
+ return;
+ }
- raise();
- activateWindow();
- // setFocus(); //Qt::ActiveWindowFocusReason
+ clearFocus();
+ hide();
+ systemTrayIcon()->show();
+}
+void MainWin::toggleMinimizedToTray() {
+ if(windowState() & Qt::WindowMinimized) {
+ // restore
+ setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
+ show();
+ raise();
} else {
- if(systemTrayIcon()->isSystemTrayAvailable ()) {
- clearFocus();
- hide();
- if(!systemTrayIcon()->isVisible()) {
- systemTrayIcon()->show();
- }
- } else {
- lower();
- }
+ setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized);
+ hideToTray();
}
}