Changeset View
Changeset View
Standalone View
Standalone View
applets/appmenu/plugin/appmenumodel.h
Show All 16 Lines | |||||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | 19 | * | ||
20 | ******************************************************************/ | 20 | ******************************************************************/ | ||
21 | 21 | | |||
22 | #ifndef APPMENUMODEL_H | 22 | #ifndef APPMENUMODEL_H | ||
23 | #define APPMENUMODEL_H | 23 | #define APPMENUMODEL_H | ||
24 | 24 | | |||
25 | #include <QAction> | ||||
25 | #include <QAbstractListModel> | 26 | #include <QAbstractListModel> | ||
26 | #include <QStringList> | 27 | #include <QStringList> | ||
27 | #include <KWindowSystem> | 28 | #include <KWindowSystem> | ||
28 | #include <QPointer> | 29 | #include <QPointer> | ||
29 | #include <QRect> | 30 | #include <QRect> | ||
30 | #include <tasksmodel.h> | 31 | #include <tasksmodel.h> | ||
31 | 32 | | |||
32 | class QMenu; | 33 | class QMenu; | ||
33 | class QModelIndex; | 34 | class QModelIndex; | ||
34 | class QDBusServiceWatcher; | 35 | class QDBusServiceWatcher; | ||
35 | class KDBusMenuImporter; | 36 | class KDBusMenuImporter; | ||
36 | 37 | | |||
37 | class AppMenuModel : public QAbstractListModel | 38 | class AppMenuModel : public QAbstractListModel | ||
38 | { | 39 | { | ||
39 | Q_OBJECT | 40 | Q_OBJECT | ||
40 | 41 | | |||
41 | Q_PROPERTY(bool menuAvailable READ menuAvailable WRITE setMenuAvailable NOTIFY menuAvailableChanged) | 42 | Q_PROPERTY(bool menuAvailable READ menuAvailable WRITE setMenuAvailable NOTIFY menuAvailableChanged) | ||
42 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | 43 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | ||
43 | 44 | | |||
44 | Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) | 45 | Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) | ||
46 | Q_PROPERTY(bool menuOpen READ menuOpen WRITE setMenuOpen NOTIFY menuOpenChanged) | ||||
45 | 47 | | |||
46 | public: | 48 | public: | ||
47 | explicit AppMenuModel(QObject *parent = nullptr); | 49 | explicit AppMenuModel(QObject *parent = nullptr); | ||
48 | ~AppMenuModel() override; | 50 | ~AppMenuModel() override; | ||
49 | 51 | | |||
50 | enum AppMenuRole { | 52 | enum AppMenuRole { | ||
51 | MenuRole = Qt::UserRole+1, // TODO this should be Qt::DisplayRole | 53 | MenuRole = Qt::UserRole+1, // TODO this should be Qt::DisplayRole | ||
52 | ActionRole | 54 | ActionRole | ||
53 | }; | 55 | }; | ||
54 | 56 | | |||
55 | QVariant data(const QModelIndex &index, int role) const override; | 57 | QVariant data(const QModelIndex &index, int role) const override; | ||
56 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 58 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
57 | QHash<int, QByteArray> roleNames() const override; | 59 | QHash<int, QByteArray> roleNames() const override; | ||
58 | 60 | | |||
59 | void updateApplicationMenu(const QString &serviceName, const QString &menuObjectPath); | 61 | void updateApplicationMenu(const QString &serviceName, const QString &menuObjectPath); | ||
60 | 62 | | |||
61 | bool menuAvailable() const; | 63 | bool menuAvailable() const; | ||
62 | void setMenuAvailable(bool set); | 64 | void setMenuAvailable(bool set); | ||
63 | 65 | | |||
64 | bool visible() const; | 66 | bool visible() const; | ||
65 | 67 | | |||
66 | QRect screenGeometry() const; | 68 | QRect screenGeometry() const; | ||
67 | void setScreenGeometry(QRect geometry); | 69 | void setScreenGeometry(QRect geometry); | ||
70 | QList<QAction*> flatActionList(); | ||||
nicolasfella: const | |||||
cblack: actions are needed as non-const | |||||
71 | | ||||
72 | void setMenuOpen(bool open); | ||||
73 | bool menuOpen(); | ||||
nicolasfella: const | |||||
74 | Q_SIGNAL void menuOpenChanged(); | ||||
68 | 75 | | |||
69 | signals: | 76 | signals: | ||
70 | void requestActivateIndex(int index); | 77 | void requestActivateIndex(int index); | ||
71 | 78 | | |||
72 | private Q_SLOTS: | 79 | private Q_SLOTS: | ||
73 | void onActiveWindowChanged(); | 80 | void onActiveWindowChanged(); | ||
74 | void setVisible(bool visible); | 81 | void setVisible(bool visible); | ||
75 | void update(); | 82 | void update(); | ||
Show All 12 Lines | 90 | private: | |||
88 | TaskManager::TasksModel* m_tasksModel; | 95 | TaskManager::TasksModel* m_tasksModel; | ||
89 | 96 | | |||
90 | //! current active window used | 97 | //! current active window used | ||
91 | WId m_currentWindowId = 0; | 98 | WId m_currentWindowId = 0; | ||
92 | //! window that its menu initialization may be delayed | 99 | //! window that its menu initialization may be delayed | ||
93 | WId m_delayedMenuWindowId = 0; | 100 | WId m_delayedMenuWindowId = 0; | ||
94 | 101 | | |||
95 | QPointer<QMenu> m_menu; | 102 | QPointer<QMenu> m_menu; | ||
103 | QPointer<QAction> m_searchAction; | ||||
104 | QList<QAction*> m_currentSearchActions; | ||||
105 | bool m_menuOpen; | ||||
106 | | ||||
107 | void removeSearchActionsFromMenu(); | ||||
108 | void insertSearchActionsIntoMenu(const QString &filter = QString()); | ||||
96 | 109 | | |||
97 | QDBusServiceWatcher *m_serviceWatcher; | 110 | QDBusServiceWatcher *m_serviceWatcher; | ||
98 | QString m_serviceName; | 111 | QString m_serviceName; | ||
99 | QString m_menuObjectPath; | 112 | QString m_menuObjectPath; | ||
100 | 113 | | |||
101 | QPointer<KDBusMenuImporter> m_importer; | 114 | QPointer<KDBusMenuImporter> m_importer; | ||
102 | }; | 115 | }; | ||
103 | 116 | | |||
104 | #endif | 117 | #endif |
const