import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as QQC2
import org.kde.plasma.plasmoid
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami
// The popup: the same circles as a filter bar, the brightness clamp for
// whatever is in focus, and tabs for the links, machines and devices behind
// it. Everything filters to the focused place when a circle is selected.
ColumnLayout {
id: view
required property var store
readonly property bool ready: store.available && store.hasValidConfig
readonly property var focusDef: (store.rev, store.focusDef)
Layout.minimumWidth: Kirigami.Units.gridUnit * 22
Layout.minimumHeight: Kirigami.Units.gridUnit * 18
Layout.preferredWidth: Kirigami.Units.gridUnit * 28
Layout.preferredHeight: Kirigami.Units.gridUnit * 30
spacing: Kirigami.Units.smallSpacing
// ── header ──────────────────────────────────────────────────────────
RowLayout {
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
PlasmaComponents3.ToolButton {
visible: view.store.focusKey !== ""
icon.name: "go-previous"
onClicked: view.store.focusKey = ""
PlasmaComponents3.ToolTip { text: i18n("Everything") }
}
Kirigami.Heading {
Layout.fillWidth: true
level: 3
elide: Text.ElideRight
text: view.focusDef ? view.focusDef.label : i18n("Lambent")
}
PlasmaComponents3.BusyIndicator {
visible: view.ready && !view.store.connected
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
}
PlasmaComponents3.ToolButton {
visible: view.store.hasValidConfig
icon.name: "internet-web-browser"
onClicked: Qt.openUrlExternally(view.store.baseUrl)
PlasmaComponents3.ToolTip { text: i18n("Open the web UI") }
}
PlasmaComponents3.ToolButton {
icon.name: "view-refresh"
enabled: view.store.connected
onClicked: view.store.refreshDevices()
PlasmaComponents3.ToolTip { text: i18n("Ask every device what it's running now") }
}
PlasmaComponents3.ToolButton {
icon.name: "configure"
onClicked: Plasmoid.internalAction("configure").trigger()
PlasmaComponents3.ToolTip { text: i18n("Configure") }
}
}
CircleStrip {
visible: view.store.connected && view.store.circlesModelRef.count > 0
Layout.fillWidth: true
store: view.store
inPanel: false
}
PlasmaComponents3.Label {
visible: view.ready && !view.store.connected
Layout.fillWidth: true
wrapMode: Text.WordWrap
color: Kirigami.Theme.neutralTextColor
font: Kirigami.Theme.smallFont
text: view.store.statusText()
}
PlasmaComponents3.Label {
visible: view.store.notice !== ""
Layout.fillWidth: true
wrapMode: Text.WordWrap
color: Kirigami.Theme.negativeTextColor
font: Kirigami.Theme.smallFont
text: view.store.notice
}
// ── setup prompts ───────────────────────────────────────────────────
ColumnLayout {
visible: !view.ready
Layout.fillWidth: true
Layout.fillHeight: true
spacing: Kirigami.Units.largeSpacing
Item { Layout.fillHeight: true }
Kirigami.Icon {
source: view.store.logoSource
isMask: true
color: Kirigami.Theme.disabledTextColor
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Kirigami.Units.iconSizes.huge
Layout.preferredHeight: Kirigami.Units.iconSizes.huge
}
PlasmaComponents3.Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: !view.store.available ? view.store.statusText()
: i18n("Point the widget at your LambentEx box")
}
PlasmaComponents3.Button {
visible: view.store.available
Layout.alignment: Qt.AlignHCenter
icon.name: "configure"
text: i18n("Configure Connection")
onClicked: Plasmoid.internalAction("configure").trigger()
}
Item { Layout.fillHeight: true }
}
// ── focused clamp ───────────────────────────────────────────────────
BrightnessRow {
visible: view.ready && (!view.focusDef || view.focusDef.place !== "")
Layout.fillWidth: true
store: view.store
place: view.focusDef ? view.focusDef.place : ""
subtitle: view.focusDef ? "" : i18n("global")
}
Kirigami.Separator {
visible: view.ready
Layout.fillWidth: true
}
PlasmaComponents3.TabBar {
id: tabs
visible: view.ready
Layout.fillWidth: true
currentIndex: view.store.currentTab
onCurrentIndexChanged: view.store.currentTab = currentIndex
PlasmaComponents3.TabButton { text: i18n("Links (%1)", view.store.linksModelRef.count) }
PlasmaComponents3.TabButton { text: i18n("Machines (%1)", view.store.machinesModelRef.count) }
PlasmaComponents3.TabButton { text: i18n("Devices (%1)", view.store.devicesModelRef.count) }
PlasmaComponents3.TabButton { text: i18n("Places") }
}
StackLayout {
visible: view.ready
Layout.fillWidth: true
Layout.fillHeight: true
currentIndex: tabs.currentIndex
// ── links ───────────────────────────────────────────────────────
ColumnLayout {
spacing: Kirigami.Units.smallSpacing
ListPane {
Layout.fillWidth: true
Layout.fillHeight: true
model: view.store.linksModelRef
empty: view.focusDef ? i18n("Nothing is linked here") : i18n("No links yet")
delegate: LinkItem {
width: ListView.view.width
store: view.store
}
}
NewLinkRow {
Layout.fillWidth: true
store: view.store
}
}
// ── machines ────────────────────────────────────────────────────
ColumnLayout {
spacing: Kirigami.Units.smallSpacing
ListPane {
Layout.fillWidth: true
Layout.fillHeight: true
model: view.store.machinesModelRef
empty: view.focusDef ? i18n("No machine drives this place") : i18n("No machines running")
delegate: MachineItem {
width: ListView.view.width
store: view.store
}
}
LibraryRow {
Layout.fillWidth: true
store: view.store
}
}
// ── devices ─────────────────────────────────────────────────────
ListPane {
model: view.store.devicesModelRef
empty: i18n("No devices found yet")
delegate: DeviceItem {
width: ListView.view.width
store: view.store
}
}
// ── places: every clamp ─────────────────────────────────────────
ListPane {
model: view.store.placesModelRef
empty: i18n("No places yet. Give a device a place and it shows up here.")
delegate: BrightnessRow {
required property string key
width: ListView.view.width
store: view.store
place: key
subtitle: (view.store.rev, i18np("%1 device", "%1 devices", view.store.macsInPlace(key).length))
}
}
}
}
neiam
/lambent-ex-plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
8.5 KiB · text
History
e43831b