Fix Bluetooth discovering process & some enhancements to Bluetooth- & Wifi-Panel

This commit is contained in:
notiant
2026-02-08 14:32:59 +01:00
committed by GitHub
parent 9ad50a17c0
commit 677d84b613
5 changed files with 77 additions and 96 deletions
@@ -93,7 +93,7 @@ NBox {
radius: Style.radiusM
clip: true
color: (modelData.connected && modelData.state !== BluetoothDeviceState.Disconnecting) ? Qt.alpha(getContentColor(), 0.08) : Color.mSurface
color: (modelData.connected && modelData.state !== BluetoothDeviceState.Disconnecting) ? Qt.alpha(Color.mPrimary, 0.15) : Color.mSurface
// Content column so expanded details are laid out inside the card
ColumnLayout {
@@ -112,7 +112,7 @@ NBox {
NIcon {
icon: BluetoothService.getDeviceIcon(modelData)
pointSize: Style.fontSizeXXL
color: getContentColor(Color.mOnSurface)
color: modelData.connected ? Color.mPrimary : getContentColor(Color.mOnSurface)
Layout.alignment: Qt.AlignVCenter
}
@@ -219,6 +219,7 @@ NBox {
outlined: !button.hovered
fontSize: Style.fontSizeS
tooltipText: root.tooltipText
backgroundColor: modelData.connected ? Color.mError : Color.mPrimary
text: {
if (modelData.pairing) {
return I18n.tr("common.pairing");
+66 -66
View File
@@ -150,72 +150,6 @@ SmartPanel {
}
}
// Fallback - No devices, scanning
NBox {
id: scanningBox
Layout.fillWidth: true
Layout.preferredHeight: scanningColumn.implicitHeight + Style.marginXL
visible: {
if (!(BluetoothService.adapter && BluetoothService.adapter.enabled && BluetoothService.adapter.devices) || !BluetoothService.scanningActive) {
return false;
}
var availableCount = BluetoothService.adapter.devices.values.filter(dev => {
return dev && !dev.paired && !dev.pairing && !dev.blocked && (dev.signalStrength === undefined || dev.signalStrength > 0);
}).length;
return (availableCount === 0);
}
ColumnLayout {
id: scanningColumn
anchors.fill: parent
anchors.margins: Style.marginM
spacing: Style.marginL
Item {
Layout.fillHeight: true
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Style.marginXS
NIcon {
icon: "refresh"
pointSize: Style.fontSizeXXL * 1.5
color: Color.mPrimary
RotationAnimation on rotation {
running: true
loops: Animation.Infinite
from: 0
to: 360
duration: Style.animationSlow * 4
}
}
NText {
text: I18n.tr("bluetooth.panel.scanning")
pointSize: Style.fontSizeL
color: Color.mOnSurface
}
}
NText {
text: I18n.tr("bluetooth.panel.pairing-mode")
pointSize: Style.fontSizeM
color: Color.mOnSurfaceVariant
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
Item {
Layout.fillHeight: true
}
}
}
// Empty state when no devices
NBox {
id: emptyBox
@@ -382,6 +316,72 @@ SmartPanel {
visible: items.length > 0 && BluetoothService.adapter && BluetoothService.adapter.enabled
Layout.fillWidth: true
}
// Fallback - No devices, scanning
NBox {
id: scanningBox
Layout.fillWidth: true
Layout.preferredHeight: scanningColumn.implicitHeight + Style.marginXL
visible: {
if (!(BluetoothService.adapter && BluetoothService.adapter.enabled && BluetoothService.adapter.devices) || !BluetoothService.scanningActive) {
return false;
}
var availableCount = BluetoothService.adapter.devices.values.filter(dev => {
return dev && !dev.paired && !dev.pairing && !dev.blocked && (dev.signalStrength === undefined || dev.signalStrength > 0);
}).length;
return (availableCount === 0);
}
ColumnLayout {
id: scanningColumn
anchors.fill: parent
anchors.margins: Style.marginM
spacing: Style.marginL
Item {
Layout.fillHeight: true
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Style.marginXS
NIcon {
icon: "refresh"
pointSize: Style.fontSizeXXL * 1.5
color: Color.mPrimary
RotationAnimation on rotation {
running: true
loops: Animation.Infinite
from: 0
to: 360
duration: Style.animationSlow * 4
}
}
NText {
text: I18n.tr("bluetooth.panel.scanning")
pointSize: Style.fontSizeL
color: Color.mOnSurface
}
}
NText {
text: I18n.tr("bluetooth.panel.pairing-mode")
pointSize: Style.fontSizeM
color: Color.mOnSurfaceVariant
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
Item {
Layout.fillHeight: true
}
}
}
}
}
}
+2 -22
View File
@@ -16,7 +16,6 @@ SmartPanel {
property string passwordSsid: ""
property string expandedSsid: ""
property bool hasHadNetworks: false
// Info panel collapsed by default, view mode persisted under Settings.data.ui.wifiDetailsViewMode
// Ethernet details UI state (mirrors WiFi info behavior)
@@ -65,7 +64,6 @@ SmartPanel {
return known;
}
onOpened: {
hasHadNetworks = false;
NetworkService.scan();
// Preload active WiFi details so Info shows instantly
NetworkService.refreshActiveWifiDetails();
@@ -101,24 +99,6 @@ SmartPanel {
return available;
}
onKnownNetworksChanged: {
if (knownNetworks.length > 0)
hasHadNetworks = true;
}
onAvailableNetworksChanged: {
if (availableNetworks.length > 0)
hasHadNetworks = true;
}
Connections {
target: Settings.data.network
function onWifiEnabledChanged() {
if (!Settings.data.network.wifiEnabled)
root.hasHadNetworks = false;
}
}
panelContent: Rectangle {
color: "transparent"
@@ -341,7 +321,7 @@ SmartPanel {
// Scanning state (show when no networks and we haven't had any yet)
NBox {
id: scanningBox
visible: panelViewMode === "wifi" && Settings.data.network.wifiEnabled && Object.keys(NetworkService.networks).length === 0 && !root.hasHadNetworks
visible: panelViewMode === "wifi" && Settings.data.network.wifiEnabled && Object.keys(NetworkService.networks).length === 0 && NetworkService.scanning
Layout.fillWidth: true
Layout.preferredHeight: scanningColumn.implicitHeight + Style.marginXL
@@ -378,7 +358,7 @@ SmartPanel {
// Empty state when no networks (only show after we've had networks before, meaning a real empty result)
NBox {
id: emptyBox
visible: panelViewMode === "wifi" && Settings.data.network.wifiEnabled && !NetworkService.scanning && Object.keys(NetworkService.networks).length === 0 && root.hasHadNetworks
visible: panelViewMode === "wifi" && Settings.data.network.wifiEnabled && !NetworkService.scanning && Object.keys(NetworkService.networks).length === 0 && !NetworkService.scanning
Layout.fillWidth: true
Layout.preferredHeight: emptyColumn.implicitHeight + Style.marginXL
+1 -1
View File
@@ -85,7 +85,7 @@ NBox {
opacity: (NetworkService.disconnectingFrom === modelData.ssid || NetworkService.forgettingNetwork === modelData.ssid) ? 0.6 : 1.0
color: modelData.connected ? Qt.rgba(Color.mPrimary.r, Color.mPrimary.g, Color.mPrimary.b, 0.08) : Color.mSurface
color: modelData.connected ? Qt.alpha(Color.mPrimary, 0.15) : Color.mSurface
Behavior on opacity {
NumberAnimation {
+5 -5
View File
@@ -103,7 +103,7 @@ Singleton {
Process {
id: fallbackScanProcess
// Pipe scan on and a long sleep to bluetoothctl to keep it running
command: ["sh", "-c", "(echo 'scan on'; sleep 3600) | bluetoothctl"]
command: ["sh", "-c", "trap 'kill 0' EXIT; (echo 'scan on'; sleep 3600) | bluetoothctl"]
onExited: Logger.d("Bluetooth", "Fallback scan process exited")
}
@@ -121,13 +121,13 @@ Singleton {
var nativeSuccess = false;
try {
if (adapter) {
if (active && adapter.startDiscovery !== undefined) {
if (active && adapter.discovering !== undefined) {
// Logger.e("Bluetooth", "Starting discovery with Quickshell API"); // used for debugging
adapter.startDiscovery();
adapter.discovering = true;
nativeSuccess = true;
} else if (!active && adapter.stopDiscovery !== undefined) {
} else if (!active && adapter.discovering !== undefined) {
// Logger.e("Bluetooth", "Stopping discovery with Quickshell API"); // used for debugging
adapter.stopDiscovery();
adapter.discovering = false;
nativeSuccess = true;
}
} else {