Improve Plasma 6 version of Plasmoid

This commit is contained in:
Martchus 2023-11-14 23:58:22 +01:00
parent c721e0a5cf
commit b78c774898
12 changed files with 38 additions and 23 deletions

View File

@ -6,6 +6,7 @@
"Category": "SystemServices", "Category": "SystemServices",
"Description": "@META_APP_DESCRIPTION@", "Description": "@META_APP_DESCRIPTION@",
"EnabledByDefault": false, "EnabledByDefault": false,
"FormFactors": ["desktop"],
"Icon": "syncthingtray", "Icon": "syncthingtray",
"Id": "@META_ID@", "Id": "@META_ID@",
"License": "@META_PROJECT_LICENSE@", "License": "@META_PROJECT_LICENSE@",
@ -13,7 +14,8 @@
"Version": "@META_APP_VERSION@", "Version": "@META_APP_VERSION@",
"Website": "@META_APP_URL@" "Website": "@META_APP_URL@"
}, },
"Keywords": "syncthing;sync;", "X-KDE-Keywords": "syncthing,sync",
"X-Plasma-API": "declarativeappletscript", "X-Plasma-API": "declarativeappletscript",
"X-Plasma-NotificationAreaCategory": "SystemServices",
"X-Plasma-MainScript": "ui/main.qml" "X-Plasma-MainScript": "ui/main.qml"
} }

View File

