plasmoid: Flatten plugin controllers, menu and other non-graphical components

Flat is better than nested. Those non-graphical components don't need to
be buried deep inside visual hierarchy tree. For example, for me it was
confusing to find the device label item after Battery, Connectivity and
VirtualMonitor only to realize some time later that those were not
actual visual indicators.
This commit is contained in:
ivan tkachenko 2024-07-01 03:34:20 +05:00
parent 8c0260d4f8
commit d2ee2bfdd8
No known key found for this signature in database
GPG key ID: AF72731B7C654CB3

View file

@ -24,6 +24,51 @@ PlasmaComponents.ItemDelegate {
hoverEnabled: false hoverEnabled: false
down: false down: false
Battery {
id: battery
device: root.device
}
Clipboard {
id: clipboard
device: root.device
}
Connectivity {
id: connectivity
device: root.device
}
FindMyPhone {
id: findmyphone
device: root.device
}
RemoteCommands {
id: remoteCommands
device: root.device
}
Sftp {
id: sftp
device: root.device
}
Share {
id: share
device: root.device
}
SMS {
id: sms
device: root.device
}
VirtualMonitor {
id: virtualmonitor
device: root.device
}
Kirigami.PromptDialog { Kirigami.PromptDialog {
id: prompt id: prompt
visible: false visible: false
@ -32,6 +77,75 @@ PlasmaComponents.ItemDelegate {
title: i18n("Virtual Monitor is not available") title: i18n("Virtual Monitor is not available")
} }
QtDialogs.FileDialog {
id: fileDialog
title: i18n("Please choose a file")
currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
fileMode: QtDialogs.FileDialog.OpenFiles
onAccepted: {
selectedFiles.forEach(url => share.plugin.shareUrl(url));
}
}
PlasmaExtras.Menu {
id: menu
visualParent: overflowMenu
placement: PlasmaExtras.Menu.BottomPosedLeftAlignedPopup
// Share
PlasmaExtras.MenuItem {
icon: "document-share"
visible: share.available
text: i18n("Share file")
onClicked: fileDialog.open()
}
// Clipboard
PlasmaExtras.MenuItem {
icon: "klipper"
visible: clipboard.clipboard?.isAutoShareDisabled ?? false
text: i18n("Send Clipboard")
onClicked: {
clipboard.sendClipboard()
}
}
// Find my phone
PlasmaExtras.MenuItem {
icon: "irc-voice"
visible: findmyphone.available
text: i18n("Ring my phone")
onClicked: {
findmyphone.ring()
}
}
// SFTP
PlasmaExtras.MenuItem {
icon: "document-open-folder"
visible: sftp.available
text: i18n("Browse this device")
onClicked: {
sftp.browse()
}
}
// SMS
PlasmaExtras.MenuItem {
icon: "message-new"
visible: sms.available
text: i18n("SMS Messages")
onClicked: {
sms.plugin.launchApp()
}
}
}
DropArea { DropArea {
id: fileDropArea id: fileDropArea
anchors.fill: parent anchors.fill: parent
@ -60,21 +174,6 @@ PlasmaComponents.ItemDelegate {
width: parent.width width: parent.width
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
Battery {
id: battery
device: root.device
}
Connectivity {
id: connectivity
device: root.device
}
VirtualMonitor {
id: virtualmonitor
device: root.device
}
PlasmaComponents.Label { PlasmaComponents.Label {
id: deviceName id: deviceName
elide: Text.ElideRight elide: Text.ElideRight
@ -164,101 +263,6 @@ PlasmaComponents.ItemDelegate {
checked: menu.status === PlasmaExtras.Menu.Open checked: menu.status === PlasmaExtras.Menu.Open
onPressed: menu.openRelative() onPressed: menu.openRelative()
PlasmaExtras.Menu {
id: menu
visualParent: overflowMenu
placement: PlasmaExtras.Menu.BottomPosedLeftAlignedPopup
// Share
PlasmaExtras.MenuItem {
id: shareFile
readonly property QtDialogs.FileDialog data: QtDialogs.FileDialog {
id: fileDialog
title: i18n("Please choose a file")
currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
fileMode: QtDialogs.FileDialog.OpenFiles
onAccepted: fileDialog.selectedFiles.forEach(url => share.plugin.shareUrl(url))
}
icon: "document-share"
visible: share.available
text: i18n("Share file")
onClicked: fileDialog.open()
}
// Clipboard
PlasmaExtras.MenuItem {
id: sendclipboard
readonly property Clipboard data: Clipboard {
id: clipboard
device: root.device
}
icon: "klipper"
visible: clipboard.clipboard?.isAutoShareDisabled ?? false
text: i18n("Send Clipboard")
onClicked: {
clipboard.sendClipboard()
}
}
// Find my phone
PlasmaExtras.MenuItem {
id: ring
readonly property FindMyPhone data: FindMyPhone {
id: findmyphone
device: root.device
}
icon: "irc-voice"
visible: findmyphone.available
text: i18n("Ring my phone")
onClicked: {
findmyphone.ring()
}
}
// SFTP
PlasmaExtras.MenuItem {
id: browse
readonly property Sftp data: Sftp {
id: sftp
device: root.device
}
icon: "document-open-folder"
visible: sftp.available
text: i18n("Browse this device")
onClicked: {
sftp.browse()
}
}
// SMS
PlasmaExtras.MenuItem {
readonly property SMS data: SMS {
id: sms
device: root.device
}
icon: "message-new"
visible: sms.available
text: i18n("SMS Messages")
onClicked: {
sms.plugin.launchApp()
}
}
}
} }
} }
@ -422,11 +426,6 @@ PlasmaComponents.ItemDelegate {
} }
} }
RemoteCommands {
id: remoteCommands
device: root.device
}
// Commands // Commands
RowLayout { RowLayout {
visible: remoteCommands.available visible: remoteCommands.available
@ -467,11 +466,5 @@ PlasmaComponents.ItemDelegate {
} }
} }
} }
// Share
Share {
id: share
device: root.device
}
} }
} }