Skip to content
Phosphor
/
API Reference
Search
PlasmaZones
Libraries
Guides
Brand
Palette
About
GitHub
Discord
Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
DBusMenuModel.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 fuddlesworth
2
// SPDX-License-Identifier: LGPL-2.1-or-later
3
4
#pragma once
5
6
#include <PhosphorServiceSni/phosphorservicesni_export.h>
7
8
#include <QAbstractListModel>
9
#include <QString>
10
11
#include <memory>
12
13
namespace
PhosphorServiceSni
{
14
25
class
PHOSPHORSERVICESNI_EXPORT
DBusMenuModel
:
public
QAbstractListModel
26
{
27
Q_OBJECT
28
Q_DISABLE_COPY_MOVE(
DBusMenuModel
)
29
Q_PROPERTY(QString
service
READ
service
WRITE
setService
NOTIFY
sourceChanged
)
30
Q_PROPERTY(QString
path
READ
path
WRITE
setPath
NOTIFY
sourceChanged
)
31
Q_PROPERTY(
int
rootId
READ
rootId
WRITE
setRootId
NOTIFY
rootIdChanged
)
32
Q_PROPERTY(
bool
valid
READ
valid
NOTIFY
validChanged
)
33
// Mirror of rowCount(): QAbstractListModel doesn't expose count
34
// as a property, so QML's `model.count` evaluates to undefined
35
// without this. Worth keeping the API symmetric with
36
// StatusNotifierItemModel.
37
Q_PROPERTY(
int
count READ
rowCount
NOTIFY
countChanged
)
38
39
public
:
40
enum
Roles
{
41
IdRole
= Qt::UserRole + 1,
42
TypeRole
,
43
LabelRole
,
44
EnabledRole
,
45
VisibleRole
,
46
IconUrlRole
,
47
IconImageRole
,
48
ToggleTypeRole
,
49
ToggleStateRole
,
50
ChildrenDisplayRole
,
51
ShortcutRole
,
52
};
53
Q_ENUM(Roles)
54
55
explicit
DBusMenuModel
(QObject* parent =
nullptr
);
56
~
DBusMenuModel
() override;
57
58
[[nodiscard]] QString
service
() const;
59
void
setService
(const QString&
service
);
60
61
[[nodiscard]] QString
path
() const;
62
void
setPath
(const QString&
path
);
63
64
[[nodiscard]]
int
rootId
() const;
65
void
setRootId
(
int
id
);
66
67
[[nodiscard]]
bool
valid
() const;
68
69
[[nodiscard]]
int
rowCount
(const QModelIndex& parent = {})
const
override
;
70
[[nodiscard]] QVariant
data
(
const
QModelIndex& index,
int
role)
const override
;
71
[[nodiscard]] QHash<int, QByteArray>
roleNames
()
const override
;
72
74
Q_INVOKABLE
void
triggerItem
(
int
row);
78
Q_INVOKABLE
int
aboutToShowSubmenu
(
int
row);
81
Q_INVOKABLE
void
aboutToShow
();
87
Q_INVOKABLE
void
aboutToHide
();
93
Q_INVOKABLE
void
refresh
();
94
95
Q_SIGNALS:
96
void
sourceChanged
();
97
void
rootIdChanged
();
98
void
validChanged
();
99
void
countChanged
();
104
void
loaded
();
110
void
loadFailed
(
const
QString& message);
111
112
private
:
113
class
Private;
114
std::unique_ptr<Private> d;
115
};
116
117
}
// namespace PhosphorServiceSni
PhosphorServiceSni::DBusMenuModel::setRootId
void setRootId(int id)
PhosphorServiceSni::DBusMenuModel::loadFailed
void loadFailed(const QString &message)
Fired when a GetLayout call returns a DBus error: usually means the SNI item advertised a Menu path t...
PhosphorServiceSni::DBusMenuModel::roleNames
QHash< int, QByteArray > roleNames() const override
PhosphorServiceSni::DBusMenuModel::aboutToHide
void aboutToHide()
Tell the item we're hiding this menu.
PhosphorServiceSni::DBusMenuModel::service
QString service() const
PhosphorServiceSni::DBusMenuModel::rootIdChanged
void rootIdChanged()
PhosphorServiceSni::DBusMenuModel::loaded
void loaded()
Fires on EVERY successful GetLayout: not just transitions from invalid → valid.
PhosphorServiceSni::DBusMenuModel::triggerItem
void triggerItem(int row)
Fire a click event at the given row. Calls Event(id, "clicked", ...).
PhosphorServiceSni::DBusMenuModel::setPath
void setPath(const QString &path)
PhosphorServiceSni::DBusMenuModel::setService
void setService(const QString &service)
PhosphorServiceSni::DBusMenuModel::sourceChanged
void sourceChanged()
PhosphorServiceSni::DBusMenuModel::validChanged
void validChanged()
PhosphorServiceSni::DBusMenuModel::aboutToShowSubmenu
int aboutToShowSubmenu(int row)
Call AboutToShow on row's submenu (if it has one) and return its id: the QML layer uses that id as th...
PhosphorServiceSni::DBusMenuModel::Roles
Roles
Definition
DBusMenuModel.h:40
PhosphorServiceSni::DBusMenuModel::ToggleStateRole
@ ToggleStateRole
0 = off, 1 = on, -1 = indeterminate
Definition
DBusMenuModel.h:49
PhosphorServiceSni::DBusMenuModel::ToggleTypeRole
@ ToggleTypeRole
"checkmark" | "radio" | empty
Definition
DBusMenuModel.h:48
PhosphorServiceSni::DBusMenuModel::ShortcutRole
@ ShortcutRole
Definition
DBusMenuModel.h:51
PhosphorServiceSni::DBusMenuModel::TypeRole
@ TypeRole
"standard" | "separator"
Definition
DBusMenuModel.h:42
PhosphorServiceSni::DBusMenuModel::IconImageRole
@ IconImageRole
raw QImage (kept for C++ use; not usable as Image.source)
Definition
DBusMenuModel.h:47
PhosphorServiceSni::DBusMenuModel::EnabledRole
@ EnabledRole
Definition
DBusMenuModel.h:44
PhosphorServiceSni::DBusMenuModel::LabelRole
@ LabelRole
menu text, ampersands already stripped for accel
Definition
DBusMenuModel.h:43
PhosphorServiceSni::DBusMenuModel::VisibleRole
@ VisibleRole
Definition
DBusMenuModel.h:45
PhosphorServiceSni::DBusMenuModel::IconUrlRole
@ IconUrlRole
data:image/png;base64,... URL: bind to Image.source
Definition
DBusMenuModel.h:46
PhosphorServiceSni::DBusMenuModel::ChildrenDisplayRole
@ ChildrenDisplayRole
"submenu" if this entry has children, else empty
Definition
DBusMenuModel.h:50
PhosphorServiceSni::DBusMenuModel::IdRole
@ IdRole
Definition
DBusMenuModel.h:41
PhosphorServiceSni::DBusMenuModel::DBusMenuModel
DBusMenuModel(QObject *parent=nullptr)
PhosphorServiceSni::DBusMenuModel::data
QVariant data(const QModelIndex &index, int role) const override
PhosphorServiceSni::DBusMenuModel::aboutToShow
void aboutToShow()
Tell the item we're about to display this menu: required by the spec before showing the root.
PhosphorServiceSni::DBusMenuModel::refresh
void refresh()
Force a fresh GetLayout against the current service/path.
PhosphorServiceSni::DBusMenuModel::rootId
int rootId() const
PhosphorServiceSni::DBusMenuModel::rowCount
int rowCount(const QModelIndex &parent={}) const override
PhosphorServiceSni::DBusMenuModel::valid
bool valid() const
PhosphorServiceSni::DBusMenuModel::countChanged
void countChanged()
PhosphorServiceSni::DBusMenuModel::path
QString path() const
PhosphorServiceSni
Definition
DBusMenuModel.h:13
phosphor-service-sni
include
PhosphorServiceSni
DBusMenuModel.h
Generated by
1.15.0