From ed87e837ffae06a5770891aa49e1f82c8b58eeec Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 2 Aug 2018 14:49:13 +0200 Subject: Add SplitView SplitView is an important tool for desktop applications that do not want to use a dock widget-style approach for their user interface. It allows users to have some degree of control over the sizing of elements in the UI, as well as the ability to conveniently serialize those sizes so that they're remembered across sessions. The main differences between this and the SplitView in Qt Quick Controls 1 are: - Has its own SplitView attached properties, rather than relying on the Layout attached properties (which required an additional import). - Uses the attached preferredWidth and preferredHeight properties as well as Item's implicitWidth/implicitHeight properties for the preferred size of items, rather than using the width and height properties. - Inherits from Container, so supports most of its API (though some parts of the API, like the currentIndex-related stuff, make no sense for SplitView). - Uses attached SplitHandle properties for the handle delegate to visualize hovered/pressed effects. - Offers convenience API for serializing the user's preferred sizes. [ChangeLog][Controls][SplitView] Introduced SplitView, a control that lays out items horizontally or vertically with a draggable splitter between each item. Task-number: QTBUG-56318 Change-Id: I3da91643ab312eb9ef5b0567da4e758f17747192 Reviewed-by: Richard Moe Gustavsen --- src/imports/controls/SplitView.qml | 55 +++++++++++++++ src/imports/controls/controls.pri | 1 + .../images/qtquickcontrols2-splitview-custom.png | Bin 0 -> 383 bytes .../snippets/qtquickcontrols2-splitview-custom.qml | 57 ++++++++++++++++ .../doc/src/qtquickcontrols2-customize.qdoc | 9 +++ src/imports/controls/fusion/SplitView.qml | 56 ++++++++++++++++ src/imports/controls/fusion/fusion.pri | 1 + src/imports/controls/imagine/SplitView.qml | 63 ++++++++++++++++++ src/imports/controls/imagine/design/imagine.sketch | Bin 293192 -> 164993 bytes .../imagine/images/splitview-handle-disabled.png | Bin 0 -> 93 bytes .../images/splitview-handle-disabled@2x.png | Bin 0 -> 99 bytes .../images/splitview-handle-disabled@3x.png | Bin 0 -> 112 bytes .../images/splitview-handle-disabled@4x.png | Bin 0 -> 130 bytes .../imagine/images/splitview-handle-hovered.png | Bin 0 -> 93 bytes .../imagine/images/splitview-handle-hovered@2x.png | Bin 0 -> 99 bytes .../imagine/images/splitview-handle-hovered@3x.png | Bin 0 -> 112 bytes .../imagine/images/splitview-handle-hovered@4x.png | Bin 0 -> 130 bytes .../imagine/images/splitview-handle-pressed.png | Bin 0 -> 93 bytes .../imagine/images/splitview-handle-pressed@2x.png | Bin 0 -> 99 bytes .../imagine/images/splitview-handle-pressed@3x.png | Bin 0 -> 112 bytes .../imagine/images/splitview-handle-pressed@4x.png | Bin 0 -> 129 bytes .../controls/imagine/images/splitview-handle.png | Bin 0 -> 93 bytes .../imagine/images/splitview-handle@2x.png | Bin 0 -> 99 bytes .../imagine/images/splitview-handle@3x.png | Bin 0 -> 112 bytes .../imagine/images/splitview-handle@4x.png | Bin 0 -> 130 bytes src/imports/controls/imagine/imagine.pri | 1 + src/imports/controls/material/SplitView.qml | 74 +++++++++++++++++++++ src/imports/controls/material/material.pri | 1 + src/imports/controls/qtquickcontrols2plugin.cpp | 6 ++ src/imports/controls/universal/SplitView.qml | 56 ++++++++++++++++ src/imports/controls/universal/universal.pri | 1 + src/imports/templates/qtquicktemplates2plugin.cpp | 6 ++ 32 files changed, 387 insertions(+) create mode 100644 src/imports/controls/SplitView.qml create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-splitview-custom.png create mode 100644 src/imports/controls/doc/snippets/qtquickcontrols2-splitview-custom.qml create mode 100644 src/imports/controls/fusion/SplitView.qml create mode 100644 src/imports/controls/imagine/SplitView.qml create mode 100644 src/imports/controls/imagine/images/splitview-handle-disabled.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-disabled@2x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-disabled@3x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-disabled@4x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-hovered.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-hovered@2x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-hovered@3x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-hovered@4x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-pressed.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-pressed@2x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-pressed@3x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle-pressed@4x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle.png create mode 100644 src/imports/controls/imagine/images/splitview-handle@2x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle@3x.png create mode 100644 src/imports/controls/imagine/images/splitview-handle@4x.png create mode 100644 src/imports/controls/material/SplitView.qml create mode 100644 src/imports/controls/universal/SplitView.qml (limited to 'src/imports') diff --git a/src/imports/controls/SplitView.qml b/src/imports/controls/SplitView.qml new file mode 100644 index 00000000..1953cf69 --- /dev/null +++ b/src/imports/controls/SplitView.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 2.12 +import QtQuick.Templates 2.5 as T +import QtQuick.Controls 2.5 +import QtQuick.Controls.impl 2.5 + +T.SplitView { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + handle: Rectangle { + implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width + implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6 + color: T.SplitHandle.pressed ? control.palette.mid + : (T.SplitHandle.hovered ? control.palette.midlight : control.palette.button) + } +} diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index 675fcf39..fbf5d075 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -53,6 +53,7 @@ QML_FILES += \ $$PWD/ScrollView.qml \ $$PWD/Slider.qml \ $$PWD/SpinBox.qml \ + $$PWD/SplitView.qml \ $$PWD/StackView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/Switch.qml \ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-splitview-custom.png b/src/imports/controls/doc/images/qtquickcontrols2-splitview-custom.png new file mode 100644 index 00000000..7afd3ff8 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-splitview-custom.png differ diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-splitview-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-splitview-custom.qml new file mode 100644 index 00000000..e202e836 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-splitview-custom.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.5 + +Item { + width: 200 + height: 100 + + //! [1] + SplitView { + id: splitView + anchors.fill: parent + + handle: Rectangle { + implicitWidth: 4 + implicitHeight: 4 + color: SplitHandle.pressed ? "#81e889" + : (SplitHandle.hovered ? Qt.lighter("#c2f4c6", 1.1) : "#c2f4c6") + } + + Rectangle { + implicitWidth: 150 + color: "#444" + } + Rectangle { + implicitWidth: 50 + color: "#666" + } + } + //! [1] +} diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc index cabeb528..de13be9d 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc @@ -736,6 +736,15 @@ \snippet qtquickcontrols2-spinbox-custom.qml file + \section2 Customizing SplitView + + SplitView consists of a visual \l {SplitView::handle}{handle} delegate. + + \image qtquickcontrols2-splitview-custom.png + + \snippet qtquickcontrols2-splitview-custom.qml 1 + + \section2 Customizing StackView StackView can have a visual \l {Control::background}{background} diff --git a/src/imports/controls/fusion/SplitView.qml b/src/imports/controls/fusion/SplitView.qml new file mode 100644 index 00000000..4050b28a --- /dev/null +++ b/src/imports/controls/fusion/SplitView.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 2.12 +import QtQuick.Templates 2.5 as T +import QtQuick.Controls 2.5 +import QtQuick.Controls.impl 2.5 +import QtQuick.Controls.Fusion 2.5 + +T.SplitView { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + handle: Rectangle { + implicitWidth: control.orientation === Qt.Horizontal ? 2 : control.width + implicitHeight: control.orientation === Qt.Horizontal ? control.height : 2 + color: T.SplitHandle.pressed ? palette.dark + : (T.SplitHandle.hovered ? control.palette.midlight : control.palette.mid) + } +} diff --git a/src/imports/controls/fusion/fusion.pri b/src/imports/controls/fusion/fusion.pri index c4493c09..72978db5 100644 --- a/src/imports/controls/fusion/fusion.pri +++ b/src/imports/controls/fusion/fusion.pri @@ -51,6 +51,7 @@ QML_FILES += \ $$PWD/SliderGroove.qml \ $$PWD/SliderHandle.qml \ $$PWD/SpinBox.qml \ + $$PWD/SplitView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/SwitchDelegate.qml \ $$PWD/SwitchIndicator.qml \ diff --git a/src/imports/controls/imagine/SplitView.qml b/src/imports/controls/imagine/SplitView.qml new file mode 100644 index 00000000..a90b3a86 --- /dev/null +++ b/src/imports/controls/imagine/SplitView.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 2.12 +import QtQuick.Templates 2.5 as T +import QtQuick.Controls.Imagine 2.5 +import QtQuick.Controls.Imagine.impl 2.5 + +T.SplitView { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + handle: NinePatchImage { + source: Imagine.url + "splitview-handle" + NinePatchImageSelector on source { + states: [ + {"vertical": control.orientation === Qt.Vertical}, + {"horizontal":control.orientation === Qt.Horizontal}, + {"disabled": !control.enabled}, + {"pressed": T.SplitHandle.pressed}, + {"mirrored": control.mirrored}, + {"hovered": T.SplitHandle.hovered} + ] + } + } +} diff --git a/src/imports/controls/imagine/design/imagine.sketch b/src/imports/controls/imagine/design/imagine.sketch index ecb437f7..f3535b37 100644 Binary files a/src/imports/controls/imagine/design/imagine.sketch and b/src/imports/controls/imagine/design/imagine.sketch differ diff --git a/src/imports/controls/imagine/images/splitview-handle-disabled.png b/src/imports/controls/imagine/images/splitview-handle-disabled.png new file mode 100644 index 00000000..0071c196 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-disabled.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-disabled@2x.png b/src/imports/controls/imagine/images/splitview-handle-disabled@2x.png new file mode 100644 index 00000000..67cee407 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-disabled@2x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-disabled@3x.png b/src/imports/controls/imagine/images/splitview-handle-disabled@3x.png new file mode 100644 index 00000000..84752ba9 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-disabled@3x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-disabled@4x.png b/src/imports/controls/imagine/images/splitview-handle-disabled@4x.png new file mode 100644 index 00000000..e4be8597 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-disabled@4x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-hovered.png b/src/imports/controls/imagine/images/splitview-handle-hovered.png new file mode 100644 index 00000000..1386d213 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-hovered.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-hovered@2x.png b/src/imports/controls/imagine/images/splitview-handle-hovered@2x.png new file mode 100644 index 00000000..4708a47b Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-hovered@2x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-hovered@3x.png b/src/imports/controls/imagine/images/splitview-handle-hovered@3x.png new file mode 100644 index 00000000..2ccc1ff5 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-hovered@3x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-hovered@4x.png b/src/imports/controls/imagine/images/splitview-handle-hovered@4x.png new file mode 100644 index 00000000..6929da70 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-hovered@4x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-pressed.png b/src/imports/controls/imagine/images/splitview-handle-pressed.png new file mode 100644 index 00000000..7face6b4 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-pressed.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-pressed@2x.png b/src/imports/controls/imagine/images/splitview-handle-pressed@2x.png new file mode 100644 index 00000000..ad940d0f Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-pressed@2x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-pressed@3x.png b/src/imports/controls/imagine/images/splitview-handle-pressed@3x.png new file mode 100644 index 00000000..d4e19dc2 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-pressed@3x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle-pressed@4x.png b/src/imports/controls/imagine/images/splitview-handle-pressed@4x.png new file mode 100644 index 00000000..8ccbbebc Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle-pressed@4x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle.png b/src/imports/controls/imagine/images/splitview-handle.png new file mode 100644 index 00000000..c1dffa67 Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle@2x.png b/src/imports/controls/imagine/images/splitview-handle@2x.png new file mode 100644 index 00000000..180e266a Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle@2x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle@3x.png b/src/imports/controls/imagine/images/splitview-handle@3x.png new file mode 100644 index 00000000..35ea51db Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle@3x.png differ diff --git a/src/imports/controls/imagine/images/splitview-handle@4x.png b/src/imports/controls/imagine/images/splitview-handle@4x.png new file mode 100644 index 00000000..3a1e7e9f Binary files /dev/null and b/src/imports/controls/imagine/images/splitview-handle@4x.png differ diff --git a/src/imports/controls/imagine/imagine.pri b/src/imports/controls/imagine/imagine.pri index cb6857a5..081a509e 100644 --- a/src/imports/controls/imagine/imagine.pri +++ b/src/imports/controls/imagine/imagine.pri @@ -30,6 +30,7 @@ QML_FILES += \ $$PWD/ScrollIndicator.qml \ $$PWD/Slider.qml \ $$PWD/SpinBox.qml \ + $$PWD/SplitView.qml \ $$PWD/StackView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/SwipeView.qml \ diff --git a/src/imports/controls/material/SplitView.qml b/src/imports/controls/material/SplitView.qml new file mode 100644 index 00000000..6e5eb54d --- /dev/null +++ b/src/imports/controls/material/SplitView.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 2.12 +import QtQuick.Templates 2.5 as T +import QtQuick.Controls 2.5 +import QtQuick.Controls.impl 2.5 +import QtQuick.Controls.Material 2.5 + +T.SplitView { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + handle: Rectangle { + implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width + implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6 + color: T.SplitHandle.pressed ? control.Material.background + : Qt.lighter(control.Material.background, T.SplitHandle.hovered ? 1.2 : 1.1) + + Rectangle { + color: control.Material.secondaryTextColor + width: control.orientation === Qt.Horizontal ? thickness : length + height: control.orientation === Qt.Horizontal ? length : thickness + radius: thickness + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + + property int length: parent.T.SplitHandle.pressed ? 3 : 8 + readonly property int thickness: parent.T.SplitHandle.pressed ? 3 : 1 + + Behavior on length { + NumberAnimation { + duration: 100 + } + } + } + } +} diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri index ab925aa2..bda1fb21 100644 --- a/src/imports/controls/material/material.pri +++ b/src/imports/controls/material/material.pri @@ -53,6 +53,7 @@ QML_FILES += \ $$PWD/Slider.qml \ $$PWD/SliderHandle.qml \ $$PWD/SpinBox.qml \ + $$PWD/SplitView.qml \ $$PWD/StackView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/SwipeView.qml \ diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 754e76ab..0dd787b4 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -56,6 +56,7 @@ #include #endif #include +#include #include #include #include @@ -186,6 +187,11 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType(resolvedUrl(QStringLiteral("MenuBarItem.qml")), uri, 2, 3, "MenuBarItem"); qmlRegisterUncreatableType(uri, 2, 3, "Overlay", QStringLiteral("Overlay is only available as an attached property.")); + // QtQuick.Controls 2.5 (new types in Qt 5.12) + qmlRegisterType(resolvedUrl(QStringLiteral("SplitView.qml")), uri, 2, 5, "SplitView"); + qmlRegisterUncreatableType(uri, 2, 5, "SplitHandle", + QStringLiteral("SplitHandle is only available as an attached property.")); + const QByteArray import = QByteArray(uri) + ".impl"; qmlRegisterModule(import, 2, QT_VERSION_MINOR - 7); // Qt 5.7->2.0, 5.8->2.1, 5.9->2.2... diff --git a/src/imports/controls/universal/SplitView.qml b/src/imports/controls/universal/SplitView.qml new file mode 100644 index 00000000..bbcdba9d --- /dev/null +++ b/src/imports/controls/universal/SplitView.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 2.12 +import QtQuick.Templates 2.5 as T +import QtQuick.Controls 2.5 +import QtQuick.Controls.impl 2.5 +import QtQuick.Controls.Universal 2.5 + +T.SplitView { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + handle: Rectangle { + implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width + implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6 + color: T.SplitHandle.pressed ? control.Universal.baseMediumColor + : (T.SplitHandle.hovered ? control.Universal.baseMediumLowColor : control.Universal.chromeHighColor) + } +} diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri index 33d0dcb0..4440acbf 100644 --- a/src/imports/controls/universal/universal.pri +++ b/src/imports/controls/universal/universal.pri @@ -34,6 +34,7 @@ QML_FILES += \ $$PWD/ScrollIndicator.qml \ $$PWD/Slider.qml \ $$PWD/SpinBox.qml \ + $$PWD/SplitView.qml \ $$PWD/StackView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/SwitchDelegate.qml \ diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index ef7a646b..0d5765be 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -337,6 +338,11 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType(); qmlRegisterType(uri, 2, 5, "RangeSlider"); qmlRegisterType(uri, 2, 5, "Slider"); + qmlRegisterType(uri, 2, 5, "SplitView"); + qmlRegisterType(); + qmlRegisterUncreatableType(uri, 2, 5, "SplitHandle", + QStringLiteral("SplitHandle is only available as an attached property.")); + qmlRegisterType(); qmlRegisterType(uri, 2, 5, "SpinBox"); qmlRegisterType(uri, 2, 5, "TextArea"); qmlRegisterType(uri, 2, 5, "TextField"); -- cgit v1.2.3