about summary refs log tree commit diff
path: root/pkgs/applications/kde
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@mailbox.org>2017-05-12 11:00:47 -0500
committerThomas Tuegel <ttuegel@mailbox.org>2017-08-21 06:51:17 -0500
commite6b42d7403cc0802c1264952fb19044eba8475e8 (patch)
treee3f4282e16da59a63b1d23e777c9ee940d952018 /pkgs/applications/kde
parent4b032f12eaf2167694098b2ae312dc508635a889 (diff)
grantleetheme: merge themes across multiple prefixes
Diffstat (limited to 'pkgs/applications/kde')
-rw-r--r--pkgs/applications/kde/default.nix2
-rw-r--r--pkgs/applications/kde/grantleetheme/default.nix (renamed from pkgs/applications/kde/grantleetheme.nix)2
-rw-r--r--pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch166
-rw-r--r--pkgs/applications/kde/grantleetheme/grantleetheme_check_null.patch (renamed from pkgs/applications/kde/grantleetheme_check_null.patch)0
-rw-r--r--pkgs/applications/kde/grantleetheme/series2
5 files changed, 170 insertions, 2 deletions
diff --git a/pkgs/applications/kde/default.nix b/pkgs/applications/kde/default.nix
index 8af0370877418..a5504a2813f84 100644
--- a/pkgs/applications/kde/default.nix
+++ b/pkgs/applications/kde/default.nix
@@ -66,7 +66,7 @@ let
       dolphin-plugins = callPackage ./dolphin-plugins.nix {};
       ffmpegthumbs = callPackage ./ffmpegthumbs.nix { };
       filelight = callPackage ./filelight.nix {};
-      grantleetheme = callPackage ./grantleetheme.nix {};
+      grantleetheme = callPackage ./grantleetheme {};
       gwenview = callPackage ./gwenview.nix {};
       k3b = callPackage ./k3b.nix {};
       kalarmcal = callPackage ./kalarmcal.nix {};
diff --git a/pkgs/applications/kde/grantleetheme.nix b/pkgs/applications/kde/grantleetheme/default.nix
index 976ccbe28ce66..5035685c64fb5 100644
--- a/pkgs/applications/kde/grantleetheme.nix
+++ b/pkgs/applications/kde/grantleetheme/default.nix
@@ -11,7 +11,7 @@ mkDerivation {
     maintainers = kdepimTeam;
   };
   output = [ "out" "dev" ];
-  patches = [ ./grantleetheme_check_null.patch ];
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
   nativeBuildInputs = [ extra-cmake-modules kdoctools ];
   buildInputs = [
     grantlee5 ki18n kiconthemes knewstuff kservice kxmlgui qtbase
diff --git a/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch b/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch
new file mode 100644
index 0000000000000..76b65a4447527
--- /dev/null
+++ b/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch
@@ -0,0 +1,166 @@
+Index: grantleetheme-17.04.0/src/grantleetheme_p.h
+===================================================================
+--- grantleetheme-17.04.0.orig/src/grantleetheme_p.h
++++ grantleetheme-17.04.0/src/grantleetheme_p.h
+@@ -47,7 +47,7 @@ public:
+     QString description;
+     QString name;
+     QString dirName;
+-    QString absolutePath;
++    QStringList absolutePaths;
+     QString author;
+     QString email;
+ 
+Index: grantleetheme-17.04.0/src/grantleetheme.cpp
+===================================================================
+--- grantleetheme-17.04.0.orig/src/grantleetheme.cpp
++++ grantleetheme-17.04.0/src/grantleetheme.cpp
+@@ -45,7 +45,7 @@ ThemePrivate::ThemePrivate(const ThemePr
+     , description(other.description)
+     , name(other.name)
+     , dirName(other.dirName)
+-    , absolutePath(other.absolutePath)
++    , absolutePaths(other.absolutePaths)
+     , author(other.author)
+     , email(other.email)
+     , loader(other.loader)
+@@ -63,12 +63,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<Grantlee::FileSystemTemplateLoader>::create();
+-    loader->setTemplateDirs({ dir.absolutePath() });
++    loader->setTemplateDirs(templateDirs);
+     loader->setTheme(dirName);
+ 
+     if (!sEngine) {
+@@ -102,9 +105,7 @@ QString ThemePrivate::errorTemplate(cons
+     Grantlee::Context ctx = createContext();
+     ctx.insert(QStringLiteral("error"), reason);
+     ctx.insert(QStringLiteral("templateName"), origTemplateName);
+-    const QString errorString = failedTemplate
+-            ? failedTemplate->errorString()
+-            : QStringLiteral("(null template)");
++    const QString errorString = failedTemplate->errorString();
+     ctx.insert(QStringLiteral("errorMessage"), errorString);
+     return tpl->render(&ctx);
+ }
+@@ -122,7 +123,7 @@ Theme::Theme(const QString &themePath, c
+     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());
+@@ -141,7 +142,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)
+@@ -185,7 +186,12 @@ QString Theme::dirName() const
+ 
+ QString Theme::absolutePath() const
+ {
+-    return d->absolutePath;
++    return d->absolutePaths.first();
++}
++
++QStringList Theme::absolutePaths() const
++{
++    return d->absolutePaths;
+ }
+ 
+ QString Theme::author() const
+@@ -224,6 +230,13 @@ QString Theme::render(const QString &tem
+     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) {
+Index: grantleetheme-17.04.0/src/grantleetheme.h
+===================================================================
+--- grantleetheme-17.04.0.orig/src/grantleetheme.h
++++ grantleetheme-17.04.0/src/grantleetheme.h
+@@ -50,11 +50,14 @@ public:
+     QStringList displayExtraVariables() const;
+     QString dirName() const;
+     QString absolutePath() const;
++    QStringList absolutePaths() const;
+     QString author() const;
+     QString authorEmail() const;
+ 
+     QString render(const QString &templateName, const QVariantHash &data, const QByteArray &applicationDomain = QByteArray());
+ 
++    void addThemeDir(const QString&);
++
+     static void addPluginPath(const QString &path);
+ 
+ private:
+Index: grantleetheme-17.04.0/src/grantleethememanager.cpp
+===================================================================
+--- grantleetheme-17.04.0.orig/src/grantleethememanager.cpp
++++ grantleetheme-17.04.0/src/grantleethememanager.cpp
+@@ -142,25 +142,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);
+@@ -374,7 +367,7 @@ QString ThemeManager::pathFromThemes(con
+                 GrantleeTheme::Theme theme = loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName);
+                 if (theme.isValid()) {
+                     if (dirName == themeName) {
+-                        return theme.absolutePath();
++                        return theme.absolutePaths().first();
+                     }
+                 }
+             }
diff --git a/pkgs/applications/kde/grantleetheme_check_null.patch b/pkgs/applications/kde/grantleetheme/grantleetheme_check_null.patch
index 730d5b0fe2612..730d5b0fe2612 100644
--- a/pkgs/applications/kde/grantleetheme_check_null.patch
+++ b/pkgs/applications/kde/grantleetheme/grantleetheme_check_null.patch
diff --git a/pkgs/applications/kde/grantleetheme/series b/pkgs/applications/kde/grantleetheme/series
new file mode 100644
index 0000000000000..5c38848de7134
--- /dev/null
+++ b/pkgs/applications/kde/grantleetheme/series
@@ -0,0 +1,2 @@
+grantleetheme_check_null.patch
+grantlee-merge-theme-dirs.patch