mirror of https://github.com/qt/qtdoc.git
Minor tweeks to the photosurface demo
The commit 0391a2fb98
makes a lot of improvements to the demo, but it also makes it
no longer search your system's photos directory by default.
This commit also updates the project files.
The CMakeLists.txt file will use qt_add_qml_module() among other
things that our guildelines recommend.
The .qrc file will have the /qt/qml/photosurface prefix, in order to
make qmake compatible with the AUTO_RESOURCE_PREFIX module.
Task-number: QTBUG-108924
Pick-to: 6.5
Change-Id: I19291ead744f8eebcd4151f02b44f746b2040319
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
1a5419646a
commit
8b3600e016
|
@ -14,10 +14,12 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/demos/photosurface")
|
|||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
if (WIN32)
|
||||
#! [appicon_windows]
|
||||
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/resources/photosurface.rc")
|
||||
qt_add_executable(photosurface main.cpp ${app_icon_resource_windows})
|
||||
qt_add_executable(photosurfaceexample main.cpp ${app_icon_resource_windows})
|
||||
#! [appicon_windows]
|
||||
elseif (APPLE)
|
||||
#! [appicon_macOS]
|
||||
|
@ -31,34 +33,29 @@ elseif (APPLE)
|
|||
set_source_files_properties(${app_icon_macos} PROPERTIES
|
||||
MACOSX_PACKAGE_LOCATION "Resources")
|
||||
|
||||
qt_add_executable(photosurface MACOSX_BUNDLE main.cpp ${app_icon_macos})
|
||||
qt_add_executable(photosurfaceexample MACOSX_BUNDLE main.cpp ${app_icon_macos})
|
||||
#! [appicon_macOS]
|
||||
else()
|
||||
qt_add_executable(photosurface main.cpp)
|
||||
qt_add_executable(photosurfaceexample main.cpp)
|
||||
endif()
|
||||
|
||||
target_link_libraries(photosurface PUBLIC
|
||||
target_link_libraries(photosurfaceexample PRIVATE
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Qml
|
||||
Qt::Quick
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set(photosurface_resource_files
|
||||
"photosurface.qml"
|
||||
"resources/folder.png"
|
||||
"resources/MomentumAnimation.qml"
|
||||
qt_add_qml_module(photosurfaceexample
|
||||
URI photosurface
|
||||
QML_FILES
|
||||
"photosurface.qml"
|
||||
"resources/MomentumAnimation.qml"
|
||||
RESOURCES
|
||||
"resources/folder.png"
|
||||
)
|
||||
|
||||
qt6_add_resources(photosurface "photosurface"
|
||||
PREFIX
|
||||
"/"
|
||||
FILES
|
||||
${photosurface_resource_files}
|
||||
)
|
||||
|
||||
install(TARGETS photosurface
|
||||
install(TARGETS photosurfaceexample
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char* argv[])
|
|||
parser.process(app);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl("qrc:///photosurface.qml"));
|
||||
engine.load(QUrl("qrc:/qt/qml/photosurface/photosurface.qml"));
|
||||
if (engine.rootObjects().isEmpty())
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Dialogs
|
||||
|
@ -160,9 +161,17 @@ Window {
|
|||
Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() }
|
||||
|
||||
Component.onCompleted: {
|
||||
let lastArg = Application.arguments.slice(-1)[0]
|
||||
if (/.*hotosurface.*|--+/.test(lastArg))
|
||||
folderDialog.open()
|
||||
const lastArg = Application.arguments.slice(-1)[0]
|
||||
const standardPicturesLocations = StandardPaths.standardLocations(StandardPaths.PicturesLocation)
|
||||
const hasValidPicturesLocation = standardPicturesLocations.length > 0
|
||||
if (hasValidPicturesLocation)
|
||||
folderDialog.currentFolder = standardPicturesLocations[0]
|
||||
if (/.*hotosurface.*|--+/.test(lastArg)) {
|
||||
if (hasValidPicturesLocation)
|
||||
folderModel.folder = standardPicturesLocations[0]
|
||||
else
|
||||
folderDialog.open()
|
||||
}
|
||||
else
|
||||
folderModel.folder = Qt.resolvedUrl("file:" + lastArg)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<qresource prefix="/qt/qml/photosurface">
|
||||
<file>photosurface.qml</file>
|
||||
<file>resources/folder.png</file>
|
||||
<file>resources/MomentumAnimation.qml</file>
|
||||
|
|
Loading…
Reference in New Issue