blob: 8ee171886fee4064aeb554c1a1269552c25262e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
import org.kde.kirigami as Kirigami
import "activity.js" as Activity
// container for one single activity
PlasmaExtras.ListItem {
id: activityItem
separatorVisible: false
enabled: true // enable mouse event handling
property bool expanded: false
ColumnLayout {
width:
(type == "announcement"
? announcementsListView : assignmentsListView).width
- Kirigami.Units.gridUnit // HACK: clearance for scrollbar
Layout.fillWidth: true
RowLayout {
// "finished" checkbox and activity title
RowLayout {
PlasmaComponents3.CheckBox {
id: activityCheckbox
checkState: finished ? Qt.Checked : Qt.Unchecked
onToggled: () => {
finished = (checkState == Qt.Checked)
activityLabel.font.strikeout = (checkState == Qt.Checked)
const configKeys = {
announcement: "finishedAnnouncements",
assignment: "finishedAssignments",
}
let finishedActivities = plasmoid.configuration[configKeys[type]]
const activityIdStr = activityId.toString()
if (finished) {
if (!finishedActivities.includes(activityIdStr)) {
finishedActivities.push(activityIdStr)
}
} else {
// remove activityIdStr from list
finishedActivities.splice(
finishedActivities.indexOf(activityIdStr), 1
)
}
// save config
plasmoid.configuration[configKeys[type]] = finishedActivities
}
}
ColumnLayout {
PlasmaComponents3.Label {
id: activityLabel
text: `[${course}] ${title}`
font.bold: important
font.strikeout: finished
color: important
? PlasmaCore.Theme.negativeTextColor
: PlasmaCore.Theme.textColor
wrapMode: Text.WordWrap
Layout.fillWidth: true
}
PlasmaComponents3.Label {
id: dueLabel
visible: type == "assignment"
text: Activity.dueLabelText()
color: activityLabel.color
Layout.fillWidth: true
}
MouseArea {
width: parent.width
height: parent.height
cursorShape: Qt.PointingHandCursor
onClicked: () => {
if (type == "announcement") {
expanded = !expanded
} else {
Qt.openUrlExternally(url)
}
}
}
}
}
// buttons
RowLayout {
Layout.alignment: Qt.AlignRight
PlasmaComponents3.ToolButton {
icon.name: "emblem-important-symbolic"
checked: important
opacity: activityItem.containsMouse ? 1 : 0
onClicked: () => {
important = !important
activityLabel.font.bold = important
activityLabel.color = important
? Kirigami.Theme.negativeTextColor
: Kirigami.Theme.textColor
const configKeys = {
announcement: "importantAnnouncements",
assignment: "importantAssignments",
}
let importantActivities = plasmoid.configuration[configKeys[type]]
const activityIdStr = activityId.toString()
if (important) {
if (!importantActivities.includes(activityIdStr)) {
importantActivities.push(activityIdStr)
}
} else {
// remove activityIdStr from list
importantActivities.splice(
importantActivities.indexOf(activityIdStr), 1
)
}
// save config
plasmoid.configuration[configKeys[type]] = importantActivities
}
}
}
}
// announcement message
PlasmaComponents3.Label {
Layout.fillWidth: true
visible: expanded
text: message
horizontalAlignment: Text.AlignLeft
}
PlasmaComponents3.Button {
icon.name: "internet-web-browser"
visible: expanded
text: i18n("Open in browser")
onClicked: () => {
Qt.openUrlExternally(url)
}
}
}
}
|