From ae03070d2261a5aa81b29a2adf25328472830b4d Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Mon, 14 Sep 2026 13:59:17 +0200 Subject: QStyleKitStyle: Support "qrc:" and "file:" paths QStyleKitStyle supported only ":" paths in the local file system. However, adding support for "qrc:" paths as well allows passing the path to a style file in a compiled QML module, speeding up startup time. Therefore add support for this schemes to not limit users that want compiled QML. For symmetry, since we now are supporting qrc: paths, support "file:" paths too. Pick-to: 6.12 Change-Id: I0c58c5e09a9c514a6e48a54c7dd65c70b22c79ee Reviewed-by: Richard Moe Gustavsen --- src/labs/stylekit/widgets/qstylekitstyle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/labs/stylekit/widgets/qstylekitstyle.cpp b/src/labs/stylekit/widgets/qstylekitstyle.cpp index 7cccff9970..d962417048 100644 --- a/src/labs/stylekit/widgets/qstylekitstyle.cpp +++ b/src/labs/stylekit/widgets/qstylekitstyle.cpp @@ -292,10 +292,9 @@ Q_STATIC_LOGGING_CATEGORY(lcStyleKit, "qt.labs.stylekit") \brief the path to the QML \l Style file driving this style. The value is a path to a local file or to a file in the resource file - system (for example, \c{:/styles/MyStyle.qml}). QStyleKitStyle resolves a - relative path against the application's working directory. The file must - contain a QML component whose root object is a \l Style. - + system, (for example, \c{:/styles/MyStyle.qml} or \c{qrc:/qt/qml/MyQmlModule/Style.qml}). + QStyleKitStyle resolves a relative path against the application's working directory. + The file must contain a QML component whose root object is a \l Style. Setting this property reloads the style. If the new file does not load, QStyleKitStyle emits a warning and keeps the previously loaded style and style path. @@ -577,8 +576,11 @@ QStyleKitStylePrivate::QStyleKitStylePrivate() static QUrl urlFromStylePath(const QString &filePath) { - return filePath.startsWith(QLatin1Char(':')) ? QUrl(QLatin1String("qrc") + filePath) - : QUrl::fromLocalFile(filePath); + if (filePath.startsWith(QLatin1Char(':'))) + return QUrl(QLatin1String("qrc") + filePath); + if (filePath.startsWith(QLatin1String("qrc:")) || filePath.startsWith(QLatin1String("file:"))) + return QUrl(filePath); + return QUrl::fromLocalFile(filePath); } bool QStyleKitStylePrivate::loadStyle() -- cgit v1.2.3