Commit 77505be9 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Make week view all day header auto-adjust height to incidences and enable...

Make week view all day header auto-adjust height to incidences and enable manual change of this view's height
parent 88c9bfd7
Pipeline #90947 passed with stage
in 5 minutes and 5 seconds
......@@ -11,6 +11,7 @@ MouseArea {
id: dayMouseArea
signal addNewIncidence(int type, date addDate)
signal deselect
property string defaultType: Kalendar.IncidenceWrapper.TypeEvent
property date addDate
......@@ -20,6 +21,8 @@ MouseArea {
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: deselect()
onDoubleClicked: {
if (pressedButtons & Qt.LeftButton) {
clickX = mouseX;
......
......@@ -20,6 +20,7 @@ Kirigami.Page {
signal deleteIncidence(var incidencePtr, date deleteDate)
signal completeTodo(var incidencePtr)
signal addSubTodo(var parentWrapper)
signal deselect()
property var openOccurrence
property date startDate
......@@ -214,6 +215,7 @@ Kirigami.Page {
onDeleteIncidence: monthPage.deleteIncidence(incidencePtr, deleteDate)
onCompleteTodo: monthPage.completeTodo(incidencePtr)
onAddSubTodo: monthPage.addSubTodo(parentWrapper)
onDeselect: monthPage.deselect()
}
}
}
......
......@@ -21,6 +21,7 @@ Item {
signal deleteIncidence(var incidencePtr, date deleteDate)
signal completeTodo(var incidencePtr)
signal addSubTodo(var parentWrapper)
signal deselect()
property var openOccurrence
......@@ -163,6 +164,7 @@ Item {
anchors.fill: parent
addDate: gridItem.date
onAddNewIncidence: addIncidence(type, addDate)
onDeselect: root.deselect()
}
}
......@@ -264,6 +266,7 @@ Item {
}
onAddNewIncidence: useGridSquareDate(type, applicationWindow().contentItem, this.mapToGlobal(clickX, clickY))
onDeselect: root.deselect()
}
model: incidences
......
......@@ -19,6 +19,7 @@ Kirigami.Page {
signal deleteIncidence(var incidencePtr, date deleteDate)
signal completeTodo(var incidencePtr)
signal addSubTodo(var parentWrapper)
signal deselect()
property var openOccurrence
property var filter: {
......@@ -220,6 +221,7 @@ Kirigami.Page {
addDate: periodStartDate
onAddNewIncidence: addIncidence(type, addDate)
onDeselect: root.deselect()
Rectangle {
anchors.top: parent.top
......
......@@ -23,6 +23,7 @@ Kirigami.ScrollablePage {
signal deleteTodo(var todoPtr, date deleteDate)
signal completeTodo(var todoPtr)
signal addSubTodo(var parentWrapper)
signal deselect
// We need to store a copy of opened incidence data or we will lose it as we scroll the listviews.
function retainTodoData(todoData, collectionData) {
......@@ -152,6 +153,7 @@ Kirigami.ScrollablePage {
root.deleteTodo(todoPtr, deleteDate);
completedSheet.closeDialog();
}
onDeselect: root.deselect()
onCompleteTodo: root.completeTodo(todoPtr);
onAddSubTodo: root.addSubTodo(parentWrapper)
}
......@@ -253,6 +255,7 @@ Kirigami.ScrollablePage {
onDeleteTodo: root.deleteTodo(todoPtr, deleteDate)
onCompleteTodo: root.completeTodo(todoPtr);
onAddSubTodo: root.addSubTodo(parentWrapper)
onDeselect: root.deselect()
}
......
......@@ -21,6 +21,7 @@ TreeListView {
signal deleteTodo(var todoPtr, date deleteDate)
signal completeTodo(var todoPtr)
signal addSubTodo(var parentWrapper)
signal deselect()
property date currentDate: new Date()
property var filter
......@@ -35,6 +36,15 @@ TreeListView {
currentIndex: -1
clip: true
MouseArea {
id: incidenceDeselectorMouseArea
anchors.fill: parent
enabled: !Kirigami.Settings.isMobile
parent: background
onClicked: deselect()
propagateComposedEvents: true
}
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
visible: root.filter && root.filter.collectionId >= 0 && root.filterCollectionDetails.isFiltered && parent.count === 0
......
......@@ -20,6 +20,7 @@ Kirigami.Page {
signal deleteIncidence(var incidencePtr, date deleteDate)
signal completeTodo(var incidencePtr)
signal addSubTodo(var parentWrapper)
signal deselect()
property var openOccurrence: {}
property var filter: {
......@@ -171,6 +172,7 @@ Kirigami.Page {
property int index: model.index
property bool isCurrentItem: PathView.isCurrentItem
property bool isNextOrCurrentItem: index >= pathView.currentIndex -1 && index <= pathView.currentIndex + 1
property int multiDayLinesShown: 0
Loader {
id: modelLoader
......@@ -192,13 +194,15 @@ Kirigami.Page {
active: isNextOrCurrentItem
//asynchronous: true
sourceComponent: ColumnLayout {
sourceComponent: Column {
id: viewColumn
width: pathView.width
height: pathView.height
spacing: 0
Row {
Layout.fillWidth: true
id: headingRow
width: pathView.width
spacing: root.gridLineWidth
Kirigami.Heading {
......@@ -258,7 +262,7 @@ Kirigami.Page {
Kirigami.Separator {
id: headerTopSeparator
Layout.fillWidth: true
width: pathView.width
height: root.gridLineWidth
z: -1
......@@ -291,10 +295,21 @@ Kirigami.Page {
Item {
id: allDayHeader
Layout.fillWidth: true
height: allDayViewLoader.implicitHeight
width: pathView.width
height: actualHeight
visible: allDayViewLoader.active
clip: true
readonly property int minHeight: Kirigami.Units.gridUnit *2
readonly property int maxHeight: pathView.height / 3
readonly property int lineHeight: viewLoader.multiDayLinesShown * (Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing + root.incidenceSpacing) + Kirigami.Units.smallSpacing
readonly property int defaultHeight: Math.min(lineHeight, maxHeight)
property int actualHeight: {
if (Kalendar.Config.weekViewAllDayHeaderHeight === -1) {
return defaultHeight;
} else {
return Kalendar.Config.weekViewAllDayHeaderHeight;
}
}
Rectangle {
id: headerBackground
......@@ -302,14 +317,45 @@ Kirigami.Page {
color: Kirigami.Theme.backgroundColor
}
Kirigami.ShadowedRectangle {
anchors.left: parent.left
anchors.top: parent.bottom
width: root.hourLabelWidth
height: resetHeaderHeightButton.height
z: -1
corners.bottomRightRadius: Kirigami.Units.smallSpacing
shadow.size: Kirigami.Units.largeSpacing
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.2)
shadow.yOffset: 2
shadow.xOffset: 2
color: Kirigami.Theme.backgroundColor
border.width: root.gridLineWidth
border.color: headerBottomSeparator.color
visible: allDayHeader.actualHeight !== allDayHeader.defaultHeight
QQC2.ToolButton {
id: resetHeaderHeightButton
width: root.hourLabelWidth
text: i18nc("@action:button", "Reset")
onClicked: {
Kalendar.Config.weekViewAllDayHeaderHeight = -1;
Kalendar.Config.save();
allDayHeader.actualHeight = allDayHeader.defaultHeight;
}
}
}
QQC2.Label {
width: root.hourLabelWidth
height: parent.height
padding: Kirigami.Units.smallSpacing
leftPadding: Kirigami.Units.largeSpacing
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignRight
text: i18n("Multi / All day")
wrapMode: Text.Wrap
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
color: Kirigami.Theme.disabledTextColor
}
......@@ -319,7 +365,8 @@ Kirigami.Page {
anchors.leftMargin: root.hourLabelWidth
active: allDayIncidenceModelLoader.item.incidenceCount > 0
sourceComponent: Item {
implicitHeight: Kirigami.Units.gridUnit * 3
id: allDayViewItem
implicitHeight: allDayHeader.actualHeight
clip: true
Repeater {
......@@ -327,8 +374,9 @@ Kirigami.Page {
Layout.topMargin: Kirigami.Units.largeSpacing
//One row => one week
Item {
id: weekItem
width: parent.width
height: Kirigami.Units.gridUnit * 3
implicitHeight: allDayHeader.actualHeight
clip: true
RowLayout {
width: parent.width
......@@ -388,11 +436,15 @@ Kirigami.Page {
addDate: parent.date
onAddNewIncidence: root.addIncidence(type, addDate, false)
onDeselect: root.deselect()
}
}
}
model: incidences
onCountChanged: {
viewLoader.multiDayLinesShown = count
}
delegate: Item {
id: line
......@@ -420,11 +472,43 @@ 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 {
id: headerBottomSeparator
Layout.fillWidth: true
width: pathView.width
height: root.gridLineWidth
z: -1
visible: allDayViewLoader.active
......@@ -438,11 +522,10 @@ Kirigami.Page {
}
}
QQC2.ScrollView {
id: hourlyView
Layout.fillWidth: true
Layout.fillHeight: true
width: pathView.width
height: pathView.height - headerBottomSeparator.height - allDayHeader.height - headerTopSeparator.height - headingRow.height
contentWidth: availableWidth
z: -2
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
......@@ -544,6 +627,7 @@ Kirigami.Page {
anchors.fill: parent
addDate: new Date(DateUtils.addDaysToDate(viewLoader.startDate, dayColumn.index).setHours(index))
onAddNewIncidence: addIncidence(type, addDate, true)
onDeselect: root.deselect()
}
}
}
......
......@@ -387,7 +387,7 @@ Kirigami.ApplicationWindow {
readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
property int actualWidth: {
if (Config.incidenceInfoDrawerWidth === -1) {
return Kirigami.Units.gridUnit * 20;
return defaultWidth;
} else {
return Config.incidenceInfoDrawerWidth;
}
......@@ -663,18 +663,6 @@ Kirigami.ApplicationWindow {
}
}
MouseArea {
id: incidenceDeselectorMouseArea
anchors.fill: parent
enabled: !Kirigami.Settings.isMobile
parent: todoViewAction.checked ? pageStack.currentItem.background : pageStack.currentItem
onClicked: {
incidenceInfo.close()
mouse.accepted = false
}
propagateComposedEvents: true
}
Component {
id: monthViewComponent
......@@ -695,6 +683,7 @@ Kirigami.ApplicationWindow {
onDeleteIncidence: root.setUpDelete(incidencePtr, deleteDate)
onCompleteTodo: root.completeTodo(incidencePtr)
onAddSubTodo: root.setUpAddSubTodo(parentWrapper)
onDeselect: incidenceInfo.close()
onMonthChanged: if(month !== root.selectedDate.getMonth() && !initialMonth) root.selectedDate = new Date (year, month, 1)
onYearChanged: if(year !== root.selectedDate.getFullYear() && !initialMonth) root.selectedDate = new Date (year, month, 1)
......@@ -731,6 +720,7 @@ Kirigami.ApplicationWindow {
onDeleteIncidence: root.setUpDelete(incidencePtr, deleteDate)
onCompleteTodo: root.completeTodo(incidencePtr)
onAddSubTodo: root.setUpAddSubTodo(parentWrapper)
onDeselect: incidenceInfo.close()
actions.contextualActions: createAction
}
......@@ -765,6 +755,7 @@ Kirigami.ApplicationWindow {
onDeleteIncidence: root.setUpDelete(incidencePtr, deleteDate)
onCompleteTodo: root.completeTodo(incidencePtr)
onAddSubTodo: root.setUpAddSubTodo(parentWrapper)
onDeselect: incidenceInfo.close()
actions.contextualActions: createAction
}
......@@ -802,6 +793,7 @@ Kirigami.ApplicationWindow {
onDeleteTodo: root.setUpDelete(todoPtr, deleteDate)
onCompleteTodo: root.completeTodo(todoPtr)
onAddSubTodo: root.setUpAddSubTodo(parentWrapper)
onDeselect: incidenceInfo.close()
}
}
......
......@@ -106,6 +106,13 @@ SPDX-License-Identifier: LGPL-2.0-or-later
</entry>
</group>
<group name="WeekView">
<entry name="weekViewAllDayHeaderHeight" type="Int">
<label>Set the height of the all-day header at the top of the week view."</label>
<default>-1</default>
</entry>
</group>
<group name="ScheduleView">
<entry name="showMonthHeader" type="Bool">
<label>Show month header in schedule view.</label>
......
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