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 import "activity.js" as Activity RowLayout { id: activityView width: (type == "announcement" ? announcementsListView : assignmentsListView).width Layout.fillWidth: true 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 } } 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 } MouseArea { width: parent.width height: parent.height 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" checked: important 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) } } else { // remove activityId from list importantActivities.splice(importantActivities.indexOf(activityId), 1) } // save config plasmoid.configuration[configKeys[type]] = importantActivities } } } }