Changeset View
Changeset View
Standalone View
Standalone View
kcms/cursortheme/kcmcursortheme.cpp
Show All 33 Lines | |||||
34 | #include <KUrlRequesterDialog> | 34 | #include <KUrlRequesterDialog> | ||
35 | #include <KIO/CopyJob> | 35 | #include <KIO/CopyJob> | ||
36 | #include <KIO/DeleteJob> | 36 | #include <KIO/DeleteJob> | ||
37 | #include <KIO/Job> | 37 | #include <KIO/Job> | ||
38 | #include <KIO/JobUiDelegate> | 38 | #include <KIO/JobUiDelegate> | ||
39 | #include <KTar> | 39 | #include <KTar> | ||
40 | #include <KGlobalSettings> | 40 | #include <KGlobalSettings> | ||
41 | 41 | | |||
42 | #include <KNewStuff3/KNS3/DownloadDialog> | 42 | #include <knewstuffcore_version.h> | ||
43 | #if KNEWSTUFFCORE_VERSION_MAJOR==5 && KNEWSTUFFCORE_VERSION_MINOR>=67 | ||||
44 | #include <KNSCore/EntryWrapper> | ||||
45 | #endif | ||||
43 | 46 | | |||
47 | #include <QQmlListReference> | ||||
44 | #include <QX11Info> | 48 | #include <QX11Info> | ||
45 | #include <QStandardItemModel> | 49 | #include <QStandardItemModel> | ||
46 | 50 | | |||
47 | #include <X11/Xlib.h> | 51 | #include <X11/Xlib.h> | ||
48 | #include <X11/Xcursor/Xcursor.h> | 52 | #include <X11/Xcursor/Xcursor.h> | ||
49 | 53 | | |||
50 | #include "cursorthemesettings.h" | 54 | #include "cursorthemesettings.h" | ||
51 | #include <klauncher_iface.h> | 55 | #include <klauncher_iface.h> | ||
▲ Show 20 Lines • Show All 349 Lines • ▼ Show 20 Line(s) | |||||
401 | void CursorThemeConfig::defaults() | 405 | void CursorThemeConfig::defaults() | ||
402 | { | 406 | { | ||
403 | ManagedConfigModule::defaults(); | 407 | ManagedConfigModule::defaults(); | ||
404 | m_preferredSize = m_settings->cursorSize(); | 408 | m_preferredSize = m_settings->cursorSize(); | ||
405 | } | 409 | } | ||
406 | 410 | | |||
407 | void CursorThemeConfig::getNewClicked() | 411 | void CursorThemeConfig::getNewClicked() | ||
408 | { | 412 | { | ||
409 | KNS3::DownloadDialog dialog("xcursor.knsrc", nullptr); | 413 | #if KNEWSTUFFCORE_VERSION_MAJOR==5 && KNEWSTUFFCORE_VERSION_MINOR>=67 | ||
410 | if (dialog.exec()) { | 414 | for (int i = 0; i < changedEntries.count(); ++i) { | ||
411 | KNS3::Entry::List list = dialog.changedEntries(); | 415 | KNSCore::EntryWrapper* entry = qobject_cast<KNSCore::EntryWrapper*>(changedEntries.at(i)); | ||
412 | if (!list.isEmpty()) { | 416 | if (entry) { | ||
413 | for (const KNS3::Entry& entry : list) { | 417 | if (entry->entry().status() == KNS3::Entry::Deleted) { | ||
414 | if (entry.status() == KNS3::Entry::Deleted) { | 418 | for (const QString& deleted : entry->entry().uninstalledFiles()) { | ||
415 | for (const QString& deleted : entry.uninstalledFiles()) { | | |||
416 | QVector<QStringRef> list = deleted.splitRef(QLatin1Char('/')); | 419 | QVector<QStringRef> list = deleted.splitRef(QLatin1Char('/')); | ||
417 | if (list.last() == QLatin1Char('*')) { | 420 | if (list.last() == QLatin1Char('*')) { | ||
418 | list.takeLast(); | 421 | list.takeLast(); | ||
ngraham: ditto | |||||
Also ditto - all the code here depends on having an entry to work with, and if that can't be pulled out of changedEntries (which doesn't work until 5.67) then there's no particularly good reason to run the other bits of the code :) leinir: Also ditto - all the code here depends on having an entry to work with, and if that can't be… | |||||
419 | } | 422 | } | ||
420 | QModelIndex idx = m_themeModel->findIndex(list.last().toString()); | 423 | QModelIndex idx = m_themeModel->findIndex(list.last().toString()); | ||
421 | if (idx.isValid()) { | 424 | if (idx.isValid()) { | ||
422 | m_themeModel->removeTheme(idx); | 425 | m_themeModel->removeTheme(idx); | ||
423 | } | 426 | } | ||
424 | } | 427 | } | ||
425 | } else if (entry.status() == KNS3::Entry::Installed) { | 428 | } else if (entry->entry().status() == KNS3::Entry::Installed) { | ||
426 | for (const QString& created : entry.installedFiles()) { | 429 | for (const QString& created : entry->entry().installedFiles()) { | ||
427 | QStringList list = created.split(QLatin1Char('/')); | 430 | QStringList list = created.split(QLatin1Char('/')); | ||
428 | if (list.last() == QLatin1Char('*')) { | 431 | if (list.last() == QLatin1Char('*')) { | ||
429 | list.takeLast(); | 432 | list.takeLast(); | ||
430 | } | 433 | } | ||
431 | // Because we sometimes get some extra slashes in the installed files list | 434 | // Because we sometimes get some extra slashes in the installed files list | ||
432 | list.removeAll({}); | 435 | list.removeAll({}); | ||
433 | // Because we'll also get the containing folder, if it was not already there | 436 | // Because we'll also get the containing folder, if it was not already there | ||
434 | // we need to ignore it. | 437 | // we need to ignore it. | ||
435 | if (list.last() == QLatin1String(".icons")) { | 438 | if (list.last() == QLatin1String(".icons")) { | ||
436 | continue; | 439 | continue; | ||
437 | } | 440 | } | ||
438 | m_themeModel->addTheme(QStringLiteral("/%1").arg(list.join(QLatin1Char('/')))); | 441 | m_themeModel->addTheme(list.join(QLatin1Char('/'))); | ||
439 | } | | |||
440 | } | 442 | } | ||
441 | } | 443 | } | ||
442 | } | 444 | } | ||
443 | } | 445 | } | ||
446 | #endif | ||||
444 | } | 447 | } | ||
445 | 448 | | |||
446 | void CursorThemeConfig::installThemeFromFile(const QUrl &url) | 449 | void CursorThemeConfig::installThemeFromFile(const QUrl &url) | ||
447 | { | 450 | { | ||
448 | if (url.isLocalFile()) { | 451 | if (url.isLocalFile()) { | ||
449 | installThemeFile(url.toLocalFile()); | 452 | installThemeFile(url.toLocalFile()); | ||
450 | return; | 453 | return; | ||
451 | } | 454 | } | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |
ditto