Zren / plasma-applet-todolist

https://store.kde.org/p/1152230/
58 stars 23 forks source link

plasma 6 support #82

Open rhjdvsgsgks opened 1 year ago

rhjdvsgsgks commented 1 year ago
com.github.zren.todolist/contents/ui/main.qml:46:3: PlasmaCore.IconItem is not a type

please use Kirigami.Icon instead https://invent.kde.org/plasma/plasma-workspace/-/issues/82

rhjdvsgsgks commented 1 year ago

my ugly fix (not suggest to be applied

diff --git a/package/contents/ui/FullRepresentation.qml b/package/contents/ui/FullRepresentation.qml
index 1cdbdb7..91cf22d 100644
--- a/package/contents/ui/FullRepresentation.qml
+++ b/package/contents/ui/FullRepresentation.qml
@@ -1,5 +1,5 @@
 import QtQuick 2.0
-import QtQuick.Controls 1.1
+import QtQuick.Controls 2.15
 import QtQuick.Layouts 1.1
 import QtQuick.Window 2.2

diff --git a/package/contents/ui/NoteSection.qml b/package/contents/ui/NoteSection.qml
index f5fbc86..56586b7 100644
--- a/package/contents/ui/NoteSection.qml
+++ b/package/contents/ui/NoteSection.qml
@@ -1,14 +1,12 @@
 import QtQuick 2.0
 import QtQuick.Controls 2.5
-import QtQuick.Dialogs 1.2 // MessageDialog
+import QtQuick.Dialogs 6.3 // MessageDialog
 import QtQuick.Layouts 1.1

-import org.kde.plasma.core 2.0 as PlasmaCore
 import org.kde.plasma.components 3.0 as PlasmaComponents3
-import org.kde.plasma.extras 2.0 as PlasmaExtras
-import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles

 import org.kde.draganddrop 2.0 as DragAndDrop
+import org.kde.ksvg 1.0 as KSvg

 ColumnLayout {
    id: container
@@ -62,7 +60,7 @@ ColumnLayout {

                delegate: labelRow

-               PlasmaCore.FrameSvgItem {
+               KSvg.FrameSvgItem {
                    visible: labelMouseArea.containsMouse && !noteSectionDropArea.containsDrag
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.top: parent.top
@@ -141,11 +139,9 @@ ColumnLayout {
                    MessageDialog {
                        // visible: true
                        title: i18n("Delete List")
-                       icon: StandardIcon.Warning
                        text: i18n("Are you sure you want to delete the list \"%1\" with %2 items?", noteSection.label || ' ', Math.max(0, noteSection.model.count - 1))
-                       standardButtons: StandardButton.Yes | StandardButton.Cancel

-                       onYes: noteItem.removeSection(index)
+                       onAccepted: noteItem.removeSection(index)
                        Component.onCompleted: visible = true
                    }
                }
@@ -154,7 +150,7 @@ ColumnLayout {
        }
    }

-   PlasmaExtras.ScrollArea {
+   ScrollView {
        Layout.fillWidth: true
        Layout.fillHeight: true

diff --git a/package/contents/ui/TodoItemDelegate.qml b/package/contents/ui/TodoItemDelegate.qml
index 5d5d857..c1162a5 100644
--- a/package/contents/ui/TodoItemDelegate.qml
+++ b/package/contents/ui/TodoItemDelegate.qml
@@ -4,6 +4,9 @@ import QtQuick.Layouts 1.1
 import org.kde.plasma.core 2.0 as PlasmaCore
 import org.kde.plasma.components 3.0 as PlasmaComponents3
 import org.kde.draganddrop 2.0 as DragAndDrop
+import org.kde.ksvg 1.0 as KSvg
+
+import org.kde.kirigami 2.20 as Kirigami

 MouseArea {
    id: todoItemDelegate
@@ -108,20 +111,20 @@ MouseArea {
                delegate: todoItemRow
            }

-           PlasmaCore.FrameSvgItem {
+           KSvg.FrameSvgItem {
                visible: todoItemDelegate.containsMouse && !dropArea.containsDrag
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                anchors.bottom: parent.bottom
                width: parent.width / 2
-               imagePath: plasmoid.file("", "images/dragarea.svg")
+               //imagePath: plasmoid.file("", "images/dragarea.svg")
            }
        }

        PlasmaComponents3.CheckBox {
            id: checkbox
            Layout.alignment: Qt.AlignTop
-           property int size: 30 * units.devicePixelRatio
+           property int size: 30
            Layout.minimumWidth: size
            Layout.minimumHeight: size
            checked: todoItemDelegate.isCompleted
@@ -205,7 +208,7 @@ MouseArea {
                    return '<a href="' + m + '">' + m + '</a>' + ' ' // Extra space to prevent styling entire text as a link when ending with a link.
                })
                // Define before anchor tags.
-               out = '<style>a { color: ' + theme.highlightColor + '; }</style>' + out
+               out = '<style>a { color: ' + Kirigami.Theme.highlightColor + '; }</style>' + out

                // Render new lines
                out = out.replace(/\n/g, '<br>')
diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml
index e08bb34..38902c7 100644
--- a/package/contents/ui/main.qml
+++ b/package/contents/ui/main.qml
@@ -2,8 +2,10 @@ import QtQuick 2.0
 import QtQuick.Layouts 1.1
 import org.kde.plasma.plasmoid 2.0
 import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.plasma.plasma5support 2.0 as P5Support
+import org.kde.kirigami 2.20 as Kirigami

-Item {
+PlasmoidItem {
    id: main

    NoteItem {
@@ -12,7 +14,7 @@ Item {

    Plasmoid.icon: plasmoid.configuration.icon

-   Plasmoid.compactRepresentation: MouseArea {
+   compactRepresentation: MouseArea {
        readonly property bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge
            || plasmoid.location == PlasmaCore.Types.RightEdge
            || plasmoid.location == PlasmaCore.Types.BottomEdge
@@ -43,7 +45,7 @@ Item {
        Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1
        Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1

-       PlasmaCore.IconItem {
+       Kirigami.Icon {
            id: icon
            anchors.fill: parent
            source: plasmoid.icon
@@ -67,7 +69,7 @@ Item {
        onClicked: plasmoid.expanded = !plasmoid.expanded
    }

-   Plasmoid.fullRepresentation: FullRepresentation {
+   fullRepresentation: FullRepresentation {
        Plasmoid.backgroundHints: isDesktopContainment && !plasmoid.configuration.showBackground ? PlasmaCore.Types.NoBackground : PlasmaCore.Types.DefaultBackground
        isDesktopContainment: plasmoid.location == PlasmaCore.Types.Floating

@@ -82,7 +84,7 @@ Item {
    }

-   PlasmaCore.DataSource {
+   P5Support.DataSource {
        id: executable
        engine: "executable"
        connectedSources: []
golinski commented 8 months ago

@rhjdvsgsgks This patch together with desktoptojson was enough to make this work on Plasma 6.0.1 in Arch. Some imports probably need to be unversioned per porting guidelines, but now at least my TODOs are back. :tada:.

morrisjuosu commented 8 months ago

@golinski > @rhjdvsgsgks This patch together with desktoptojson was enough to make this work on Plasma 6.0.1 in Arch. Some imports probably need to be unversioned per porting guidelines, but now at least my TODOs are back. 🎉.

As a normy... I'm unsure how to do what you did.

Is there a file I'm editing? I really miss my lists already!

browser-bug commented 8 months ago

@rhjdvsgsgks This patch together with desktoptojson was enough to make this work on Plasma 6.0.1 in Arch. Some imports probably need to be unversioned per porting guidelines, but now at least my TODOs are back. 🎉.

I think I did the same but I still get an unsupported widget error. Could you share the PKGBUILD file and any other steps you followed to achieve this. I'm on arch too with Plasma 6.0.1

marco-calautti commented 8 months ago

I am also on arch with Plasma 6.0.1 and I am interested to understand what you actually did. Applying the patch, and installing the applet did not work for me.

browser-bug commented 8 months ago

I've looked a bit more into it. And now I'm more convinced that the patch provided by @rhjdvsgsgks is insufficient. Also the desktoptojson command doesn't come for free since it needs more manual changes:

In addition, some changes to applets' metadata are needed. In Plasma 6, all plasmoids must use JSON metadata. You can convert your plasmoid's old-style .desktop file to the new-style .json file using the desktoptojson command line utility. Beyond the automatic desktop-to-json metadata conversion, a few manual tweaks are also needed:

Set "X-Plasma-API-Minimum-Version": "6.0" so that the system sees the plasmoid. Plasmoids without this key are assumed to only work with Plasma 5 and will not be mad available in the UI.
Remove the X-Plasma-MainScript entry. In Plasma 6, ui/main.qml is always used as the entry point, so make sure that's the name of your "main" file.
Remove the X-Plasma-API entry.

If you automatically converted the metadata.json from a metadata.desktop, the KPlugin section may still contain the ServiceTypes key. This needs to be replaced by a KPackageStructure entry in the json's top level.

Sadly, even after these changes I don't get it working. I think strictly sticking to the official porting docs will be needed in order to get this work again.

My OS:

OS: Arch Linux x86_64
Kernel: 6.7.8-arch1-1
DE: Plasma 6.0.1
WM: i3
Theme: [Plasma], Breeze-Dark [GTK2], Breeze [GTK3]
Icons: [Plasma], breeze-dark [GTK2/3]