Index: sources/gui/qml/pages/settings/SettingsWiFi.qml =================================================================== diff -u -rbf9223700613ced6c377f3e3a7b4de8367c30474 -rb12cc2840bb819c5222bfd3bc2cc5ca6eb4c37fd --- sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision bf9223700613ced6c377f3e3a7b4de8367c30474) +++ sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision b12cc2840bb819c5222bfd3bc2cc5ca6eb4c37fd) @@ -14,15 +14,16 @@ */ // Qt -import QtQuick +import QtQuick 2.15 // Project -import Gui.Actions 0.1 // Qml imports import "qrc:/globals" +import "qrc:/compounds" import "qrc:/components" import "qrc:/pages" +import "qrc:/dialogs" /*! * \brief SettingsWiFi @@ -44,181 +45,226 @@ readonly property int topMargin : 160 readonly property bool isConnected : vDevice.ssid !== "" + confirmVisible : false - readonly property bool isValid : - _ipAddress .textInput.acceptableInput - && _gateway .textInput.acceptableInput - && _subnetmask .textInput.acceptableInput - && _dns .textInput.acceptableInput - - confirmEnabled : isValid - confirmVisible : false // since the static setting is done one by one seems confirm is not needed for now. - firstFocusInput : _ipAddress notificationText: vDevice.status - Column { id : _ipColumn - spacing : _root.spacing - y : _root.topMargin - anchors.left : parent.left - anchors.leftMargin : _root.leftMargin - TextEntry { id : _ssid - nextInput : _ipAddress // helps user to tap on enter to go to the next entry, keyboard visibility is handled by TextEntry. - textInput.text : vDevice.ssid - label.text : qsTr("SSID") - textInput.width : entryWidth - label.width : labelWidth - hasCursor : false // set false for now to disable the static IP entry for phase 1 - textInput.color : Colors.textMain - } + contentItem: Item { id: _contentRow + anchors.fill: parent - TextEntry { id : _ipAddress - nextInput : _gateway // helps user to tap on enter to go to the next entry, keyboard visibility is handled by TextEntry. - textInput.text : vDevice.ipAddress - textInput.visible: _root.isConnected - label.text : qsTr("IP Address") - textInput.width : entryWidth - label.width : labelWidth - hasCursor : false // set false for now to disable the static IP entry for phase 1 - textInput.color : Colors.textMain - } + Item { id: _wifiItem + anchors { + left : parent.left + leftMargin : Variables.defaultMargin * 2 + top : contentItem.top + bottom : contentItem.bottom + } - TextEntry { id : _gateway - nextInput : _subnetmask // helps user to tap on enter to go to the next entry, keyboard visibility is handled by TextEntry. - textInput.text : vDevice.gateway - textInput.visible: _root.isConnected - textInput.width : entryWidth - label.width : labelWidth - label.text : qsTr("Gateway") - hasCursor : false // set false for now to disable the static IP entry for phase 1 - textInput.color : Colors.textMain - } + width : parent.width / 2.5 - TextEntry { id : _subnetmask - nextInput : _dns // helps user to tap on enter to go to the next entry, keyboard visibility is handled by TextEntry. - textInput.text : vDevice.subnetMask - textInput.visible: _root.isConnected - textInput.width : entryWidth - label.width : labelWidth - label.text : qsTr("Subnet Mask") - hasCursor : false // set false for now to disable the static IP entry for phase 1 - textInput.color : Colors.textMain - } + ReviewContainer { id: _currentWifiInfo + anchors { + top : parent.top + left: parent.left + } + title : qsTr("Current Wi-Fi Information") + width : parent.width + cellHeight : 100 + valuePixelSize : Fonts.fontPixelTextRectTitle + color : Colors.transparent + headerColor : Colors.transparent + border.width : 0 + delegateFontWeight : Font.Medium - TextEntry { id : _dns - textInput.text : vDevice.dns - textInput.visible: _root.isConnected - textInput.width : entryWidth - textInput.wrapMode : Text.WordWrap - label.width : labelWidth - label.text : qsTr("DNS") - hasCursor : false // set false for now to disable the static IP entry for phase 1 - textInput.color : Colors.textMain - } - } + label : [ qsTr("SSID") , + qsTr("IP Address") , + qsTr("Gateway") , + qsTr("Subnet Mask") , + qsTr("DNS") ] - TouchRect { id : _scanButton - anchors.bottom : parent.bottom - anchors.bottomMargin: Variables.mainMenuHeight * 2 + Variables.minVGap - anchors.left : parent.left - anchors.leftMargin : _root.leftMargin - text.text : qsTr("SCAN") - width : 350 - isDefault : true - enabled : vDevice.wifiListEnabled - onClicked : vDevice.wifiList = "" - } + initial : [ vDevice.ssid , + _root.isConnected ? vDevice.ipAddress : "" , + vDevice.gateway , + vDevice.subnetMask , + vDevice.dns ] - ScrollBar { flickable : _networkList - anchors.fill: _networkList - } - ListView { id : _networkList - model : vDevice - clip : true - spacing : 7 - y : _root.topMargin - width : 450 - anchors.top : _ipColumn.top - anchors.bottom : _scanButton.bottom - anchors.right : _root.right - anchors.rightMargin : _root.rightMargin - delegate : - TouchRect { id : _delegate - readonly property color networkDelegateTextColor : wifiSupported ? Colors.textMain : Colors.textDisableButton - readonly property string postSecurityTypeLabel : wifiSupported ? "" : " - " + qsTr("Not Supported") - readonly property bool isConnected : wifiConnected - onIsConnectedChanged: { - if ( isConnected ) { - vDevice.doInitWifiInfo() - } + actual : [ "" , "" , "" , "" , "" ] + units : [ "" , "" , "" , "" , "" ] } + } - clip : true - text.text : wifiSsid - text.elide : Text.ElideLeft - text.color : _delegate.networkDelegateTextColor - width : _networkList.width - Variables.minVGap - height : 75 - radius : Variables.dialogRadius + Rectangle { id: _networkRect + color : Colors.panelBackgroundColor + anchors { + right : parent.right + rightMargin : Variables.defaultMargin * 2 + top : contentItem.top + bottom : contentItem.bottom + bottomMargin : Variables.defaultMargin + } + width : parent.width / 2.5 - text.anchors.horizontalCenter : undefined - text.horizontalAlignment : Text.AlignLeft - text.leftPadding : 5 - border.width : 1 - borderColor : wifiConnected ? Colors.borderButtonSelected : Colors.borderButton + Column { id: _networkColumn + anchors.fill: parent - Text { id : _securityLevel - anchors { - left : parent.left - leftMargin : 10 - bottom : parent.bottom - } - font.pixelSize : Fonts.fontPixelDialogText - text : wifiSecurityTypes + _delegate.postSecurityTypeLabel - color : _delegate.networkDelegateTextColor - } + Rectangle { id: _header + width : parent.width + height : 75 + color : Colors.panelBackgroundColor + radius : 9 - Text { id : _isConnected - anchors { - right : parent.right - rightMargin : 10 - bottom : parent.bottom + border { + width: 1 + color: Colors.panelBorderColor + } + + Text { id: _title + text : qsTr("Available Networks") + color : Colors.offWhite + font.family : Fonts.fontFamilyFixed + font.weight : Font.DemiBold + font.pixelSize : Fonts.fontPixelTextRectTitle + anchors { + left : parent.left + leftMargin : Variables.defaultMargin + verticalCenter : parent.verticalCenter + } + } + + IconButton { id: _refreshIcon + anchors { + right : parent.right + rightMargin : Variables.defaultMargin + verticalCenter : parent.verticalCenter + } + iconSize : Variables.iconsDiameter + iconImageSource : enabled ? "qrc:/images/iRefresh" : "qrc:/images/iRefreshDisabled" + enabled : ! vDevice.isWifiScanning + + onPressed : vDevice.wifiList = "" + + + RotationAnimator on rotation { + running : vDevice.isWifiScanning + from : 0 + to : 360 + loops : Animation.Infinite + duration: 7200 + } + } } - font.pixelSize : Fonts.fontPixelDialogText - text : wifiConnected ? qsTr("Connected") : "" - color : _delegate.networkDelegateTextColor - } - onClicked : { - if( wifiSupported ) { - _userConfirmation.isPassword = ! wifiConnected - _userConfirmation.ssid = wifiSsid - _userConfirmation.macAddress = wifiMacAddress - push( _userConfirmation ) - _userConfirmation.setFocus() + Item { id: _wifiListItem + width : parent.width + height : parent.height - _header.height + + ListView { id : _networkList + model : vDevice.wifiModel + clip : true + width : parent.width + height : parent.height + + delegate : TouchRect { id : _delegate + readonly property color networkDelegateTextColor : wifiSupported ? Colors.offWhite : Colors.textDisableButton + readonly property string postSecurityTypeLabel : wifiSupported ? "" : " - " + qsTr("Not Supported") + readonly property bool isConnected : wifiConnected + readonly property int margin : Variables.defaultMargin * 2 + onIsConnectedChanged: { + if ( isConnected ) { + vDevice.doInitWifiInfo() + } + } + + clip : true + text.text : wifiSsid + text.elide : Text.ElideLeft + text.color : _delegate.networkDelegateTextColor + width : parent.width + height : 75 + radius : 0 + backgroundColor : Colors.waterSampleContainer + pixelSize : Fonts.fontPixelTextRectTitle + text.font.weight : Font.Medium + text.anchors.horizontalCenter : undefined + text.anchors.verticalCenter : undefined + + text.horizontalAlignment : Text.AlignLeft + text.leftPadding : _delegate.margin + text.topPadding : 10 + text.verticalAlignment : Text.AlignTop + border.width : 0 + + Text { id : _securityLevel + anchors { + left : parent.left + leftMargin : _delegate.margin + bottom : parent.bottom + bottomMargin: 5 + } + font.pixelSize : Fonts.fontPixelDialogText + font.weight : Font.Light + text : wifiSecurityTypes + _delegate.postSecurityTypeLabel + color : _delegate.networkDelegateTextColor + } + + Text { id : _isConnected + anchors { + verticalCenter : parent.verticalCenter + right : parent.right + rightMargin : _delegate.margin + } + font.pixelSize : Fonts.fontPixelTextRectExtra + font.weight : Font.Medium + text : wifiConnected ? qsTr("Connected") : "" + color : Colors.statusTextActive + } + + Line { id: _wifiDivider + color : Colors.panelBorderColor + visible : index !== _networkList.count - 1 + anchors { + bottom : parent.bottom + left : parent.left + leftMargin : _delegate.margin + right : parent.right + rightMargin : _delegate.margin + } + } + + onClicked : { + if( wifiSupported ) { + _wifiConfirmDialog.isPassword = ! wifiConnected + _wifiConfirmDialog.ssid = wifiSsid + _wifiConfirmDialog.open() + } + } + } + } + + ScrollBar { + flickable : _networkList + anchors.fill : _networkList + scrollColor : Colors.scrollBarColor + handleWidth : 5 + visible : _networkList.count > 0 + } } } } } - UserConfirmation { id : _userConfirmation - property string ssid : "" - property string macAddress : "" - property string separator : "\n" - readonly property string spaceSeparator : " " - notificationText : vDevice.status - message : qsTr("Do you want to disconnect from `%1`?").arg(ssid) - title : isPassword ? qsTr("Join") + separator + ssid + spaceSeparator + qsTr("Password") : qsTr("Disconnect") + separator + ssid - onConfirmClicked : { + ConfirmPasswordDialog { id: _wifiConfirmDialog + + onAccepted : { if ( isPassword ) { - if( passwordCurrent.length > 0 ) { - vDevice.doWifiConnect( true, ssid, passwordCurrent ) - pop() + if( passwordLength > 0 ) { + vDevice.doWifiConnect( true, ssid, password ) } } else { vDevice.doWifiConnect( false, ssid, "" ) - pop() } } } + }