Commit Graph

49 Commits

Author SHA1 Message Date
Olivier De Cannière b322512f60 DiceSpawner: Fix qmllint warnings
-Add missing imports
-Bind ids inside of Components
-Explicitly require implcitly depended on index property
-Qualify lookups
-Cast reading as AccelerometerReading until it is exposed as the proper
 type

Also fix a binding loop when setting the die's position.

Fixes: QTBUG-138165
Pick-to: 6.10
Change-Id: I691d4a5bbf4cfbd8f7a6af0e837c15319f60343d
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-07-25 10:13:12 +02:00
Kai Köhne 1bc8cba0e2 Example: Use actual example name for project()
The project name is used in Qt Creator as root name for the project.
Using the same name as the documentation/example name makes it
clearer which example is actually open. Only drop prefixes like
'Qt Quick Demo - '.

Pick-to: 6.10
Change-Id: I863a23e26307a973bb04ce879d0c95c3731cdc53
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-07-09 08:58:58 +02:00
Rami Potinkara 0a3912dcb2 Android: Enable QML debugging in non-release builds
This patch
-enables qmltooling in non release builds
-this will allow QML debugging to start and work
-this patch will do this to following examples:
   -calqlatr, coffee machine and dice

Task-number: QTBUG-136794
Pick-to: 6.9 6.8
Change-Id: I4699285fa20021ec9d6e29c86a7a16516af085fa
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-16 18:36:49 +03:00
Soheil Armin 48edb006a9 Dice: Improve initial position of dices
This change ensures proper initial distance of dices based
on their size. It also distributes them horizontally so that
they hit each other later at different angles.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I7f8d2ab0c9b7b6b00996cae8fb121de950b68ca4
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-24 10:53:25 +00:00
Soheil Armin f8da375cf9 Dice: Set realistic values of PhysicsMaterial of dice
These new values better matches to a acrylic D6 dice
material.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I120f35815ffdcb1af56cc5505b752ca356bd61c0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-24 09:13:01 +00:00
Soheil Armin 4712e40925 Dice: Replace SoundEffect with MediaPlayer
Although the SoundEffect type has lower latency, it is
more resource intensive and shows lower performance and
makes the UI stuttering in some desktop or mobile target
devices.

In this change, we replace SoundEffect with MediaPlayer to
get better visual performance.

Pick-to: 6.8 6.9 6.9.0
Change-Id: Ib5f4d8fe6efb726e341481af9a3aaf2d1f4f1515
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-24 09:12:59 +00:00
Soheil Armin f865c01f0a Dice: Hide menu button when drawer is shown
Pick-to: 6.8 6.9 6.9.0
Change-Id: I17f4e81f9821bd413fd7d1a24cf43cf0ff0f93c9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-24 09:12:53 +00:00
Soheil Armin a7c2e00368 Dice: Improve shake detection
This change enhances the readability of the code and improves the
behavior of triggering a roll. It adds a small delay to prevent
multiple rolls from occurring in short intervals.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I657450be50742d9b6236e2c29cf365b04349f191
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-24 09:12:43 +00:00
Soheil Armin a15fe391af Dice: Show values of sliders in front of related Labels
The user could not see actual values that are set with
sliders. This change appends those values to their related
labels.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I0683a2765368e8385e103639695f7f337902e996
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-20 18:52:06 +02:00
Soheil Armin a9ac96fe36 Dice: Remove redundant RowLayouts with one item inside
Pick-to: 6.8 6.9 6.9.0
Change-Id: Ib10806101288af892ed4040d596ab36a3af04dc7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-20 18:52:00 +02:00
Soheil Armin 630a817385 Dice: Improve tapLabel disappearing logic
This removes the hide() function and the manual animation
from the tapLabel and uses Behavior as an alternative.

Pick-to: 6.8 6.9 6.9.0
Change-Id: Ib4cb924ff1ac3dce70dfde3a80e00efa39a5799a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-20 18:51:56 +02:00
Soheil Armin d4752094b4 Dice: Fix cameraController stealing drawer flickable gestures
The OrbitCameraController inside the Scene, steals gestures from
the Flickable inside the drawer.

This change disables the camera controller when drawer is shown.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I557f1196db0da2d1b30ddbfbe804585de2519f1a
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-20 18:51:53 +02:00
Soheil Armin 015e19ce0d Dice: Replace forEach() with reduce() to calculate dice sound volume
Pick-to: 6.8 6.9 6.9.0
Change-Id: I1411176d718d5219a42a12c4334d8d6d89b88a8a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-20 18:51:49 +02:00
Soheil Armin 65937d3bc8 Dice: Improve atRest property of PhysicalDie
atRest property should be true while the motionTimeout timer
is running.

