forked from quickshell/quickshell
all: replace list properties with ObjectModels
This commit is contained in:
parent
6326f60ce2
commit
5016dbf0d4
11 changed files with 201 additions and 152 deletions
|
@ -2,10 +2,9 @@
|
|||
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "../../core/model.hpp"
|
||||
#include "item.hpp"
|
||||
|
||||
namespace SystemTrayStatus { // NOLINT
|
||||
|
@ -108,27 +107,21 @@ signals:
|
|||
class SystemTray: public QObject {
|
||||
Q_OBJECT;
|
||||
/// List of all system tray icons.
|
||||
Q_PROPERTY(QQmlListProperty<SystemTrayItem> items READ items NOTIFY itemsChanged);
|
||||
Q_PROPERTY(ObjectModel<SystemTrayItem>* items READ items CONSTANT);
|
||||
QML_ELEMENT;
|
||||
QML_SINGLETON;
|
||||
|
||||
public:
|
||||
explicit SystemTray(QObject* parent = nullptr);
|
||||
|
||||
[[nodiscard]] QQmlListProperty<SystemTrayItem> items();
|
||||
|
||||
signals:
|
||||
void itemsChanged();
|
||||
[[nodiscard]] ObjectModel<SystemTrayItem>* items();
|
||||
|
||||
private slots:
|
||||
void onItemRegistered(qs::service::sni::StatusNotifierItem* item);
|
||||
void onItemUnregistered(qs::service::sni::StatusNotifierItem* item);
|
||||
|
||||
private:
|
||||
static qsizetype itemsCount(QQmlListProperty<SystemTrayItem>* property);
|
||||
static SystemTrayItem* itemAt(QQmlListProperty<SystemTrayItem>* property, qsizetype index);
|
||||
|
||||
QList<SystemTrayItem*> mItems;
|
||||
ObjectModel<SystemTrayItem> mItems {this};
|
||||
};
|
||||
|
||||
///! Accessor for SystemTrayItem menus.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue