service/tray: add activate, secondaryActivate and scroll methods

This commit is contained in:
outfoxxed 2024-04-19 22:03:06 -07:00
parent 94a1140aab
commit 97bcdbecc1
Signed by: outfoxxed
GPG Key ID: 4C88A185FB89301E
5 changed files with 25 additions and 6 deletions

View File

@ -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.

View File

@ -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();

View File

@ -7,6 +7,7 @@
#include <qobject.h>
#include <qpixmap.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#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<QString> id {this->properties, "Id"};

View File

@ -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();

View File

@ -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;