This change remove a function binding and directly aliases the
atRest property to running property of the timer.

TODO: atRest is unused based on a previous change. If we decide
to keep the logic in the previous patch, then we can remove
this timer and also the property.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I9d0c58f192251621cb3e691cf431366eb6b1dd68
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-20 18:51:46 +02:00
Soheil Armin fc4f30767e Dice: Improve DiceSpawner and its property bindings
This change replaces the imperative logic of DiceSpawner
with a more declarative approach using Repeater3D.

It also replaces sending properties via functions, with
property binding and property aliases.

Pick-to: 6.8 6.9 6.9.0
Change-Id: Ic5c166fb50b0ede393cc72411f1a4a7e08a6ccd7
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-20 18:51:37 +02:00
Soheil Armin ec48a83d72 Dice: Replace the DirectionalLight with a PointLight
DirectionalLight shows performance issues on some targets.
We can achieve a similar visual result with a PointLight.

Pick-to: 6.8 6.9 6.9.0
Change-Id: I39708d2179782f8643ede39e970f47337cae507f
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-03-20 18:51:34 +02:00
Assam Boudjelthia c2c840647a Android: set QT_ANDROID_TARGET_SDK_VERSION to 34
Setting this to 35 is not going to work properly as edge-to-edge is not
working properly yet in Qt for Android 15.

See https://developer.android.com/develop/ui/views/layout/edge-to-edge

Fixes: QTBUG-132360
Pick-to: 6.9 6.8
Change-Id: I46020d07e3aea59d57ebf1bef1b25f1f90971827
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-24 13:13:17 +00:00
Jonas Karlsson 0365c031cf Dice app: Disable camera panning
There is no point in being able to make the camera not focused on the
table since there is nothing else to see in the example.

Change-Id: I6fc0df5619080165ea147ce870065b2cae12e371
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-12-05 10:49:36 +00:00
Lucie Gérard c91bd3ae52 Add REUSE.toml files and missing licenses
REUSE.toml files are read by reuse to complement or override the
copyright and licensing information found in file.

The use of REUSE.toml files was introduced in REUSE version 3.1.0a1.
This reuse version is compatible with reuse specification
version 3.2 [1].
With this commit's files,
* The SPDX document generated by reuse spdx conforms to SPDX 2.3,
* The reuse lint command reports that the Qt project is reuse compliant.

In order to be reuse compliant all the licenses referenced in file
or within a REUSE.toml file must be present in the LICENSES
directory at the base of the module.
The missing licenses are added.

Also, all the licenses present in the LICENSES directory must be used.
License files not used are removed.

[1]: https://reuse.software/spec-3.2/

Task-number: QTBUG-124453
Task-number: QTBUG-125211
Pick-to: 6.8
Change-Id: I1dabbf6f13c2ae5ad73dc8c7df9108c160e1dc2b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-11-06 13:48:01 +01:00
Jonas Karlsson 779fea7875 Dice example: tweak shadowBias
There was a bug previously causing the shadowBias to be 2x its specified
value, so update the value to account for this fix.

Change-Id: I980993eb3a798755ede736d6b20537ed4f23186c
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-10-01 14:15:13 +02:00
Assam Boudjelthia 7668e5a746 Android: optimize dice app for mobile orientation
Now, the camera position is set too close so that not the whole view
is shown on portrait mode. So set the camera position close or far based
on the orientation.

Increase the default size of the dice so it's more visible and not tiny.

Don't move/shift the whole scene when the drawer is opened, this just
causes huge drop in fps on Android devices, instead the drawer opens
without affecting the scene's postion or dimentions.

Pick-to: 6.8
Task-number: QTBUG-127813
Change-Id: I3c7c54e4a1dbb3378045d86debaa21c8e50e8e94
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-09-26 15:39:24 +03:00
Assam Boudjelthia e74acbf6df Android: set dice project configuration for publishing to Play Store
Pick-to: 6.8
Task-number: QTBUG-124674
Change-Id: Ie70a492ae94c0dd73a4be1ca24dd4d0923c82f13
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2024-09-26 15:39:22 +03:00
Jonas Karlsson 8b4248d687 Dice example: adapt to Qt 6.8 shadow mapping
The dice shadows are now only enabled when they are close enough to the
table. This will keep shadow map bounds smaller and reduce graphical
artifacts.

Pick-to: 6.8
Change-Id: I4664e4d6d825f0dd01ebb65e1180cb28155cb890
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-08-22 09:11:29 +02:00
Sami Shalayel c4d3c1690a dice demo: use qt_add_qml_module
Use qt_add_qml_module for the dice demo.

Make the demo qmllint clean by removing unused imports, unqualified
accesses and more.

