Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinrules/detectwidget.h
Show All 16 Lines | |||||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | 19 | | |||
20 | #ifndef __DETECTWIDGET_H__ | 20 | #ifndef __DETECTWIDGET_H__ | ||
21 | #define __DETECTWIDGET_H__ | 21 | #define __DETECTWIDGET_H__ | ||
22 | 22 | | |||
23 | #include <QDialog> | 23 | #include <QDialog> | ||
24 | #include <kwindowsystem.h> | 24 | #include <kwindowsystem.h> | ||
25 | #include <QAbstractNativeEventFilter> | | |||
26 | 25 | | |||
27 | #include "../../rules.h" | 26 | #include "../../rules.h" | ||
28 | //Added by qt3to4: | 27 | //Added by qt3to4: | ||
29 | #include <QEvent> | 28 | #include <QEvent> | ||
30 | #include <QByteArray> | 29 | #include <QByteArray> | ||
31 | 30 | | |||
32 | #include "ui_detectwidget.h" | 31 | #include "ui_detectwidget.h" | ||
33 | 32 | | |||
34 | namespace KWin | 33 | namespace KWin | ||
35 | { | 34 | { | ||
36 | 35 | | |||
37 | class DetectWidget | 36 | class DetectWidget | ||
38 | : public QWidget, public Ui_DetectWidget | 37 | : public QWidget, public Ui_DetectWidget | ||
39 | { | 38 | { | ||
40 | Q_OBJECT | 39 | Q_OBJECT | ||
41 | public: | 40 | public: | ||
42 | explicit DetectWidget(QWidget* parent = nullptr); | 41 | explicit DetectWidget(QWidget* parent = nullptr); | ||
43 | }; | 42 | }; | ||
44 | 43 | | |||
45 | class DetectDialog | 44 | class DetectDialog | ||
46 | : public QDialog, public QAbstractNativeEventFilter | 45 | : public QDialog | ||
47 | { | 46 | { | ||
48 | Q_OBJECT | 47 | Q_OBJECT | ||
49 | public: | 48 | public: | ||
50 | explicit DetectDialog(QWidget* parent = nullptr, const char* name = nullptr); | 49 | explicit DetectDialog(QWidget* parent = nullptr, const char* name = nullptr); | ||
51 | void detect(WId window, int secs = 0); | 50 | void detect(int secs = 0); | ||
52 | QByteArray selectedClass() const; | 51 | QByteArray selectedClass() const; | ||
53 | bool selectedWholeClass() const; | 52 | bool selectedWholeClass() const; | ||
54 | QByteArray selectedRole() const; | 53 | QByteArray selectedRole() const; | ||
55 | bool selectedWholeApp() const; | 54 | bool selectedWholeApp() const; | ||
56 | NET::WindowType selectedType() const; | 55 | NET::WindowType selectedType() const; | ||
57 | QString selectedTitle() const; | 56 | QString selectedTitle() const; | ||
58 | Rules::StringMatch titleMatch() const; | 57 | Rules::StringMatch titleMatch() const; | ||
59 | QByteArray selectedMachine() const; | 58 | QByteArray selectedMachine() const; | ||
60 | const KWindowInfo& windowInfo() const; | | |||
61 | 59 | | |||
62 | virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) override; | 60 | const QVariantMap &windowInfo() const { | ||
61 | return m_windowInfo; | ||||
62 | } | ||||
63 | | ||||
63 | Q_SIGNALS: | 64 | Q_SIGNALS: | ||
64 | void detectionDone(bool); | 65 | void detectionDone(bool); | ||
65 | private Q_SLOTS: | 66 | private Q_SLOTS: | ||
66 | void selectWindow(); | 67 | void selectWindow(); | ||
67 | private: | 68 | private: | ||
68 | void readWindow(WId window); | | |||
69 | void executeDialog(); | 69 | void executeDialog(); | ||
70 | WId findWindow(); | | |||
71 | QByteArray wmclass_class; | 70 | QByteArray wmclass_class; | ||
72 | QByteArray wmclass_name; | 71 | QByteArray wmclass_name; | ||
73 | QByteArray role; | 72 | QByteArray role; | ||
74 | NET::WindowType type; | 73 | NET::WindowType type; | ||
75 | QString title; | 74 | QString title; | ||
76 | QByteArray extrarole; | 75 | QByteArray extrarole; | ||
77 | QByteArray machine; | 76 | QByteArray machine; | ||
78 | DetectWidget* widget; | 77 | DetectWidget* widget; | ||
79 | QScopedPointer<QDialog> grabber; | 78 | QVariantMap m_windowInfo; | ||
80 | QScopedPointer<KWindowInfo> info; | | |||
81 | }; | 79 | }; | ||
82 | 80 | | |||
83 | inline | | |||
84 | const KWindowInfo& DetectDialog::windowInfo() const | | |||
85 | { | | |||
86 | Q_ASSERT(!info.isNull()); | | |||
87 | return *(info.data()); | | |||
88 | } | | |||
89 | | ||||
90 | } // namespace | 81 | } // namespace | ||
91 | 82 | | |||
92 | #endif | 83 | #endif |