7#include "styleselector.h"
12#include <kirigamiplatform_logging.h>
21 if (qEnvironmentVariableIntValue(
"KIRIGAMI_FORCE_STYLE") == 1) {
24 return styleChain().
first();
30 if (qEnvironmentVariableIntValue(
"KIRIGAMI_FORCE_STYLE") == 1) {
40#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
42 if (style.
isEmpty() || style == QStringLiteral(
"org.kde.desktop.plasma")) {
43 auto path = resolveFilePath(QStringLiteral(
"/styles/org.kde.desktop"));
45 s_styleChain.
prepend(QStringLiteral(
"org.kde.desktop"));
48#elif defined(Q_OS_ANDROID)
49 s_styleChain.
prepend(QStringLiteral(
"Material"));
51 s_styleChain.
prepend(QStringLiteral(
"Material"));
54 auto stylePath = resolveFilePath(QStringLiteral(
"/styles/") + style);
58 auto plasmaPath = resolveFilePath(QStringLiteral(
"/styles/org.kde.desktop.plasma"));
59 if (style == QStringLiteral(
"org.kde.desktop") &&
QFile::exists(plasmaPath)) {
60 s_styleChain.
prepend(QStringLiteral(
"org.kde.desktop.plasma"));
63#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
64 s_styleChain.
prepend(QStringLiteral(
"org.kde.desktop"));
71QUrl StyleSelector::componentUrl(
const QString &fileName)
73 const auto chain = styleChain();
74 for (
const QString &style : chain) {
75 const QString candidate = QStringLiteral(
"styles/") + style +
QLatin1Char(
'/') + fileName;
77 return QUrl(resolveFileUrl(candidate));
82 qCWarning(KirigamiPlatform) <<
"Requested an unexisting component" << fileName;
84 return QUrl(resolveFileUrl(fileName));
87void StyleSelector::setBaseUrl(
const QUrl &baseUrl)
94#if defined(KIRIGAMI_BUILD_TYPE_STATIC) || defined(Q_OS_ANDROID)
95 return QStringLiteral(
":/qt/qml/org/kde/kirigami/") +
path;
107#if defined(KIRIGAMI_BUILD_TYPE_STATIC) || defined(Q_OS_ANDROID)
108 return QStringLiteral(
"qrc:/qt/qml/org/kde/kirigami/") +
path;
QString path(const QString &relativePath)
bool exists() const const
bool isEmpty() const const
void prepend(parameter_type value)
bool isEmpty() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool isValid() const const
QString toLocalFile() const const
QString toString(FormattingOptions options) const const