mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
network: support hidden SSIDs
This commit is contained in:
@@ -11,6 +11,7 @@ FloatingWindow {
|
||||
property string wifiPasswordInput: ""
|
||||
property string wifiUsernameInput: ""
|
||||
property bool requiresEnterprise: false
|
||||
property bool isHiddenNetwork: false
|
||||
|
||||
property string wifiAnonymousIdentityInput: ""
|
||||
property string wifiDomainInput: ""
|
||||
@@ -44,6 +45,8 @@ FloatingWindow {
|
||||
property int calculatedHeight: {
|
||||
let h = headerHeight + buttonRowHeight + Theme.spacingL * 2;
|
||||
h += fieldsInfo.length * inputFieldWithSpacing;
|
||||
if (isHiddenNetwork)
|
||||
h += inputFieldWithSpacing;
|
||||
if (showUsernameField)
|
||||
h += inputFieldWithSpacing;
|
||||
if (showPasswordField)
|
||||
@@ -68,6 +71,10 @@ FloatingWindow {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isHiddenNetwork) {
|
||||
ssidInput.forceActiveFocus();
|
||||
return;
|
||||
}
|
||||
if (requiresEnterprise && !isVpnPrompt) {
|
||||
usernameInput.forceActiveFocus();
|
||||
return;
|
||||
@@ -82,6 +89,7 @@ FloatingWindow {
|
||||
wifiAnonymousIdentityInput = "";
|
||||
wifiDomainInput = "";
|
||||
isPromptMode = false;
|
||||
isHiddenNetwork = false;
|
||||
promptToken = "";
|
||||
promptReason = "";
|
||||
promptFields = [];
|
||||
@@ -100,6 +108,30 @@ FloatingWindow {
|
||||
Qt.callLater(focusFirstField);
|
||||
}
|
||||
|
||||
function showHidden() {
|
||||
wifiPasswordSSID = "";
|
||||
wifiPasswordInput = "";
|
||||
wifiUsernameInput = "";
|
||||
wifiAnonymousIdentityInput = "";
|
||||
wifiDomainInput = "";
|
||||
isPromptMode = false;
|
||||
isHiddenNetwork = true;
|
||||
promptToken = "";
|
||||
promptReason = "";
|
||||
promptFields = [];
|
||||
promptSetting = "";
|
||||
isVpnPrompt = false;
|
||||
connectionName = "";
|
||||
vpnServiceType = "";
|
||||
connectionType = "";
|
||||
fieldsInfo = [];
|
||||
secretValues = {};
|
||||
requiresEnterprise = false;
|
||||
|
||||
visible = true;
|
||||
Qt.callLater(focusFirstField);
|
||||
}
|
||||
|
||||
function showFromPrompt(token, ssid, setting, fields, hints, reason, connType, connName, vpnService, fInfo) {
|
||||
isPromptMode = true;
|
||||
promptToken = token;
|
||||
@@ -184,8 +216,9 @@ FloatingWindow {
|
||||
}
|
||||
NetworkService.submitCredentials(promptToken, secrets, savePasswordCheckbox.checked);
|
||||
} else {
|
||||
const ssid = isHiddenNetwork ? ssidInput.text : wifiPasswordSSID;
|
||||
const username = requiresEnterprise ? usernameInput.text : "";
|
||||
NetworkService.connectToWifi(wifiPasswordSSID, passwordInput.text, username, wifiAnonymousIdentityInput, wifiDomainInput);
|
||||
NetworkService.connectToWifi(ssid, passwordInput.text, username, wifiAnonymousIdentityInput, wifiDomainInput, isHiddenNetwork);
|
||||
}
|
||||
|
||||
hide();
|
||||
@@ -196,6 +229,8 @@ FloatingWindow {
|
||||
passwordInput.text = "";
|
||||
if (requiresEnterprise)
|
||||
usernameInput.text = "";
|
||||
if (isHiddenNetwork)
|
||||
ssidInput.text = "";
|
||||
}
|
||||
|
||||
function clearAndClose() {
|
||||
@@ -215,6 +250,8 @@ FloatingWindow {
|
||||
return I18n.tr("Smartcard PIN");
|
||||
if (isVpnPrompt)
|
||||
return I18n.tr("VPN Password");
|
||||
if (isHiddenNetwork)
|
||||
return I18n.tr("Hidden Network");
|
||||
return I18n.tr("Wi-Fi Password");
|
||||
}
|
||||
minimumSize: Qt.size(420, calculatedHeight)
|
||||
@@ -236,6 +273,7 @@ FloatingWindow {
|
||||
usernameInput.text = "";
|
||||
anonInput.text = "";
|
||||
domainMatchInput.text = "";
|
||||
ssidInput.text = "";
|
||||
for (var i = 0; i < dynamicFieldsRepeater.count; i++) {
|
||||
const item = dynamicFieldsRepeater.itemAt(i);
|
||||
if (item?.children[0])
|
||||
@@ -296,6 +334,8 @@ FloatingWindow {
|
||||
return I18n.tr("Smartcard Authentication");
|
||||
if (isVpnPrompt)
|
||||
return I18n.tr("Connect to VPN");
|
||||
if (isHiddenNetwork)
|
||||
return I18n.tr("Connect to Hidden Network");
|
||||
return I18n.tr("Connect to Wi-Fi");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
@@ -315,6 +355,8 @@ FloatingWindow {
|
||||
return I18n.tr("Enter credentials for ") + wifiPasswordSSID;
|
||||
if (isVpnPrompt)
|
||||
return I18n.tr("Enter password for ") + wifiPasswordSSID;
|
||||
if (isHiddenNetwork)
|
||||
return I18n.tr("Enter network name and password");
|
||||
const prefix = requiresEnterprise ? I18n.tr("Enter credentials for ") : I18n.tr("Enter password for ");
|
||||
return prefix + wifiPasswordSSID;
|
||||
}
|
||||
@@ -357,6 +399,34 @@ FloatingWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: inputFieldHeight
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceHover
|
||||
border.color: ssidInput.activeFocus ? Theme.primary : Theme.outlineStrong
|
||||
border.width: ssidInput.activeFocus ? 2 : 1
|
||||
visible: isHiddenNetwork
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: ssidInput.forceActiveFocus()
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: ssidInput
|
||||
|
||||
anchors.fill: parent
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
textColor: Theme.surfaceText
|
||||
placeholderText: I18n.tr("Network Name (SSID)")
|
||||
backgroundColor: "transparent"
|
||||
enabled: root.visible
|
||||
keyNavigationTab: passwordInput
|
||||
onAccepted: passwordInput.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: dynamicFieldsRepeater
|
||||
model: fieldsInfo
|
||||
@@ -696,6 +766,8 @@ FloatingWindow {
|
||||
}
|
||||
if (isVpnPrompt)
|
||||
return passwordInput.text.length > 0;
|
||||
if (isHiddenNetwork)
|
||||
return ssidInput.text.length > 0;
|
||||
return requiresEnterprise ? (usernameInput.text.length > 0 && passwordInput.text.length > 0) : passwordInput.text.length > 0;
|
||||
}
|
||||
opacity: enabled ? 1 : 0.5
|
||||
|
||||
@@ -768,6 +768,13 @@ Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankActionButton {
|
||||
iconName: "wifi_find"
|
||||
buttonSize: 32
|
||||
visible: NetworkService.backend === "networkmanager" && NetworkService.wifiEnabled && !NetworkService.wifiToggling
|
||||
onClicked: PopoutService.showHiddenNetworkModal()
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
iconName: "refresh"
|
||||
buttonSize: 32
|
||||
@@ -1102,6 +1109,14 @@ Item {
|
||||
visible: isPinned
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
name: "visibility_off"
|
||||
size: 14
|
||||
color: Theme.surfaceVariantText
|
||||
visible: modelData.hidden || false
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -1127,6 +1142,20 @@ Item {
|
||||
visible: modelData.saved
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "•"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
visible: modelData.hidden || false
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Hidden")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
visible: modelData.hidden || false
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "•"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
|
||||
@@ -413,7 +413,7 @@ Singleton {
|
||||
scanWifi();
|
||||
}
|
||||
|
||||
function connectToWifi(ssid, password = "", username = "", anonymousIdentity = "", domainSuffixMatch = "") {
|
||||
function connectToWifi(ssid, password = "", username = "", anonymousIdentity = "", domainSuffixMatch = "", hidden = false) {
|
||||
if (!networkAvailable || isConnecting)
|
||||
return;
|
||||
pendingConnectionSSID = ssid;
|
||||
@@ -427,6 +427,8 @@ Singleton {
|
||||
};
|
||||
if (effectiveWifiDevice)
|
||||
params.device = effectiveWifiDevice;
|
||||
if (hidden)
|
||||
params.hidden = true;
|
||||
|
||||
if (DMSService.apiVersion >= 7) {
|
||||
if (password || username) {
|
||||
@@ -611,8 +613,8 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function connectToWifiAndSetPreference(ssid, password, username = "", anonymousIdentity = "", domainSuffixMatch = "") {
|
||||
connectToWifi(ssid, password, username, anonymousIdentity, domainSuffixMatch);
|
||||
function connectToWifiAndSetPreference(ssid, password, username = "", anonymousIdentity = "", domainSuffixMatch = "", hidden = false) {
|
||||
connectToWifi(ssid, password, username, anonymousIdentity, domainSuffixMatch, hidden);
|
||||
setNetworkPreference("wifi");
|
||||
}
|
||||
|
||||
|
||||
@@ -415,8 +415,12 @@ Singleton {
|
||||
notificationModal?.close();
|
||||
}
|
||||
|
||||
function showWifiPasswordModal() {
|
||||
wifiPasswordModal?.show();
|
||||
function showWifiPasswordModal(ssid) {
|
||||
wifiPasswordModal?.show(ssid);
|
||||
}
|
||||
|
||||
function showHiddenNetworkModal() {
|
||||
wifiPasswordModal?.showHidden();
|
||||
}
|
||||
|
||||
function hideWifiPasswordModal() {
|
||||
|
||||
Reference in New Issue
Block a user