|
|
|
|
@ -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()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|