[KDE/Mac] QSP patch/activator
René J.V. Bertin
rjvbertin at gmail.com
Sun Jan 31 10:18:34 UTC 2016
Hi,
I was just reminded of a related issue. The native Mac platform theme has a very limited icon theme search path. You can add the XDG-compliant icon repository to that path, but then almost all buttons will start to show icons: the platform theme apparently doesn't even check the DialogButtonBoxHaveIcons (or whatever) attribute but will simply display the icon if a widget has one.
While that is something I may need to report as a bug it still does seem to make sense for a Qt5 adapted to a distribution-style build to patch qcocoatheme.mm in a way shown below. It would allow certain applications built against a distribution-style build to find the icons they need in a non-native (= XDG-compliant) location. Whether or not one would/should want to allow that is an orthogonal question, but it does show an IMHO valid use-case for a QSP mode switch.
Did you consider the problem of icon themes (I recall you did mention icon themes long ago, but not if it was about this aspect)? Do you see any (good) way to combine this with a per-call approach, where in your Scribus example Scribus itself wouldn't show unwanted icons, but any KF5-based plugins or dialogs from KF5 frameworks would still show them where required?
I can only think of replacing QSP::isXDGLocationsEnabled() with QSP::wasXDGLocationsEnabledInLastQuery() . That would probably work for the KF5 plugins or dialogs if they do an explicit QSP query that includes a mode setting before trying to load an icon (and it seems likely they would do that).
@@ -272,6 +274,29 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz
return pixmap;
}
+// adapted from QGenericUnixTheme::xdgIconThemePaths()
+static QStringList xdgIconThemePaths()
+{
+ QStringList paths;
+ // Add home directory first in search path
+ const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons"));
+ if (homeIconDir.isDir())
+ paths.prepend(homeIconDir.absoluteFilePath());
+
+ QStringList xdgDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
+ if (!xdgDirs.isEmpty()) {
+ foreach (const QString &xdgDir, xdgDirs) {
+ const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons"));
+ if (xdgIconsDir.isDir())
+ paths.append(xdgIconsDir.absoluteFilePath());
+ const QFileInfo pixmapsIconsDir(xdgDir + QStringLiteral("/pixmaps"));
+ if (pixmapsIconsDir.isDir())
+ paths.append(pixmapsIconsDir.absoluteFilePath());
+ }
+ }
+ return paths;
+}
+
QVariant QCocoaTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
@@ -295,6 +320,20 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
}
case QPlatformTheme::PasswordMaskCharacter:
return QVariant(QChar(kBulletUnicode));
+ case QPlatformTheme::SystemIconThemeName:
+ if (QStandardPaths::isXDGLocationsEnabled()) {
+ return QVariant(QString(QStringLiteral("Ciment")));
+ }
+ case QPlatformTheme::SystemIconFallbackThemeName:
+ if (QStandardPaths::isXDGLocationsEnabled()) {
+ return QVariant(QString(QStringLiteral("hicolor")));
+ }
+ case QPlatformTheme::IconThemeSearchPaths:
+ if (QStandardPaths::isXDGLocationsEnabled()) {
+ return xdgIconThemePaths();
+ }
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return false;
default:
break;
}
More information about the kde-mac
mailing list