From dd1b0df73c7f867d84e1a3e445e133749d987b5a Mon Sep 17 00:00:00 2001 From: Be Date: Wed, 4 Apr 2018 17:41:15 -0500 Subject: [PATCH] add support for platform-dependent styles This will allow us to work around platform-dependent quirks in styling. For 2.1 this is needed to work around the issue of the checkmark pushing text to the right and getting cut off in WEffectSelector only on macOS. --- src/skin/legacyskinparser.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 80f0ba81122..1b55c8dac00 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -1873,6 +1873,26 @@ QString LegacySkinParser::getStyleFromNode(const QDomNode& node) { fileBytes.length()); } + QString platformSpecificAttribute; +#if defined(Q_OS_MAC) + platformSpecificAttribute = "src-mac"; +#elif defined(__WINDOWS__) + platformSpecificAttribute = "src-windows"; +#else + platformSpecificAttribute = "src-linux"; +#endif + + if (styleElement.hasAttribute(platformSpecificAttribute)) { + QString platformSpecificSrc = styleElement.attribute(platformSpecificAttribute); + QFile platformSpecificFile(platformSpecificSrc); + if (platformSpecificFile.open(QIODevice::ReadOnly)) { + QByteArray fileBytes = platformSpecificFile.readAll(); + + style += QString::fromLocal8Bit(fileBytes.constData(), + fileBytes.length()); + } + } + // This section can be enabled on demand. It is useful to tweak // pixel sized values for different scalings. But we should know if this is // actually used when migrating to Qt5