import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import "../components" Item { id: page property string deviceIp: "…" function refreshIp() { var devs = systemInfo.networkInfo() for (var i = 0; i < devs.length; ++i) { var addrs = devs[i].addresses if (!addrs || devs[i].state !== "connected") continue var a = String(addrs).split(",")[0].trim() var slash = a.indexOf("/") if (slash >= 0) a = a.substring(0, slash) if (a.length > 0) { deviceIp = a return } } deviceIp = "—" } function refreshBrightness() { var r = systemInfo.brightnessStatus() if (r.ok) { brightnessSlider.value = r.percent != null ? r.percent : 100 brightnessHint.text = "Сейчас: " + r.percent + "%" + (r.device ? (" (" + r.device + ")") : "") + (r.saved != null ? (" · сохранено: " + r.saved + "%") : "") } else { brightnessHint.text = "Подсветка недоступна: " + (r.error || "ошибка") } } Component.onCompleted: { refreshIp() refreshBrightness() } Timer { interval: 5000 running: true repeat: true onTriggered: page.refreshIp() } signal openButtons() signal openLayout() signal openBackground() signal openFeedback() signal openNetwork() signal openUpdate() signal changePassword() Rectangle { anchors.fill: parent color: "#161628" } ScrollView { anchors.fill: parent clip: true contentWidth: availableWidth contentHeight: menuColumn.implicitHeight + 16 ScrollBar.vertical.policy: ScrollBar.AsNeeded ColumnLayout { id: menuColumn width: page.width - 16 x: 8 y: 8 spacing: 8 SettingsButton { Layout.fillWidth: true text: "Кнопки (CRUD + порядок)" onClicked: page.openButtons() } SettingsButton { Layout.fillWidth: true text: "Расположение: " + settingsContainer.layoutMode + " (" + (settingsContainer.layoutMode === "grid" ? settingsContainer.layoutColumns + " колонок" : "список") + ")" onClicked: page.openLayout() } SettingsButton { Layout.fillWidth: true text: "Фон" onClicked: page.openBackground() } SettingsButton { Layout.fillWidth: true text: "Обводка отклика (ОК / Ошибка)" onClicked: page.openFeedback() } SettingsButton { Layout.fillWidth: true text: "Сеть" onClicked: page.openNetwork() } SettingsButton { Layout.fillWidth: true text: "Обновление ПО" onClicked: page.openUpdate() } SettingsButton { Layout.fillWidth: true text: "Сменить пароль" onClicked: page.changePassword() } Rectangle { Layout.fillWidth: true Layout.preferredHeight: brightnessCol.implicitHeight + 16 Layout.topMargin: 8 radius: 4 color: "#2a2a40" ColumnLayout { id: brightnessCol anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top anchors.margins: 8 spacing: 6 Text { Layout.fillWidth: true text: "Яркость экрана" color: "#ffffff" font.pixelSize: 14 font.bold: true } Text { id: brightnessHint Layout.fillWidth: true text: "Загрузка…" color: "#aaaaaa" font.pixelSize: 12 wrapMode: Text.WordWrap } LabeledSlider { id: brightnessSlider Layout.fillWidth: true label: "Яркость %" from: 1 to: 100 stepSize: 1 value: 100 } SettingsButton { Layout.fillWidth: true text: "Применить яркость" onClicked: { var r = systemInfo.setBrightness(Math.round(brightnessSlider.value)) if (r.ok) { brightnessHint.text = "Сейчас: " + r.percent + "%" + (r.device ? (" (" + r.device + ")") : "") + (r.saved != null ? (" · сохранено: " + r.saved + "%") : "") } else { brightnessHint.text = "Ошибка: " + (r.error || "неизвестно") } } } } } Text { Layout.fillWidth: true Layout.topMargin: 8 text: "IP: " + page.deviceIp color: "#cccccc" font.pixelSize: 12 horizontalAlignment: Text.AlignHCenter } Text { Layout.fillWidth: true text: "Веб-конфигуратор: http://" + page.deviceIp + ":" + settingsContainer.webPort color: "#cccccc" font.pixelSize: 12 horizontalAlignment: Text.AlignHCenter } Text { Layout.fillWidth: true text: "Конфиг: " + config.configPath color: "#cccccc" font.pixelSize: 11 elide: Text.ElideMiddle horizontalAlignment: Text.AlignHCenter } Item { Layout.preferredHeight: 8 } } } }