From ac329a2b2409a487736d6a3285dea15aa078cec5 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 22 Oct 2023 07:00:17 +0300 Subject: [PATCH] plasma: check popup status on Plasma::Applet::activate() signal not always emitted by Plasma::PopupAppletPrivate::internalTogglePopup() tho Signed-off-by: Ivailo Monev --- plasma/applets/systemtray/systemtray.cpp | 18 +++++------------- plasma/applets/systemtray/systemtray.h | 2 -- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/plasma/applets/systemtray/systemtray.cpp b/plasma/applets/systemtray/systemtray.cpp index 0596d6a6..3e40f8d1 100644 --- a/plasma/applets/systemtray/systemtray.cpp +++ b/plasma/applets/systemtray/systemtray.cpp @@ -25,8 +25,6 @@ // standard issue margin/spacing static const int s_margin = 4; static const int s_spacing = 2; -// there is no signal for when the popup is shown so it has to be checked on timer -static const int s_popuptimeout = 500; static QString kElementForArrow(const Qt::Orientation orientation, const bool reverse) { @@ -58,19 +56,11 @@ SystemTrayApplet::SystemTrayApplet(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), m_layout(nullptr), m_arrowicon(nullptr), - m_showinghidden(false), - m_popuptimer(nullptr) + m_showinghidden(false) { KGlobal::locale()->insertCatalog("plasma_applet_systemtray"); setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - m_popuptimer = new QTimer(this); - m_popuptimer->setInterval(s_popuptimeout); - connect( - m_popuptimer, SIGNAL(timeout()), - this, SLOT(slotUpdateVisibility()) - ); } SystemTrayApplet::~SystemTrayApplet() @@ -148,7 +138,6 @@ void SystemTrayApplet::constraintsEvent(Plasma::Constraints constraints) void SystemTrayApplet::slotUpdateLayout() { - m_popuptimer->stop(); QMutexLocker locker(&m_mutex); foreach (Plasma::Applet* plasmaapplet, m_applets) { disconnect(plasmaapplet, 0, this, 0); @@ -191,6 +180,10 @@ void SystemTrayApplet::slotUpdateLayout() plasmaapplet, SIGNAL(appletDestroyed(Plasma::Applet*)), this, SLOT(slotUpdateLayout()) ); + connect( + plasmaapplet, SIGNAL(activate()), + this, SLOT(slotUpdateVisibility()) + ); connect( plasmaapplet, SIGNAL(newStatus(Plasma::ItemStatus)), this, SLOT(slotUpdateVisibility()) @@ -201,7 +194,6 @@ void SystemTrayApplet::slotUpdateLayout() } locker.unlock(); slotUpdateVisibility(); - m_popuptimer->start(); } void SystemTrayApplet::slotUpdateVisibility() diff --git a/plasma/applets/systemtray/systemtray.h b/plasma/applets/systemtray/systemtray.h index 2fc6e6bb..7be92758 100644 --- a/plasma/applets/systemtray/systemtray.h +++ b/plasma/applets/systemtray/systemtray.h @@ -20,7 +20,6 @@ #define SYSTEMTRAY_H #include -#include #include #include #include @@ -52,7 +51,6 @@ private: QList m_applets; Plasma::IconWidget* m_arrowicon; bool m_showinghidden; - QTimer* m_popuptimer; }; #endif // SYSTEMTRAY_H