1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-05 03:53:41 +00:00
nixpkgs/pkgs/applications/kde/grantleetheme/grantlee-merge-theme-dirs.patch
2017-12-24 12:54:19 +03:00

154 lines
5.7 KiB
Diff

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.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();
}
}
}
--- src/grantleetheme.cpp.orig 2017-12-22 16:11:39.863598126 +0300
+++ ./src/grantleetheme.cpp 2017-12-22 16:16:14.045664607 +0300
@@ -46,7 +46,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)
@@ -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, 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());
@@ -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,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
@@ -223,6 +231,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) {