#include "iconloader.h"
#include "networkmodel.h"
#include "qtui.h"
+#include "systemtray.h"
KNotificationBackend::KNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
KNotification *notification = KNotification::event("Highlight", message, DesktopIcon("dialog-information"), QtUi::mainWindow(),
KNotification::Persistent|KNotification::RaiseWidgetOnActivation|KNotification::CloseWhenWidgetActivated);
connect(notification, SIGNAL(activated()), SLOT(notificationActivated()));
+ QtUi::mainWindow()->systemTray()->setAlert(true);
}
void KNotificationBackend::close(uint notificationId) {
Q_UNUSED(notificationId);
+ QtUi::mainWindow()->systemTray()->setAlert(false);
}
void KNotificationBackend::notificationActivated() {
#include "sessionsettings.h"
#include "settingsdlg.h"
#include "settingspagedlg.h"
+#include "systemtray.h"
#include "toolbaractionprovider.h"
#include "topicwidget.h"
#include "verticaldock.h"
sslLabel(new QLabel()),
msgProcessorStatusWidget(new MsgProcessorStatusWidget()),
_titleSetter(this),
- _trayIcon(new QSystemTrayIcon(this)),
_awayLog(0)
{
QtUiSettings uiSettings;
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::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ SLOT(messagesInserted(const QModelIndex &, int, int)));
connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
// Setup Dock Areas
setDisconnectedState(); // Disable menus and stuff
show();
+
if(Quassel::runMode() != Quassel::Monolithic) {
showCoreConnectionDlg(true); // autoconnect if appropriate
} else {
s.setValue("MainWinState", saveState());
}
+// FIXME
void MainWin::updateIcon() {
QPixmap icon;
if(Client::isConnected())
icon = DesktopIcon("quassel_disconnected", IconLoader::SizeEnormous);
setWindowIcon(icon);
qApp->setWindowIcon(icon);
- systemTrayIcon()->setIcon(icon);
}
void MainWin::setupActions() {
}
void MainWin::setupSystray() {
- connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
- SLOT(messagesInserted(const QModelIndex &, int, int)));
-
- ActionCollection *coll = QtUi::actionCollection("General");
- systrayMenu = new QMenu(this);
- systrayMenu->addAction(coll->action("ConnectCore"));
- systrayMenu->addAction(coll->action("DisconnectCore"));
- systrayMenu->addAction(coll->action("CoreInfo"));
- systrayMenu->addSeparator();
- systrayMenu->addAction(coll->action("Quit"));
-
- systemTrayIcon()->setContextMenu(systrayMenu);
-
- QtUiSettings s;
- if(s.value("UseSystemTrayIcon", QVariant(true)).toBool()) {
- systemTrayIcon()->show();
- }
+ _systemTray = new SystemTray(this);
#ifndef Q_WS_MAC
- connect(systemTrayIcon(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
+ connect(systemTray(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
#endif
+
}
void MainWin::setupToolBars() {
sslLabel->setVisible(!Client::internalCore());
coreLagLabel->setVisible(!Client::internalCore());
updateIcon();
+ systemTray()->setState(SystemTray::Active);
}
void MainWin::loadLayout() {
if(msgProcessorStatusWidget)
msgProcessorStatusWidget->setProgress(0, 0);
updateIcon();
+ systemTray()->setState(SystemTray::Inactive);
}
void MainWin::startInternalCore() {
}
void MainWin::hideToTray() {
- if(!systemTrayIcon()->isSystemTrayAvailable()) {
+ if(!systemTray()->isSystemTrayAvailable()) {
qWarning() << Q_FUNC_INFO << "was called with no SystemTray available!";
return;
}
-
clearFocus();
hide();
- systemTrayIcon()->show();
+ systemTray()->setIconVisible();
}
void MainWin::toggleMinimizedToTray() {
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
show();
raise();
+
} else {
setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized);
hideToTray();
class InputWidget;
class MsgProcessorStatusWidget;
class NickListWidget;
-class SystemTrayIcon;
+class SystemTray;
class QMenu;
class QLabel;
void addBufferView(ClientBufferViewConfig *config);
BufferView *allBuffersView() const;
- inline QSystemTrayIcon *systemTrayIcon() const;
+ inline SystemTray *systemTray() const;
virtual bool event(QEvent *event);
KHelpMenu *_kHelpMenu;
#endif
- QMenu *systrayMenu;
QLabel *coreLagLabel;
QLabel *sslLabel;
MsgProcessorStatusWidget *msgProcessorStatusWidget;
void toggleMinimizedToTray();
void enableMenus();
- QSystemTrayIcon *_trayIcon;
+ SystemTray *_systemTray;
QList<BufferViewDock *> _bufferViews;
BufferWidget *_bufferWidget;
friend class QtUi;
};
-QSystemTrayIcon *MainWin::systemTrayIcon() const {
- return _trayIcon;
+SystemTray *MainWin::systemTray() const {
+ return _systemTray;
}
#endif
#include "mainwin.h"
#include "networkmodel.h"
#include "qtui.h"
+#include "systemtray.h"
SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent)
: AbstractNotificationBackend(parent)
notificationSettings.notify("Systray/ShowBubble", this, SLOT(showBubbleChanged(const QVariant &)));
notificationSettings.notify("Systray/Animate", this, SLOT(animateChanged(const QVariant &)));
- _iconActive = false;
- connect(&_animationTimer, SIGNAL(timeout()), SLOT(blink()));
- connect(QtUi::mainWindow()->systemTrayIcon(), SIGNAL(messageClicked()), this, SIGNAL(activated()));
+ connect(QtUi::mainWindow()->systemTray(), SIGNAL(messageClicked()), this, SIGNAL(activated()));
}
void SystrayNotificationBackend::notify(const Notification ¬ification) {
*/
_notifications.clear();
_notifications.append(notification);
- if(_showBubble) {
+ if(_showBubble)
showBubble();
- }
- if(_animate) {
- startAnimation();
- }
+
+ if(_animate)
+ QtUi::mainWindow()->systemTray()->setAlert(true);
}
void SystrayNotificationBackend::close(uint notificationId) {
*/
_notifications.clear();
closeBubble();
- stopAnimation();
+ QtUi::mainWindow()->systemTray()->setAlert(false);
}
void SystrayNotificationBackend::showBubble() {
Notification n = _notifications.takeLast();
QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId);
QString message = QString("<%1> %2").arg(n.sender, n.message);
- QtUi::mainWindow()->systemTrayIcon()->showMessage(title, message);
+ QtUi::mainWindow()->systemTray()->showMessage(title, message);
}
void SystrayNotificationBackend::closeBubble() {
// there really seems to be no sane way to close the bubble... :(
#ifdef Q_WS_X11
- QtUi::mainWindow()->systemTrayIcon()->showMessage("", "", QSystemTrayIcon::NoIcon, 1);
+ QtUi::mainWindow()->systemTray()->showMessage("", "", QSystemTrayIcon::NoIcon, 1);
#endif
}
_showBubble = v.toBool();
}
-void SystrayNotificationBackend::startAnimation() {
- if(!_animationTimer.isActive())
- _animationTimer.start(500);
-}
-
-void SystrayNotificationBackend::stopAnimation() {
- _animationTimer.stop();
- QtUi::mainWindow()->systemTrayIcon()->setIcon(Icon("quassel"));
- _iconActive = false;
-}
-
-void SystrayNotificationBackend::blink() {
- QtUi::mainWindow()->systemTrayIcon()->setIcon(_iconActive ? Icon("quassel") : Icon("quassel_newmessage"));
- _iconActive = !_iconActive;
-}
-
void SystrayNotificationBackend::animateChanged(const QVariant &v) {
_animate = v.toBool();
}
private slots:
void showBubble();
void closeBubble();
- void startAnimation();
- void stopAnimation();
- void blink();
void animateChanged(const QVariant &);
void showBubbleChanged(const QVariant &);
bool _showBubble;
bool _animate;
- bool _iconActive;
- QTimer _animationTimer;
QList<Notification> _notifications;
};