~fkfd/kanvas

b78347b90c2b7760da419f93d98b9adfffa211dd — Frederick Yin 3 months ago fcfda88
Port to KF6
M .gitignore => .gitignore +1 -1
@@ 1,5 1,5 @@
# vim
.undodir/

.directory
res/
releases/

M README.md => README.md +3 -2
@@ 9,7 9,7 @@ I have not touched JavaScript in two years, so the code sucks.

Right now, it looks like this:

![Screenshot](img/screenshot_0.1.1.png)
![Screenshot](img/screenshot_0.3.0.png)

## Development



@@ 17,6 17,7 @@ First obviously you need the Plasma framework. If you have zero Plasma
development experience like me, here are some useful links:

- [Techbase: Plasma 5](https://techbase.kde.org/Development/Tutorials/Plasma5)
- [Plasma QML API](https://api.kde.org/frameworks/plasma-framework/html/index.html)
- [Developer: Plasma Widget Testing](https://develop.kde.org/docs/plasma/widget/testing/)

After you clone this repo, run `make install` to copy the plasmoid to


@@ 37,8 38,8 @@ add the widget to your desktop it has to be configured again.
- [ ] Sort assignments by urgency
- [ ] More friendly course list in config dialog
- [ ] Ignore activity and undo ignore
- [ ] Show announcement details
- [ ] Migrate to KF6 when it replaces KF5 (see [Porting guide](https://develop.kde.org/docs/plasma/widget/porting_kf6/))
- [ ] Improve accessibility [with help of this article](https://carlschwan.eu/2023/07/30/debugging-the-keyboard-navigation-in-your-qml-application/)

## Contributing


M contents/ui/ActivityView.qml => contents/ui/ActivityView.qml +12 -13
@@ 2,17 2,16 @@ 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 org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
import org.kde.kirigami as Kirigami

import "activity.js" as Activity

// container for one single activity
// TODO: port to PlasmaComponents3 before release of KF6
PlasmaComponents.ListItem {
PlasmaExtras.ListItem {
    id: activityItem
    separatorVisible: false
    enabled: true // enable mouse event handling


@@ 22,7 21,7 @@ PlasmaComponents.ListItem {
        width:
            (type == "announcement"
            ? announcementsListView : assignmentsListView).width
            - PlasmaCore.Units.gridUnit // HACK: clearance for scrollbar
            - Kirigami.Units.gridUnit // HACK: clearance for scrollbar
        Layout.fillWidth: true
        RowLayout {
            // "finished" checkbox and activity title


@@ 104,8 103,8 @@ PlasmaComponents.ListItem {
                        important = !important
                        activityLabel.font.bold = important
                        activityLabel.color = important
                            ? PlasmaCore.Theme.negativeTextColor
                            : PlasmaCore.Theme.textColor
                            ? Kirigami.Theme.negativeTextColor
                            : Kirigami.Theme.textColor

                        const configKeys = {
                            announcement: "importantAnnouncements",


@@ 114,7 113,7 @@ PlasmaComponents.ListItem {

                        let importantActivities = plasmoid.configuration[configKeys[type]]
                        const activityIdStr = activityId.toString()
                        

                        if (important) {
                            if (!importantActivities.includes(activityIdStr)) {
                                importantActivities.push(activityIdStr)


@@ 133,11 132,11 @@ PlasmaComponents.ListItem {
        }

        // announcement message
        PlasmaExtras.Paragraph {
        PlasmaComponents3.Label {
            Layout.fillWidth: true
            visible: expanded
            text: message
            horizontalAlignment: PlasmaExtras.Paragraph.AlignLeft
            horizontalAlignment: Text.AlignLeft
        }

        PlasmaComponents3.Button {

M contents/ui/configCanvas.qml => contents/ui/configCanvas.qml +1 -1
@@ 1,7 1,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kirigami as Kirigami

Kirigami.FormLayout {
    property alias cfg_canvasUrl: canvasUrl.text

M contents/ui/configGeneral.qml => contents/ui/configGeneral.qml +1 -1
@@ 1,7 1,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kirigami as Kirigami

Kirigami.FormLayout {
    property alias cfg_showSubmittedAssignments: showSubmittedAssignments.checked

M contents/ui/main.qml => contents/ui/main.qml +22 -23
@@ 2,19 2,18 @@ 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 org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
import org.kde.plasma.networkmanagement as PlasmaNM
import org.kde.kirigami as Kirigami

import "kanvas.js" as Kanvas

// TODO: change to PlasmoidItem on KF6
Item {
    width: PlasmaCore.Units.gridUnit * 20
    height: PlasmaCore.Units.gridUnit * 40
PlasmoidItem {
    width: Kirigami.Units.gridUnit * 20
    height: Kirigami.Units.gridUnit * 40
    clip: true

    readonly property string canvasUrl: plasmoid.configuration.canvasUrl


@@ 69,8 68,8 @@ Item {
        }

        ScrollView {
            implicitHeight: PlasmaCore.Units.gridUnit * 20
            Layout.margins: PlasmaCore.Units.smallSpacing
            implicitHeight: Kirigami.Units.gridUnit * 20
            Layout.margins: Kirigami.Units.smallSpacing
            Layout.fillWidth: true
            Layout.fillHeight: true
            ScrollBar.horizontal.policy: ScrollBar.AlwaysOff


@@ 84,7 83,7 @@ Item {

                PlasmaExtras.PlaceholderMessage {
                    anchors.centerIn: parent
                    width: parent.width - (PlasmaCore.Units.largeSpacing * 4)
                    width: parent.width - (Kirigami.Units.gridUnit * 4)
                    visible: announcementsModel.count == 0
                    iconName: "mail-read-symbolic"
                    text: i18n("No announcements")


@@ 115,8 114,8 @@ Item {
        }

        ScrollView {
            implicitHeight: PlasmaCore.Units.gridUnit * 20
            Layout.margins: PlasmaCore.Units.smallSpacing
            implicitHeight: Kirigami.Units.gridUnit * 20
            Layout.margins: Kirigami.Units.smallSpacing
            Layout.fillWidth: true
            Layout.fillHeight: true
            ScrollBar.horizontal.policy: ScrollBar.AlwaysOff


@@ 124,13 123,13 @@ Item {
            ListView {
                id: assignmentsListView
                Layout.fillWidth: true
                spacing: PlasmaCore.Units.smallSpacing
                spacing: Kirigami.Units.smallSpacing
                delegate: ActivityView {}
                model: assignmentsModel

                PlasmaExtras.PlaceholderMessage {
                    anchors.centerIn: parent
                    width: parent.width - (PlasmaCore.Units.largeSpacing * 4)
                    width: parent.width - (Kirigami.Units.gridUnit * 4)
                    visible: assignmentsModel.count == 0
                    iconName: "mail-read-symbolic"
                    text: i18n("No assignments")


@@ 145,12 144,12 @@ Item {
                onClicked: Kanvas.syncCanvas()
            }

            PlasmaComponents3.Label {
                id: offlineLabel 
                visible: networkStatus.networkStatus != "Connected"
                text: i18n("Network disconnected")
                color: PlasmaCore.Theme.negativeTextColor
            }
            // PlasmaComponents3.Label {
                // id: offlineLabel
                // visible: networkStatus.networkStatus != "Connected"
                // text: i18n("Network disconnected")
                // color: PlasmaCore.Theme.negativeTextColor
            // }
        }
    }
}

A img/screenshot_0.3.0.png => img/screenshot_0.3.0.png +0 -0
M metadata.json => metadata.json +2 -4
@@ 17,12 17,10 @@
        "Name[zh_CN]": "Kanvas",
        "Name[zh_TW]": "Kanvas",
        "Icon": "institution",
        "ServiceTypes": [
            "Plasma/Applet"
        ],
        "Version": "0.2.0",
        "Version": "0.3.0",
        "Website": "https://fkfd.me/projects/kanvas/"
    },
    "KPackageStructure": "Plasma/Applet",
    "X-Plasma-API": "declarativeappletscript",
    "X-Plasma-MainScript": "ui/main.qml"
}