From b78c77489825ece19b34dd92ac00c8be382bb516 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 14 Nov 2023 23:58:22 +0100 Subject: [PATCH] Improve Plasma 6 version of Plasmoid --- plasmoid/cmake/templates/metadata.json.in | 4 +++- .../package6/contents/ui/CompactRepresentation.qml | 11 ++++++++++- plasmoid/package6/contents/ui/DetailItem.qml | 2 +- plasmoid/package6/contents/ui/DetailView.qml | 7 ++++++- plasmoid/package6/contents/ui/DevicesPage.qml | 2 +- plasmoid/package6/contents/ui/DirectoriesPage.qml | 8 ++++---- plasmoid/package6/contents/ui/DownloadsPage.qml | 2 +- .../package6/contents/ui/FullRepresentation.qml | 5 +++-- plasmoid/package6/contents/ui/TabButton.qml | 2 +- plasmoid/package6/contents/ui/ToolButton.qml | 2 +- plasmoid/package6/contents/ui/TopLevelView.qml | 2 +- plasmoid/package6/contents/ui/main.qml | 14 ++++++-------- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/plasmoid/cmake/templates/metadata.json.in b/plasmoid/cmake/templates/metadata.json.in index b247948..c7b99aa 100644 --- a/plasmoid/cmake/templates/metadata.json.in +++ b/plasmoid/cmake/templates/metadata.json.in @@ -6,6 +6,7 @@ "Category": "SystemServices", "Description": "@META_APP_DESCRIPTION@", "EnabledByDefault": false, + "FormFactors": ["desktop"], "Icon": "syncthingtray", "Id": "@META_ID@", "License": "@META_PROJECT_LICENSE@", @@ -13,7 +14,8 @@ "Version": "@META_APP_VERSION@", "Website": "@META_APP_URL@" }, - "Keywords": "syncthing;sync;", + "X-KDE-Keywords": "syncthing,sync", "X-Plasma-API": "declarativeappletscript", + "X-Plasma-NotificationAreaCategory": "SystemServices", "X-Plasma-MainScript": "ui/main.qml" } diff --git a/plasmoid/package6/contents/ui/CompactRepresentation.qml b/plasmoid/package6/contents/ui/CompactRepresentation.qml index 6b56310..a4219ec 100644 --- a/plasmoid/package6/contents/ui/CompactRepresentation.qml +++ b/plasmoid/package6/contents/ui/CompactRepresentation.qml @@ -5,9 +5,18 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.20 as Kirigami MouseArea { + property bool wasExpanded Layout.fillWidth: false hoverEnabled: true - onClicked: plasmoid.expanded = !plasmoid.expanded + + onPressed: wasExpanded = syncthingApplet.expanded + onClicked: mouse => { + if (mouse.button === Qt.MiddleButton) { + Plasmoid.showWebUI(); + } else { + syncthingApplet.expanded = !wasExpanded; + } + } Kirigami.Icon { id: icon diff --git a/plasmoid/package6/contents/ui/DetailItem.qml b/plasmoid/package6/contents/ui/DetailItem.qml index 6a9c74b..8199b00 100644 --- a/plasmoid/package6/contents/ui/DetailItem.qml +++ b/plasmoid/package6/contents/ui/DetailItem.qml @@ -30,7 +30,7 @@ Item { font.weight: Font.DemiBold } PlasmaComponents3.Label { - Layout.leftMargin: theme.defaultFont.pointSize * 0.9 + Layout.leftMargin: Kirigami.Theme.defaultFont.pointSize * 0.9 Layout.fillWidth: true text: detailValue elide: Text.ElideRight diff --git a/plasmoid/package6/contents/ui/DetailView.qml b/plasmoid/package6/contents/ui/DetailView.qml index c183def..86c58ab 100644 --- a/plasmoid/package6/contents/ui/DetailView.qml +++ b/plasmoid/package6/contents/ui/DetailView.qml @@ -6,7 +6,12 @@ ListView { property DetailItem contextMenuItem: null currentIndex: -1 interactive: false - height: contentHeight + + onCountChanged: { + var d = delegate.createObject(detailView, {detailName: "", detailValue: ""}); + height = count * d.height + d.destroy() + } PlasmaExtras.Menu { id: contextMenu diff --git a/plasmoid/package6/contents/ui/DevicesPage.qml b/plasmoid/package6/contents/ui/DevicesPage.qml index 734243d..da2ca76 100644 --- a/plasmoid/package6/contents/ui/DevicesPage.qml +++ b/plasmoid/package6/contents/ui/DevicesPage.qml @@ -52,7 +52,7 @@ Item { PlasmaComponents3.Label { height: implicitHeight text: statusString - color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor + color: statusColor ? statusColor : Kirigami.Theme.textColor Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft } Item { diff --git a/plasmoid/package6/contents/ui/DirectoriesPage.qml b/plasmoid/package6/contents/ui/DirectoriesPage.qml index 3e68987..8ec4d5d 100644 --- a/plasmoid/package6/contents/ui/DirectoriesPage.qml +++ b/plasmoid/package6/contents/ui/DirectoriesPage.qml @@ -54,8 +54,8 @@ ColumnLayout { Layout.fillWidth: true Kirigami.Icon { - Layout.preferredWidth: units.iconSizes.small - Layout.preferredHeight: units.iconSizes.small + Layout.preferredWidth: Kirigami.Units.iconSizes.small + Layout.preferredHeight: Kirigami.Units.iconSizes.small Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft source: statusIcon } @@ -72,11 +72,11 @@ ColumnLayout { PlasmaComponents3.Label { height: implicitHeight text: statusString - color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor + color: statusColor ? statusColor : Kirigami.Theme.textColor Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft } Item { - width: units.smallSpacing + width: Kirigami.Units.smallSpacing } TinyButton { id: errorsButton diff --git a/plasmoid/package6/contents/ui/DownloadsPage.qml b/plasmoid/package6/contents/ui/DownloadsPage.qml index 94c7f4b..ed07b7a 100644 --- a/plasmoid/package6/contents/ui/DownloadsPage.qml +++ b/plasmoid/package6/contents/ui/DownloadsPage.qml @@ -35,7 +35,7 @@ Item { Layout.fillWidth: true RowLayout { - spacing: units.smallSpacing + spacing: Kirigami.Units.smallSpacing PlasmaComponents3.Label { Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft elide: Text.ElideRight diff --git a/plasmoid/package6/contents/ui/FullRepresentation.qml b/plasmoid/package6/contents/ui/FullRepresentation.qml index b02b576..08c7610 100644 --- a/plasmoid/package6/contents/ui/FullRepresentation.qml +++ b/plasmoid/package6/contents/ui/FullRepresentation.qml @@ -14,7 +14,8 @@ PlasmaExtras.Representation { // header ("toolbar" with buttons and combo box) and footer ("tabbar") header: PlasmaExtras.PlasmoidHeading { - ToolBar { + focus: true + contentItem: ToolBar { id: toolbar width: parent.width } @@ -23,7 +24,7 @@ PlasmaExtras.Representation { spacing: 0 topPadding: 0 height: Kirigami.Units.iconSizes.medium - PlasmaComponents3.TabBar { + contentItem: PlasmaComponents3.TabBar { id: tabBar readonly property double buttonWidth: parent.width / count position: PlasmaComponents3.TabBar.Footer diff --git a/plasmoid/package6/contents/ui/TabButton.qml b/plasmoid/package6/contents/ui/TabButton.qml index e20bb18..872dbcb 100644 --- a/plasmoid/package6/contents/ui/TabButton.qml +++ b/plasmoid/package6/contents/ui/TabButton.qml @@ -37,7 +37,7 @@ PlasmaComponents3.TabButton { id: label visible: text.length > 0 text: root.showTabText ? root.text : "" - color: PlasmaCore.ColorScope.textColor + color: Kirigami.Theme.textColor elide: Text.ElideRight Layout.fillHeight: true } diff --git a/plasmoid/package6/contents/ui/ToolButton.qml b/plasmoid/package6/contents/ui/ToolButton.qml index cda308c..50b76cd 100644 --- a/plasmoid/package6/contents/ui/ToolButton.qml +++ b/plasmoid/package6/contents/ui/ToolButton.qml @@ -22,7 +22,7 @@ PlasmaComponents3.ToolButton { id: label visible: text.length > 0 text: root.text - color: PlasmaCore.ColorScope.textColor + color: Kirigami.Theme.textColor elide: Text.ElideRight Layout.fillWidth: true Layout.fillHeight: true diff --git a/plasmoid/package6/contents/ui/TopLevelView.qml b/plasmoid/package6/contents/ui/TopLevelView.qml index 92996b3..b0a70ec 100644 --- a/plasmoid/package6/contents/ui/TopLevelView.qml +++ b/plasmoid/package6/contents/ui/TopLevelView.qml @@ -26,7 +26,7 @@ ListView { function activate(index) { if (typeof contextMenu !== "undefined" - && contextMenu.status !== PlasmaExtras.DialogStatus.Closed) { + && contextMenu.status !== PlasmaExtras.Menu.Closed) { return } currentIndex = index diff --git a/plasmoid/package6/contents/ui/main.qml b/plasmoid/package6/contents/ui/main.qml index 1aebb98..bb1eeca 100644 --- a/plasmoid/package6/contents/ui/main.qml +++ b/plasmoid/package6/contents/ui/main.qml @@ -8,18 +8,16 @@ import org.kde.kirigami 2.20 as Kirigami PlasmoidItem { id: syncthingApplet - // FIXME: adding title causes plasmawindowed to segfault - //Plasmoid.title: "Syncthing" + Plasmoid.title: "Syncthing" Plasmoid.icon: "syncthing" - // FIXME: not sure whether assigning switchWidth/switchHeight like this works - switchWidth: fullRepresentationItem ? fullRepresentationItem.Layout.minimumWidth : -1 - switchHeight: fullRepresentationItem ? fullRepresentationItem.Layout.minimumHeight : -1 - preferredRepresentation: fullRepresentation + switchWidth: Kirigami.Units.gridUnit * Plasmoid.size.width + switchHeight: Kirigami.Units.gridUnit * Plasmoid.size.height compactRepresentation: CompactRepresentation {} fullRepresentation: FullRepresentation { - Layout.minimumWidth: Kirigami.Units.gridUnit * Plasmoid.size.width - Layout.minimumHeight: Kirigami.Units.gridUnit * Plasmoid.size.height + Layout.minimumWidth: syncthingApplet.switchWidth + Layout.minimumHeight: syncthingApplet.switchHeight } + toolTipMainText: Plasmoid.statusText toolTipSubText: Plasmoid.additionalStatusText toolTipItem: ToolTipView {}