Changeset View
Changeset View
Standalone View
Standalone View
imports/activitymanager/switcherbackend.h
Show All 39 Lines | |||||
40 | class QJSEngine; | 40 | class QJSEngine; | ||
41 | 41 | | |||
42 | namespace KIO { class PreviewJob; } | 42 | namespace KIO { class PreviewJob; } | ||
43 | 43 | | |||
44 | class SwitcherBackend : public QObject { | 44 | class SwitcherBackend : public QObject { | ||
45 | Q_OBJECT | 45 | Q_OBJECT | ||
46 | 46 | | |||
47 | Q_PROPERTY(bool shouldShowSwitcher READ shouldShowSwitcher WRITE setShouldShowSwitcher NOTIFY shouldShowSwitcherChanged) | 47 | Q_PROPERTY(bool shouldShowSwitcher READ shouldShowSwitcher WRITE setShouldShowSwitcher NOTIFY shouldShowSwitcherChanged) | ||
48 | Q_PROPERTY(bool dropEnabled READ dropEnabled CONSTANT) | ||||
48 | 49 | | |||
49 | 50 | | |||
50 | public: | 51 | public: | ||
51 | explicit SwitcherBackend(QObject *parent = nullptr); | 52 | explicit SwitcherBackend(QObject *parent = nullptr); | ||
52 | ~SwitcherBackend() override; | 53 | ~SwitcherBackend() override; | ||
53 | 54 | | |||
54 | static QObject *instance(QQmlEngine *engine, QJSEngine *scriptEngine); | 55 | static QObject *instance(QQmlEngine *engine, QJSEngine *scriptEngine); | ||
55 | 56 | | |||
56 | Q_SIGNALS: | 57 | Q_SIGNALS: | ||
57 | void showSwitchNotification(const QString &id, const QString &name, const QString &icon); | 58 | void showSwitchNotification(const QString &id, const QString &name, const QString &icon); | ||
58 | void shouldShowSwitcherChanged(bool value); | 59 | void shouldShowSwitcherChanged(bool value); | ||
59 | 60 | | |||
60 | public Q_SLOTS: | 61 | public Q_SLOTS: | ||
61 | void init(); | 62 | void init(); | ||
62 | 63 | | |||
63 | bool shouldShowSwitcher() const; | 64 | bool shouldShowSwitcher() const; | ||
64 | void setShouldShowSwitcher(bool shouldShowSwitcher); | 65 | void setShouldShowSwitcher(bool shouldShowSwitcher); | ||
65 | 66 | | |||
66 | QAbstractItemModel *runningActivitiesModel() const; | 67 | QAbstractItemModel *runningActivitiesModel() const; | ||
67 | QAbstractItemModel *stoppedActivitiesModel() const; | 68 | QAbstractItemModel *stoppedActivitiesModel() const; | ||
68 | 69 | | |||
69 | void setCurrentActivity(const QString &activity); | 70 | void setCurrentActivity(const QString &activity); | ||
70 | void stopActivity(const QString &activity); | 71 | void stopActivity(const QString &activity); | ||
71 | 72 | | |||
73 | void setDropMode(bool value); | ||||
74 | void drop(QMimeData* mimeData, int modifiers, const QVariant &activityId); | ||||
75 | bool dropEnabled() const; | ||||
76 | | ||||
72 | private: | 77 | private: | ||
73 | template <typename Handler> | 78 | template <typename Handler> | ||
74 | inline void registerShortcut(const QString &actionName, const QString &name, | 79 | inline void registerShortcut(const QString &actionName, const QString &name, | ||
75 | const QKeySequence &shortcut, | 80 | const QKeySequence &shortcut, | ||
76 | Handler &&handler); | 81 | Handler &&handler); | ||
77 | 82 | | |||
78 | enum Direction { | 83 | enum Direction { | ||
79 | Next, | 84 | Next, | ||
Show All 14 Lines | |||||
94 | private: | 99 | private: | ||
95 | QHash<QString, QKeySequence> m_actionShortcut; | 100 | QHash<QString, QKeySequence> m_actionShortcut; | ||
96 | QAction *m_lastInvokedAction = nullptr; | 101 | QAction *m_lastInvokedAction = nullptr; | ||
97 | KActivities::Controller m_activities; | 102 | KActivities::Controller m_activities; | ||
98 | bool m_shouldShowSwitcher; | 103 | bool m_shouldShowSwitcher; | ||
99 | QTimer m_modKeyPollingTimer; | 104 | QTimer m_modKeyPollingTimer; | ||
100 | QString m_previousActivity; | 105 | QString m_previousActivity; | ||
101 | 106 | | |||
107 | bool m_dropModeActive; | ||||
108 | QTimer m_dropModeHider; | ||||
109 | | ||||
102 | SortedActivitiesModel *m_runningActivitiesModel = nullptr; | 110 | SortedActivitiesModel *m_runningActivitiesModel = nullptr; | ||
103 | SortedActivitiesModel *m_stoppedActivitiesModel = nullptr; | 111 | SortedActivitiesModel *m_stoppedActivitiesModel = nullptr; | ||
104 | 112 | | |||
105 | }; | 113 | }; | ||
106 | 114 | | |||
107 | #endif // SWITCHER_BACKEND_H | 115 | #endif // SWITCHER_BACKEND_H |