summaryrefslogtreecommitdiff
blob: 81da8d67fe75cc4506ee9ce0ac71641de250e256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
commit fa473a1c4572ef3c2614318b0ce7090613878005
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Tue Sep 13 04:13:47 2016 +0200

    cursor model: look for cursors in correct place
    
    plasma-desktop's cursor theme kcm does the right thing, by consulting
    the libXcursor library for the right search paths. Unfortunately, the
    kcm here does a pretty butchered job of it. So, we copy, more or less,
    the same algorithm used by plasma-desktop. Now there's parity in cursor
    selection.
    
    For reference, please see line 165 of:
    https://quickgit.kde.org/?p=plasma-desktop.git&a=blob&f=kcms%2Fcursortheme%2Fxcursor%2Fthememodel.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07d313c..88f5a47 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_P
 
 find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Widgets Test)
 find_package(KF5 REQUIRED COMPONENTS I18n KIO ConfigWidgets NewStuff Archive KCMUtils IconThemes)
+find_package(X11 REQUIRED)
 
 include_directories(
     ${CMAKE_SOURCE_DIR} 
@@ -54,7 +55,7 @@ ki18n_wrap_ui(kcm_SRCS
 )
 add_library(kcm_kdegtkconfig MODULE ${kcm_SRCS})
 target_compile_definitions(kcm_kdegtkconfig PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
-target_link_libraries(kcm_kdegtkconfig KF5::I18n KF5::KIOWidgets KF5::NewStuff KF5::Archive KF5::NewStuff KF5::ConfigWidgets KF5::IconThemes)
+target_link_libraries(kcm_kdegtkconfig ${X11_Xcursor_LIB} KF5::I18n KF5::KIOWidgets KF5::NewStuff KF5::Archive KF5::NewStuff KF5::ConfigWidgets KF5::IconThemes)
 
 kcoreaddons_desktop_to_json(kcm_kdegtkconfig kde-gtk-config.desktop)
 
diff --git a/src/cursorthemesmodel.cpp b/src/cursorthemesmodel.cpp
index 5238714..0e58230 100644
--- a/src/cursorthemesmodel.cpp
+++ b/src/cursorthemesmodel.cpp
@@ -24,12 +24,14 @@
 #include <QDir>
 #include <QDirIterator>
 #include <QSet>
-#include <KIconTheme>
 #include <QStandardPaths>
+#include <KIconTheme>
+#include <KShell>
+
+#include <X11/Xcursor/Xcursor.h>
 
-CursorThemesModel::CursorThemesModel(bool onlyHome, QObject* parent)
+CursorThemesModel::CursorThemesModel(QObject* parent)
     : IconThemesModel(parent)
-    , m_onlyHome(onlyHome)
 {
     reload();
 }
@@ -37,13 +39,11 @@ CursorThemesModel::CursorThemesModel(bool onlyHome, QObject* parent)
 QList<QDir> CursorThemesModel::installedThemesPaths()
 {
     QList<QDir> availableIcons;
+    QStringList dirs(QString(XcursorLibraryPath()).split(':', QString::SkipEmptyParts));
+
+    std::transform(dirs.begin(), dirs.end(), dirs.begin(), KShell::tildeExpand);
+    dirs.removeDuplicates();
 
-    QSet<QString> dirs;
-    dirs += QDir::home().filePath(".icons");
-    if(!m_onlyHome) {
-        dirs += QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "icons", QStandardPaths::LocateDirectory).toSet();
-    }
-    
     foreach(const QString& dir, dirs) {
         QDir userIconsDir(dir);
         QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs|QDir::NoSymLinks);
diff --git a/src/cursorthemesmodel.h b/src/cursorthemesmodel.h
index 7658bd5..4acfa4b 100644
--- a/src/cursorthemesmodel.h
+++ b/src/cursorthemesmodel.h
@@ -29,14 +29,13 @@ class QDir;
 class CursorThemesModel : public IconThemesModel
 {
     public:
-        explicit CursorThemesModel(bool onlyHome=false, QObject* parent = 0);
+        explicit CursorThemesModel(QObject* parent = 0);
 
         void reload();
         
     private:
         static void fillItem(const QDir& dir, QStandardItem* item);
         QList<QDir> installedThemesPaths();
-        bool m_onlyHome;
 };
 
 #endif // CURSORTHEMESMODEL_H
diff --git a/src/gtkconfigkcmodule.cpp b/src/gtkconfigkcmodule.cpp
index 7afe698..d36c6a3 100644
--- a/src/gtkconfigkcmodule.cpp
+++ b/src/gtkconfigkcmodule.cpp
@@ -71,7 +71,7 @@ GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args )
     setButtons(KCModule::Default | KCModule::Apply);
     ui->setupUi(this);
     appareance = new AppearenceGTK;
-    m_cursorsModel = new CursorThemesModel(false, this);
+    m_cursorsModel = new CursorThemesModel(this);
     ui->cb_cursor->setModel(m_cursorsModel);
     m_iconsModel = new IconThemesModel(false, this);
     ui->cb_icon->setModel(m_iconsModel);