X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fstatusnotifieritem.cpp;h=25b14bfb19a7ea0a4fb7656332d26489fd0c01e7;hp=59a129ea8811e190f445ca77bdbb21ecd6f5d99a;hb=900cce213a6ed000b7131a05a0dec7d04b35b023;hpb=6bfa260800588318e5a7b17e3b9dbfaa67bba635 diff --git a/src/qtui/statusnotifieritem.cpp b/src/qtui/statusnotifieritem.cpp index 59a129ea..25b14bfb 100644 --- a/src/qtui/statusnotifieritem.cpp +++ b/src/qtui/statusnotifieritem.cpp @@ -61,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(); @@ -72,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(); @@ -86,54 +84,51 @@ StatusNotifierItem::StatusNotifierItem(QWidget *parent) setMode(Mode::StatusNotifier); - connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool))); - connect(this, SIGNAL(modeChanged(Mode)), this, SLOT(onModeChanged(Mode))); - connect(this, SIGNAL(stateChanged(State)), this, SLOT(onStateChanged(State))); + connect(this, &StatusNotifierItem::visibilityChanged, this, &StatusNotifierItem::onVisibilityChanged); + connect(this, &StatusNotifierItem::modeChanged, this, &StatusNotifierItem::onModeChanged); + connect(this, &StatusNotifierItem::stateChanged, this, &StatusNotifierItem::onStateChanged); 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())); + connect(this, &SystemTray::iconsChanged, this, &StatusNotifierItem::refreshIcons); refreshIcons(); // Our own SNI service _statusNotifierItemDBus = new StatusNotifierItemDBus(this); - connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewIcon())); - connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon())); - connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip())); + connect(this, &StatusNotifierItem::currentIconNameChanged, _statusNotifierItemDBus, &StatusNotifierItemDBus::NewIcon); + connect(this, &StatusNotifierItem::currentIconNameChanged, _statusNotifierItemDBus, &StatusNotifierItemDBus::NewAttentionIcon); + connect(this, &StatusNotifierItem::toolTipChanged, _statusNotifierItemDBus, &StatusNotifierItemDBus::NewToolTip); // Service watcher to keep track of the StatusNotifierWatcher service _serviceWatcher = new QDBusServiceWatcher(kSniWatcherService, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); - connect(_serviceWatcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString))); + connect(_serviceWatcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &StatusNotifierItem::serviceChange); // Client instance for StatusNotifierWatcher _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService, kSniWatcherPath, QDBusConnection::sessionBus(), this); - connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), SLOT(checkForRegisteredHosts())); - connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), SLOT(checkForRegisteredHosts())); + connect(_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierHostRegistered, this, &StatusNotifierItem::checkForRegisteredHosts); + connect(_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierHostUnregistered, this, &StatusNotifierItem::checkForRegisteredHosts); // Client instance for notifications _notificationsClient = new org::freedesktop::Notifications(kXdgNotificationsService, kXdgNotificationsPath, QDBusConnection::sessionBus(), this); - connect(_notificationsClient, SIGNAL(NotificationClosed(uint, uint)), SLOT(notificationClosed(uint, uint))); - connect(_notificationsClient, SIGNAL(ActionInvoked(uint, QString)), SLOT(notificationInvoked(uint, QString))); + connect(_notificationsClient, &OrgFreedesktopNotificationsInterface::NotificationClosed, this, &StatusNotifierItem::notificationClosed); + connect(_notificationsClient, &OrgFreedesktopNotificationsInterface::ActionInvoked, this, &StatusNotifierItem::notificationInvoked); if (_notificationsClient->isValid()) { QStringList desktopCapabilities = _notificationsClient->GetCapabilities(); @@ -195,7 +190,6 @@ void StatusNotifierItem::onDBusError(const QDBusError &error) void StatusNotifierItem::refreshIcons() { -#if QT_VERSION >= 0x050000 if (!_iconThemePath.isEmpty()) { QDir baseDir{_iconThemePath + "/hicolor"}; baseDir.removeRecursively(); @@ -223,7 +217,7 @@ void StatusNotifierItem::refreshIcons() } } } -#endif + if (_statusNotifierItemDBus) { emit _statusNotifierItemDBus->NewIcon(); emit _statusNotifierItemDBus->NewAttentionIcon(); @@ -321,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); } @@ -342,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)