1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-23 01:35:18 +00:00
harbour-sailfin/sailfish/qml/pages/ControllableDevicesPage.qml

76 lines
2.8 KiB
QML
Raw Permalink Normal View History

import QtQuick 2.6
import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
import ".."
Page {
id: pageRoot
SilicaListView {
id: listView
anchors.fill: parent
contentHeight: Theme.itemSizeLarge
header: PageHeader {
//: Page title: page for remote controlling other Jellyfin apps
title: qsTr("Remote control")
}
model: J.RemoteDeviceList {
id: deviceList
apiClient: appWindow.apiClient
scanning: pageRoot.status == PageStatus.Active
}
delegate: ListItem {
property bool isConnected: model.jellyfinId === appWindow.playbackManager.controllingSessionId
onClicked: deviceList.activateSession(appWindow.playbackManager, model.index)
contentHeight: Theme.itemSizeMedium
Icon {
id: deviceIcon
anchors {
left: parent.left
leftMargin: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
height: parent.contentHeight - 2 * Theme.paddingMedium
width: height
source: {
if (model.deviceType == J.DeviceType.Phone) {
return "image://theme/icon-m-device"
} else if (model.deviceType == J.DeviceType.Tv) {
// For the lack of a better icon
return "image://theme/icon-m-device-landscape"
} else if (model.deviceType == J.DeviceType.Computer) {
return "image://theme/icon-m-computer"
} else {
//case J.DeviceType.Unknown:
return "image://theme/icon-m-question"
}
}
highlighted: parent.down || isConnected
}
Column {
anchors {
left: deviceIcon.right
right: parent.right
verticalCenter: parent.verticalCenter
leftMargin: Theme.paddingLarge
rightMargin: Theme.horizontalPageMargin
}
Label {
id: deviceName
//: List of devices item title in the form of <app name> — <device name>
text: qsTr("%1 — %2").arg(model.name).arg(model.deviceName)
color: isConnected || highlighted ? Theme.highlightColor : Theme.primaryColor
}
Label {
id: deviceUser
text: model.userName
color: isConnected || highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
}
}
}
}
}