2013-11-12 03:40:52 +01:00
|
|
|
/*
|
2020-08-13 21:08:54 +02:00
|
|
|
SPDX-FileCopyrightText: 2013 Heena Mahour <heena393@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
|
2021-04-23 19:35:27 +02:00
|
|
|
SPDX-FileCopyrightText: 2021 Jan Blackquill <uhhadd@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
|
2020-08-13 21:08:54 +02:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-11-12 03:40:52 +01:00
|
|
|
import QtQuick 2.0
|
|
|
|
import org.kde.plasma.calendar 2.0
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2021-04-23 19:35:27 +02:00
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents2 // For Highlight
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
2021-04-29 23:38:46 +02:00
|
|
|
import QtQml.Models 2.15
|
2021-05-19 19:38:14 +02:00
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
2013-11-12 03:40:52 +01:00
|
|
|
|
2015-07-27 11:41:35 +02:00
|
|
|
import org.kde.plasma.calendar 2.0
|
2013-11-12 03:40:52 +01:00
|
|
|
|
2021-04-23 19:35:27 +02:00
|
|
|
PlasmaComponents3.AbstractButton {
|
2013-11-13 05:28:42 +01:00
|
|
|
id: dayStyle
|
2013-11-12 03:40:52 +01:00
|
|
|
|
2015-08-04 12:44:37 +02:00
|
|
|
hoverEnabled: true
|
2021-04-29 23:38:46 +02:00
|
|
|
property var dayModel: null
|
2015-08-04 12:44:37 +02:00
|
|
|
|
2015-07-27 11:41:35 +02:00
|
|
|
signal activated
|
|
|
|
|
|
|
|
readonly property date thisDate: new Date(yearNumber, typeof monthNumber !== "undefined" ? monthNumber - 1 : 0, typeof dayNumber !== "undefined" ? dayNumber : 1)
|
|
|
|
readonly property bool today: {
|
2021-04-23 19:35:27 +02:00
|
|
|
const today = root.today;
|
|
|
|
let result = true;
|
2015-07-27 11:41:35 +02:00
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYear) {
|
|
|
|
result = result && today.getFullYear() === thisDate.getFullYear()
|
|
|
|
}
|
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYearAndMonth) {
|
|
|
|
result = result && today.getMonth() === thisDate.getMonth()
|
|
|
|
}
|
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYearMonthAndDay) {
|
|
|
|
result = result && today.getDate() === thisDate.getDate()
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
readonly property bool selected: {
|
2021-04-23 19:35:27 +02:00
|
|
|
const current = root.currentDate;
|
|
|
|
let result = true;
|
2015-07-27 11:41:35 +02:00
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYear) {
|
|
|
|
result = result && current.getFullYear() === thisDate.getFullYear()
|
|
|
|
}
|
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYearAndMonth) {
|
|
|
|
result = result && current.getMonth() === thisDate.getMonth()
|
|
|
|
}
|
|
|
|
if (dateMatchingPrecision >= Calendar.MatchYearMonthAndDay) {
|
|
|
|
result = result && current.getDate() === thisDate.getDate()
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2013-11-13 05:28:42 +01:00
|
|
|
|
2021-04-23 19:35:27 +02:00
|
|
|
PlasmaComponents2.Highlight {
|
2013-11-13 05:28:42 +01:00
|
|
|
id: todayRect
|
2014-07-12 13:52:14 +02:00
|
|
|
anchors.fill: parent
|
2014-02-21 01:22:24 +01:00
|
|
|
opacity: {
|
2021-04-23 19:35:27 +02:00
|
|
|
if (today) {
|
|
|
|
return 1;
|
|
|
|
} else if (selected) {
|
|
|
|
return 0.6;
|
|
|
|
} else if (dayStyle.hovered) {
|
|
|
|
return 0.3;
|
2014-05-12 19:19:24 +02:00
|
|
|
}
|
2021-04-23 19:35:27 +02:00
|
|
|
return 0;
|
2013-11-13 05:28:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-13 00:24:53 +02:00
|
|
|
Loader {
|
|
|
|
active: model.eventCount !== undefined && model.eventCount > 0
|
2016-04-21 05:41:13 +02:00
|
|
|
anchors.bottom: parent.bottom
|
2021-04-29 23:38:46 +02:00
|
|
|
anchors.bottomMargin: PlasmaCore.Units.smallSpacing
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-05-13 00:24:53 +02:00
|
|
|
sourceComponent: Row {
|
|
|
|
spacing: PlasmaCore.Units.smallSpacing
|
|
|
|
Repeater {
|
|
|
|
model: DelegateModel {
|
|
|
|
model: dayStyle.dayModel
|
|
|
|
rootIndex: modelIndex(index)
|
|
|
|
delegate: Rectangle {
|
|
|
|
width: PlasmaCore.Units.smallSpacing * 1.5
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
2021-05-19 19:38:14 +02:00
|
|
|
color: model.eventColor ? Kirigami.ColorUtils.linearInterpolation(model.eventColor, PlasmaCore.Theme.textColor, 0.2) : PlasmaCore.Theme.highlightColor
|
2021-05-13 00:24:53 +02:00
|
|
|
}
|
2021-04-29 23:38:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-21 05:41:13 +02:00
|
|
|
}
|
|
|
|
|
2021-04-23 19:35:27 +02:00
|
|
|
contentItem: PlasmaExtras.Heading {
|
2013-11-12 03:40:52 +01:00
|
|
|
id: label
|
2015-07-27 11:41:35 +02:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
text: model.label || dayNumber
|
|
|
|
opacity: isCurrent ? 1.0 : 0.5
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
elide: Text.ElideRight
|
2016-02-08 00:07:43 +01:00
|
|
|
fontSizeMode: Text.HorizontalFit
|
2013-11-12 03:40:52 +01:00
|
|
|
}
|
|
|
|
}
|