more formatting

This commit is contained in:
Benjamin Palko 2025-07-29 17:13:55 -04:00
parent 0bbb032823
commit db13cd7d8f
4 changed files with 75 additions and 31 deletions

View file

@ -10,7 +10,7 @@ import Quickshell.Widgets
StyledLabel { StyledLabel {
id: root id: root
required property BluetoothDevice modelData property BluetoothDevice device
RowLayout { RowLayout {
id: row id: row
@ -18,20 +18,20 @@ StyledLabel {
spacing: 8 spacing: 8
Loader { Loader {
active: root.modelData?.icon != undefined active: root.device?.icon != undefined
sourceComponent: IconImage { sourceComponent: IconImage {
implicitSize: 22 implicitSize: 22
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic") source: Quickshell.iconPath(root.device.icon, "device-support-unknown-symbolic")
} }
} }
StyledText { StyledText {
text: root.modelData.deviceName text: root.device.deviceName
} }
StyledButton { StyledButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
hoverEnabled: !root.modelData.pairing hoverEnabled: !root.device.pairing
color: containsMouse ? Theme.palette.primary : Theme.palette.base200 color: containsMouse ? Theme.palette.primary : Theme.palette.base200
content: StyledText { content: StyledText {
text: 'Pair' text: 'Pair'
@ -41,8 +41,8 @@ StyledLabel {
if (!hoverEnabled) { if (!hoverEnabled) {
return; return;
} }
root.modelData.trusted = true; root.device.trusted = true;
root.modelData.pair(); root.device.pair();
} }
} }
} }

View file

@ -42,8 +42,7 @@ StyledPopupWindow {
Switch { Switch {
checked: Bluetooth.defaultAdapter.discovering checked: Bluetooth.defaultAdapter.discovering
onClicked: Bluetooth.defaultAdapter.discovering = true; onClicked: Bluetooth.defaultAdapter.discovering = checked
} }
} }
} }
@ -57,44 +56,89 @@ StyledPopupWindow {
spacing: 8 spacing: 8
StyledText { StyledText {
Layout.topMargin: 8
Layout.minimumWidth: 320 Layout.minimumWidth: 320
font.bold: true font.bold: true
font.pixelSize: 14
text: "Connected Devices" text: "Connected Devices"
} }
ColumnLayout { ColumnLayout {
Loader {
active: Bluetooth.connectedDevices.length == 0
sourceComponent: StyledText {
font.italic: true
text: "No devices connected..."
}
}
Repeater { Repeater {
model: Bluetooth.connectedDevices model: Bluetooth.connectedDevices
delegate: ConnectedDevice { delegate: Loader {
id: connectedDeviceLoader
required property var modelData
Layout.fillWidth: true Layout.fillWidth: true
active: modelData != null
sourceComponent: ConnectedDevice {
device: connectedDeviceLoader.modelData
}
} }
} }
} }
StyledText { StyledText {
Layout.topMargin: 8
font.bold: true font.bold: true
font.pixelSize: 14
text: "Paired Devices" text: "Paired Devices"
} }
ColumnLayout { ColumnLayout {
Loader {
active: Bluetooth.availableDevices.length == 0
sourceComponent: StyledText {
font.italic: true
text: "No paired devices..."
}
}
Repeater { Repeater {
model: Bluetooth.pairedDevices model: Bluetooth.pairedDevices
delegate: PairedDevice { delegate: Loader {
id: pairedDeviceLoader
required property var modelData
Layout.fillWidth: true Layout.fillWidth: true
active: modelData != null
sourceComponent: PairedDevice {
device: pairedDeviceLoader.modelData
}
} }
} }
} }
StyledText { StyledText {
Layout.topMargin: 8
font.bold: true font.bold: true
font.pixelSize: 14
text: "Available Devices" text: "Available Devices"
} }
ColumnLayout { ColumnLayout {
Loader {
active: Bluetooth.availableDevices.length == 0
sourceComponent: StyledText {
font.italic: true
text: Bluetooth.defaultAdapter.discovering ? "No devices found..." : "Scan to find devices..."
}
}
Repeater { Repeater {
model: Bluetooth.availableDevices model: Bluetooth.availableDevices
delegate: AvailableDevice { delegate: Loader {
id: availableDeviceLoader
required property var modelData
Layout.fillWidth: true Layout.fillWidth: true
active: modelData != null
sourceComponent: AvailableDevice {
device: availableDeviceLoader.modelData
}
} }
} }
} }

View file

@ -11,7 +11,7 @@ import Quickshell.Widgets
StyledLabel { StyledLabel {
id: root id: root
required property BluetoothDevice modelData required property BluetoothDevice device
RowLayout { RowLayout {
id: row id: row
@ -19,19 +19,19 @@ StyledLabel {
spacing: 8 spacing: 8
Loader { Loader {
active: root.modelData?.icon != undefined active: root.device?.icon != undefined
sourceComponent: IconImage { sourceComponent: IconImage {
implicitSize: 22 implicitSize: 22
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic") source: Quickshell.iconPath(root.device.icon, "device-support-unknown-symbolic")
} }
} }
StyledText { StyledText {
text: root.modelData.deviceName text: root.device.deviceName
} }
Loader { Loader {
active: root.modelData.batteryAvailable active: root.device.batteryAvailable
sourceComponent: RowLayout { sourceComponent: RowLayout {
StyledText { StyledText {
id: icon id: icon
@ -42,11 +42,11 @@ StyledLabel {
states: [ states: [
State { State {
name: "full" name: "full"
when: root.modelData.battery > 0.66 when: root.device.battery > 0.66
}, },
State { State {
name: "medium" name: "medium"
when: root.modelData.battery > 0.33 when: root.device.battery > 0.33
PropertyChanges { PropertyChanges {
icon { icon {
text: Icons.batteryFull text: Icons.batteryFull
@ -55,7 +55,7 @@ StyledLabel {
}, },
State { State {
name: "low" name: "low"
when: root.modelData.battery > 0.10 when: root.device.battery > 0.10
PropertyChanges { PropertyChanges {
icon { icon {
text: Icons.batteryFull text: Icons.batteryFull
@ -64,7 +64,7 @@ StyledLabel {
}, },
State { State {
name: "critical" name: "critical"
when: root.modelData.battery > 0.10 when: root.device.battery > 0.10
PropertyChanges { PropertyChanges {
icon { icon {
text: Icons.batteryWarning text: Icons.batteryWarning
@ -85,10 +85,10 @@ StyledLabel {
font.pixelSize: 12 font.pixelSize: 12
} }
onClicked: { onClicked: {
if (root.modelData.state != BluetoothDeviceState.Connected) { if (root.device.state != BluetoothDeviceState.Connected) {
return; return;
} }
root.modelData.connected = false; root.device.connected = false;
} }
} }
} }

View file

@ -10,7 +10,7 @@ import Quickshell.Widgets
StyledLabel { StyledLabel {
id: root id: root
required property BluetoothDevice modelData required property BluetoothDevice device
RowLayout { RowLayout {
id: row id: row
@ -18,21 +18,21 @@ StyledLabel {
spacing: 8 spacing: 8
Loader { Loader {
active: root.modelData?.icon != undefined active: root.device?.icon != undefined
sourceComponent: IconImage { sourceComponent: IconImage {
implicitSize: 22 implicitSize: 22
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic") source: Quickshell.iconPath(root.device.icon, "device-support-unknown-symbolic")
} }
} }
StyledText { StyledText {
text: root.modelData.deviceName text: root.device.deviceName
} }
RowLayout { RowLayout {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
StyledButton { StyledButton {
hoverEnabled: root.modelData.state == BluetoothDeviceState.Disconnected hoverEnabled: root.device.state == BluetoothDeviceState.Disconnected
color: containsMouse ? Theme.palette.primary : Theme.palette.base200 color: containsMouse ? Theme.palette.primary : Theme.palette.base200
content: StyledText { content: StyledText {
text: 'Connect' text: 'Connect'
@ -42,12 +42,12 @@ StyledLabel {
if (!hoverEnabled) { if (!hoverEnabled) {
return; return;
} }
root.modelData.connect(); root.device.connect();
} }
} }
StyledButton { StyledButton {
hoverEnabled: root.modelData.state == BluetoothDeviceState.Disconnected hoverEnabled: root.device.state == BluetoothDeviceState.Disconnected
color: containsMouse ? Theme.palette.error : Theme.palette.base200 color: containsMouse ? Theme.palette.error : Theme.palette.base200
content: StyledText { content: StyledText {
text: 'Unpair' text: 'Unpair'
@ -57,7 +57,7 @@ StyledLabel {
if (!hoverEnabled) { if (!hoverEnabled) {
return; return;
} }
root.modelData.forget(); root.device.forget();
} }
} }
} }