WLAN connection new UI

pull/30/head
reionwong 4 years ago
parent eb807ad556
commit 60d788a769

@ -30,10 +30,26 @@ import "../"
Item {
id: control
height: _itemLayout.implicitHeight + FishUI.Units.largeSpacing
property bool passwordIsStatic: (model.securityType === NM.Enums.StaticWep || model.securityType === NM.Enums.WpaPsk ||
model.securityType === NM.Enums.Wpa2Psk || model.securityType === NM.Enums.SAE)
property bool predictableWirelessPassword: !model.uuid && model.type === NM.Enums.Wireless && passwordIsStatic
ColumnLayout {
id: _itemLayout
anchors.fill: parent
anchors.leftMargin: 0
anchors.rightMargin: FishUI.Units.smallSpacing
anchors.topMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.smallSpacing
spacing: 0
//
Item {
Layout.fillWidth: true
Layout.preferredHeight: _topItem.implicitHeight + FishUI.Units.largeSpacing
Rectangle {
anchors.fill: parent
radius: FishUI.Theme.smallRadius
@ -48,25 +64,31 @@ Item {
acceptedButtons: Qt.LeftButton
onClicked: {
if (model.uuid || !predictableWirelessPassword) {
if (connectionState === NM.Enums.Deactivated) {
if (!predictableWirelessPassword && !model.uuid) {
handler.addAndActivateConnection(model.devicePath, model.specificPath);
} else {
handler.activateConnection(model.connectionPath, model.devicePath, model.specificPath);
}
} else {
handler.deactivateConnection(model.connectionPath, model.devicePath);
}
} else if (predictableWirelessPassword) {
passwordDialog.show()
}
additionalSettings.toggle()
// if (model.uuid || !predictableWirelessPassword) {
// if (connectionState === NM.Enums.Deactivated) {
// if (!predictableWirelessPassword && !model.uuid) {
// handler.addAndActivateConnection(model.devicePath, model.specificPath);
// } else {
// handler.activateConnection(model.connectionPath, model.devicePath, model.specificPath);
// }
// } else {
// additionalSettings.toggle()
// // handler.deactivateConnection(model.connectionPath, model.devicePath);
// }
// } else if (predictableWirelessPassword) {
// // passwordDialog.show()
// // wirelessView.hideAllItems()
// additionalSettings.toggle()
// }
}
}
RowLayout {
id: _topItem
anchors.fill: parent
anchors.margins: FishUI.Units.smallSpacing
spacing: FishUI.Units.largeSpacing
Image {
@ -132,47 +154,39 @@ Item {
}
}
}
}
Window {
id: passwordDialog
title: model.itemUniqueName
width: 300
height: mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
minimumWidth: width
minimumHeight: height
maximumHeight: height
maximumWidth: width
flags: Qt.Dialog
modality: Qt.WindowModal
signal accept()
Hideable {
id: additionalSettings
spacing: 0
onVisibleChanged: {
passwordField.text = ""
onShownChanged: {
//
if (!shown) {
passwordField.clear()
} else {
// wirelessView.contentY = control.y
passwordField.forceActiveFocus()
showPasswordCheckbox.checked = false
}
onAccept: {
handler.addAndActivateConnection(model.devicePath, model.specificPath, passwordField.text)
passwordDialog.close()
}
Rectangle {
anchors.fill: parent
color: FishUI.Theme.secondBackgroundColor
Item {
height: FishUI.Units.largeSpacing * 2
}
ColumnLayout {
id: mainLayout
anchors.fill: parent
anchors.margins: FishUI.Units.largeSpacing
//
RowLayout {
visible: predictableWirelessPassword
spacing: FishUI.Units.largeSpacing
Label {
text: qsTr("Password")
}
TextField {
id: passwordField
focus: true
echoMode: showPasswordCheckbox.checked ? TextInput.Normal : TextInput.Password
echoMode: TextInput.Password
selectByMouse: true
placeholderText: qsTr("Password")
validator: RegExpValidator {
@ -182,40 +196,64 @@ Item {
return /^(?:[\x20-\x7F]{8,64}){1}$/;
}
}
onAccepted: passwordDialog.accept()
Keys.onEscapePressed: passwordDialog.close()
onAccepted: connectWithPassword()
Keys.onEscapePressed: additionalSettings.toggle()
Layout.fillWidth: true
}
Item {
height: FishUI.Units.smallSpacing
Button {
text: qsTr("Cancel")
onClicked: additionalSettings.hide()
}
CheckBox {
id: showPasswordCheckbox
checked: false
text: qsTr("Show password")
Button {
text: qsTr("Connect")
flat: true
enabled: passwordField.acceptableInput
onClicked: connectWithPassword()
}
Item {
height: FishUI.Units.largeSpacing
}
RowLayout {
Button {
text: qsTr("Cancel")
Layout.fillWidth: true
onClicked: passwordDialog.close()
}
visible: !predictableWirelessPassword
Button {
visible: (model.uuid || !predictableWirelessPassword) && connectionState === NM.Enums.Deactivated
text: qsTr("Connect")
enabled: passwordField.acceptableInput
Layout.fillWidth: true
flat: true
onClicked: passwordDialog.accept()
onClicked: {
if (!predictableWirelessPassword && !model.uuid) {
handler.addAndActivateConnection(model.devicePath, model.specificPath)
} else {
handler.activateConnection(model.connectionPath, model.devicePath, model.specificPath)
}
}
}
Button {
visible: connectionState === NM.Enums.Activated
text: qsTr("Disconnect")
onClicked: {
handler.deactivateConnection(model.connectionPath, model.devicePath)
}
}
}
Item {
height: FishUI.Units.smallSpacing
}
HorizontalDivider {}
}
}
function connectWithPassword() {
handler.addAndActivateConnection(model.devicePath, model.specificPath, passwordField.text)
}
function hideAdditional() {
additionalSettings.hide()
}
}

@ -73,7 +73,7 @@ ColumnLayout {
sourceModel: connectionModel
}
spacing: FishUI.Units.largeSpacing
spacing: 0
interactive: false
visible: count > 0
@ -81,7 +81,13 @@ ColumnLayout {
delegate: WifiItem {
width: ListView.view.width
height: ListView.view.itemHeight
// height: ListView.view.itemHeight
}
function hideAllItems() {
for (var i = 0; i < wirelessView.count; ++i) {
wirelessView.itemAtIndex(i).hideAdditional()
}
}
}
}

@ -390,44 +390,44 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="100"/>
<location filename="../src/qml/User/Main.qml" line="101"/>
<source>Add new user</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="109"/>
<location filename="../src/qml/User/Main.qml" line="115"/>
<location filename="../src/qml/User/Main.qml" line="110"/>
<location filename="../src/qml/User/Main.qml" line="116"/>
<source>User name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="135"/>
<location filename="../src/qml/User/Main.qml" line="141"/>
<location filename="../src/qml/User/Main.qml" line="136"/>
<location filename="../src/qml/User/Main.qml" line="142"/>
<source>Verify password</source>
<translation type="unfinished">Verify password</translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="148"/>
<location filename="../src/qml/User/Main.qml" line="149"/>
<source>Account type</source>
<translation type="unfinished">Account type</translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="154"/>
<location filename="../src/qml/User/Main.qml" line="155"/>
<source>Standard</source>
<translation type="unfinished">Standard</translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="154"/>
<location filename="../src/qml/User/Main.qml" line="155"/>
<source>Administrator</source>
<translation type="unfinished">Administrator</translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="167"/>
<location filename="../src/qml/User/Main.qml" line="168"/>
<source>Cancel</source>
<translation type="unfinished">Cancel</translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="177"/>
<location filename="../src/qml/User/Main.qml" line="178"/>
<source>Add</source>
<translation type="unfinished">Add</translation>
</message>
@ -521,8 +521,8 @@
</message>
<message>
<location filename="../src/qml/Hotspot/Main.qml" line="113"/>
<location filename="../src/qml/User/Main.qml" line="122"/>
<location filename="../src/qml/User/Main.qml" line="128"/>
<location filename="../src/qml/User/Main.qml" line="123"/>
<location filename="../src/qml/User/Main.qml" line="129"/>
<source>Password</source>
<translation type="unfinished">Password</translation>
</message>
@ -793,25 +793,27 @@
<context>
<name>WifiItem</name>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="177"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="183"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="191"/>
<source>Password</source>
<translation type="unfinished">Password</translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="197"/>
<source>Show password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="206"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="205"/>
<source>Cancel</source>
<translation type="unfinished">Cancel</translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="212"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="210"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="222"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="236"/>
<source>Disconnect</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WifiView</name>

@ -390,44 +390,44 @@
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="100"/>
<location filename="../src/qml/User/Main.qml" line="101"/>
<source>Add new user</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="109"/>
<location filename="../src/qml/User/Main.qml" line="115"/>
<location filename="../src/qml/User/Main.qml" line="110"/>
<location filename="../src/qml/User/Main.qml" line="116"/>
<source>User name</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="135"/>
<location filename="../src/qml/User/Main.qml" line="141"/>
<location filename="../src/qml/User/Main.qml" line="136"/>
<location filename="../src/qml/User/Main.qml" line="142"/>
<source>Verify password</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="148"/>
<location filename="../src/qml/User/Main.qml" line="149"/>
<source>Account type</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="154"/>
<location filename="../src/qml/User/Main.qml" line="155"/>
<source>Standard</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="154"/>
<location filename="../src/qml/User/Main.qml" line="155"/>
<source>Administrator</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="167"/>
<location filename="../src/qml/User/Main.qml" line="168"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/Main.qml" line="177"/>
<location filename="../src/qml/User/Main.qml" line="178"/>
<source>Add</source>
<translation></translation>
</message>
@ -521,8 +521,8 @@
</message>
<message>
<location filename="../src/qml/Hotspot/Main.qml" line="113"/>
<location filename="../src/qml/User/Main.qml" line="122"/>
<location filename="../src/qml/User/Main.qml" line="128"/>
<location filename="../src/qml/User/Main.qml" line="123"/>
<location filename="../src/qml/User/Main.qml" line="129"/>
<source>Password</source>
<translation></translation>
</message>
@ -793,25 +793,31 @@
<context>
<name>WifiItem</name>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="177"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="183"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="191"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="197"/>
<source>Show password</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="206"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="205"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="212"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="210"/>
<location filename="../src/qml/WLAN/WifiItem.qml" line="222"/>
<source>Connect</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/WLAN/WifiItem.qml" line="236"/>
<source>Disconnect</source>
<translation></translation>
</message>
</context>
<context>
<name>WifiView</name>

Loading…
Cancel
Save