Use loadFromModule instead of load, and rename main.qml to Main.qml to
be loadable. Also add a missing qmldir file for the qmake project to
work with loadFromModule, and fix the prefixes in the .pro file.

Pick-to: 6.8
Task-number: QTBUG-100100
Change-Id: I786dcb971980f48e91b0aeaf9d65f285a78c260e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-07-09 08:57:19 +02:00
Assam Boudjelthia 45a82b2b73 Android: cleanup AndroidManifest.xml files in examples
Change-Id: If4712fb258052a1a74d56ecb8415503d4025b8b3
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2024-05-23 15:13:28 +03:00
Alexandru Croitor cde9cfb96c CMake: Add deployment API to our examples
Projects were modified using the tool at:
https://git.qt.io/alcroito/cmake_refactor

Some examples had to be adapted manually, mostly those that build
additional qml modules / plugins.

documentviewer did not get the deployment api, because it's trickier.

Pick-to: 6.7
Task-number: QTBUG-101340
Task-number: QTBUG-102056
Task-number: QTBUG-102057
Change-Id: I76322185fc824c112d77e077ee39e7ccbc193a4c
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-05-13 09:44:04 +02:00
Even Oscar Andersen cb69d167bb Add missing sound files to dice qmake build
Pick-to: 6.7 6.6
Change-Id: I56de4c78fdf979cd43be067e402a8ff90df2ba8b
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2024-04-17 08:18:55 +00:00
Even Oscar Andersen 5c04abcb6e Dice demo: Add missing menu icon to qmake project
Pick-to: 6.7 6.6
Change-Id: I6e463cf04d0e4ca6d7015e17241d657940a01613
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2024-04-03 05:17:17 +00:00
Lucie Gérard 8b36425fab Correct build system file license under example
According to QUIP-18 [1] all files under examples
should be licensed
LicenseRef-Qt-Commercial OR BSD-3-Clause

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7 6.7.0
Task-number: QTBUG-121787
Change-Id: Ia2e8f62af64a384196a9b0c02ac5b2fbf5404a8b
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-19 08:20:16 +01:00
Jonas Karlsson 691a8b9bc3 Dice example: center text
Fixes: QTBUG-121144
Change-Id: Ifa4735307bda97dd9e830af8acac6239358fb1e1
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-03-12 20:11:07 +00:00
Nicholas Bennett 5a62cbe268 Docs: Update Qt Dice example documentation
Added the required modules to the note, updated the brief.

Pick-to: 6.7 6.7.0
Change-Id: I2515aaeec95dd7825794b784d7799920a2624b43
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2024-03-12 08:43:50 +00:00
Nicholas Bennett 32fcefb291 Dice app example: fix menu in landscape mode
Put the column of controls in a flickable and set the scroll-bar
to always on if the UI's height is greater than the screen height.
This way the the user knows they can scroll if they start
the application in a landscape orientation. Should see no change in
on desktops, unless you resize the application window smaller than
the menu height.

Fixes: QTBUG-122444
Pick-to: 6.7 6.7.0
Change-Id: Ic49c7b0acdb8f71723925441af5dfbaa8793b67e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-07 08:09:17 +00:00
Nicholas Bennett 15e216c402 Update package and app name for dice example
This is to meet the requirement that the app have a different name on
the app store.

Task-number: QTBUG-115724
Pick-to: 6.7
Change-Id: Ia5b657b7a9f363a5c4ca1e7c27f75daa07d5c689
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-06 09:45:21 +00:00
Jonas Karlsson 7b243c46f3 Dice example: fix deprecated warning
"Injection of parameters into signal handlers is deprecated"

Change-Id: I12f6257b4cf2f5b79d9ba7153ad256292eebc0fd
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-01-26 19:57:58 +01:00
Kai Köhne 9a61a3a987 Demos: Add dependency info to example metadata
Add metadata about build time / runtime dependencies in the form
of Qt documentation modules. This should allow Qt Creator to hide
examples where needed Qt modules are not installed (because they
are optional in the Qt Online Installer).

Pick-to: 6.7
Task-number: QTBUG-120759
Change-Id: I03d8d75b273fe497803b9af9783b90e397b0638d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-01-19 10:26:22 +01:00
Bartlomiej Moskal ffc1984fd3 QDice Example: Add a timer-guard for rolling dices
There is a problem in QQ3DPhysics. onBodyContact may still refer to
already deleted object - which causes the application to crash.
It happens when Accelerometer spam a lot with scene.spawnDice(...)
calls.

To avoid this crash, the timer-guard for rolling dices was added.

Pick-to: 6.7 6.6
Fixes: QTBUG-120364
Change-Id: I3ca3811662fb2400d61cb256c8b34885a6fe028a
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2024-01-16 09:06:00 +01:00
Tuukka Turunen 84a7477e2a Add possibility to adjust dice size with a slider
New slider UI controls added to adjust dice size.

