forked from Shinonome/dots-hyprland
bluetooth: refractor and fix wrong icon
This commit is contained in:
@@ -2,7 +2,6 @@ import "./weather"
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Bluetooth
|
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import qs
|
import qs
|
||||||
import qs.services
|
import qs.services
|
||||||
@@ -307,10 +306,7 @@ Item { // Bar content region
|
|||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
}
|
}
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
readonly property bool bluetoothEnabled: Bluetooth.defaultAdapter?.enabled
|
text: BluetoothStatus.connected ? "bluetooth_connected" : BluetoothStatus.enabled ? "bluetooth" : "bluetooth_disabled"
|
||||||
readonly property BluetoothDevice bluetoothDevice: Bluetooth.defaultAdapter?.devices.values.find(device => device.connected)
|
|
||||||
readonly property bool bluetoothConnected: bluetoothDevice !== undefined
|
|
||||||
text: bluetoothConnected ? "bluetooth_connected" : bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
|
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import qs
|
import qs
|
||||||
|
import qs.services
|
||||||
import qs.modules.common
|
import qs.modules.common
|
||||||
import qs.modules.common.widgets
|
import qs.modules.common.widgets
|
||||||
import qs.modules.common.functions
|
import qs.modules.common.functions
|
||||||
@@ -10,11 +11,8 @@ import Quickshell.Hyprland
|
|||||||
|
|
||||||
QuickToggleButton {
|
QuickToggleButton {
|
||||||
id: root
|
id: root
|
||||||
readonly property bool bluetoothEnabled: Bluetooth.defaultAdapter?.enabled ?? false
|
toggled: BluetoothStatus.enabled
|
||||||
readonly property BluetoothDevice bluetoothDevice: Bluetooth.defaultAdapter?.devices.values.find(device => device.connected) ?? null
|
buttonIcon: BluetoothStatus.connected ? "bluetooth_connected" : BluetoothStatus.enabled ? "bluetooth" : "bluetooth_disabled"
|
||||||
readonly property bool bluetoothConnected: bluetoothDevice !== undefined
|
|
||||||
toggled: bluetoothEnabled
|
|
||||||
buttonIcon: bluetoothConnected ? "bluetooth_connected" : bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Bluetooth.defaultAdapter.enabled = !Bluetooth.defaultAdapter?.enabled
|
Bluetooth.defaultAdapter.enabled = !Bluetooth.defaultAdapter?.enabled
|
||||||
}
|
}
|
||||||
@@ -24,7 +22,8 @@ QuickToggleButton {
|
|||||||
}
|
}
|
||||||
StyledToolTip {
|
StyledToolTip {
|
||||||
content: Translation.tr("%1 | Right-click to configure").arg(
|
content: Translation.tr("%1 | Right-click to configure").arg(
|
||||||
(bluetoothDevice?.name.length > 0) ?
|
(BluetoothStatus.firstActiveDevice?.name ?? Translation.tr("Bluetooth"))
|
||||||
bluetoothDevice.name : Translation.tr("Bluetooth"))
|
+ (BluetoothStatus.activeDeviceCount > 1 ? ` +${BluetoothStatus.activeDeviceCount - 1}` : "")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,10 +285,7 @@ Item { // Bar content region
|
|||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
}
|
}
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
readonly property bool bluetoothEnabled: Bluetooth.defaultAdapter?.enabled
|
text: BluetoothStatus.connected ? "bluetooth_connected" : BluetoothStatus.enabled ? "bluetooth" : "bluetooth_disabled"
|
||||||
readonly property BluetoothDevice bluetoothDevice: Bluetooth.defaultAdapter?.devices.values.find(device => device.connected)
|
|
||||||
readonly property bool bluetoothConnected: bluetoothDevice !== undefined
|
|
||||||
text: bluetoothConnected ? "bluetooth_connected" : bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
|
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Bluetooth
|
||||||
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Network service with nmcli.
|
||||||
|
*/
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property bool enabled: Bluetooth.defaultAdapter?.enabled
|
||||||
|
readonly property BluetoothDevice firstActiveDevice: Bluetooth.defaultAdapter?.devices.values.find(device => device.connected) ?? null
|
||||||
|
readonly property int activeDeviceCount: Bluetooth.defaultAdapter?.devices.values.filter(device => device.connected).length ?? 0
|
||||||
|
readonly property bool connected: Bluetooth.devices.values.some(d => d.connected)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user