Commit Graph

1734 Commits

Author SHA1 Message Date
Samuli Piippo a5ced5b63c examples/texteditor: remove use of Material style
Amend ec582ef0b9 which removed use of Material
as the default style. This cause example to fail when cross-compiled, as it
then used different qml file which had dependency to Material style.

Fixes: QTBUG-106557
Pick-to: 6.4 6.3 6.2
Change-Id: I7f918363a47c801a6755eca38c1c4bc4da2854b6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-09-14 08:17:32 +03:00
Doris Verria db0716571c todolist example: Make it easier to hide keyboard when finished editing
- Hide keyboard on Keys.onReturnPressed event in the TextField-s
- Add "Done" button to TextArea to mark editing as finished and hide
the keyboard in return

Done-with: Mitch Curtis <mitch.curtis@qt.io>
Pick-to: 6.4
Change-Id: I3351e5b3db356946b59b19c6f424153cbf2dbbb1
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-09-13 11:12:36 +02:00
Joni Poikelin 61314a2863 Fix signals in QML extended example
Change-Id: I03afea816e6935af7f32f38caf736f60e351d87a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-09-13 07:14:29 +03:00
Luca Di Sera c1b198e013 Doc: Remove usages of the second argument of a "\page" command
The "\page" command for QDoc, used to construct a standalone
documentation page in the output documentation of a project, was able to
take a second argument, apart from the first argument representing the
name for the generated documentation page, that roughly represented the
type of the page that was to be generated.

This second argument was not actually used by QDoc, such that it had no
meaningful effect.

QDoc was recently modified to not support this second argument,
internally, and officially removed its use.

For technical legacy reason, QDoc will still support the usage of a
second argument for a "\page" command, albeit it will do nothing, as
before.

To avoid confusion for future readers who might not be aware of the
history of the "\page" argument and that will not find an explanation in
QDoc's documentation anymore, the usages of the second argument in
"\page" commands are now removed.

Change-Id: I0241ffa17d658245516f725e64048e332cbccd42
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-09-08 16:46:56 +02:00
Kristoffer Skau 7fe4c9bb27 Add live property to QQuickItem layer
QQuickItemLayer now has a live property that can be set to determine if
its contents should change whenever the item updates. This enables
variable refresh rate for quick items.

[ChangeLog] Added live property to QQuickItem layer.

Fixes: QTBUG-77343
Change-Id: I8bf7e7af4cfed6deef2253d346bb0b72d0fef66e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-09-08 16:46:55 +02:00
Jenny Lofthus 6b5cf59698 Controls: add todolist example for showcasing the iOS Style
Task-number: QTBUG-80261
Pick-to: 6.4.0 6.4
Change-Id: Ie6d86b0a49bd0684373816d709c7e010aff7e7a5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-08 09:44:35 +02:00
Lucie Gérard 1b9808737a Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: Id89ed14990804a5024183e75382cc539d4293da1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-07 17:01:30 +02:00
Kai Köhne b7f448f864 Examples: Do not use import version numbers anymore
Pick-to: 6.4
Change-Id: I1f4d4920bb9d132a846ac2dbcfdb8b660759d540
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-08-31 16:37:35 +02:00
Richard Moe Gustavsen ec582ef0b9 examples, texteditor: remove the config file, and use default settings instead
The qtquickcontrols2.conf file was hard coding the style to be
Material. In addition, it was overriding both the Primary and the
Foreground color, and sat Theme=System. The latter meant that the
application would run in either Light or Dark mode, depending on
the OS. And for Dark mode, the assigned colors caused the text to
end up with the same color as the background color, and therefore
be invisible.

The same with the toolbar buttons; since the icon color of a toolbar
button map to the primary color, and the primary color was hard-coded
to be the same as the background color in the configuration file, the
buttons would appear hidden.

Since we now have native styles for both macOS and Windows (and
Fusion on Linux), overriding the style (and especially the colors)
in a config file seems unnecessary.

This patch will therefore remove the whole config file, and use
the default style settings instead.

Fixes: QTBUG-105860
Pick-to: 6.4 6.3 6.2
Change-Id: I330fe30746096cf26d8dca343f2c122d7c32c7fe
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-08-31 13:09:32 +02:00
Samuli Piippo b21290a731 examples: deploy qmldir for plugin example
We need to deploy qmldir to make the example work also for remote targets.

Pick-to: 6.4 6.3 6.2
Change-Id: Id0b7bf4a48bd163ddf5e44a5a68ca3edbbcc008e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-31 07:56:45 +03:00
Oliver Eftevaag 314cae8752 TextEditor example: use the ColorDialog from qt quick dialogs
In 6.4 we're introducing the ColorDialog in the qt quick dialogs module.
This was the final dialog, that was missing from the module in previous
versions of qt.

This change will make use of the new dialog, instead of the qt labs
platform version, which is using the widgets color dialog as a fallback.

The eventual goal for this example should be to eliminate the need for
the qt labs platform module entirely.

Note that I am also making a small change to how the font dialog is
being used, since we deprecated the currentFont property in the 6.3
release, but I forgot to update this example along with it.

Pick-to: 6.4
Change-Id: Ib99ca7cbf110d3084ff96dfadfa1cd8c8af8815e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-08-25 03:56:22 +02:00
Mitch Curtis 2f67fdb949 texteditor: fix out-dated code snippet
The property should be selectedFile, not file.

Pick-to: 6.3 6.4
Change-Id: I3ce399a7df2d80d122058c411b9b1a633f04fc64
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-08-25 09:55:57 +08:00
Bartlomiej Moskal db11519e68 Doc: Fix image for eventcalendar example
Use correct image in documentation for eventcalendar example.

Pick-to: 6.4 6.3
Fixes: QTBUG-105572
Change-Id: If217dfa536aea2fa3197510c36a865053e3e96dd
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-08-25 03:55:35 +02:00
Ulf Hermann 57e9eacaf2 Examples: Actually fix the shadereffects example
The paths need to be the same between CMake and qmake and you really
should not use absolute qrc paths.

Amends commit d270c51f81
Amends commit e0ee63a06e

Change-Id: I9f6d3ac3fbf4483e0c0f2cad540f45c25192886e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-08-24 15:04:08 +02:00
Laszlo Agocs e0ee63a06e Fix shadereffects example resources
Stuff cannot just magically move under a different prefix
when shaders are referenced with relative paths.

As the example uses the common main helper code, it is
easier to switch to absolute paths than to use
NO_RESOURCE_TARGET_PATH.

Amends d270c51f81

Change-Id: I527314725210e02675dc8c2f5fc5042dc5e1c478
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-08-17 01:45:55 +02:00
Shawn Rutledge 77d0ec9f84 Fix the pointerhandlers example
Amends d270c51f81

Change-Id: I616850c04facbcd7662c479d34b1a3f0a7220556
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-11 17:23:24 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Ulf Hermann d270c51f81 Adapt examples to AUTO_RESOURCE_PREFIX
Examples that don't explicitly set NO_RESOURCE_TARGET_PATH get the
AUTO_RESOURCE_PREFIX now.

Task-number: QTBUG-103452
Change-Id: I6b41e96ce5620079f60ca2f967b0a2e611c1f738
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-06-24 08:45:43 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Ulf Hermann d8dc3507d0 Examples: Add missing header files to the CMakeLists.txt
It's generally a good idea to state the headers. Let's teach our users
to do so.

Change-Id: I50b81d6724bce1f7e5aa6ed4491fcc63e21a0247
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-07 09:33:29 +02:00
Ulf Hermann b61301af77 Add missing "flipable" example to the build tree
Change-Id: I6452ba667078cb8ad5dbf9cc8c6512c8dea9f933
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-07 09:33:25 +02:00
Kai Köhne 21a17fbd89 Examples: Replace qt-5 urls
Pick-to: 6.3
Change-Id: Ifec0960bfb3f179e2cf5ff5e7f11364b106a86e3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-05 13:39:35 +02:00
Andreas Eliasson 92419f7f1b Doc: Rename snippet id to a unique identifier
The header file has two snippets with the same id. Rename to unique
values and link to the correct snippet id from the qdoc file.

Fixes: QTWEBSITE-1051
Pick-to: 6.3
Change-Id: I9003916f831898026f520fd86d60ab1c0230e6c4
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-02 10:07:40 +02:00
Ulf Hermann 4a32ceec40 Fix URI of i18n example
It shouldn't be "dynamicscene" as that URI is already used by a
different example.

