File indexing completed on 2024-05-05 09:56:36
0001 /* 0002 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QStandardItemModel> 0010 0011 #include <kconfig.h> 0012 #include <kconfiggroup.h> 0013 0014 namespace Plasma 0015 { 0016 class Containment; 0017 class ContainmentActions; 0018 } 0019 0020 class QQuickItem; 0021 0022 // This model load the data about available containment actions plugins, such as context menus that can be loaded on mouse click 0023 // TODO: out of the library? 0024 class CurrentContainmentActionsModel : public QStandardItemModel 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 enum Roles { 0030 ActionRole = Qt::UserRole + 1, 0031 PluginNameRole, 0032 HasConfigurationInterfaceRole, 0033 }; 0034 0035 explicit CurrentContainmentActionsModel(Plasma::Containment *containment, QObject *parent = nullptr); 0036 ~CurrentContainmentActionsModel() override; 0037 0038 QHash<int, QByteArray> roleNames() const override; 0039 0040 Q_INVOKABLE bool isTriggerUsed(const QString &trigger); 0041 Q_INVOKABLE QString mouseEventString(int mouseButtons, int modifiers); 0042 Q_INVOKABLE QString wheelEventString(QObject *quickWheelEvent); 0043 Q_INVOKABLE bool append(const QString &action, const QString &plugin); 0044 Q_INVOKABLE void update(int row, const QString &action, const QString &plugin); 0045 Q_INVOKABLE void remove(int row); 0046 Q_INVOKABLE void showConfiguration(int row, QQuickItem *ctx = nullptr); 0047 Q_INVOKABLE QVariant aboutMetaData(int row) const; 0048 Q_INVOKABLE void save(); 0049 0050 Q_SIGNALS: 0051 void configurationChanged(); 0052 0053 private: 0054 Plasma::Containment *m_containment; 0055 QHash<QString, Plasma::ContainmentActions *> m_plugins; 0056 KConfigGroup m_baseCfg; 0057 KConfigGroup m_tempConfig; 0058 KConfig m_tempConfigParent; 0059 QStringList m_removedTriggers; 0060 };