Index: sources/gui/qml/pages/SettingsBluetooth.qml =================================================================== diff -u -r0470ff6f209ff0c5089f8f0849b6da04f60f8f41 -r62d4bbefa96100e5a01194c0b704fe32d9db56ec --- sources/gui/qml/pages/SettingsBluetooth.qml (.../SettingsBluetooth.qml) (revision 0470ff6f209ff0c5089f8f0849b6da04f60f8f41) +++ sources/gui/qml/pages/SettingsBluetooth.qml (.../SettingsBluetooth.qml) (revision 62d4bbefa96100e5a01194c0b704fe32d9db56ec) @@ -15,6 +15,7 @@ // Qt import QtQuick 2.12 +import QtQuick.Controls 2.12 // Project import Gui.Actions 0.1; @@ -29,57 +30,174 @@ */ ScreenItem { id: _root - signal clickedBack() + signal backClicked() BackButton { id : _backButton - onClicked: _root.clickedBack() + onClicked: { + vBluetooth.doSaveMyDevices() + _root.backClicked() + } } - TouchRect { - id: _scan_for_devices + TitleText { id: _title anchors.horizontalCenter: _root.horizontalCenter anchors.top: _root.top - anchors.topMargin: 75 + anchors.left: _root.left + anchors.topMargin: Variables.settingsBLEMargin + text: qsTr("Bluetooth") + } + + TouchRect { id: _scanForDevices + anchors.left: _root.left + anchors.top: _root.top + anchors.topMargin: 6*Variables.settingsBLEMargin + anchors.leftMargin: 2*Variables.settingsBLEMargin height: Variables.settingsBLEButtonHeight width: Variables.settingsBLEButtonWidth - text.text: "Scan for devices" - animated: true - onClicked: vBluetooth.onScanForDevices() + text.text: qsTr("Scan for devices") + animated: false + onClicked: { + if (!vBluetooth.scanInProgress) { + vBluetooth.doScanForDevices() + } + } + backgroundColor: vBluetooth.scanInProgress ? Colors.backgroundButtonNormal : Colors.backgroundButtonSelect + textColor: vBluetooth.scanInProgress ? "grey" : Colors.textMain } - Rectangle { - id: _status - anchors.left: _scan_for_devices.right - anchors.top: _root.top - anchors.topMargin: 75 + Rectangle { id: _status + anchors.bottom: _scanForDevices.bottom + anchors.left: _scanForDevices.left + anchors.bottomMargin: Variables.settingsBLEMargin color: "transparent" height: Variables.settingsBLEButtonHeight width: Variables.settingsBLEButtonWidth - Text { - id: _status_text - anchors.centerIn: parent - text: vBluetooth.status + Text { id: _status_text + anchors.leftMargin: 10 + text: qsTr(vBluetooth.status) color: Colors.textMain font.pixelSize: Fonts.fontPixelDialogText + wrapMode: Text.WordWrap + width: parent.width } } - ListView { - id: _devices + Text { id: _pairedDevicesLabel + anchors.top: _root.top + anchors.right: _devices.left + anchors.rightMargin: Variables.settingsBLEMargin + anchors.topMargin: 2*Variables.settingsBLEMargin + + font.pixelSize: Fonts.bleTitleFontSize + color: Colors.textMain + text: qsTr("My Devices") + } + + ListView { id: _pairedDevices + model: vBluetooth.pairedDevices + anchors.top: _pairedDevicesLabel.bottom + anchors.topMargin: Variables.settingsBLEListViewMargin + anchors.horizontalCenter: _pairedDevicesLabel.horizontalCenter + anchors.bottom: _root.bottom + anchors.bottomMargin: Variables.mainMenuHeight + Variables.notificationHeight + width: Variables.settingsBLEListViewWidth + clip: true + spacing: 10 + + ScrollBar.vertical: ScrollBar { id: _scrollBarPairedDevices + anchors.right: _pairedDevices.right + anchors.rightMargin: 3 + contentItem: Rectangle { + color: Colors.backgroundRangeRect + implicitWidth: 6 + radius: width / 2 + width: 3 + } + } + + delegate: TouchRect { + id: _pairedDevicesRect + anchors.right: parent.right + anchors.rightMargin: Variables.settingsBLEItemRightMargin + height: Variables.settingsBLEButtonHeight + width: Variables.settingsBLEButtonWidth + color: Colors.backgroundMain + border.color: Colors.borderButton + radius: 5 + animated: true + + Text { + id: _pairedDeviceName + anchors.bottom: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: modelData.name + color: Colors.textMain + } + + Text { + id: _pairedDevicesAddress + anchors.top: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: modelData.address + color: Colors.textMain + } + + Text { + id: _isConnected + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.horizontalCenter: parent.horizontalCenter + anchors.leftMargin: 5 + text: modelData.connected ? "Paired, Connected" : "Paired, Not Connected" + color: Colors.textMain + font.pixelSize: Fonts.bleConnectedFontSize + } + + onClicked: { + vBluetooth.doSelectDevice(modelData.address, modelData.name) + } + } + } + + Text { id: _devicesLabel + anchors.top: _root.top + anchors.right: _root.right + anchors.rightMargin: 3*Variables.settingsBLEMargin + anchors.topMargin: 2*Variables.settingsBLEMargin + + font.pixelSize: Fonts.bleTitleFontSize + color: Colors.textMain + text: qsTr("Other Devices") + } + + ListView { id: _devices model: vBluetooth.devices - anchors.top: _scan_for_devices.bottom - anchors.topMargin: 10 + anchors.top: _devicesLabel.bottom + anchors.topMargin: Variables.settingsBLEListViewMargin + anchors.horizontalCenter: _devicesLabel.horizontalCenter anchors.bottom: _root.bottom - width: Variables.settingsBLEButtonWidth - anchors.horizontalCenter: _root.horizontalCenter + anchors.bottomMargin: Variables.mainMenuHeight + Variables.notificationHeight + width: Variables.settingsBLEListViewWidth clip: true spacing: 10 + ScrollBar.vertical: ScrollBar { id: _scrollBarOtherDevices + anchors.right: _devices.right + anchors.rightMargin: 3 + contentItem: Rectangle { + color: Colors.backgroundRangeRect + implicitWidth: 6 + radius: width / 2 + width: 3 + } + } + delegate: TouchRect { id: _devices_rect - anchors.horizontalCenter: parent.horizontalCenter - height: 85 - width: parent.width + anchors.right: parent.right + anchors.rightMargin: Variables.settingsBLEItemRightMargin + height: Variables.settingsBLEButtonHeight + width: Variables.settingsBLEButtonWidth color: Colors.backgroundMain border.color: Colors.borderButton radius: 5 @@ -102,14 +220,8 @@ } onClicked: { - vBluetooth.onSelectedDevice(modelData.address) + vBluetooth.doSelectDevice(modelData.address, modelData.name) } } } - - Connections { target: vBluetooth - onScanFinished: { - console.debug("Scan Finished."); - } - } }