@ -5,9 +5,18 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
MouseArea { MouseArea {
property bool wasExpanded
Layout.fillWidth: false Layout.fillWidth: false
hoverEnabled: true 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 { Kirigami.Icon {
id: icon id: icon

View File

@ -30,7 +30,7 @@ Item {
font.weight: Font.DemiBold font.weight: Font.DemiBold
} }
PlasmaComponents3.Label { PlasmaComponents3.Label {
Layout.leftMargin: theme.defaultFont.pointSize * 0.9 Layout.leftMargin: Kirigami.Theme.defaultFont.pointSize * 0.9
Layout.fillWidth: true Layout.fillWidth: true
text: detailValue text: detailValue
elide: Text.ElideRight elide: Text.ElideRight

View File

@ -6,7 +6,12 @@ ListView {
property DetailItem contextMenuItem: null property DetailItem contextMenuItem: null
currentIndex: -1 currentIndex: -1
interactive: false interactive: false
height: contentHeight
onCountChanged: {
var d = delegate.createObject(detailView, {detailName: "", detailValue: ""});
height = count * d.height
d.destroy()
}
PlasmaExtras.Menu { PlasmaExtras.Menu {
id: contextMenu id: contextMenu

View File

@ -52,7 +52,7 @@ Item {
PlasmaComponents3.Label { PlasmaComponents3.Label {
height: implicitHeight height: implicitHeight
text: statusString text: statusString
color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor color: statusColor ? statusColor : Kirigami.Theme.textColor
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
} }
Item { Item {

View File

@ -54,8 +54,8 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Kirigami.Icon { Kirigami.Icon {
Layout.preferredWidth: units.iconSizes.small Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: units.iconSizes.small Layout.preferredHeight: Kirigami.Units.iconSizes.small
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
source: statusIcon source: statusIcon
} }
@ -72,11 +72,11 @@ ColumnLayout {
PlasmaComponents3.Label { PlasmaComponents3.Label {
height: implicitHeight height: implicitHeight
text: statusString text: statusString
color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor color: statusColor ? statusColor : Kirigami.Theme.textColor
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
} }
Item { Item {
width: units.smallSpacing width: Kirigami.Units.smallSpacing
} }
TinyButton { TinyButton {
id: errorsButton id: errorsButton

View File

@ -35,7 +35,7 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
RowLayout { RowLayout {
spacing: units.smallSpacing spacing: Kirigami.Units.smallSpacing
PlasmaComponents3.Label { PlasmaComponents3.Label {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
elide: Text.ElideRight elide: Text.ElideRight

View File

@ -14,7 +14,8 @@ PlasmaExtras.Representation {
// header ("toolbar" with buttons and combo box) and footer ("tabbar") // header ("toolbar" with buttons and combo box) and footer ("tabbar")
header: PlasmaExtras.PlasmoidHeading { header: PlasmaExtras.PlasmoidHeading {
ToolBar { focus: true
contentItem: ToolBar {
id: toolbar id: toolbar
width: parent.width width: parent.width
} }
@ -23,7 +24,7 @@ PlasmaExtras.Representation {
spacing: 0 spacing: 0
topPadding: 0 topPadding: 0
height: Kirigami.Units.iconSizes.medium height: Kirigami.Units.iconSizes.medium
PlasmaComponents3.TabBar { contentItem: PlasmaComponents3.TabBar {
id: tabBar id: tabBar
readonly property double buttonWidth: parent.width / count readonly property double buttonWidth: parent.width / count
position: PlasmaComponents3.TabBar.Footer position: PlasmaComponents3.TabBar.Footer

View File

@ -37,7 +37,7 @@ PlasmaComponents3.TabButton {
id: label id: label
visible: text.length > 0 visible: text.length > 0
text: root.showTabText ? root.text : "" text: root.showTabText ? root.text : ""
color: PlasmaCore.ColorScope.textColor color: Kirigami.Theme.textColor
elide: Text.ElideRight elide: Text.ElideRight
Layout.fillHeight: true Layout.fillHeight: true
} }

View File

@ -22,7 +22,7 @@ PlasmaComponents3.ToolButton {
id: label id: label
visible: text.length > 0 visible: text.length > 0
text: root.text text: root.text
color: PlasmaCore.ColorScope.textColor color: Kirigami.Theme.textColor
elide: Text.ElideRight elide: Text.ElideRight
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -26,7 +26,7 @@ ListView {
function activate(index) { function activate(index) {
if (typeof contextMenu !== "undefined" if (typeof contextMenu !== "undefined"
&& contextMenu.status !== PlasmaExtras.DialogStatus.Closed) { && contextMenu.status !== PlasmaExtras.Menu.Closed) {
return return
} }
currentIndex = index currentIndex = index

View File

@ -8,18 +8,16 @@ import org.kde.kirigami 2.20 as Kirigami
PlasmoidItem { PlasmoidItem {
id: syncthingApplet id: syncthingApplet
// FIXME: adding title causes plasmawindowed to segfault Plasmoid.title: "Syncthing"
//Plasmoid.title: "Syncthing"
Plasmoid.icon: "syncthing" Plasmoid.icon: "syncthing"
// FIXME: not sure whether assigning switchWidth/switchHeight like this works switchWidth: Kirigami.Units.gridUnit * Plasmoid.size.width
switchWidth: fullRepresentationItem ? fullRepresentationItem.Layout.minimumWidth : -1 switchHeight: Kirigami.Units.gridUnit * Plasmoid.size.height
switchHeight: fullRepresentationItem ? fullRepresentationItem.Layout.minimumHeight : -1
preferredRepresentation: fullRepresentation
compactRepresentation: CompactRepresentation {} compactRepresentation: CompactRepresentation {}
fullRepresentation: FullRepresentation { fullRepresentation: FullRepresentation {
Layout.minimumWidth: Kirigami.Units.gridUnit * Plasmoid.size.width Layout.minimumWidth: syncthingApplet.switchWidth
Layout.minimumHeight: Kirigami.Units.gridUnit * Plasmoid.size.height Layout.minimumHeight: syncthingApplet.switchHeight
} }
toolTipMainText: Plasmoid.statusText toolTipMainText: Plasmoid.statusText
toolTipSubText: Plasmoid.additionalStatusText toolTipSubText: Plasmoid.additionalStatusText
toolTipItem: ToolTipView {} toolTipItem: ToolTipView {}