From 17accd23ac6369713ee91396e61b4783489100a3 Mon Sep 17 00:00:00 2001 From: Ignacio Rodriguez Date: Thu, 21 Jan 2021 22:09:14 +0700 Subject: [PATCH] Handling pre-main window status notifications --- ChangeLog | 1 + src/gui/src/TrayIcon.cpp | 5 ----- src/gui/src/TrayIcon.h | 13 ++++++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7f518cd1..780f1f46b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Bug fixes: - #6900 Remaining SonarCloud reported bug items (test fixed) - #6889 Systray Icon on Ubuntu Auto Start (take 2) - #6910 Don't use the word “Version” for release names because it can lead to errors during update checking. +- #69XX Handling pre-main window creation status notifications =========== v1.13.0-stable diff --git a/src/gui/src/TrayIcon.cpp b/src/gui/src/TrayIcon.cpp index aa494bd8c..f44cfa33c 100644 --- a/src/gui/src/TrayIcon.cpp +++ b/src/gui/src/TrayIcon.cpp @@ -12,8 +12,3 @@ void TrayIcon::tryCreate() const QTimer::singleShot(2500, this, &TrayIcon::tryCreate); } } - -void TrayIcon::set(const QIcon& icon) const -{ - m_pTrayIcon->setIcon(icon); -} diff --git a/src/gui/src/TrayIcon.h b/src/gui/src/TrayIcon.h index c708270c8..39d6e3133 100644 --- a/src/gui/src/TrayIcon.h +++ b/src/gui/src/TrayIcon.h @@ -12,6 +12,15 @@ class TrayIcon : public QObject public: using TConnector = std::function; + TrayIcon() + { + set = [this](const QIcon &icon){ + m_init = [this,icon](){ + this->set(icon); + }; + }; + } + template void create(TActionContainer const &actionContainer, TConnector const &connector) { @@ -30,16 +39,18 @@ public: m_pTrayIcon = std::make_unique(); m_pTrayIcon->setContextMenu(m_pTrayIconMenu.get()); m_pTrayIcon->setToolTip("Synergy"); + set = [this](const QIcon& icon) { m_pTrayIcon->setIcon(icon); }; tryCreate(); } void tryCreate() const; - void set(const QIcon& icon) const; + std::function set; private: std::unique_ptr m_pTrayIcon {}; std::unique_ptr m_pTrayIconMenu {}; TConnector m_connector; + std::function m_init; };