Change-Id: I35ac6b7ea70703f24304f640252f922d6a5b2371
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-02 02:42:52 +02:00
Oliver Eftevaag 5b0bb8d78e Update the text editor to use the MessageDialog in qt quick dialogs
Our goal is to eventually remove the dependency for the qt labs platform
module. This patch will replace one of the labs platform MessageDialogs,
with a MessageDialog from qt quick dialogs.

All of the dialogs that are used in this example will eventually be from
the qt quick dialogs module.

Change-Id: I19f97948bf04d0fa5b265e057bbf49374bb51472
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-05-11 12:56:22 +02:00
Andreas Eliasson a12db0dfc9 Doc: Add CMake sections to 'Creating C++ Plugins for QML' page
- Revise grammar
- Fix so that example project can be built from the command line using
  CMake
- Add tabs on example page

Pick-to: 6.3
Task-number: QTBUG-102330
Change-Id: Ic6bdcadec66850f5e811dcaac23a8cb59a6c3f94
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-05-04 22:34:15 +02:00
Andreas Eliasson d4c8f0b95b Doc: Add CMake documentation to 'Extending QML' example
Fixes: QTBUG-102085
Pick-to: 6.3
Change-Id: I8f79a00b9ef827f229a94bc840b1951c8f67e4a2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-04-25 11:44:26 +02:00
Fawzi Mohamed 838c7724e6 qmldom: Fix standalone compilation against Qt 6.3.0
Change-Id: I402eeeab1cd6f5e02d5f49eedbd01010de39d05a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-22 01:47:50 +02:00
Mitch Curtis e25196599b Merge "Merge remote-tracking branch 'origin/dev' into wip/iosstyle" 2022-04-01 13:39:52 +08:00
Alexey Edelev 396d8b0d17 Add VERBATIM option to add_custom_command calls
Use VERBATIM option to prepare the correct command line for the
add_custom_command. This especially sensitive when using build
directories with names containing special symbols, that cannot be
handled by shell correctly.

Change-Id: Ic6ea2a557fe4e7ccc1d2a0c5c4ab707223c0b91a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-31 20:09:57 +02:00
Mitch Curtis c7a8e5e2d3 Merge remote-tracking branch 'origin/dev' into wip/iosstyle
Change-Id: I669b338496d926b5a2fa0f49561dddc0cf349bd0
2022-03-31 10:43:33 +08:00
Fabian Kosmale 612d988243 Add cmake support for examples
qml-i18n needed to be ported to CMake first. It uses qt_add_translations
introduced in 6.2

As a drive-by, move find_package calls from examples' CML to the top
level CML, and make the QtSql dependency optional. Also make sure that
we only add the dynamicscene example when the Quick target is available.

Pick-to: 6.2 6.3
Fixes: QTBUG-90964
Change-Id: Id357eb14e4704753386e01393300966eb89b4e86
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-29 22:12:43 +02:00
Shawn Rutledge 864dade139 Sidebar example: nest content in MouseArea to restore hover propagation
After 499828b855 if you want a MouseArea
underneath some other contents to receive propagated hover events, the
content must be inside the MouseArea, not a sibling. HoverHandler still
does not have this restriction (handlers cannot have items as children,
and the handler is not considered a sibling: it's an event-handling
facet added to the item in which it's declared).

Pick-to: 6.3 6.2
Change-Id: I5ac31d982e429ac002cb0bd7ae9c071ab927032b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-28 23:42:16 +02:00
Tasuku Suzuki 771b31c235 Replace paintedWidth/Height with contentWidth/Height
They were renamed in 51b7425329

Pick-to: 6.2 6.3
Task-number: QTBUG-15160
Change-Id: If30f69d47adf391d2d1c795caaf2bbe15f6bc32a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-03-27 21:38:57 +00:00
Jani Korteniemi 9dcd908fb5 Add improvements to object listmodel example
Scaled to fit whole screen on android.
Replaced items with Qt Module names.
Randomized colors.
Added scrollbar.

Task-number: QTBUG-95438
Pick-to: 6.3 6.2
Change-Id: I1686aff4d4770d0d34399f20301c8fc393b8d778
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-22 18:47:47 +02:00
Laszlo Agocs a184f2e0ab Make QQuickWidget QRhi-based
When it comes to examples, quickwidget has the direct OpenGL usage
removed because we want this example to be working with any graphics
API. qquickviewcomparison, which features direct OpenGL usage within
its Qt Quick scene, is renamed to a more descriptive name and is also
getting a doc landing page. It continues to be requesting OpenGL (via
QRhi) explicitly.

Change-Id: Iae5b835441f3af229e9746e14dedbe9d1a62b2b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-18 22:56:54 +01:00
Richard Moe Gustavsen e798058823 Merge remote-tracking branch 'origin/dev' into iosstyle
Change-Id: If094d48e544c4ea14c1e4c21d99322b71b580dde
2022-03-10 12:19:59 +01:00
Kai Köhne e2138561df Use QSGRendererInterface::OpenGL in documentation and examples
QSGRendererInterface::OpenGLRhi is only an (undocumented) alias to
...::OpenGL, so let's use that instead.

Amends 0b2311a62b

Pick-to: 6.2 6.3
Change-Id: I4acdd39dc1d9b75bed5c474667a43b4ad86e7f47
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-14 11:38:10 +00:00
Doris Verria af7f42b8af Add directory for new iOS style and initial plugin implementation
Change-Id: I80c8d0406a071e435bc8872aad7478fb75996475
Reviewed-by: Doris Verria <doris.verria@qt.io>
2022-02-10 12:03:15 +00:00
Kai Köhne 9d82f4bff8 Improve examples CMakeLists.txt
- Remove # generated from xyz.pro comment from pro2cmake
- Remove "# special case" markers for pro2cmake
- Remove automatic use of CMAKE_AUTORCC
- Only opt into CMAKE_AUTOUIC if .ui files are involved
- Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR
- Combine multiple find_package(Qt6 ... calls)
 - use REQUIRED COMPONENTS
 - sort components alphabetically
- Fix wrong indentations
- Use (only) one empty line after multi-line commands

Pick-to: 6.3
Change-Id: I0d6bfb06c4b25e9921d3d2bf31d977150f12b31b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-24 13:25:13 +01:00
Shawn Rutledge f9834fa3c7 Disambiguate "parent" in flatstyle example
Amends d7862eac1b

"rectangle" wasn't a good name for the circular knob part of the switch.
By using a more unique name "nub" we can make it a bit easier to read and
avoid using "parent" at all. https://en.wiktionary.org/wiki/nub

Fixes: QTBUG-100110
Pick-to: 6.3
Change-Id: I428dc6d8463af4ea7e5890145fd40590fed4bcbe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-24 13:25:13 +01:00
Ulf Hermann 712b637b58 Rename "Basic Types" to "Value Types"
Internally they've been called "value types" all along. Now that we are
adding the ability to define your own value types the "basic" name is
not really fitting anymore. Value types can be quite complex.

Change-Id: I5fb4abec1dd2f0bbf7fb7f08b02db0882490e983
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:23:59 +01:00
Shawn Rutledge 092b582460 Drag and Drop example: remove ParentChange
Reparenting the tile doesn't seem to be needed; and behavior changed
somehow in Qt 6.

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-99436
Change-Id: If860d62260a7904718eb33b857b339bc6c5557a8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-04 22:00:24 +00:00
Alexandru Croitor 2f45a9c2b9 Switch examples to build as isolated sub-builds
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Change-Id: I7fab73f63a22901ab2d4d4e57b5a25b433100de5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-16 18:28:29 +01:00
Shawn Rutledge 0d008bc0cd Fix pointer handlers example build: include piemenu, qmake support
Amends e17bfffc07 and
8503f884bb : all qml files need to be
listed in CMakeLists.txt, we need to keep qml.qrc updated too, and
we decided to keep the qmake project files.

Change-Id: Idaa4bbddabd59e79a0ae3b907319c6843d8a026a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2021-12-12 14:39:36 +01:00
Shawn Rutledge 8326ff2ac1 Instantiator: don't interfere with delegates that assign parents
[ChangeLog][QtQml][Instantiator] Instantiator now avoids re-assigning a
delegate object's parent to itself if it was already set; thus, you can
now declare a parent assignment.

Task-number: QTBUG-64546
Task-number: QTBUG-84730
Change-Id: I7d95fa76e71c363b4cb5b7a512c2e984488c8af4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-12-10 06:52:35 +01:00
Shawn Rutledge cd5d62e999 Pointer Handlers example: show mouse wheel feedback
MouseFeedbackSprite now shows a mouse wheel animating in the same
direction as the physical mouse wheel is being rotated.

Change-Id: I08709ead3b85065723d2320d17d49adb51a00f92
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-10 06:52:06 +01:00
Shawn Rutledge 2b50181be8 Add HoverHandler.blocking property
As with WheelHandler, sometimes users want to let the hover events
propagate (which has been the default all along), but sometimes it's not
appropriate to allow parents of nested items to show hover feedback.

[ChangeLog][QtQuick][HoverHandler] HoverHandler now has a property
called blocking, which is false by default; but if set to true, it
prevents hover events from propagating to items "under" this handler's
parent, and their HoverHandlers.

Task-number: QTBUG-85926
Change-Id: I26f89482e294c7a6b30a55a7e23ac444a0d1ac7f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-12-09 23:16:36 +01:00
Fawzi Mohamed c630ee67b7 qmldom: load and rewrite example
load and rewrite example using the standalone build of the dom and
compiler libraries

Change-Id: Ib7823712aea2164291c21b07956dcec734bc9542
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-07 12:47:34 +02:00
Fabian Kosmale 4e8fe676d2 Fix toplevel Qt build (for real this time)
reused_dir_targets takes a list of targets, not directories, so provide
that one. Amends 953c1cf394

Fixes: QTBUG-98468
Change-Id: I44e811ff738c5a51845c4829e1e6928e5f2f06f1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 00c352c4d4)
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-12-06 22:42:39 +01:00
Fabian Kosmale 45d63800d7 Fix toplevel Qt build
All targets using the "shared" approach need special handling in
toplevel builds to ensure that AUTOMOC works.
Amends aa4897e017.

