diff options
author | Oliver Eftevaag <[email protected]> | 2023-05-24 17:44:41 +0200 |
---|---|---|
committer | Oliver Eftevaag <[email protected]> | 2023-05-26 10:03:00 +0200 |
commit | 064aa8127ca4be856f573c25d94d0cf86215a1c4 (patch) | |
tree | 3efe5d63f8c48cea7b819824c4a1f8e6b60c76a7 /examples/quick/customitems | |
parent | bd916dee64cf2bc710227fc2eb4231c68eaab626 (diff) |
customitems examples: adhere to guidelines
They were in a pretty good state already.
This patch simply makes some minor tweaks,
based on our own guidelines for examples.
The tweaks include, but are not limited to:
- PRIVATE linkage
- WIN32 and MACOSX_BUNDLE in qt_add_executable()
- Remove unused #include
- Use qsTr()
- Remove warnings.
Pick-to: 6.5
Change-Id: Ie4d50d4e2134b7b373bdf1ba38779d3052165286
Reviewed-by: Mitch Curtis <[email protected]>
Diffstat (limited to 'examples/quick/customitems')
9 files changed, 15 insertions, 22 deletions
diff --git a/examples/quick/customitems/dialcontrol/CMakeLists.txt b/examples/quick/customitems/dialcontrol/CMakeLists.txt index da97def218..b8eda130d0 100644 --- a/examples/quick/customitems/dialcontrol/CMakeLists.txt +++ b/examples/quick/customitems/dialcontrol/CMakeLists.txt @@ -17,15 +17,12 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(dialcontrolexample + WIN32 + MACOSX_BUNDLE main.cpp ) -set_target_properties(dialcontrolexample PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(dialcontrolexample PUBLIC +target_link_libraries(dialcontrolexample PRIVATE Qt6::Core Qt6::Gui Qt6::Qml diff --git a/examples/quick/customitems/dialcontrol/Dial.qml b/examples/quick/customitems/dialcontrol/Dial.qml index 7e3b8cbd87..3b9692cc91 100644 --- a/examples/quick/customitems/dialcontrol/Dial.qml +++ b/examples/quick/customitems/dialcontrol/Dial.qml @@ -32,7 +32,7 @@ Item { id: needleRotation origin.x: 5; origin.y: 65 //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + angle: Math.min(Math.max(-130, root.value * 2.6 - 130), 133) Behavior on angle { SpringAnimation { spring: 1.4 diff --git a/examples/quick/customitems/dialcontrol/QuitButton.qml b/examples/quick/customitems/dialcontrol/QuitButton.qml index af362b6ddf..841ff34ee8 100644 --- a/examples/quick/customitems/dialcontrol/QuitButton.qml +++ b/examples/quick/customitems/dialcontrol/QuitButton.qml @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick + Image { source: "quit.png" scale: quitMouse.pressed ? 0.8 : 1.0 diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qml b/examples/quick/customitems/dialcontrol/dialcontrol.qml index d30f66fa2c..695ec9fb46 100644 --- a/examples/quick/customitems/dialcontrol/dialcontrol.qml +++ b/examples/quick/customitems/dialcontrol/dialcontrol.qml @@ -43,7 +43,7 @@ Rectangle { return } - var desiredPercent = slider.x * 100 / (oldWidth - 32) + let desiredPercent = slider.x * 100 / (oldWidth - 32) slider.x = desiredPercent * (width - 32) / 100 oldWidth = width } diff --git a/examples/quick/customitems/flipable/CMakeLists.txt b/examples/quick/customitems/flipable/CMakeLists.txt index 2f4a402ed5..7d2c75c56e 100644 --- a/examples/quick/customitems/flipable/CMakeLists.txt +++ b/examples/quick/customitems/flipable/CMakeLists.txt @@ -23,7 +23,7 @@ qt_add_executable(flipableexample main.cpp ) -target_link_libraries(flipableexample PUBLIC +target_link_libraries(flipableexample PRIVATE Qt6::Core Qt6::Gui Qt6::Qml diff --git a/examples/quick/customitems/maskedmousearea/CMakeLists.txt b/examples/quick/customitems/maskedmousearea/CMakeLists.txt index 3afa2ed41a..9274fcdeee 100644 --- a/examples/quick/customitems/maskedmousearea/CMakeLists.txt +++ b/examples/quick/customitems/maskedmousearea/CMakeLists.txt @@ -15,16 +15,13 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/maskedmousearea find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) qt_add_executable(maskedmousearea + WIN32 + MACOSX_BUNDLE main.cpp maskedmousearea.cpp maskedmousearea.h ) -set_target_properties(maskedmousearea PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(maskedmousearea PUBLIC +target_link_libraries(maskedmousearea PRIVATE Qt6::Core Qt6::Gui Qt6::Qml diff --git a/examples/quick/customitems/maskedmousearea/main.cpp b/examples/quick/customitems/maskedmousearea/main.cpp index 64cc1c62f2..6c19ac91f8 100644 --- a/examples/quick/customitems/maskedmousearea/main.cpp +++ b/examples/quick/customitems/maskedmousearea/main.cpp @@ -4,8 +4,6 @@ #include <QGuiApplication> #include <QQuickView> -#include "maskedmousearea.h" - int main(int argc, char* argv[]) { QGuiApplication app(argc,argv); diff --git a/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt index 72e7ebc574..6f3ed2f35c 100644 --- a/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt +++ b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt @@ -14,7 +14,7 @@ qt_add_qml_module(qmltextballoon textballoon.cpp textballoon.h ) -target_link_libraries(qmltextballoon PUBLIC +target_link_libraries(qmltextballoon PRIVATE Qt6::Core Qt6::Gui Qt6::Qml diff --git a/examples/quick/customitems/painteditem/textballoons.qml b/examples/quick/customitems/painteditem/textballoons.qml index d363093d95..1ef491f061 100644 --- a/examples/quick/customitems/painteditem/textballoons.qml +++ b/examples/quick/customitems/painteditem/textballoons.qml @@ -20,14 +20,14 @@ Item { } ListView { + id: balloonView anchors.bottom: controls.top anchors.bottomMargin: 2 anchors.top: parent.top - id: balloonView delegate: TextBalloon { - anchors.right: index % 2 == 0 ? undefined : parent.right + anchors.right: index % 2 != 0 ? parent?.right : undefined height: 60 - rightAligned: index % 2 == 0 ? false : true + rightAligned: index % 2 != 0 width: balloonWidth } model: balloonModel @@ -50,7 +50,7 @@ Item { Text { anchors.centerIn: parent - text: "Add another balloon" + text: qsTr("Add another balloon") } MouseArea { |