summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-05 15:35:34 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-09 18:32:48 +0200
commit89984a8a61a7e33a4ff62db98083a0e3c0c7b4b1 (patch)
tree963172f280b2a4ca5cfef6b5f6749806bcba67ae /examples
parent0a3107dd302c521c240b273229ba40a358cb0873 (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')
-rw-r--r--examples/widgets/desktop/systray/window.cpp9
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:"));