diff options
Diffstat (limited to 'src/widgets/util/qsystemtrayicon.cpp')
-rw-r--r-- | src/widgets/util/qsystemtrayicon.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 903cb4380c..2a55f014e1 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -61,7 +61,7 @@ static QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon) called the \e{system tray} or \e{notification area}, where long-running applications can display icons and short messages. - \image system-tray.png The system tray on Windows XP. + \image system-tray.webp The system tray on Windows 10. The QSystemTrayIcon class can be used on the following platforms: @@ -154,9 +154,6 @@ QSystemTrayIcon::~QSystemTrayIcon() The menu will pop up when the user requests the context menu for the system tray icon by clicking the mouse button. - On \macos, this is currently converted to a NSMenu, so the - aboutToHide() signal is not emitted. - \note The system tray icon does not take ownership of the menu. You must ensure that it is deleted at the appropriate time by, for example, creating the menu with a suitable parent object. @@ -165,12 +162,16 @@ void QSystemTrayIcon::setContextMenu(QMenu *menu) { Q_D(QSystemTrayIcon); QMenu *oldMenu = d->menu.data(); + if (oldMenu == menu) + return; + d->menu = menu; d->updateMenu_sys(); - if (oldMenu != menu && d->qpa_sys) { + + if (d->qpa_sys) { // Show the QMenu-based menu for QPA plugins that do not provide native menus if (oldMenu && !oldMenu->platformMenu()) - QObject::disconnect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested, menu, nullptr); + QObject::disconnect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested, oldMenu, nullptr); if (menu && !menu->platformMenu()) { QObject::connect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested, menu, |