Merge #15007: qt: Notificator class refactoring

698d0f882a Remove misplaced Q_UNUSED and others enhancements (Hennadii Stepanov)

Pull request description:

  This PR:
  - removes misplaced `Q_UNUSED(cls)`; `cls` is actually used:
  eb7daf4d60/src/qt/notificator.cpp (L188)

  - removes unused parameters in functions `notifySystray()` and `notifyMacUserNotificationCenter()`

  - improves comments

Tree-SHA512: 78c0713f2a968b471dae422e9a5a0959018923e0d24ed595921001a9895ffb6ceb0311c63e4264fdff470b021a8b8df0f6972c630a051dafed06281880acc261
This commit is contained in:
Wladimir J. van der Laan 2019-01-04 10:30:23 +01:00
commit f51aeac5ad
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D
2 changed files with 12 additions and 14 deletions

View file

@ -39,7 +39,7 @@ Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon
mode(None), mode(None),
trayIcon(_trayIcon) trayIcon(_trayIcon)
#ifdef USE_DBUS #ifdef USE_DBUS
,interface(0) ,interface(nullptr)
#endif #endif
{ {
if(_trayIcon && _trayIcon->supportsMessages()) if(_trayIcon && _trayIcon->supportsMessages())
@ -154,14 +154,14 @@ QVariant FreedesktopImage::toVariant(const QImage &img)
void Notificator::notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) void Notificator::notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
{ {
Q_UNUSED(cls); // https://developer.gnome.org/notification-spec/
// Arguments for DBus call: // Arguments for DBus "Notify" call:
QList<QVariant> args; QList<QVariant> args;
// Program Name: // Program Name:
args.append(programName); args.append(programName);
// Unique ID of this notification type: // Replaces ID; A value of 0 means that this notification won't replace any existing notifications:
args.append(0U); args.append(0U);
// Application Icon, empty string // Application Icon, empty string
@ -209,9 +209,8 @@ void Notificator::notifyDBus(Class cls, const QString &title, const QString &tex
} }
#endif #endif
void Notificator::notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) void Notificator::notifySystray(Class cls, const QString &title, const QString &text, int millisTimeout)
{ {
Q_UNUSED(icon);
QSystemTrayIcon::MessageIcon sicon = QSystemTrayIcon::NoIcon; QSystemTrayIcon::MessageIcon sicon = QSystemTrayIcon::NoIcon;
switch(cls) // Set icon based on class switch(cls) // Set icon based on class
{ {
@ -222,13 +221,12 @@ void Notificator::notifySystray(Class cls, const QString &title, const QString &
trayIcon->showMessage(title, text, sicon, millisTimeout); trayIcon->showMessage(title, text, sicon, millisTimeout);
} }
// Based on Qt's tray icon implementation
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon) { void Notificator::notifyMacUserNotificationCenter(const QString &title, const QString &text)
{
// icon is not supported by the user notification center yet. OSX will use the app icon. // icon is not supported by the user notification center yet. OSX will use the app icon.
MacNotificationHandler::instance()->showNotification(title, text); MacNotificationHandler::instance()->showNotification(title, text);
} }
#endif #endif
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
@ -241,11 +239,11 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c
break; break;
#endif #endif
case QSystemTray: case QSystemTray:
notifySystray(cls, title, text, icon, millisTimeout); notifySystray(cls, title, text, millisTimeout);
break; break;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
case UserNotificationCenter: case UserNotificationCenter:
notifyMacUserNotificationCenter(cls, title, text, icon); notifyMacUserNotificationCenter(title, text);
break; break;
#endif #endif
default: default:

View file

@ -57,7 +57,7 @@ private:
enum Mode { enum Mode {
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
Freedesktop, /**< Use DBus org.freedesktop.Notifications */ Freedesktop, /**< Use DBus org.freedesktop.Notifications */
QSystemTray, /**< Use QSystemTray::showMessage */ QSystemTray, /**< Use QSystemTrayIcon::showMessage() */
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */ UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
}; };
QString programName; QString programName;
@ -68,9 +68,9 @@ private:
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
#endif #endif
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); void notifySystray(Class cls, const QString &title, const QString &text, int millisTimeout);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon); void notifyMacUserNotificationCenter(const QString &title, const QString &text);
#endif #endif
}; };