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 | void CursorThemeConfig::setPreferredSize(int size) | ||
144 | { | | |||
145 | return m_canConfigure; | | |||
146 | } | | |||
147 | | ||||
148 | void CursorThemeConfig::setSelectedThemeRow(int row) | | |||
149 | { | | |||
150 | if (m_selectedThemeRow == row) { | | |||
151 | return; | | |||
152 | } | | |||
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 | { | 151 | { | ||
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; | 152 | m_preferredSize = size; | ||
177 | setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize); | | |||
178 | } | 153 | } | ||
ervin: Once you got the NOTIFY part of the property it'll be emitted from here. | |||||
179 | 154 | | |||
180 | int CursorThemeConfig::selectedSizeRow() const | 155 | bool CursorThemeConfig::canConfigure() const | ||
181 | { | 156 | { | ||
182 | return m_selectedSizeRow; | 157 | return m_canConfigure; | ||
183 | } | 158 | } | ||
184 | 159 | | |||
185 | bool CursorThemeConfig::downloadingFile() const | 160 | bool CursorThemeConfig::downloadingFile() const | ||
186 | { | 161 | { | ||
187 | return m_tempCopyJob; | 162 | return m_tempCopyJob; | ||
188 | } | 163 | } | ||
189 | 164 | | |||
190 | | ||||
191 | | ||||
192 | QAbstractItemModel *CursorThemeConfig::cursorsModel() | 165 | QAbstractItemModel *CursorThemeConfig::cursorsModel() | ||
193 | { | 166 | { | ||
194 | return m_themeProxyModel; | 167 | return m_themeProxyModel; | ||
195 | } | 168 | } | ||
196 | 169 | | |||
197 | QAbstractItemModel *CursorThemeConfig::sizesModel() | 170 | QAbstractItemModel *CursorThemeConfig::sizesModel() | ||
198 | { | 171 | { | ||
199 | return m_sizesModel; | 172 | return m_sizesModel; | ||
200 | } | 173 | } | ||
201 | 174 | | |||
202 | bool CursorThemeConfig::iconsIsWritable() const | 175 | bool CursorThemeConfig::iconsIsWritable() const | ||
203 | { | 176 | { | ||
204 | const QFileInfo icons = QFileInfo(QDir::homePath() + "/.icons"); | 177 | const QFileInfo icons = QFileInfo(QDir::homePath() + "/.icons"); | ||
205 | const QFileInfo home = QFileInfo(QDir::homePath()); | 178 | const QFileInfo home = QFileInfo(QDir::homePath()); | ||
206 | 179 | | |||
207 | return ((icons.exists() && icons.isDir() && icons.isWritable()) || | 180 | return ((icons.exists() && icons.isDir() && icons.isWritable()) || | ||
208 | (!icons.exists() && home.isWritable())); | 181 | (!icons.exists() && home.isWritable())); | ||
209 | } | 182 | } | ||
210 | 183 | | |||
211 | 184 | | |||
212 | void CursorThemeConfig::updateSizeComboBox() | 185 | void CursorThemeConfig::updateSizeComboBox() | ||
213 | { | 186 | { | ||
214 | | ||||
215 | // clear the combo box | 187 | // clear the combo box | ||
216 | m_sizesModel->clear(); | 188 | m_sizesModel->clear(); | ||
217 | 189 | | |||
218 | // refill the combo box and adopt its icon size | 190 | // refill the combo box and adopt its icon size | ||
219 | QModelIndex selected = themeSelectedIndex(); | 191 | int row = cursorThemeIndex(m_settings->cursorTheme()); | ||
192 | QModelIndex selected = m_themeProxyModel->index(row, 0); | ||||
220 | int maxIconWidth = 0; | 193 | int maxIconWidth = 0; | ||
221 | int maxIconHeight = 0; | 194 | int maxIconHeight = 0; | ||
222 | if (selected.isValid()) { | 195 | if (selected.isValid()) { | ||
223 | const CursorTheme *theme = m_themeProxyModel->theme(selected); | 196 | const CursorTheme *theme = m_themeProxyModel->theme(selected); | ||
224 | const QList<int> sizes = theme->availableSizes(); | 197 | const QList<int> sizes = theme->availableSizes(); | ||
225 | QIcon m_icon; | 198 | QIcon m_icon; | ||
226 | // only refill the combobox if there is more that 1 size | 199 | // only refill the combobox if there is more that 1 size | ||
227 | if (sizes.size() > 1) { | 200 | if (sizes.size() > 1) { | ||
Show All 24 Lines | 218 | foreach (i, sizes) { | |||
252 | } | 225 | } | ||
253 | QStandardItem *item = new QStandardItem(QIcon(m_pixmap), QString::number(i)); | 226 | QStandardItem *item = new QStandardItem(QIcon(m_pixmap), QString::number(i)); | ||
254 | item->setData(i); | 227 | item->setData(i); | ||
255 | m_sizesModel->appendRow(item); | 228 | m_sizesModel->appendRow(item); | ||
256 | comboBoxList << i; | 229 | comboBoxList << i; | ||
257 | } | 230 | } | ||
258 | 231 | | |||
259 | // select an item | 232 | // select an item | ||
260 | int selectItem = comboBoxList.indexOf(m_preferredSize); | 233 | int size = m_preferredSize; | ||
261 | // m_preferredSize not available for this theme | 234 | int selectItem = comboBoxList.indexOf(size); | ||
235 | | ||||
236 | // cursor size not available for this theme | ||||
262 | if (selectItem < 0) { | 237 | if (selectItem < 0) { | ||
263 | /* Search the value next to m_preferredSize. The first entry (0) | 238 | /* Search the value next to cursor size. The first entry (0) | ||
264 | is ignored. (If m_preferredSize would have been 0, then we | 239 | 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 | 240 | would had found it yet. As cursor size is not 0, we won't | ||
266 | default to "automatic size".)*/ | 241 | default to "automatic size".)*/ | ||
267 | int j; | 242 | int j; | ||
268 | int distance; | 243 | int distance; | ||
269 | int smallestDistance; | 244 | int smallestDistance; | ||
270 | selectItem = 1; | 245 | selectItem = 1; | ||
271 | j = comboBoxList.value(selectItem); | 246 | j = comboBoxList.value(selectItem); | ||
272 | smallestDistance = j < m_preferredSize ? m_preferredSize - j : j - m_preferredSize; | 247 | size = j; | ||
248 | smallestDistance = qAbs(m_preferredSize - j); | ||||
273 | for (int i = 2; i < comboBoxList.size(); ++i) { | 249 | for (int i = 2; i < comboBoxList.size(); ++i) { | ||
274 | j = comboBoxList.value(i); | 250 | j = comboBoxList.value(i); | ||
275 | distance = j < m_preferredSize ? m_preferredSize - j : j - m_preferredSize; | 251 | distance = qAbs(m_preferredSize - j); | ||
276 | if (distance < smallestDistance || (distance == smallestDistance && j > m_preferredSize)) { | 252 | if (distance < smallestDistance || (distance == smallestDistance && j > m_preferredSize)) { | ||
277 | smallestDistance = distance; | 253 | smallestDistance = distance; | ||
278 | selectItem = i; | 254 | selectItem = i; | ||
255 | size = j; | ||||
279 | } | 256 | } | ||
280 | } | 257 | } | ||
281 | } | 258 | } | ||
282 | if (selectItem < 0) { | 259 | if (selectItem < 0) { | ||
283 | selectItem = 0; | 260 | selectItem = 0; | ||
284 | } | 261 | } | ||
285 | setSelectedSizeRow(selectItem); | 262 | m_settings->setCursorSize(size); | ||
286 | } | 263 | } | ||
287 | } | 264 | } | ||
288 | 265 | | |||
289 | // enable or disable the combobox | 266 | // enable or disable the combobox | ||
290 | if (m_settings->isImmutable("cursorSize")) { | 267 | if (m_settings->isImmutable("cursorSize")) { | ||
291 | setCanResize(false); | 268 | setCanResize(false); | ||
292 | } else { | 269 | } else { | ||
293 | setCanResize(m_sizesModel->rowCount() > 0); | 270 | setCanResize(m_sizesModel->rowCount() > 0); | ||
294 | } | 271 | } | ||
295 | 272 | // We need to emit a cursorSizeChanged in all case to refresh UI | |||
273 | emit m_settings->cursorSizeChanged(); | ||||
296 | } | 274 | } | ||
297 | 275 | | |||
298 | bool CursorThemeConfig::applyTheme(const CursorTheme *theme, const int size) | 276 | bool CursorThemeConfig::applyTheme(const CursorTheme *theme, const int size) | ||
299 | { | 277 | { | ||
300 | // Require the Xcursor version that shipped with X11R6.9 or greater, since | 278 | // 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 | 279 | // in previous versions the Xfixes code wasn't enabled due to a bug in the | ||
302 | // build system (freedesktop bug #975). | 280 | // build system (freedesktop bug #975). | ||
303 | #if HAVE_XFIXES && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | 281 | #if HAVE_XFIXES && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | ||
Show All 37 Lines | 315 | names << "X_cursor" << "right_ptr" << "hand1" | |||
341 | << "top_left_corner" << "top_side" << "top_right_corner" | 319 | << "top_left_corner" << "top_side" << "top_right_corner" | ||
342 | << "right_side" << "bottom_right_corner" << "bottom_side" | 320 | << "right_side" << "bottom_right_corner" << "bottom_side" | ||
343 | << "bottom_left_corner" << "left_side" << "question_arrow" | 321 | << "bottom_left_corner" << "left_side" << "question_arrow" | ||
344 | << "pirate"; | 322 | << "pirate"; | ||
345 | 323 | | |||
346 | foreach (const QString &name, names) { | 324 | foreach (const QString &name, names) { | ||
347 | XFixesChangeCursorByName(QX11Info::display(), theme->loadCursor(name, size), QFile::encodeName(name)); | 325 | XFixesChangeCursorByName(QX11Info::display(), theme->loadCursor(name, size), QFile::encodeName(name)); | ||
348 | } | 326 | } | ||
349 | 327 | updateSizeComboBox(); | |||
350 | return true; | 328 | return true; | ||
351 | #else | 329 | #else | ||
352 | Q_UNUSED(theme) | 330 | Q_UNUSED(theme) | ||
353 | return false; | 331 | return false; | ||
354 | #endif | 332 | #endif | ||
355 | } | 333 | } | ||
356 | 334 | | |||
335 | int CursorThemeConfig::cursorSizeIndex(const int cursorSize) const | ||||
ervin: int, not const inst | |||||
336 | { | ||||
337 | if (m_sizesModel->rowCount() > 0) { | ||||
338 | if (cursorSize == 0) { | ||||
339 | return 0; | ||||
340 | } | ||||
341 | const auto items = m_sizesModel->findItems(QString::number(cursorSize)); | ||||
342 | if (items.count() == 1) { | ||||
343 | return items.first()->row(); | ||||
344 | } | ||||
345 | } | ||||
346 | return -1; | ||||
347 | } | ||||
357 | 348 | | |||
358 | void CursorThemeConfig::save() | 349 | int CursorThemeConfig::cursorSizeFromIndex(int row) | ||
ervin: s/row/index/ | |||||
359 | { | 350 | { | ||
360 | const CursorTheme *theme = themeSelectedIndex().isValid() ? m_themeProxyModel->theme(themeSelectedIndex()) : nullptr; | 351 | Q_ASSERT (row < m_sizesModel->rowCount() && row >= 0); | ||
361 | 352 | | |||
362 | if (theme) { | 353 | return m_sizesModel->item(row)->data().toInt(); | ||
363 | m_settings->setCursorTheme(theme->name()); | | |||
364 | } | 354 | } | ||
365 | m_settings->setCursorSize(m_preferredSize); | | |||
366 | 355 | | |||
356 | int CursorThemeConfig::cursorThemeIndex(const QString &cursorTheme) const | ||||
357 | { | ||||
358 | auto results = m_themeProxyModel->findIndex(cursorTheme); | ||||
359 | return results.row(); | ||||
360 | } | ||||
361 | | ||||
362 | QString CursorThemeConfig::cursorThemeFromIndex(int index) const | ||||
363 | { | ||||
364 | QModelIndex idx = m_themeProxyModel->index(index, 0); | ||||
365 | return m_themeProxyModel->theme(idx)->name(); | ||||
366 | } | ||||
367 | | ||||
368 | void CursorThemeConfig::save() | ||||
369 | { | ||||
367 | m_settings->save(); | 370 | m_settings->save(); | ||
371 | m_currentTheme = m_settings->cursorTheme(); | ||||
372 | m_currentSize = m_settings->cursorSize(); | ||||
373 | setPreferredSize(m_currentSize); | ||||
374 | | ||||
375 | int row = cursorThemeIndex(m_settings->cursorTheme()); | ||||
376 | QModelIndex selected = m_themeProxyModel->index(row, 0); | ||||
377 | const CursorTheme *theme = selected.isValid() ? m_themeProxyModel->theme(selected) : nullptr; | ||||
368 | 378 | | |||
369 | if (!applyTheme(theme, m_preferredSize)) { | 379 | if (!applyTheme(theme, m_currentSize)) { | ||
370 | emit showInfoMessage(i18n("You have to restart the Plasma session for these changes to take effect.")); | 380 | emit showInfoMessage(i18n("You have to restart the Plasma session for these changes to take effect.")); | ||
371 | } | 381 | } | ||
372 | | ||||
373 | m_appliedIndex = themeSelectedIndex(); | | |||
374 | m_appliedSize = m_preferredSize; | | |||
375 | m_originalSelectedThemeRow = m_selectedThemeRow; | | |||
376 | m_originalPreferredSize = m_preferredSize; | | |||
377 | setNeedsSave(false); | 382 | setNeedsSave(false); | ||
378 | } | 383 | } | ||
379 | 384 | | |||
380 | 385 | | |||
381 | void CursorThemeConfig::load() | 386 | void CursorThemeConfig::load() | ||
382 | { | 387 | { | ||
383 | m_settings->load(); | 388 | m_settings->load(); | ||
389 | m_currentSize = m_settings->cursorSize(); | ||||
390 | m_currentTheme = m_settings->cursorTheme(); | ||||
391 | setPreferredSize(m_currentSize); | ||||
384 | // Get the name of the theme KDE is configured to use | 392 | // Get the name of the theme KDE is configured to use | ||
385 | QString currentTheme = m_settings->cursorTheme(); | 393 | QString currentTheme = m_settings->cursorTheme(); | ||
386 | 394 | | |||
387 | // Find the theme in the listview | | |||
388 | if (!currentTheme.isEmpty()) { | | |||
389 | m_appliedIndex = m_themeProxyModel->findIndex(currentTheme); | | |||
390 | } else { | | |||
391 | m_appliedIndex = m_themeProxyModel->defaultIndex(); | | |||
392 | } | | |||
393 | | ||||
394 | // Disable the listview and the buttons if we're in kiosk mode | 395 | // Disable the listview and the buttons if we're in kiosk mode | ||
395 | if (m_settings->isImmutable( QStringLiteral( "cursorTheme" ))) { | 396 | if (m_settings->isImmutable( QStringLiteral( "cursorTheme" ))) { | ||
396 | setCanConfigure(false); | 397 | setCanConfigure(false); | ||
397 | setCanInstall(false); | 398 | setCanInstall(false); | ||
398 | } | 399 | } | ||
399 | 400 | | |||
400 | setSelectedThemeRow(m_appliedIndex.row()); | | |||
401 | m_originalSelectedThemeRow = m_selectedThemeRow; | | |||
402 | | ||||
403 | // Load cursor size | | |||
404 | int size = m_settings->cursorSize(); | | |||
405 | if (size <= 0) { | | |||
406 | m_preferredSize = 0; | | |||
407 | } else { | | |||
408 | m_preferredSize = size; | | |||
409 | } | | |||
410 | m_originalPreferredSize = m_preferredSize; | | |||
411 | updateSizeComboBox(); // This handles also the kiosk mode | 401 | updateSizeComboBox(); // This handles also the kiosk mode | ||
412 | 402 | | |||
413 | m_appliedSize = size; | | |||
414 | | ||||
415 | | ||||
416 | setNeedsSave(false); | 403 | setNeedsSave(false); | ||
417 | } | 404 | } | ||
418 | 405 | | |||
419 | 406 | | |||
420 | void CursorThemeConfig::defaults() | 407 | void CursorThemeConfig::defaults() | ||
421 | { | 408 | { | ||
422 | QModelIndex defaultIndex = m_themeProxyModel->findIndex(m_settings->defaultCursorThemeValue()); | 409 | m_settings->setDefaults(); | ||
423 | setSelectedThemeRow(defaultIndex.row()); | 410 | m_preferredSize = m_settings->cursorSize(); | ||
424 | m_preferredSize = m_settings->defaultCursorSizeValue(); | | |||
425 | updateSizeComboBox(); | | |||
426 | setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize); | | |||
427 | } | 411 | } | ||
428 | 412 | | |||
429 | QModelIndex CursorThemeConfig::themeSelectedIndex() const | 413 | void CursorThemeConfig::updateNeedsSave() | ||
430 | { | 414 | { | ||
431 | return m_themeProxyModel->index(m_selectedThemeRow, 0); | 415 | setNeedsSave(m_settings->cursorTheme() != m_currentTheme || m_settings->cursorSize() != m_currentSize); | ||
432 | } | 416 | } | ||
433 | 417 | | |||
434 | void CursorThemeConfig::getNewClicked() | 418 | void CursorThemeConfig::getNewClicked() | ||
435 | { | 419 | { | ||
436 | KNS3::DownloadDialog dialog("xcursor.knsrc", nullptr); | 420 | KNS3::DownloadDialog dialog("xcursor.knsrc", nullptr); | ||
437 | if (dialog.exec()) { | 421 | if (dialog.exec()) { | ||
438 | KNS3::Entry::List list = dialog.changedEntries(); | 422 | KNS3::Entry::List list = dialog.changedEntries(); | ||
439 | if (!list.isEmpty()) { | 423 | if (!list.isEmpty()) { | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 564 | { | |||
581 | QModelIndex idx = m_themeProxyModel->index(row, 0); | 565 | QModelIndex idx = m_themeProxyModel->index(row, 0); | ||
582 | if (!idx.isValid()) { | 566 | if (!idx.isValid()) { | ||
583 | return; | 567 | return; | ||
584 | } | 568 | } | ||
585 | 569 | | |||
586 | const CursorTheme *theme = m_themeProxyModel->theme(idx); | 570 | const CursorTheme *theme = m_themeProxyModel->theme(idx); | ||
587 | 571 | | |||
588 | // Don't let the user delete the currently configured theme | 572 | // Don't let the user delete the currently configured theme | ||
589 | if (idx == m_appliedIndex) { | 573 | if (theme->name() == m_currentTheme) { | ||
590 | KMessageBox::sorry(nullptr, i18n("<qt>You cannot delete the theme you are currently " | 574 | KMessageBox::sorry(nullptr, i18n("<qt>You cannot delete the theme you are currently " | ||
591 | "using.<br />You have to switch to another theme first.</qt>")); | 575 | "using.<br />You have to switch to another theme first.</qt>")); | ||
592 | return; | 576 | return; | ||
593 | } | 577 | } | ||
594 | 578 | | |||
595 | // Get confirmation from the user | 579 | // Get confirmation from the user | ||
596 | QString question = i18n("<qt>Are you sure you want to remove the " | 580 | QString question = i18n("<qt>Are you sure you want to remove the " | ||
597 | "<i>%1</i> cursor theme?<br />" | 581 | "<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.