mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
feat(network): initial WiFi hotspot support (#2825)
* Add hotspot contract layer with capability-gated dispatch. Establish the interface and manager plumbing for hotspot support so backends can opt in without expanding the core Backend contract. Only backends that implement HotspotBackend get hotspot state propagated; others are forced to unsupported regardless of what they self-report. * Add IPC handlers and API docs for hotspot actions. Wire up configure/ start/ stop hotspot through the request router so the QML service layer can drive hotspot operations. Bump API version to 27 and document the capability-gating contract clients should follow. * Implement NetworkManager hotspot backend. Implement HotspotBackend on NetworkManagerBackend with DMS-owned profile management, AP capability detection, and band validation. Device resolution is deferred to StartHotspot when no device is specified, so profiles survive hardware changes. * Isolate client Wi-Fi state from AP-mode connections. Filter AP-mode profiles and access points out of all client Wi-Fi paths so the DMS hotspot (and user-created APs) never appear as saved networks, visible networks, or connected state. This protects existing client behavior before hotspot controls are exposed in the UI. * Prefer idle radios for automatic hotspot device selection. * Add hotspot properties and methods to QML service layer. Expose hotspot state and actions through DMSNetworkService, NetworkService, and LegacyNetworkService. Capability is gated on API version and backend-reported support, not backend name checks, and stays stable when Wi-Fi radio is disabled. * Add hotspot controls to Settings and Control Center. Settings shows a hotspot setup card as a sibling in the Wi-Fi tab with SSID, password, device, band, save, and start/ stop controls. Control Center shows a compact row that toggles a configured hotspot or routes to Settings for initial setup. Both stay visible when Wi-Fi is disabled, explaining the requirement instead of hiding. * Add translator context to hotspot strings.
This commit is contained in:
@@ -6,6 +6,7 @@ import qs.Modules.Network
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
import qs.Modals
|
||||
import qs.Modals.Common
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
@@ -17,10 +18,10 @@ Rectangle {
|
||||
if (height > 0)
|
||||
return height;
|
||||
if (NetworkService.wifiToggling)
|
||||
return headerRow.height + wifiToggleContent.height + Theme.spacingM;
|
||||
return headerRow.height + hotspotContentHeight + wifiToggleContent.height + Theme.spacingM;
|
||||
if (NetworkService.wifiEnabled)
|
||||
return headerRow.height + wifiContent.height + Theme.spacingM;
|
||||
return headerRow.height + wifiOffContent.height + Theme.spacingM;
|
||||
return headerRow.height + hotspotContentHeight + wifiContent.height + Theme.spacingM;
|
||||
return headerRow.height + hotspotContentHeight + wifiOffContent.height + Theme.spacingM;
|
||||
}
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.nestedSurface
|
||||
@@ -39,6 +40,31 @@ Rectangle {
|
||||
property bool hasWifiAvailable: (NetworkService.wifiDevices?.length ?? 0) > 0
|
||||
property bool hasBothConnectionTypes: hasEthernetAvailable && hasWifiAvailable
|
||||
property int maxPinnedNetworks: 3
|
||||
readonly property int hotspotContentHeight: currentPreferenceIndex === 1 && NetworkService.hotspotAvailable ? 56 + Theme.spacingS : 0
|
||||
|
||||
property var hotspotStartConfirm: ConfirmModal {}
|
||||
|
||||
function explainHotspotNeedsWiFi() {
|
||||
ToastService.showError(I18n.tr("WiFi is disabled", "hotspot start error title"), I18n.tr("Enable WiFi before starting the hotspot.", "hotspot WiFi requirement message"));
|
||||
}
|
||||
|
||||
function startHotspotWithConfirm() {
|
||||
if (!NetworkService.hotspotWouldDisconnectWifi) {
|
||||
NetworkService.startHotspot();
|
||||
return;
|
||||
}
|
||||
hotspotStartConfirm.showWithOptions({
|
||||
title: I18n.tr("Start Hotspot?", "hotspot start confirmation title"),
|
||||
message: I18n.tr("This will disconnect WiFi from \"%1\" — the radio can't host a hotspot and stay connected at the same time. Internet sharing will need another connection, such as Ethernet.", "hotspot WiFi disconnection confirmation message").arg(NetworkService.currentWifiSSID),
|
||||
confirmText: I18n.tr("Start", "hotspot start confirmation action"),
|
||||
onConfirm: () => NetworkService.startHotspot()
|
||||
});
|
||||
}
|
||||
|
||||
function openHotspotSettings() {
|
||||
PopoutService.closeControlCenter();
|
||||
PopoutService.openSettingsWithTab("network_wifi");
|
||||
}
|
||||
|
||||
function normalizePinList(value) {
|
||||
if (Array.isArray(value))
|
||||
@@ -159,12 +185,183 @@ Rectangle {
|
||||
}
|
||||
|
||||
Item {
|
||||
id: wifiToggleContent
|
||||
id: hotspotRow
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.hotspotAvailable
|
||||
height: visible ? 56 : 0
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: hotspotMouseArea.containsMouse ? Theme.primaryHoverLight : Theme.surfaceLight
|
||||
border.width: NetworkService.hotspotEnabled ? 2 : 1
|
||||
border.color: NetworkService.hotspotEnabled ? Theme.primary : Theme.outlineLight
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.right: hotspotRightControls.left
|
||||
anchors.rightMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
name: NetworkService.hotspotEnabled ? "wifi_tethering" : "wifi_tethering_off"
|
||||
size: Theme.iconSize - 4
|
||||
color: NetworkService.hotspotEnabled ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Column {
|
||||
id: hotspotTextColumn
|
||||
|
||||
readonly property bool warnsWifiDrop: NetworkService.hotspotConfigured && NetworkService.wifiEnabled && !NetworkService.hotspotBusy && !NetworkService.hotspotActivating && !NetworkService.hotspotEnabled && NetworkService.hotspotWouldDisconnectWifi
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
width: parent.width - Theme.iconSize - Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: NetworkService.hotspotConfigured ? I18n.tr("Hotspot", "hotspot control label") : I18n.tr("Set up hotspot", "hotspot setup action label")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: NetworkService.hotspotEnabled ? Font.Medium : Font.Normal
|
||||
color: NetworkService.hotspotEnabled ? Theme.primary : Theme.surfaceText
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
StyledText {
|
||||
visible: !hotspotTextColumn.warnsWifiDrop
|
||||
text: {
|
||||
if (!NetworkService.hotspotConfigured)
|
||||
return I18n.tr("Set up hotspot in Settings", "unconfigured hotspot status message");
|
||||
if (NetworkService.hotspotBusy || NetworkService.hotspotActivating)
|
||||
return I18n.tr("Starting...", "hotspot activation status");
|
||||
if (NetworkService.hotspotEnabled)
|
||||
return NetworkService.hotspotSSID || I18n.tr("Running", "hotspot active status");
|
||||
if (!NetworkService.wifiEnabled)
|
||||
return I18n.tr("WiFi disabled", "hotspot unavailable status");
|
||||
return NetworkService.hotspotSSID || I18n.tr("Ready", "hotspot ready status");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: NetworkService.hotspotEnabled ? Theme.primary : Theme.surfaceVariantText
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Row {
|
||||
visible: hotspotTextColumn.warnsWifiDrop
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
id: hotspotWarnSsid
|
||||
text: NetworkService.hotspotSSID || I18n.tr("Ready", "hotspot ready status")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
elide: Text.ElideRight
|
||||
width: Math.min(implicitWidth, parent.width / 2)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: hotspotWarnSeparator
|
||||
text: "•"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Will disconnect \"%1\"", "hotspot WiFi disconnection warning").arg(NetworkService.currentWifiSSID)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.warning
|
||||
elide: Text.ElideRight
|
||||
width: Math.max(0, parent.width - hotspotWarnSsid.width - hotspotWarnSeparator.width - Theme.spacingXS * 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: hotspotRightControls
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Setup", "hotspot setup action")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primary
|
||||
visible: !NetworkService.hotspotConfigured
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
name: "chevron_right"
|
||||
size: 20
|
||||
color: Theme.primary
|
||||
visible: !NetworkService.hotspotConfigured
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankSpinner {
|
||||
readonly property bool hotspotWorking: NetworkService.hotspotBusy || NetworkService.hotspotActivating
|
||||
size: 20
|
||||
strokeWidth: 2
|
||||
color: Theme.primary
|
||||
running: hotspotWorking
|
||||
visible: NetworkService.hotspotConfigured && hotspotWorking
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
readonly property bool hotspotWorking: NetworkService.hotspotBusy || NetworkService.hotspotActivating
|
||||
checked: NetworkService.hotspotEnabled
|
||||
enabled: NetworkService.hotspotConfigured && !hotspotWorking
|
||||
visible: NetworkService.hotspotConfigured && !hotspotWorking
|
||||
onToggled: checked => {
|
||||
if (checked) {
|
||||
if (!NetworkService.wifiEnabled) {
|
||||
root.explainHotspotNeedsWiFi();
|
||||
return;
|
||||
}
|
||||
root.startHotspotWithConfirm();
|
||||
} else {
|
||||
NetworkService.stopHotspot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: hotspotRipple
|
||||
cornerRadius: parent.radius
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: hotspotMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: !NetworkService.hotspotConfigured
|
||||
visible: !NetworkService.hotspotConfigured
|
||||
onPressed: mouse => hotspotRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: root.openHotspotSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: wifiToggleContent
|
||||
anchors.top: hotspotRow.visible ? hotspotRow.bottom : headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: hotspotRow.visible ? Theme.spacingS : Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiToggling
|
||||
height: visible ? wifiToggleColumn.implicitHeight + Theme.spacingM * 2 : 0
|
||||
|
||||
@@ -201,11 +398,11 @@ Rectangle {
|
||||
|
||||
Item {
|
||||
id: wifiOffContent
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.top: hotspotRow.visible ? hotspotRow.bottom : headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
anchors.topMargin: hotspotRow.visible ? Theme.spacingS : Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && !NetworkService.wifiEnabled && !NetworkService.wifiToggling
|
||||
height: visible ? wifiOffColumn.implicitHeight + Theme.spacingM * 2 : 0
|
||||
|
||||
@@ -482,12 +679,12 @@ Rectangle {
|
||||
|
||||
Item {
|
||||
id: wifiScanningOverlay
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.top: hotspotRow.visible ? hotspotRow.bottom : headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
anchors.topMargin: hotspotRow.visible ? Theme.spacingS : Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiEnabled && !NetworkService.wifiToggling && NetworkService.wifiInterface && (NetworkService.wifiNetworks?.length ?? 0) < 1 && NetworkService.isScanning
|
||||
|
||||
DankIcon {
|
||||
@@ -509,12 +706,12 @@ Rectangle {
|
||||
|
||||
DankListView {
|
||||
id: wifiContent
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.top: hotspotRow.visible ? hotspotRow.bottom : headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
anchors.topMargin: hotspotRow.visible ? Theme.spacingS : Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiEnabled && !NetworkService.wifiToggling && !wifiScanningOverlay.visible
|
||||
clip: true
|
||||
spacing: Theme.spacingS
|
||||
|
||||
@@ -1263,6 +1263,359 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
id: hotspotCard
|
||||
|
||||
width: parent.width
|
||||
title: I18n.tr("Hotspot", "hotspot settings card title")
|
||||
iconName: "wifi_tethering"
|
||||
settingKey: "networkHotspot"
|
||||
tags: ["wifi", "wi-fi", "wireless", "network", "hotspot", "access point", "sharing", "ssid"]
|
||||
visible: NetworkService.hotspotAvailable
|
||||
|
||||
property string ssid: NetworkService.hotspotSSID || ""
|
||||
property string password: ""
|
||||
property string device: NetworkService.hotspotDevice || ""
|
||||
property string band: NetworkService.hotspotBand || ""
|
||||
property bool editing: false
|
||||
property bool passwordLoading: false
|
||||
property bool passwordResolved: true
|
||||
property int passwordRequestId: 0
|
||||
property int passwordEditRevision: 0
|
||||
readonly property bool showForm: !NetworkService.hotspotConfigured || editing
|
||||
readonly property bool starting: NetworkService.hotspotBusy || NetworkService.hotspotActivating
|
||||
property var startConfirm: ConfirmModal {}
|
||||
|
||||
function confirmThenStart(targetDevice, targetBand, startFn) {
|
||||
if (!NetworkService.hotspotTargetWouldDisconnectWifi(targetDevice, targetBand)) {
|
||||
startFn();
|
||||
return;
|
||||
}
|
||||
startConfirm.showWithOptions({
|
||||
title: I18n.tr("Start Hotspot?", "hotspot start confirmation title"),
|
||||
message: I18n.tr("This will disconnect WiFi from \"%1\" — the radio can't host a hotspot and stay connected at the same time. Internet sharing will need another connection, such as Ethernet.", "hotspot WiFi disconnection confirmation message").arg(NetworkService.currentWifiSSID),
|
||||
confirmText: I18n.tr("Start", "hotspot start confirmation action"),
|
||||
onConfirm: startFn
|
||||
});
|
||||
}
|
||||
|
||||
function bandLabel(value) {
|
||||
switch (value) {
|
||||
case "bg":
|
||||
return I18n.tr("2.4 GHz", "hotspot WiFi band option");
|
||||
case "a":
|
||||
return I18n.tr("5 GHz", "hotspot WiFi band option");
|
||||
default:
|
||||
return I18n.tr("Auto", "hotspot device or band option");
|
||||
}
|
||||
}
|
||||
|
||||
function bandValue(label) {
|
||||
if (label === I18n.tr("2.4 GHz", "hotspot WiFi band option"))
|
||||
return "bg";
|
||||
if (label === I18n.tr("5 GHz", "hotspot WiFi band option"))
|
||||
return "a";
|
||||
return "";
|
||||
}
|
||||
|
||||
function syncFromService() {
|
||||
ssid = NetworkService.hotspotSSID || ssid || "";
|
||||
device = NetworkService.hotspotDevice || "";
|
||||
band = NetworkService.hotspotBand || "";
|
||||
}
|
||||
|
||||
function beginEditing() {
|
||||
syncFromService();
|
||||
password = "";
|
||||
editing = true;
|
||||
passwordRequestId++;
|
||||
const requestId = passwordRequestId;
|
||||
const editRevision = passwordEditRevision;
|
||||
passwordLoading = NetworkService.hotspotSecured;
|
||||
passwordResolved = !NetworkService.hotspotSecured;
|
||||
if (NetworkService.hotspotSecured) {
|
||||
NetworkService.getHotspotSecrets(response => {
|
||||
if (!editing || requestId !== passwordRequestId)
|
||||
return;
|
||||
passwordLoading = false;
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Couldn't load hotspot password", "hotspot password error title"), I18n.tr("Re-enter the password before saving.", "hotspot password recovery message"));
|
||||
} else {
|
||||
const storedPassword = response.result?.password ?? response.password ?? "";
|
||||
if (!storedPassword) {
|
||||
ToastService.showError(I18n.tr("Couldn't load hotspot password", "hotspot password error title"), I18n.tr("Re-enter the password before saving.", "hotspot password recovery message"));
|
||||
} else {
|
||||
passwordResolved = true;
|
||||
if (editRevision === passwordEditRevision) {
|
||||
password = storedPassword;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function stopEditing() {
|
||||
passwordRequestId++;
|
||||
editing = false;
|
||||
password = "";
|
||||
passwordLoading = false;
|
||||
passwordResolved = true;
|
||||
}
|
||||
|
||||
function buildCanConfigure() {
|
||||
return ssid.trim().length > 0 && passwordResolved && !passwordLoading && !NetworkService.hotspotBusy && !NetworkService.hotspotEnabled && !NetworkService.hotspotActivating;
|
||||
}
|
||||
|
||||
function explainWiFiDisabled() {
|
||||
ToastService.showError(I18n.tr("WiFi is disabled", "hotspot start error title"), I18n.tr("Enable WiFi before starting the hotspot.", "hotspot WiFi requirement message"));
|
||||
}
|
||||
|
||||
function saveOnly() {
|
||||
if (!buildCanConfigure())
|
||||
return;
|
||||
NetworkService.configureHotspot(ssid.trim(), password, device, band, response => {
|
||||
if (!response.error) {
|
||||
stopEditing();
|
||||
ToastService.showInfo(I18n.tr("Hotspot saved", "hotspot configuration success message"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function startOrStop() {
|
||||
if (NetworkService.hotspotEnabled) {
|
||||
NetworkService.stopHotspot(response => {
|
||||
if (!response.error)
|
||||
ToastService.showInfo(I18n.tr("Hotspot stopped", "hotspot stop success message"));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NetworkService.wifiEnabled) {
|
||||
explainWiFiDisabled();
|
||||
return;
|
||||
}
|
||||
|
||||
if (showForm) {
|
||||
if (!buildCanConfigure())
|
||||
return;
|
||||
confirmThenStart(device, band, () => {
|
||||
NetworkService.configureAndStartHotspot(ssid.trim(), password, device, band, response => {
|
||||
if (!response.error)
|
||||
stopEditing();
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
confirmThenStart(NetworkService.hotspotDevice, NetworkService.hotspotBand, () => NetworkService.startHotspot());
|
||||
}
|
||||
|
||||
onVisibleChanged: if (visible)
|
||||
syncFromService()
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: {
|
||||
if (NetworkService.hotspotEnabled)
|
||||
return I18n.tr("Your hotspot is running.", "hotspot active status message");
|
||||
if (hotspotCard.starting)
|
||||
return I18n.tr("Starting hotspot...", "hotspot activation status message");
|
||||
if (NetworkService.hotspotConfigured)
|
||||
return I18n.tr("Your hotspot profile is saved and ready to start.", "configured hotspot status message");
|
||||
return I18n.tr("Set up a WiFi hotspot for sharing this connection.", "unconfigured hotspot description");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: NetworkService.hotspotEnabled ? Theme.primary : Theme.surfaceVariantText
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: I18n.tr("WiFi is disabled. You can still edit and save hotspot settings, but starting the hotspot requires WiFi to be enabled.", "hotspot WiFi requirement explanation")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.warning
|
||||
wrapMode: Text.WordWrap
|
||||
visible: !NetworkService.wifiEnabled
|
||||
}
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: I18n.tr("Starting the hotspot will disconnect WiFi from \"%1\" — the radio can't do both at once. Sharing internet then requires another connection, such as Ethernet.", "hotspot WiFi disconnection warning").arg(NetworkService.currentWifiSSID)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.warning
|
||||
wrapMode: Text.WordWrap
|
||||
visible: NetworkService.wifiEnabled && !NetworkService.hotspotEnabled && !hotspotCard.starting && (hotspotCard.showForm ? NetworkService.hotspotTargetWouldDisconnectWifi(hotspotCard.device, hotspotCard.band) : NetworkService.hotspotWouldDisconnectWifi)
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
visible: !hotspotCard.showForm
|
||||
|
||||
DankIcon {
|
||||
name: NetworkService.hotspotEnabled ? "wifi_tethering" : "wifi_tethering_off"
|
||||
size: Theme.iconSize
|
||||
color: NetworkService.hotspotEnabled ? Theme.primary : Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - Theme.iconSize - Theme.spacingM
|
||||
spacing: 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: NetworkService.hotspotSSID
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: {
|
||||
const parts = [NetworkService.hotspotSecured ? I18n.tr("WPA2 password", "hotspot security summary") : I18n.tr("Open network", "hotspot security summary"), hotspotCard.bandLabel(NetworkService.hotspotBand)];
|
||||
if (NetworkService.hotspotDevice)
|
||||
parts.push(NetworkService.hotspotDevice);
|
||||
return parts.join(" • ");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
visible: hotspotCard.showForm
|
||||
|
||||
DankTextField {
|
||||
width: parent.width
|
||||
labelText: I18n.tr("Hotspot name", "hotspot SSID field label")
|
||||
placeholderText: I18n.tr("SSID", "hotspot network name placeholder")
|
||||
text: hotspotCard.ssid
|
||||
leftIconName: "badge"
|
||||
showClearButton: true
|
||||
onTextEdited: hotspotCard.ssid = text
|
||||
onAccepted: hotspotCard.saveOnly()
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
width: parent.width
|
||||
labelText: I18n.tr("Password", "hotspot password field label")
|
||||
placeholderText: I18n.tr("Optional; leave blank for open hotspot", "hotspot password field placeholder")
|
||||
text: hotspotCard.password
|
||||
leftIconName: "key"
|
||||
showPasswordToggle: true
|
||||
echoMode: passwordVisible ? TextInput.Normal : TextInput.Password
|
||||
onTextEdited: {
|
||||
hotspotCard.password = text;
|
||||
hotspotCard.passwordEditRevision++;
|
||||
if (text.length > 0)
|
||||
hotspotCard.passwordResolved = true;
|
||||
}
|
||||
onAccepted: hotspotCard.saveOnly()
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankDropdown {
|
||||
width: (parent.width - Theme.spacingM) / 2
|
||||
text: I18n.tr("Device", "hotspot WiFi device field label")
|
||||
description: I18n.tr("Optional", "hotspot WiFi device field description")
|
||||
currentValue: hotspotCard.device || I18n.tr("Auto", "hotspot device or band option")
|
||||
options: {
|
||||
const devices = NetworkService.wifiDevices || [];
|
||||
return [I18n.tr("Auto", "hotspot device or band option")].concat(devices.filter(d => d.apCapable).map(d => d.name));
|
||||
}
|
||||
onValueChanged: value => hotspotCard.device = value === I18n.tr("Auto", "hotspot device or band option") ? "" : value
|
||||
}
|
||||
|
||||
DankDropdown {
|
||||
width: (parent.width - Theme.spacingM) / 2
|
||||
text: I18n.tr("Band", "hotspot WiFi band field label")
|
||||
description: I18n.tr("Optional", "hotspot WiFi band field description")
|
||||
currentValue: hotspotCard.bandLabel(hotspotCard.band)
|
||||
options: [I18n.tr("Auto", "hotspot device or band option"), I18n.tr("2.4 GHz", "hotspot WiFi band option"), I18n.tr("5 GHz", "hotspot WiFi band option")]
|
||||
onValueChanged: value => hotspotCard.band = hotspotCard.bandValue(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Item {
|
||||
width: Math.max(0, parent.width - (cancelButton.visible ? cancelButton.width + Theme.spacingS : 0) - (editButton.visible ? editButton.width + Theme.spacingS : 0) - (saveButton.visible ? saveButton.width + Theme.spacingS : 0) - (startStopButton.width + Theme.spacingS))
|
||||
height: 1
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: cancelButton
|
||||
visible: hotspotCard.editing
|
||||
text: I18n.tr("Cancel", "cancel hotspot editing action")
|
||||
buttonHeight: 36
|
||||
backgroundColor: Theme.surfaceVariant
|
||||
textColor: Theme.surfaceText
|
||||
onClicked: hotspotCard.stopEditing()
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: editButton
|
||||
visible: !hotspotCard.showForm
|
||||
text: I18n.tr("Edit", "edit hotspot action")
|
||||
iconName: "edit"
|
||||
buttonHeight: 36
|
||||
enabled: !NetworkService.hotspotEnabled && !hotspotCard.starting
|
||||
backgroundColor: Theme.surfaceVariant
|
||||
textColor: Theme.surfaceText
|
||||
onClicked: hotspotCard.beginEditing()
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: saveButton
|
||||
visible: hotspotCard.showForm
|
||||
text: hotspotCard.passwordLoading ? I18n.tr("Loading...", "hotspot password loading status") : (NetworkService.hotspotBusy ? I18n.tr("Saving...", "hotspot configuration saving status") : I18n.tr("Save", "save hotspot configuration action"))
|
||||
iconName: "save"
|
||||
buttonHeight: 36
|
||||
enabled: hotspotCard.buildCanConfigure()
|
||||
backgroundColor: Theme.surfaceVariant
|
||||
textColor: Theme.surfaceText
|
||||
onClicked: hotspotCard.saveOnly()
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: startStopButton
|
||||
text: {
|
||||
if (NetworkService.hotspotEnabled)
|
||||
return I18n.tr("Stop", "stop hotspot action");
|
||||
if (hotspotCard.starting)
|
||||
return I18n.tr("Starting...", "hotspot activation status");
|
||||
return hotspotCard.showForm ? I18n.tr("Save & Start", "save and start hotspot action") : I18n.tr("Start", "start hotspot action");
|
||||
}
|
||||
iconName: NetworkService.hotspotEnabled ? "stop" : "wifi_tethering"
|
||||
buttonHeight: 36
|
||||
enabled: !hotspotCard.starting && (NetworkService.hotspotEnabled || hotspotCard.buildCanConfigure())
|
||||
backgroundColor: NetworkService.hotspotEnabled ? Theme.error : Theme.primary
|
||||
textColor: NetworkService.hotspotEnabled ? Theme.surfaceText : Theme.onPrimary
|
||||
onClicked: hotspotCard.startOrStop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user