Flat model exposing ONE level of a com.canonical.dbusmenu tree at a time.
More...
#include <phosphor-services/include/PhosphorServices/DBusMenuModel.h>
|
| enum | Roles {
IdRole = Qt::UserRole + 1
, TypeRole
, LabelRole
, EnabledRole
,
VisibleRole
, IconUrlRole
, IconImageRole
, ToggleTypeRole
,
ToggleStateRole
, ChildrenDisplayRole
, ShortcutRole
} |
| |
|
| void | sourceChanged () |
| |
| void | rootIdChanged () |
| |
| void | validChanged () |
| |
| void | countChanged () |
| |
| void | loaded () |
| | Fires on EVERY successful GetLayout — not just transitions from invalid → valid.
|
| |
| void | loadFailed (const QString &message) |
| | Fired when a GetLayout call returns a DBus error — usually means the SNI item advertised a Menu path that's stale, broken, or implemented as something other than canonical dbusmenu.
|
| |
|
| | DBusMenuModel (QObject *parent=nullptr) |
| |
| | ~DBusMenuModel () override |
| |
| QString | service () const |
| |
| void | setService (const QString &service) |
| |
| QString | path () const |
| |
| void | setPath (const QString &path) |
| |
| int | rootId () const |
| |
| void | setRootId (int id) |
| |
| bool | valid () const |
| |
| int | rowCount (const QModelIndex &parent={}) const override |
| |
| QVariant | data (const QModelIndex &index, int role) const override |
| |
| QHash< int, QByteArray > | roleNames () const override |
| |
| void | triggerItem (int row) |
| | Fire a click event at the given row. Calls Event(id, "clicked", ...).
|
| |
| 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 the rootId for the cascaded child model.
|
| |
| void | aboutToShow () |
| | Tell the item we're about to display this menu — required by the spec before showing the root.
|
| |
| void | aboutToHide () |
| |
| void | refresh () |
| | Force a fresh GetLayout against the current service/path.
|
| |
Flat model exposing ONE level of a com.canonical.dbusmenu tree at a time.
Tree mode (QAbstractItemModel) is awkward to drive from QML — most shells render submenus as cascading popups instead, so each popup binds a fresh DBusMenuModel pointing at a different rootId.
Construct one with the SNI item's dbusService + the menu object path from StatusNotifierItem::menuPath(). The model then drives itself: GetLayout on construction, LayoutUpdated/ItemsPropertiesUpdated signals to refresh.
◆ Roles
| Enumerator |
|---|
| IdRole | |
| TypeRole | "standard" | "separator"
|
| LabelRole | menu text, ampersands already stripped for accel
|
| EnabledRole | |
| VisibleRole | |
| IconUrlRole | data:image/png;base64,... URL — bind to Image.source
|
| IconImageRole | raw QImage (kept for C++ use; not usable as Image.source)
|
| ToggleTypeRole | "checkmark" | "radio" | empty
|
| ToggleStateRole | 0 = off, 1 = on, -1 = indeterminate
|
| ChildrenDisplayRole | "submenu" if this entry has children, else empty
|
| ShortcutRole | |
◆ DBusMenuModel()
| PhosphorServices::DBusMenuModel::DBusMenuModel |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
◆ ~DBusMenuModel()
| PhosphorServices::DBusMenuModel::~DBusMenuModel |
( |
| ) |
|
|
override |
◆ aboutToHide()
| void PhosphorServices::DBusMenuModel::aboutToHide |
( |
| ) |
|
◆ aboutToShow()
| void PhosphorServices::DBusMenuModel::aboutToShow |
( |
| ) |
|
Tell the item we're about to display this menu — required by the spec before showing the root.
Idempotent on repeated calls.
◆ aboutToShowSubmenu()
| int PhosphorServices::DBusMenuModel::aboutToShowSubmenu |
( |
int |
row | ) |
|
Call AboutToShow on row's submenu (if it has one) and return its id — the QML layer uses that id as the rootId for the cascaded child model.
◆ countChanged
| void PhosphorServices::DBusMenuModel::countChanged |
( |
| ) |
|
|
signal |
◆ data()
| QVariant PhosphorServices::DBusMenuModel::data |
( |
const QModelIndex & |
index, |
|
|
int |
role |
|
) |
| const |
|
override |
◆ loaded
| void PhosphorServices::DBusMenuModel::loaded |
( |
| ) |
|
|
signal |
Fires on EVERY successful GetLayout — not just transitions from invalid → valid.
Used by QML to remap the popup when the same menu is re-opened (validChanged stays silent in that case because the bool didn't change).
◆ loadFailed
| void PhosphorServices::DBusMenuModel::loadFailed |
( |
const QString & |
message | ) |
|
|
signal |
Fired when a GetLayout call returns a DBus error — usually means the SNI item advertised a Menu path that's stale, broken, or implemented as something other than canonical dbusmenu.
QML can listen and dismiss the popup so the user doesn't stare at an empty floating box.
◆ path()
| QString PhosphorServices::DBusMenuModel::path |
( |
| ) |
const |
◆ refresh()
| void PhosphorServices::DBusMenuModel::refresh |
( |
| ) |
|
Force a fresh GetLayout against the current service/path.
Used by the QML side when re-opening the SAME menu — setService/ setPath early-return when values are unchanged, so without this the model never re-fetches and never re-fires loaded, leaving the popup unable to remap.
◆ roleNames()
| QHash< int, QByteArray > PhosphorServices::DBusMenuModel::roleNames |
( |
| ) |
const |
|
override |
◆ rootId()
| int PhosphorServices::DBusMenuModel::rootId |
( |
| ) |
const |
◆ rootIdChanged
| void PhosphorServices::DBusMenuModel::rootIdChanged |
( |
| ) |
|
|
signal |
◆ rowCount()
| int PhosphorServices::DBusMenuModel::rowCount |
( |
const QModelIndex & |
parent = {} | ) |
const |
|
override |
◆ service()
| QString PhosphorServices::DBusMenuModel::service |
( |
| ) |
const |
◆ setPath()
| void PhosphorServices::DBusMenuModel::setPath |
( |
const QString & |
path | ) |
|
◆ setRootId()
| void PhosphorServices::DBusMenuModel::setRootId |
( |
int |
id | ) |
|
◆ setService()
| void PhosphorServices::DBusMenuModel::setService |
( |
const QString & |
service | ) |
|
◆ sourceChanged
| void PhosphorServices::DBusMenuModel::sourceChanged |
( |
| ) |
|
|
signal |
◆ triggerItem()
| void PhosphorServices::DBusMenuModel::triggerItem |
( |
int |
row | ) |
|
Fire a click event at the given row. Calls Event(id, "clicked", ...).
◆ valid()
| bool PhosphorServices::DBusMenuModel::valid |
( |
| ) |
const |
◆ validChanged
| void PhosphorServices::DBusMenuModel::validChanged |
( |
| ) |
|
|
signal |
The documentation for this class was generated from the following file: