198 lines
7.3 KiB
QML
198 lines
7.3 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Controls.Material
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Networking
|
|
import "services"
|
|
|
|
// Compact ChromeOS/Android-inspired desktop dashboard. Real actions only.
|
|
ScrollView {
|
|
id: dashboard
|
|
signal navigate(string name)
|
|
clip: true
|
|
contentWidth: availableWidth
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
Material.theme: Theme.dark ? Material.Dark : Material.Light
|
|
Material.accent: Theme.primary
|
|
|
|
BrightnessController { id: brightness }
|
|
readonly property bool hasBacklight: brightness.devices.length > 0
|
|
readonly property bool hasAudio: Hardware.sink !== null && Hardware.sink.audio !== null
|
|
readonly property bool hasBluetooth: Hardware.bluetoothAdapters.length > 0
|
|
|
|
component Tile: Rectangle {
|
|
id: tile
|
|
property string title: ""
|
|
property string symbol: ""
|
|
property bool selected: false
|
|
property bool usable: true
|
|
signal activated()
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 46
|
|
radius: 23
|
|
color: selected ? Theme.primaryContainer : Theme.surfaceHigh
|
|
opacity: usable ? 1 : 0.45
|
|
Behavior on color { ColorAnimation { duration: Theme.duration } }
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 12
|
|
anchors.rightMargin: 10
|
|
spacing: 9
|
|
Text {
|
|
text: tile.symbol
|
|
font.pixelSize: 16
|
|
color: tile.selected ? Theme.onPrimaryContainer : Theme.foreground
|
|
Layout.preferredWidth: 19
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
Text {
|
|
text: tile.title
|
|
font.pixelSize: 12
|
|
font.weight: Font.DemiBold
|
|
color: tile.selected ? Theme.onPrimaryContainer : Theme.foreground
|
|
Layout.fillWidth: true
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
enabled: tile.usable
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: tile.activated()
|
|
}
|
|
}
|
|
|
|
ColumnLayout {
|
|
width: dashboard.availableWidth
|
|
spacing: 10
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 36
|
|
spacing: 8
|
|
Text {
|
|
text: "▦"
|
|
color: Theme.primary
|
|
font.pixelSize: 19
|
|
}
|
|
Text {
|
|
text: "Быстрые настройки"
|
|
color: Theme.foreground
|
|
font.pixelSize: 16
|
|
font.weight: Font.DemiBold
|
|
Layout.fillWidth: true
|
|
elide: Text.ElideRight
|
|
}
|
|
ToolButton {
|
|
text: "⚙"
|
|
Accessible.name: "Открыть настройки"
|
|
onClicked: dashboard.navigate("settings")
|
|
}
|
|
}
|
|
|
|
// Material 3 Expressive pill-shaped sliders. Do not show unsupported hardware.
|
|
Rectangle {
|
|
visible: dashboard.hasBacklight
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: visible ? 48 : 0
|
|
radius: 24
|
|
color: Theme.secondaryContainer
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 14
|
|
anchors.rightMargin: 12
|
|
spacing: 8
|
|
Text { text: "☀"; color: Theme.foreground; font.pixelSize: 18 }
|
|
Slider {
|
|
Layout.fillWidth: true
|
|
from: 1; to: 100; stepSize: 1
|
|
value: dashboard.hasBacklight ? brightness.devices[0].percent : 50
|
|
enabled: dashboard.hasBacklight && !brightness.busy
|
|
Accessible.name: "Яркость"
|
|
onPressedChanged: {
|
|
if (!pressed && dashboard.hasBacklight)
|
|
brightness.setBrightness(brightness.devices[0].name, Math.round(value))
|
|
}
|
|
}
|
|
Text { text: dashboard.hasBacklight ? brightness.devices[0].percent + "%" : ""; color: Theme.foreground; font.pixelSize: 11 }
|
|
}
|
|
}
|
|
Rectangle {
|
|
visible: dashboard.hasAudio
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: visible ? 48 : 0
|
|
radius: 24
|
|
color: Theme.surfaceHigh
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 12
|
|
anchors.rightMargin: 12
|
|
spacing: 8
|
|
ToolButton {
|
|
text: dashboard.hasAudio && Hardware.sink.audio.muted ? "♩" : "♫"
|
|
Accessible.name: "Включить или выключить звук"
|
|
onClicked: if (dashboard.hasAudio) Hardware.sink.audio.muted = !Hardware.sink.audio.muted
|
|
}
|
|
Slider {
|
|
Layout.fillWidth: true
|
|
from: 0; to: 1
|
|
value: dashboard.hasAudio ? Hardware.sink.audio.volume : 0
|
|
enabled: dashboard.hasAudio
|
|
Accessible.name: "Громкость"
|
|
onMoved: if (dashboard.hasAudio) Hardware.sink.audio.volume = value
|
|
}
|
|
Text { text: dashboard.hasAudio ? Math.round(Hardware.sink.audio.volume * 100) + "%" : ""; color: Theme.foreground; font.pixelSize: 11 }
|
|
}
|
|
}
|
|
|
|
GridLayout {
|
|
Layout.fillWidth: true
|
|
columns: 2
|
|
columnSpacing: 8
|
|
rowSpacing: 8
|
|
Tile {
|
|
visible: Hardware.wifiPresent
|
|
title: "Wi-Fi"; symbol: "◉"
|
|
selected: Networking.wifiEnabled
|
|
usable: Networking.wifiHardwareEnabled
|
|
onActivated: Networking.wifiEnabled = !Networking.wifiEnabled
|
|
}
|
|
Tile {
|
|
visible: dashboard.hasBluetooth
|
|
title: "Bluetooth"; symbol: "ᛒ"
|
|
selected: dashboard.hasBluetooth && Hardware.bluetoothAdapters[0].enabled
|
|
onActivated: if (dashboard.hasBluetooth) Hardware.bluetoothAdapters[0].enabled = !Hardware.bluetoothAdapters[0].enabled
|
|
}
|
|
Tile {
|
|
title: "Интернет"; symbol: "⌁"
|
|
selected: Hardware.networkReady
|
|
onActivated: dashboard.navigate("network")
|
|
}
|
|
Tile {
|
|
title: "Звук"; symbol: "♫"
|
|
selected: dashboard.hasAudio
|
|
usable: dashboard.hasAudio
|
|
onActivated: dashboard.navigate("audio")
|
|
}
|
|
Tile {
|
|
title: "Уведомления"; symbol: "◌"
|
|
onActivated: dashboard.navigate("notifications")
|
|
}
|
|
Tile {
|
|
title: "Дисплей"; symbol: "▣"
|
|
onActivated: dashboard.navigate("display")
|
|
}
|
|
}
|
|
Text {
|
|
visible: brightness.error !== ""
|
|
Layout.fillWidth: true
|
|
text: brightness.error
|
|
color: Theme.foreground
|
|
wrapMode: Text.Wrap
|
|
font.pixelSize: 12
|
|
}
|
|
}
|
|
}
|