Commit 1081227c authored by Slawek Kaplonski's avatar Slawek Kaplonski Committed by Claudio Cambra
Browse files

Make incidences which are in the past a bit more transparent

To mark events from the past as already finished, lets make them
to be a bit more transparent than events from now and from the future.
parent 678019b3
Pipeline #182594 passed with stage
in 4 minutes and 2 seconds
......@@ -5,6 +5,7 @@ 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 org.kde.kalendar 1.0 as Kalendar
import "labelutils.js" as LabelUtils
Kirigami.ShadowedRectangle {
......@@ -17,7 +18,7 @@ Kirigami.ShadowedRectangle {
anchors.fill: parent
color: isOpenOccurrence ? modelData.color :
LabelUtils.getIncidenceDelegateBackgroundColor(modelData.color, root.isDark)
LabelUtils.getIncidenceDelegateBackgroundColor(modelData, root.isDark, Kalendar.Config.pastEventsTransparencyLevel)
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
opacity: isOpenOccurrence || isInCurrentMonth ? 1.0 : 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutCubic } }
......
......@@ -168,10 +168,10 @@ function isDarkColor(background) {
return temp.a > 0 && getDarkness(background) >= 0.4;
}
function getIncidenceDelegateBackgroundColor(color, darkMode) {
let bgColor = getDarkness(color) > 0.9 ? Qt.lighter(color, 1.5) : color;
function getIncidenceDelegateBackgroundColor(modelData, darkMode, pastEventsDimmLevel=0.0) {
let bgColor = getDarkness(modelData.color) > 0.9 ? Qt.lighter(modelData.color, 1.5) : modelData.color;
if(darkMode) {
if(getDarkness(color) >= 0.5) {
if(getDarkness(modelData.color) >= 0.5) {
bgColor.a = 0.6;
} else {
bgColor.a = 0.4;
......@@ -179,6 +179,10 @@ function getIncidenceDelegateBackgroundColor(color, darkMode) {
} else {
bgColor.a = 0.7;
}
const now = new Date();
if (modelData.endTime < now) {
bgColor.a = Math.max(0.0, bgColor.a - pastEventsDimmLevel);
}
return bgColor;
}
......
......@@ -136,7 +136,7 @@ TreeListView {
objectName: "taskDelegate"
decoration.decorationHighlightColor: model.color
activeBackgroundColor: LabelUtils.getIncidenceDelegateBackgroundColor(model.color, root.isDark)
activeBackgroundColor: LabelUtils.getIncidenceDelegateBackgroundColor(model, root.isDark)
onActiveBackgroundColorChanged: activeBackgroundColor.a = 0.15
Kirigami.Theme.inherit: false
Kirigami.Theme.highlightColor: activeBackgroundColor
......
......@@ -24,6 +24,21 @@ Kirigami.ScrollablePage {
Config.save();
}
}
RowLayout {
Kirigami.FormData.label: i18n("Past event transparency:")
Layout.fillWidth: true
Controls.Slider {
stepSize: 1.0
from: 0.0
to: 100.0
value: Config.pastEventsTransparencyLevel * 100
onMoved: {
Config.pastEventsTransparencyLevel = value / 100;
Config.save();
}
}
}
Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Month View settings")
......
......@@ -164,6 +164,10 @@ SPDX-License-Identifier: LGPL-2.0-or-later
<label>Show all completed subtasks even if the parent task is incomplete</label>
<default>true</default>
</entry>
<entry name="pastEventsTransparencyLevel" type="Double" min="0.0" max="1.0">
<label>Dimmer</label>
<default>0</default>
</entry>
</group>
</kcfg>
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