Changeset View
Changeset View
Standalone View
Standalone View
kcms/cursortheme/kcmcursortheme.h
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #ifndef KCMCURSORTHEME_H | 19 | #ifndef KCMCURSORTHEME_H | ||
20 | #define KCMCURSORTHEME_H | 20 | #define KCMCURSORTHEME_H | ||
21 | 21 | | |||
22 | #include <KCModule> | 22 | #include <KQuickAddons/ConfigModule> | ||
23 | #include "themepage.h" | | |||
24 | 23 | | |||
25 | class CursorThemeConfig : public KCModule | 24 | class QStandardItemModel; | ||
25 | | ||||
26 | class CursorThemeModel; | ||||
27 | class SortProxyModel; | ||||
28 | class CursorTheme; | ||||
29 | | ||||
30 | class CursorThemeConfig : public KQuickAddons::ConfigModule | ||||
26 | { | 31 | { | ||
27 | Q_OBJECT | 32 | Q_OBJECT | ||
33 | Q_PROPERTY(bool canInstall READ canInstall WRITE setCanInstall NOTIFY canInstallChanged) | ||||
34 | Q_PROPERTY(bool canResize READ canResize WRITE setCanResize NOTIFY canResizeChanged) | ||||
35 | Q_PROPERTY(bool canConfigure READ canConfigure WRITE setCanConfigure NOTIFY canConfigureChanged) | ||||
36 | Q_PROPERTY(QAbstractItemModel *cursorsModel READ cursorsModel CONSTANT) | ||||
37 | Q_PROPERTY(QAbstractItemModel *sizesModel READ sizesModel CONSTANT) | ||||
38 | Q_PROPERTY(int selectedThemeRow READ selectedThemeRow WRITE setSelectedThemeRow NOTIFY selectedThemeRowChanged) | ||||
39 | Q_PROPERTY(int preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged) | ||||
28 | 40 | | |||
29 | public: | 41 | public: | ||
30 | CursorThemeConfig(QWidget *parent, const QVariantList &); | 42 | CursorThemeConfig(QObject *parent, const QVariantList &); | ||
31 | ~CursorThemeConfig(); | 43 | ~CursorThemeConfig(); | ||
32 | 44 | | |||
33 | public: | 45 | public: | ||
34 | void load() Q_DECL_OVERRIDE; | 46 | void load() Q_DECL_OVERRIDE; | ||
35 | void save() Q_DECL_OVERRIDE; | 47 | void save() Q_DECL_OVERRIDE; | ||
36 | void defaults() Q_DECL_OVERRIDE; | 48 | void defaults() Q_DECL_OVERRIDE; | ||
37 | 49 | | |||
50 | //for QML properties | ||||
51 | bool canInstall() const; | ||||
52 | void setCanInstall(bool can); | ||||
53 | | ||||
54 | bool canResize() const; | ||||
55 | void setCanResize(bool can); | ||||
56 | | ||||
57 | bool canConfigure() const; | ||||
58 | void setCanConfigure(bool can); | ||||
59 | | ||||
60 | int selectedThemeRow() const; | ||||
61 | void setSelectedThemeRow(int row); | ||||
62 | | ||||
63 | /** @returns 0 if in the UI "automatic size" is selected, otherwise | ||||
64 | returns the custom size. */ | ||||
65 | int preferredSize() const; | ||||
66 | void setPreferredSize(int size); | ||||
67 | | ||||
68 | QAbstractItemModel *cursorsModel(); | ||||
69 | QAbstractItemModel *sizesModel(); | ||||
70 | | ||||
71 | Q_SIGNALS: | ||||
72 | void canInstallChanged(); | ||||
73 | void canResizeChanged(); | ||||
74 | void canConfigureChanged(); | ||||
75 | void selectedThemeRowChanged(); | ||||
76 | void preferredSizeChanged(); | ||||
77 | | ||||
78 | public Q_SLOTS: | ||||
79 | void getNewClicked(); | ||||
80 | void installClicked(); | ||||
81 | void removeTheme(int row); | ||||
82 | | ||||
83 | private Q_SLOTS: | ||||
84 | void selectionChanged(); | ||||
85 | /** Updates the size combo box. It loads the size list of the selected cursor | ||||
86 | theme with the corresponding icons and chooses an appropriate entry. It | ||||
87 | enables the combo box and the label if the theme provides more than one | ||||
88 | size, otherwise it disables it. If the size setting is looked in kiosk | ||||
89 | mode, it stays always disabled. */ | ||||
90 | void updateSizeComboBox(); | ||||
91 | | ||||
92 | | ||||
38 | private: | 93 | private: | ||
39 | ThemePage *themepage; | 94 | QModelIndex selectedIndex() const; | ||
95 | bool installThemes(const QString &file); | ||||
96 | /** Applies a given theme, using XFixes, XCursor and KGlobalSettings. | ||||
97 | @param theme The cursor theme to be applied. It is save to pass 0 here | ||||
98 | (will result in \e false as return value). | ||||
99 | @param size The size hint that is used to select the cursor size. | ||||
100 | @returns If the changes could be applied. Will return \e false if \e theme is | ||||
101 | 0 or if the XFixes and XCursor libraries aren't available in the required | ||||
102 | version, otherwise returns \e true. */ | ||||
103 | bool applyTheme(const CursorTheme *theme, const int size); | ||||
104 | bool iconsIsWritable() const; | ||||
105 | | ||||
106 | | ||||
107 | CursorThemeModel *m_model; | ||||
108 | SortProxyModel *m_proxyModel; | ||||
109 | QStandardItemModel *m_sizesModel; | ||||
110 | | ||||
111 | int m_appliedSize; | ||||
112 | // This index refers to the CursorThemeModel, not the proxy or the view | ||||
113 | QPersistentModelIndex m_appliedIndex; | ||||
114 | | ||||
115 | /** Holds the last size that was choosen by the user. Example: The user chooses | ||||
116 | theme1 which provides the sizes 24 and 36. He chooses 36. preferredSize gets | ||||
117 | set to 36. Now, he switchs to theme2 which provides the sizes 30 and 40. | ||||
118 | preferredSize still is 36, so the UI will default to 40, which is next to 36. | ||||
119 | Now, he chooses theme3 which provides the sizes 34 and 44. preferredSize is | ||||
120 | still 36, so the UI defaults to 34. Now the user changes manually to 44. This | ||||
121 | will also change preferredSize. */ | ||||
122 | int m_preferredSize; | ||||
123 | | ||||
124 | int m_selectedThemeRow; | ||||
125 | bool m_canInstall; | ||||
126 | bool m_canResize; | ||||
127 | bool m_canConfigure; | ||||
40 | }; | 128 | }; | ||
41 | 129 | | |||
42 | #endif | 130 | #endif |