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
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property alias view: deviceView
|
|
|
|
objectName: "DevicesPage"
|
|
|
|
|
2022-05-05 20:51:53 +02:00
|
|
|
PlasmaComponents3.ScrollView {
|
2017-08-29 23:58:49 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2022-05-09 23:14:22 +02:00
|
|
|
// HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890
|
|
|
|
PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3.ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
contentItem: TopLevelView {
|
2017-08-29 23:58:49 +02:00
|
|
|
id: deviceView
|
2020-10-20 19:16:53 +02:00
|
|
|
model: plasmoid.nativeInterface.sortFilterDevModel
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
delegate: TopLevelItem {
|
|
|
|
id: item
|
2022-09-01 22:32:17 +02:00
|
|
|
width: deviceView.effectiveWidth()
|
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
|
2022-02-05 21:31:53 +01:00
|
|
|
icon.source: plasmoid.nativeInterface.faUrl + (paused ? "play" : "pause")
|
|
|
|
icon.cache: false
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|