From 1dbc0e3c88ba271ba35bc3f82e7864c4f35e1236 Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Sun, 25 May 2025 12:13:31 +0200 Subject: Initial Commit --- src/lib/xdgdesktopentries.h | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/lib/xdgdesktopentries.h (limited to 'src/lib/xdgdesktopentries.h') diff --git a/src/lib/xdgdesktopentries.h b/src/lib/xdgdesktopentries.h new file mode 100644 index 0000000..89aff08 --- /dev/null +++ b/src/lib/xdgdesktopentries.h @@ -0,0 +1,58 @@ +#ifndef XDGDESKTOPENTRIES_H +#define XDGDESKTOPENTRIES_H + +#include +#include +#include "xdgentries.h" + +namespace xdg { + class DesktopEntries : public QAbstractListModel + { + Q_OBJECT + Q_PROPERTY(QStringList categories READ categories NOTIFY categoriesChanged) + xdg::Entries m_entries; + + private slots: + bool _contains(QString path); + //void _reload(QString path); + QStringList _getEntriesFrom(QString path = ""); + void _dataChanged(const QString appid, const QString item, const QString value); + + public: + explicit DesktopEntries(QObject *parent = nullptr); + + enum XdgDesktopEntriesRoles { + PathRole = Qt::UserRole + 1, + NameRole, + IconRole, + CategoryRole, + NoDisplayRole, + KeywordsRole, + ExecRole, + DesktopFileRole, + AppIdRole, + AppNameRole, + EntryRole + }; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash roleNames() const override; + + QStringList categories(); + + public slots: + void start(QString path, const QStringList &args = QStringList()); + void stop(QString path, const QStringList &args = QStringList()); + QString appIdData(QString appid, QString key); + + signals: + void raiseProcess(int pid); + void categoriesChanged(QStringList categories); + + private: + QString m_sources; + }; +} + +#endif // XDGDESKTOPENTRIES_H -- cgit v1.2.3