aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols2impl
Commit message (Collapse)AuthorAgeFilesLines
* Remove "2" from Qt Quick Controls directoriesMitch Curtis2022-12-0136-3965/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Qt Quick Controls 2 was named that way because it was a follow-up to Qt Quick Controls 1.x. Now that Qt Quick Controls 1 is no longer supported, we don't need to have "2" in the name. Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. By doing this renaming a few weeks before feature freeze, it won't affect the release but still results in as little time possible spent manually fixing conflicts in cherry-picks from non-LTS releases as a result of the renaming. This patch does the following: - Renames directories. - Adapts CMakeLists.txt and other files to account for the new paths. A follow-up patch will handle documentation. It does not touch library names or other user-facing stuff, as that will have to be done in Qt 7. Task-number: QTBUG-95413 Change-Id: I170d8db19033ee71e495ff0c5c1a517a41ed7634 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickNinePatchImage: fix aliasing by respecting the smooth propertyMitch Curtis2022-11-081-1/+43
| | | | | | | | | | | | | | | | | | | | | | | When scaling with fractional values, aliasing can occur. Use the same approach as BorderImage and respect the smooth property of NinePatchImage. This property comes from QQuickImageBase, which sets it to true by default. We change QQuickNinePatchImage's default value for it to false, but this can be overridden by setting QT_QUICK_CONTROLS_IMAGINE_SMOOTH to 1. As NinePatchImage is not public API, and users would have to set the smooth property on every image (where some items contain multiple NinePatchImages), it's better to have one place to set this for all controls. [ChangeLog][Controls] The Imagine style now supports smooth scaling for 9-patch images when the QT_QUICK_CONTROLS_IMAGINE_SMOOTH environment variable is set to 1. Fixes: QTBUG-107989 Pick-to: 6.2 6.4 Change-Id: I250a041f87c0270d67af191168f7bcfbf6237925 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Make QQuickAttachedPropertyPropagator publicMitch Curtis2022-10-133-295/+0
| | | | | | | | | | | | | | | | | | | | | | | | This type has been used internally as QQuickAttachedObject by the Imagine, Material and Universal styles to enable propagation of colors, dark mode flags, etc. for a while now. Users would benefit from having access to it to create their own styles (although it's not just limited to that use case). This patch: - Makes the type public in quickcontrols2. - Adds documentation and an example. - Fixes the test_window test to ensure that propagation through child windows actually works. [ChangeLog][Controls] Added QQuickAttachedPropertyPropagator, which provides a way to propagate attached properties from parent objects to children. This is especially useful when creating your own style. Fixes: QTBUG-63267 Change-Id: I2f1794dc4a9f2be56fad2f5e5f39e2ab845157fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-073-15/+15
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickPlatformTheme: fix handling of QT_QUICK_DIALOGS_SHOW_DIRS_FIRSTMitch Curtis2022-09-291-3/+4
| | | | | | | | | | Apparently an empty string can be converted to a bool, so account for that by checking if the variable was set before trying to convert it. Task-number: QTBUG-106690 Pick-to: 6.2 6.4 Change-Id: I64c41eef0cc1a88a642dabeafae959250bcd732d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | 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>
* Fix emission of QQuickPaddedRectangle::topPaddingChangedJoerg Bornemann2022-07-131-1/+1
| | | | | | | | | | | | | | ...when setting the padding property. The topPaddingChanged signal is to be emitted if padding changed and no separate topPadding has been specified. Unlike the other *PaddingChanged signals, it was emitted if topPadding *was* specified. Fixes: QTBUG-104865 Pick-to: 6.2 6.3 6.4 Change-Id: I8585c4b3f7aa70030b5c6e195516e1aba73e5c46 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-06-1137-1406/+74
| | | | | | | | | | | | 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>
* Add QtQuick.Templates dependency to QtQuick.Controls.implMarco Bubke2022-06-081-0/+1
| | | | | | | QQuickIcon is referenced as parameter. Change-Id: I984d43cb247e71b43c3a888cc7678976e918a882 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* FileDialog: make selectedFile writableMitch Curtis2022-06-022-1/+13
| | | | | | | | | | | | This allows setting an initially selected file. [ChangeLog][QtQuickDialogs] FileDialog's selectedFile property can now be set to an initially selected file. Fixes: QTBUG-101975 Pick-to: 6.3 Change-Id: I399f9379e1ac54917edbc31f9029d5522a914340 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add TUs for QML_FOREIGNs and namespaces to enable includemocsMarc Mutz2022-05-102-1/+47
| | | | | | | | | | | | There is never any implementation of QML_FOREIGN Q_GADGETs, or Q_ENUMs, so just compiling their moc-files in mocs_compilation.cpp would be fine. But at some point we want automoc to throw an error when mocs_compilation.cpp isn't empty, so add TUs nonetheless. Task-number: QTBUG-102948 Pick-to: 6.3 Change-Id: Ie4167badc730e09d51429c961915da5990c7b51a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add missing include guards to qtquickcontrols2foreign_p.hMarc Mutz2022-05-101-0/+4
| | | | | | | | Detected by includemocs. Pick-to: 6.3 6.2 Change-Id: Ic432dbba6a292c4f6887b3b3c3b543d044f55283 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QuickControls2Impl: includemocsMarc Mutz2022-04-2915-0/+30
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: If6f459ba6b7403a1703551fba571b0e1bdcf3b82 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/dev' into wip/iosstyleMitch Curtis2022-03-312-0/+3
|\ | | | | | | Change-Id: I669b338496d926b5a2fa0f49561dddc0cf349bd0
| * qqc2: do not rely on transitive includesFabian Kosmale2022-03-111-0/+1
| | | | | | | | | | | | Change-Id: Id52852490cf3ac0e96dd8a0c0c12d5c0991bc9e2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Merge remote-tracking branch 'origin/dev' into iosstyleRichard Moe Gustavsen2022-03-101-1/+1
|\| | | | | | | Change-Id: If094d48e544c4ea14c1e4c21d99322b71b580dde
| * QQuickIcon: Resolve source URL relative to outermost property ownerYuya Nishihara2022-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original attempt, deb238586a "QQuickIcon: Resolve URL relative to current element," works fine for IconLabel itself, but not for Buttons containing IconLabel. // <style>/Button.qml T.Button { id: control icon: // owner: control contentItem: IconLabel { icon: control.icon // owner: this, but should be control } } // user code Button { icon.source: "a.png" } Since IconLabel is an implementation detail of the Button, IconLabel.icon owner needs to point to the Button so the user-specified icon.source can be resolved relative to the user code, not to the <style>/ directory. This patch fixes the problem by explicitly resolving the source URL on setIcon() and propagating the resolved icon object to the inner items. If the relative URL has already been resolved by e.g. Button, the inner IconLabel never resolves the URL again to itself. The problem could be addressed by initializing icon owner only once by Action/Button constructor, but that would lead to dangling owner pointer as icon object could be copied anywhere. So I've added resolvedSource data member in place of the owner pointer. Button { id: dangling } Button { id: victim; icon: dangling.icon } // owner: dangling Component.onCompleted: dangling.destroy() // ... would SEGV (or use after free) if victim.icon.source modified. Fixes: QTBUG-95587 Pick-to: 6.2 6.3 Change-Id: Ibdd07118e79f1e1f36e1faea0289150eca734e27 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | iOS style: Move NinePatchImage and ImageSelector out of Imagine styleDoris Verria2022-02-105-0/+1086
|/ | | | | | | | | The iOS style implementation uses these components too, so make them part of QtQuick.Controls.impl instead. Change-Id: Ib3e18dcb052b9b1fe676b6cd3ce2b2b198bc6c50 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Auto-test-export QQuickIconLabelPrivateMarc Mutz2022-01-291-1/+1
| | | | | | | | | It's used in tst_qquickiconlabel.cpp, thus breaking ubsan builds unless exported. Pick-to: 6.3 6.2 Change-Id: I44192fafc7cfcc57e6eccaf0d7df37b510e6d290 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickIconLabelPrivate: de-inline dtorMarc Mutz2022-01-252-0/+4
| | | | | | | | | | Pins the vtable to a single TU. See task for more details: Task-number: QTBUG-45582 Change-Id: I56bbc64fd632f1528714a3a48420cb7248888078 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace currentFile(s) with selectedFile(s)Mitch Curtis2022-01-051-2/+7
| | | | | | | | | | | | | | | | | | selectedFile can represent the currently-selected file (if the platform supports it), and so we can free up "currentFolder" for FolderDialog now that it means the folder that is being displayed, rather than the folder that is currently selected. [ChangeLog][QtQuickDialogs] FileDialog's currentFile and currentFiles properties have been deprecated. The selectedFile and selectedFiles properties now refer to the currently selected file(s), as well as the final selection. Fixes: QTBUG-98562 Task-number: QTBUG-87798 Pick-to: 6.3 Change-Id: Ic66481332338f21169a9f63617cf4db4be83265d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use up-to date LGPL license headerKai Köhne2021-11-2932-352/+448
| | | | | | | | Remove usages of outdated LGPL3 header that references LICENSES.LGPLv3 instead of LICENSES.LGPL3. Change-Id: If7a90ec18331a68491c5a740f131a5e7b3f37df4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move Q_DECLARE_PUBLIC to the public sectionThiago Macieira2021-11-272-2/+2
| | | | | | | This is now required to use QObjectPrivate::connect. Change-Id: Iccb47e5527544b6fbd75fffd16b8bd87f0818ad5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* FileDialog: show dirs first on non-macOS platformsMitch Curtis2021-11-051-0/+6
| | | | | | | macOS shows files amongst directories instead of after them. Change-Id: Ib21918611eed59936dccd694540bc426752729fe Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add (private) PlatformTheme singletonMitch Curtis2021-11-053-0/+136
| | | | | | | | | | Exposes platform theme hints to QML so that styles have a more accurate way of checking for platform-specific behavior than: Qt.platform.os === "foo" Change-Id: I5588671005aae0751c5e473f36e0b2ba86be8998 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Migrate to autogenerated cpp exports in qqc2Alexey Edelev2021-11-0316-26/+17
| | | | | | | | | | Replace the hardcoded cpp exports with a generated one in qqc2. Task-number: QTBUG-90492 Change-Id: I8435b127a78eb924639bbb68f8b87f20dc715943 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Avoid unnecessary color format conversionJiDe Zhang2021-10-291-4/+7
| | | | | | | | | | | | 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>
* QQuickIcon: Resolve URL relative to current elementFabian Kosmale2021-09-201-2/+3
| | | | | | | | | | | | | | | | | | If a user passes a relative URL to icon, they probably expect the URL to be handled relative to the current file (like in Qt 5). We restore this behavior by doing the URL resolution in the current QML context. Unfortunately, as a gadget, QQuickIcon does not have its own context. Thus, we need to store (and set) a pointer to its "owner", so that we can retrieve the context for the binding that causes the URL to be set. We adjust the three classes which currently use QQuickIcon to set the owner in their setIcon methods. Task-number: QTBUG-95587 Pick-to: 6.2 Change-Id: Icd1f2ddf65ae7d09ff787a50a01f1db78c571abf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't qDeleteAll on std::vector<std::unique_ptr<...>>Ulf Hermann2021-09-201-2/+1
| | | | | | | | The type of QIconLoader::entries has changed. Change-Id: Ic7db865cc6a26049d60378f325af9afd65eb2ea7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix memory leak in Qt Quick Controls iconEirik Aavitsland2021-09-072-0/+8
| | | | | | | | | | | The implementation of the icon property uses the internal QThemeIconInfo struct from qtbase. That is low level and expects the user to handle memory deallocation, and this was missing. Fixes: QTBUG-93050 Pick-to: 6.2 Change-Id: Ied6488aa8871c246d3781a3db47f40130dc19bcc Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* CMake: Fix controls packages to have correct Qt package dependenciesAlexandru Croitor2021-08-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The Qt6QuickControls2 package did not get a Dependencies.cmake file generated to call find_package(Qt6Quick) because Quick was removed from the PUBLIC_LIBRARIES section of the Qt module definition. Same for the other controls Qt modules and their dependencies. Those were incorrectly removed with the idea that they were plugin targets which don't have public dependencies, but that's not the case, they are Qt modules, not plugins. Restore the public library dependencies, so that transitive find_package'ing works. Amends 9c30798a439e6a87b574472aca7a4e15107c6221 Pick-to: 6.2 Fixes: QTBUG-95532 Change-Id: Ie2cb69cdde5585e90a5ce97a6d3666a647daef40 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove unnecessary type registrtion function declarationsUlf Hermann2021-07-161-2/+0
| | | | | | | | For auto-generated plugins we don't need the declarations. Pick-to: 6.2 Change-Id: I0250703e7c81debc6bc6ca526722c43b8a8058c8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* CMake: Don't give plugins PUBLIC usage requirementsJoerg Bornemann2021-07-091-4/+0
| | | | | | | | | | | | | | | | | | | | | | | The pro2cmake.py conversion script faithfully reproduced the .pro files for the plugins, which specified the libraries as public. But in CMake, the implications of this are that public usage requirements should then be propagated to consumers. We don't expect any consumers, since a plugin is created as a MODULE library in CMake, so for Windows we don't even have an import library to link with. The only exception to this is for static builds where plugins are created as STATIC libraries instead, but only in certain controlled situations do we then link to plugins. Even then, usage requirements are not expected to propagate to the consumers, so these relationships should always be specified as private. As a drive-by fix, remove Qt::Foo dependencies that are already implied by Qt::FooPrivate. Pick-to: 6.2 Task-number: QTBUG-90819 Change-Id: I3f33766612367520e09e599f03ac06d43613aa81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Update to latest qml CMake APICraig Scott2021-06-051-23/+7
| | | | | | | | | | | | | | The new qml CMake API places a closer relationship between the backing target and the plugin target. Both are typically created together and they share a lot of common details. Instead of creating them in different parts of the source tree, they are now specified together. The src/imports area has effectively been absorbed into the other corresponding subdirectories below src with this change. Task-number: QTBUG-91621 Change-Id: I9bd32e9eb78c198ccc9db04e2829303cac323502 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Remove GENERATE_METATYPES usageMaximilian Goldstein2021-04-271-1/+0
| | | | | | | We now generate metatypes by default and every instance of GENERATE_METATYPES now causes a warning. Change-Id: I691d0a3973c47cab666bd4ca948b2afe047ee13f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Fix qml module version to use the repo project versionAlexandru Croitor2021-04-151-1/+1
| | | | | | | | | | | Use PROJECT_VERSION instead of CMAKE_PROJECT_VERSION, so that the repo project version is used in a top-level build, rather than the version of the qt5 project. Pick-to: 6.1 6.0 Task-number: QTBUG-92861 Change-Id: Ifd12d6309f358b9b72372a5c069141ecb7322bc7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove QMake project filesJoerg Bornemann2021-02-111-54/+0
| | | | | | | | | | This includes removal of the corresponding .prev_CMakeLists.txt files. Pick-to: 6.1 Task-number: QTBUG-88742 Change-Id: I4247294258629c92e80914518e9208019090c815 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-10-071-2/+2
| | | | | | | | Modify special case locations to use the new API as well. Task-number: QTBUG-86815 Change-Id: I4a690095fcd4b1141550de86b6820ae2dd579429 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Fix CMake buildMitch Curtis2020-08-261-0/+64
| | | | | | Task-number: QTBUG-82922 Change-Id: I75f4a553a6bb260f77bfa791f12fa42e80131e09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Bump import version to 6.0Mitch Curtis2020-08-261-1/+1
| | | | | | Task-number: QTBUG-82922 Change-Id: I2eb924eaaaddbe75d342f59f5fb3cd30c4a84fef Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Register C++ types declarativelyMitch Curtis2020-08-2631-0/+4124
Adapt to the new way of registering C++ types. The types need to be seen at compile time so that code can be generated that invokes them. This patch: - Adds QML_* macros where applicable. - Adapts the build system files to the new way of registering modules. - Splits up the QtQuick.Controls[.*].impl files into their own plugins, as we can only register one QML module per .pro file. - Removes C++ type registration calls in every plugin. - Moves private types from src/quickcontrols2/quickcontrols2.pro to src/quickcontrols2/impl/quickcontrols2-impl.pro. Some of these types need to be exposed to QML, but quickcontrols2.pro is already in use to declare the QtQuick.Controls import (and also provides the public C++ QQuickStyle API), and the new QML_IMPORT_NAME/VERSION syntax only allows one module per project. As some of the types that need to be exposed to QML are also referenced by some C++ code (e.g. tests, etc.), we just move all of the private types to the new library. Follow-up patches will register the QML types declaratively. Task-number: QTBUG-82922 Change-Id: Iaf9ee106237d61701d57a8896f3822304c8151a6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>