aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/tutorials/samegame/samegame4
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/tutorials/samegame/samegame4')
-rw-r--r--examples/quick/tutorials/samegame/samegame4/CMakeLists.txt34
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame.js11
2 files changed, 26 insertions, 19 deletions
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);