From 5a280f20286e34319414881d84d4f024d95fc3da Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Thu, 7 Apr 2022 15:31:55 +0800 Subject: Merge announcement/assignment views as ActivityView --- contents/ui/ActivityView.qml | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 contents/ui/ActivityView.qml (limited to 'contents/ui/ActivityView.qml') diff --git a/contents/ui/ActivityView.qml b/contents/ui/ActivityView.qml new file mode 100644 index 0000000..9c4cc30 --- /dev/null +++ b/contents/ui/ActivityView.qml @@ -0,0 +1,86 @@ +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.components 3.0 as PlasmaComponents3 +import org.kde.plasma.extras 2.0 as PlasmaExtras + +RowLayout { + id: activityView + width: parent.width + Layout.fillWidth: true + + RowLayout { + Layout.fillWidth: true + PlasmaComponents3.CheckBox { + id: activityCheckbox + onToggled: () => { + activityLabel.font.strikeout = (checkState == Qt.Checked) + } + } + + PlasmaComponents3.Label { + id: activityLabel + text: `[${course}] ${title}` + font.bold: important + color: important ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.textColor + elide: Text.ElideRight + Layout.fillWidth: true + + MouseArea { + anchors.fill: parent + onClicked: () => { + activityCheckbox.toggle() // toggle checkbox + activityCheckbox.toggled() // and trigger the onToggled effects + } + } + } + } + + RowLayout { + Layout.alignment: Qt.AlignRight + + PlasmaComponents3.ToolButton { + icon.name: "view-visible" + onClicked: () => { + Qt.openUrlExternally(url) + } + } + + PlasmaComponents3.ToolButton { + icon.name: "emblem-important-symbolic" + onClicked: () => { + important = !important + activityLabel.font.bold = important + activityLabel.color = important ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.textColor + let importantActivities = plasmoid.configuration.importantActivities + if (important) { + if (!importantActivities.includes(activityId)) { + importantActivities.push(activityId) + } + } else { + // remove activityId from list + importantActivities.splice(importantActivities.indexOf(activityId), 1) + } + // save config + plasmoid.configuration.importantActivities = importantActivities + } + } + + PlasmaComponents3.ToolButton { + icon.name: "delete" + onClicked: () => { + // avoid non-fatal TypeError due to activityView.parent=null but .width=parent.width + activityView.width = 0 + if (type == "announcement") { + announcementsModel.remove(index) + } else { + assignmentsModel.remove(index) + } + } + } + } +} -- cgit v1.2.3