Lay the Control Center out as a resizable, editable grid
Modules are tiles on a 4-column grid, each 1x1 to 4x4 and adapting its layout to its size. Edit Controls in the panel reorders by dragging, resizes from a corner handle, removes with a badge and adds from a tray. Connectivity splits into Wi-Fi, Bluetooth and Network tiles and Audio into Sound and Microphone; right-clicking Sound extends it with output devices and a volume slider per app. Adds a Caffeine tile. Config version 2 migrates existing layouts in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0dcf37346c
commit
11bdc4c751
32 files changed
+2147
-355
No files matched your search
@@ -0,0 +1,16 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
|
||||
CCTile {
|
||||
objectName: "bluetoothToggle"
|
||||
title: "Bluetooth"
|
||||
detail: !BluetoothService.adapter ? "No adapter" : !BluetoothService.canToggle ? "Hardware blocked" : BluetoothService.summary
|
||||
page: "bluetooth"
|
||||
glyph: BluetoothService.enabled ? "" : ""
|
||||
fallback: "B"
|
||||
checked: BluetoothService.enabled
|
||||
enabled: BluetoothService.canToggle
|
||||
onClicked: BluetoothService.toggle()
|
||||
}
|
||||
@@ -1,44 +1,24 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import ".."
|
||||
import "../../components"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
ControlCard {
|
||||
id: root
|
||||
// Display brightness; providers apply it on release.
|
||||
CCSlider {
|
||||
readonly property var info: SystemService.state.brightness || ({
|
||||
available: false
|
||||
})
|
||||
objectName: "brightnessTile"
|
||||
title: "Display"
|
||||
GlassBarSlider {
|
||||
objectName: "brightnessSlider"
|
||||
Layout.fillWidth: true
|
||||
glyph: ""
|
||||
fallback: "☀"
|
||||
from: 1
|
||||
to: 100
|
||||
stepSize: 1
|
||||
value: root.info.value || 1
|
||||
enabled: !!root.info.available && !SystemService.acting
|
||||
onPressedChanged: if (!pressed && enabled) {
|
||||
SystemService.action("brightness", value, false);
|
||||
value = Qt.binding(() => root.info.value || 1);
|
||||
}
|
||||
Keys.onReleased: event => {
|
||||
if (event.key === Qt.Key_Left || event.key === Qt.Key_Right) {
|
||||
SystemService.action("brightness", value, false);
|
||||
value = Qt.binding(() => root.info.value || 1);
|
||||
}
|
||||
}
|
||||
Accessible.name: "Display brightness"
|
||||
}
|
||||
Text {
|
||||
visible: !root.info.available
|
||||
text: root.info.notice || "No brightness provider"
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
glyph: ""
|
||||
fallback: "☀"
|
||||
sliderName: "brightnessSlider"
|
||||
from: 1
|
||||
to: 100
|
||||
stepSize: 1
|
||||
value: info.value || 1
|
||||
enabled: !!info.available && !SystemService.acting
|
||||
known: !!info.available
|
||||
notice: info.available ? "" : info.notice || "No brightness provider"
|
||||
onCommitted: value => SystemService.action("brightness", value, false)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
|
||||
// Keeps the screen on and the system awake until turned off.
|
||||
CCTile {
|
||||
objectName: "caffeineToggle"
|
||||
title: "Caffeine"
|
||||
detail: CaffeineService.active ? "Staying awake" : "Off"
|
||||
glyph: CaffeineService.active ? "" : ""
|
||||
fallback: "☕"
|
||||
checked: CaffeineService.active
|
||||
onClicked: CaffeineService.toggle()
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import ".."
|
||||
import "../../services"
|
||||
import "../../core"
|
||||
import "../../theme"
|
||||
|
||||
// Wi-Fi, Bluetooth and live throughput; labels open the matching Settings page.
|
||||
ControlCard {
|
||||
id: root
|
||||
// Tile metrics, so rows line up with the small tiles beside this card: when
|
||||
// the block stretches it, the gaps grow and each row meets a tile's toggle.
|
||||
readonly property int rowHeight: 34
|
||||
padding: 10
|
||||
implicitHeight: 3 * rowHeight + 2 * 10 + 2 * padding
|
||||
spacing: Math.max(10, (root.height - 2 * root.padding - 3 * root.rowHeight) / 2)
|
||||
Demand {
|
||||
service: MetricsService
|
||||
}
|
||||
component Entry: RowLayout {
|
||||
id: entry
|
||||
property alias toggle: toggle
|
||||
property string title
|
||||
property string detail
|
||||
property string page
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: toggle.size
|
||||
spacing: 10
|
||||
CCToggle {
|
||||
id: toggle
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: labels.implicitHeight
|
||||
ColumnLayout {
|
||||
id: labels
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
spacing: 0
|
||||
Text {
|
||||
text: entry.title
|
||||
color: Theme.text
|
||||
font.pixelSize: 12
|
||||
font.weight: Font.DemiBold
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Text {
|
||||
text: entry.detail
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: ShellState.openSettings(entry.page)
|
||||
}
|
||||
}
|
||||
}
|
||||
Entry {
|
||||
title: "Wi-Fi"
|
||||
detail: !NetworkService.available ? "No Wi-Fi adapter" : !NetworkService.backend.wifiHardwareEnabled ? "Hardware blocked" : NetworkService.enabled ? NetworkService.summary : "Off"
|
||||
page: "network"
|
||||
toggle.objectName: "wifiToggle"
|
||||
toggle.glyph: NetworkService.enabled ? "" : ""
|
||||
toggle.fallback: "W"
|
||||
toggle.checked: NetworkService.available && NetworkService.enabled
|
||||
toggle.enabled: NetworkService.available && NetworkService.backend.wifiHardwareEnabled
|
||||
toggle.onClicked: NetworkService.toggle()
|
||||
toggle.Accessible.name: "Wi-Fi"
|
||||
}
|
||||
Entry {
|
||||
title: "Bluetooth"
|
||||
detail: !BluetoothService.adapter ? "No adapter" : !BluetoothService.canToggle ? "Hardware blocked" : BluetoothService.summary
|
||||
page: "bluetooth"
|
||||
toggle.objectName: "bluetoothToggle"
|
||||
toggle.glyph: BluetoothService.enabled ? "" : ""
|
||||
toggle.fallback: "B"
|
||||
toggle.checked: BluetoothService.enabled
|
||||
toggle.enabled: BluetoothService.canToggle
|
||||
toggle.onClicked: BluetoothService.toggle()
|
||||
toggle.Accessible.name: "Bluetooth"
|
||||
}
|
||||
Entry {
|
||||
title: "Network"
|
||||
detail: "↓ " + MetricsService.bytes(MetricsService.network.download) + "/s ↑ " + MetricsService.bytes(MetricsService.network.upload) + "/s"
|
||||
page: "metrics"
|
||||
toggle.glyph: ""
|
||||
toggle.fallback: "N"
|
||||
toggle.onClicked: ShellState.openSettings("network")
|
||||
toggle.Accessible.name: "Network settings"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
@@ -12,6 +13,7 @@ CCTile {
|
||||
title: "Do Not Disturb"
|
||||
detail: shellOwned ? (NotificationService.dnd ? "On" : "Off") : !info.available ? (info.notice || "No notification server") : info.enabled ? "On" : "Off"
|
||||
glyph: ""
|
||||
page: "notifications"
|
||||
fallback: "☾"
|
||||
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
||||
checked: shellOwned ? NotificationService.dnd : !!info.enabled
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
|
||||
// Microphone level. Right click (or spare rows) shows input devices.
|
||||
CCSlider {
|
||||
readonly property var node: AudioService.source
|
||||
objectName: "inputTile"
|
||||
title: "Microphone"
|
||||
glyph: ""
|
||||
mutedGlyph: ""
|
||||
fallback: "M"
|
||||
sliderName: "microphoneSlider"
|
||||
muteName: "microphoneMute"
|
||||
muteable: true
|
||||
enabled: !!node && !!node.audio
|
||||
muted: enabled && node.audio.muted
|
||||
value: enabled ? node.audio.volume : 0
|
||||
notice: AudioService.available ? "" : "PipeWire is unavailable"
|
||||
onMoved: value => AudioService.volume(true, value)
|
||||
onMuteClicked: AudioService.mute(true)
|
||||
extension: AudioMixer {
|
||||
input: true
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,99 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import ".."
|
||||
import "../../core"
|
||||
import "../../metrics"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
MetricsCard {
|
||||
compact: true
|
||||
radius: Math.max(12, Theme.radius * 0.75)
|
||||
color: Theme.fill
|
||||
border.color: Theme.hairline
|
||||
// CPU, RAM and GPU load. Small tiles show the figures as text (1×1 just CPU);
|
||||
// wide tall tiles show ring gauges. Click opens the Metrics settings.
|
||||
CCModule {
|
||||
id: root
|
||||
readonly property var stats: [
|
||||
{
|
||||
label: "CPU",
|
||||
value: MetricsService.cpu.percent
|
||||
},
|
||||
{
|
||||
label: "RAM",
|
||||
value: MetricsService.ram.percent
|
||||
},
|
||||
{
|
||||
label: "GPU",
|
||||
value: MetricsService.gpu.percent
|
||||
}
|
||||
]
|
||||
readonly property int shown: compact ? 1 : Math.min(stats.length, wide ? cols : rows)
|
||||
readonly property bool gauges: wide && tall
|
||||
objectName: "metricsTile"
|
||||
hovered: area.containsMouse
|
||||
Demand {
|
||||
service: MetricsService
|
||||
}
|
||||
MouseArea {
|
||||
id: area
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: ShellState.openSettings("metrics")
|
||||
}
|
||||
GridLayout {
|
||||
visible: !root.gauges
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
columns: root.wide ? root.shown : 1
|
||||
rowSpacing: 4
|
||||
columnSpacing: 4
|
||||
Repeater {
|
||||
model: root.stats.slice(0, root.shown)
|
||||
ColumnLayout {
|
||||
id: stat
|
||||
required property var modelData
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 0
|
||||
Text {
|
||||
text: MetricsService.value(stat.modelData.value, "%")
|
||||
color: Theme.text
|
||||
font.pixelSize: 17
|
||||
font.weight: Font.DemiBold
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignBottom
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
Text {
|
||||
text: stat.modelData.label
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignTop
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Row {
|
||||
visible: root.gauges
|
||||
anchors.centerIn: parent
|
||||
Repeater {
|
||||
model: root.gauges ? root.stats.slice(0, root.shown) : []
|
||||
Item {
|
||||
id: cell
|
||||
required property var modelData
|
||||
readonly property real scaleBy: Math.min(1, (root.width - 16) / root.shown / 100, (root.baseHeight - 16) / 106)
|
||||
width: 100 * scaleBy
|
||||
height: 106 * scaleBy
|
||||
MetricGauge {
|
||||
label: cell.modelData.label
|
||||
value: cell.modelData.value
|
||||
scale: cell.scaleBy
|
||||
transformOrigin: Item.TopLeft
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import ".."
|
||||
import "../../core"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
// Live throughput. 1×1 shows just the two rates.
|
||||
CCTile {
|
||||
id: root
|
||||
readonly property string down: "↓ " + MetricsService.bytes(MetricsService.network.download) + "/s"
|
||||
readonly property string up: "↑ " + MetricsService.bytes(MetricsService.network.upload) + "/s"
|
||||
objectName: "networkTile"
|
||||
title: "Network"
|
||||
detail: down + " " + up
|
||||
page: "network"
|
||||
glyph: ""
|
||||
fallback: "N"
|
||||
round: false
|
||||
compactGlyph: false
|
||||
onClicked: ShellState.openSettings("metrics")
|
||||
Demand {
|
||||
service: MetricsService
|
||||
}
|
||||
ColumnLayout {
|
||||
visible: root.compact
|
||||
anchors.centerIn: parent
|
||||
spacing: 2
|
||||
Repeater {
|
||||
model: [root.down, root.up]
|
||||
Text {
|
||||
required property string modelData
|
||||
text: modelData
|
||||
color: Theme.text
|
||||
font.pixelSize: 10
|
||||
font.weight: Font.DemiBold
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
@@ -10,6 +11,7 @@ CCTile {
|
||||
title: "Night Light"
|
||||
detail: !info.available ? "No gamma provider" : info.enabled ? "On" : "Off"
|
||||
glyph: ""
|
||||
page: "displays"
|
||||
fallback: "N"
|
||||
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
||||
checked: !!info.enabled
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Widgets
|
||||
import ".."
|
||||
import "../../components"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
// Now Playing tile. 1×1 is a round play button over the artwork; one row puts
|
||||
// the artwork beside the track; taller tiles stack artwork, track and controls,
|
||||
// with a progress bar from three rows.
|
||||
CCModule {
|
||||
id: root
|
||||
readonly property bool canControl: !!MediaService.player && MediaService.player.canControl
|
||||
readonly property bool showProgress: rows >= 3 && wide && MediaService.length > 0
|
||||
objectName: "nowPlayingTile"
|
||||
round: true
|
||||
hovered: area.containsMouse
|
||||
Demand {
|
||||
service: MediaService
|
||||
counter: "progressConsumers"
|
||||
active: root.showProgress
|
||||
}
|
||||
|
||||
component Art: ClippingRectangle {
|
||||
id: artFrame
|
||||
property real size: 48
|
||||
implicitWidth: size
|
||||
implicitHeight: size
|
||||
radius: Math.max(8, size * 0.18)
|
||||
color: Theme.surfaceVariant
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: art.status !== Image.Ready
|
||||
text: Icons.available ? "" : "♫"
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: Math.round(artFrame.size * 0.4)
|
||||
color: Theme.textSecondary
|
||||
}
|
||||
Image {
|
||||
id: art
|
||||
anchors.fill: parent
|
||||
source: MediaService.artwork
|
||||
sourceSize: Qt.size(192, 192)
|
||||
asynchronous: true
|
||||
retainWhileLoading: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
}
|
||||
component Track: ColumnLayout {
|
||||
property int titleSize: 13
|
||||
property int align: Text.AlignLeft
|
||||
spacing: 1
|
||||
Text {
|
||||
text: MediaService.title
|
||||
color: Theme.text
|
||||
font.pixelSize: parent.titleSize
|
||||
font.weight: Font.DemiBold
|
||||
elide: Text.ElideRight
|
||||
horizontalAlignment: parent.align
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Text {
|
||||
text: MediaService.artist
|
||||
visible: text !== ""
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
elide: Text.ElideRight
|
||||
horizontalAlignment: parent.align
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
component Control: Item {
|
||||
id: control
|
||||
property string glyph
|
||||
property string fallback
|
||||
property bool main: false
|
||||
property bool available: true
|
||||
signal clicked
|
||||
implicitWidth: main ? 34 : 28
|
||||
implicitHeight: implicitWidth
|
||||
enabled: root.canControl && available
|
||||
opacity: enabled ? 1 : 0.4
|
||||
Accessible.role: Accessible.Button
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: width / 2
|
||||
color: control.main ? Qt.alpha(Theme.text, controlArea.containsMouse ? 0.2 : 0.12) : controlArea.containsMouse ? Theme.hover : Theme.transparent
|
||||
}
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Icons.available ? control.glyph : control.fallback
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: control.main ? 17 : 15
|
||||
color: Theme.text
|
||||
scale: controlArea.pressed ? 0.9 : 1
|
||||
}
|
||||
MouseArea {
|
||||
id: controlArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: control.clicked()
|
||||
}
|
||||
}
|
||||
component Controls: RowLayout {
|
||||
property bool full: true
|
||||
spacing: 4
|
||||
Control {
|
||||
visible: parent.full
|
||||
glyph: ""
|
||||
fallback: "⏮"
|
||||
available: !!MediaService.player && MediaService.player.canGoPrevious
|
||||
onClicked: MediaService.previous()
|
||||
Accessible.name: "Previous track"
|
||||
}
|
||||
Control {
|
||||
objectName: "ccMediaToggle"
|
||||
main: true
|
||||
glyph: MediaService.playing ? "" : ""
|
||||
fallback: MediaService.playing ? "Ⅱ" : "▶"
|
||||
available: !!MediaService.player && MediaService.player.canTogglePlaying
|
||||
onClicked: MediaService.toggle()
|
||||
Accessible.name: MediaService.playing ? "Pause" : "Play"
|
||||
}
|
||||
Control {
|
||||
visible: parent.full
|
||||
glyph: ""
|
||||
fallback: "⏭"
|
||||
available: !!MediaService.player && MediaService.player.canGoNext
|
||||
onClicked: MediaService.next()
|
||||
Accessible.name: "Next track"
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: area
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: if (root.compact && root.canControl)
|
||||
MediaService.toggle()
|
||||
}
|
||||
GlassToolTip {
|
||||
visible: root.compact && area.containsMouse
|
||||
delay: 500
|
||||
text: MediaService.title + (MediaService.artist ? " · " + MediaService.artist : "")
|
||||
}
|
||||
|
||||
// 1×1: artwork filling the circle with the play state on top.
|
||||
ClippingRectangle {
|
||||
visible: root.compact
|
||||
x: root.background.x
|
||||
y: root.background.y
|
||||
width: root.background.width
|
||||
height: root.background.height
|
||||
radius: width / 2
|
||||
color: Theme.transparent
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: root.compact ? MediaService.artwork : ""
|
||||
sourceSize: Qt.size(128, 128)
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
opacity: 0.55
|
||||
}
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Icons.available ? (MediaService.playing ? "" : "") : (MediaService.playing ? "Ⅱ" : "▶")
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: Math.round(root.background.width * 0.32)
|
||||
color: Theme.text
|
||||
}
|
||||
}
|
||||
|
||||
// One row: artwork, track, controls.
|
||||
RowLayout {
|
||||
visible: root.wide && !root.tall
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
anchors.rightMargin: 12
|
||||
spacing: 10
|
||||
Art {
|
||||
size: root.baseHeight - 20
|
||||
}
|
||||
Track {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Controls {
|
||||
full: root.cols >= 3
|
||||
}
|
||||
}
|
||||
|
||||
// One column: artwork above the play button.
|
||||
ColumnLayout {
|
||||
visible: !root.wide && root.tall
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
spacing: 8
|
||||
Art {
|
||||
size: Math.min(root.width - 20, root.baseHeight - 64)
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
Track {
|
||||
visible: root.rows >= 3
|
||||
titleSize: 11
|
||||
align: Text.AlignHCenter
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
Controls {
|
||||
full: false
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
// Large: artwork and track on top, controls along the bottom.
|
||||
ColumnLayout {
|
||||
visible: root.wide && root.tall
|
||||
anchors.fill: parent
|
||||
anchors.margins: 14
|
||||
spacing: 8
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 12
|
||||
Art {
|
||||
size: Math.min(root.rows >= 3 ? 96 : 56, root.width / 2 - 14)
|
||||
}
|
||||
Track {
|
||||
titleSize: root.cols >= 3 ? 15 : 13
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
RowLayout {
|
||||
visible: root.showProgress
|
||||
Layout.fillWidth: true
|
||||
spacing: 6
|
||||
Text {
|
||||
text: MediaService.time(MediaService.position)
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
}
|
||||
GlassSlider {
|
||||
Layout.fillWidth: true
|
||||
from: 0
|
||||
to: Math.max(1, MediaService.length)
|
||||
value: MediaService.position
|
||||
enabled: MediaService.seekable
|
||||
onMoved: MediaService.seek(value)
|
||||
Accessible.name: "Track position"
|
||||
}
|
||||
Text {
|
||||
text: "−" + MediaService.time(MediaService.length - MediaService.position)
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
}
|
||||
}
|
||||
Controls {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
|
||||
// Output volume. Right click (or spare rows) shows devices and per-app volume.
|
||||
CCSlider {
|
||||
readonly property var node: AudioService.sink
|
||||
objectName: "outputTile"
|
||||
title: "Sound"
|
||||
glyph: ""
|
||||
mutedGlyph: ""
|
||||
fallback: "♪"
|
||||
sliderName: "volumeSlider"
|
||||
muteName: "volumeMute"
|
||||
muteable: true
|
||||
enabled: !!node && !!node.audio
|
||||
muted: enabled && node.audio.muted
|
||||
value: enabled ? node.audio.volume : 0
|
||||
notice: AudioService.available ? "" : "PipeWire is unavailable"
|
||||
onMoved: value => AudioService.volume(false, value)
|
||||
onMuteClicked: AudioService.mute(false)
|
||||
extension: AudioMixer {}
|
||||
}
|
||||
@@ -6,55 +6,94 @@ import "../../components"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
ControlCard {
|
||||
// Session actions as round buttons, wrapped to the tile. When they do not fit
|
||||
// it becomes one power button that extends into a list. Confirmation for
|
||||
// destructive actions extends below the tile.
|
||||
CCModule {
|
||||
id: root
|
||||
readonly property var actions: [
|
||||
{
|
||||
id: "lock",
|
||||
glyph: "",
|
||||
label: "Lock"
|
||||
},
|
||||
{
|
||||
id: "logout",
|
||||
glyph: "",
|
||||
label: "Log out"
|
||||
},
|
||||
{
|
||||
id: "suspend",
|
||||
glyph: "",
|
||||
label: "Suspend"
|
||||
},
|
||||
{
|
||||
id: "reboot",
|
||||
glyph: "",
|
||||
label: "Reboot"
|
||||
},
|
||||
{
|
||||
id: "shutdown",
|
||||
glyph: "",
|
||||
label: "Shut down"
|
||||
}
|
||||
]
|
||||
readonly property real innerWidth: width - 20
|
||||
readonly property real innerHeight: baseHeight - 12
|
||||
readonly property int count: actions.length
|
||||
function perRowFor(slot) {
|
||||
return Math.max(1, Math.min(count, Math.floor((innerWidth + 4) / (slot + 4))));
|
||||
}
|
||||
function heightFor(perRow, rowHeight) {
|
||||
return Math.ceil(count / perRow) * (rowHeight + 4) - 4;
|
||||
}
|
||||
// Labelled buttons where they fit on four-wide or taller tiles, else plain
|
||||
// 34 px buttons, else one row of smaller ones, else the menu button.
|
||||
readonly property bool labels: (cols >= 4 || rows >= 2) && heightFor(perRowFor(52), 49) <= innerHeight
|
||||
readonly property bool plain: !labels && heightFor(perRowFor(34), 34) <= innerHeight
|
||||
readonly property real squeezed: Math.min(innerHeight, Math.floor((innerWidth - 4 * (count - 1)) / count))
|
||||
readonly property int perRow: labels ? perRowFor(52) : plain ? perRowFor(34) : count
|
||||
readonly property real buttonSize: labels || plain ? 34 : squeezed
|
||||
readonly property real buttonWidth: labels ? 52 : buttonSize
|
||||
readonly property bool fits: labels || plain || squeezed >= 24
|
||||
readonly property bool pending: PowerService.pending !== ""
|
||||
round: !fits
|
||||
hovered: menuArea.containsMouse
|
||||
extraHeight: (pending || (expanded && !fits)) && extension.item ? extension.implicitHeight + 20 : 0
|
||||
Component.onDestruction: PowerService.cancel()
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 4
|
||||
function allowed(id) {
|
||||
return (id === "lock" && ConfigService.ready && ConfigService.data.lock.enabled) || (!!SystemService.state.power && !!SystemService.state.power[id] && !SystemService.acting);
|
||||
}
|
||||
|
||||
// Everything fits: a wrapped grid of buttons.
|
||||
GridLayout {
|
||||
visible: root.fits
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: (root.baseHeight - height) / 2
|
||||
columns: root.perRow
|
||||
rowSpacing: 4
|
||||
columnSpacing: Math.max(4, (root.innerWidth - root.perRow * root.buttonWidth) / Math.max(1, root.perRow - 1) - 2)
|
||||
Repeater {
|
||||
model: [
|
||||
{
|
||||
id: "lock",
|
||||
glyph: ""
|
||||
},
|
||||
{
|
||||
id: "logout",
|
||||
glyph: ""
|
||||
},
|
||||
{
|
||||
id: "suspend",
|
||||
glyph: ""
|
||||
},
|
||||
{
|
||||
id: "reboot",
|
||||
glyph: ""
|
||||
},
|
||||
{
|
||||
id: "shutdown",
|
||||
glyph: ""
|
||||
}
|
||||
]
|
||||
model: root.actions
|
||||
ColumnLayout {
|
||||
id: action
|
||||
required property var modelData
|
||||
readonly property string label: modelData.id === "logout" ? "Log out" : modelData.id === "shutdown" ? "Shut down" : modelData.id.charAt(0).toUpperCase() + modelData.id.slice(1)
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 1
|
||||
spacing: 4
|
||||
Layout.preferredWidth: root.buttonWidth
|
||||
spacing: 3
|
||||
CCToggle {
|
||||
objectName: "power-" + action.modelData.id
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
size: 38
|
||||
size: root.buttonSize
|
||||
glyph: action.modelData.glyph
|
||||
fallback: action.label.charAt(0)
|
||||
fallback: action.modelData.label.charAt(0)
|
||||
checked: PowerService.pending === action.modelData.id
|
||||
enabled: (action.modelData.id === "lock" && ConfigService.ready && ConfigService.data.lock.enabled) || (!!SystemService.state.power && !!SystemService.state.power[action.modelData.id] && !SystemService.acting)
|
||||
enabled: root.allowed(action.modelData.id)
|
||||
onClicked: PowerService.request(action.modelData.id)
|
||||
Accessible.name: action.label
|
||||
Accessible.name: action.modelData.label
|
||||
}
|
||||
Text {
|
||||
text: action.label
|
||||
visible: root.labels
|
||||
text: action.modelData.label
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
elide: Text.ElideRight
|
||||
@@ -64,28 +103,119 @@ ControlCard {
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
visible: PowerService.pending !== ""
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
Text {
|
||||
text: "Confirm " + PowerService.pending + "? Unsaved work may be lost."
|
||||
color: Theme.text
|
||||
font.pixelSize: 12
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
|
||||
// Too small: one button that extends into the list.
|
||||
MouseArea {
|
||||
id: menuArea
|
||||
visible: !root.fits
|
||||
width: parent.width
|
||||
height: root.baseHeight
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.expanded = !root.expanded
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: "Power"
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: 2
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: Icons.available ? "" : "⏻"
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: Math.min(26, root.innerHeight * 0.5)
|
||||
color: Theme.text
|
||||
}
|
||||
Text {
|
||||
visible: root.innerHeight >= 44
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Power"
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
}
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "powerCancel"
|
||||
text: "Cancel"
|
||||
onClicked: PowerService.cancel()
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: extension
|
||||
x: 10
|
||||
y: root.baseHeight + 6
|
||||
width: root.width - 20
|
||||
active: root.pending || (root.expanded && !root.fits)
|
||||
sourceComponent: root.pending ? confirm : menu
|
||||
}
|
||||
Component {
|
||||
id: menu
|
||||
ColumnLayout {
|
||||
spacing: 2
|
||||
Repeater {
|
||||
model: root.actions
|
||||
Rectangle {
|
||||
id: item
|
||||
required property var modelData
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 30
|
||||
radius: 8
|
||||
enabled: root.allowed(modelData.id)
|
||||
opacity: enabled ? 1 : 0.45
|
||||
color: itemArea.containsMouse ? Theme.hover : Theme.transparent
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
spacing: 8
|
||||
Text {
|
||||
text: Icons.available ? item.modelData.glyph : ""
|
||||
font.family: Icons.family
|
||||
font.pixelSize: 14
|
||||
color: Theme.text
|
||||
}
|
||||
Text {
|
||||
text: item.modelData.label
|
||||
color: Theme.text
|
||||
font.pixelSize: 12
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: itemArea
|
||||
objectName: "power-" + item.modelData.id
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: PowerService.request(item.modelData.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "powerConfirm"
|
||||
text: "Confirm"
|
||||
accented: true
|
||||
enabled: !SystemService.acting
|
||||
onClicked: PowerService.confirm()
|
||||
}
|
||||
Component {
|
||||
id: confirm
|
||||
ColumnLayout {
|
||||
spacing: 8
|
||||
Text {
|
||||
text: "Confirm " + PowerService.pending + "? Unsaved work may be lost."
|
||||
color: Theme.text
|
||||
font.pixelSize: 12
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
spacing: 8
|
||||
GlassButton {
|
||||
objectName: "powerCancel"
|
||||
text: "Cancel"
|
||||
onClicked: PowerService.cancel()
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "powerConfirm"
|
||||
text: "Confirm"
|
||||
accented: true
|
||||
enabled: !SystemService.acting
|
||||
onClicked: PowerService.confirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
@@ -15,6 +16,7 @@ CCTile {
|
||||
title: "Power profile"
|
||||
detail: !info.available ? "Unavailable" : current ? current.charAt(0).toUpperCase() + current.slice(1).replace(/-/g, " ") : "—"
|
||||
glyph: current === "power-saver" ? "" : current === "performance" ? "" : ""
|
||||
page: "power"
|
||||
fallback: "P"
|
||||
checked: info.available && current !== "" && current !== "balanced"
|
||||
enabled: !!info.available && profiles.length > 1 && !SystemService.acting
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import ".."
|
||||
import "../../services"
|
||||
|
||||
CCTile {
|
||||
objectName: "wifiToggle"
|
||||
title: "Wi-Fi"
|
||||
detail: !NetworkService.available ? "No Wi-Fi adapter" : !NetworkService.backend.wifiHardwareEnabled ? "Hardware blocked" : NetworkService.enabled ? NetworkService.summary : "Off"
|
||||
page: "network"
|
||||
glyph: NetworkService.enabled ? "" : ""
|
||||
fallback: "W"
|
||||
checked: NetworkService.available && NetworkService.enabled
|
||||
enabled: NetworkService.available && NetworkService.backend.wifiHardwareEnabled
|
||||
onClicked: NetworkService.toggle()
|
||||
}
|
||||
Reference in new issue
Block a user