| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 1.15
- import QtQuick.Dialogs
- import "../components"
- import "../components" as Components
- Page {
- id: page
- property var backend: null
- // Local state
- property bool ledPowerOn: false
- property int ledBrightness: 100
- property string ledProvider: "none"
- property bool ledConnected: false
- property int currentEffectIndex: 0
- property int currentPaletteIndex: 0
- property var effectsList: []
- property var palettesList: []
- // Predefined colors for quick selection (muted tones to fit dark UI)
- property var presetColors: [
- {"name": "White", "color": "#e8e8e8", "sendColor": "#ffffff"},
- {"name": "Warm", "color": "#d4a574", "sendColor": "#ffaa55"},
- {"name": "Red", "color": "#c45c5c", "sendColor": "#ff0000"},
- {"name": "Orange", "color": "#d4875c", "sendColor": "#ff8800"},
- {"name": "Yellow", "color": "#c9b95c", "sendColor": "#ffff00"},
- {"name": "Green", "color": "#5cb85c", "sendColor": "#00ff00"},
- {"name": "Cyan", "color": "#5cb8b8", "sendColor": "#00ffff"},
- {"name": "Blue", "color": "#5c7cc4", "sendColor": "#0000ff"},
- {"name": "Purple", "color": "#8b5cc4", "sendColor": "#8800ff"},
- {"name": "Pink", "color": "#c45c99", "sendColor": "#ff00ff"}
- ]
- // Backend signal connections
- Connections {
- target: backend
- function onLedStatusChanged() {
- if (backend) {
- ledPowerOn = backend.ledPowerOn
- ledBrightness = backend.ledBrightness
- ledProvider = backend.ledProvider
- ledConnected = backend.ledConnected
- currentEffectIndex = backend.ledCurrentEffect
- currentPaletteIndex = backend.ledCurrentPalette
- }
- }
- function onLedEffectsLoaded(effects) {
- effectsList = effects
- }
- function onLedPalettesLoaded(palettes) {
- palettesList = palettes
- }
- }
- // Load LED config on page load
- Component.onCompleted: {
- if (backend) {
- backend.loadLedConfig()
- }
- }
- Rectangle {
- anchors.fill: parent
- color: Components.ThemeManager.backgroundColor
- }
- ColumnLayout {
- anchors.fill: parent
- spacing: 0
- // Header
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: 50
- color: Components.ThemeManager.surfaceColor
- Rectangle {
- anchors.bottom: parent.bottom
- width: parent.width
- height: 1
- color: Components.ThemeManager.borderColor
- }
- RowLayout {
- anchors.fill: parent
- anchors.leftMargin: 15
- anchors.rightMargin: 10
- ConnectionStatus {
- backend: page.backend
- Layout.rightMargin: 8
- }
- Label {
- text: "LED Control"
- font.pixelSize: 18
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- Item {
- Layout.fillWidth: true
- }
- }
- }
- // Main Content
- ScrollView {
- Layout.fillWidth: true
- Layout.fillHeight: true
- contentWidth: availableWidth
- ColumnLayout {
- width: parent.width
- anchors.margins: 5
- spacing: 2
- // Provider Info & Power/Brightness Section
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: ledProvider === "none" ? 100 : (ledProvider === "wled" ? 90 : 110)
- Layout.margins: 5
- radius: 8
- color: Components.ThemeManager.surfaceColor
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: 15
- spacing: 10
- // Not configured message
- ColumnLayout {
- visible: ledProvider === "none"
- Layout.fillWidth: true
- spacing: 8
- Label {
- text: "LED Not Configured"
- font.pixelSize: 14
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- Label {
- text: "Configure LED settings in the main Dune Weaver web interface"
- font.pixelSize: 12
- color: Components.ThemeManager.textSecondary
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- // DW LEDs Controls - Power and Brightness in same section
- ColumnLayout {
- visible: ledProvider === "dw_leds"
- Layout.fillWidth: true
- spacing: 8
- // Power row with status and toggle
- RowLayout {
- Layout.fillWidth: true
- spacing: 12
- // Status indicator with label
- RowLayout {
- spacing: 6
- Rectangle {
- width: 12
- height: 12
- radius: 6
- color: ledPowerOn ? "#4CAF50" : "#6b7280"
- }
- Label {
- text: ledPowerOn ? "On" : "Off"
- font.pixelSize: 13
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- }
- // Toggle button
- ModernControlButton {
- Layout.preferredWidth: 100
- Layout.preferredHeight: 36
- text: ledPowerOn ? "Turn Off" : "Turn On"
- icon: ""
- buttonColor: ledPowerOn ? "#6b7280" : "#4CAF50"
- fontSize: 11
- onClicked: {
- if (backend) {
- backend.toggleLedPower()
- }
- }
- }
- Item { Layout.fillWidth: true }
- // Connection status (smaller, secondary)
- RowLayout {
- spacing: 4
- Rectangle {
- width: 8
- height: 8
- radius: 4
- color: ledConnected ? "#4CAF50" : "#ef4444"
- }
- Label {
- text: ledConnected ? "Connected" : "Disconnected"
- font.pixelSize: 10
- color: Components.ThemeManager.textTertiary
- }
- }
- }
- // Brightness row
- RowLayout {
- Layout.fillWidth: true
- spacing: 10
- Label {
- text: "Brightness"
- font.pixelSize: 12
- color: Components.ThemeManager.textSecondary
- }
- Slider {
- id: brightnessSlider
- Layout.fillWidth: true
- from: 0
- to: 100
- stepSize: 5
- value: ledBrightness
- onMoved: {
- if (backend) {
- backend.setLedBrightness(Math.round(value))
- }
- }
- }
- Label {
- text: Math.round(brightnessSlider.value) + "%"
- font.pixelSize: 12
- font.bold: true
- color: Components.ThemeManager.textPrimary
- Layout.preferredWidth: 35
- horizontalAlignment: Text.AlignRight
- }
- }
- }
- // WLED Info
- ColumnLayout {
- visible: ledProvider === "wled"
- Layout.fillWidth: true
- spacing: 8
- Label {
- text: "WLED Mode"
- font.pixelSize: 14
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- Label {
- text: "Use the main Dune Weaver web interface for WLED controls"
- font.pixelSize: 12
- color: Components.ThemeManager.textSecondary
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- }
- }
- // Effects Section (only for dw_leds)
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: effectsList.length > 0 ? 180 : 80
- Layout.margins: 5
- radius: 8
- color: Components.ThemeManager.surfaceColor
- visible: ledProvider === "dw_leds"
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: 15
- spacing: 10
- Label {
- text: "Effects"
- font.pixelSize: 14
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- // Show loading or no effects message
- Label {
- visible: effectsList.length === 0
- text: "No effects available"
- font.pixelSize: 12
- color: Components.ThemeManager.textSecondary
- }
- // Effects grid
- GridLayout {
- Layout.fillWidth: true
- columns: 4
- rowSpacing: 6
- columnSpacing: 6
- visible: effectsList.length > 0
- Repeater {
- model: effectsList.slice(0, 12) // Show first 12 effects
- Rectangle {
- property int effectId: modelData.id !== undefined ? modelData.id : index
- property bool isSelected: effectId === currentEffectIndex
- Layout.fillWidth: true
- Layout.preferredHeight: 35
- radius: 6
- color: isSelected ?
- Components.ThemeManager.selectedBackground :
- Components.ThemeManager.buttonBackground
- border.color: isSelected ?
- Components.ThemeManager.selectedBorder :
- Components.ThemeManager.buttonBorder
- border.width: 1
- Label {
- anchors.centerIn: parent
- anchors.leftMargin: 4
- anchors.rightMargin: 4
- width: parent.width - 8
- text: modelData.name || ("Effect " + effectId)
- font.pixelSize: 10
- color: isSelected ? "white" : Components.ThemeManager.textPrimary
- elide: Text.ElideRight
- horizontalAlignment: Text.AlignHCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (backend) {
- backend.setLedEffect(effectId)
- currentEffectIndex = effectId
- }
- }
- }
- }
- }
- }
- }
- }
- // Palettes Section (only for dw_leds)
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: palettesList.length > 0 ? 140 : 80
- Layout.margins: 5
- radius: 8
- color: Components.ThemeManager.surfaceColor
- visible: ledProvider === "dw_leds"
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: 15
- spacing: 10
- Label {
- text: "Palettes"
- font.pixelSize: 14
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- // Show loading or no palettes message
- Label {
- visible: palettesList.length === 0
- text: "No palettes available"
- font.pixelSize: 12
- color: Components.ThemeManager.textSecondary
- }
- // Palettes grid
- GridLayout {
- Layout.fillWidth: true
- columns: 4
- rowSpacing: 6
- columnSpacing: 6
- visible: palettesList.length > 0
- Repeater {
- model: palettesList.slice(0, 8) // Show first 8 palettes
- Rectangle {
- property int paletteId: modelData.id !== undefined ? modelData.id : index
- property bool isSelected: paletteId === currentPaletteIndex
- Layout.fillWidth: true
- Layout.preferredHeight: 35
- radius: 6
- color: isSelected ?
- Components.ThemeManager.selectedBackground :
- Components.ThemeManager.buttonBackground
- border.color: isSelected ?
- Components.ThemeManager.selectedBorder :
- Components.ThemeManager.buttonBorder
- border.width: 1
- Label {
- anchors.centerIn: parent
- anchors.leftMargin: 4
- anchors.rightMargin: 4
- width: parent.width - 8
- text: modelData.name || ("Palette " + paletteId)
- font.pixelSize: 10
- color: isSelected ? "white" : Components.ThemeManager.textPrimary
- elide: Text.ElideRight
- horizontalAlignment: Text.AlignHCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (backend) {
- backend.setLedPalette(paletteId)
- currentPaletteIndex = paletteId
- }
- }
- }
- }
- }
- }
- }
- }
- // Quick Colors Section - MOVED TO BOTTOM (only for dw_leds)
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: 160
- Layout.margins: 5
- radius: 8
- color: Components.ThemeManager.surfaceColor
- visible: ledProvider === "dw_leds"
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: 15
- spacing: 10
- Label {
- text: "Quick Colors"
- font.pixelSize: 14
- font.bold: true
- color: Components.ThemeManager.textPrimary
- }
- GridLayout {
- Layout.fillWidth: true
- Layout.fillHeight: true
- columns: 5
- rowSpacing: 8
- columnSpacing: 8
- Repeater {
- model: presetColors
- Rectangle {
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.minimumHeight: 50
- radius: 6
- color: Components.ThemeManager.buttonBackground
- border.color: Components.ThemeManager.buttonBorder
- border.width: 1
- RowLayout {
- anchors.centerIn: parent
- spacing: 6
- // Color indicator circle
- Rectangle {
- width: 14
- height: 14
- radius: 7
- color: modelData.color
- border.color: Qt.darker(modelData.color, 1.2)
- border.width: 1
- }
- Label {
- text: modelData.name
- font.pixelSize: 11
- color: Components.ThemeManager.textPrimary
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (backend) {
- backend.setLedColorHex(modelData.sendColor)
- }
- }
- }
- // Touch feedback
- Rectangle {
- id: colorTouchFeedback
- anchors.fill: parent
- color: Components.ThemeManager.darkMode ? "#ffffff" : "#000000"
- opacity: 0
- radius: 6
- NumberAnimation {
- id: colorTouchAnimation
- target: colorTouchFeedback
- property: "opacity"
- from: 0.15
- to: 0
- duration: 200
- }
- }
- }
- }
- }
- }
- }
- // Add some bottom spacing for better scrolling
- Item {
- Layout.preferredHeight: 20
- }
- }
- }
- }
- }
|