diff options
author | Frederick Yin <fkfd@fkfd.me> | 2023-07-26 13:45:45 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2023-07-26 13:45:45 +0800 |
commit | 8db750f3da3aa93301ee4658db20d6ab516d51a1 (patch) | |
tree | 5123d1100c763c3a03d583f3d68bc7638498e572 /contents/ui/ActivityView.qml | |
parent | 81159f9f9ccc11bcae107a203a11f6b7a27d60dc (diff) |
Use PlasmaComponents.ListView
Diffstat (limited to 'contents/ui/ActivityView.qml')
-rw-r--r-- | contents/ui/ActivityView.qml | 169 |
1 files changed, 86 insertions, 83 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 } } } |