import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 Item { id: page readonly property color fg: "#ffffff" readonly property color muted: "#aaaaaa" readonly property color rowBg: "#222236" readonly property color headerBg: "#2a2a40" ColumnLayout { anchors.fill: parent anchors.margins: 4 spacing: 6 Text { Layout.fillWidth: true text: "Датчики BLE" + (sensorsBridge.poolFull ? " · пул заполнен" : "") color: page.fg font.pixelSize: 16 font.bold: true } // Table header Rectangle { Layout.fillWidth: true Layout.preferredHeight: 28 color: page.headerBg radius: 2 RowLayout { anchors.fill: parent anchors.leftMargin: 6 anchors.rightMargin: 6 spacing: 4 Text { Layout.preferredWidth: parent.width * 0.34; text: "MAC"; color: page.muted; font.pixelSize: 12 } Text { Layout.preferredWidth: parent.width * 0.18; text: "Аккум."; color: page.muted; font.pixelSize: 12 } Text { Layout.preferredWidth: parent.width * 0.26; text: "Показание"; color: page.muted; font.pixelSize: 12 } Text { Layout.fillWidth: true; text: "RSSI"; color: page.muted; font.pixelSize: 12 } } } ListView { id: table Layout.fillWidth: true Layout.preferredHeight: Math.min(160, contentHeight + 4) clip: true model: sensorsBridge.sensorSlots spacing: 2 delegate: Rectangle { width: table.width height: 28 color: page.rowBg radius: 2 opacity: modelData.empty ? 0.45 : 1.0 RowLayout { anchors.fill: parent anchors.leftMargin: 6 anchors.rightMargin: 6 spacing: 4 Text { Layout.preferredWidth: parent.width * 0.34 text: modelData.empty ? ("слот " + modelData.slot) : modelData.mac color: page.fg font.pixelSize: 12 elide: Text.ElideRight } Text { Layout.preferredWidth: parent.width * 0.18 text: modelData.empty ? "—" : modelData.battery color: page.fg font.pixelSize: 12 } Text { Layout.preferredWidth: parent.width * 0.26 text: modelData.empty ? "—" : modelData.reading color: page.fg font.pixelSize: 12 } Text { Layout.fillWidth: true text: modelData.empty ? "—" : modelData.rssi color: page.fg font.pixelSize: 12 } } } Text { anchors.centerIn: parent visible: table.count === 0 text: "Нет данных коллектора" color: page.muted font.pixelSize: 13 } } Text { Layout.fillWidth: true text: "Лог" color: page.fg font.pixelSize: 14 font.bold: true } Rectangle { Layout.fillWidth: true Layout.fillHeight: true color: "#141422" radius: 2 border.color: "#333348" ListView { id: logView anchors.fill: parent anchors.margins: 4 clip: true model: sensorsBridge.logEntries delegate: Text { width: logView.width wrapMode: Text.Wrap color: modelData.level === "warn" ? "#ffcc66" : page.muted font.pixelSize: 11 text: (modelData.ts || "") + " " + (modelData.msg || "") + (modelData.detail ? (" " + modelData.detail) : "") } } } Button { Layout.fillWidth: true Layout.preferredHeight: 40 text: "Отправить рекламу" onClicked: { if (!sensorsBridge.advertise()) console.warn("advertise cmd failed") } background: Rectangle { radius: 4 color: parent.down ? "#3a3a58" : "#2a2a40" border.color: "#555570" } contentItem: Text { text: parent.text color: page.fg horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.pixelSize: 14 } } } }