From 97bcdbecc1e676159eb20f6845960ef96d9c8ba9 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 19 Apr 2024 22:03:06 -0700 Subject: [PATCH] service/tray: add activate, secondaryActivate and scroll methods --- src/core/popupwindow.cpp | 4 +--- src/services/status_notifier/item.cpp | 8 ++++++++ src/services/status_notifier/item.hpp | 5 +++++ src/services/status_notifier/qml.cpp | 8 ++++++++ src/services/status_notifier/qml.hpp | 6 +++--- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/core/popupwindow.cpp b/src/core/popupwindow.cpp index e6a7f241..547bbe36 100644 --- a/src/core/popupwindow.cpp +++ b/src/core/popupwindow.cpp @@ -22,9 +22,7 @@ void ProxyPopupWindow::completeWindow() { this->updateTransientParent(); } -void ProxyPopupWindow::postCompleteWindow() { - this->ProxyWindowBase::setVisible(this->mVisible); -} +void ProxyPopupWindow::postCompleteWindow() { this->ProxyWindowBase::setVisible(this->mVisible); } bool ProxyPopupWindow::deleteOnInvisible() const { // Currently crashes in normal mode, do not have the time to debug it now. diff --git a/src/services/status_notifier/item.cpp b/src/services/status_notifier/item.cpp index 896f4c07..0bc05e41 100644 --- a/src/services/status_notifier/item.cpp +++ b/src/services/status_notifier/item.cpp @@ -153,6 +153,14 @@ QPixmap StatusNotifierItem::createPixmap(const QSize& size) const { return pixmap; } +void StatusNotifierItem::activate() { this->item->Activate(0, 0); } + +void StatusNotifierItem::secondaryActivate() { this->item->SecondaryActivate(0, 0); } + +void StatusNotifierItem::scroll(qint32 delta, bool horizontal) { + this->item->Scroll(delta, horizontal ? "horizontal" : "vertical"); +} + void StatusNotifierItem::updateIcon() { this->iconIndex++; emit this->iconChanged(); diff --git a/src/services/status_notifier/item.hpp b/src/services/status_notifier/item.hpp index b818f951..22de7946 100644 --- a/src/services/status_notifier/item.hpp +++ b/src/services/status_notifier/item.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../../dbus/dbusutil.hpp" #include "dbus_item.h" @@ -27,6 +28,10 @@ public: [[nodiscard]] QString iconId() const; [[nodiscard]] QPixmap createPixmap(const QSize& size) const; + void activate(); + void secondaryActivate(); + void scroll(qint32 delta, bool horizontal); + // clang-format off dbus::DBusPropertyGroup properties; dbus::DBusProperty id {this->properties, "Id"}; diff --git a/src/services/status_notifier/qml.cpp b/src/services/status_notifier/qml.cpp index c5858fec..8185ac57 100644 --- a/src/services/status_notifier/qml.cpp +++ b/src/services/status_notifier/qml.cpp @@ -89,6 +89,14 @@ bool SystemTrayItem::onlyMenu() const { return this->item->isMenu.get(); } +void SystemTrayItem::activate() { this->item->activate(); } + +void SystemTrayItem::secondaryActivate() { this->item->secondaryActivate(); } + +void SystemTrayItem::scroll(qint32 delta, bool horizontal) { + this->item->scroll(delta, horizontal); +} + SystemTray::SystemTray(QObject* parent): QObject(parent) { auto* host = StatusNotifierHost::instance(); diff --git a/src/services/status_notifier/qml.hpp b/src/services/status_notifier/qml.hpp index ad7e8ceb..ffac6638 100644 --- a/src/services/status_notifier/qml.hpp +++ b/src/services/status_notifier/qml.hpp @@ -69,13 +69,13 @@ public: ); // Primary activation action, generally triggered via a left click. - //Q_INVOKABLE void activate(); + Q_INVOKABLE void activate(); // Secondary activation action, generally triggered via a middle click. - //Q_INVOKABLE void secondaryActivate(); + Q_INVOKABLE void secondaryActivate(); // Scroll action, such as changing volume on a mixer. - //Q_INVOKABLE void scroll(qint32 delta, bool horizontal); + Q_INVOKABLE void scroll(qint32 delta, bool horizontal); [[nodiscard]] QString id() const; [[nodiscard]] QString title() const;