Commit 829e042e authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Improve differentation between all-day and non all-day incidences in day grid view



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 9aacdf8e
Pipeline #220806 passed with stage
in 2 minutes and 40 seconds
......@@ -100,71 +100,79 @@ Item {
reactToCurrentMonth: parent.reactToCurrentMonth
isInCurrentMonth: parent.isInCurrentMonth
isDark: parent.isDark
allDay: modelData.allDay
}
RowLayout {
id: incidenceContents
clip: true
property bool spaceRestricted: parent.width < Kirigami.Units.gridUnit * 5
property color textColor: LabelUtils.getIncidenceLabelColor(modelData.color, root.isDark)
function otherMonthTextColor(color) {
if(isDark) {
if(LabelUtils.getDarkness(color) >= 0.5) {
return Qt.lighter(color, 2);
}
return Qt.lighter(color, 1.5);
}
return Qt.darker(color, 3);
}
readonly property bool spaceRestricted: parent.width < Kirigami.Units.gridUnit * 5
readonly property color textColor: incidenceDelegateBackground.opacity > 0 ?
LabelUtils.getIncidenceLabelColor(modelData.color, incidenceDelegate.isDark) : Kirigami.Theme.textColor
readonly property color otherMonthTextColor: {
if(incidenceDelegateBackground.visible && incidenceDelegateBackground.opacity > 0) {
if (incidenceDelegate.isDark) {
return LabelUtils.getDarkness(modelData.color) >= 0.5 ?
Qt.lighter(modelData.color, 2) : Qt.lighter(modelData.color, 1.5);
}
return Qt.darker(modelData.color, 3);
}
return Kirigami.Theme.textColor;
}
readonly property color selectedContentColor: LabelUtils.isDarkColor(modelData.color) ? "white" : "black"
readonly property color contentColor: incidenceDelegate.isOpenOccurrence ?
selectedContentColor : incidenceDelegate.isInCurrentMonth ?
textColor : otherMonthTextColor
readonly property int leadingIconSize: Kirigami.Units.gridUnit / 2
anchors {
fill: parent
leftMargin: spaceRestricted ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.smallSpacing
rightMargin: spaceRestricted ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.smallSpacing
}
Kirigami.Icon {
Layout.maximumHeight: parent.height
Layout.maximumWidth: height
Rectangle {
id: dotRectangle
width: incidenceContents.leadingIconSize
height: width
radius: width / 2
source: modelData.incidenceTypeIcon
isMask: true
color: isOpenOccurrence ? (LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
isInCurrentMonth ? incidenceContents.textColor :
incidenceContents.otherMonthTextColor(modelData.color)
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
visible: !parent.spaceRestricted && modelData.incidenceType === Kalendar.IncidenceWrapper.TypeTodo
}
// We want equal alignment for items that both have a dot, don't have a dot because they are all-day, and
// items that don't have a dot because they represent todos. Hidden items are compressed to a size of 0 so
// instead we set the color to transparent.
color: modelData.allDay ? "transparent" :
incidenceDelegate.isOpenOccurrence ? incidenceContents.selectedContentColor : modelData.color
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
}
QQC2.Label {
text: modelData.incidenceType === Kalendar.IncidenceWrapper.TypeTodo ?
modelData.endTime.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat) :
modelData.startTime.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)
Layout.fillWidth: true
text: modelData.text
elide: parent.spaceRestricted ? Text.ElideNone : Text.ElideRight // Eliding takes up space
font.weight: Font.Medium
font.pointSize: parent.spaceRestricted ? Kirigami.Theme.smallFont.pointSize :
Kirigami.Theme.defaultFont.pointSize
font.strikeout: modelData.todoCompleted
renderType: Text.QtRendering
color: isOpenOccurrence ? (LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
isInCurrentMonth ? incidenceContents.textColor :
incidenceContents.otherMonthTextColor(modelData.color)
color: incidenceContents.contentColor
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
visible: !modelData.allDay
}
QQC2.Label {
Layout.fillWidth: true
text: modelData.text
//elide: parent.spaceRestricted ? Text.ElideNone : Text.ElideRight // Eliding takes up space
font.weight: Font.Medium
QQC2.Label {
text: modelData.incidenceType === Kalendar.IncidenceWrapper.TypeTodo ?
modelData.endTime.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat) :
modelData.startTime.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)
font.pointSize: parent.spaceRestricted ? Kirigami.Theme.smallFont.pointSize :
Kirigami.Theme.defaultFont.pointSize
font.strikeout: modelData.todoCompleted
renderType: Text.QtRendering
color: isOpenOccurrence ? (LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
isInCurrentMonth ? incidenceContents.textColor :
incidenceContents.otherMonthTextColor(modelData.color)
color: incidenceContents.contentColor
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
visible: !modelData.allDay
}
}
......
......@@ -15,12 +15,13 @@ Kirigami.ShadowedRectangle {
property bool reactToCurrentMonth: false
property bool isInCurrentMonth: true
property bool isDark: KalendarUiUtils.darkMode
property bool allDay: false
anchors.fill: parent
color: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceDelegateBackgroundColor(modelData.color, root.isDark, modelData.endTime, Kalendar.Config.pastEventsTransparencyLevel)
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
opacity: isOpenOccurrence || isInCurrentMonth ? 1.0 : 0
opacity: isOpenOccurrence || (isInCurrentMonth && allDay) ? 1.0 : 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
radius: Kirigami.Units.smallSpacing
......
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