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",
"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"
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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 {}