X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fstatusnotifieritem.cpp;h=63af7c6b10bd7c3a31d3c5850a3719756b81b283;hp=5932746cf3375f1982522bf2f92c2e490b645337;hb=98144aaad0cd747f186edcd0e36a1d67326ac766;hpb=a888a2886dc1466eb0b1bb3591f43350623c6330 diff --git a/src/qtui/statusnotifieritem.cpp b/src/qtui/statusnotifieritem.cpp index 5932746c..63af7c6b 100644 --- a/src/qtui/statusnotifieritem.cpp +++ b/src/qtui/statusnotifieritem.cpp @@ -23,16 +23,19 @@ #ifdef HAVE_DBUS +#include "statusnotifieritem.h" + #include #include #include +#include #include #include #include +#include "icon.h" #include "qtui.h" #include "quassel.h" -#include "statusnotifieritem.h" #include "statusnotifieritemdbus.h" constexpr int kProtocolVersion {0}; @@ -58,7 +61,7 @@ public: {} protected: - virtual QString iconNameForAction(QAction *action) // TODO Qt 4.7: fixme when we have converted our iconloader + QString iconNameForAction(QAction *action) override // TODO Qt 4.7: fixme when we have converted our iconloader { QIcon icon(action->icon()); return icon.isNull() ? QString() : icon.name(); @@ -69,9 +72,7 @@ protected: StatusNotifierItem::StatusNotifierItem(QWidget *parent) : StatusNotifierItemParent(parent) -#if QT_VERSION >= 0x050000 , _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}} -#endif { static bool registered = []() -> bool { qDBusRegisterMetaType(); @@ -90,15 +91,12 @@ StatusNotifierItem::StatusNotifierItem(QWidget *parent) trayMenu()->installEventFilter(this); // Create a temporary directory that holds copies of the tray icons. That way, visualizers can find our icons. - // For Qt4 the relevant icons are installed in hicolor already, so nothing to be done. -#if QT_VERSION >= 0x050000 if (_iconThemeDir.isValid()) { _iconThemePath = _iconThemeDir.path(); } else { qWarning() << "Could not create temporary directory for themed tray icons!"; } -#endif connect(this, SIGNAL(iconsChanged()), this, SLOT(refreshIcons())); refreshIcons(); @@ -110,11 +108,11 @@ StatusNotifierItem::StatusNotifierItem(QWidget *parent) connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip())); // Service watcher to keep track of the StatusNotifierWatcher service - QDBusServiceWatcher *watcher = new QDBusServiceWatcher(kSniWatcherService, - QDBusConnection::sessionBus(), - QDBusServiceWatcher::WatchForOwnerChange, - this); - connect(watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString))); + _serviceWatcher = new QDBusServiceWatcher(kSniWatcherService, + QDBusConnection::sessionBus(), + QDBusServiceWatcher::WatchForOwnerChange, + this); + connect(_serviceWatcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString))); // Client instance for StatusNotifierWatcher _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService, @@ -192,13 +190,12 @@ void StatusNotifierItem::onDBusError(const QDBusError &error) void StatusNotifierItem::refreshIcons() { -#if QT_VERSION >= 0x050000 if (!_iconThemePath.isEmpty()) { QDir baseDir{_iconThemePath + "/hicolor"}; baseDir.removeRecursively(); for (auto &&trayState : { State::Active, State::Passive, State::NeedsAttention }) { auto iconName = SystemTray::iconName(trayState); - QIcon icon = QIcon::fromTheme(iconName); + QIcon icon = icon::get(iconName); if (!icon.isNull()) { for (auto &&size : icon.availableSizes()) { auto pixDir = QString{"%1/%2x%3/status"}.arg(baseDir.absolutePath()).arg(size.width()).arg(size.height()); @@ -220,7 +217,7 @@ void StatusNotifierItem::refreshIcons() } } } -#endif + if (_statusNotifierItemDBus) { emit _statusNotifierItemDBus->NewIcon(); emit _statusNotifierItemDBus->NewAttentionIcon(); @@ -318,18 +315,9 @@ void StatusNotifierItem::activated(const QPoint &pos) bool StatusNotifierItem::eventFilter(QObject *watched, QEvent *event) { if (mode() == StatusNotifier) { - //FIXME: ugly ugly workaround to weird QMenu's focus problems -#ifdef HAVE_KDE4 - if (watched == trayMenu() && - (event->type() == QEvent::WindowDeactivate || (event->type() == QEvent::MouseButtonRelease && static_cast(event)->button() == Qt::LeftButton))) { - // put at the back of event queue to let the action activate anyways - QTimer::singleShot(0, trayMenu(), SLOT(hide())); - } -#else if (watched == trayMenu() && event->type() == QEvent::HoverLeave) { trayMenu()->hide(); } -#endif } return StatusNotifierItemParent::eventFilter(watched, event); } @@ -339,12 +327,9 @@ void StatusNotifierItem::showMessage(const QString &title, const QString &messag { QString message = message_; if (_notificationsClient->isValid()) { - if (_notificationsClientSupportsMarkup) -#if QT_VERSION < 0x050000 - message = Qt::escape(message); -#else + if (_notificationsClientSupportsMarkup) { message = message.toHtmlEscaped(); -#endif + } QStringList actions; if (_notificationsClientSupportsActions)