Fixes: QTBUG-98468
Change-Id: Ic0a6ee0ab43190e359ad7cfb7e7634d393ff0b03
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 953c1cf394)
2021-12-06 22:42:34 +01:00
Shawn Rutledge e17bfffc07 Add TapHandler.gesturePolicy: DragWithinBounds enum value; examples
On a touchscreen, right-clicking is not directly possible; so sometimes
a long-press gesture is used as a substitute. The next thing a UI
designer would want would then be a way of showing feedback that a
long-press is in progress, rather than simply waiting for the long-press
to occur and then surprising the user with some instant action.
For example, a menu might begin to open as the user holds down the
touchpoint; but before the long-press gesture is complete, the user can
simply release, to cancel the gesture and close the menu. The timeHeld
property could drive the animation, to avoid needing a separate
animation type; in fact the reason timeHeld exists is to make it easy
to emulate this sort of touch-press animation, like one that occurs on
touchscreens since Windows 7.

But after the menu is open, the user would probably expect to be able to
drag the finger to a menu item and release, to select the menu item. For
such a purpose, the existing gesture policies weren't very useful: each
of them resets the timeHeld property if the user drags beyond the drag
threshold; so if the user expects to drag and release over a menu item,
then the timeHeld property cannot drive the menu-opening animation,
because the menu would disappear as soon as the user drags a little.

