337fdf13dc
- Use conditional Binding to sync slider values only when not dragging - Send value to light once on release instead of every pixel - Improve shared config file loading with multiple path fallbacks
146 lines
4.2 KiB
QML
146 lines
4.2 KiB
QML
import QtQuick
|
|
import QtQuick.Controls as QQC2
|
|
import QtQuick.Layouts
|
|
import org.kde.kirigami as Kirigami
|
|
import org.kde.plasma.components as PC3
|
|
|
|
ColumnLayout {
|
|
id: fullRoot
|
|
|
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 18
|
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 10
|
|
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
|
|
|
spacing: Kirigami.Units.smallSpacing
|
|
|
|
// Not configured state
|
|
PC3.Label {
|
|
Layout.alignment: Qt.AlignCenter
|
|
text: "Run 'elgato discover' or configure host in widget settings"
|
|
visible: root.lightHost === ""
|
|
wrapMode: Text.WordWrap
|
|
Layout.fillWidth: true
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
|
|
// Unreachable state
|
|
PC3.Label {
|
|
Layout.alignment: Qt.AlignCenter
|
|
text: "Light unreachable (" + root.lightHost + ")"
|
|
visible: root.lightHost !== "" && !root.lightReachable
|
|
wrapMode: Text.WordWrap
|
|
Layout.fillWidth: true
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
|
|
// Controls (only when reachable)
|
|
ColumnLayout {
|
|
visible: root.lightHost !== "" && root.lightReachable
|
|
Layout.fillWidth: true
|
|
spacing: Kirigami.Units.smallSpacing
|
|
Layout.margins: Kirigami.Units.smallSpacing
|
|
|
|
// Header: Power switch
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
|
|
Kirigami.Icon {
|
|
source: "video-television"
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
|
|
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
|
|
}
|
|
|
|
PC3.Label {
|
|
text: "Elgato Key Light"
|
|
font.bold: true
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.Switch {
|
|
checked: root.lightOn
|
|
onToggled: root.toggleLight()
|
|
}
|
|
}
|
|
|
|
Kirigami.Separator {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
// Brightness slider
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
|
|
Kirigami.Icon {
|
|
source: "brightness-high"
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
|
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
|
}
|
|
|
|
PC3.Slider {
|
|
id: brightnessSlider
|
|
Layout.fillWidth: true
|
|
from: 3
|
|
to: 100
|
|
stepSize: 1
|
|
|
|
// Sync from light state only when not dragging
|
|
Binding on value {
|
|
value: root.lightBrightness
|
|
when: !brightnessSlider.pressed
|
|
}
|
|
|
|
onPressedChanged: {
|
|
if (!pressed) {
|
|
// Send final value on release
|
|
root.setBrightness(Math.round(value))
|
|
}
|
|
}
|
|
}
|
|
|
|
PC3.Label {
|
|
text: Math.round(brightnessSlider.value) + "%"
|
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
|
|
horizontalAlignment: Text.AlignRight
|
|
}
|
|
}
|
|
|
|
// Temperature slider
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
|
|
Kirigami.Icon {
|
|
source: "color-management"
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
|
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
|
}
|
|
|
|
PC3.Slider {
|
|
id: temperatureSlider
|
|
Layout.fillWidth: true
|
|
from: 143
|
|
to: 344
|
|
stepSize: 1
|
|
|
|
// Sync from light state only when not dragging
|
|
Binding on value {
|
|
value: root.lightTemperature
|
|
when: !temperatureSlider.pressed
|
|
}
|
|
|
|
onPressedChanged: {
|
|
if (!pressed) {
|
|
// Send final value on release
|
|
root.setTemperature(Math.round(value))
|
|
}
|
|
}
|
|
}
|
|
|
|
PC3.Label {
|
|
text: Math.round(1000000 / temperatureSlider.value) + "K"
|
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
|
|
horizontalAlignment: Text.AlignRight
|
|
}
|
|
}
|
|
}
|
|
}
|