aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/tutorials/samegame
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/tutorials/samegame')
-rw-r--r--examples/quick/tutorials/samegame/CMakeLists.txt2
-rw-r--r--examples/quick/tutorials/samegame/samegame1/CMakeLists.txt34
-rw-r--r--examples/quick/tutorials/samegame/samegame2/CMakeLists.txt34
-rw-r--r--examples/quick/tutorials/samegame/samegame3/CMakeLists.txt34
-rw-r--r--examples/quick/tutorials/samegame/samegame4/CMakeLists.txt34
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame.js11
6 files changed, 84 insertions, 65 deletions
diff --git a/examples/quick/tutorials/samegame/CMakeLists.txt b/examples/quick/tutorials/samegame/CMakeLists.txt
index 49b043e18d..4582f44309 100644
--- a/examples/quick/tutorials/samegame/CMakeLists.txt
+++ b/examples/quick/tutorials/samegame/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(samegame1)
qt_internal_add_example(samegame2)
diff --git a/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt
index 8cc399ccd0..0ce11660a8 100644
--- a/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt
+++ b/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt
@@ -1,19 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(samegame1 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame1")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(samegame1
main.cpp
)
@@ -25,7 +21,6 @@ set_target_properties(samegame1 PROPERTIES
qt_add_qml_module(samegame1
URI samegame
- AUTO_RESOURCE_PREFIX
QML_FILES
"Block.qml"
"Button.qml"
@@ -36,14 +31,23 @@ qt_add_qml_module(samegame1
)
target_link_libraries(samegame1 PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
install(TARGETS samegame1
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET samegame1
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/tutorials/samegame/samegame2/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame2/CMakeLists.txt
index 1233e4d407..3fe42e4cd4 100644
--- a/examples/quick/tutorials/samegame/samegame2/CMakeLists.txt
+++ b/examples/quick/tutorials/samegame/samegame2/CMakeLists.txt
@@ -1,19 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(samegame2 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame2")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(samegame2
main.cpp
)
@@ -25,7 +21,6 @@ set_target_properties(samegame2 PROPERTIES
qt_add_qml_module(samegame2
URI samegame
- AUTO_RESOURCE_PREFIX
QML_FILES
"Block.qml"
"Button.qml"
@@ -37,14 +32,23 @@ qt_add_qml_module(samegame2
)
target_link_libraries(samegame2 PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
install(TARGETS samegame2
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET samegame2
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/tutorials/samegame/samegame3/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame3/CMakeLists.txt
index 59fa1302a6..4bd5124fbe 100644
--- a/examples/quick/tutorials/samegame/samegame3/CMakeLists.txt
+++ b/examples/quick/tutorials/samegame/samegame3/CMakeLists.txt
@@ -1,19 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(samegame3 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame3")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(samegame3
main.cpp
)
@@ -25,7 +21,6 @@ set_target_properties(samegame3 PROPERTIES
qt_add_qml_module(samegame3
URI samegame
- AUTO_RESOURCE_PREFIX
QML_FILES
"Block.qml"
"Button.qml"
@@ -40,14 +35,23 @@ qt_add_qml_module(samegame3
)
target_link_libraries(samegame3 PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
install(TARGETS samegame3
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET samegame3
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt
index 77fdb83718..7760ee1abf 100644
--- a/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt
+++ b/examples/quick/tutorials/samegame/samegame4/CMakeLists.txt
@@ -1,19 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(samegame4 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame4")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(samegame4
main.cpp
)
@@ -25,7 +21,6 @@ set_target_properties(samegame4 PROPERTIES
qt_add_qml_module(samegame4
URI samegame
- AUTO_RESOURCE_PREFIX
QML_FILES
"BoomBlock.qml"
"Button.qml"
@@ -47,14 +42,23 @@ qt_add_qml_module(samegame4
)
target_link_libraries(samegame4 PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
install(TARGETS samegame4
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET samegame4
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/tutorials/samegame/samegame4/samegame.js b/examples/quick/tutorials/samegame/samegame4/samegame.js
index 80b175d450..99d34c64a0 100644
--- a/examples/quick/tutorials/samegame/samegame4/samegame.js
+++ b/examples/quick/tutorials/samegame/samegame4/samegame.js
@@ -27,10 +27,6 @@ function startNewGame() {
maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
maxIndex = maxRow * maxColumn;
- //Close dialogs
- nameInputDialog.hide();
- dialog.hide();
-
//Initialize Board
board = new Array(maxIndex);
gameCanvas.score = 0;
@@ -41,6 +37,10 @@ function startNewGame() {
}
}
+ //Close dialogs
+ nameInputDialog.hide();
+ dialog.hide();
+
gameDuration = new Date();
}
@@ -191,6 +191,9 @@ function floodMoveCheck(column, row, type) {
//![2]
function saveHighScore(name) {
+ if (gameCanvas.score == 0)
+ return;
+
if (scoresURL != "")
sendHighScore(name);