core/menu: add QsMenuAnchor for more control of platform menus

This commit is contained in:
outfoxxed 2024-07-25 20:44:26 -07:00
parent 54350277be
commit 6b9b1fcb53
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
10 changed files with 245 additions and 21 deletions

View file

@ -141,12 +141,8 @@ void SystemTrayItem::display(QObject* parentWindow, qint32 relativeX, qint32 rel
if (!success) delete platform;
};
if (handle->menu()) {
onMenuChanged();
} else {
QObject::connect(handle, &DBusMenuHandle::menuChanged, this, onMenuChanged);
}
if (handle->menu()) onMenuChanged();
QObject::connect(handle, &DBusMenuHandle::menuChanged, this, onMenuChanged);
handle->refHandle();
}

View file

@ -70,6 +70,8 @@ class SystemTrayItem: public QObject {
/// If this tray item has an associated menu accessible via @@display() or @@menu.
Q_PROPERTY(bool hasMenu READ hasMenu NOTIFY hasMenuChanged);
/// A handle to the menu associated with this tray item, if any.
///
/// Can be displayed with @@Quickshell.QsMenuAnchor or @@Quickshell.QsMenuOpener.
Q_PROPERTY(QsMenuHandle* menu READ menu NOTIFY hasMenuChanged);
/// If this tray item only offers a menu and activation will do nothing.
Q_PROPERTY(bool onlyMenu READ onlyMenu NOTIFY onlyMenuChanged);