core/menu: add handle support to QsMenuOpener + add handle to tray

This commit is contained in:
outfoxxed 2024-07-25 02:51:17 -07:00
parent acdbe73c10
commit 54350277be
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
6 changed files with 101 additions and 51 deletions

View file

@ -519,7 +519,7 @@ void DBusMenuHandle::setAddress(const QString& service, const QString& path) {
this->onMenuPathChanged();
}
void DBusMenuHandle::ref() {
void DBusMenuHandle::refHandle() {
this->refcount++;
qCDebug(logDbusMenu) << this << "gained a reference. Refcount is now" << this->refcount;
@ -532,7 +532,7 @@ void DBusMenuHandle::ref() {
}
}
void DBusMenuHandle::unref() {
void DBusMenuHandle::unrefHandle() {
this->refcount--;
qCDebug(logDbusMenu) << this << "lost a reference. Refcount is now" << this->refcount;
@ -564,9 +564,7 @@ void DBusMenuHandle::onMenuPathChanged() {
}
}
QsMenuEntry* DBusMenuHandle::menu() const {
return this->loaded ? &this->mMenu->rootItem : nullptr;
}
QsMenuEntry* DBusMenuHandle::menu() { return this->loaded ? &this->mMenu->rootItem : nullptr; }
QDebug operator<<(QDebug debug, const DBusMenuHandle* handle) {
if (handle) {

View file

@ -162,19 +162,15 @@ class DBusMenuHandle;
QDebug operator<<(QDebug debug, const DBusMenuHandle* handle);
class DBusMenuHandle: public menu::QsMenuHandle {
Q_OBJECT;
QML_ELEMENT;
QML_UNCREATABLE("");
public:
explicit DBusMenuHandle(QObject* parent): menu::QsMenuHandle(parent) {}
void setAddress(const QString& service, const QString& path);
void ref() override;
void unref() override;
void refHandle() override;
void unrefHandle() override;
[[nodiscard]] QsMenuEntry* menu() const override;
[[nodiscard]] QsMenuEntry* menu() override;
private:
void onMenuPathChanged();