Commit 7a84ca1e authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Created ResizerSeparator component, resizer separators now indicate...

Created ResizerSeparator component, resizer separators now indicate interactivity, used in hourly views
parent 3782603a
Pipeline #167116 passed with stage
in 2 minutes and 42 seconds
......@@ -427,7 +427,7 @@ Kirigami.Page {
case 7:
default:
return weekViewMultiDayViewModel;
} // from root.model
} // from root.model
Layout.topMargin: Kirigami.Units.largeSpacing
//One row => one week
Item {
......@@ -562,47 +562,25 @@ Kirigami.Page {
}
}
}
MouseArea {
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.right: parent.right
height: 5
z: Infinity
cursorShape: !Kirigami.Settings.isMobile ? Qt.SplitVCursor : undefined
preventStealing: true
enabled: true
visible: true
onPressed: {
_lastY = mapToGlobal(mouseX, mouseY).y;
if(Kalendar.Config.weekViewAllDayHeaderHeight === -1) {
// Stops shrink on first drag
Kalendar.Config.weekViewAllDayHeaderHeight = allDayHeader.defaultHeight;
}
}
onReleased: {
Kalendar.Config.weekViewAllDayHeaderHeight = allDayHeader.actualHeight;
Kalendar.Config.save();
}
property real _lastY: -1
onPositionChanged: {
if (_lastY === -1) {
return;
} else {
allDayHeader.actualHeight = Math.min(allDayHeader.maxHeight, Math.max(allDayHeader.minHeight, Kalendar.Config.weekViewAllDayHeaderHeight - _lastY + mapToGlobal(mouseX, mouseY).y))
}
}
}
}
Kirigami.Separator {
ResizerSeparator {
id: headerBottomSeparator
width: pathView.width
height: root.gridLineWidth
z: -1
oversizeMouseAreaVertical: 5
z: Infinity
visible: allDayViewLoader.active
function setPos() {
Kalendar.Config.weekViewAllDayHeaderHeight = allDayHeader.actualHeight;
Kalendar.Config.save();
}
onDragBegin: setPos()
onDragReleased: setPos()
onDragPositionChanged: allDayHeader.actualHeight = Math.min(allDayHeader.maxHeight, Math.max(allDayHeader.minHeight, Kalendar.Config.weekViewAllDayHeaderHeight + changeY))
RectangularGlow {
anchors.fill: parent
z: -1
......
// SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
import QtQuick 2.15
import org.kde.kirigami 2.15 as Kirigami
// Useful for things such as resizing views
Kirigami.Separator {
id: root
signal dragBegin(real globalPosX, real globalPosY)
signal dragReleased(real totalChangeX, real totalChangeY)
signal dragPositionChanged(real changeX, real changeY)
property int oversizeMouseAreaVertical: 0
property int oversizeMouseAreaHorizontal: 0
property Item mouseArea: separatorMouseArea
MouseArea {
id: separatorMouseArea
anchors.centerIn: parent
width: root.width + root.oversizeMouseAreaHorizontal
height: root.height + root.oversizeMouseAreaVertical
cursorShape: !Kirigami.Settings.isMobile ? root.width < root.height ? Qt.SplitHCursor : Qt.SplitVCursor : undefined
preventStealing: true
hoverEnabled: true
property real initX: 0
property real initY: 0
property real lastX: 0
property real lastY: 0
onPressed: {
const globalPos = mapToGlobal(mouseX, mouseY);
initX = globalPos.x;
initY = globalPos.y;
lastX = globalPos.x;
lastY = globalPos.y;
root.dragBegin(initX, initY);
}
onReleased: {
const globalPos = mapToGlobal(mouseX, mouseY);
const totalChangedX = globalPos.x - initX;
const totalChangedY = globalPos.y - initY;
root.dragReleased(totalChangedX, totalChangedY);
}
onPositionChanged: if(pressed) {
const globalPos = mapToGlobal(mouseX, mouseY);
const changedX = globalPos.x - lastX;
const changedY = globalPos.y - lastY;
root.dragPositionChanged(changedX, changedY);
}
}
color: mouseArea.containsMouse || mouseArea.pressed ? Kirigami.Theme.highlightColor : defaultSeparator.color
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
Kirigami.Separator { // So we can pull the normal separator colour, as we always want to match
id: defaultSeparator
visible: false
}
}
......@@ -60,5 +60,6 @@ SPDX-License-Identifier: CC0-1.0
<file alias="CalendarItemMouseArea.qml">contents/ui/CalendarItemMouseArea.qml</file>
<file alias="CalendarItemMenu.qml">contents/ui/CalendarItemMenu.qml</file>
<file alias="RecurringIncidenceChangeSheet.qml">contents/ui/RecurringIncidenceChangeSheet.qml</file>
<file alias="ResizerSeparator.qml">contents/ui/ResizerSeparator.qml</file>
</qresource>
</RCC>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment