diff options
author | Serge Lysenko <sergii.lysenko@avid.com> | 2015-10-20 19:21:42 +0300 |
---|---|---|
committer | Serge Lysenko <lserge@auster.in.ua> | 2016-09-07 17:56:28 +0000 |
commit | e8892c7e7a0bdebca9ff491a9446c0b4192fe7fd (patch) | |
tree | 759c8c11344b9388b7d2274f24149cefdf8a3cd6 /examples/widgets/desktop | |
parent | 39a2eed039f8cb335f72caaf3b35d5e6832c2c5b (diff) |
Support large custom icons for the system tray balloon notification
Modern platforms such as macOS and Windows support large fancy icons
in the system balloon notification. We just need to pass the icon into
platform plugin.
[ChangeLog][QtWidgets][QSystemTrayIcon] Support custom icons in showMessage()
Task-number: QTBUG-49283
Change-Id: Iaeca36fe1bf350eae34d105549010ecbedf9c0a1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/widgets/desktop')
-rw-r--r-- | examples/widgets/desktop/systray/window.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index 518f03d4b5..ac05f16341 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -161,10 +161,16 @@ void Window::iconActivated(QSystemTrayIcon::ActivationReason reason) void Window::showMessage() { showIconCheckBox->setChecked(true); - QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon( + QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon( typeComboBox->itemData(typeComboBox->currentIndex()).toInt()); - trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon, + if (msgIcon == QSystemTrayIcon::NoIcon) { + QIcon icon(iconComboBox->itemIcon(iconComboBox->currentIndex())); + trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon, durationSpinBox->value() * 1000); + } else { + trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), msgIcon, + durationSpinBox->value() * 1000); + } } //! [5] @@ -216,6 +222,8 @@ void Window::createMessageGroupBox() typeComboBox->addItem(style()->standardIcon( QStyle::SP_MessageBoxCritical), tr("Critical"), QSystemTrayIcon::Critical); + typeComboBox->addItem(QIcon(), tr("Custom icon"), + QSystemTrayIcon::NoIcon); typeComboBox->setCurrentIndex(1); durationLabel = new QLabel(tr("Duration:")); |