sidebar toggle buttons
This commit is contained in:
@@ -2,9 +2,9 @@ import Quickshell.Bluetooth
|
|||||||
import Quickshell.Networking as QSNetwork
|
import Quickshell.Networking as QSNetwork
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import ZShell.Components
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import qs.Config
|
import qs.Config
|
||||||
import qs.Modules
|
|
||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
import qs.Daemons
|
import qs.Daemons
|
||||||
|
|
||||||
@@ -19,74 +19,69 @@ CustomRect {
|
|||||||
implicitHeight: layout.implicitHeight + 18 * 2
|
implicitHeight: layout.implicitHeight + 18 * 2
|
||||||
radius: Appearance.rounding.smallest
|
radius: Appearance.rounding.smallest
|
||||||
|
|
||||||
ColumnLayout {
|
ButtonRow {
|
||||||
id: layout
|
id: layout
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 18
|
anchors.margins: 18
|
||||||
spacing: 10
|
spacing: Appearance.spacing.extraSmall
|
||||||
|
|
||||||
RowLayout {
|
Toggle {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
checked: Network.wifiEnabled
|
||||||
spacing: 7
|
icon: Network.wifiEnabled ? "wifi" : "wifi_off"
|
||||||
|
visible: QSNetwork.Networking.devices.values.some(n => n.type === QSNetwork.DeviceType.Wifi)
|
||||||
|
|
||||||
Toggle {
|
onClicked: Network.toggleWifi()
|
||||||
checked: Network.wifiEnabled
|
}
|
||||||
icon: Network.wifiEnabled ? "wifi" : "wifi_off"
|
|
||||||
visible: QSNetwork.Networking.devices.values.some(n => n.type === QSNetwork.DeviceType.Wifi)
|
|
||||||
|
|
||||||
onClicked: Network.toggleWifi()
|
Toggle {
|
||||||
|
id: toggle
|
||||||
|
|
||||||
|
checked: !NotifServer.dnd
|
||||||
|
icon: NotifServer.dnd ? "notifications_off" : "notifications"
|
||||||
|
|
||||||
|
onClicked: NotifServer.dnd = !NotifServer.dnd
|
||||||
|
}
|
||||||
|
|
||||||
|
Toggle {
|
||||||
|
checked: !Audio.sourceMuted
|
||||||
|
icon: Audio.sourceMuted ? "mic_off" : "mic"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
const audio = Audio.source?.audio;
|
||||||
|
if (audio)
|
||||||
|
audio.muted = !audio.muted;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Toggle {
|
Toggle {
|
||||||
id: toggle
|
checked: !Audio.muted
|
||||||
|
icon: Audio.muted ? "volume_off" : "volume_up"
|
||||||
|
|
||||||
checked: !NotifServer.dnd
|
onClicked: {
|
||||||
icon: NotifServer.dnd ? "notifications_off" : "notifications"
|
const audio = Audio.sink?.audio;
|
||||||
|
if (audio)
|
||||||
onClicked: NotifServer.dnd = !NotifServer.dnd
|
audio.muted = !audio.muted;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Toggle {
|
Toggle {
|
||||||
checked: !Audio.sourceMuted
|
checked: Bluetooth.defaultAdapter?.enabled ?? false
|
||||||
icon: Audio.sourceMuted ? "mic_off" : "mic"
|
icon: Bluetooth.defaultAdapter?.enabled ? "bluetooth" : "bluetooth_disabled"
|
||||||
|
visible: Bluetooth.defaultAdapter ?? false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const audio = Audio.source?.audio;
|
const adapter = Bluetooth.defaultAdapter;
|
||||||
if (audio)
|
if (adapter)
|
||||||
audio.muted = !audio.muted;
|
adapter.enabled = !adapter.enabled;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Toggle {
|
Toggle {
|
||||||
checked: !Audio.muted
|
checked: GameMode.enabled
|
||||||
icon: Audio.muted ? "volume_off" : "volume_up"
|
icon: GameMode.enabled ? "videogame_asset" : "videogame_asset_off"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: GameMode.enabled = !GameMode.enabled
|
||||||
const audio = Audio.sink?.audio;
|
|
||||||
if (audio)
|
|
||||||
audio.muted = !audio.muted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Toggle {
|
|
||||||
checked: Bluetooth.defaultAdapter?.enabled ?? false
|
|
||||||
icon: Bluetooth.defaultAdapter?.enabled ? "bluetooth" : "bluetooth_disabled"
|
|
||||||
visible: Bluetooth.defaultAdapter ?? false
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
const adapter = Bluetooth.defaultAdapter;
|
|
||||||
if (adapter)
|
|
||||||
adapter.enabled = !adapter.enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Toggle {
|
|
||||||
checked: GameMode.enabled
|
|
||||||
icon: GameMode.enabled ? "videogame_asset" : "videogame_asset_off"
|
|
||||||
|
|
||||||
onClicked: GameMode.enabled = !GameMode.enabled
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,19 +94,9 @@ CustomRect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
component Toggle: IconButton {
|
component Toggle: IconButton {
|
||||||
Layout.fillWidth: true
|
fillWidth: true
|
||||||
Layout.preferredWidth: implicitWidth + (stateLayer.pressed ? 18 : internalChecked ? 7 : 0)
|
isRound: true
|
||||||
inactiveColor: DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHighest, 2)
|
|
||||||
isToggle: true
|
isToggle: true
|
||||||
radius: stateLayer.pressed ? 6 / 2 : internalChecked ? 6 : 8
|
shapeMorph: true
|
||||||
radiusAnim.duration: MaterialEasing.expressiveEffectsTime
|
|
||||||
radiusAnim.easing.bezierCurve: MaterialEasing.expressiveEffects
|
|
||||||
|
|
||||||
Behavior on Layout.preferredWidth {
|
|
||||||
Anim {
|
|
||||||
duration: MaterialEasing.expressiveEffectsTime
|
|
||||||
easing.bezierCurve: MaterialEasing.expressiveEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user