X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Flegacysystemtray.cpp;h=5ded59a520fc328eb04b89909396d46d326ad90b;hp=3fbe1dcac2129556ac91b31315e12a866591dd71;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=30b159cb876a9495de42e9a3e70ca050516f0805 diff --git a/src/qtui/legacysystemtray.cpp b/src/qtui/legacysystemtray.cpp index 3fbe1dca..5ded59a5 100644 --- a/src/qtui/legacysystemtray.cpp +++ b/src/qtui/legacysystemtray.cpp @@ -20,23 +20,20 @@ #ifndef QT_NO_SYSTEMTRAYICON -#include "legacysystemtray.h" +# include "legacysystemtray.h" -#include "icon.h" -#include "mainwin.h" -#include "qtui.h" +# include "icon.h" +# include "mainwin.h" +# include "qtui.h" -LegacySystemTray::LegacySystemTray(QWidget *parent) +LegacySystemTray::LegacySystemTray(QWidget* parent) : SystemTray(parent) , _trayIcon{new QSystemTrayIcon(associatedWidget())} { - -#ifndef Q_OS_MAC - connect(_trayIcon, &QSystemTrayIcon::activated, - this, &LegacySystemTray::onActivated); -#endif - connect(_trayIcon, &QSystemTrayIcon::messageClicked, - this, &LegacySystemTray::onMessageClicked); +# ifndef Q_OS_MAC + connect(_trayIcon, &QSystemTrayIcon::activated, this, &LegacySystemTray::onActivated); +# endif + connect(_trayIcon, &QSystemTrayIcon::messageClicked, this, &LegacySystemTray::onMessageClicked); _trayIcon->setContextMenu(trayMenu()); _trayIcon->setVisible(false); @@ -53,15 +50,11 @@ LegacySystemTray::LegacySystemTray(QWidget *parent) updateToolTip(); } - bool LegacySystemTray::isSystemTrayAvailable() const { - return mode() == Mode::Legacy - ? QSystemTrayIcon::isSystemTrayAvailable() - : SystemTray::isSystemTrayAvailable(); + return mode() == Mode::Legacy ? QSystemTrayIcon::isSystemTrayAvailable() : SystemTray::isSystemTrayAvailable(); } - void LegacySystemTray::onVisibilityChanged(bool isVisible) { if (mode() == Legacy) { @@ -69,7 +62,6 @@ void LegacySystemTray::onVisibilityChanged(bool isVisible) } } - void LegacySystemTray::onModeChanged(Mode mode) { if (mode == Mode::Legacy) { @@ -80,43 +72,38 @@ void LegacySystemTray::onModeChanged(Mode mode) } } - void LegacySystemTray::updateIcon() { QString iconName = (state() == NeedsAttention) ? currentAttentionIconName() : currentIconName(); _trayIcon->setIcon(icon::get(iconName, QString{":/icons/hicolor/24x24/status/%1.svg"}.arg(iconName))); } - void LegacySystemTray::updateToolTip() { -#if defined Q_OS_MAC || defined Q_OS_WIN +# if defined Q_OS_MAC || defined Q_OS_WIN QString tooltip = QString("%1").arg(toolTipTitle()); if (!toolTipSubTitle().isEmpty()) tooltip += QString("\n%1").arg(toolTipSubTitle()); -#else +# else QString tooltip = QString("%1").arg(toolTipTitle()); if (!toolTipSubTitle().isEmpty()) tooltip += QString("
%1").arg(toolTipSubTitle()); -#endif +# endif _trayIcon->setToolTip(tooltip); } - void LegacySystemTray::onActivated(QSystemTrayIcon::ActivationReason reason) { activate((SystemTray::ActivationReason)reason); } - void LegacySystemTray::onMessageClicked() { emit messageClicked(_lastMessageId); } - -void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int msTimeout, uint id) +void LegacySystemTray::showMessage(const QString& title, const QString& message, SystemTray::MessageIcon icon, int msTimeout, uint id) { // fancy stuff later: show messages in order // for now, we just show the last message @@ -124,16 +111,14 @@ void LegacySystemTray::showMessage(const QString &title, const QString &message, _trayIcon->showMessage(title, message, (QSystemTrayIcon::MessageIcon)icon, msTimeout); } - void LegacySystemTray::closeMessage(uint notificationId) { Q_UNUSED(notificationId) // there really seems to be no sane way to close the bubble... :( -#ifdef Q_WS_X11 +# ifdef Q_WS_X11 showMessage("", "", NoIcon, 1); -#endif +# endif } - #endif /* QT_NO_SYSTEMTRAYICON */