summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-05-10 15:55:56 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-05-10 15:55:56 +0800
commit67165d9325faf7c6eb8a978a0981fd602a02e892 (patch)
tree6b273a4b3faaf135b26a1545b4ebdd3d145d4d04
parenta5fa5c0c7c2ddda9dbb8e8215ddc4f4f1373cc0c (diff)
Remember finished activities
-rw-r--r--contents/config/main.xml2
-rw-r--r--contents/ui/ActivityView.qml20
-rw-r--r--contents/ui/main.qml4
3 files changed, 26 insertions, 0 deletions
diff --git a/contents/config/main.xml b/contents/config/main.xml
index 70a84c6..c071c3e 100644
--- a/contents/config/main.xml
+++ b/contents/config/main.xml
@@ -23,5 +23,7 @@
<group name="Data">
<entry name="importantAnnouncements" type="StringList"></entry>
<entry name="importantAssignments" type="StringList"></entry>
+ <entry name="finishedAnnouncements" type="StringList"></entry>
+ <entry name="finishedAssignments" type="StringList"></entry>
</group>
</kcfg>
diff --git a/contents/ui/ActivityView.qml b/contents/ui/ActivityView.qml
index 6c58b68..6c3bb87 100644
--- a/contents/ui/ActivityView.qml
+++ b/contents/ui/ActivityView.qml
@@ -94,8 +94,27 @@ RowLayout {
Layout.fillWidth: true
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]]
+ if (finished) {
+ if (!finishedActivities.includes(activityId)) {
+ finishedActivities.push(activityId)
+ }
+ } else {
+ // remove activityId from list
+ finishedActivities.splice(finishedActivities.indexOf(activityId), 1)
+ }
+ // save config
+ plasmoid.configuration[configKeys[type]] = finishedActivities
}
}
@@ -104,6 +123,7 @@ RowLayout {
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
diff --git a/contents/ui/main.qml b/contents/ui/main.qml
index 1fc6779..41af62a 100644
--- a/contents/ui/main.qml
+++ b/contents/ui/main.qml
@@ -66,6 +66,7 @@ Item {
title: announcement.title,
url: announcement.html_url,
important: plasmoid.configuration.importantAnnouncements.includes(announcement.id.toString()),
+ finished: plasmoid.configuration.finishedAnnouncements.includes(announcement.id.toString()),
}
if (info.important) {
@@ -87,6 +88,7 @@ Item {
submitted: assignment.has_submitted_submissions,
url: assignment.html_url,
important: plasmoid.configuration.importantAssignments.includes(assignment.id.toString()),
+ finished: plasmoid.configuration.finishedAssignments.includes(assignment.id.toString()),
}
if (!info.submitted || showSubmittedAssignments) {
@@ -133,6 +135,7 @@ Item {
title: "Code quality"
url: "https://xkcd.com/1513"
important: true
+ finished: false
activityId: 0
}
*/
@@ -170,6 +173,7 @@ Item {
submitted: true
url: "https://xkcd.com/730"
important: true
+ finished: true
activityId: 1
}
*/