#pragma once #include "ApplicationFilterModel.hpp" #include "ApplicationModel.hpp" #include #include #include #include class ApplicationService : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_PROPERTY(ApplicationModel *model READ model CONSTANT) Q_PROPERTY(ApplicationFilterModel *filteredModel READ filteredModel CONSTANT) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) public: explicit ApplicationService(QObject *parent = nullptr); ~ApplicationService() override; static ApplicationService *create(QQmlEngine *engine, QJSEngine *scriptEngine); static ApplicationService *instance(); ApplicationModel *model() const; ApplicationFilterModel *filteredModel() const; QString filter() const; void setFilter(const QString &filter); int count() const; Q_INVOKABLE bool launch(const QString &desktopId) const; Q_INVOKABLE QString displayNameForWindow(const QString &appId, const QString &windowClass) const; Q_INVOKABLE QString iconNameForWindow(const QString &appId, const QString &windowClass) const; Q_INVOKABLE void refresh(); signals: void filterChanged(); void countChanged(); private: ApplicationModel *m_model = nullptr; ApplicationFilterModel *m_filtered = nullptr; };