diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-30 15:46:39 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-31 11:51:14 +0000 |
commit | f6ca497fe43b0f5e976f296e8a4d425516508e51 (patch) | |
tree | cd25d1b5eb0bffdb180bb8507ab2e2b785ff7534 /examples/quick/tutorials/samegame/samegame4 | |
parent | 9e09b78fe5f4a73cde9363b3d7aa8803f8f48dc9 (diff) |
Fix samegame example to use QML modules
In this case it really makes no sense to use a shared directory because
we want to show the progressive changes between the different versions.
It's actually important to note that we're adding the pictures one by
one. Therefore, the shared directory is dissolved and the pictures added
duplicated into the respective versions of samegame.
Furthermore, moving the code into a "content" directory is a bad idea
because it complicates the import logic. We don't want to make the
"content" directory its own QML module. We might move samegame.qml into
the "content" directory, too, and apply some path wrangling to make it
work, but it's really not worth it here.
Change-Id: Ifc45f48832596377c21bc6ef55e918ef487bc94e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit a3ea7a99381748c457336bfa8b9373070ebfa3ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quick/tutorials/samegame/samegame4')
16 files changed, 84 insertions, 19 deletions
diff --git a/examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml index 12cc64a09b..8353437542 100644 --- a/examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml @@ -76,11 +76,11 @@ Item { anchors.fill: parent source: { if (block.type == 0) - return "../../shared/pics/redStone.png"; + return "pics/redStone.png"; else if (block.type == 1) - return "../../shared/pics/blueStone.png"; + return "pics/blueStone.png"; else - return "../../shared/pics/greenStone.png"; + return "pics/greenStone.png"; } opacity: 0 @@ -98,11 +98,11 @@ Item { // ![0] source: { if (block.type == 0) - return "../../shared/pics/redStar.png"; + return "pics/redStar.png"; else if (block.type == 1) - return "../../shared/pics/blueStar.png"; + return "pics/blueStar.png"; else - return "../../shared/pics/greenStar.png"; + return "pics/greenStar.png"; } rotationVelocityVariation: 360 // ![0] diff --git a/examples/quick/tutorials/samegame/samegame4/content/Button.qml b/examples/quick/tutorials/samegame/samegame4/Button.qml index 77921772d2..77921772d2 100644 --- a/examples/quick/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/quick/tutorials/samegame/samegame4/Button.qml diff --git a/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt new file mode 100644 index 0000000000..c89d191873 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.16) +project(samegame4 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame4") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Quick) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(samegame4 + main.cpp +) +set_target_properties(samegame4 PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +qt_add_qml_module(samegame4 + URI samegame + VERSION 1.0 + QML_FILES + "BoomBlock.qml" + "Button.qml" + "Dialog.qml" + "samegame.qml" + "samegame.js" + RESOURCES + "highscores/README" + "highscores/score_data.xml" + "highscores/score_style.xsl" + "highscores/scores.php" + "pics/background.jpg" + "pics/blueStar.png" + "pics/blueStone.png" + "pics/greenStar.png" + "pics/greenStone.png" + "pics/redStar.png" + "pics/redStone.png" +) + +target_link_libraries(samegame4 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +install(TARGETS samegame4 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quick/tutorials/samegame/samegame4/content/Dialog.qml b/examples/quick/tutorials/samegame/samegame4/Dialog.qml index 5663add8ad..5663add8ad 100644 --- a/examples/quick/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/quick/tutorials/samegame/samegame4/Dialog.qml diff --git a/examples/quick/tutorials/samegame/samegame4/main.cpp b/examples/quick/tutorials/samegame/samegame4/main.cpp index 7589b92906..f76b5d8940 100644 --- a/examples/quick/tutorials/samegame/samegame4/main.cpp +++ b/examples/quick/tutorials/samegame/samegame4/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(samegame) +DECLARATIVE_EXAMPLE_MAIN(samegame/samegame) diff --git a/examples/quick/tutorials/samegame/samegame4/pics/background.jpg b/examples/quick/tutorials/samegame/samegame4/pics/background.jpg Binary files differnew file mode 100644 index 0000000000..903d395c8d --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/background.jpg diff --git a/examples/quick/tutorials/samegame/samegame4/pics/blueStar.png b/examples/quick/tutorials/samegame/samegame4/pics/blueStar.png Binary files differnew file mode 100644 index 0000000000..213bb4bf6c --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/blueStar.png diff --git a/examples/quick/tutorials/samegame/samegame4/pics/blueStone.png b/examples/quick/tutorials/samegame/samegame4/pics/blueStone.png Binary files differnew file mode 100644 index 0000000000..20e43c75b6 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/blueStone.png diff --git a/examples/quick/tutorials/samegame/samegame4/pics/greenStar.png b/examples/quick/tutorials/samegame/samegame4/pics/greenStar.png Binary files differnew file mode 100644 index 0000000000..38429749b8 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/greenStar.png diff --git a/examples/quick/tutorials/samegame/samegame4/pics/greenStone.png b/examples/quick/tutorials/samegame/samegame4/pics/greenStone.png Binary files differnew file mode 100644 index 0000000000..b568a1900c --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/greenStone.png diff --git a/examples/quick/tutorials/samegame/samegame4/pics/redStar.png b/examples/quick/tutorials/samegame/samegame4/pics/redStar.png Binary files differnew file mode 100644 index 0000000000..5cdf45c4c0 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/redStar.png diff --git a/examples/quick/tutorials/samegame/samegame4/pics/redStone.png b/examples/quick/tutorials/samegame/samegame4/pics/redStone.png Binary files differnew file mode 100644 index 0000000000..36b09a2686 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/pics/redStone.png diff --git a/examples/quick/tutorials/samegame/samegame4/content/samegame.js b/examples/quick/tutorials/samegame/samegame4/samegame.js index 80b175d450..80b175d450 100644 --- a/examples/quick/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/quick/tutorials/samegame/samegame4/samegame.js diff --git a/examples/quick/tutorials/samegame/samegame4/samegame.qml b/examples/quick/tutorials/samegame/samegame4/samegame.qml index 0cdbcd8cb0..1335024b13 100644 --- a/examples/quick/tutorials/samegame/samegame4/samegame.qml +++ b/examples/quick/tutorials/samegame/samegame4/samegame.qml @@ -49,8 +49,7 @@ ****************************************************************************/ import QtQuick 2.0 -import "content" -import "content/samegame.js" as SameGame +import "samegame.js" as SameGame Rectangle { id: screen @@ -66,7 +65,7 @@ Rectangle { Image { id: background anchors.fill: parent - source: "../shared/pics/background.jpg" + source: "pics/background.jpg" fillMode: Image.PreserveAspectCrop } diff --git a/examples/quick/tutorials/samegame/samegame4/samegame4.pro b/examples/quick/tutorials/samegame/samegame4/samegame4.pro index 5da0d46e19..e9d341d555 100644 --- a/examples/quick/tutorials/samegame/samegame4/samegame4.pro +++ b/examples/quick/tutorials/samegame/samegame4/samegame4.pro @@ -2,10 +2,7 @@ TEMPLATE = app QT += quick qml SOURCES += main.cpp - -RESOURCES += \ - samegame4.qrc \ - ../shared/pics/shared.qrc +RESOURCES += samegame4.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame4 INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame4/samegame4.qrc b/examples/quick/tutorials/samegame/samegame4/samegame4.qrc index 8b130721f5..9dc482d7de 100644 --- a/examples/quick/tutorials/samegame/samegame4/samegame4.qrc +++ b/examples/quick/tutorials/samegame/samegame4/samegame4.qrc @@ -1,13 +1,20 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/samegame"> <file>samegame.qml</file> - <file>content/BoomBlock.qml</file> - <file>content/Button.qml</file> - <file>content/Dialog.qml</file> - <file>content/samegame.js</file> + <file>BoomBlock.qml</file> + <file>Button.qml</file> + <file>Dialog.qml</file> + <file>samegame.js</file> <file>highscores/README</file> <file>highscores/score_data.xml</file> <file>highscores/score_style.xsl</file> <file>highscores/scores.php</file> + <file>pics/background.jpg</file> + <file>pics/blueStar.png</file> + <file>pics/blueStone.png</file> + <file>pics/greenStar.png</file> + <file>pics/greenStone.png</file> + <file>pics/redStar.png</file> + <file>pics/redStone.png</file> </qresource> </RCC> |