feat: bluetooth popout
This commit is contained in:
parent
017b1b4ce0
commit
ded156f58d
5 changed files with 47 additions and 6 deletions
|
|
@ -12,21 +12,28 @@ StyledRect {
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
|
|
||||||
function checkPopout(y: real): var {
|
function checkPopout(y: real): var {
|
||||||
|
const spacing = Appearance.spacing.small;
|
||||||
const aw = activeWindow.child;
|
const aw = activeWindow.child;
|
||||||
const awy = activeWindow.y + aw.y;
|
const awy = activeWindow.y + aw.y;
|
||||||
const n = statusIconsInner.network;
|
const n = statusIconsInner.network;
|
||||||
const ny = statusIcons.y + statusIconsInner.y + n.y;
|
const ny = statusIcons.y + statusIconsInner.y + n.y - spacing / 2;
|
||||||
|
const bls = statusIcons.y + statusIconsInner.y + statusIconsInner.bs - spacing / 2;
|
||||||
|
const ble = statusIcons.y + statusIconsInner.y + statusIconsInner.be + spacing / 2;
|
||||||
const b = statusIconsInner.battery;
|
const b = statusIconsInner.battery;
|
||||||
const by = statusIcons.y + statusIconsInner.y + b.y;
|
const by = statusIcons.y + statusIconsInner.y + b.y - spacing / 2;
|
||||||
if (y >= awy && y <= awy + aw.implicitHeight) {
|
if (y >= awy && y <= awy + aw.implicitHeight) {
|
||||||
Popouts.currentName = "activewindow";
|
Popouts.currentName = "activewindow";
|
||||||
Popouts.currentCenter = Qt.binding(() => activeWindow.y + aw.y + aw.implicitHeight / 2);
|
Popouts.currentCenter = Qt.binding(() => activeWindow.y + aw.y + aw.implicitHeight / 2);
|
||||||
Popouts.hasCurrent = true;
|
Popouts.hasCurrent = true;
|
||||||
} else if (y >= ny && y <= ny + n.implicitHeight) {
|
} else if (y >= ny && y <= ny + n.implicitHeight + spacing) {
|
||||||
Popouts.currentName = "network";
|
Popouts.currentName = "network";
|
||||||
Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + n.y + n.implicitHeight / 2);
|
Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + n.y + n.implicitHeight / 2);
|
||||||
Popouts.hasCurrent = true;
|
Popouts.hasCurrent = true;
|
||||||
} else if (y >= by && y <= by + b.implicitHeight) {
|
} else if (y >= bls && y <= ble) {
|
||||||
|
Popouts.currentName = "bluetooth";
|
||||||
|
Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + statusIconsInner.bs + (statusIconsInner.be - statusIconsInner.bs) / 2);
|
||||||
|
Popouts.hasCurrent = true;
|
||||||
|
} else if (y >= by && y <= by + b.implicitHeight + spacing) {
|
||||||
Popouts.currentName = "battery";
|
Popouts.currentName = "battery";
|
||||||
Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + b.y + b.implicitHeight / 2);
|
Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + b.y + b.implicitHeight / 2);
|
||||||
Popouts.hasCurrent = true;
|
Popouts.hasCurrent = true;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ Item {
|
||||||
property color colour: Colours.palette.m3secondary
|
property color colour: Colours.palette.m3secondary
|
||||||
|
|
||||||
readonly property Item network: network
|
readonly property Item network: network
|
||||||
|
readonly property real bs: bluetooth.y
|
||||||
|
readonly property real be: repeater.count > 0 ? devices.y + devices.implicitHeight : bluetooth.y + bluetooth.implicitHeight
|
||||||
readonly property Item battery: battery
|
readonly property Item battery: battery
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
|
||||||
18
modules/bar/popouts/Bluetooth.qml
Normal file
18
modules/bar/popouts/Bluetooth.qml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import "root:/widgets"
|
||||||
|
import "root:/services"
|
||||||
|
import "root:/config"
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
spacing: Appearance.spacing.normal
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: qsTr("Bluetooth %1").arg(Bluetooth.powered ? "enabled" : "disabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: Bluetooth.devices.some(d => d.connected) ? qsTr("Connected to: %1").arg(Bluetooth.devices.filter(d => d.connected).map(d => d.alias).join(", ")) : qsTr("No devices connected")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ Item {
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
implicitWidth: Popouts.hasCurrent ? content.children.find(c => c.shouldBeActive).implicitWidth + Appearance.padding.large * 2 : 0
|
implicitWidth: Popouts.hasCurrent ? (content.children.find(c => c.shouldBeActive)?.implicitWidth ?? 0) + Appearance.padding.large * 2 : 0
|
||||||
implicitHeight: Popouts.hasCurrent ? content.children.find(c => c.shouldBeActive).implicitHeight + Appearance.padding.large * 2 : 0
|
implicitHeight: Popouts.hasCurrent ? (content.children.find(c => c.shouldBeActive)?.implicitHeight ?? 0) + Appearance.padding.large * 2 : 0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: content
|
id: content
|
||||||
|
|
@ -31,6 +31,11 @@ Item {
|
||||||
source: "Network.qml"
|
source: "Network.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popout {
|
||||||
|
name: "bluetooth"
|
||||||
|
source: "Bluetooth.qml"
|
||||||
|
}
|
||||||
|
|
||||||
Popout {
|
Popout {
|
||||||
name: "battery"
|
name: "battery"
|
||||||
source: "Battery.qml"
|
source: "Battery.qml"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import "root:/config"
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
|
@ -7,4 +8,12 @@ Singleton {
|
||||||
property string currentName
|
property string currentName
|
||||||
property real currentCenter
|
property real currentCenter
|
||||||
property bool hasCurrent
|
property bool hasCurrent
|
||||||
|
|
||||||
|
Behavior on currentCenter {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.anim.durations.normal
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.emphasized
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue