From e8892c7e7a0bdebca9ff491a9446c0b4192fe7fd Mon Sep 17 00:00:00 2001 From: Serge Lysenko Date: Tue, 20 Oct 2015 19:21:42 +0300 Subject: 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 --- examples/widgets/desktop/systray/window.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'examples') 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:")); -- cgit v1.2.3