diff options
author | miniak <milan.burda@gmail.com> | 2010-06-11 12:54:19 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-06-11 12:54:19 (GMT) |
commit | 936fc54e313cfe8923ba94738e52a92adcf6ccf0 (patch) | |
tree | 2417a15e6c53d488f6bc4aff7ad811358ffa9887 | |
parent | d36e728d35f9b83710b4d88c719fbe64bbe58c1b (diff) | |
download | Qt-936fc54e313cfe8923ba94738e52a92adcf6ccf0.zip Qt-936fc54e313cfe8923ba94738e52a92adcf6ccf0.tar.gz Qt-936fc54e313cfe8923ba94738e52a92adcf6ccf0.tar.bz2 |
Fix QSystemTrayIcon::supportsMessages() on Windows
Add QSystemTrayIconPrivate::supportsMessages_sys() method
Report support for balloon messages only when they are actually allowed ("EnableBalloonTips" registry value)
Merge-request: 2355
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
-rw-r--r-- | src/gui/util/qsystemtrayicon.cpp | 5 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_mac.mm | 5 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_p.h | 2 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_qws.cpp | 5 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_win.cpp | 26 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_wince.cpp | 5 | ||||
-rw-r--r-- | src/gui/util/qsystemtrayicon_x11.cpp | 5 |
7 files changed, 31 insertions, 22 deletions
diff --git a/src/gui/util/qsystemtrayicon.cpp b/src/gui/util/qsystemtrayicon.cpp index d7dde87..941961b 100644 --- a/src/gui/util/qsystemtrayicon.cpp +++ b/src/gui/util/qsystemtrayicon.cpp @@ -356,10 +356,7 @@ bool QSystemTrayIcon::isSystemTrayAvailable() */ bool QSystemTrayIcon::supportsMessages() { -#if defined(Q_WS_QWS) - return false; -#endif - return true; + return QSystemTrayIconPrivate::supportsMessages_sys(); } /*! diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm index 8aaaa0f..22134cb 100644 --- a/src/gui/util/qsystemtrayicon_mac.mm +++ b/src/gui/util/qsystemtrayicon_mac.mm @@ -226,6 +226,11 @@ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() return true; } +bool QSystemTrayIconPrivate::supportsMessages_sys() +{ + return true; +} + void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon icon, int) { diff --git a/src/gui/util/qsystemtrayicon_p.h b/src/gui/util/qsystemtrayicon_p.h index e8bf197..4592e43 100644 --- a/src/gui/util/qsystemtrayicon_p.h +++ b/src/gui/util/qsystemtrayicon_p.h @@ -83,7 +83,9 @@ public: void updateMenu_sys(); QRect geometry_sys() const; void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); + static bool isSystemTrayAvailable_sys(); + static bool supportsMessages_sys(); QPointer<QMenu> menu; QIcon icon; diff --git a/src/gui/util/qsystemtrayicon_qws.cpp b/src/gui/util/qsystemtrayicon_qws.cpp index b1b895b..cda47aa 100644 --- a/src/gui/util/qsystemtrayicon_qws.cpp +++ b/src/gui/util/qsystemtrayicon_qws.cpp @@ -75,6 +75,11 @@ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() return false; } +bool QSystemTrayIconPrivate::supportsMessages_sys() +{ + return false; +} + void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title, QSystemTrayIcon::MessageIcon icon, diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index aee2027..a9585b9 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -111,8 +111,6 @@ public: bool trayMessage(DWORD msg); void setIconContents(NOTIFYICONDATA &data); bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs); - bool allowsMessages(); - bool supportsMessages(); QRect findIconGeometry(const int a_iButtonID); void createIcon(); HICON hIcon; @@ -125,7 +123,7 @@ private: bool ignoreNextMouseRelease; }; -bool QSystemTrayIconSys::allowsMessages() +static bool allowsMessages() { #ifndef QT_NO_SETTINGS QSettings settings(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft" @@ -136,11 +134,6 @@ bool QSystemTrayIconSys::allowsMessages() #endif } -bool QSystemTrayIconSys::supportsMessages() -{ - return allowsMessages(); -} - QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) : hIcon(0), q(object), ignoreNextMouseRelease(false) @@ -449,7 +442,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut) { - if (!sys || !sys->allowsMessages()) + if (!sys || !allowsMessages()) return; uint uSecs = 0; @@ -467,15 +460,7 @@ void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString //title is limited to 63 chars + NULL QString titleString = title.left(63) + QChar(); - if (sys->supportsMessages()) { - sys->showMessage(titleString, messageString, type, (unsigned int)uSecs); - } else { - //use fallback - QRect iconPos = sys->findIconGeometry(q_uNOTIFYICONID); - if (iconPos.isValid()) { - QBalloonTip::showBalloon(type, title, message, sys->q, iconPos.center(), uSecs, true); - } - } + sys->showMessage(titleString, messageString, type, uSecs); } QRect QSystemTrayIconPrivate::geometry_sys() const @@ -528,6 +513,11 @@ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() return true; } +bool QSystemTrayIconPrivate::supportsMessages_sys() +{ + return allowsMessages(); +} + QT_END_NAMESPACE #endif diff --git a/src/gui/util/qsystemtrayicon_wince.cpp b/src/gui/util/qsystemtrayicon_wince.cpp index 6ff5c58..e5cf0fd 100644 --- a/src/gui/util/qsystemtrayicon_wince.cpp +++ b/src/gui/util/qsystemtrayicon_wince.cpp @@ -283,6 +283,11 @@ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() return true; } +bool QSystemTrayIconPrivate::supportsMessages_sys() +{ + return true; +} + QT_END_NAMESPACE #endif diff --git a/src/gui/util/qsystemtrayicon_x11.cpp b/src/gui/util/qsystemtrayicon_x11.cpp index 82b4325..59fdc07 100644 --- a/src/gui/util/qsystemtrayicon_x11.cpp +++ b/src/gui/util/qsystemtrayicon_x11.cpp @@ -381,6 +381,11 @@ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() return QSystemTrayIconSys::locateSystemTray() != XNone; } +bool QSystemTrayIconPrivate::supportsMessages_sys() +{ + return true; +} + void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title, QSystemTrayIcon::MessageIcon icon, int msecs) { |