diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-07-05 15:35:34 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-07-09 18:32:48 +0200 |
commit | 89984a8a61a7e33a4ff62db98083a0e3c0c7b4b1 (patch) | |
tree | 963172f280b2a4ca5cfef6b5f6749806bcba67ae /examples/widgets/desktop | |
parent | 0a3107dd302c521c240b273229ba40a358cb0873 (diff) |
Fix the systray example to only show an icon when requested
The "None" and "Custom icon" cases where using the same value for icon
type, which resulted in both options showing the application icon.
Use -1 to indicate the custom option, and treat all other options
the same.
Task-number: QTBUG-76916
Change-Id: Ib715f5d328175bd6e221b3f507087954fa542838
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'examples/widgets/desktop')
-rw-r--r-- | examples/widgets/desktop/systray/window.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index 05944c92a7..28287dc02b 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -160,9 +160,10 @@ void Window::iconActivated(QSystemTrayIcon::ActivationReason reason) void Window::showMessage() { showIconCheckBox->setChecked(true); - QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon( - typeComboBox->itemData(typeComboBox->currentIndex()).toInt()); - if (msgIcon == QSystemTrayIcon::NoIcon) { + int selectedIcon = typeComboBox->itemData(typeComboBox->currentIndex()).toInt(); + QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon(selectedIcon); + + if (selectedIcon == -1) { // custom icon QIcon icon(iconComboBox->itemIcon(iconComboBox->currentIndex())); trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon, durationSpinBox->value() * 1000); @@ -222,7 +223,7 @@ void Window::createMessageGroupBox() QStyle::SP_MessageBoxCritical), tr("Critical"), QSystemTrayIcon::Critical); typeComboBox->addItem(QIcon(), tr("Custom icon"), - QSystemTrayIcon::NoIcon); + -1); typeComboBox->setCurrentIndex(1); durationLabel = new QLabel(tr("Duration:")); |