So it makes more sense to have a gesturePolicy that acts like
WithinBounds, but also applies the same policy to the timeHeld property
and the longPressed signal. We don't care about the drag threshold:
if the user is holding down a finger, it's considered to be a
long-press-in-progress, regardless of how far it has moved since press
(as long as it stays within the parent's bounds).

An example of such a menu is added.  The menu must have TapHandler as
its root object, because it reacts to press-and-drag within some larger
item, larger than the menu itself.  For example such a menu could be
used in a canvas-like application (drawing, diagramming, dragging things
like photos or file icons, or something like that): dragging items on
the canvas is possible, but long-pressing anywhere will open a context
menu. But in this example so far, only the menu is implemented.
It's a pie menu, because those are particularly touch-friendly; but
perhaps for the mouse, a conventional context menu would be used.

[ChangeLog][QtQuick][Event Handlers] TapHandler now has one more
gesturePolicy value: DragWithinBounds; it is similar to WithinBounds,
except that timeHeld is not reset during dragging, and the longPressed
signal can be emitted regardless of the drag threshold. This is useful
for implementing press-drag-release components such as menus, while
using timeHeld to directly drive an "opening" animation.

Change-Id: I298f8b1ad8f8d7d3c241ef4fdd68e7ec8d8b5bdd
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-12-02 12:52:58 +01:00
Friedemann Kleint 0b2311a62b Scenegraph examples: Use suffix-less RHI constants
Complements 23dbe3d6e0.

Pick-to: 6.2
Change-Id: Ic1bda49a888b0580ac483d650b879a9ae843129b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-23 18:42:51 +01:00
Thomas Hartmann 84b3e889b8 Add .qmlproject file for examples containing .ui.qml files
If an example contains ui.qml it should also have
a .qmlproject file for Qt Design Studio.

Pick-to: 6.2
Change-Id: I290838f5bf7c6d295ea7fecb6b1c689ad5b924e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-18 10:23:00 +00:00
Oliver Eftevaag 88dfbe0dea Rendercontrol example: use new cmake api
Updating the CMakeLists.txt files in the d3d11 and opengl version of
the example to use the new qt_add_qml_module() function instead of the
old qt_add_resources()

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: Ida43e4b0c875951a85d754b3a96f88366b580e24
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-15 23:07:17 +01:00
Venugopal Shivashankar dc569a6189 Doc: Fix qdoc warnings
- Comment out \instantiates entries that refer to private C++ classes
- Fix clang-format and regexp warnings

Change-Id: I7228538715b9d34ab39e7c0f71155be7a277116a
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-11-14 23:47:54 +01:00
Oliver Eftevaag a155b3bc3e Model examples: use new cmake api
The models directory contains 3 subdirectories with an example project
in each.

This patch updates the CMakeLists.txt files to use qt_add_qml_module()
instead of the old qt_add_resources().

In order to achieve intercompatibility with both cmake and qmake, I had
to do some slight modifications to both the .qrc files and the url path
used to set the source to the QQuickView.

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I13d1c01a0eda181823f394bc2a4259ce98abd4f8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-12 12:24:29 +01:00
Oliver Eftevaag fe59c788a6 painteditem: better error message when running cmake on textballoon
Building the TextBalloon in isolation doesn't make any sense.
Its purpose is to implement a delegate, for the painteditem example to
use, and should therefore only be built as part of the painteditem
project.

To build the example, cmake should be invoked with
examples/quick/customitems/painteditem/CMakeLists.txt as its source
path.

The CMakeLists.txt in examples/quick/customitems/painteditem/TextBalloon
should only be used from another CMakeLists.txt file via the
add_subdirectory() command. If invoked directly it makes sense to print
an error message and stop processing.

Task-number: QTBUG-96806
Pick-to: 6.2
Change-Id: I1ebd2157790afbf7307498a4fb64049794ae6c5b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-11 13:11:40 +02:00
Oliver Eftevaag fb26412952 Embeddedinwidgets example: use qt_add_qml_module()
We want to use the new cmake api, rather than qt6_add_resources()

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I567aec77b963adce03fb683c244d758880891ce5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-11 11:11:40 +00:00
Oliver Eftevaag 750e7d946c Keyinteraction example: use qt_add_qml_module() in CMakeLists.txt
We want to use the new cmake api instead of qt6_add_resources()
The file structure has also been flattened a bit.

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I1651d25e2902bf6932b78c2224ee4ffe454b658d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-11 12:11:40 +01:00
Oliver Eftevaag 28bfd773ca MouseArea example: use qt_add_qml_module() and update a signal handler
Thing patch updates the CMakeLists.txt file to use qt_add_qml_module()
instead of qt6_add_resource().

Additionally, it changes a signal handler, which was previously a plain
statement, into a js function, which is the preferred way to write signal
handlers.

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I1b08dcd3eae370d78587aa3d37d9456437b54b42
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-11 11:11:40 +00:00
Oliver Eftevaag aa4897e017 Particle examples: use new cmake api
The particles directory contains 5 different examples
and a shared directory with some images files.

This patch changes the examples to use qt_add_qml_module()
in the CMakeLists.txt project files, and changes the .qrc
files to directory reference the files needed by the individual
projects, which removes the need for images.qrc.
(The .pro files still reference the shared.qrc file)

The "content" directories located in the different example
projects, have been removed, and the containing files have simply
been moved to the parent directories instead.

Some unused files in the itemparticle example have also been
deleted. This example looks very outdated and should ideally
be improved, or perhaps simply removed, but I decided to leave
it for now.

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: If05986b4347814715bca50b8d3f6a5cddbf9ced4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-11 12:11:40 +01:00
Mitch Curtis 5e8e12b342 Fix CMakeLists.txts of chattutorial
- Run pro2cmake.py on each .pro and did some manual adjustments.
- Rename directories to simplify resource paths, URIs, etc.
- Rename executables to ensure they're distinguishable from other
  targets in Creator's locator.
- Duplicate images into each example due to issues with resources.
- Now that we use qt_add_qml_module, the qtquickcontrols2.conf
  file will no longer be at the resource root, so specify it
  separately with qt6_add_resources.
- Update qmake files.
- Fix documentation.

Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I210ef2cbcd45dd7f4df881332174bff1b18c5be7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-09 18:55:15 +01:00
Friedemann Kleint c442ed4d65 Polish the QML reference examples
- Use member initialization, which allows for using
  constructors from the base classes
- Use qsizetype for indexes
- Use qInfo() instead of qWarning() for printing
- Add spaces/fix formatting

Pick-to: 6.2
Change-Id: Iebce1b810ce00f29395207d93303363b3b71e52e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-04 10:51:39 +01:00
Mitch Curtis dbf7048ae2 Add calendar types
Formerly Qt.labs.calendar, then QtQuick.Calendar in the marketplace,
this now returns as part of the controls module.

[ChangeLog] Added types from Qt.labs.calendar/QtQuick.Calendar.

Change-Id: I8a06c08e6520be1ba8f33c73ba174785724e99c2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-03 11:40:59 +01:00
Ulf Hermann d7862eac1b Update examples to use new PropertyChanges
Also, prefer the multi-line syntax over ';'-separated bindings for
readability.

Change-Id: I3d6eb854e514ee257ca83773a11e6e9e10770bff
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-03 09:14:48 +01:00
Andrei Golubev 3f2816ff6e rendercontrol_d3d11: Explicitly include qt_windows.h
Prevent accidental inclusion of windows.h through d3d11_1.h where
max/min are defined as macro. That causes the subtle error elsewhere
within the example

Change-Id: I527c53ecbc82204a1f087719f5b0b4736d8c3447
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-10-29 17:49:13 +02:00
JiDe Zhang 85b5413dc4 Avoid unnecessary color format conversion
If a color is not the rgb format, when QColor::red() QColor::blue()
QColor::green() is used continuously to obtain the values of different
channels, three times color conversions will occur. Therefore, use
QColor::toRgb() before that to ensure that only one conversion is
performed at most. Not only rgb, the conversion of other formats is the
same.

Change-Id: Ia969e1ca6f1524ad5d7e8dec915bcbc407875c66
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-29 18:59:48 +08:00
Ivan Tkachenko e4308747d3 Fix indentation in positioners example
Pick-to: 6.2 5.15
Change-Id: I5a39ba9361503cd5d7ce2e6da59d7807d540bee5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-10-28 07:16:40 +03:00
Shawn Rutledge cc18223e0b Remove import versions from qml files in the pointerhandlers example
Many of these are portable to Qt 5; but we don't need the version
numbers in Qt 6, and the components that use "palette" refer to
Item.palette, which was added in Qt 6.

Pick-to: 6.2
Change-Id: Ic799fba5dd66db51a8808c52dce01d27c6da62bb
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-27 12:35:15 +00:00
Shawn Rutledge c61cfa8487 Fix pointerhandlers/fakeFlickable example
TapHandlerButton is not in this example: we just call it Button.
Amends 8503f884bb

Pick-to: 6.2
Change-Id: I49bc6081f05642cd938a257c14c10497bfafb8a8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-26 12:04:34 +02:00
Oliver Eftevaag e2532e8773 Pointerhandlers example: fix CMakeLists.txt linking error
Fixes: QTBUG-97466
Pick-to: 6.2
Change-Id: I9bb0b79b12cbd43209f56137bbdb67ca2457ca6c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-26 10:03:30 +00:00
Luca Di Sera 325938018b Remove deprecated usage of QQmlFileSelector::get in texteditor example
The text editor example adds a "touch" file selector to the qml engine
that is used for the application such as to be able to provide an
interface for touch based devices.

The extra selectors were added by retrieving the engine's file selector
trough QQmlFileSelector::get, which was deprecated in Qt 6.0, see commit
75563fa761.

This resulted in a deprecation warning when the example was built.

To avoid the warning and the use of deprecated methods in examples, the
example was modified to use the suggested replacement, `QQmlApplicationEngine::setExtraFileSelectors`.

A line suggesting the use of the deprecated method was removed
from `QQmlFileSelector`'s documentaton page.

Fixes: QTBUG-97462
Pick-to: 6.2
Change-Id: I6ee0306647fe16e75c2cd72f3b37be6c7c5f9261
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-10-22 07:36:35 +00:00
Allan Sandfeld Jensen 72c3befaa2 Replace 0 pointer constants with nullptr
Replaced in most common patterns.

Change-Id: Idcaff1f2e915f29922702d3600a2e5f1e2418a7a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-18 12:39:28 +02:00
Mitch Curtis f60e514300 chattutorial: fix build without SQL
Pick-to: 6.2
Change-Id: I68d1a2c42cde55ed9d370411943c2cb006355186
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-15 15:45:16 +02:00
Shawn Rutledge eca6bd4854 Implement horizontal rule rendering in text
The rule is just a line drawn with the same thickness as an underline:
it gets thicker as DPR increases.

A horizontal rule can be created via <hr/> in RichText.
In markdown it's called a "thematic break," and a line with
- - -
is one way to create it: https://spec.commonmark.org/0.30/#thematic-breaks
<hr width=70/> or <hr width=70%> set the width in pixels, and percent
of the text width, respectively; the rule will be centered within the
line's bounding box in that case, as in QTextEdit etc.

The color can come from QTextFormat::BackgroundBrush if it's set
on the QTextBlockFormat, but otherwise falls back to the text color.
This can be done with CSS styling: <hr style="background-color:green;"/>

[ChangeLog][QtQuick][Text] Horizontal rules (thematic breaks in markdown)
are now rendered as simple horizontal lines, either in the same color
as the text, or as specified via CSS background-color.

Fixes: QTBUG-74342
Task-number: QTBUG-81306
Change-Id: I64f9daf28994225d1a8383d8e2e01e611a0a0237
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-14 20:55:59 +02:00
Edward Welbourne d8ce3b7f61 Fix typo: alignment has an n in it
Change-Id: Ibe0ef16609a704042b964b4c29078c462820e602
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-10-13 18:58:22 +02:00
Oliver Eftevaag b128136f80 DragAndDrop example: Update CMakeLists.txt
This commit updates the drag and drop example to use qt_add_qml_module()
in its CMakeLists.txt file.

Pick-to: 6.2
Change-Id: I47fd28a1a114fe70986f73d4f2d87265255652a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-06 01:03:51 +02:00
Shawn Rutledge 8fc3c036de Flickable manual test: add sliders to adjust flick-speed metrics
The sliders adjust maximumFlickVelocity and flickDeceleration.

Also in the shared Slider: try harder to end up with value being
the same as init, after initialization, by making the range of movement
divisible by more numbers, by default.  180 is highly divisible, and
keeps the default Slider size reasonable.  You can still override the
size of the Slider arbitrarily, though.

Task-number: QTBUG-97055
Change-Id: I6fb41ccb87e401a747d5a8add3100053a06d9d88
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-04 15:53:33 +02:00
Alexandru Croitor d5e8a697f8 CMake: Fix wrongly copy-pasted dependency in example
Amends edc4357ae4

Pick-to: 6.2
Task-number: QTBUG-96805
Change-Id: Iedbf372cd94b1b04db55685a5d05daca491200fe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-10-01 14:04:01 +02:00
Oliver Eftevaag cba55a2f08 TextEditor: Clean up example and use quick dialogs
The text editor example is dependent on Qt.labs for its dialogs and
native menus.

The long term goal is to remove the Qt.labs dependency, and replace it
with components from QtQuick.

Currently we have a file and a font dialog, that should be used instead
of the Qt.labs dialogs.

I'm also replacing some of the properties in the DocumentHandler, since
I don't think it makes sense for the font to be limited to only a few
font weights and styles (which can be selected through the font dialog).
Selecting the most common font weight and style is still possible
using the bold and italic shortcuts and toolbar buttons.

Some more features includes:
* An additional toolbar button, which can be used to strikeout the
  selected font. This required adding an additional glyph to
  fontello.ttf.
* When coupled with the fix for QTBUG-96934, the font for the current
  selection should automatically update the listviews in the font dialog
  to select the correct family, style, sizes and effects for what is
  selected in the document handler.

Fixes: QTBUG-95976
Pick-to: 6.2
Change-Id: I2907a2270e2a139b1ccb3fcb3ce3a788306a42e3
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-09-29 23:16:33 +02:00
Shawn Rutledge 0c4851e12b doc: Replace qmlscene with qml
We deprecated qmlscene in a9c93e2716
so we should stop recommending it in docs, too.

Task-number: QTBUG-53219
Pick-to: 6.2
Change-Id: Ic729624a8ef849bd13f38087e20b5a410c5c5756
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-29 23:16:33 +02:00
Alexandru Croitor 73d8a2c016 CMake: Fix textballoon example when using a shared Qt on macOS
Copy the qml plugin into the macOS app bundle just like we do for the
examples that use the 'shared' project using the new
add_qml_module_to_macos_app_bundle helper function.

Amends 79cae5f652

Pick-to: 6.2
Fixes: QTBUG-96805
Change-Id: Ib22131a15f0cd06a7888ec991f5ec9f79045d202
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-29 16:14:44 +02:00
Alexandru Croitor 7ab424a5cd CMake: Refactor bundle_shared into a more reusable function
Refactor the logic of bundle_shared into a more reusable
add_qml_module_to_macos_app_bundle function that can be used in
QtQuick examples that need to bundle the qml plugin on macOS, but don't
use the 'shared' qml module plugin.

The new function is placed in a QtBundleQmlModuleForMacOS.cmake file
which can be included separately from the shared/CMakeLists.txt
project.

Amends 633a85cd39

Pick-to: 6.2
Task-number: QTBUG-96805
Change-Id: Iebb3f4734b9a6bd8a8316bf5ae01d9740c442645
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-29 16:14:44 +02:00
Alexandru Croitor d73f98b1b5 CMake: Fix textballoon example when using a static Qt
Don't pre-create a qml module backing library, don't link to it
directly and instead rely on regular qml plugin loading.

This avoids undefined linker errors.

Amends 79cae5f652

Pick-to: 6.2
Fixes: QTBUG-96805
Change-Id: I77acd086257e27e1933e9b36d7f0212765afceb3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-29 16:14:44 +02:00
Alexandru Croitor edc4357ae4 CMake: Fix examples that use 'shared' project when using a static Qt
When using a static Qt, linking of examples that use the 'shared' Qml
module would fail with the following error

Undefined symbols for architecture x86_64:
  "qt_static_plugin_sharedPlugin()", referenced from:
  StaticsharedPluginPluginInstance::StaticsharedPluginPluginInstance()
  in window_shared_init.cpp.o

This happened because the 'shared' project pre-created its
plugin target with qt_add_library instead of qt_add_plugin.

qt_add_plugin passes an additional QT_STATICPLUGIN compile definition
when compiling the moc'ed file to ensure that the QT_MOC_EXPORT_PLUGIN
macro creates a qt_plugin_instance_PLUGIN_NAME symbol.

Unfortunately we can't use qt_add_plugin for shared Qt builds, because
some of the projects link directly against the plugin target and it's
not possible to link against a MODULE_LIBRARY target which
qt_add_plugin creates in shared Qt build.

We could try to conditionally switch between using qt_add_library for
a shared Qt build and qt_add_plugin for a static Qt build, but that
further complicates the build system code because it requires
specifying a class name and plugin type explicitly.

Remove the direct linkage against the libraries in the examples and
instead rely on plugin loading.
This simplifies the logic of not having to pre-create a target.

Amends 7b6eea37ae

Pick-to: 6.2
Fixes: QTBUG-96805
Change-Id: I5b2f3992ccda29b59f1e99748005381c73daca69
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-29 16:14:44 +02:00
Alexandru Croitor 2a04bfaf3a CMake: Ensure proper dependencies in bundle_shared
Ensure the shared qml module is built before it is bundled into the
app's bundle dir on macOS.

Pick-to: 6.2
Change-Id: I0b93fc54d1caa86070335347f5d2735eafe6819a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-29 16:14:44 +02:00
Shawn Rutledge e57ba6916e Large Text: populate only lines visible in Window into SG
Text is rendered top-to-bottom: QQuickTextNode::addTextLayout()
iterates lines of text.  Now it first maps the window size() rectangle
into the Text item's coordinate system, and treats that as the viewport:
lines whose y coordinates fall outside are omitted.
This saves a huge amount of time and memory when the text is large.
So Flickable { Text { } } can actually be used in an ebook reader now,
for example.

QQuickItemPrivate::transformChanged(parent) is now used to inform
all children when a parent moves; so e.g. when a content item is
moved inside a "viewport" item (like a Flickable, or any other item
that is being used as a clipping viewport or just as a holder),
all children of the content item will be notified; and QQuickTextPrivate
uses this occasion to mark itself dirty so that the updatePaintNode()
will be called again.  This happens directly after the actual movement:

  QQuickTextPrivate::transformChanged  qquicktext.cpp        2990
  QQuickItemPrivate::transformChanged  qquickitem.cpp        5200
  QQuickItemPrivate::dirty             qquickitem.cpp        6339
  QQuickItem::setY                     qquickitem.cpp        6830
  QQuickFlickablePrivate::setViewportY qquickflickable.cpp   1800

Task-number: QTBUG-60491
Task-number: QTBUG-90734
Change-Id: I152d23caa725f194a186a604fbc8d0c07f597b16
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-09-29 16:14:44 +02:00
Ivan Tkachenko f5fc1d556d Use strict === equality for ScrollBar::orientation
Pick-to: 6.2
Change-Id: Icaf1bcda4a996cc3348911c87e43c4af2a246d73
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-09-27 16:30:02 +03:00
Shawn Rutledge d5fb3c9a61 Shapes interactive example: use Controls canonically; architecture
As long as we had the funcs array, it would have been nice to be able to
directly get an index from whatever "tool" is selected. For example,
TabBar has currentIndex; but TabBar is otherwise not a great fit here.
But the funcs array wasn't so elegant anyway.

So that prompts switching to the known OO design pattern in which
drawing tools are objects containing functions that "do" the drawing, so
that there's no conditional dispatch: just ask the tool to handle each
mouse state change. I.e. here the DragHandler on the canvas uses the
tool's shapeType Component to create the shape, but the DragHandler
doesn't have to care which shape it is.

Handles for moving the shapes' control points are also shape-agnostic:
- a handle is a sort of template taking the path x and y properties to
  read and write
- the handle initializes its position from those properties
- the DragHandler inside gets to do what it does best: just drag the
  handle, nothing else (instead of needing to script the movement of
  both the handle and the control point, we don't script either one)
- declarative bindings on the handle's position update the path
  properties whenever the handle moves

And some styling:
- Switch looks better than Button for toggling
- use palette colors so that it looks good in dark mode too
- fix handle colors getting stuck on yellow
- borders on handles (yellow on white makes it hard to see the edge otherwise)
- reorder curve types by mathematical order (line, quadratic, cubic)

Pick-to: 6.2
Change-Id: Iefd980f428601840deb55370aad9256748855f07
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-09-27 10:55:47 +02:00
Shawn Rutledge 8503f884bb Move most of the pointer manual tests to a new pointerhandlers example
They were always meant to be examples eventually. Now they will be used
for an example of how to implement custom controls using only basic
items and handlers. Some components are very similar to those in
the shared directory; but most examples will use Qt Quick Controls,
so those shared components can be removed when we no longer use them.
This example should remain as the one that shows how to build
reusable controls "from scratch".

Removed InputInspector because it's inefficient, has limited usefulness,
tends to require building the manual test to be able to run it, and
could be better built as a reusable Qt.labs component later on,
providing a model with all known devices and taking advantage of the
QPointingDevice::grabChanged signal to track the grab states rather
than polling.

Pick-to: 6.2
Change-Id: I47ab6ebb2cecab07a69cf96e546ffd0db3026a60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-24 17:03:19 +02:00
Shawn Rutledge 38ac4b4ec2 Shapes example: give each qml file's root item a default size
Each square is resized anyway in shapegallery.qml; but for the sake of
running individual examples on the command line with qml, the content
being shown should be visible. Without this fix, each item had a 0,0
size by default; but the shapes themselves have their own sizes and are
centered in the zero-size root item. But when a window is created, the
window system does not allow it to have zero size, so it expands; and
then the shape would be centered at the top-left corner, and you could
only see part of it.

Pick-to: 6.2
Change-Id: I42a537421430aea8233106353e9c2033f5bc5774
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-22 20:39:52 +02:00
Oliver Eftevaag 9025ea98ca Gallery example: remove binding loop from TextArea page
The width binding for the TextArea was didn't make a lot of sense.
It used to be limited by the panes availableWidth / 3, but if the
implicitWidth was less, the text would move towards the center, since
the anchors are centering the TextArea horizontally.

Setting the width to just always be the panes availableWidth / 3,
simplifies the binding, removes the binding loop, and doesn't move the
visible text towards the center when the implicitWidth is less than 1/3
of the panes availableWidth.

Note that this doesn't directly fix QTBUG-91109, because QTBUG-91109
isn't really a bug to begin with.

Pick-to: 6.2
Fixes: QTBUG-91109
Change-Id: I5b6de8dfd11fd726e8ffdae0e46143c448985dc4
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-09-13 14:42:09 +02:00
Fabian Kosmale deccfa4636 Fix toplevel build again
delegatechooser_shared also uses the shared directory, and thus needs
the workaround.
Amennds f4760b48bb.

Pick-to: 6.2
Change-Id: If05694c2608b0e0a86993f0f2ace7b1640d039c7
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2021-09-08 14:41:20 +02:00
Craig Scott f4760b48bb Fix top level builds failing with AUTOMOC-related missing moc exe
In top level builds, qt_autogen_tools() needs to be called on any
target that enables AUTOMOC. A previous commit fixed that problem for
the qt_target_qml_sources_example target, but missed also fixing it for
the associated plugin target. Add that missed call here.

More examples that use the common "shared" quick directory have also
since been added, but the step that ensures qt_autogen_tools() was
missed. Add them to the missing step. One of the existing steps also
had a typo, which meant it wasn't handled either, so correct that as
well.

Amends 067253fb2f

Task-number: QTBUG-96118
Task-number: QTBUG-96159
Change-Id: I2fae5d9a1fd474b22e01ec51d5b1030237f3e08f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 215dea1bfc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-09-07 11:42:11 +00:00
Fabian Kosmale 011ee2dfec Examples: Fix top level build
Examples using the "shared" pattern need to be recorded in the list in
examples/quick/CMakeLists.txt, so that we do the necessary AUTOMOC
handling for them in a top level build. For details, see the commit
which introduced that list.
Amends 34bc389543.

Pick-to: 6.2
Change-Id: I6945b0c8445fe436da259dd240342e1c3b5cbf26
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-09-07 13:42:10 +02:00
Oliver Eftevaag 2cd4391ba0 Fix layouts example to use a QML module
Changing the CMakeLists.txt file to use qt_add_qml_module().

Pick-to: 6.2
Change-Id: Icafe9359494136af6d5f3befaa9e767ab12deb30
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-09-06 21:23:00 +02:00
Oliver Eftevaag 06e96fdcde Fix positioners example to use a QML module
This fix changes the CMakeLists.txt file to use qt_add_qml_module().

It also updates copyright headers and changes import statements to
remove version numbers. This causes the example to use qt quick
controls 2, rather than qt quick controls 1, which is obsolete, and
should no longer be used by any of our examples.

Pick-to: 6.2
Change-Id: I1e40990b3a184c73b67a2ab04b4ec555774b8a1b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-06 14:03:11 +02:00
Oliver Eftevaag 56b47052b8 Fix righttoleft example to use a QML module
Updated CMakeLists.txt to use qt_add_qml_module().

Copyright headers and import statements have also been updated.

Pick-to: 6.2
Change-Id: I8093d186f433293e63c6330def579f5589a938e6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-06 14:03:11 +02:00
Ulf Hermann 79cae5f652 Clean up the painteditem example
The way it was before it was unusable. Move the files that belong to the
TextBalloon module into their own directory, and add a wrapper
application that loads textballoons.qml with the right parameters to
actually find the TextBalloon module. Make sure that the qmldir file is
copied to the output directory.

Pick-to: 6.2
Change-Id: Ie7407a425a0a95a46de6486f9a28fd1aee07de9f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-06 11:03:09 +02:00
Ulf Hermann 485416c9d5 Fix delegatechooser example to use QML modules
We need to rephrase the image source selection due to ListElement only
accepting literals. We can't just poke into the qrc file system of the
"shared" module without importing it.

Pick-to: 6.2
Change-Id: I54d3fa4daf304afc9a0a55ab8b590d9c5ad20aa2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-06 11:03:09 +02:00
Ulf Hermann be260ba529 Fix dynamicscene example to use a QML module
Pick-to: 6.2
Change-Id: I23b87b8ca98721cebc0dc948f0c9bbf741af6cd5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:48:15 +02:00
Ulf Hermann a57d3a0beb Fix the canvas example to use a QML module
Pick-to: 6.2
Change-Id: I84445909adafbd2cf0f5654fa78a005ed243536f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:47:17 +02:00
Ulf Hermann 65b2e46423 Fix animation example to use a QML module
Pick-to: 6.2
Change-Id: Ic53194b43eb651438d3f89bbb5dfbb97aff8b606
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:47:07 +02:00
Ulf Hermann e11c320029 Update text example to use QML modules
Pick-to: 6.2
Change-Id: If1c8455aa823eb432f10586bdb31a65166ed915d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:46:56 +02:00
Ulf Hermann 23ddc51e5e Fix threading example to use QML modules
Pick-to: 6.2
Change-Id: I973244a0546e668ba8c65e573747e08f60a506c0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:46:37 +02:00
Oliver Eftevaag 34bc389543 Fix ImageElements example to use a QML module
Removed the 'content' directory, and placed all images into a 'pics'
directory.

CMakeLists.txt is now also using qt_add_qml_module()

Pick-to: 6.2
Change-Id: I673b7adea1832f304003f95e171118b0822b3c83
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-03 17:10:32 +02:00
Ulf Hermann 633a85cd39 Install the "shared" example module into macOS bundles
If we build an application bundle we cannot rely on the relative path
between the application's and the shared module's output directories.

This is somewhat ugly, but as we don't have a comprehensive solution for
building application bundles, yet, it's the best we can do right now.

In order for the shared bundle to be loaded from the PlugIns directory,
we need to add the PlugIns directory to the import path on macOS.

Pick-to: 6.2
Change-Id: I5b952420b4bb60af74886a140fa2c6a263d2f730
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-03 13:04:55 +02:00
Craig Scott 920a5f727b Fix top level builds where AUTOMOC_EXECUTABLE was unset on some targets
The qt_example_build_end() command tries to recursively find all build
system targets by descending into all source directories. Some sets of
examples re-use the same source directory multiple times with different
build directories, but this hides all but one of those re-used source
directories from the recursive search. This resulted in some targets
being missed, which in turn prevented qt_autogen_tools() from being
called on them. In top level builds, this meant AUTOMOC_EXECUTABLE
wasn't set, so CMake tried to verify the moc it wanted to use, which
doesn't exist for the first configure of a top level build, resulting
in a fatal error. Since we can't find all targets reliably with a
recursive search, manually handle the ones that could be missed.

There was a similar problem with qt_autogen_tools() not being called
for a target created to compile a doc snippet. The error message is
the same as the case above, the cause is again AUTOMOC_EXECUTABLE
not being set, but for a different reason. Apply the same fix and
call it manually, which should have been the case originally.

Fixes: QTBUG-96118
Fixes: QTBUG-96159
Pick-to: 6.2
Change-Id: I079c696cf74f77d7caa2c59e6263d3fb1c55d20e
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-03 19:37:06 +10:00
Oliver Eftevaag 713bb3ce8f Clean up flipable example
Turning the project structure to be inline with Ulf's ideas.
Such as using qt_add_qml_module().

Previously the path to 5_heart.png and 9_club.png were broken.
This patch updates the path in the qml file, in order to make sure that
the resource is actually loaded.

It also adds a CMakeLists.txt, since it didn't already have one.

Pick-to: 6.2
Change-Id: I4b2ffbfcfff7d2d63d7aab9fd7b40f77c1a1073c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-03 10:52:09 +02:00
Oliver Eftevaag 5d751f3ce6 Simplify the XmlHttpRequest example
The XmlHttpRequest example contains a lot of unnecessary code, and I
felt that most of it could just be removed.

The point of the example project is to showcase how to use the
XMLHttpRequest javascript object to make requests.

Which is why I felt that we could remove any outside dependencies for
the project (like the LauncherList from the 'quick/shared' directory),
and reduce the amount of components down to the minimum.

Fixes: QTBUG-95734
Pick-to: 6.2
Change-Id: I9b062f4d7e942db4a2669a8c65f7488aa4a54740
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-03 10:39:37 +02:00
Oliver Eftevaag b0e567e7e3 Fix localstorage example to use a QML module
Removing the directory 'localstorage' that is inside the top-level
'localstorage' directory, and moving the content one level up in the
file hierarchy.

Pick-to: 6.2
Change-Id: I97cf1ff92be9860d9a92bce66c88af927618e2b0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-03 10:39:22 +02:00
Topi Reinio 5e6777be1d Doc: Fix documentation warnings in qtdeclarative
* QtLabsPlatform has its own documentation project, but its source
  directory was pulled into QtQuick docs, causing duplicate generation
  and warnings.

* Fix \snippet paths for files that were renamed/moved around.

* Clean up .qdocconf files, use the {,} syntax to set identical values
  for multiple variables.

* Fix incorrect \sa link.

Pick-to: 6.2
Fixes: QTBUG-96125
Change-Id: I4c83787ac23a5b40019c74d46ee87c968a8d4907
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2021-09-03 10:16:39 +02:00
Craig Scott 2e04ba2994 Disable quick examples currently breaking top level builds
The add_subdirectory("../shared" "shared") pattern used by these
examples seems to somehow trigger an AUTOMOC-related generation error.
The cause is not currently known, so this change temporarily disables
those tests until a proper fix can be found.

Task-number: QTBUG-96159
Change-Id: I2525b77d0a25c3e3191ae2956857acabc0aedbf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit d83c303b95)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-09-01 21:28:34 +00:00
Shawn Rutledge 270a6f9bba Rename shapes example qml files according to what they demonstrate
The order they are shown in the grid is not important; but users should
be able to run any of these qml files directly without building the
example, and appropriate names make the "right one" easier to find.

Task-number: QTBUG-95739
Pick-to: 6.2
Change-Id: I9751b52ce80bc08e12919ca3396c9d428d700a04
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-01 18:11:54 +02:00
Ulf Hermann 2dfb912058 Fix dialcontrol example to use a QML module
Also move the QML files out of the "content" subdirectory in order to
avoid the directory import.

Pick-to: 6.2
Change-Id: I84a1f5ef1a45e5098ec3213c6fbce06346f3606a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-01 11:49:15 +02:00
Ulf Hermann 66c011c558 Clean up shapes example
Drop the confusing alias mangling on all the QML files. Instead move
them into the base "shapes" directory. Also, use a QML module in CMake
and use the "shared" module as intended.

Pick-to: 6.2
Change-Id: I6a8fc3f2b2f86f58a54e188cf83ec7e2d4e8f468
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-01 11:49:06 +02:00
Oliver Eftevaag 9556a46743 Fix ExternalDragAndDrop example to use qt_add_qml_module()
Pick-to: 6.2
Change-Id: Ic368ce6e36ee41aff519a3ae106d18670c05bb54
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-31 23:19:51 +02:00
Ulf Hermann c10427bc04 Convert dynamicview tutorial to use QML modules
Pick-to: 6.2
Change-Id: I98069eea1bd4492aba661e4672ffe297f0dcc4c8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-08-31 23:19:51 +02:00
Ulf Hermann 255d8a84b3 Fix shadereffects example to use a QML module
Pick-to: 6.2
Change-Id: I3787fdfebfa1e376c2891f16f3fcf4f29f0e26d4
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-08-31 21:20:14 +02:00
Ulf Hermann 405bbc1c0e Remove .prev_CMakeLists.txt
We don't need to use pro2cmake anymore here.

Pick-to: 6.2
Change-Id: Iba8bac70c1fe31e56bf9680608913cc2c336f946
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-31 11:26:11 +02:00
Oliver Eftevaag 71a781beb1 DynamicView4 tutorial: add forgotten file to qrc
The FileSelector.qml component for some reason were never added to the
qrc file, which meant that it didn't exist in the eyes of qmake.

It should now be possible to run the program.

Pick-to: 6.2
Change-Id: Iaab67860123e926456c99b775449648f5d8e7c3c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-31 11:26:10 +02:00
Ulf Hermann a3ea7a9938 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.

Pick-to: 6.2
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>
2021-08-31 11:26:10 +02:00
Alexandru Croitor 9cbf4d2cc8 CMake: qmake: Fix chapter6-plugins example to build in more configs
Before this change, I tested the following configurations / scenarios

 (1) shared Qt + qmake + macOS bundle -> works
 (2) shared Qt + CMake + macOS bundle -> broken
 (3) static Qt + qmake + macOS bundle -> broken
 (4) static Qt + CMake + macOS bundle -> works

 (2) was broken because the shared qml plugin is not located in the
 expected location (see below)
 (3) was broken because qmake needs a lot of error-prone boilerplate
 to ensure static qml plugin building and linking works.

The change fixes the example to build and run successfully in case
(2).

Tested the following scenarios on macOS with the change

  shared Qt + qmake + macOS bundle -> works
  shared Qt + CMake + macOS bundle -> works
  shared Qt + qmake + no bundle    -> works
  shared Qt + CMake + no bundle    -> works
  static Qt + qmake                -> still broken
  static Qt + CMake                -> works

To make shared qml plugins be found in a macOS bundle, we need to copy
the qmldir and plugin under the bundle's PlugIns subfolder, because
the application adds that as the expected qml import path for macOS.
This basically mimics what the qmake project does with
QMAKE_BUNDLE_DATA.

The change also cleans up the CMake projects a bit so they don't link
PUBLIC-ly against dependencies, install the plugin under a more
sensible location and don't needlessly setup package finding and other
boilerplate that's done in the parent project.

The change also cleans up the qmake projects to adjust to not pollute
the macos bundle dir with static plugin files.

Amends 9e1d2a0eb1

Pick-to: 6.2
Change-Id: I45bb699a67adf598587350a03f778291fad3f850
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-31 14:51:25 +10:00
Craig Scott 784af37650 Fix warnings/errors from changes to paths in chapter6-plugins example
Amends 2d2750efc3b5a97a5f1cf09b4265a26fcc393499

Change-Id: Iab27efb7359cfcea9274dcbbc7ac64b647d3e71b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-31 14:51:22 +10:00
Laszlo Agocs d5700949ff Migrate to fixed add_shaders prefix handling
Change-Id: I6c5b0680d32bc3650983c64cc4583f790774da88
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-30 20:56:30 +00:00
Oliver Eftevaag 9454685db8 Add qsTr() around 2 strings in imageelements example
Making some strings translatable

Change-Id: I7a088e9e9966996ee20ab8bee29cf17c060120d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-30 22:56:29 +02:00
Ulf Hermann 76a413bb11 Fix touchinteraction example to use QML modules
Remove the "content" subdirectories. They just add noise.

Pick-to: 6.2
Change-Id: Iae6bf7d91b6804294673be8966e30b11caae0654
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-30 20:34:57 +02:00
Ulf Hermann cb9cc7ca66 Update views example to use modules
The qmake and qmlproject files are adapted to use the "shared" module,
too.

Pick-to: 6.2
Change-Id: I5fc4895416357ba202528b155581b1b5a880a68d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-30 20:34:49 +02:00
Ulf Hermann 7b6eea37ae Fix the qtquick/window example to use QML modules
The shared code becomes its own module. Due to the ${PROJECT_NAME} trick
it should be possible to include it multiple times, in different
examples.

Pick-to: 6.2
Change-Id: I78cc3211f67fae9a713320fae4041898e6a397ed
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2021-08-30 20:34:43 +02:00
Oliver Eftevaag 621e583f05 Fix coding style
Pick-to: 6.2
Change-Id: Icfcdcb306dbeb750c8ebad44b431c5364ef63c44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-30 15:01:16 +02:00
Oliver Eftevaag 9e38f4da96 ShaderEffects example: replace custom slider with qqc2
Replacing a custom made slider component with a qqc2 slider.

Task-number: QTBUG-95738
Pick-to: 6.2
Change-Id: I407307a3769a0c9821d311189ed40b0d48dab4d3
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-28 17:25:28 +02:00
Oliver Eftevaag 5ae40afa97 Shapes example: use qqc2 components
Changing the example to use qt quick controls where it makes sense

Task-number: QTBUG-95739
Pick-to: 6.2
Change-Id: Id0df227657693234de4481c2316dc6c3e0545043
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-28 17:25:03 +02:00
Ulf Hermann 9cb0b528e3 Update the accessibility example to use QML modules
Pick-to: 6.2
Change-Id: Iec3dad42dd08ac230ffde15b422ae7f68d419e81
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-08-27 17:09:50 +02:00
Oliver Eftevaag e771c12ae7 ImageElements example: Use QQC2 and update copyright
Updating the example to use qt quick controls 2 where it makes sense, as
well as copyright headers.

Task-number: QTBUG-95737
Pick-to: 6.2
Change-Id: Ie22ab8551926916abd0a478adc16d1d4daeb13ad
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:49 +02:00
Oliver Eftevaag dad9a15c9c Replace custom button component with QQC2 buttons
Now that we've moved qtquickcontrols2 into the qtdeclarative submodule.
We want our examples to simply use qqc2 controls, rather than custom
made buttons and other controls.

This example used a custom made button component, which this patch will
replace with qqc2.

It will also use qqc2 in other places where it makes sense, like replacing
a TextEdit with a qqc2 TextArea, and Text components with qqc2 Labels.

Task-number: QTBUG-95733
Pick-to: 6.2
Change-Id: Ic733cd592cd10ef2cf45058aaf08a0f6b2f5bd2c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:48 +02:00
Oliver Eftevaag 8976c46f46 ExternalDragAndDrop example: Use controls from Qt Quick Controls 2
This patch changes the external drag and drop example to use qqc2
checkboxes instead of a custom made component.

It also changes the position of the checkbox in order to avoid having
the label text overlap with it.

Task-number: QTBUG-95736
Pick-to: 6.2
Change-Id: If3e798ea0ccd64921138690c7599876ec0584038
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:48 +02:00
Oliver Eftevaag 409019bc11 EmbeddedInWidgets example: Use QQC2 components
Replaces the TextBox custom component with a qt quick controls 2
TextField.

Task-number: QTBUG-95735
Pick-to: 6.2
Change-Id: Ic1fb47c8e57cd2d805d4a9941df9bc02a5e7bc17
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:47 +02:00
Laszlo Agocs 266b93c9f8 Use add_shaders with CMake in some examples
Take the most obvious candidates, to which users typically turn
when getting started with ShaderEffect or QSGMaterial:

shadereffects
scenegraph/custommaterial
scenegraph/twotextureproviders

As with the parent patch that ports and updates embeddedinwidgets and
quickwidget/qquickviewcomparison to use the proper CMake machinery, we
still need to keep the .qsb files for the sake of qmake. compile.bat and
similar scripts are however removed now. With CMake the .qsb files are
not needed and are autogenerated at build time. Once qmake support
disappears from the examples, the .qsb files can be removed as well.

Pick-to: 6.2
Change-Id: I879354eef2e2179dcd268c9ae9f1402e1eaef379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 13:51:52 +02:00
Laszlo Agocs c7093e553c Port leftover effects in some of the examples
For qmake we have no choice but to ship the .qsb files, whereas with
CMake we now rely on qt6_add_shaders.

Pick-to: 6.2
Change-Id: I9bb64a3ffd01cda84fca5a0f7def270975bf71aa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 13:51:52 +02:00
Craig Scott a86fd709dd Update quick examples to new QML CMake API
This is a pre-requisite to being able to make
qt6_qml_type_registration() an internal rather than public command.
Not all examples have been updated, only those that were using the
qt6_qml_type_registration() command.

Task-number: QTBUG-95093
Pick-to: 6.2
Change-Id: I3f1814a29af608461daa90477eca0aa2304eb9d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:08:21 +10:00
Craig Scott 9e1d2a0eb1 Update qml examples for improved target path handling
Some examples were still using the old "add as ordinary resources"
approach for QML modules, others needed adjustment to the subdirectory
structure to better reflect the URI structure of the QML modules
involved.

Task-number: QTBUG-95144
Pick-to: 6.2
Change-Id: Ie3399410cf6df491eb1e7b4a589ca26c577d82a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:08:21 +10:00
Shawn Rutledge ca89437d00 Use qEnvironmentVariableIntValue() instead of qgetenv().toInt()
The docs tell us that it's faster.

Pick-to: 6.2
Change-Id: Ib828ed9a10bbb617670a61e7525cbbe25704815d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-17 16:14:53 +02:00
Joerg Bornemann b4ab58d791 Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I9f76b787533dad1c469fbb8c69df6c27b20a9aa3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 13:48:14 +02:00
Luca Di Sera 6901fb779a Remove deprecation warning from QtQuickControls2 gallery example
In the "Delegates" page of the gallery example the user is allowed to
swipe over the available `SwipeDelegateComponent`s to show a 'remove'
button, which allows the removal of that item from the containing list
when pressed.

When this happens, an animation is played.
In the code, the animation was attached to the signal handler,
as follows:

```
ListView.onRemove: SequentialAnimation {
...
}
```

This form of attachment has been deprecated as of
Qt 6.1.0, in commit 6eb35df60e, in favor of creating a stand-alone
object and calling the relevant slot from the signal handler,
generating a series of warning when the attachment happens
during the creation of the page.

This patch updates the connection to the new format, avoiding
the generation of the warnings.

Pick-to: 6.2 6.1
Fixes: QTBUG-95562
Change-Id: Ib67cb9b8703dad427c49475c00791fdd5d1b0669
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-05 09:44:41 +00:00
Mitch Curtis 16436239cd Merge qtquickcontrols2 into qtdeclarative
Task-number: QTBUG-95173
Change-Id: I2cf31e30127e8cc2f10304cabf4ff7f5050633b8
2021-07-28 11:21:25 +02:00
Craig Scott 0c99c17761 CMake: Change the default of OUTPUT_DIRECTORY for qt6_add_qml_module()
The new default is now controlled via a new QT_QML_OUTPUT_DIRECTORY
variable. If that isn't set, the fallback assumes the source directory
structure follows the URI structure and uses
${CMAKE_CURRENT_BINARY_DIR} instead. This pattern means more projects
will have working import paths for qmllint and possibly other tools
out of the box. There should also be fewer cases where the
OUTPUT_DIRECTORY option needs to be used in calls to
qt6_add_qml_module(). The QT_QML_OUTPUT_DIRECTORY variable facilitates
the scenario where QML modules might be distributed across different
parts of the source directory hierarchy, but once collected under a
common base point defined by QT_QML_OUTPUT_DIRECTORY, they form a
coherent set of QML modules whose subdirectory structure below that
base point follows their TARGET_PATH.

Fixes: QTBUG-94164
Fixes: QTBUG-95081
Pick-to: 6.2
Change-Id: I82864c361a2b34f7f1484cdbda0d9b64b34b9950
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-20 16:33:48 +10:00
Ulf Hermann fff8d6120a Use "= default" rather than empty bodies for ctors and dtors
Change-Id: Idef0ebaa0074e1e4b6b74d20bd6c70cb22a04f93
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-07-01 08:34:58 +02:00
Ulf Hermann 91e7009aec Use "auto" as type when initializing using "new"
The type is immediately visible from the right hand side then.

Change-Id: Ifc1a15e3eea9b5a91ff8647f759d207a0ee221b8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-01 08:34:54 +02:00
Ulf Hermann 83859221c1 Initialize members in declaration rather than ctor
Change-Id: I084a6865ae37c6612fbcfd44a233234f05e38814
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:17:12 +02:00