2017-08-29 23:58:49 +02:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import QtQml.Models 2.2
|
2020-11-27 19:09:47 +01:00
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents // for Menu and MenuItem
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
2017-08-29 23:58:49 +02:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property alias view: deviceView
|
2017-09-09 21:40:00 +02:00
|
|
|
|
2017-08-29 23:58:49 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
objectName: "DevicesPage"
|
|
|
|
|
|
|
|
PlasmaExtras.ScrollArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
TopLevelView {
|
|
|
|
id: deviceView
|
2020-08-18 01:27:48 +02:00
|
|
|
width: parent.width
|
2020-10-20 19:16:53 +02:00
|
|
|
model: plasmoid.nativeInterface.sortFilterDevModel
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
delegate: TopLevelItem {
|
|
|
|
id: item
|
2020-08-18 01:27:48 +02:00
|
|
|
width: deviceView.width
|
2020-10-07 21:34:37 +02:00
|
|
|
readonly property string devName: name
|
2020-10-08 16:39:22 +02:00
|
|
|
readonly property string devID: devId
|
2017-09-26 23:46:20 +02:00
|
|
|
property alias resumePauseButton: resumePauseButton
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
RowLayout {
|
2017-10-01 21:22:37 +02:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2017-09-08 16:59:53 +02:00
|
|
|
PlasmaCore.IconItem {
|
2017-09-12 00:00:16 +02:00
|
|
|
Layout.preferredWidth: units.iconSizes.small
|
|
|
|
Layout.preferredHeight: units.iconSizes.small
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-09-08 16:59:53 +02:00
|
|
|
source: statusIcon
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.Label {
|
2017-08-29 23:58:49 +02:00
|
|
|
Layout.fillWidth: true
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-09-08 16:59:53 +02:00
|
|
|
elide: Text.ElideRight
|
|
|
|
text: name
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
id: toolButtonsLayout
|
|
|
|
spacing: 0
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.Label {
|
2017-08-29 23:58:49 +02:00
|
|
|
height: implicitHeight
|
|
|
|
text: statusString
|
2017-09-08 16:59:53 +02:00
|
|
|
color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
Item {
|
|
|
|
width: 3
|
|
|
|
}
|
2017-09-12 00:00:16 +02:00
|
|
|
TinyButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: resumePauseButton
|
2020-11-27 19:09:47 +01:00
|
|
|
icon.name: paused ? "media-playback-start" : "media-playback-pause"
|
2017-08-29 23:58:49 +02:00
|
|
|
tooltip: paused ? qsTr("Resume") : qsTr("Pause")
|
2021-02-12 20:31:05 +01:00
|
|
|
enabled: !isOwnDevice
|
2017-09-09 21:40:00 +02:00
|
|
|
onClicked: {
|
|
|
|
paused ? plasmoid.nativeInterface.connection.resumeDevice(
|
|
|
|
[devId]) : plasmoid.nativeInterface.connection.pauseDevice(
|
|
|
|
[devId])
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DetailView {
|
|
|
|
id: detailsView
|
|
|
|
visible: item.expanded
|
2017-10-01 21:22:37 +02:00
|
|
|
Layout.fillWidth: true
|
2019-02-27 20:41:50 +01:00
|
|
|
Layout.topMargin: 3
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
model: DelegateModel {
|
|
|
|
model: plasmoid.nativeInterface.devModel
|
2020-10-20 19:16:53 +02:00
|
|
|
rootIndex: deviceView.model.mapToSource(deviceView.model.index(index, 0))
|
2017-09-09 21:40:00 +02:00
|
|
|
delegate: DetailItem {
|
2019-03-19 23:05:31 +01:00
|
|
|
width: detailsView.width
|
2017-09-09 21:40:00 +02:00
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-26 22:56:55 +02:00
|
|
|
|
|
|
|
PlasmaComponents.Menu {
|
|
|
|
id: contextMenu
|
|
|
|
|
|
|
|
function init(item) {
|
|
|
|
// use value for properties depending on paused state from buttons
|
|
|
|
resumePauseItem.text = item.resumePauseButton.tooltip
|
2020-04-13 02:04:20 +02:00
|
|
|
resumePauseItem.icon = item.resumePauseButton.icon
|
2018-03-26 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
2020-10-07 21:34:37 +02:00
|
|
|
PlasmaComponents.MenuItem {
|
|
|
|
text: qsTr("Copy name")
|
|
|
|
icon: "edit-copy"
|
|
|
|
onClicked: deviceView.copyCurrentItemData("devName")
|
|
|
|
}
|
|
|
|
PlasmaComponents.MenuItem {
|
|
|
|
text: qsTr("Copy ID")
|
|
|
|
icon: "edit-copy"
|
2020-10-08 16:39:22 +02:00
|
|
|
onClicked: deviceView.copyCurrentItemData("devID")
|
2020-10-07 21:34:37 +02:00
|
|
|
}
|
|
|
|
PlasmaComponents.MenuItem {
|
|
|
|
separator: true
|
|
|
|
}
|
2018-03-26 22:56:55 +02:00
|
|
|
PlasmaComponents.MenuItem {
|
|
|
|
id: resumePauseItem
|
|
|
|
text: qsTr("Pause")
|
|
|
|
icon: "media-playback-pause"
|
|
|
|
onClicked: deviceView.clickCurrentItemButton(
|
|
|
|
"resumePauseButton")
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|