summaryrefslogtreecommitdiff
path: root/contents
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-04-07 12:26:24 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-04-07 12:26:24 +0800
commitb026a7f1b2920b3b9639f9b9fe30f8dc8473461d (patch)
tree4ad4f035f0402c8d98317b526cde0239d31e3480 /contents
parent38287d3fbfbd126a94d1e4f58c4c62836a2516ff (diff)
Save and load important announcements from config
Diffstat (limited to 'contents')
-rw-r--r--contents/config/main.xml4
-rw-r--r--contents/ui/AnnouncementView.qml18
-rw-r--r--contents/ui/main.qml8
3 files changed, 27 insertions, 3 deletions
diff --git a/contents/config/main.xml b/contents/config/main.xml
index 1f846eb..9ccc5e7 100644
--- a/contents/config/main.xml
+++ b/contents/config/main.xml
@@ -12,4 +12,8 @@
<default></default>
</entry>
</group>
+ <group name="Data">
+ <entry name="importantAnnouncements" type="StringList">
+ </entry>
+ </group>
</kcfg>
diff --git a/contents/ui/AnnouncementView.qml b/contents/ui/AnnouncementView.qml
index 95caf9e..53c78be 100644
--- a/contents/ui/AnnouncementView.qml
+++ b/contents/ui/AnnouncementView.qml
@@ -25,6 +25,8 @@ RowLayout {
PlasmaComponents3.Label {
id: announcementLabel
text: `[${course}] ${title}`
+ font.bold: important
+ color: important ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.textColor
elide: Text.ElideRight
Layout.fillWidth: true
@@ -51,8 +53,20 @@ RowLayout {
PlasmaComponents3.ToolButton {
icon.name: "emblem-important-symbolic"
onClicked: () => {
- announcementLabel.font.bold = true
- announcementLabel.color = PlasmaCore.Theme.negativeTextColor
+ important = !important
+ announcementLabel.font.bold = important
+ announcementLabel.color = important ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.textColor
+ let importantAnnouncements = plasmoid.configuration.importantAnnouncements
+ if (important) {
+ if (!importantAnnouncements.includes(announcementId)) {
+ importantAnnouncements.push(announcementId)
+ }
+ } else {
+ // remove announcementId from list
+ importantAnnouncements.splice(importantAnnouncements.indexOf(announcementId), 1)
+ }
+ // save config
+ plasmoid.configuration.importantAnnouncements = importantAnnouncements
}
}
diff --git a/contents/ui/main.qml b/contents/ui/main.qml
index 48d51b8..4872c3c 100644
--- a/contents/ui/main.qml
+++ b/contents/ui/main.qml
@@ -57,7 +57,11 @@ Item {
index: index,
course: course[1],
title: activity.title,
- url: activity.html_url
+ url: activity.html_url,
+ important: plasmoid.configuration.importantAnnouncements.includes(
+ activity.announcement_id.toString()
+ ),
+ announcementId: activity.announcement_id
})
}
})
@@ -92,6 +96,8 @@ Item {
course: "CS101"
title: "Title of the announcement"
url: "https://xkcd.com"
+ important: true
+ announcementId: 0
}
}