grantleetheme: merge themes across multiple prefixes

+170 -2
+1 -1
pkgs/applications/kde/default.nix
··· 66 66 dolphin-plugins = callPackage ./dolphin-plugins.nix {}; 67 67 ffmpegthumbs = callPackage ./ffmpegthumbs.nix { }; 68 68 filelight = callPackage ./filelight.nix {}; 69 - grantleetheme = callPackage ./grantleetheme.nix {}; 69 + grantleetheme = callPackage ./grantleetheme {}; 70 70 gwenview = callPackage ./gwenview.nix {}; 71 71 k3b = callPackage ./k3b.nix {}; 72 72 kalarmcal = callPackage ./kalarmcal.nix {};
+1 -1
pkgs/applications/kde/grantleetheme.nix pkgs/applications/kde/grantleetheme/default.nix
··· 11 11 maintainers = kdepimTeam; 12 12 }; 13 13 output = [ "out" "dev" ]; 14 - patches = [ ./grantleetheme_check_null.patch ]; 14 + patches = copyPathsToStore (lib.readPathsFromFile ./. ./series); 15 15 nativeBuildInputs = [ extra-cmake-modules kdoctools ]; 16 16 buildInputs = [ 17 17 grantlee5 ki18n kiconthemes knewstuff kservice kxmlgui qtbase
+166
pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch
··· 1 + Index: grantleetheme-17.04.0/src/grantleetheme_p.h 2 + =================================================================== 3 + --- grantleetheme-17.04.0.orig/src/grantleetheme_p.h 4 + +++ grantleetheme-17.04.0/src/grantleetheme_p.h 5 + @@ -47,7 +47,7 @@ public: 6 + QString description; 7 + QString name; 8 + QString dirName; 9 + - QString absolutePath; 10 + + QStringList absolutePaths; 11 + QString author; 12 + QString email; 13 + 14 + Index: grantleetheme-17.04.0/src/grantleetheme.cpp 15 + =================================================================== 16 + --- grantleetheme-17.04.0.orig/src/grantleetheme.cpp 17 + +++ grantleetheme-17.04.0/src/grantleetheme.cpp 18 + @@ -45,7 +45,7 @@ ThemePrivate::ThemePrivate(const ThemePr 19 + , description(other.description) 20 + , name(other.name) 21 + , dirName(other.dirName) 22 + - , absolutePath(other.absolutePath) 23 + + , absolutePaths(other.absolutePaths) 24 + , author(other.author) 25 + , email(other.email) 26 + , loader(other.loader) 27 + @@ -63,12 +63,15 @@ void ThemePrivate::setupEngine() 28 + 29 + void ThemePrivate::setupLoader() 30 + { 31 + - // Get the parent dir with themes, we set the theme directory separately 32 + - QDir dir(absolutePath); 33 + - dir.cdUp(); 34 + + QStringList templateDirs; 35 + + for (const QString& path : absolutePaths) { 36 + + QDir dir(path); 37 + + dir.cdUp(); 38 + + templateDirs << dir.absolutePath(); 39 + + } 40 + 41 + loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>::create(); 42 + - loader->setTemplateDirs({ dir.absolutePath() }); 43 + + loader->setTemplateDirs(templateDirs); 44 + loader->setTheme(dirName); 45 + 46 + if (!sEngine) { 47 + @@ -102,9 +105,7 @@ QString ThemePrivate::errorTemplate(cons 48 + Grantlee::Context ctx = createContext(); 49 + ctx.insert(QStringLiteral("error"), reason); 50 + ctx.insert(QStringLiteral("templateName"), origTemplateName); 51 + - const QString errorString = failedTemplate 52 + - ? failedTemplate->errorString() 53 + - : QStringLiteral("(null template)"); 54 + + const QString errorString = failedTemplate->errorString(); 55 + ctx.insert(QStringLiteral("errorMessage"), errorString); 56 + return tpl->render(&ctx); 57 + } 58 + @@ -122,7 +123,7 @@ Theme::Theme(const QString &themePath, c 59 + KConfigGroup group(&config, QStringLiteral("Desktop Entry")); 60 + if (group.isValid()) { 61 + d->dirName = dirName; 62 + - d->absolutePath = themePath; 63 + + d->absolutePaths = QStringList(themePath); 64 + d->name = group.readEntry("Name", QString()); 65 + d->description = group.readEntry("Description", QString()); 66 + d->themeFileName = group.readEntry("FileName", QString()); 67 + @@ -141,7 +142,7 @@ Theme::~Theme() 68 + 69 + bool Theme::operator==(const Theme &other) const 70 + { 71 + - return isValid() && other.isValid() && d->absolutePath == other.absolutePath(); 72 + + return isValid() && other.isValid() && d->absolutePaths == other.absolutePaths(); 73 + } 74 + 75 + Theme &Theme::operator=(const Theme &other) 76 + @@ -185,7 +186,12 @@ QString Theme::dirName() const 77 + 78 + QString Theme::absolutePath() const 79 + { 80 + - return d->absolutePath; 81 + + return d->absolutePaths.first(); 82 + +} 83 + + 84 + +QStringList Theme::absolutePaths() const 85 + +{ 86 + + return d->absolutePaths; 87 + } 88 + 89 + QString Theme::author() const 90 + @@ -224,6 +230,13 @@ QString Theme::render(const QString &tem 91 + return result; 92 + } 93 + 94 + +void Theme::addThemeDir(const QString& path) 95 + +{ 96 + + QDir dir(path); 97 + + dir.cdUp(); 98 + + d->absolutePaths << dir.absolutePath(); 99 + +} 100 + + 101 + void Theme::addPluginPath(const QString &path) 102 + { 103 + if (!ThemePrivate::sEngine) { 104 + Index: grantleetheme-17.04.0/src/grantleetheme.h 105 + =================================================================== 106 + --- grantleetheme-17.04.0.orig/src/grantleetheme.h 107 + +++ grantleetheme-17.04.0/src/grantleetheme.h 108 + @@ -50,11 +50,14 @@ public: 109 + QStringList displayExtraVariables() const; 110 + QString dirName() const; 111 + QString absolutePath() const; 112 + + QStringList absolutePaths() const; 113 + QString author() const; 114 + QString authorEmail() const; 115 + 116 + QString render(const QString &templateName, const QVariantHash &data, const QByteArray &applicationDomain = QByteArray()); 117 + 118 + + void addThemeDir(const QString&); 119 + + 120 + static void addPluginPath(const QString &path); 121 + 122 + private: 123 + Index: grantleetheme-17.04.0/src/grantleethememanager.cpp 124 + =================================================================== 125 + --- grantleetheme-17.04.0.orig/src/grantleethememanager.cpp 126 + +++ grantleetheme-17.04.0/src/grantleethememanager.cpp 127 + @@ -142,25 +142,18 @@ public: 128 + 129 + for (const QString &directory : qAsConst(themesDirectories)) { 130 + QDirIterator dirIt(directory, QStringList(), QDir::AllDirs | QDir::NoDotAndDotDot); 131 + - QStringList alreadyLoadedThemeName; 132 + while (dirIt.hasNext()) { 133 + dirIt.next(); 134 + const QString dirName = dirIt.fileName(); 135 + GrantleeTheme::Theme theme = q->loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName); 136 + if (theme.isValid()) { 137 + QString themeName = theme.name(); 138 + - if (alreadyLoadedThemeName.contains(themeName)) { 139 + - int i = 2; 140 + - const QString originalName(theme.name()); 141 + - while (alreadyLoadedThemeName.contains(themeName)) { 142 + - themeName = originalName + QStringLiteral(" (%1)").arg(i); 143 + - ++i; 144 + - } 145 + - theme.d->name = themeName; 146 + + QMap<QString, GrantleeTheme::Theme>::iterator i = themes.find(dirName); 147 + + if (i != themes.end()) { 148 + + i.value().addThemeDir(dirIt.filePath()); 149 + + } else { 150 + + themes.insert(dirName, theme); 151 + } 152 + - alreadyLoadedThemeName << themeName; 153 + - themes.insert(dirName, theme); 154 + - //qDebug()<<" theme.name()"<<theme.name(); 155 + } 156 + } 157 + watch->addDir(directory); 158 + @@ -374,7 +367,7 @@ QString ThemeManager::pathFromThemes(con 159 + GrantleeTheme::Theme theme = loadTheme(dirIt.filePath(), dirName, defaultDesktopFileName); 160 + if (theme.isValid()) { 161 + if (dirName == themeName) { 162 + - return theme.absolutePath(); 163 + + return theme.absolutePaths().first(); 164 + } 165 + } 166 + }
+2
pkgs/applications/kde/grantleetheme/series
··· 1 + grantleetheme_check_null.patch 2 + grantlee-merge-theme-dirs.patch
pkgs/applications/kde/grantleetheme_check_null.patch pkgs/applications/kde/grantleetheme/grantleetheme_check_null.patch