diff options
author | Alexandru Croitor <[email protected]> | 2023-04-11 16:52:16 +0200 |
---|---|---|
committer | Alexandru Croitor <[email protected]> | 2023-04-12 09:36:57 +0200 |
commit | 32f6cbe9f09ed80f717ec1836b30e14b60ad2b70 (patch) | |
tree | 8ee2bd487fa03b30183096cda80709a5e45926ec /examples/quickcontrols/filesystemexplorer | |
parent | 0230ceaec8b0b2ed9ccf7573d2713aa82272cc2b (diff) |
Fix filesystemexplorer example to work in macOS bundles
The FileSystemModule qmldir was explicitly put into the "/" resource
prefix, but that prefix is not a default qml import path. That caused
the qml module not to be found when building on macOS as an app
bundle, which relies only on resources and not the file system to find
the module.
To ensure the module qmldir is found in the resources, we want it to
be placed in the default qml import path ':/qt/qml'. To do that,
remove the previously specified RESOURCE_PREFIX option and enable
the QTP0001 policy by requiring Qt 6.5+, which will put the module
qmldir into :/qt/qml/FileSystemModule/qmldir.
Because the policy also changes the resource prefix for other
resources (images), adjust all Image source urls to be relative paths
(relative to the component), instead of absolute paths.
Also adjust the qmake generated qrc file to place the files into the
new resource prefix.
Amends 213e932e138d460159487a624838aa7d3bcffb4a
Fixes: QTBUG-112683
Change-Id: I5205cf6d399a6faaf7cce68d55c71dade37479a7
Reviewed-by: Alexey Edelev <[email protected]>
Reviewed-by: Dennis Oberst <[email protected]>
Reviewed-by: Mitch Curtis <[email protected]>
Reviewed-by: Amir Masoud Abdol <[email protected]>
Diffstat (limited to 'examples/quickcontrols/filesystemexplorer')
6 files changed, 10 insertions, 12 deletions
diff --git a/examples/quickcontrols/filesystemexplorer/CMakeLists.txt b/examples/quickcontrols/filesystemexplorer/CMakeLists.txt index 39c88db471..1127d0f93d 100644 --- a/examples/quickcontrols/filesystemexplorer/CMakeLists.txt +++ b/examples/quickcontrols/filesystemexplorer/CMakeLists.txt @@ -11,7 +11,7 @@ endif () set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/filesystemexplorer") find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2) -qt_standard_project_setup() +qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(filesystemexplorerapp main.cpp @@ -31,8 +31,6 @@ set_source_files_properties(qml/Colors.qml qt_add_qml_module(filesystemexplorerapp URI FileSystemModule VERSION 1.0 - RESOURCE_PREFIX / - NO_RESOURCE_TARGET_PATH QML_FILES "Main.qml" "qml/About.qml" diff --git a/examples/quickcontrols/filesystemexplorer/filesystemexplorer.pro b/examples/quickcontrols/filesystemexplorer/filesystemexplorer.pro index 3b5dc85cfd..125f2c1a56 100644 --- a/examples/quickcontrols/filesystemexplorer/filesystemexplorer.pro +++ b/examples/quickcontrols/filesystemexplorer/filesystemexplorer.pro @@ -45,7 +45,7 @@ theme_resources.files = \ icons/resize.svg \ icons/qt_logo.svg \ -theme_resources.prefix = / +theme_resources.prefix = /qt/qml/FileSystemModule RESOURCES += qml_resources theme_resources diff --git a/examples/quickcontrols/filesystemexplorer/qml/About.qml b/examples/quickcontrols/filesystemexplorer/qml/About.qml index 33e92d8c96..b7bc0ac6f3 100644 --- a/examples/quickcontrols/filesystemexplorer/qml/About.qml +++ b/examples/quickcontrols/filesystemexplorer/qml/About.qml @@ -25,7 +25,7 @@ ApplicationWindow { anchors.right: parent.right anchors.top: parent.top anchors.margins: 20 - source: "qrc:/icons/qt_logo.svg" + source: "../icons/qt_logo.svg" sourceSize: Qt.size(80, 80) fillMode: Image.PreserveAspectFit smooth: true diff --git a/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml b/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml index abcc02b711..ade2e48c1f 100644 --- a/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml +++ b/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml @@ -44,8 +44,8 @@ Rectangle { x: leftMargin + (depth * indentation) anchors.verticalCenter: parent.verticalCenter path: treeDelegate.hasChildren - ? (treeDelegate.expanded ? "qrc:/icons/folder_open.svg" : "qrc:/icons/folder_closed.svg") - : "qrc:/icons/generic_file.svg" + ? (treeDelegate.expanded ? "../icons/folder_open.svg" : "../icons/folder_closed.svg") + : "../icons/generic_file.svg" iconColor: (treeDelegate.expanded && treeDelegate.hasChildren) ? Colors.color2 : Colors.folder } Text { diff --git a/examples/quickcontrols/filesystemexplorer/qml/ResizeButton.qml b/examples/quickcontrols/filesystemexplorer/qml/ResizeButton.qml index f9a350031e..eb2e5bc027 100644 --- a/examples/quickcontrols/filesystemexplorer/qml/ResizeButton.qml +++ b/examples/quickcontrols/filesystemexplorer/qml/ResizeButton.qml @@ -11,7 +11,7 @@ Button { rightPadding: 3 bottomPadding: 3 - icon.source: "qrc:/icons/resize.svg" + icon.source: "../icons/resize.svg" icon.color: down || checked ? Colors.iconIndicator : Colors.icon checkable: false diff --git a/examples/quickcontrols/filesystemexplorer/qml/Sidebar.qml b/examples/quickcontrols/filesystemexplorer/qml/Sidebar.qml index a0c4df5976..9d08562d97 100644 --- a/examples/quickcontrols/filesystemexplorer/qml/Sidebar.qml +++ b/examples/quickcontrols/filesystemexplorer/qml/Sidebar.qml @@ -66,7 +66,7 @@ Rectangle { // Shows help text when clicked. SidebarEntry { - icon.source: "qrc:/icons/light_bulb.svg" + icon.source: "../icons/light_bulb.svg" checkable: true checked: true @@ -75,7 +75,7 @@ Rectangle { // Shows the file system when clicked. SidebarEntry { - icon.source: "qrc:/icons/read.svg" + icon.source: "../icons/read.svg" checkable: true Layout.alignment: Qt.AlignHCenter @@ -94,7 +94,7 @@ Rectangle { // Opens the Qt website in the system's web browser. SidebarEntry { id: qtWebsiteButton - icon.source: "qrc:/icons/globe.svg" + icon.source: "../icons/globe.svg" checkable: false onClicked: Qt.openUrlExternally("https://www.qt.io/") @@ -103,7 +103,7 @@ Rectangle { // Opens the About Qt Window. SidebarEntry { id: aboutQtButton - icon.source: "qrc:/icons/info_sign.svg" + icon.source: "../icons/info_sign.svg" checkable: false onClicked: aboutQtWindow.visible = !aboutQtWindow.visible |