aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-08-06 10:49:04 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-11 18:35:57 +0000
commitffdc90d42eef09233b000ff60febc1a339a4c1a7 (patch)
treec319e636a8df836216f2cf79b78d2ea1cb2d33d0
parent1955a180d2cbee2f11ec2ea1ced72bc13a3afd84 (diff)
Imagine: add SelectionRectangle.qml
Add a SelectionRectangle to the imagine style. The style will then draw selection handles that looks the same as a slider handle. Change-Id: I20e23d01aee39d3cf05b313c95741fb274a1935f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 207e950ad44d4c105d3e93feed1e54e588943a0f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quickcontrols2/imagine/CMakeLists.txt1
-rw-r--r--src/quickcontrols2/imagine/SelectionRectangle.qml76
-rw-r--r--src/quickcontrols2/imagine/imagine.pri1
3 files changed, 78 insertions, 0 deletions
diff --git a/src/quickcontrols2/imagine/CMakeLists.txt b/src/quickcontrols2/imagine/CMakeLists.txt
index 088aeba6b6..c1823d04fe 100644
--- a/src/quickcontrols2/imagine/CMakeLists.txt
+++ b/src/quickcontrols2/imagine/CMakeLists.txt
@@ -34,6 +34,7 @@ set(qml_files
"ScrollView.qml"
"ScrollBar.qml"
"ScrollIndicator.qml"
+ "SelectionRectangle.qml"
"Slider.qml"
"SpinBox.qml"
"SplitView.qml"
diff --git a/src/quickcontrols2/imagine/SelectionRectangle.qml b/src/quickcontrols2/imagine/SelectionRectangle.qml
new file mode 100644
index 0000000000..2dbce02b63
--- /dev/null
+++ b/src/quickcontrols2/imagine/SelectionRectangle.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.Imagine
+import QtQuick.Controls.Imagine.impl
+
+T.SelectionRectangle {
+ id: control
+
+ topLeftHandle: handle
+ bottomRightHandle: handle
+
+ Component {
+ id: handle
+ Image {
+ id: image
+ source: Imagine.url + "slider-handle"
+ visible: SelectionRectangle.control.active
+ ImageSelector on source {
+ states: [
+ {"vertical": false},
+ {"horizontal": true},
+ {"disabled": false},
+ {"pressed": tapHandler.pressed || image.SelectionRectangle.dragging},
+ {"focused": true},
+ {"mirrored": false},
+ {"hovered": hoverHandler.hovered}
+ ]
+ }
+
+ HoverHandler {
+ id: hoverHandler
+ }
+
+ TapHandler {
+ id: tapHandler
+ }
+ }
+ }
+}
diff --git a/src/quickcontrols2/imagine/imagine.pri b/src/quickcontrols2/imagine/imagine.pri
index 134aa2c34e..18a2ee6f92 100644
--- a/src/quickcontrols2/imagine/imagine.pri
+++ b/src/quickcontrols2/imagine/imagine.pri
@@ -38,6 +38,7 @@ QML_FILES += \
$$PWD/ScrollView.qml \
$$PWD/ScrollBar.qml \
$$PWD/ScrollIndicator.qml \
+ $$PWD/SelectionRectangle.qml \
$$PWD/Slider.qml \
$$PWD/SpinBox.qml \
$$PWD/SplitView.qml \