diff options
Diffstat (limited to 'src/settingsui/network/NetworkSettings.qml')
-rw-r--r-- | src/settingsui/network/NetworkSettings.qml | 144 |
1 files changed, 60 insertions, 84 deletions
diff --git a/src/settingsui/network/NetworkSettings.qml b/src/settingsui/network/NetworkSettings.qml index bb09954..c357671 100644 --- a/src/settingsui/network/NetworkSettings.qml +++ b/src/settingsui/network/NetworkSettings.qml @@ -28,104 +28,80 @@ ****************************************************************************/ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.2 import QtDeviceUtilities.NetworkSettings 1.0 +import "../common" Item { + id: root property string title: qsTr("Network Settings") - GroupBox { - id: networkSelect - anchors.rightMargin: parent.width * 0.618 - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.top: parent.top - anchors.topMargin: 20 + Column { + id: networkSettingsColumn + spacing: pluginMain.spacing + anchors.margins: viewSettings.pageMargin - title: qsTr("Select Connection") - - function stateToStr(serviceState) { - switch (serviceState) { - case NetworkService.Idle: - return qsTr("Idle"); - case NetworkService.Failure: - return qsTr("Failure"); - case NetworkService.Association: - return qsTr("Association"); - case NetworkService.Configuration: - return qsTr("Configuration"); - case NetworkService.Ready: - return qsTr("Ready"); - case NetworkService.Disconnect: - return qsTr("Disconnect"); - case NetworkService.Online: - return qsTr("Online"); - default: - return qsTr("Undefined"); + Row { + spacing: root.width * 0.025 + leftPadding: pluginMain.margin + Text { + text: qsTr("Wi-Fi") + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + color: "white" } - } - ColumnLayout { - width: parent.width - - Repeater { - model: NetworkSettingsManager.interfaces - - RadioButton { - id: btn - enabled: (type != NetworkSettingsType.Wired) || NetworkSettingsManager.services.wiredNetworksAvailable - Layout.fillWidth: true - implicitHeight: 54 - indicator: Item {} - contentItem: Rectangle { - color: checked ? "#80c342" : "white" - border.color: "#bdbebf" - border.width: 1 - anchors.fill: parent - - Column { - height: parent.height * .7 - width: parent.width - spacing: 0 - anchors.verticalCenter: parent.verticalCenter - Label { - width: parent.width - horizontalAlignment: Text.AlignHCenter - text: name - } - Label { - width: parent.width - horizontalAlignment: Text.AlignHCenter - text: ((type == NetworkSettingsType.Wired) && !NetworkSettingsManager.services.wiredNetworksAvailable) ? - qsTr("No networks") : networkSelect.stateToStr(modelData.state) - font.pixelSize: 12 - } - } + CustomSwitch { + id: wifiSwitch + indicatorWidth: root.width * 0.15 + indicatorHeight: root.height * 0.06 + property bool wiFiAvailable: NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0) !== null + enabled: wiFiAvailable && !wifiSwitchTimer.running + onCheckedChanged: { + // Power on/off all WiFi interfaces + for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { + NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered = checked + wifiSwitchTimer.start() } - - onCheckedChanged: { - if (checked) { - networkDetails.selectedInterface = modelData - networkDetails.selectedInterface.scanServices() - if (type === NetworkSettingsType.Wired) { - networkDetails.source = "WiredSettings.qml"; - } - else if (type === NetworkSettingsType.Wifi) { - networkDetails.source = "WifiSettings.qml"; - } + } + Component.onCompleted: { + // If any of the WiFi interfaces is powered on, switch is checked + var checkedStatus = false; + for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { + if (NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered) { + checkedStatus = true; + break; } } + checked = checkedStatus; + } + + // At least 1s between switching on/off + Timer { + id: wifiSwitchTimer + interval: 1000 + running: false } } } - } - NetworkDetails { - id: networkDetails - anchors.leftMargin: networkSelect.width + 40 - anchors.topMargin: 20 - anchors.rightMargin: 20 - anchors.bottomMargin: 20 - anchors.fill: parent + Text { + text: qsTr("Network list:") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + font.styleName: "SemiBold" + color: "white" + } + + Row { + id: listViewRow + leftPadding: pluginMain.margin + NetworkListView { + id: networkList + width: root.width - listViewRow.leftPadding + height: root.height - listViewRow.y - networkSettingsColumn.anchors.margins + } + } } } |