qtquick: Create ResizeHandlerHelper.qml to save some code
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<file>private/quick/qml/FloatingWindow.qml</file>
|
||||
<file>private/quick/qml/Frame.qml</file>
|
||||
<file>private/quick/qml/MainWindowMDI.qml</file>
|
||||
<file>private/quick/qml/ResizeHandlerHelper.qml</file>
|
||||
<file>private/quick/qml/RubberBand.qml</file>
|
||||
<file>private/quick/qml/TitleBarBase.qml</file>
|
||||
<file>private/quick/qml/TitleBar.qml</file>
|
||||
|
||||
@@ -49,139 +49,91 @@ Rectangle {
|
||||
frameCpp.geometryUpdated();
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
width: root.mouseResizeMargin
|
||||
cursorShape: enabled ? Qt.SizeHorCursor : Qt.ArrowCursor // Even if disabled the MouseArea changes cursor, as it's different than Item.enabled, so explicitly change cursor if disabled
|
||||
shape: Qt.SizeHorCursor
|
||||
z: mouseArea.z + 1
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
width: root.mouseResizeMargin
|
||||
cursorShape: enabled ? Qt.SizeHorCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeHorCursor
|
||||
z: mouseArea.z + 1
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
cursorShape: enabled ? Qt.SizeVerCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeVerCursor
|
||||
z: mouseArea.z + 1
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
cursorShape: enabled ? Qt.SizeVerCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeVerCursor
|
||||
z: mouseArea.z + 1
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
width: height
|
||||
|
||||
cursorShape: enabled ? Qt.SizeFDiagCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeFDiagCursor
|
||||
z: mouseArea.z + 2
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
width: height
|
||||
|
||||
cursorShape: enabled ? Qt.SizeFDiagCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeFDiagCursor
|
||||
z: mouseArea.z + 2
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
width: height
|
||||
|
||||
cursorShape: enabled ? Qt.SizeBDiagCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeBDiagCursor
|
||||
z: mouseArea.z + 2
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
ResizeHandlerHelper {
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
hoverEnabled: true
|
||||
height: root.mouseResizeMargin
|
||||
width: height
|
||||
|
||||
cursorShape: enabled ? Qt.SizeBDiagCursor : Qt.ArrowCursor
|
||||
shape: Qt.SizeBDiagCursor
|
||||
z: mouseArea.z + 2
|
||||
enabled: root.resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
objectName: "frameMouseArea"
|
||||
|
||||
30
src/private/quick/qml/ResizeHandlerHelper.qml
Normal file
30
src/private/quick/qml/ResizeHandlerHelper.qml
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.9
|
||||
import QtQuick.Layouts 1.9
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
property int resizeMargin: 2
|
||||
property int shape
|
||||
property bool resizeAllowed: true
|
||||
|
||||
hoverEnabled: true
|
||||
width: resizeMargin
|
||||
cursorShape: enabled ? shape : Qt.ArrowCursor // Even if disabled the MouseArea changes cursor, as it's different than Item.enabled, so explicitly change cursor if disabled
|
||||
z: mouseArea.z + 1
|
||||
enabled: resizeAllowed
|
||||
onPressed: { mouse.accepted = false; }
|
||||
onReleased: { mouse.accepted = false; }
|
||||
}
|
||||
Reference in New Issue
Block a user