tray: wireless password displays errors and resets
This commit is contained in:
parent
f617c15d88
commit
1e4e00dd82
1 changed files with 49 additions and 24 deletions
|
|
@ -183,14 +183,17 @@ ColumnLayout {
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.topMargin: Appearance.spacing.small
|
Layout.topMargin: Appearance.spacing.small
|
||||||
visible: connectButton.connecting
|
visible: connectButton.connecting || connectButton.hasError
|
||||||
text: {
|
text: {
|
||||||
|
if (connectButton.hasError) {
|
||||||
|
return qsTr("Connection failed. Please check your password and try again.");
|
||||||
|
}
|
||||||
if (connectButton.connecting) {
|
if (connectButton.connecting) {
|
||||||
return qsTr("Connecting...");
|
return qsTr("Connecting...");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
color: Colours.palette.m3onSurfaceVariant
|
color: connectButton.hasError ? Colours.palette.m3error : Colours.palette.m3onSurfaceVariant
|
||||||
font.pointSize: Appearance.font.size.small
|
font.pointSize: Appearance.font.size.small
|
||||||
font.weight: 400
|
font.weight: 400
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|
@ -215,6 +218,11 @@ ColumnLayout {
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear error when user starts typing
|
||||||
|
if (connectButton.hasError && event.text && event.text.length > 0) {
|
||||||
|
connectButton.hasError = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||||
if (connectButton.enabled) {
|
if (connectButton.enabled) {
|
||||||
connectButton.clicked();
|
connectButton.clicked();
|
||||||
|
|
@ -241,6 +249,7 @@ ColumnLayout {
|
||||||
passwordContainer.forceActiveFocus();
|
passwordContainer.forceActiveFocus();
|
||||||
}, 50);
|
}, 50);
|
||||||
passwordContainer.passwordBuffer = "";
|
passwordContainer.passwordBuffer = "";
|
||||||
|
connectButton.hasError = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -259,10 +268,16 @@ ColumnLayout {
|
||||||
color: passwordContainer.activeFocus
|
color: passwordContainer.activeFocus
|
||||||
? Qt.lighter(Colours.tPalette.m3surfaceContainer, 1.05)
|
? Qt.lighter(Colours.tPalette.m3surfaceContainer, 1.05)
|
||||||
: Colours.tPalette.m3surfaceContainer
|
: Colours.tPalette.m3surfaceContainer
|
||||||
border.width: passwordContainer.activeFocus ? 4 : (root.shouldBeVisible ? 1 : 0)
|
border.width: passwordContainer.activeFocus || connectButton.hasError ? 4 : (root.shouldBeVisible ? 1 : 0)
|
||||||
border.color: passwordContainer.activeFocus
|
border.color: {
|
||||||
? Colours.palette.m3primary
|
if (connectButton.hasError) {
|
||||||
: (root.shouldBeVisible ? Colours.palette.m3outline : "transparent")
|
return Colours.palette.m3error;
|
||||||
|
}
|
||||||
|
if (passwordContainer.activeFocus) {
|
||||||
|
return Colours.palette.m3primary;
|
||||||
|
}
|
||||||
|
return root.shouldBeVisible ? Colours.palette.m3outline : "transparent";
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on border.color {
|
Behavior on border.color {
|
||||||
CAnim {}
|
CAnim {}
|
||||||
|
|
@ -409,6 +424,7 @@ ColumnLayout {
|
||||||
enabled: passwordContainer.passwordBuffer.length > 0 && !connecting
|
enabled: passwordContainer.passwordBuffer.length > 0 && !connecting
|
||||||
|
|
||||||
property bool connecting: false
|
property bool connecting: false
|
||||||
|
property bool hasError: false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!root.network || connecting) {
|
if (!root.network || connecting) {
|
||||||
|
|
@ -420,6 +436,9 @@ ColumnLayout {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear any previous error
|
||||||
|
hasError = false;
|
||||||
|
|
||||||
// Set connecting state
|
// Set connecting state
|
||||||
connecting = true;
|
connecting = true;
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
@ -437,19 +456,26 @@ ColumnLayout {
|
||||||
// Shouldn't happen since we provided password
|
// Shouldn't happen since we provided password
|
||||||
connectionMonitor.stop();
|
connectionMonitor.stop();
|
||||||
connecting = false;
|
connecting = false;
|
||||||
|
hasError = true;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
text = qsTr("Connect");
|
text = qsTr("Connect");
|
||||||
|
passwordContainer.passwordBuffer = "";
|
||||||
|
// Delete the failed connection
|
||||||
|
if (root.network && root.network.ssid) {
|
||||||
|
Nmcli.forgetNetwork(root.network.ssid, () => {});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Connection failed immediately - return to network popout
|
// Connection failed immediately - show error
|
||||||
connectionMonitor.stop();
|
connectionMonitor.stop();
|
||||||
connecting = false;
|
connecting = false;
|
||||||
|
hasError = true;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
text = qsTr("Connect");
|
text = qsTr("Connect");
|
||||||
Qt.callLater(() => {
|
passwordContainer.passwordBuffer = "";
|
||||||
if (root.wrapper.currentName === "wirelesspassword") {
|
// Delete the failed connection
|
||||||
root.wrapper.currentName = "network";
|
if (root.network && root.network.ssid) {
|
||||||
}
|
Nmcli.forgetNetwork(root.network.ssid, () => {});
|
||||||
}, 500);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -498,14 +524,14 @@ ColumnLayout {
|
||||||
if (connectionMonitor.repeatCount > 10) {
|
if (connectionMonitor.repeatCount > 10) {
|
||||||
connectionMonitor.stop();
|
connectionMonitor.stop();
|
||||||
connectButton.connecting = false;
|
connectButton.connecting = false;
|
||||||
|
connectButton.hasError = true;
|
||||||
connectButton.enabled = true;
|
connectButton.enabled = true;
|
||||||
connectButton.text = qsTr("Connect");
|
connectButton.text = qsTr("Connect");
|
||||||
// Return to network popout on timeout failure
|
passwordContainer.passwordBuffer = "";
|
||||||
Qt.callLater(() => {
|
// Delete the failed connection
|
||||||
if (root.wrapper.currentName === "wirelesspassword") {
|
if (root.network && root.network.ssid) {
|
||||||
root.wrapper.currentName = "network";
|
Nmcli.forgetNetwork(root.network.ssid, () => {});
|
||||||
}
|
}
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -540,14 +566,12 @@ ColumnLayout {
|
||||||
if (root.shouldBeVisible && root.network && root.network.ssid === ssid && connectButton.connecting) {
|
if (root.shouldBeVisible && root.network && root.network.ssid === ssid && connectButton.connecting) {
|
||||||
connectionMonitor.stop();
|
connectionMonitor.stop();
|
||||||
connectButton.connecting = false;
|
connectButton.connecting = false;
|
||||||
|
connectButton.hasError = true;
|
||||||
connectButton.enabled = true;
|
connectButton.enabled = true;
|
||||||
connectButton.text = qsTr("Connect");
|
connectButton.text = qsTr("Connect");
|
||||||
// Return to network popout on connection failure
|
passwordContainer.passwordBuffer = "";
|
||||||
Qt.callLater(() => {
|
// Delete the failed connection
|
||||||
if (root.wrapper.currentName === "wirelesspassword") {
|
Nmcli.forgetNetwork(ssid, () => {});
|
||||||
root.wrapper.currentName = "network";
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -560,6 +584,7 @@ ColumnLayout {
|
||||||
isClosing = true;
|
isClosing = true;
|
||||||
passwordContainer.passwordBuffer = "";
|
passwordContainer.passwordBuffer = "";
|
||||||
connectButton.connecting = false;
|
connectButton.connecting = false;
|
||||||
|
connectButton.hasError = false;
|
||||||
connectButton.text = qsTr("Connect");
|
connectButton.text = qsTr("Connect");
|
||||||
connectionMonitor.stop();
|
connectionMonitor.stop();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue