#ifndef QT_NO_SYSTEMTRAYICON
#include "legacysystemtray.h"
+#include "mainwin.h"
#include "qtui.h"
-LegacySystemTray::LegacySystemTray(QObject *parent)
+LegacySystemTray::LegacySystemTray(QWidget *parent)
: SystemTray(parent),
_blinkState(false),
_isVisible(true)
{
#ifndef HAVE_KDE
- _trayIcon = new QSystemTrayIcon(QtUi::mainWindow());
+ _trayIcon = new QSystemTrayIcon(associatedWidget());
#else
- _trayIcon = new KSystemTrayIcon(QtUi::mainWindow());
+ _trayIcon = new KSystemTrayIcon(associatedWidget());
// We don't want to trigger a minimize if a highlight is pending, so we brutally remove the internal connection for that
disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
_trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason)));
connect(_trayIcon, SIGNAL(messageClicked()),
SIGNAL(messageClicked()));
- setTrayMenu(_trayIcon->contextMenu());
- _trayIcon->setContextMenu(trayMenu());
-
_blinkTimer.setInterval(500);
_blinkTimer.setSingleShot(false);
connect(&_blinkTimer, SIGNAL(timeout()), SLOT(on_blinkTimeout()));
+
+ connect(this, SIGNAL(toolTipChanged(QString,QString)), SLOT(syncLegacyIcon()));
}
void LegacySystemTray::init() {
if(mode() == Invalid) // derived class hasn't set a mode itself
setMode(Legacy);
+
+ SystemTray::init();
+
+ _trayIcon->setContextMenu(trayMenu());
}
void LegacySystemTray::syncLegacyIcon() {
_trayIcon->setIcon(stateIcon());
- _trayIcon->setToolTip(toolTipTitle());
+
+ QString tooltip = QString("<b>%1</b>").arg(toolTipTitle());
+ if(!toolTipSubTitle().isEmpty())
+ tooltip += QString("<br>%1").arg(toolTipSubTitle());
+ _trayIcon->setToolTip(tooltip);
}
void LegacySystemTray::setVisible(bool visible) {
}
}
+bool LegacySystemTray::isVisible() const {
+ if(mode() == Legacy) {
+ return _trayIcon->isVisible();
+ }
+ return false;
+}
+
void LegacySystemTray::setMode(Mode mode_) {
SystemTray::setMode(mode_);
}
void LegacySystemTray::on_activated(QSystemTrayIcon::ActivationReason reason) {
- emit activated((ActivationReason)reason);
-
- if(reason == QSystemTrayIcon::Trigger && !isActivationInhibited()) {
-
-# ifdef HAVE_KDE
- // the slot is private, but meh, who cares :)
- QMetaObject::invokeMethod(_trayIcon, "activateOrHide", Q_ARG(QSystemTrayIcon::ActivationReason, QSystemTrayIcon::Trigger));
-# else
- QtUi::mainWindow()->toggleMinimizedToTray();
-# endif
-
- }
+ activate((SystemTray::ActivationReason)reason);
}
void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int millisecondsTimeoutHint) {