import QtQuick
import QtQuick.Layouts
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami
import "Lambent.js" as L
// A discovered device. Poke flashes it (its indicator LED when it has one,
// the strands otherwise) so you can tell which one it is.
ColumnLayout {
id: item
required property var store
required property string key
readonly property var device: (store.rev, store.devices[key] || null)
readonly property int driving: (store.rev, store.linksOn([key]).length)
spacing: 0
RowLayout {
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
Kirigami.Icon {
source: item.device && item.device.type === "mqtt-tasmota" ? "network-wireless" : "lighttable"
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
opacity: item.driving > 0 ? 1 : 0.5
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
PlasmaComponents3.Label {
Layout.fillWidth: true
elide: Text.ElideRight
text: L.deviceLabel(item.device, item.key)
+ (item.device && item.device.place ? " · " + item.device.place : "")
}
PlasmaComponents3.Label {
Layout.fillWidth: true
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
text: !item.device ? "" : [
item.device.ip || "",
item.device.type || "",
// a legacy 8266 reports 0 strands and still has one
i18np("%1 strand", "%1 strands", Math.max(item.device.sox || 0, 1)),
item.device.ver ? "v" + item.device.ver : "",
item.driving > 0 ? i18np("%1 link on", "%1 links on", item.driving) : i18n("dark")
].filter(function(s) { return s !== "" }).join(" · ")
}
}
PlasmaComponents3.ToolButton {
icon.name: "flashlight-on"
onClicked: item.store.poke(item.key)
PlasmaComponents3.ToolTip { text: i18n("Poke — flash it to find it") }
}
}
Kirigami.Separator {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing / 2
opacity: 0.5
}
}
neiam
/lambent-ex-plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
2.4 KiB · text
History
cc97953