Changeset View
Changeset View
Standalone View
Standalone View
plugin/appmenumodel.h
Context not available. | |||||
19 | * | 19 | * | ||
---|---|---|---|---|---|
20 | ******************************************************************/ | 20 | ******************************************************************/ | ||
21 | 21 | | |||
22 | #ifndef APPMENUMODEL_H | ||||
23 | #define APPMENUMODEL_H | ||||
24 | | ||||
22 | #include <QAbstractListModel> | 25 | #include <QAbstractListModel> | ||
23 | #include <QAbstractNativeEventFilter> | 26 | #include <QAbstractNativeEventFilter> | ||
24 | #include <QStringList> | 27 | #include <QStringList> | ||
25 | #include <KWindowSystem> | 28 | #include <KWindowSystem> | ||
26 | #include <QPointer> | 29 | #include <QPointer> | ||
30 | #include <QRect> | ||||
27 | 31 | | |||
28 | class QMenu; | 32 | class QMenu; | ||
29 | class QAction; | 33 | class QAction; | ||
Context not available. | |||||
36 | Q_OBJECT | 40 | Q_OBJECT | ||
37 | 41 | | |||
38 | Q_PROPERTY(bool menuAvailable READ menuAvailable WRITE setMenuAvailable NOTIFY menuAvailableChanged) | 42 | Q_PROPERTY(bool menuAvailable READ menuAvailable WRITE setMenuAvailable NOTIFY menuAvailableChanged) | ||
43 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | ||||
44 | | ||||
45 | Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) | ||||
39 | 46 | | |||
40 | public: | 47 | public: | ||
41 | explicit AppMenuModel(QObject *parent = 0); | 48 | explicit AppMenuModel(QObject *parent = nullptr); | ||
42 | ~AppMenuModel(); | 49 | ~AppMenuModel() override; | ||
43 | 50 | | |||
44 | enum AppMenuRole { | 51 | enum AppMenuRole { | ||
45 | MenuRole = Qt::UserRole+1, | 52 | MenuRole = Qt::UserRole+1, // TODO this should be Qt::DisplayRole | ||
46 | ActionRole | 53 | ActionRole | ||
47 | }; | 54 | }; | ||
48 | 55 | | |||
49 | QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; | 56 | QVariant data(const QModelIndex &index, int role) const override; | ||
50 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | 57 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
51 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | 58 | QHash<int, QByteArray> roleNames() const override; | ||
52 | 59 | | |||
53 | void updateApplicationMenu(const QString &serviceName, const QString &menuObjectPath); | 60 | void updateApplicationMenu(const QString &serviceName, const QString &menuObjectPath); | ||
54 | 61 | | |||
55 | bool menuAvailable() const; | 62 | bool menuAvailable() const; | ||
56 | void setMenuAvailable(bool set); | 63 | void setMenuAvailable(bool set); | ||
57 | 64 | | |||
65 | bool visible() const; | ||||
66 | | ||||
67 | QRect screenGeometry() const; | ||||
68 | void setScreenGeometry(QRect geometry); | ||||
69 | | ||||
58 | signals: | 70 | signals: | ||
59 | void requestActivateIndex(int index); | 71 | void requestActivateIndex(int index); | ||
60 | 72 | | |||
Context not available. | |||||
63 | 75 | | |||
64 | private Q_SLOTS: | 76 | private Q_SLOTS: | ||
65 | void onActiveWindowChanged(WId id); | 77 | void onActiveWindowChanged(WId id); | ||
78 | void onWindowChanged(WId id); | ||||
79 | void setVisible(bool visible); | ||||
66 | void update(); | 80 | void update(); | ||
67 | 81 | | |||
68 | signals: | 82 | signals: | ||
69 | void menuAvailableChanged(); | 83 | void menuAvailableChanged(); | ||
70 | void modelNeedsUpdate(); | 84 | void modelNeedsUpdate(); | ||
85 | void screenGeometryChanged(); | ||||
86 | void visibleChanged(); | ||||
71 | 87 | | |||
72 | private: | 88 | private: | ||
73 | bool m_menuAvailable; | 89 | bool m_menuAvailable; | ||
90 | bool m_updatePending = false; | ||||
91 | bool m_visible = true; | ||||
92 | | ||||
93 | QRect m_screenGeometry; | ||||
74 | 94 | | |||
95 | //! current active window used | ||||
75 | WId m_currentWindowId = 0; | 96 | WId m_currentWindowId = 0; | ||
97 | //! window that its menu initialization may be delayed | ||||
98 | WId m_delayedMenuWindowId = 0; | ||||
76 | 99 | | |||
77 | QPointer<QMenu> m_menu; | 100 | QPointer<QMenu> m_menu; | ||
78 | QStringList m_activeMenu; | | |||
79 | QList<QAction *> m_activeActions; | | |||
80 | 101 | | |||
81 | QDBusServiceWatcher *m_serviceWatcher; | 102 | QDBusServiceWatcher *m_serviceWatcher; | ||
82 | QString m_serviceName; | 103 | QString m_serviceName; | ||
Context not available. | |||||
85 | QPointer<KDBusMenuImporter> m_importer; | 106 | QPointer<KDBusMenuImporter> m_importer; | ||
86 | }; | 107 | }; | ||
87 | 108 | | |||
109 | #endif | ||||
Context not available. |