Pick-to: 6.7 6.6
Change-Id: Ie01efacff8eae0a33644f943bfd50d2cd258a7b1
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-12 11:04:10 +01:00
Nicholas Bennett 39074ca944 Fix menu icon on Android, fix initial msg not wrapping on small screens
The menu button icon did not appear on Android with the text method, so
added an icon svg to use on all platforms.

The initial label pop up was not wrapping on small screens so added a
height, modified properties to keep the original text size but wrap the
text.

Fixes: QAA-2183
Pick-to: 6.6 6.7
Change-Id: I2265e7558dfec839530b5f9b6a7a4129d7b081b2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2023-12-22 12:22:52 +02:00
Rami Potinkara 33d02572d8 Docs: add QML Media Player and Dice to Mobile category
Task-number: QTBUG-117458
Pick-to: 6.7
Change-Id: Iccc2c7bc47118c21fce72f23ef489bb4476a8644
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2023-12-19 20:03:00 +02:00
Nicholas Bennett 4d21bd9e57 Add app icon for ios target to Dice example application
Updated the CMakeLists file, added the icon and json file.

Task-number: QTBUG-117125
Pick-to: 6.6
Change-Id: I2691c2e84e7ebc0b25bb34eece9a08f5e922eb58
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-12-08 09:55:43 +02:00
Nicholas Bennett 81d73cdbb5 Add Android icon and target SDK for dice example app
Added target SDK 33 with CMake and added icon for Android target,
using Qt creator to generate icons and the AndroidManifest xml
file. Gradle files were excluded.

Task-number: QTBUG-118513
Pick-to: 6.6
Change-Id: I57953099350017975702309496e4e4f1a87e9d1f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-12-04 09:02:05 +00:00
Nicholas Bennett bc2e698936 Docs: Update dice example app documentation
A had initially intended to expand this documentation more exhaustively,
however, I decided that example documentation that describes each discrete feature already exists.
Added sections, expanded a bit, referenced existing applicable example
documents, and the fact that this example will be available already
built for Android in the Google Play Store.

Fixes: QTBUG-114599
Pick-to: 6.6
Change-Id: Id989d82a40fb95808a42aa1b497b4d76161b5d74
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-09-02 04:11:45 +00:00
Nicholas Bennett 62b33327c0 Dice Demo: Add sound effects and shake to roll
Added the features in line with the spike outcome.
In addition, I modified the spawnDice function to
estimate if all dice are at rest before enabling spawning.
This prevents duplicate shake events and double tap
fumbles.

Task-number: QTBUG-116491
Pick-to: 6.6
Change-Id: Ia0dc59e469e008da5fc3afe2a7342381eadc1008
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-09-02 03:40:04 +00:00
Kai Köhne 0bc36e534e Dice: Extract calculation of 45degrees
Don't calculate this inside the for loop.

Pick-to: 6.5 6.6
Change-Id: I09d46e363325071086332d901235f0feeabbb474
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2023-08-14 18:25:28 +02:00
Kai Köhne 0f05ed1e01 Examples: Explicitly mention Quick3D requirement in the documentation
Quick3D is an optional component in the online installer. As the examples are part of qtdoc,
they are however installed & available also if Quick3D is missing.

Let's at least mention the dependency in the respective examples' documentation.
Add a general 'Running the Example' section if missing, too.

Pick-to: 6.5 6.6
Fixes: QTBUG-114998
Change-Id: If4d3b48b3d0352a0359f6962d4eb1bc2e1e67c95
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2023-08-11 13:58:36 +02:00
Jonas Karlsson 41625c4721 Dice example: remove workaround
The bug is fixed but the workaround was actually not needed to begin
with since the bug only affects nodes with a position and a parent with
scale which is not the case here.

Pick-to: 6.5 6.6
Change-Id: I99766586d2671b3286085d54c7cf8cca7e0f9b7b
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-07-17 12:09:56 +00:00
Kai Köhne 68e3af8836 Dice example: Add tags
Pick-to: 6.5 6.6
Change-Id: If2dc727786ae7e4ca582fb7268a96c8e2657b875
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2023-06-26 13:40:11 +02:00
Kai Köhne 67d2885605 Reformat .qml files in dice example
Use qmlformat -i on all files.

Pick-to: 6.5 6.6
Change-Id: I163d1faf281fc085b824e092056cebe57fce5a6b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-22 17:27:34 +02:00
Jonas Karlsson 34ecd60038 Add the 'dice' example
Fixes: QTBUG-113600
Pick-to: 6.5 6.5.2 6.6
Change-Id: I13b8327f2dcf3e7eaec80c7c10038b22a1656df3
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-06-21 00:50:04 +02:00