Commit b4744ad9 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Separated incidence background onto own component and added glow in dark mode

parent 4b726233
// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.14 as Kirigami
import "labelutils.js" as LabelUtils
Kirigami.ShadowedRectangle {
id: incidenceBackground
property bool isOpenOccurrence: false
property bool reactToCurrentMonth: false
property bool isInCurrentMonth: true
property bool isDark: false
anchors.fill: parent
color: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceBackgroundColor(modelData.color, root.isDark)
visible: isOpenOccurrence || isInCurrentMonth
radius: Kirigami.Units.smallSpacing
shadow.size: isDark && isOpenOccurrence ? Kirigami.Units.largeSpacing * 1.5 : Kirigami.Units.largeSpacing
shadow.color: !isDark ? Qt.rgba(0.0, 0.0, 0.0, 0.2) :
isOpenOccurrence ? modelData.color : LabelUtils.getIncidenceBackgroundColor(modelData.color, true)
shadow.yOffset: !isDark ? 2 : 0
border.width: 1
border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.2)
}
......@@ -232,7 +232,7 @@ Item {
anchors {
fill: parent
// Offset for date
topMargin: root.showDayIndicator ? Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing : 0
topMargin: root.showDayIndicator ? Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing * 1.5 : 0
}
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
......
......@@ -32,20 +32,12 @@ Rectangle {
true
property bool isDark: false
Kirigami.ShadowedRectangle {
IncidenceBackground {
id: incidenceBackground
anchors.fill: parent
color: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceBackgroundColor(modelData.color, root.isDark)
visible: isOpenOccurrence || isInCurrentMonth
radius: parent.radius
shadow.size: Kirigami.Units.largeSpacing
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.2)
shadow.yOffset: 2
border.width: 1
border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.2)
isOpenOccurrence: parent.isOpenOccurrence
reactToCurrentMonth: parent.reactToCurrentMonth
isInCurrentMonth: parent.isInCurrentMonth
isDark: parent.isDark
}
RowLayout {
......
......@@ -346,27 +346,25 @@ Kirigami.Page {
Kirigami.AbstractCard {
id: incidenceCard
Layout.fillWidth: true
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.backgroundColor: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceBackgroundColor(modelData.color, root.isDark)
Kirigami.Theme.highlightColor: Qt.darker(Kirigami.Theme.backgroundColor, 3)
property real paddingSize: Kirigami.Settings.isMobile ? Kirigami.Units.largeSpacing : Kirigami.Units.smallSpacing
topPadding: paddingSize
bottomPadding: paddingSize
showClickFeedback: true
property real paddingSize: Kirigami.Settings.isMobile ?
Kirigami.Units.largeSpacing : Kirigami.Units.smallSpacing
property bool isOpenOccurrence: root.openOccurrence ?
root.openOccurrence.incidenceId === modelData.incidenceId : false
property bool multiday: modelData.startTime.getDate() !== modelData.endTime.getDate()
property int incidenceDays: DateUtils.fullDaysBetweenDates(modelData.startTime, modelData.endTime)
property int dayOfMultidayIncidence: DateUtils.fullDaysBetweenDates(modelData.startTime, periodStartDate)
Layout.fillWidth: true
topPadding: paddingSize
bottomPadding: paddingSize
showClickFeedback: true
background: IncidenceBackground {
id: incidenceBackground
isOpenOccurrence: parent.isOpenOccurrence
isDark: root.isDark
}
contentItem: GridLayout {
id: cardContents
......@@ -380,7 +378,9 @@ Kirigami.Page {
Layout.fillHeight: true
source: modelData.incidenceTypeIcon
isMask: true
color: cardContents.textColor
color: incidenceCard.isOpenOccurrence ?
(LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
cardContents.textColor
}
QQC2.Label {
......@@ -390,8 +390,9 @@ Kirigami.Page {
Layout.row: 0
Layout.columnSpan: root.isLarge ? 2 : 1
color: incidenceCard.isOpenOccurrence ? (LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
cardContents.textColor
color: incidenceCard.isOpenOccurrence ?
(LabelUtils.isDarkColor(modelData.color) ? "white" : "black") :
cardContents.textColor
text: {
if(incidenceCard.multiday) {
return i18n("%1 (Day %2 of %3)", modelData.text, incidenceCard.dayOfMultidayIncidence, incidenceCard.incidenceDays);
......
......@@ -555,19 +555,10 @@ Kirigami.Page {
color: Qt.rgba(0,0,0,0)
visible: !modelData.allDay
Kirigami.ShadowedRectangle {
IncidenceBackground {
id: incidenceBackground
anchors.fill: parent
color: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceBackgroundColor(modelData.color, root.isDark)
radius: parent.radius
shadow.size: Kirigami.Units.largeSpacing
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.2)
shadow.yOffset: 2
border.width: 1
border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.2)
isOpenOccurrence: parent.isOpenOccurrence
isDark: root.isDark
}
ColumnLayout {
......
......@@ -3,6 +3,7 @@
<file alias="main.qml">contents/ui/main.qml</file>
<file alias="Sidebar.qml">contents/ui/Sidebar.qml</file>
<file alias="BottomToolBar.qml">contents/ui/BottomToolBar.qml</file>
<file alias="IncidenceBackground.qml">contents/ui/IncidenceBackground.qml</file>
<file alias="MultiDayViewIncidenceDelegate.qml">contents/ui/MultiDayViewIncidenceDelegate.qml</file>
<file alias="MultiDayView.qml">contents/ui/MultiDayView.qml</file>
<file alias="MonthView.qml">contents/ui/MonthView.qml</file>
......
Markdown is supported
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