Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions default/i18n/en/shell.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
"network.forgetting": "Forgetting…",
"network.gateway": "Gateway",
"network.hidden": "Hidden",
"network.hidePassphrase": "Hide passphrase",
"network.identity": "Identity (user@domain)",
"network.ipAddress": "IP Address",
"network.knownNetworks": "KNOWN NETWORKS",
Expand Down Expand Up @@ -381,6 +382,7 @@
"network.sending": "Sending",
"network.setCustomDns": "Set custom DNS servers",
"network.setDnsTo": "Set DNS to %1",
"network.showPassphrase": "Show passphrase",
"network.showQrCode": "Show QR code",
"network.signInRequired": "Sign-in required",
"network.signInRequiredHeader": "SIGN-IN REQUIRED",
Expand Down
32 changes: 29 additions & 3 deletions shell/plugins/panels/network/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ Panel {
property string passwordSsid: ""
property string passwordText: ""
property string identityText: ""
// Eye toggle on the passphrase field. Resets whenever the prompt moves or
// closes so a revealed passphrase never carries over to another network.
property bool passwordRevealed: false

// ConnectionFailReason values as a plain object, so Model.js helpers stay
// pure JS and Node-testable.
Expand Down Expand Up @@ -355,6 +358,7 @@ Panel {
// The KeyboardPanel's focusTarget covers initial popup-open; this handles
// the inline-editor case where focus was handed off to a child.
onPasswordSsidChanged: {
passwordRevealed = false
if (passwordSsid === "" && opened) {
passwordText = ""
Qt.callLater(function() { if (panel.loadedContent) panel.loadedContent.forceActiveFocus() })
Expand Down Expand Up @@ -2023,7 +2027,7 @@ Panel {
id: idField
visible: row.isEnterprise && !row.isBusy && !row.isFailed
anchors.left: parent.left
anchors.right: connectPwBtn.left
anchors.right: revealPwBtn.left
anchors.top: parent.top
anchors.rightMargin: Style.space(6)
placeholderText: Commons.I18n.t("network.identity")
Expand All @@ -2047,11 +2051,14 @@ Panel {
id: pwField
visible: !row.isBusy && !row.isFailed
anchors.left: parent.left
anchors.right: connectPwBtn.left
anchors.right: revealPwBtn.left
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.spacing.rowGap / 2
anchors.rightMargin: Style.space(6)
password: true
password: !root.passwordRevealed
// Qt only asks the input method not to learn or predict what's typed
// while the text is masked, so keep asking once it is revealed.
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
placeholderText: Commons.I18n.t("network.passphrase")
font.family: Style.font.family
font.pixelSize: Style.font.body
Expand Down Expand Up @@ -2092,6 +2099,25 @@ Panel {
}
}

// Shows the passphrase in plain text so typos are visible before
// connecting. Clicking doesn't take focus from pwField, but hand it
// back anyway so typing continues after the toggle.
PanelActionButton {
id: revealPwBtn
visible: pwField.visible
anchors.right: connectPwBtn.left
anchors.verticalCenter: pwField.verticalCenter
anchors.rightMargin: Style.space(2)
iconText: root.passwordRevealed ? "󰈉" : "󰈈"
tooltipText: root.passwordRevealed ? Commons.I18n.t("network.hidePassphrase") : Commons.I18n.t("network.showPassphrase")
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
onClicked: {
root.passwordRevealed = !root.passwordRevealed
pwField.forceActiveFocus()
}
}

// 22×22 right-anchored to line up with lockIndicator above. Esc closes
// the prompt (handled by pwField.Keys.onEscapePressed)
// so there's no separate cancel button.
Expand Down
10 changes: 10 additions & 0 deletions test/shell.d/network-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ assert(
)
assert(!/disconnect\(\s*(root\.)?networkForSsid\(/.test(panelSource), 'network never passes an unguarded networkForSsid() lookup to disconnect()')

// The eye toggle reveals the passphrase to catch typos, but the reveal must
// not outlive the prompt: moving to another network or closing re-masks it.
assert(/id: pwField[\s\S]*?password: !root\.passwordRevealed/.test(panelSource), 'network masks the passphrase unless the user reveals it')
assert(/id: revealPwBtn[\s\S]*?root\.passwordRevealed = !root\.passwordRevealed/.test(panelSource), 'network toggles passphrase visibility from the eye button')
assert(/onPasswordSsidChanged: \{\s*passwordRevealed = false/.test(panelSource), 'network re-masks the passphrase whenever the prompt moves or closes')
// Qt drops its "don't learn this" input method hints along with the mask.
assert(/id: pwField[\s\S]*?inputMethodHints: Qt\.ImhSensitiveData \| Qt\.ImhNoPredictiveText \| Qt\.ImhNoAutoUppercase/.test(panelSource), 'network keeps the input method from learning a revealed passphrase')
// The tooltips go through the catalog like every other panel string.
assert(/id: revealPwBtn[\s\S]*?tooltipText: root\.passwordRevealed \? Commons\.I18n\.t\("network\.hidePassphrase"\) : Commons\.I18n\.t\("network\.showPassphrase"\)/.test(panelSource), 'network translates the passphrase reveal tooltips')

assertDeepEqual(
network.parseNetworkStatus('wifi\tCafe WiFi\t78\t5200\n'),
{ kind: 'wifi', label: 'Cafe WiFi', signalStrength: 78, frequency: '5200' },
Expand Down