Changeset View
Changeset View
Standalone View
Standalone View
kcms/cursortheme/kcmcursortheme.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | # include <X11/extensions/Xfixes.h> | 54 | # include <X11/extensions/Xfixes.h> | ||
55 | #endif | 55 | #endif | ||
56 | 56 | | |||
57 | K_PLUGIN_FACTORY_WITH_JSON(CursorThemeConfigFactory, "kcm_cursortheme.json", registerPlugin<CursorThemeConfig>();) | 57 | K_PLUGIN_FACTORY_WITH_JSON(CursorThemeConfigFactory, "kcm_cursortheme.json", registerPlugin<CursorThemeConfig>();) | ||
58 | 58 | | |||
59 | CursorThemeConfig::CursorThemeConfig(QObject *parent, const QVariantList &args) | 59 | CursorThemeConfig::CursorThemeConfig(QObject *parent, const QVariantList &args) | ||
60 | : KQuickAddons::ConfigModule(parent, args), | 60 | : KQuickAddons::ConfigModule(parent, args), | ||
61 | m_settings(new CursorThemeSettings), | 61 | m_settings(new CursorThemeSettings), | ||
62 | m_appliedSize(0), | | |||
63 | m_preferredSize(0), | | |||
64 | m_selectedThemeRow(-1), | | |||
65 | m_selectedSizeRow(-1), | | |||
66 | m_originalSelectedThemeRow(-1), | | |||
67 | m_canInstall(true), | 62 | m_canInstall(true), | ||
68 | m_canResize(true), | 63 | m_canResize(true), | ||
69 | m_canConfigure(true) | 64 | m_canConfigure(true) | ||
70 | { | 65 | { | ||
71 | // Unfortunately doesn't generate a ctor taking the parent as parameter | 66 | // Unfortunately doesn't generate a ctor taking the parent as parameter | ||
72 | m_settings->setParent(this); | 67 | m_settings->setParent(this); | ||
68 | m_currentSize = m_settings->cursorSize(); | ||||
69 | m_currentTheme = m_settings->cursorTheme(); | ||||
70 | m_preferredSize = m_currentSize; | ||||
71 | connect(m_settings, &CursorThemeSettings::configChanged, this, &CursorThemeConfig::updateNeedsSave); | ||||
72 | connect(m_settings, &CursorThemeSettings::cursorSizeChanged, this, &CursorThemeConfig::updateNeedsSave); | ||||
73 | connect(m_settings, &CursorThemeSettings::cursorThemeChanged, this, &CursorThemeConfig::updateNeedsSave); | ||||
74 | connect(m_settings, &CursorThemeSettings::cursorThemeChanged, this, &CursorThemeConfig::updateSizeComboBox); | ||||
73 | qmlRegisterType<PreviewWidget>("org.kde.private.kcm_cursortheme", 1, 0, "PreviewWidget"); | 75 | qmlRegisterType<PreviewWidget>("org.kde.private.kcm_cursortheme", 1, 0, "PreviewWidget"); | ||
74 | qmlRegisterType<SortProxyModel>(); | 76 | qmlRegisterType<SortProxyModel>(); | ||
75 | 77 | qmlRegisterType<CursorThemeSettings>(); | |||
76 | KAboutData* aboutData = new KAboutData(QStringLiteral("kcm_cursortheme"), i18n("Cursors"), | 78 | KAboutData* aboutData = new KAboutData(QStringLiteral("kcm_cursortheme"), i18n("Cursors"), | ||
77 | QStringLiteral("1.0"), QString(), KAboutLicense::GPL, i18n("(c) 2003-2007 Fredrik Höglund")); | 79 | QStringLiteral("1.0"), QString(), KAboutLicense::GPL, i18n("(c) 2003-2007 Fredrik Höglund")); | ||
78 | aboutData->addAuthor(i18n("Fredrik Höglund")); | 80 | aboutData->addAuthor(i18n("Fredrik Höglund")); | ||
79 | aboutData->addAuthor(i18n("Marco Martin")); | 81 | aboutData->addAuthor(i18n("Marco Martin")); | ||
80 | setAboutData(aboutData); | 82 | setAboutData(aboutData); | ||
81 | 83 | | |||
82 | m_themeModel = new CursorThemeModel(this); | 84 | m_themeModel = new CursorThemeModel(this); | ||
83 | 85 | | |||
Show All 11 Lines | |||||
95 | } | 97 | } | ||
96 | } | 98 | } | ||
97 | 99 | | |||
98 | CursorThemeConfig::~CursorThemeConfig() | 100 | CursorThemeConfig::~CursorThemeConfig() | ||
99 | { | 101 | { | ||
100 | /* */ | 102 | /* */ | ||
101 | } | 103 | } | ||
102 | 104 | | |||
105 | CursorThemeSettings *CursorThemeConfig::cursorThemeSettings() const | ||||
106 | { | ||||
107 | return m_settings; | ||||
108 | } | ||||
109 | | ||||
103 | void CursorThemeConfig::setCanInstall(bool can) | 110 | void CursorThemeConfig::setCanInstall(bool can) | ||
104 | { | 111 | { | ||
105 | if (m_canInstall == can) { | 112 | if (m_canInstall == can) { | ||
106 | return; | 113 | return; | ||
107 | } | 114 | } | ||
108 | 115 | | |||
109 | m_canInstall = can; | 116 | m_canInstall = can; | ||
110 | emit canInstallChanged(); | 117 | emit canInstallChanged(); | ||
Show All 24 Lines | 141 | { | |||
135 | if (m_canConfigure == can) { | 142 | if (m_canConfigure == can) { | ||
136 | return; | 143 | return; | ||
137 | } | 144 | } | ||
138 | 145 | | |||
139 | m_canConfigure = can; | 146 | m_canConfigure = can; | ||
140 | emit canConfigureChanged(); | 147 | emit canConfigureChanged(); | ||
141 | } | 148 | } | ||
142 | 149 | | |||
143 | bool CursorThemeConfig::canConfigure() const | 150 | int CursorThemeConfig::preferredSize() const | ||
144 | { | 151 | { | ||
145 | return m_canConfigure; | 152 | return m_preferredSize; | ||
146 | } | 153 | } | ||
147 | 154 | | |||
148 | void CursorThemeConfig::setSelectedThemeRow(int row) | 155 | void CursorThemeConfig::setPreferredSize(int size) | ||
149 | { | 156 | { | ||
150 | if (m_selectedThemeRow == row) { | 157 | if (m_preferredSize == size) { | ||
151 | return; | 158 | return; | ||
152 | } | 159 | } | ||
153 | | ||||
154 | m_selectedThemeRow = row; | | |||
155 | emit selectedThemeRowChanged(); | | |||
156 | updateSizeComboBox(); | | |||
157 | | ||||
158 | setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize); | | |||
159 | } | | |||
160 | | ||||
161 | int CursorThemeConfig::selectedThemeRow() const | | |||
162 | { | | |||
163 | return m_selectedThemeRow; | | |||
164 | } | | |||
165 | | ||||
166 | void CursorThemeConfig::setSelectedSizeRow(int row) | | |||
167 | { | | |||
168 | Q_ASSERT (row < m_sizesModel->rowCount() && row >= 0); | | |||
169 | | ||||
170 | // we don't return early if m_selectedSizeRow == row as this is called after the model is changed | | |||
171 | m_selectedSizeRow = row; | | |||
172 | emit selectedSizeRowChanged(); | | |||
173 | | ||||
174 | int size = m_sizesModel->item(row)->data().toInt(); | | |||
175 | | ||||
176 | m_preferredSize = size; | 160 | m_preferredSize = size; | ||
177 | setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize); | 161 | emit preferredSizeChanged(); | ||
ervin: Once you got the NOTIFY part of the property it'll be emitted from here. | |||||
178 | } | 162 | } | ||
179 | 163 | | |||
180 | int CursorThemeConfig::selectedSizeRow() const | 164 | bool CursorThemeConfig::canConfigure() const | ||
181 | { | 165 | { | ||
182 | return m_selectedSizeRow; | 166 | return m_canConfigure; | ||
183 | } | 167 | } | ||
184 | 168 | | |||
185 | bool CursorThemeConfig::downloadingFile() const | 169 | bool CursorThemeConfig::downloadingFile() const | ||
186 | { | 170 | { | ||
187 | return m_tempCopyJob; | 171 | return m_tempCopyJob; | ||
188 | } | 172 | } | ||
189 | 173 | | |||
190 | | ||||
191 | | ||||
192 | QAbstractItemModel *CursorThemeConfig::cursorsModel() | 174 | QAbstractItemModel *CursorThemeConfig::cursorsModel() | ||
193 | { | 175 | { | ||
194 | return m_themeProxyModel; | 176 | return m_themeProxyModel; | ||
195 | } | 177 | } | ||
196 | 178 | | |||
197 | QAbstractItemModel *CursorThemeConfig::sizesModel() | 179 | QAbstractItemModel *CursorThemeConfig::sizesModel() | ||
198 | { | 180 | { | ||
199 | return m_sizesModel; | 181 | return m_sizesModel; | ||
200 | } | 182 | } | ||
201 | 183 | | |||
202 | bool CursorThemeConfig::iconsIsWritable() const | 184 | bool CursorThemeConfig::iconsIsWritable() const | ||
203 | { | 185 | { | ||
204 | const QFileInfo icons = QFileInfo(QDir::homePath() + "/.icons"); | 186 | const QFileInfo icons = QFileInfo(QDir::homePath() + "/.icons"); | ||
205 | const QFileInfo home = QFileInfo(QDir::homePath()); | 187 | const QFileInfo home = QFileInfo(QDir::homePath()); | ||
206 | 188 | | |||
207 | return ((icons.exists() && icons.isDir() && icons.isWritable()) || | 189 | return ((icons.exists() && icons.isDir() && icons.isWritable()) || | ||
208 | (!icons.exists() && home.isWritable())); | 190 | (!icons.exists() && home.isWritable())); | ||
209 | } | 191 | } | ||
210 | 192 | | |||
211 | 193 | | |||
212 | void CursorThemeConfig::updateSizeComboBox() | 194 | void CursorThemeConfig::updateSizeComboBox() | ||
213 | { | 195 | { | ||
214 | | ||||
215 | // clear the combo box | 196 | // clear the combo box | ||
216 | m_sizesModel->clear(); | 197 | m_sizesModel->clear(); | ||
217 | 198 | | |||
218 | // refill the combo box and adopt its icon size | 199 | // refill the combo box and adopt its icon size | ||
219 | QModelIndex selected = themeSelectedIndex(); | 200 | int row = cursorThemeIndex(m_settings->cursorTheme()); | ||
201 | QModelIndex selected = m_themeProxyModel->index(row, 0); | ||||
220 | int maxIconWidth = 0; | 202 | int maxIconWidth = 0; | ||
221 | int maxIconHeight = 0; | 203 | int maxIconHeight = 0; | ||
222 | if (selected.isValid()) { | 204 | if (selected.isValid()) { | ||
223 | const CursorTheme *theme = m_themeProxyModel->theme(selected); | 205 | const CursorTheme *theme = m_themeProxyModel->theme(selected); | ||
224 | const QList<int> sizes = theme->availableSizes(); | 206 | const QList<int> sizes = theme->availableSizes(); | ||
225 | QIcon m_icon; | 207 | QIcon m_icon; | ||
226 | // only refill the combobox if there is more that 1 size | 208 | // only refill the combobox if there is more that 1 size | ||
227 | if (sizes.size() > 1) { | 209 | if (sizes.size() > 1) { | ||
Show All 24 Lines | 227 | foreach (i, sizes) { | |||
252 | } | 234 | } | ||
253 | QStandardItem *item = new QStandardItem(QIcon(m_pixmap), QString::number(i)); | 235 | QStandardItem *item = new QStandardItem(QIcon(m_pixmap), QString::number(i)); | ||
254 | item->setData(i); | 236 | item->setData(i); | ||
255 | m_sizesModel->appendRow(item); | 237 | m_sizesModel->appendRow(item); | ||
256 | comboBoxList << i; | 238 | comboBoxList << i; | ||
257 | } | 239 | } | ||
258 | 240 | | |||
259 | // select an item | 241 | // select an item | ||
260 | int selectItem = comboBoxList.indexOf(m_preferredSize); | 242 | int size = m_preferredSize; | ||
261 | // m_preferredSize not available for this theme | 243 | int selectItem = comboBoxList.indexOf(size); | ||
244 | | ||||
245 | // cursor size not available for this theme | ||||
262 | if (selectItem < 0) { | 246 | if (selectItem < 0) { | ||
263 | /* Search the value next to m_preferredSize. The first entry (0) | 247 | /* Search the value next to cursor size. The first entry (0) | ||
264 | is ignored. (If m_preferredSize would have been 0, then we | 248 | is ignored. (If cursor size would have been 0, then we | ||
265 | would had found it yet. As m_preferredSize is not 0, we won't | 249 | would had found it yet. As cursor size is not 0, we won't | ||
266 | default to "automatic size".)*/ | 250 | default to "automatic size".)*/ | ||
267 | int j; | 251 | int j; | ||
268 | int distance; | 252 | int distance; | ||
269 | int smallestDistance; | 253 | int smallestDistance; | ||
270 | selectItem = 1; | 254 | selectItem = 1; | ||
271 | j = comboBoxList.value(selectItem); | 255 | j = comboBoxList.value(selectItem); | ||
272 | smallestDistance = j < m_preferredSize ? m_preferredSize - j : j - m_preferredSize; | 256 | size = j; | ||
257 | smallestDistance = qAbs(m_preferredSize - j); | ||||
273 | for (int i = 2; i < comboBoxList.size(); ++i) { | 258 | for (int i = 2; i < comboBoxList.size(); ++i) { | ||
274 | j = comboBoxList.value(i); | 259 | j = comboBoxList.value(i); | ||
275 | distance = j < m_preferredSize ? m_preferredSize - j : j - m_preferredSize; | 260 | distance = qAbs(m_preferredSize - j); | ||
276 | if (distance < smallestDistance || (distance == smallestDistance && j > m_preferredSize)) { | 261 | if (distance < smallestDistance || (distance == smallestDistance && j > m_preferredSize)) { | ||
277 | smallestDistance = distance; | 262 | smallestDistance = distance; | ||
278 | selectItem = i; | 263 | selectItem = i; | ||
264 | size = j; | ||||
279 | } | 265 | } | ||
280 | } | 266 | } | ||
281 | } | 267 | } | ||
282 | if (selectItem < 0) { | 268 | if (selectItem < 0) { | ||
283 | selectItem = 0; | 269 | selectItem = 0; | ||
284 | } | 270 | } | ||
285 | setSelectedSizeRow(selectItem); | 271 | m_settings->setCursorSize(size); | ||
286 | } | 272 | } | ||
287 | } | 273 | } | ||
288 | 274 | | |||
289 | // enable or disable the combobox | 275 | // enable or disable the combobox | ||
290 | if (m_settings->isImmutable("cursorSize")) { | 276 | if (m_settings->isImmutable("cursorSize")) { | ||
291 | setCanResize(false); | 277 | setCanResize(false); | ||
292 | } else { | 278 | } else { | ||
293 | setCanResize(m_sizesModel->rowCount() > 0); | 279 | setCanResize(m_sizesModel->rowCount() > 0); | ||
294 | } | 280 | } | ||
295 | 281 | // We need to emit a cursorSizeChanged in all case to refresh UI | |||
282 | emit m_settings->cursorSizeChanged(); | ||||
296 | } | 283 | } | ||
297 | 284 | | |||
298 | bool CursorThemeConfig::applyTheme(const CursorTheme *theme, const int size) | 285 | bool CursorThemeConfig::applyTheme(const CursorTheme *theme, const int size) | ||
299 | { | 286 | { | ||
300 | // Require the Xcursor version that shipped with X11R6.9 or greater, since | 287 | // Require the Xcursor version that shipped with X11R6.9 or greater, since | ||
301 | // in previous versions the Xfixes code wasn't enabled due to a bug in the | 288 | // in previous versions the Xfixes code wasn't enabled due to a bug in the | ||
302 | // build system (freedesktop bug #975). | 289 | // build system (freedesktop bug #975). | ||
303 | #if HAVE_XFIXES && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | 290 | #if HAVE_XFIXES && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | ||
Show All 37 Lines | 324 | names << "X_cursor" << "right_ptr" << "hand1" | |||
341 | << "top_left_corner" << "top_side" << "top_right_corner" | 328 | << "top_left_corner" << "top_side" << "top_right_corner" | ||
342 | << "right_side" << "bottom_right_corner" << "bottom_side" | 329 | << "right_side" << "bottom_right_corner" << "bottom_side" | ||
343 | << "bottom_left_corner" << "left_side" << "question_arrow" | 330 | << "bottom_left_corner" << "left_side" << "question_arrow" | ||
344 | << "pirate"; | 331 | << "pirate"; | ||
345 | 332 | | |||
346 | foreach (const QString &name, names) { | 333 | foreach (const QString &name, names) { | ||
347 | XFixesChangeCursorByName(QX11Info::display(), theme->loadCursor(name, size), QFile::encodeName(name)); | 334 | XFixesChangeCursorByName(QX11Info::display(), theme->loadCursor(name, size), QFile::encodeName(name)); | ||
348 | } | 335 | } | ||
349 | 336 | updateSizeComboBox(); | |||
350 | return true; | 337 | return true; | ||
351 | #else | 338 | #else | ||
352 | Q_UNUSED(theme) | 339 | Q_UNUSED(theme) | ||
353 | return false; | 340 | return false; | ||
354 | #endif | 341 | #endif | ||
355 | } | 342 | } | ||
356 | 343 | | |||
344 | int CursorThemeConfig::cursorSizeIndex(int cursorSize) const | ||||
ervin: int, not const inst | |||||
345 | { | ||||
346 | if (m_sizesModel->rowCount() > 0) { | ||||
347 | if (cursorSize == 0) { | ||||
348 | return 0; | ||||
349 | } | ||||
350 | const auto items = m_sizesModel->findItems(QString::number(cursorSize)); | ||||
351 | if (items.count() == 1) { | ||||
352 | return items.first()->row(); | ||||
353 | } | ||||
354 | } | ||||
355 | return -1; | ||||
356 | } | ||||
357 | 357 | | |||
358 | void CursorThemeConfig::save() | 358 | int CursorThemeConfig::cursorSizeFromIndex(int index) | ||
ervin: s/row/index/ | |||||
359 | { | 359 | { | ||
360 | const CursorTheme *theme = themeSelectedIndex().isValid() ? m_themeProxyModel->theme(themeSelectedIndex()) : nullptr; | 360 | Q_ASSERT (index < m_sizesModel->rowCount() && index >= 0); | ||
361 | 361 | | |||
362 | if (theme) { | 362 | return m_sizesModel->item(index)->data().toInt(); | ||
363 | m_settings->setCursorTheme(theme->name()); | 363 | } | ||
364 | | ||||
365 | int CursorThemeConfig::cursorThemeIndex(const QString &cursorTheme) const | ||||
366 | { | ||||
367 | auto results = m_themeProxyModel->findIndex(cursorTheme); | ||||
368 | return results.row(); | ||||
369 | } | ||||
370 | | ||||
371 | QString CursorThemeConfig::cursorThemeFromIndex(int index) const | ||||
372 | { | ||||
373 | QModelIndex idx = m_themeProxyModel->index(index, 0); | ||||
374 | return m_themeProxyModel->theme(idx)->name(); | ||||
364 | } | 375 | } | ||
365 | m_settings->setCursorSize(m_preferredSize); | | |||
366 | 376 | | |||
377 | void CursorThemeConfig::save() | ||||
378 | { | ||||
367 | m_settings->save(); | 379 | m_settings->save(); | ||
380 | m_currentTheme = m_settings->cursorTheme(); | ||||
381 | m_currentSize = m_settings->cursorSize(); | ||||
382 | setPreferredSize(m_currentSize); | ||||
383 | | ||||
384 | int row = cursorThemeIndex(m_settings->cursorTheme()); | ||||
385 | QModelIndex selected = m_themeProxyModel->index(row, 0); | ||||
386 | const CursorTheme *theme = selected.isValid() ? m_themeProxyModel->theme(selected) : nullptr; | ||||
368 | 387 | | |||
369 | if (!applyTheme(theme, m_preferredSize)) { | 388 | if (!applyTheme(theme, m_currentSize)) { | ||
370 | emit showInfoMessage(i18n("You have to restart the Plasma session for these changes to take effect.")); | 389 | emit showInfoMessage(i18n("You have to restart the Plasma session for these changes to take effect.")); | ||
371 | } | 390 | } | ||
372 | | ||||
373 | m_appliedIndex = themeSelectedIndex(); | | |||
374 | m_appliedSize = m_preferredSize; | | |||
375 | m_originalSelectedThemeRow = m_selectedThemeRow; | | |||
376 | m_originalPreferredSize = m_preferredSize; | | |||
377 | setNeedsSave(false); | 391 | setNeedsSave(false); | ||
378 | } | 392 | } | ||
379 | 393 | | |||
380 | 394 | | |||
381 | void CursorThemeConfig::load() | 395 | void CursorThemeConfig::load() | ||
382 | { | 396 | { | ||
397 | m_settings->load(); | ||||
398 | m_currentSize = m_settings->cursorSize(); | ||||
399 | m_currentTheme = m_settings->cursorTheme(); | ||||
400 | setPreferredSize(m_currentSize); | ||||
383 | // Get the name of the theme KDE is configured to use | 401 | // Get the name of the theme KDE is configured to use | ||
384 | QString currentTheme = m_settings->cursorTheme(); | 402 | QString currentTheme = m_settings->cursorTheme(); | ||
385 | 403 | | |||
386 | // Find the theme in the listview | | |||
387 | if (!currentTheme.isEmpty()) { | | |||
388 | m_appliedIndex = m_themeProxyModel->findIndex(currentTheme); | | |||
389 | } else { | | |||
390 | m_appliedIndex = m_themeProxyModel->defaultIndex(); | | |||
391 | } | | |||
392 | | ||||
393 | // Disable the listview and the buttons if we're in kiosk mode | 404 | // Disable the listview and the buttons if we're in kiosk mode | ||
394 | if (m_settings->isImmutable( QStringLiteral( "cursorTheme" ))) { | 405 | if (m_settings->isImmutable( QStringLiteral( "cursorTheme" ))) { | ||
395 | setCanConfigure(false); | 406 | setCanConfigure(false); | ||
396 | setCanInstall(false); | 407 | setCanInstall(false); | ||
397 | } | 408 | } | ||
398 | 409 | | |||
399 | setSelectedThemeRow(m_appliedIndex.row()); | | |||
400 | m_originalSelectedThemeRow = m_selectedThemeRow; | | |||
401 | | ||||
402 | // Load cursor size | | |||
403 | int size = m_settings->cursorSize(); | | |||
404 | if (size <= 0) { | | |||
405 | m_preferredSize = 0; | | |||
406 | } else { | | |||
407 | m_preferredSize = size; | | |||
408 | } | | |||
409 | m_originalPreferredSize = m_preferredSize; | | |||
410 | updateSizeComboBox(); // This handles also the kiosk mode | 410 | updateSizeComboBox(); // This handles also the kiosk mode | ||
411 | 411 | | |||
412 | m_appliedSize = size; | | |||
413 | | ||||
414 | | ||||
415 | setNeedsSave(false); | 412 | setNeedsSave(false); | ||
416 | } | 413 | } | ||
417 | 414 | | |||
418 | 415 | | |||
419 | void CursorThemeConfig::defaults() | 416 | void CursorThemeConfig::defaults() | ||
420 | { | 417 | { | ||
421 | QModelIndex defaultIndex = m_themeProxyModel->findIndex(m_settings->defaultCursorThemeValue()); | 418 | m_settings->setDefaults(); | ||
422 | setSelectedThemeRow(defaultIndex.row()); | 419 | m_preferredSize = m_settings->cursorSize(); | ||
423 | m_preferredSize = m_settings->defaultCursorSizeValue(); | | |||
424 | updateSizeComboBox(); | | |||
425 | setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize); | | |||
426 | } | 420 | } | ||
427 | 421 | | |||
428 | QModelIndex CursorThemeConfig::themeSelectedIndex() const | 422 | void CursorThemeConfig::updateNeedsSave() | ||
429 | { | 423 | { | ||
430 | return m_themeProxyModel->index(m_selectedThemeRow, 0); | 424 | setNeedsSave(m_settings->cursorTheme() != m_currentTheme || m_settings->cursorSize() != m_currentSize); | ||
431 | } | 425 | } | ||
432 | 426 | | |||
433 | void CursorThemeConfig::getNewClicked() | 427 | void CursorThemeConfig::getNewClicked() | ||
434 | { | 428 | { | ||
435 | KNS3::DownloadDialog dialog("xcursor.knsrc", nullptr); | 429 | KNS3::DownloadDialog dialog("xcursor.knsrc", nullptr); | ||
436 | if (dialog.exec()) { | 430 | if (dialog.exec()) { | ||
437 | KNS3::Entry::List list = dialog.changedEntries(); | 431 | KNS3::Entry::List list = dialog.changedEntries(); | ||
438 | if (!list.isEmpty()) { | 432 | if (!list.isEmpty()) { | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 573 | { | |||
580 | QModelIndex idx = m_themeProxyModel->index(row, 0); | 574 | QModelIndex idx = m_themeProxyModel->index(row, 0); | ||
581 | if (!idx.isValid()) { | 575 | if (!idx.isValid()) { | ||
582 | return; | 576 | return; | ||
583 | } | 577 | } | ||
584 | 578 | | |||
585 | const CursorTheme *theme = m_themeProxyModel->theme(idx); | 579 | const CursorTheme *theme = m_themeProxyModel->theme(idx); | ||
586 | 580 | | |||
587 | // Don't let the user delete the currently configured theme | 581 | // Don't let the user delete the currently configured theme | ||
588 | if (idx == m_appliedIndex) { | 582 | if (theme->name() == m_currentTheme) { | ||
589 | KMessageBox::sorry(nullptr, i18n("<qt>You cannot delete the theme you are currently " | 583 | KMessageBox::sorry(nullptr, i18n("<qt>You cannot delete the theme you are currently " | ||
590 | "using.<br />You have to switch to another theme first.</qt>")); | 584 | "using.<br />You have to switch to another theme first.</qt>")); | ||
591 | return; | 585 | return; | ||
592 | } | 586 | } | ||
593 | 587 | | |||
594 | // Get confirmation from the user | 588 | // Get confirmation from the user | ||
595 | QString question = i18n("<qt>Are you sure you want to remove the " | 589 | QString question = i18n("<qt>Are you sure you want to remove the " | ||
596 | "<i>%1</i> cursor theme?<br />" | 590 | "<i>%1</i> cursor theme?<br />" | ||
Show All 26 Lines |
Once you got the NOTIFY part of the property it'll be emitted from here.