File indexing completed on 2024-05-05 17:43:52

0001 /*
0002     SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QString>
0011 #include <QStringList>
0012 
0013 #include "gdbusmenutypes_p.h"
0014 
0015 class Actions : public QObject
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     Actions(const QString &serviceName, const QString &objectPath, QObject *parent = nullptr);
0021     ~Actions() override;
0022 
0023     void load();
0024 
0025     bool get(const QString &name, GMenuAction &action) const;
0026     GMenuActionMap getAll() const;
0027     void trigger(const QString &name, const QVariant &target, uint timestamp = 0);
0028 
0029     bool isValid() const; // basically "has actions"
0030 
0031 Q_SIGNALS:
0032     void loaded();
0033     void failedToLoad(); // expose error?
0034     void actionsChanged(const QStringList &dirtyActions);
0035 
0036 private Q_SLOTS:
0037     void onActionsChanged(const QStringList &removed, const StringBoolMap &enabledChanges, const QVariantMap &stateChanges, const GMenuActionMap &added);
0038 
0039 private:
0040     GMenuActionMap m_actions;
0041 
0042     QString m_serviceName;
0043     QString m_objectPath;
0044 };