summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2023-07-26 13:45:45 +0800
committerFrederick Yin <fkfd@fkfd.me>2023-07-26 13:45:45 +0800
commit8db750f3da3aa93301ee4658db20d6ab516d51a1 (patch)
tree5123d1100c763c3a03d583f3d68bc7638498e572
parent81159f9f9ccc11bcae107a203a11f6b7a27d60dc (diff)
Use PlasmaComponents.ListView
-rw-r--r--contents/ui/ActivityView.qml169
-rw-r--r--contents/ui/main.qml4
2 files changed, 88 insertions, 85 deletions
diff --git a/contents/ui/ActivityView.qml b/contents/ui/ActivityView.qml
index 82b3458..e8d840a 100644
--- a/contents/ui/ActivityView.qml
+++ b/contents/ui/ActivityView.qml
@@ -10,109 +10,112 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
import "activity.js" as Activity
-RowLayout {
- id: activityView
- width: (type == "announcement" ? announcementsListView : assignmentsListView).width
- Layout.fillWidth: true
-
+PlasmaComponents.ListItem {
+ separatorVisible: false
RowLayout {
+ id: activityView
+ width: (type == "announcement" ? announcementsListView : assignmentsListView).width
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)
+ 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)
}
- } else {
- // remove activityId from list
- finishedActivities.splice(finishedActivities.indexOf(activityId), 1)
+ // save config
+ plasmoid.configuration[configKeys[type]] = finishedActivities
}
- // 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
- }
+ 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
- }
+ PlasmaComponents3.Label {
+ id: dueLabel
+ visible: type == "assignment"
+ text: Activity.dueLabelText()
+ color: activityLabel.color
+ Layout.fillWidth: true
+ }
- MouseArea {
- width: parent.width
- height: parent.height
- onClicked: () => {
- activityCheckbox.toggle() // toggle checkbox
- activityCheckbox.toggled() // and trigger the onToggled effects
+ MouseArea {
+ width: parent.width
+ height: parent.height
+ onClicked: () => {
+ activityCheckbox.toggle() // toggle checkbox
+ activityCheckbox.toggled() // and trigger the onToggled effects
+ }
}
}
- }
- }
+ }
- RowLayout {
- Layout.alignment: Qt.AlignRight
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
- PlasmaComponents3.ToolButton {
- icon.name: "view-visible"
- onClicked: () => {
- Qt.openUrlExternally(url)
+ PlasmaComponents3.ToolButton {
+ icon.name: "view-visible"
+ onClicked: () => {
+ Qt.openUrlExternally(url)
+ }
}
- }
-
- PlasmaComponents3.ToolButton {
- icon.name: "emblem-important-symbolic"
- checked: important
- onClicked: () => {
- important = !important
- activityLabel.font.bold = important
- activityLabel.color = important
- ? PlasmaCore.Theme.negativeTextColor
- : PlasmaCore.Theme.textColor
+ PlasmaComponents3.ToolButton {
+ icon.name: "emblem-important-symbolic"
+ checked: important
- const configKeys = {
- announcement: "importantAnnouncements",
- assignment: "importantAssignments",
- }
+ onClicked: () => {
+ important = !important
+ activityLabel.font.bold = important
+ activityLabel.color = important
+ ? PlasmaCore.Theme.negativeTextColor
+ : PlasmaCore.Theme.textColor
+
+ const configKeys = {
+ announcement: "importantAnnouncements",
+ assignment: "importantAssignments",
+ }
- let importantActivities = plasmoid.configuration[configKeys[type]]
- if (important) {
- if (!importantActivities.includes(activityId)) {
- importantActivities.push(activityId)
+ let importantActivities = plasmoid.configuration[configKeys[type]]
+ if (important) {
+ if (!importantActivities.includes(activityId)) {
+ importantActivities.push(activityId)
+ }
+ } else {
+ // remove activityId from list
+ importantActivities.splice(importantActivities.indexOf(activityId), 1)
}
- } else {
- // remove activityId from list
- importantActivities.splice(importantActivities.indexOf(activityId), 1)
+ // save config
+ plasmoid.configuration[configKeys[type]] = importantActivities
}
- // save config
- plasmoid.configuration[configKeys[type]] = importantActivities
}
}
}
diff --git a/contents/ui/main.qml b/contents/ui/main.qml
index 6465a16..86c4022 100644
--- a/contents/ui/main.qml
+++ b/contents/ui/main.qml
@@ -76,7 +76,7 @@ Item {
ListView {
id: announcementsListView
Layout.fillWidth: true
- spacing: PlasmaCore.Units.smallSpacing
+ spacing: 0
delegate: ActivityView {}
model: announcementsModel
@@ -122,7 +122,7 @@ Item {
ListView {
id: assignmentsListView
Layout.fillWidth: true
- spacing: PlasmaCore.Units.gridUnit
+ spacing: 0
delegate: ActivityView {}
model: assignmentsModel