aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/grantlee-merge-theme-dirs.patch
blob: 96a15a387bc441432ec2508a2576a3733d616b93 (about) (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Taken from nixpkgs, see
grantleetheme: merge themes across multiple prefixes
<https://github.com/NixOS/nixpkgs/commits/master/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch>


diff --git a/src/grantleetheme.cpp b/src/grantleetheme.cpp
index 27d5bc8..8d43140 100644
--- a/src/grantleetheme.cpp
+++ b/src/grantleetheme.cpp
@@ -46,7 +46,7 @@ ThemePrivate::ThemePrivate(const ThemePrivate &other)
     , description(other.description)
     , name(other.name)
     , dirName(other.dirName)
-    , absolutePath(other.absolutePath)
+    , absolutePaths(other.absolutePaths)
     , author(other.author)
     , email(other.email)
     , loader(other.loader)
@@ -64,12 +64,15 @@ void ThemePrivate::setupEngine()
 
 void ThemePrivate::setupLoader()
 {
-    // Get the parent dir with themes, we set the theme directory separately
-    QDir dir(absolutePath);
-    dir.cdUp();
+    QStringList templateDirs;
+    for (const QString& path : absolutePaths) {
+        QDir dir(path);
+        dir.cdUp();
+        templateDirs << dir.absolutePath();
+    }
 
     loader = QSharedPointer<GrantleeTheme::QtResourceTemplateLoader>::create();
-    loader->setTemplateDirs({ dir.absolutePath() });
+    loader->setTemplateDirs(templateDirs);
     loader->setTheme(dirName);
 
     if (!sEngine) {
@@ -121,7 +124,7 @@ Theme::Theme(const QString &themePath, const QString &dirName, const QString &de
     KConfigGroup group(&config, QStringLiteral("Desktop Entry"));
     if (group.isValid()) {
         d->dirName = dirName;
-        d->absolutePath = themePath;
+        d->absolutePaths = QStringList(themePath);
         d->name = group.readEntry("Name", QString());
         d->description = group.readEntry("Description", QString());
         d->themeFileName = group.readEntry("FileName", QString());
@@ -140,7 +143,7 @@ Theme::~Theme()
 
 bool Theme::operator==(const Theme &other) const
 {
-    return isValid() && other.isValid() && d->absolutePath == other.absolutePath();
+    return isValid() && other.isValid() && d->absolutePaths == other.absolutePaths();
 }
 
 Theme &Theme::operator=(const Theme &other)
@@ -184,7 +187,15 @@ QString Theme::dirName() const
 
 QString Theme::absolutePath() const
 {
-    return d->absolutePath;
+    if (! d->absolutePaths.isEmpty()) {
+      return d->absolutePaths.first();
+    };
+    return QString();
+}
+
+QStringList Theme::absolutePaths() const
+{
+    return d->absolutePaths;
 }
 
 QString Theme::author() const
@@ -223,6 +231,13 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con
     return result;
 }
 
+void Theme::addThemeDir(const QString& path)
+{
+    QDir dir(path);
+    dir.cdUp();
+    d->absolutePaths << dir.absolutePath();
+}
+
 void Theme::addPluginPath(const QString &path)
 {
     if (!ThemePrivate::sEngine) {
diff --git a/src/grantleetheme.h b/src/grantleetheme.h
index a25c27b..be38299 100644
--- a/src/grantleetheme.h
+++ b/src/grantleetheme.h
@@ -48,11 +48,14 @@ public:
     Q_REQUIRED_RESULT QStringList displayExtraVariables() const;
     Q_REQUIRED_RESULT QString dirName() const;
     Q_REQUIRED_RESULT QString absolutePath() const;
+    Q_REQUIRED_RESULT QStringList absolutePaths() const;
     Q_REQUIRED_RESULT QString author() const;
     Q_REQUIRED_RESULT QString authorEmail() const;
 
     Q_REQUIRED_RESULT QString render(const QString &templateName, const QVariantHash &data, const QByteArray &applicationDomain = QByteArray());
 
+    void addThemeDir(const QString&);
+
     static void addPluginPath(const QString &path);
 
 private:
diff --git a/src/grantleetheme_p.h b/src/grantleetheme_p.h
index eb73dcb..00510e9 100644
--- a/src/grantleetheme_p.h
+++ b/src/grantleetheme_p.h
@@ -43,7 +43,7 @@ public:
     QString description;
     QString name;
     QString dirName;
-    QString absolutePath;
+    QStringList absolutePaths;
     QString author;
     QString email;
 
diff --git a/src/grantleethememanager.cpp b/src/grantleethememanager.cpp
index 606d717..dc99041 100644
--- a/src/grantleethememanager.cpp
+++ b/src/grantleethememanager.cpp
@@ -125,25 +125,18 @@ public:
 
         for (const QString &directory : qAsConst(themesDirectories)) {
             QDirIterator dirIt(directory, QStringList(), QDir::AllDirs | QDir::NoDotAndDotDot);
-            QStringList alreadyLoadedThemeName;
             while (dirIt.hasNext()) {
                 dirIt.next();
                 const QString dirName = dirIt.fileName();
                 GrantleeTheme::Theme theme = q->loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName);
                 if (theme.isValid()) {
                     QString themeName = theme.name();
-                    if (alreadyLoadedThemeName.contains(themeName)) {
-                        int i = 2;
-                        const QString originalName(theme.name());
-                        while (alreadyLoadedThemeName.contains(themeName)) {
-                            themeName = originalName + QStringLiteral(" (%1)").arg(i);
-                            ++i;
-                        }
-                        theme.d->name = themeName;
+                    QMap<QString, GrantleeTheme::Theme>::iterator i = themes.find(dirName);
+                    if (i != themes.end()) {
+                        i.value().addThemeDir(dirIt.filePath());
+                    } else {
+                        themes.insert(dirName, theme);
                     }
-                    alreadyLoadedThemeName << themeName;
-                    themes.insert(dirName, theme);
-                    //qDebug()<<" theme.name()"<<theme.name();
                 }
             }
             watch->addDir(directory);
@@ -366,7 +359,7 @@ QString ThemeManager::pathFromThemes(const QString &themesRelativePath, const QS
                 GrantleeTheme::Theme theme = loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName);
                 if (theme.isValid()) {
                     if (dirName == themeName) {
-                        return theme.absolutePath();
+                        return theme.absolutePaths().first();
                     }
                 }
             }
xim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Raghav Gururajan 2021-03-29gnu: belr: Update to 4.4.34 and enable tests....* gnu/packages/linphone.scm (belr)[source]: Switch to git repository. [version]: Update to 4.4.34. [arguments]: Remove the tests? argument to enable tests. [phases]{move-tester, check}: New phases. Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Raghav Gururajan 2021-03-29gnu: bctoolbox: Update to 4.4.34 and enable libdecaf, tests....* gnu/packages/linphone.scm (bctoolbox)[version]: Update to 4.4.34. [source]: Switch to git repository. [outputs]: Add a debug output. [arguments]: Remove tests? argument, enabling tests. [phases]{patch-cmake, skip-problematic-tests} {fix-installed-resource-directory-detection}: New phases. {check}: Override phase. [inputs]: Add libdecaf. [license]: Update to GPLv3+. Co-authored-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Raghav Gururajan 2021-03-26gnu: bcmatroska2: Fetch the sources from git....* gnu/packages/linphone.scm (bcmatroska2)[source]: Fetch sources from git. [description]: Expound description. [license]: Add the gpl2+ license to the list. Remove broken URLs. Raghav Gururajan 2021-03-26gnu: bcg729: Enable tests and update home page, license....* gnu/packages/linphone.scm (bcg729)[source]: Remove '.git' suffix from URL. [tests?]: Remove argument. [configure-flags]: Enable tests. [phases]{copy-inputs}: New phase. {check}: Override. [native-inputs]: Add perl, test-patterns and unzip. [home-page]: Update. [license]: Upgrade to GPLv3+. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Raghav Gururajan 2021-03-24gnu: bcunit: Update to 3.0.2-0.74021cc and enable more features....* gnu/packages/linphone.scm (bcunit)[source]: Switch to git repository. [version]: Update to 3.0.2-0.74021cc. [outputs]: Add a "doc" output. [arguments]: Remove the tests? argument, enabling tests. [configure-flags]: Enable curses, doc, examples, tests and memtrace. [phases]{patch-source, move-doc}: New phases. {check}: Override phase. [inputs]: Add ncurses. [description]: Fix typo. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Raghav Gururajan