Files
dotfiles/quickshell/QuickSettings.qml
T
2026-11-17 18:15:16 +07:00

165 lines
7.1 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Networking
import Quickshell.Bluetooth
import "services"
import "components"
ScrollView {
id: quick
Material.theme: Theme.dark ? Material.Dark : Material.Light
Material.accent: Theme.primary
signal navigate(string name)
clip: true
contentWidth: availableWidth
BrightnessController { id: brightnessControl }
readonly property bool desktop: width >= 350
ColumnLayout {
width: quick.availableWidth
spacing: 10
RowLayout {
visible: quick.desktop
Layout.fillWidth: true
Label { text: "Быстрые настройки"; font.pixelSize: 17; font.bold: true; color: Theme.foreground; Layout.fillWidth: true }
ActionButton { text: "⚙"; onClicked: quick.navigate("settings") }
}
Rectangle {
visible: quick.desktop
Layout.fillWidth: true
implicitHeight: 8
radius: 4
color: Theme.secondaryContainer
}
Label { visible: quick.desktop; text: "Подключения"; font.pixelSize: 13; color: Theme.outline }
Label { visible: !quick.desktop; text: "Сеть"; color: Theme.primary; font.pixelSize: 20 }
Rectangle {
visible: quick.desktop && (Hardware.wifiPresent || Hardware.bluetoothAdapters.length > 0)
Layout.fillWidth: true
implicitHeight: 1
color: Theme.outline
opacity: 0.25
}
Switch {
visible: Hardware.wifiPresent
text: Hardware.wifiState === "blocked" ? "Wi-Fi заблокирован оборудованием" : "Wi-Fi"
checked: Networking.wifiEnabled
enabled: Networking.wifiHardwareEnabled
onClicked: Networking.wifiEnabled = checked
}
Repeater {
model: Hardware.wiredDevices
ActionButton {
required property var modelData
Layout.fillWidth: true
text: "Ethernet · " + modelData.name + (modelData.connected ? " · подключено" : modelData.hasLink ? " · кабель подключён" : " · нет кабеля")
onClicked: quick.navigate("network")
}
}
ActionButton {
visible: Hardware.networkReady && (Hardware.networks.length > 0 || Networking.canCheckConnectivity)
text: "Сетевые подключения…"
onClicked: quick.navigate("network")
}
ActionButton { visible: Modems.present; text: "Мобильная сеть · " + Modems.devices.length + " модем(ов)"; onClicked: quick.navigate("modem") }
Repeater {
model: Hardware.bluetoothAdapters
Switch {
required property var modelData
text: "Bluetooth · " + modelData.name
checked: modelData.enabled
onClicked: modelData.enabled = checked
}
}
ActionButton { visible: Hardware.bluetoothAdapters.length > 0; text: "Устройства Bluetooth"; onClicked: quick.navigate("bluetooth") }
// Brightness is hardware-dependent: no dead slider on desktop monitors
// without a kernel backlight. Changes are committed on release, avoiding
// a burst of brightnessctl processes while dragging.
Label {
visible: brightnessControl.devices.length > 0
text: "Яркость экрана"
color: Theme.primary
font.pixelSize: 20
}
Repeater {
model: brightnessControl.devices
ColumnLayout {
id: backlightRow
required property var modelData
Layout.fillWidth: true
spacing: 4
Label {
Layout.fillWidth: true
text: backlightRow.modelData.name + " · " + backlightRow.modelData.percent + "%"
color: Theme.foreground
elide: Text.ElideRight
}
Slider {
id: brightnessSlider
Layout.fillWidth: true
from: 1
to: 100
stepSize: 1
value: backlightRow.modelData.percent
enabled: !brightnessControl.busy
onPressedChanged: {
if (!pressed)
brightnessControl.setBrightness(backlightRow.modelData.name, Math.round(value))
}
Accessible.name: "Яркость " + backlightRow.modelData.name
}
}
}
Label {
visible: brightnessControl.error !== ""
Layout.fillWidth: true
text: brightnessControl.error
wrapMode: Text.Wrap
color: Theme.outline
}
ActionButton {
visible: brightnessControl.devices.length > 0
text: "Настройки дисплея…"
onClicked: quick.navigate("display")
}
Label { visible: Hardware.sink !== null; text: "Громкость"; color: Theme.primary; font.pixelSize: quick.desktop ? 14 : 20 }
RowLayout {
visible: Hardware.sink !== null
Layout.fillWidth: true
ActionButton {
text: Hardware.sink?.audio?.muted ? "Включить звук" : "Без звука"
onClicked: if (Hardware.sink?.audio) Hardware.sink.audio.muted = !Hardware.sink.audio.muted
}
Slider {
Layout.fillWidth: true
from: 0; to: 1
value: Hardware.sink?.audio?.volume || 0
onMoved: if (Hardware.sink?.audio) Hardware.sink.audio.volume = value
}
}
Switch {
visible: Hardware.source !== null
text: "Микрофон"
checked: Hardware.source?.audio ? !Hardware.source.audio.muted : false
onClicked: if (Hardware.source?.audio) Hardware.source.audio.muted = !checked
}
ActionButton { visible: Hardware.audioReady; text: "Аудиоустройства"; onClicked: quick.navigate("audio") }
Repeater {
model: Hardware.players
ColumnLayout {
required property var modelData
Layout.fillWidth: true
Label { Layout.fillWidth: true; text: modelData.trackTitle || modelData.identity; color: Theme.foreground; elide: Text.ElideRight; textFormat: Text.PlainText }
RowLayout {
ActionButton { text: "Назад"; enabled: modelData.canGoPrevious; onClicked: modelData.previous() }
ActionButton { text: modelData.isPlaying ? "Пауза" : "Играть"; enabled: modelData.canTogglePlaying; onClicked: modelData.togglePlaying() }
ActionButton { text: "Далее"; enabled: modelData.canGoNext; onClicked: modelData.next() }
}
}
}
}
}