|
| 1 | +// Copyright (C) 2018 The Qt Company Ltd. |
| 2 | +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | + |
| 4 | +// Adapted from qtdeclarative/qml/QtQuick/Controls/Material/SplitView.qml |
| 5 | +// SplitHandles should be purely visual but we need to detect when the mouse hovers the handle |
| 6 | + |
| 7 | +import QtQuick |
| 8 | +import QtQuick.Templates as T |
| 9 | +import QtQuick.Controls.impl |
| 10 | +import QtQuick.Controls.Material |
| 11 | + |
| 12 | +Rectangle { |
| 13 | + id: root |
| 14 | + |
| 15 | + required property var control |
| 16 | + |
| 17 | + implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width |
| 18 | + implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6 |
| 19 | + color: T.SplitHandle.pressed ? control.Material.background |
| 20 | + : Qt.lighter(control.Material.background, T.SplitHandle.hovered ? 1.2 : 1.1) |
| 21 | + |
| 22 | + Rectangle { |
| 23 | + color: control.Material.secondaryTextColor |
| 24 | + width: control.orientation === Qt.Horizontal ? thickness : length |
| 25 | + height: control.orientation === Qt.Horizontal ? length : thickness |
| 26 | + radius: thickness |
| 27 | + x: (parent.width - width) / 2 |
| 28 | + y: (parent.height - height) / 2 |
| 29 | + |
| 30 | + property int length: parent.T.SplitHandle.pressed ? 3 : 8 |
| 31 | + readonly property int thickness: parent.T.SplitHandle.pressed ? 3 : 1 |
| 32 | + |
| 33 | + Behavior on length { |
| 34 | + NumberAnimation { |
| 35 | + duration: 100 |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + // Begin: Listen to hover changes |
| 40 | + property var hoveredd: parent.T.SplitHandle.hovered |
| 41 | + |
| 42 | + onHovereddChanged: { |
| 43 | + root.hovered = hoveredd |
| 44 | + } |
| 45 | + // End: Listen to hover changes |
| 46 | + } |
| 47 | + |
| 48 | + // Begin: Listen to hover changes |
| 49 | + property var hovered: false |
| 50 | + // End: Listen to hover changes |
| 51 | +} |
0 commit comments