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
+2110
-318
No files matched your search
@@ -175,9 +175,15 @@ without replacing your saved layout. Cava is optional and off by default.
|
|||||||
## Control Center
|
## Control Center
|
||||||
|
|
||||||
Click the right-hand system pill or run `./scripts/glassmxrph controlcenter`.
|
Click the right-hand system pill or run `./scripts/glassmxrph controlcenter`.
|
||||||
Control Center opens at the active monitor's upper-right, with configurable modules
|
Control Center opens at the active monitor's upper-right. Its modules sit on a
|
||||||
for connectivity, audio/microphone, brightness, Night Light, DND, power profiles,
|
4-column grid: Wi-Fi, Bluetooth, network throughput, sound, microphone, display
|
||||||
shared media and power actions. Settings → Control Center enables/reorders modules.
|
brightness, Night Light, DND, Caffeine (keeps the system awake via `systemd-inhibit`),
|
||||||
|
power profile, Now Playing, power actions and system metrics, with Notifications
|
||||||
|
below. Each tile can be any size from 1×1 to 4×4 and adapts its layout to it.
|
||||||
|
**Edit Controls** at the bottom of the panel lets you drag tiles to reorder them,
|
||||||
|
resize them from the corner handle, remove them with the badge and add others.
|
||||||
|
Right-click Sound to extend it with output devices and a volume slider per app
|
||||||
|
(the players EasyEffects processes); right-click a toggle to open its settings.
|
||||||
Logout, reboot and shutdown require explicit confirmation.
|
Logout, reboot and shutdown require explicit confirmation.
|
||||||
|
|
||||||
NetworkManager, BlueZ and PipeWire use native Quickshell models. Other controls reuse
|
NetworkManager, BlueZ and PipeWire use native Quickshell models. Other controls reuse
|
||||||
|
|||||||
@@ -114,6 +114,15 @@ failures do not cause restart loops. Song artwork never changes the global accen
|
|||||||
## Phase 7 system controls
|
## Phase 7 system controls
|
||||||
|
|
||||||
`ControlCenter` is an active-monitor overlay with a registry-driven module layout.
|
`ControlCenter` is an active-monitor overlay with a registry-driven module layout.
|
||||||
|
Modules are `CCModule` tiles on a 4-column grid (`controlcenter/GridLogic.js` packs
|
||||||
|
them first-fit in configured order); each has a default size in `ControlRegistry`
|
||||||
|
and an optional per-module `w`/`h` (1–4) in `controlCenter.modules`, set from the
|
||||||
|
panel's edit mode. Tiles adapt their layout to their size. A tile can extend below
|
||||||
|
its cells (`extraHeight`: the Sound mixer, power confirmation) and the grid moves
|
||||||
|
the tiles underneath down. Config version 2 split the old Connectivity and Audio
|
||||||
|
cards into Wi-Fi/Bluetooth/Network and Output/Input. `CaffeineService` holds a
|
||||||
|
`systemd-inhibit` idle/sleep lock while on; `AudioService.streams` lists app
|
||||||
|
playback streams, tracked only while a mixer holds a `Demand`.
|
||||||
`ShellState` coordinates its visibility with existing shell popups. `AudioService`,
|
`ShellState` coordinates its visibility with existing shell popups. `AudioService`,
|
||||||
`NetworkService` and `BluetoothService` adapt native Quickshell event-driven models.
|
`NetworkService` and `BluetoothService` adapt native Quickshell event-driven models.
|
||||||
`SystemService` serializes one-shot JSON provider jobs for visible display/DND/power
|
`SystemService` serializes one-shot JSON provider jobs for visible display/DND/power
|
||||||
|
|||||||
@@ -150,41 +150,61 @@
|
|||||||
"history": []
|
"history": []
|
||||||
},
|
},
|
||||||
"controlCenter": {
|
"controlCenter": {
|
||||||
"version": 1,
|
"version": 2,
|
||||||
"width": 400,
|
"width": 400,
|
||||||
"modules": [
|
"modules": [
|
||||||
{
|
{
|
||||||
"id": "connectivity",
|
"id": "wifi",
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "audio",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "brightness",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "nightLight",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dnd",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "profiles",
|
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "media",
|
"id": "media",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "bluetooth",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dnd",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "nightLight",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "caffeine",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "profiles",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "output",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "input",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "brightness",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "power",
|
"id": "power",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "network",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "metrics",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "notifications",
|
"id": "notifications",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
|||||||
@@ -0,0 +1,170 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import "../components"
|
||||||
|
import "../services"
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
// Extension of the Output and Input tiles: device choice, and for output a
|
||||||
|
// volume slider per app stream (the players EasyEffects processes).
|
||||||
|
ColumnLayout {
|
||||||
|
id: root
|
||||||
|
property bool input: false
|
||||||
|
readonly property var nodes: input ? AudioService.inputs : AudioService.outputs
|
||||||
|
readonly property var current: input ? AudioService.source : AudioService.sink
|
||||||
|
spacing: 2
|
||||||
|
Demand {
|
||||||
|
service: AudioService
|
||||||
|
counter: "streamConsumers"
|
||||||
|
active: !root.input
|
||||||
|
}
|
||||||
|
component Heading: Text {
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 10
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
font.letterSpacing: 1.1
|
||||||
|
Layout.topMargin: 4
|
||||||
|
Layout.bottomMargin: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
Heading {
|
||||||
|
text: root.input ? "INPUT DEVICE" : "OUTPUT DEVICE"
|
||||||
|
}
|
||||||
|
Repeater {
|
||||||
|
model: root.nodes
|
||||||
|
Rectangle {
|
||||||
|
id: device
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: modelData === root.current
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: 28
|
||||||
|
radius: 8
|
||||||
|
color: deviceArea.containsMouse ? Qt.alpha(Theme.text, 0.08) : Theme.transparent
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 6
|
||||||
|
anchors.rightMargin: 6
|
||||||
|
spacing: 8
|
||||||
|
Text {
|
||||||
|
text: device.selected ? "✓" : ""
|
||||||
|
color: Theme.accent
|
||||||
|
font.pixelSize: 12
|
||||||
|
Layout.preferredWidth: 12
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: device.modelData.description || device.modelData.name
|
||||||
|
color: device.selected ? Theme.text : Qt.alpha(Theme.text, 0.8)
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.weight: device.selected ? Font.DemiBold : Font.Normal
|
||||||
|
elide: Text.ElideRight
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: deviceArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: AudioService.select(root.input, device.index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Heading {
|
||||||
|
visible: !root.input
|
||||||
|
text: "APPLICATIONS"
|
||||||
|
Layout.topMargin: 8
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible: !root.input && AudioService.streams.length === 0
|
||||||
|
text: "No apps are playing audio"
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
Layout.leftMargin: 6
|
||||||
|
}
|
||||||
|
Repeater {
|
||||||
|
model: root.input ? [] : AudioService.streams
|
||||||
|
RowLayout {
|
||||||
|
id: stream
|
||||||
|
required property var modelData
|
||||||
|
readonly property bool muted: !!modelData.audio && modelData.audio.muted
|
||||||
|
readonly property string icon: AudioService.streamIcon(modelData)
|
||||||
|
objectName: "appVolume-" + AudioService.streamName(modelData)
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
spacing: 8
|
||||||
|
// The app icon doubles as its mute button.
|
||||||
|
Item {
|
||||||
|
implicitWidth: 22
|
||||||
|
implicitHeight: 22
|
||||||
|
opacity: stream.muted ? 0.4 : 1
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: (stream.muted ? "Unmute " : "Mute ") + AudioService.streamName(stream.modelData)
|
||||||
|
IconImage {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: stream.icon !== ""
|
||||||
|
source: stream.icon
|
||||||
|
asynchronous: true
|
||||||
|
}
|
||||||
|
GlassIcon {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: stream.icon === ""
|
||||||
|
size: 22
|
||||||
|
glyphSize: 11
|
||||||
|
fallback: AudioService.streamName(stream.modelData).charAt(0).toUpperCase()
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible: stream.muted
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.margins: -3
|
||||||
|
text: Icons.available ? "" : "×"
|
||||||
|
font.family: Icons.available ? Icons.family : ""
|
||||||
|
font.pixelSize: 11
|
||||||
|
color: Theme.text
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
objectName: "appMute-" + AudioService.streamName(stream.modelData)
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: AudioService.streamMute(stream.modelData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: 2
|
||||||
|
Text {
|
||||||
|
text: AudioService.streamName(stream.modelData)
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 11
|
||||||
|
elide: Text.ElideRight
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
GlassBarSlider {
|
||||||
|
id: level
|
||||||
|
objectName: "appSlider-" + AudioService.streamName(stream.modelData)
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: 10
|
||||||
|
from: 0
|
||||||
|
to: 1
|
||||||
|
stepSize: 0.01
|
||||||
|
enabled: !!stream.modelData.audio
|
||||||
|
value: stream.modelData.audio ? stream.modelData.audio.volume : 0
|
||||||
|
onMoved: AudioService.streamVolume(stream.modelData, value)
|
||||||
|
onPressedChanged: if (!pressed)
|
||||||
|
value = Qt.binding(() => stream.modelData.audio ? stream.modelData.audio.volume : 0)
|
||||||
|
Accessible.name: AudioService.streamName(stream.modelData) + " volume"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: stream.modelData.audio ? Math.round(stream.modelData.audio.volume * 100) + "%" : "—"
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
Layout.preferredWidth: 32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
// Control Center grid tile. Modules fill their cells and adapt to `cols` ×
|
||||||
|
// `rows` (1–4 each). A module can extend below its cells (`extraHeight`, e.g.
|
||||||
|
// per-app volume); the grid moves the tiles underneath down to make room.
|
||||||
|
// Outside the grid (Settings pages) it is a 4×1 tile that grows the same way.
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
default property alias content: body.data
|
||||||
|
property int cols: 4
|
||||||
|
property int rows: 1
|
||||||
|
// Height of the cells, without the extension; the grid sets it.
|
||||||
|
property real baseHeight: rows * 68 + (rows - 1) * 10
|
||||||
|
// Height wanted below the cells while extended; 0 when not.
|
||||||
|
property real extraHeight: 0
|
||||||
|
property bool expanded: false
|
||||||
|
// 1×1 toggles draw as a circle centred in their cell.
|
||||||
|
property bool round: false
|
||||||
|
property bool hovered: false
|
||||||
|
property color color: hovered ? Theme.hover : Theme.fill
|
||||||
|
readonly property bool compact: cols === 1 && rows === 1
|
||||||
|
readonly property bool wide: cols >= 2
|
||||||
|
readonly property bool tall: rows >= 2
|
||||||
|
readonly property bool circle: round && compact && extraHeight <= 0
|
||||||
|
readonly property alias background: bg
|
||||||
|
implicitWidth: 360
|
||||||
|
implicitHeight: baseHeight + (extraHeight > 0 ? extraHeight + 10 : 0)
|
||||||
|
Rectangle {
|
||||||
|
id: bg
|
||||||
|
readonly property real d: Math.min(root.width, root.baseHeight)
|
||||||
|
x: root.circle ? (root.width - d) / 2 : 0
|
||||||
|
width: root.circle ? d : root.width
|
||||||
|
height: root.circle ? d : root.height
|
||||||
|
radius: root.circle ? d / 2 : Math.min(30, root.baseHeight / 2, root.width / 2)
|
||||||
|
color: root.color
|
||||||
|
border.width: 1
|
||||||
|
border.color: Theme.hairline
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
id: body
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import "../components"
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
// Level tile (volume, microphone, brightness). One row is a title over a
|
||||||
|
// slider; 1 wide and taller is a vertical slider; 1×1 is a round button that
|
||||||
|
// shows the level, toggles mute and scrolls to adjust. An `extension` (e.g.
|
||||||
|
// the per-app mixer) fills spare rows of wide tall tiles, and right click
|
||||||
|
// extends the tile down to show it at other sizes.
|
||||||
|
CCModule {
|
||||||
|
id: root
|
||||||
|
property string title
|
||||||
|
property string glyph
|
||||||
|
property string fallback
|
||||||
|
property string mutedGlyph: glyph
|
||||||
|
property real value: 0
|
||||||
|
property real from: 0
|
||||||
|
property real to: 1
|
||||||
|
property real stepSize: 0.01
|
||||||
|
property bool muted: false
|
||||||
|
property bool muteable: false
|
||||||
|
property string sliderName
|
||||||
|
property string muteName
|
||||||
|
property string notice
|
||||||
|
property Component extension: null
|
||||||
|
readonly property alias slider: horizontal
|
||||||
|
readonly property bool inline: !!extension && wide && tall
|
||||||
|
// Whether `value` is real; it can be while the slider is briefly disabled.
|
||||||
|
property bool known: enabled
|
||||||
|
readonly property string percent: known ? Math.round((value - from) / Math.max(1e-9, to - from) * 100) + "%" : "—"
|
||||||
|
// Live changes while dragging, and the final value on release.
|
||||||
|
signal moved(real value)
|
||||||
|
signal committed(real value)
|
||||||
|
signal muteClicked
|
||||||
|
round: true
|
||||||
|
hovered: area.containsMouse
|
||||||
|
extraHeight: expanded && outer.item ? outer.implicitHeight + 24 : 0
|
||||||
|
function nudge(steps) {
|
||||||
|
const next = Math.max(from, Math.min(to, value + steps * (to - from) / 20));
|
||||||
|
moved(next);
|
||||||
|
committed(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
component Level: GlassBarSlider {
|
||||||
|
from: root.from
|
||||||
|
to: root.to
|
||||||
|
stepSize: root.stepSize
|
||||||
|
value: root.value
|
||||||
|
enabled: root.enabled
|
||||||
|
// The mute button carries the icon when there is one.
|
||||||
|
glyph: root.muteable ? "" : root.glyph
|
||||||
|
fallback: root.muteable ? "" : root.fallback
|
||||||
|
onMoved: root.moved(value)
|
||||||
|
// Dragging writes `value`; follow the source again once released.
|
||||||
|
onPressedChanged: if (!pressed) {
|
||||||
|
root.committed(value);
|
||||||
|
value = Qt.binding(() => root.value);
|
||||||
|
}
|
||||||
|
Keys.onReleased: event => {
|
||||||
|
if (event.key === Qt.Key_Left || event.key === Qt.Key_Right || event.key === Qt.Key_Up || event.key === Qt.Key_Down)
|
||||||
|
root.committed(value);
|
||||||
|
}
|
||||||
|
Accessible.name: root.title
|
||||||
|
}
|
||||||
|
component Mute: CCToggle {
|
||||||
|
visible: root.muteable
|
||||||
|
size: 26
|
||||||
|
glyph: root.muted ? root.mutedGlyph : root.glyph
|
||||||
|
fallback: root.muted ? "×" : root.fallback
|
||||||
|
checked: root.muted
|
||||||
|
enabled: root.enabled
|
||||||
|
onClicked: root.muteClicked()
|
||||||
|
Accessible.name: "Mute " + root.title
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: area
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.RightButton && root.extension && !root.inline)
|
||||||
|
root.expanded = !root.expanded;
|
||||||
|
else if (mouse.button === Qt.LeftButton && root.compact && root.muteable)
|
||||||
|
root.muteClicked();
|
||||||
|
}
|
||||||
|
onWheel: wheel => {
|
||||||
|
if (root.enabled)
|
||||||
|
root.nudge(wheel.angleDelta.y > 0 ? 1 : wheel.angleDelta.y < 0 ? -1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GlassToolTip {
|
||||||
|
visible: root.compact && area.containsMouse
|
||||||
|
delay: 500
|
||||||
|
text: root.title + " · " + root.percent
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1×1: icon and level in a circle.
|
||||||
|
Column {
|
||||||
|
visible: root.compact
|
||||||
|
x: (root.width - width) / 2
|
||||||
|
y: (root.baseHeight - height) / 2
|
||||||
|
spacing: 1
|
||||||
|
Text {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
text: Icons.available && root.glyph ? (root.muted ? root.mutedGlyph : root.glyph) : root.fallback
|
||||||
|
font.family: Icons.available && root.glyph ? Icons.family : ""
|
||||||
|
font.pixelSize: Math.round(root.background.width * 0.3)
|
||||||
|
color: root.muted ? Theme.textSecondary : Theme.text
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
text: root.percent
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 10
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// One column: a vertical slider with mute above it.
|
||||||
|
ColumnLayout {
|
||||||
|
visible: !root.wide && root.tall
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 12
|
||||||
|
anchors.bottomMargin: 12 + root.height - root.baseHeight
|
||||||
|
spacing: 8
|
||||||
|
Mute {
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible: !root.muteable
|
||||||
|
text: root.percent
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 10
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
Level {
|
||||||
|
orientation: Qt.Vertical
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.preferredWidth: Math.min(40, root.width - 34)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wide: title and level over the slider, then the extension in spare rows.
|
||||||
|
ColumnLayout {
|
||||||
|
id: wideLayout
|
||||||
|
visible: root.wide
|
||||||
|
x: 14
|
||||||
|
y: root.tall ? 12 : (root.baseHeight - implicitHeight) / 2
|
||||||
|
width: root.width - 28
|
||||||
|
spacing: 6
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Text {
|
||||||
|
text: root.title
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
elide: Text.ElideRight
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: root.notice || root.percent
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
elide: Text.ElideRight
|
||||||
|
Layout.maximumWidth: root.width * 0.6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: 8
|
||||||
|
Mute {
|
||||||
|
objectName: root.muteName
|
||||||
|
}
|
||||||
|
Level {
|
||||||
|
id: horizontal
|
||||||
|
objectName: root.sliderName
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: root.tall ? 30 : 26
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Flickable {
|
||||||
|
visible: root.inline
|
||||||
|
x: 14
|
||||||
|
y: wideLayout.y + wideLayout.height + 10
|
||||||
|
width: root.width - 28
|
||||||
|
height: root.baseHeight - y - 10
|
||||||
|
clip: true
|
||||||
|
contentHeight: inner.implicitHeight
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar {
|
||||||
|
policy: ScrollBar.AsNeeded
|
||||||
|
}
|
||||||
|
Loader {
|
||||||
|
id: inner
|
||||||
|
width: parent.width
|
||||||
|
active: root.inline
|
||||||
|
sourceComponent: root.extension
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Extended below the cells.
|
||||||
|
Loader {
|
||||||
|
id: outer
|
||||||
|
x: 14
|
||||||
|
y: root.baseHeight + 6
|
||||||
|
width: root.width - 28
|
||||||
|
active: root.expanded && !root.inline
|
||||||
|
sourceComponent: root.extension
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,50 +1,46 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import "../components"
|
||||||
|
import "../core"
|
||||||
import "../theme"
|
import "../theme"
|
||||||
|
|
||||||
// Small Control Center tile: round toggle, title and state; the whole tile toggles.
|
// Toggle tile: icon, title and state. 1×1 is a round toggle, one row is a pill
|
||||||
ControlCard {
|
// with labels beside the icon, taller tiles stack them. Left click toggles;
|
||||||
|
// right click opens the matching Settings page.
|
||||||
|
CCModule {
|
||||||
id: root
|
id: root
|
||||||
|
property string title
|
||||||
property string glyph
|
property string glyph
|
||||||
property string fallback
|
property string fallback
|
||||||
property string detail
|
property string detail
|
||||||
|
property string page
|
||||||
property bool checked: false
|
property bool checked: false
|
||||||
|
// 1×1 shows the icon; modules with their own compact face turn it off.
|
||||||
|
property bool compactGlyph: true
|
||||||
signal clicked
|
signal clicked
|
||||||
padding: 10
|
signal secondaryClicked
|
||||||
heading: false
|
round: true
|
||||||
|
hovered: area.containsMouse && enabled
|
||||||
opacity: enabled ? 1 : 0.55
|
opacity: enabled ? 1 : 0.55
|
||||||
color: area.containsMouse && enabled ? Theme.hover : Theme.fill
|
color: compact && checked ? Theme.accent : hovered ? Theme.hover : Theme.fill
|
||||||
Accessible.role: Accessible.CheckBox
|
Accessible.role: Accessible.CheckBox
|
||||||
Accessible.name: title
|
Accessible.name: title
|
||||||
Accessible.checked: checked
|
Accessible.checked: checked
|
||||||
MouseArea {
|
onSecondaryClicked: if (page)
|
||||||
id: area
|
ShellState.openSettings(page)
|
||||||
parent: root
|
|
||||||
z: -1
|
component Labels: ColumnLayout {
|
||||||
anchors.fill: parent
|
property int align: Text.AlignLeft
|
||||||
hoverEnabled: true
|
property int lines: 1
|
||||||
cursorShape: Qt.PointingHandCursor
|
spacing: 1
|
||||||
onClicked: root.clicked()
|
|
||||||
}
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: 10
|
|
||||||
CCToggle {
|
|
||||||
glyph: root.glyph
|
|
||||||
fallback: root.fallback
|
|
||||||
checked: root.checked
|
|
||||||
enabled: root.enabled
|
|
||||||
onClicked: root.clicked()
|
|
||||||
}
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: 0
|
|
||||||
Text {
|
Text {
|
||||||
text: root.title
|
text: root.title
|
||||||
color: Theme.text
|
color: Theme.text
|
||||||
font.pixelSize: 12
|
font.pixelSize: root.wide && root.tall ? 14 : 12
|
||||||
font.weight: Font.DemiBold
|
font.weight: Font.DemiBold
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
horizontalAlignment: parent.align
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
@@ -53,8 +49,102 @@ ControlCard {
|
|||||||
color: Theme.textSecondary
|
color: Theme.textSecondary
|
||||||
font.pixelSize: 11
|
font.pixelSize: 11
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
wrapMode: parent.lines > 1 ? Text.Wrap : Text.NoWrap
|
||||||
|
maximumLineCount: parent.lines
|
||||||
|
horizontalAlignment: parent.align
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: area
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: mouse => mouse.button === Qt.RightButton ? root.secondaryClicked() : root.clicked()
|
||||||
|
}
|
||||||
|
GlassToolTip {
|
||||||
|
visible: root.compact && area.containsMouse
|
||||||
|
delay: 500
|
||||||
|
text: root.title + (root.detail ? " · " + root.detail : "")
|
||||||
|
}
|
||||||
|
// 1×1: the circle itself is the toggle.
|
||||||
|
Text {
|
||||||
|
visible: root.compact && root.compactGlyph
|
||||||
|
x: root.background.x + (root.background.width - width) / 2
|
||||||
|
y: root.background.y + (root.background.height - height) / 2
|
||||||
|
text: Icons.available && root.glyph ? root.glyph : root.fallback
|
||||||
|
font.family: Icons.available && root.glyph ? Icons.family : ""
|
||||||
|
font.pixelSize: Math.round(root.background.width * 0.34)
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
color: root.checked ? Theme.accentText : Theme.text
|
||||||
|
scale: area.pressed ? 0.92 : 1
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// One row: icon beside the labels.
|
||||||
|
RowLayout {
|
||||||
|
visible: root.wide && !root.tall
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: (root.baseHeight - toggleRow.size) / 2
|
||||||
|
anchors.rightMargin: 14
|
||||||
|
spacing: 10
|
||||||
|
CCToggle {
|
||||||
|
id: toggleRow
|
||||||
|
size: Math.min(38, root.baseHeight - 20)
|
||||||
|
glyph: root.glyph
|
||||||
|
fallback: root.fallback
|
||||||
|
checked: root.checked
|
||||||
|
enabled: root.enabled
|
||||||
|
onClicked: root.clicked()
|
||||||
|
}
|
||||||
|
Labels {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// One column: icon above centred labels.
|
||||||
|
ColumnLayout {
|
||||||
|
visible: !root.wide && root.tall
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.width - 16
|
||||||
|
spacing: 8
|
||||||
|
CCToggle {
|
||||||
|
size: Math.min(44, root.width - 24)
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
glyph: root.glyph
|
||||||
|
fallback: root.fallback
|
||||||
|
checked: root.checked
|
||||||
|
enabled: root.enabled
|
||||||
|
onClicked: root.clicked()
|
||||||
|
}
|
||||||
|
Labels {
|
||||||
|
align: Text.AlignHCenter
|
||||||
|
lines: Math.max(1, root.rows - 1)
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Large: icon top left, labels along the bottom.
|
||||||
|
CCToggle {
|
||||||
|
visible: root.wide && root.tall
|
||||||
|
x: 14
|
||||||
|
y: 14
|
||||||
|
size: 44
|
||||||
|
glyph: root.glyph
|
||||||
|
fallback: root.fallback
|
||||||
|
checked: root.checked
|
||||||
|
enabled: root.enabled
|
||||||
|
onClicked: root.clicked()
|
||||||
|
}
|
||||||
|
Labels {
|
||||||
|
visible: root.wide && root.tall
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.margins: 14
|
||||||
|
lines: root.rows - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import "../components"
|
|||||||
import "../services"
|
import "../services"
|
||||||
import "../core"
|
import "../core"
|
||||||
import "../theme"
|
import "../theme"
|
||||||
|
import "GridLogic.js" as Grid
|
||||||
|
|
||||||
// macOS-style Control Center. The layer surface is sized to the panel so
|
// macOS-style Control Center. The layer surface is sized to the panel so
|
||||||
// compositor glass (HyprGlass) shapes its edges to the panel, not the screen.
|
// compositor glass (HyprGlass) shapes its edges to the panel, not the screen.
|
||||||
@@ -45,44 +46,79 @@ PanelWindow {
|
|||||||
Component.onCompleted: ShellState.controlCenterWindow = root
|
Component.onCompleted: ShellState.controlCenterWindow = root
|
||||||
Component.onDestruction: ShellState.controlCenterWindow = null
|
Component.onDestruction: ShellState.controlCenterWindow = null
|
||||||
|
|
||||||
// Connectivity and the small tiles share one block (connectivity left, tiles
|
// Modules on a 4-column grid, packed first-fit in the configured order;
|
||||||
// stacked right), placed where the first of them appears; other modules
|
// Notifications is a section under it. Edit mode reorders by dragging,
|
||||||
// span the full width in their configured order.
|
// resizes from the corner handle, removes with the badge and adds from a tray.
|
||||||
readonly property var smallTiles: ["dnd", "nightLight", "profiles"]
|
readonly property int gap: 10
|
||||||
readonly property var blocks: {
|
readonly property int cellHeight: 68
|
||||||
if (!ConfigService.ready)
|
readonly property real gridWidth: panel.targetWidth - 28
|
||||||
return [];
|
readonly property real cellWidth: (gridWidth - 3 * gap) / Grid.COLS
|
||||||
const ids = ConfigService.data.controlCenter.modules.filter(m => m.enabled && !!ControlRegistry.entry(m.id)).map(m => m.id);
|
readonly property var entries: ConfigService.ready ? ConfigService.data.controlCenter.modules : []
|
||||||
const grouped = ids.filter(id => id === "connectivity" || smallTiles.includes(id));
|
readonly property var tiles: entries.filter(m => m.enabled && !!ControlRegistry.entry(m.id) && !ControlRegistry.entry(m.id).section)
|
||||||
const result = [];
|
readonly property bool notifications: entries.some(m => m.id === "notifications" && m.enabled)
|
||||||
let placed = false;
|
readonly property var addable: Object.keys(ControlRegistry.modules).filter(id => !entries.some(m => m.id === id && m.enabled))
|
||||||
for (const id of ids) {
|
property bool editing: false
|
||||||
if (!grouped.includes(id)) {
|
// Live edit previews: the order while a tile is dragged, a size while resized.
|
||||||
result.push({
|
property var dragOrder: null
|
||||||
kind: "full",
|
property string dragId: ""
|
||||||
ids: [id]
|
property point dragPoint
|
||||||
});
|
property point grabOffset
|
||||||
} else if (!placed) {
|
property string resizeId: ""
|
||||||
placed = true;
|
property var resizeSize: null
|
||||||
const tiles = grouped.filter(g => g !== "connectivity");
|
// Tile id -> pixels a tile extends below its cells.
|
||||||
if (!grouped.includes("connectivity"))
|
property var extras: ({})
|
||||||
result.push({
|
readonly property var order: dragOrder ? dragOrder.filter(id => tiles.some(m => m.id === id)) : tiles.map(m => m.id)
|
||||||
kind: "grid",
|
readonly property var plan: Grid.pack(order.map(id => {
|
||||||
ids: tiles
|
const m = tiles.find(t => t.id === id);
|
||||||
});
|
const size = id === resizeId && resizeSize ? resizeSize : ControlRegistry.size(m);
|
||||||
else if (tiles.length === 0)
|
return {
|
||||||
result.push({
|
id: id,
|
||||||
kind: "full",
|
w: size.w,
|
||||||
ids: ["connectivity"]
|
h: size.h
|
||||||
});
|
};
|
||||||
else
|
}))
|
||||||
result.push({
|
readonly property var geometry: Grid.geometry(plan, cellWidth, cellHeight, gap, editing ? {} : extras)
|
||||||
kind: "split",
|
function setExtra(id, value) {
|
||||||
ids: tiles
|
if ((extras[id] || 0) === value)
|
||||||
});
|
return;
|
||||||
|
const next = Object.assign({}, extras);
|
||||||
|
next[id] = value;
|
||||||
|
extras = next;
|
||||||
}
|
}
|
||||||
|
function cellAt(p) {
|
||||||
|
return Qt.point(Math.floor(p.x / (cellWidth + gap)), Math.floor(p.y / (cellHeight + gap)));
|
||||||
|
}
|
||||||
|
// Writes the module list back, keeping entries that are not grid tiles.
|
||||||
|
function saveOrder(ids) {
|
||||||
|
const rest = entries.filter(m => !ids.includes(m.id));
|
||||||
|
ConfigService.setValue("controlCenter.modules", ids.map(id => entries.find(m => m.id === id)).concat(rest));
|
||||||
|
}
|
||||||
|
function saveSize(id, size) {
|
||||||
|
ConfigService.setValue("controlCenter.modules", entries.map(m => m.id === id ? Object.assign({}, m, {
|
||||||
|
w: size.w,
|
||||||
|
h: size.h
|
||||||
|
}) : m));
|
||||||
|
}
|
||||||
|
function setEnabled(id, on) {
|
||||||
|
const known = entries.some(m => m.id === id);
|
||||||
|
ConfigService.setValue("controlCenter.modules", known ? entries.map(m => m.id === id ? Object.assign({}, m, {
|
||||||
|
enabled: on
|
||||||
|
}) : m) : entries.concat([
|
||||||
|
{
|
||||||
|
id: id,
|
||||||
|
enabled: on
|
||||||
|
}
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
function reset() {
|
||||||
|
ConfigService.setValue("controlCenter.modules", ConfigService.defaults.controlCenter.modules);
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: ShellState
|
||||||
|
function onControlCenterOpenChanged() {
|
||||||
|
if (!ShellState.controlCenterOpen)
|
||||||
|
root.editing = false;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
component ModuleSlot: Loader {
|
component ModuleSlot: Loader {
|
||||||
@@ -92,6 +128,62 @@ PanelWindow {
|
|||||||
active: ShellState.controlCenterOpen
|
active: ShellState.controlCenterOpen
|
||||||
source: moduleId ? ControlRegistry.entry(moduleId).source : ""
|
source: moduleId ? ControlRegistry.entry(moduleId).source : ""
|
||||||
}
|
}
|
||||||
|
component Badge: Rectangle {
|
||||||
|
id: badge
|
||||||
|
property string glyph
|
||||||
|
signal clicked
|
||||||
|
width: 22
|
||||||
|
height: 22
|
||||||
|
radius: 11
|
||||||
|
color: badgeArea.containsMouse ? Theme.accent : Theme.surface
|
||||||
|
border.width: 1
|
||||||
|
border.color: Qt.alpha(Theme.text, 0.35)
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: badge.glyph
|
||||||
|
color: badgeArea.containsMouse ? Theme.accentText : Theme.text
|
||||||
|
font.pixelSize: 15
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: badgeArea
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -3
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: badge.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
component Pill: Rectangle {
|
||||||
|
id: pill
|
||||||
|
property string text
|
||||||
|
property bool strong: false
|
||||||
|
signal clicked
|
||||||
|
implicitWidth: pillLabel.implicitWidth + 28
|
||||||
|
implicitHeight: 30
|
||||||
|
radius: 15
|
||||||
|
color: strong ? (pillArea.containsMouse ? Theme.accentHover : Theme.accent) : pillArea.containsMouse ? Theme.hover : Theme.fill
|
||||||
|
border.width: strong ? 0 : 1
|
||||||
|
border.color: Theme.hairline
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: text
|
||||||
|
Text {
|
||||||
|
id: pillLabel
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: pill.text
|
||||||
|
color: pill.strong ? Theme.accentText : Theme.text
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.weight: Font.Medium
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: pillArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: pill.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
component HeaderButton: Rectangle {
|
component HeaderButton: Rectangle {
|
||||||
id: headerButton
|
id: headerButton
|
||||||
property string glyph
|
property string glyph
|
||||||
@@ -152,6 +244,8 @@ PanelWindow {
|
|||||||
Keys.onEscapePressed: {
|
Keys.onEscapePressed: {
|
||||||
if (PowerService.pending)
|
if (PowerService.pending)
|
||||||
PowerService.cancel();
|
PowerService.cancel();
|
||||||
|
else if (root.editing)
|
||||||
|
root.editing = false;
|
||||||
else
|
else
|
||||||
ShellState.controlCenterOpen = false;
|
ShellState.controlCenterOpen = false;
|
||||||
}
|
}
|
||||||
@@ -179,13 +273,14 @@ PanelWindow {
|
|||||||
Layout.leftMargin: 4
|
Layout.leftMargin: 4
|
||||||
spacing: 2
|
spacing: 2
|
||||||
Text {
|
Text {
|
||||||
text: "Control Center"
|
text: root.editing ? "Edit Controls" : "Control Center"
|
||||||
color: Theme.text
|
color: Theme.text
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
font.weight: Font.DemiBold
|
font.weight: Font.DemiBold
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
HeaderButton {
|
HeaderButton {
|
||||||
|
visible: root.editing
|
||||||
glyph: ""
|
glyph: ""
|
||||||
fallback: "⚙"
|
fallback: "⚙"
|
||||||
onClicked: ShellState.openSettings("controlcenter")
|
onClicked: ShellState.openSettings("controlcenter")
|
||||||
@@ -198,61 +293,274 @@ PanelWindow {
|
|||||||
Accessible.name: "Close Control Center"
|
Accessible.name: "Close Control Center"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Repeater {
|
|
||||||
model: root.blocks
|
|
||||||
Item {
|
Item {
|
||||||
id: block
|
|
||||||
required property var modelData
|
|
||||||
Layout.fillWidth: true
|
|
||||||
implicitHeight: block.modelData.kind === "full" ? full.implicitHeight : block.modelData.kind === "split" ? split.implicitHeight : grid.implicitHeight
|
|
||||||
ModuleSlot {
|
|
||||||
id: full
|
|
||||||
visible: block.modelData.kind === "full"
|
|
||||||
width: parent.width
|
|
||||||
moduleId: block.modelData.kind === "full" ? block.modelData.ids[0] : ""
|
|
||||||
active: visible && ShellState.controlCenterOpen
|
|
||||||
}
|
|
||||||
RowLayout {
|
|
||||||
id: split
|
|
||||||
visible: block.modelData.kind === "split"
|
|
||||||
width: parent.width
|
|
||||||
spacing: 10
|
|
||||||
ModuleSlot {
|
|
||||||
moduleId: "connectivity"
|
|
||||||
active: split.visible && ShellState.controlCenterOpen
|
|
||||||
Layout.fillHeight: true
|
|
||||||
}
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.preferredWidth: 1
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
spacing: 10
|
|
||||||
Repeater {
|
|
||||||
model: block.modelData.kind === "split" ? block.modelData.ids : []
|
|
||||||
ModuleSlot {
|
|
||||||
required property string modelData
|
|
||||||
moduleId: modelData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GridLayout {
|
|
||||||
id: grid
|
id: grid
|
||||||
visible: block.modelData.kind === "grid"
|
objectName: "controlGrid"
|
||||||
width: parent.width
|
Layout.fillWidth: true
|
||||||
columns: 2
|
implicitHeight: root.geometry.height
|
||||||
columnSpacing: 10
|
visible: root.tiles.length > 0
|
||||||
rowSpacing: 10
|
Behavior on implicitHeight {
|
||||||
|
enabled: panel.settled && !root.dragId
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
Repeater {
|
Repeater {
|
||||||
model: block.modelData.kind === "grid" ? block.modelData.ids : []
|
// Keyed by id so moving or resizing keeps each module alive.
|
||||||
ModuleSlot {
|
model: ScriptModel {
|
||||||
|
values: root.tiles.map(m => m.id)
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
id: slot
|
||||||
required property string modelData
|
required property string modelData
|
||||||
moduleId: modelData
|
readonly property var cell: root.plan.items.find(i => i.id === modelData) || null
|
||||||
|
readonly property var rect: root.geometry.tiles[modelData] || null
|
||||||
|
readonly property bool dragging: root.dragId === modelData
|
||||||
|
readonly property real extra: loader.item ? loader.item.extraHeight : 0
|
||||||
|
objectName: "controlTile-" + modelData
|
||||||
|
visible: !!rect
|
||||||
|
x: dragging ? root.dragPoint.x - root.grabOffset.x : rect ? rect.x : 0
|
||||||
|
y: dragging ? root.dragPoint.y - root.grabOffset.y : rect ? rect.y : 0
|
||||||
|
width: rect ? rect.w : 0
|
||||||
|
height: rect ? rect.h : 0
|
||||||
|
z: dragging ? 10 : 0
|
||||||
|
scale: dragging ? 1.04 : 1
|
||||||
|
onExtraChanged: root.setExtra(modelData, extra)
|
||||||
|
Behavior on x {
|
||||||
|
enabled: panel.settled && !slot.dragging
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on y {
|
||||||
|
enabled: panel.settled && !slot.dragging
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on width {
|
||||||
|
enabled: panel.settled
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on height {
|
||||||
|
enabled: panel.settled
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
anchors.fill: parent
|
||||||
|
active: ShellState.controlCenterOpen
|
||||||
|
source: ControlRegistry.entry(slot.modelData).source
|
||||||
|
// Edit mode shows every tile at rest.
|
||||||
|
opacity: root.editing ? 0.85 : 1
|
||||||
|
}
|
||||||
|
Binding {
|
||||||
|
target: loader.item
|
||||||
|
when: !!loader.item && !!slot.cell
|
||||||
|
property: "cols"
|
||||||
|
value: slot.cell ? slot.cell.w : 1
|
||||||
|
}
|
||||||
|
Binding {
|
||||||
|
target: loader.item
|
||||||
|
when: !!loader.item && !!slot.cell
|
||||||
|
property: "rows"
|
||||||
|
value: slot.cell ? slot.cell.h : 1
|
||||||
|
}
|
||||||
|
Binding {
|
||||||
|
target: loader.item
|
||||||
|
when: !!loader.item && !!slot.cell
|
||||||
|
property: "baseHeight"
|
||||||
|
value: slot.cell ? slot.cell.h * root.cellHeight + (slot.cell.h - 1) * root.gap : 0
|
||||||
|
}
|
||||||
|
// One extended tile at a time, none while editing.
|
||||||
|
Connections {
|
||||||
|
target: loader.item
|
||||||
|
function onExpandedChanged() {
|
||||||
|
if (!loader.item.expanded)
|
||||||
|
return;
|
||||||
|
for (let i = 0; i < grid.children.length; ++i) {
|
||||||
|
const other = grid.children[i];
|
||||||
|
if (other !== slot && other.collapse)
|
||||||
|
other.collapse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function collapse() {
|
||||||
|
if (loader.item && loader.item.expanded)
|
||||||
|
loader.item.expanded = false;
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
function onEditingChanged() {
|
||||||
|
if (root.editing)
|
||||||
|
slot.collapse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The tile's drawn shape: a 1×1 circle is smaller than its cell.
|
||||||
|
readonly property var shape: loader.item ? loader.item.background : null
|
||||||
|
readonly property bool circle: !!loader.item && loader.item.circle
|
||||||
|
// Edit mode: this layer takes the clicks, so pressing drags.
|
||||||
|
Rectangle {
|
||||||
|
visible: root.editing
|
||||||
|
x: slot.shape ? slot.shape.x : 0
|
||||||
|
y: slot.shape ? slot.shape.y : 0
|
||||||
|
width: slot.shape ? slot.shape.width : parent.width
|
||||||
|
height: slot.shape ? slot.shape.height : parent.height
|
||||||
|
radius: slot.shape ? slot.shape.radius : 12
|
||||||
|
color: move.containsMouse || slot.dragging ? Qt.alpha(Theme.text, 0.06) : Theme.transparent
|
||||||
|
border.width: slot.dragging || root.resizeId === slot.modelData ? 2 : 1
|
||||||
|
border.color: slot.dragging || root.resizeId === slot.modelData ? Theme.accent : Qt.alpha(Theme.text, 0.3)
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: move
|
||||||
|
objectName: "controlMove-" + slot.modelData
|
||||||
|
visible: root.editing
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
preventStealing: true
|
||||||
|
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
|
||||||
|
property point lastCell: Qt.point(-1, -1)
|
||||||
|
onPressed: mouse => {
|
||||||
|
const p = mapToItem(grid, mouse.x, mouse.y);
|
||||||
|
root.grabOffset = Qt.point(p.x - slot.x, p.y - slot.y);
|
||||||
|
root.dragPoint = p;
|
||||||
|
lastCell = Qt.point(-1, -1);
|
||||||
|
}
|
||||||
|
onPositionChanged: mouse => {
|
||||||
|
if (!pressed)
|
||||||
|
return;
|
||||||
|
const p = mapToItem(grid, mouse.x, mouse.y);
|
||||||
|
if (!root.dragId) {
|
||||||
|
if (Math.hypot(p.x - root.dragPoint.x, p.y - root.dragPoint.y) < 6)
|
||||||
|
return;
|
||||||
|
root.dragOrder = root.order.slice();
|
||||||
|
root.dragId = slot.modelData;
|
||||||
|
}
|
||||||
|
root.dragPoint = p;
|
||||||
|
const c = root.cellAt(p);
|
||||||
|
if (c.x === lastCell.x && c.y === lastCell.y)
|
||||||
|
return;
|
||||||
|
lastCell = c;
|
||||||
|
root.dragOrder = Grid.reorder(root.order, root.plan, slot.modelData, Math.max(0, Math.min(Grid.COLS - 1, c.x)), Math.max(0, c.y));
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
const order = root.dragOrder;
|
||||||
|
const moved = !!root.dragId && order && order.join() !== root.tiles.map(m => m.id).join();
|
||||||
|
root.dragId = "";
|
||||||
|
if (moved)
|
||||||
|
root.saveOrder(order);
|
||||||
|
root.dragOrder = null;
|
||||||
|
}
|
||||||
|
onCanceled: {
|
||||||
|
root.dragId = "";
|
||||||
|
root.dragOrder = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Badge {
|
||||||
|
objectName: "controlRemove-" + slot.modelData
|
||||||
|
visible: root.editing && !slot.dragging
|
||||||
|
// On the shape's top-left curve, inside the scroll clip.
|
||||||
|
x: slot.circle && slot.shape ? slot.shape.x + slot.shape.width * 0.146 - width / 2 : 0
|
||||||
|
y: slot.circle && slot.shape ? slot.shape.y + slot.shape.height * 0.146 - height / 2 : 0
|
||||||
|
glyph: "−"
|
||||||
|
onClicked: root.setEnabled(slot.modelData, false)
|
||||||
|
Accessible.name: "Remove " + ControlRegistry.entry(slot.modelData).title
|
||||||
|
}
|
||||||
|
// Size while resizing.
|
||||||
|
Rectangle {
|
||||||
|
visible: root.resizeId === slot.modelData
|
||||||
|
anchors.centerIn: parent
|
||||||
|
implicitWidth: sizeLabel.implicitWidth + 16
|
||||||
|
implicitHeight: 22
|
||||||
|
radius: 11
|
||||||
|
color: Theme.accent
|
||||||
|
Text {
|
||||||
|
id: sizeLabel
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: slot.cell ? slot.cell.w + "×" + slot.cell.h : ""
|
||||||
|
color: Theme.accentText
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: handle
|
||||||
|
visible: root.editing && !slot.dragging
|
||||||
|
x: slot.circle && slot.shape ? slot.shape.x + slot.shape.width * 0.854 - width / 2 : parent.width - width - 2
|
||||||
|
y: slot.circle && slot.shape ? slot.shape.y + slot.shape.height * 0.854 - height / 2 : parent.height - height - 2
|
||||||
|
width: 14
|
||||||
|
height: 14
|
||||||
|
radius: 7
|
||||||
|
color: Theme.text
|
||||||
|
border.width: 2
|
||||||
|
border.color: Theme.accent
|
||||||
|
MouseArea {
|
||||||
|
objectName: "controlResize-" + slot.modelData
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -5
|
||||||
|
preventStealing: true
|
||||||
|
cursorShape: Qt.SizeFDiagCursor
|
||||||
|
property point start
|
||||||
|
property var startSize
|
||||||
|
onPressed: mouse => {
|
||||||
|
start = mapToItem(grid, mouse.x, mouse.y);
|
||||||
|
startSize = {
|
||||||
|
w: slot.cell.w,
|
||||||
|
h: slot.cell.h
|
||||||
|
};
|
||||||
|
root.resizeSize = startSize;
|
||||||
|
root.resizeId = slot.modelData;
|
||||||
|
}
|
||||||
|
onPositionChanged: mouse => {
|
||||||
|
if (!pressed)
|
||||||
|
return;
|
||||||
|
const p = mapToItem(grid, mouse.x, mouse.y);
|
||||||
|
const next = Grid.resize(startSize, p.x - start.x, p.y - start.y, root.cellWidth, root.cellHeight, root.gap);
|
||||||
|
if (next.w !== root.resizeSize.w || next.h !== root.resizeSize.h)
|
||||||
|
root.resizeSize = next;
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
const size = root.resizeSize;
|
||||||
|
root.resizeId = "";
|
||||||
|
root.resizeSize = null;
|
||||||
|
if (size && (size.w !== startSize.w || size.h !== startSize.h))
|
||||||
|
root.saveSize(slot.modelData, size);
|
||||||
|
}
|
||||||
|
onCanceled: {
|
||||||
|
root.resizeId = "";
|
||||||
|
root.resizeSize = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible: root.tiles.length === 0 && !root.editing
|
||||||
|
text: "No controls. Use Edit Controls to add some."
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 12
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 8
|
||||||
|
Layout.bottomMargin: 8
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
visible: SystemService.acting
|
visible: SystemService.acting
|
||||||
text: "Updating system controls…"
|
text: "Updating system controls…"
|
||||||
@@ -270,10 +578,79 @@ PanelWindow {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: 4
|
Layout.leftMargin: 4
|
||||||
}
|
}
|
||||||
GlassButton {
|
ModuleSlot {
|
||||||
visible: root.blocks.length === 0
|
moduleId: "notifications"
|
||||||
text: "Add modules"
|
visible: root.notifications && !root.editing
|
||||||
onClicked: ShellState.openSettings("controlcenter")
|
active: visible && ShellState.controlCenterOpen
|
||||||
|
}
|
||||||
|
// Edit mode stands the Notifications section in as a bar.
|
||||||
|
Item {
|
||||||
|
visible: root.notifications && root.editing
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: 44
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: 22
|
||||||
|
color: Theme.fill
|
||||||
|
border.width: 1
|
||||||
|
border.color: Qt.alpha(Theme.text, 0.3)
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "Notifications"
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Badge {
|
||||||
|
objectName: "controlRemove-notifications"
|
||||||
|
glyph: "−"
|
||||||
|
onClicked: root.setEnabled("notifications", false)
|
||||||
|
Accessible.name: "Remove Notifications"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColumnLayout {
|
||||||
|
visible: root.editing && root.addable.length > 0
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 4
|
||||||
|
spacing: 8
|
||||||
|
Text {
|
||||||
|
text: "Add Controls"
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
Layout.leftMargin: 4
|
||||||
|
}
|
||||||
|
Flow {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: 8
|
||||||
|
Repeater {
|
||||||
|
model: root.editing ? root.addable : []
|
||||||
|
Pill {
|
||||||
|
required property string modelData
|
||||||
|
objectName: "controlAdd-" + modelData
|
||||||
|
text: "+ " + (Icons.available ? ControlRegistry.entry(modelData).glyph + " " : "") + ControlRegistry.entry(modelData).title
|
||||||
|
onClicked: root.setEnabled(modelData, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layout.topMargin: 2
|
||||||
|
spacing: 8
|
||||||
|
Pill {
|
||||||
|
objectName: "controlReset"
|
||||||
|
visible: root.editing
|
||||||
|
text: "Reset"
|
||||||
|
onClicked: root.reset()
|
||||||
|
}
|
||||||
|
Pill {
|
||||||
|
objectName: "controlEdit"
|
||||||
|
text: root.editing ? "Done" : "Edit Controls"
|
||||||
|
strong: root.editing
|
||||||
|
onClicked: root.editing = !root.editing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,46 +2,122 @@ pragma Singleton
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
|
// Control Center modules. Grid tiles have a default size in cells (w × h,
|
||||||
|
// each 1–4) that the user can change in edit mode; Notifications is a section
|
||||||
|
// under the grid instead.
|
||||||
Singleton {
|
Singleton {
|
||||||
function entry(id) {
|
function entry(id) {
|
||||||
return Object.prototype.hasOwnProperty.call(modules, id) ? modules[id] : null;
|
return Object.prototype.hasOwnProperty.call(modules, id) ? modules[id] : null;
|
||||||
}
|
}
|
||||||
|
// Configured size, else the module's default.
|
||||||
|
function size(module) {
|
||||||
|
if (!module)
|
||||||
|
return {
|
||||||
|
w: 1,
|
||||||
|
h: 1
|
||||||
|
};
|
||||||
|
const e = entry(module.id);
|
||||||
|
return {
|
||||||
|
w: module.w || (e ? e.w : 1),
|
||||||
|
h: module.h || (e ? e.h : 1)
|
||||||
|
};
|
||||||
|
}
|
||||||
readonly property var modules: ({
|
readonly property var modules: ({
|
||||||
metrics: {title:"System Metrics", source:Qt.resolvedUrl("modules/Metrics.qml")},
|
wifi: {
|
||||||
connectivity: {
|
title: "Wi-Fi",
|
||||||
title: "Connectivity",
|
glyph: "",
|
||||||
source: Qt.resolvedUrl("modules/Connectivity.qml")
|
w: 2,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Wifi.qml")
|
||||||
},
|
},
|
||||||
audio: {
|
bluetooth: {
|
||||||
title: "Audio",
|
title: "Bluetooth",
|
||||||
source: Qt.resolvedUrl("modules/Audio.qml")
|
glyph: "",
|
||||||
|
w: 1,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Bluetooth.qml")
|
||||||
|
},
|
||||||
|
network: {
|
||||||
|
title: "Network",
|
||||||
|
glyph: "",
|
||||||
|
w: 2,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Network.qml")
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
title: "Sound",
|
||||||
|
glyph: "",
|
||||||
|
w: 4,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Output.qml")
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
title: "Microphone",
|
||||||
|
glyph: "",
|
||||||
|
w: 4,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Input.qml")
|
||||||
},
|
},
|
||||||
brightness: {
|
brightness: {
|
||||||
title: "Brightness",
|
title: "Display",
|
||||||
|
glyph: "",
|
||||||
|
w: 4,
|
||||||
|
h: 1,
|
||||||
source: Qt.resolvedUrl("modules/Brightness.qml")
|
source: Qt.resolvedUrl("modules/Brightness.qml")
|
||||||
},
|
},
|
||||||
nightLight: {
|
nightLight: {
|
||||||
title: "Night Light",
|
title: "Night Light",
|
||||||
|
glyph: "",
|
||||||
|
w: 1,
|
||||||
|
h: 1,
|
||||||
source: Qt.resolvedUrl("modules/NightLight.qml")
|
source: Qt.resolvedUrl("modules/NightLight.qml")
|
||||||
},
|
},
|
||||||
dnd: {
|
dnd: {
|
||||||
title: "Do Not Disturb",
|
title: "Do Not Disturb",
|
||||||
|
glyph: "",
|
||||||
|
w: 1,
|
||||||
|
h: 1,
|
||||||
source: Qt.resolvedUrl("modules/Dnd.qml")
|
source: Qt.resolvedUrl("modules/Dnd.qml")
|
||||||
},
|
},
|
||||||
|
caffeine: {
|
||||||
|
title: "Caffeine",
|
||||||
|
glyph: "",
|
||||||
|
w: 1,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Caffeine.qml")
|
||||||
|
},
|
||||||
profiles: {
|
profiles: {
|
||||||
title: "Power profile",
|
title: "Power profile",
|
||||||
|
glyph: "",
|
||||||
|
w: 2,
|
||||||
|
h: 1,
|
||||||
source: Qt.resolvedUrl("modules/Profiles.qml")
|
source: Qt.resolvedUrl("modules/Profiles.qml")
|
||||||
},
|
},
|
||||||
media: {
|
media: {
|
||||||
title: "Media",
|
title: "Now Playing",
|
||||||
source: Qt.resolvedUrl("modules/Media.qml")
|
glyph: "",
|
||||||
|
w: 2,
|
||||||
|
h: 2,
|
||||||
|
source: Qt.resolvedUrl("modules/NowPlaying.qml")
|
||||||
},
|
},
|
||||||
power: {
|
power: {
|
||||||
title: "Power",
|
title: "Power",
|
||||||
|
glyph: "",
|
||||||
|
w: 4,
|
||||||
|
h: 1,
|
||||||
source: Qt.resolvedUrl("modules/Power.qml")
|
source: Qt.resolvedUrl("modules/Power.qml")
|
||||||
},
|
},
|
||||||
|
metrics: {
|
||||||
|
title: "System Metrics",
|
||||||
|
glyph: "",
|
||||||
|
w: 4,
|
||||||
|
h: 1,
|
||||||
|
source: Qt.resolvedUrl("modules/Metrics.qml")
|
||||||
|
},
|
||||||
notifications: {
|
notifications: {
|
||||||
title: "Notifications",
|
title: "Notifications",
|
||||||
|
glyph: "",
|
||||||
|
section: true,
|
||||||
source: Qt.resolvedUrl("modules/Notifications.qml")
|
source: Qt.resolvedUrl("modules/Notifications.qml")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
// Pure helpers for the Control Center grid: packing, drag reordering and
|
||||||
|
// resizing.
|
||||||
|
// Tiles are {id, w, h} in grid cells; the grid is `cols` wide and grows down.
|
||||||
|
|
||||||
|
var COLS = 4;
|
||||||
|
var MAX = 4;
|
||||||
|
|
||||||
|
function clampSize(n) {
|
||||||
|
n = Math.round(Number(n));
|
||||||
|
return Number.isFinite(n) ? Math.max(1, Math.min(MAX, n)) : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Packs tiles first-fit in list order: each takes the first free spot, scanning
|
||||||
|
// rows top to bottom and columns left to right, so small tiles backfill gaps.
|
||||||
|
function pack(tiles, cols) {
|
||||||
|
cols = cols || COLS;
|
||||||
|
const occ = [], items = [];
|
||||||
|
let rows = 0;
|
||||||
|
function free(r, c, w, h) {
|
||||||
|
for (let y = r; y < r + h; y++)
|
||||||
|
for (let x = c; x < c + w; x++)
|
||||||
|
if (occ[y] && occ[y][x])
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (const t of tiles) {
|
||||||
|
const w = Math.min(cols, clampSize(t.w)), h = clampSize(t.h);
|
||||||
|
let placed = false;
|
||||||
|
for (let r = 0; !placed; r++) {
|
||||||
|
for (let c = 0; c + w <= cols; c++) {
|
||||||
|
if (!free(r, c, w, h))
|
||||||
|
continue;
|
||||||
|
for (let y = r; y < r + h; y++) {
|
||||||
|
occ[y] = occ[y] || [];
|
||||||
|
for (let x = c; x < c + w; x++)
|
||||||
|
occ[y][x] = true;
|
||||||
|
}
|
||||||
|
items.push({id: t.id, col: c, row: r, w: w, h: h});
|
||||||
|
rows = Math.max(rows, r + h);
|
||||||
|
placed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {items: items, rows: rows};
|
||||||
|
}
|
||||||
|
|
||||||
|
// The packed tile covering a cell, or null.
|
||||||
|
function at(plan, col, row) {
|
||||||
|
return plan.items.find(i => col >= i.col && col < i.col + i.w && row >= i.row && row < i.row + i.h) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order after dragging `id` over the cell (col, row): it takes the index of the
|
||||||
|
// tile under the pointer. Over empty space it goes after the last tile that
|
||||||
|
// starts at or before that cell in reading order.
|
||||||
|
function reorder(ids, plan, id, col, row) {
|
||||||
|
if (ids.indexOf(id) < 0)
|
||||||
|
return ids.slice();
|
||||||
|
const hit = at(plan, col, row);
|
||||||
|
if (hit && hit.id === id)
|
||||||
|
return ids.slice();
|
||||||
|
const next = ids.filter(i => i !== id);
|
||||||
|
let to;
|
||||||
|
if (hit) {
|
||||||
|
// Moving forward lands after the hit tile, backward lands before it.
|
||||||
|
to = next.indexOf(hit.id) + (ids.indexOf(id) < ids.indexOf(hit.id) ? 1 : 0);
|
||||||
|
} else {
|
||||||
|
const before = plan.items.filter(i => i.id !== id && (i.row < row || (i.row === row && i.col <= col)));
|
||||||
|
to = before.length ? Math.max(...before.map(i => next.indexOf(i.id))) + 1 : 0;
|
||||||
|
}
|
||||||
|
next.splice(to, 0, id);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cells for a tile resized by a pixel delta from its start size.
|
||||||
|
function resize(start, dx, dy, cellW, cellH, gap) {
|
||||||
|
return {
|
||||||
|
w: clampSize(start.w + dx / (cellW + gap)),
|
||||||
|
h: clampSize(start.h + dy / (cellH + gap))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pixel geometry. `extras` maps tile id -> extra height below it (an expanded
|
||||||
|
// tile); everything starting at or below that tile's bottom row moves down.
|
||||||
|
function geometry(plan, cellW, cellH, gap, extras) {
|
||||||
|
extras = extras || {};
|
||||||
|
const boundary = {};
|
||||||
|
for (const i of plan.items) {
|
||||||
|
const e = extras[i.id] || 0;
|
||||||
|
if (e > 0)
|
||||||
|
boundary[i.row + i.h] = Math.max(boundary[i.row + i.h] || 0, e + gap);
|
||||||
|
}
|
||||||
|
function shift(row) {
|
||||||
|
let s = 0;
|
||||||
|
for (const b in boundary)
|
||||||
|
if (row >= Number(b))
|
||||||
|
s += boundary[b];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
const out = {};
|
||||||
|
for (const i of plan.items)
|
||||||
|
out[i.id] = {
|
||||||
|
x: i.col * (cellW + gap),
|
||||||
|
y: i.row * (cellH + gap) + shift(i.row),
|
||||||
|
w: i.w * cellW + (i.w - 1) * gap,
|
||||||
|
h: i.h * cellH + (i.h - 1) * gap + ((extras[i.id] || 0) > 0 ? extras[i.id] + gap : 0)
|
||||||
|
};
|
||||||
|
const height = plan.rows ? plan.rows * (cellH + gap) - gap + shift(plan.rows) : 0;
|
||||||
|
return {tiles: out, height: height};
|
||||||
|
}
|
||||||
@@ -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
|
||||||
import QtQuick.Layouts
|
|
||||||
import ".."
|
import ".."
|
||||||
import "../../components"
|
|
||||||
import "../../services"
|
import "../../services"
|
||||||
import "../../theme"
|
|
||||||
|
|
||||||
ControlCard {
|
// Display brightness; providers apply it on release.
|
||||||
id: root
|
CCSlider {
|
||||||
readonly property var info: SystemService.state.brightness || ({
|
readonly property var info: SystemService.state.brightness || ({
|
||||||
available: false
|
available: false
|
||||||
})
|
})
|
||||||
|
objectName: "brightnessTile"
|
||||||
title: "Display"
|
title: "Display"
|
||||||
GlassBarSlider {
|
|
||||||
objectName: "brightnessSlider"
|
|
||||||
Layout.fillWidth: true
|
|
||||||
glyph: ""
|
glyph: ""
|
||||||
fallback: "☀"
|
fallback: "☀"
|
||||||
|
sliderName: "brightnessSlider"
|
||||||
from: 1
|
from: 1
|
||||||
to: 100
|
to: 100
|
||||||
stepSize: 1
|
stepSize: 1
|
||||||
value: root.info.value || 1
|
value: info.value || 1
|
||||||
enabled: !!root.info.available && !SystemService.acting
|
enabled: !!info.available && !SystemService.acting
|
||||||
onPressedChanged: if (!pressed && enabled) {
|
known: !!info.available
|
||||||
SystemService.action("brightness", value, false);
|
notice: info.available ? "" : info.notice || "No brightness provider"
|
||||||
value = Qt.binding(() => root.info.value || 1);
|
onCommitted: value => SystemService.action("brightness", value, false)
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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 QtQuick
|
||||||
import ".."
|
import ".."
|
||||||
import "../../services"
|
import "../../services"
|
||||||
@@ -12,6 +13,7 @@ CCTile {
|
|||||||
title: "Do Not Disturb"
|
title: "Do Not Disturb"
|
||||||
detail: shellOwned ? (NotificationService.dnd ? "On" : "Off") : !info.available ? (info.notice || "No notification server") : info.enabled ? "On" : "Off"
|
detail: shellOwned ? (NotificationService.dnd ? "On" : "Off") : !info.available ? (info.notice || "No notification server") : info.enabled ? "On" : "Off"
|
||||||
glyph: ""
|
glyph: ""
|
||||||
|
page: "notifications"
|
||||||
fallback: "☾"
|
fallback: "☾"
|
||||||
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
||||||
checked: shellOwned ? NotificationService.dnd : !!info.enabled
|
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
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import ".."
|
||||||
|
import "../../core"
|
||||||
import "../../metrics"
|
import "../../metrics"
|
||||||
|
import "../../services"
|
||||||
import "../../theme"
|
import "../../theme"
|
||||||
|
|
||||||
MetricsCard {
|
// CPU, RAM and GPU load. Small tiles show the figures as text (1×1 just CPU);
|
||||||
compact: true
|
// wide tall tiles show ring gauges. Click opens the Metrics settings.
|
||||||
radius: Math.max(12, Theme.radius * 0.75)
|
CCModule {
|
||||||
color: Theme.fill
|
id: root
|
||||||
border.color: Theme.hairline
|
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 QtQuick
|
||||||
import ".."
|
import ".."
|
||||||
import "../../services"
|
import "../../services"
|
||||||
@@ -10,6 +11,7 @@ CCTile {
|
|||||||
title: "Night Light"
|
title: "Night Light"
|
||||||
detail: !info.available ? "No gamma provider" : info.enabled ? "On" : "Off"
|
detail: !info.available ? "No gamma provider" : info.enabled ? "On" : "Off"
|
||||||
glyph: ""
|
glyph: ""
|
||||||
|
page: "displays"
|
||||||
fallback: "N"
|
fallback: "N"
|
||||||
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
// Shows acknowledged provider state; a failed request leaves it unchanged.
|
||||||
checked: !!info.enabled
|
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 "../../services"
|
||||||
import "../../theme"
|
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
|
id: root
|
||||||
Component.onDestruction: PowerService.cancel()
|
readonly property var actions: [
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: 4
|
|
||||||
Repeater {
|
|
||||||
model: [
|
|
||||||
{
|
{
|
||||||
id: "lock",
|
id: "lock",
|
||||||
glyph: ""
|
glyph: "",
|
||||||
|
label: "Lock"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "logout",
|
id: "logout",
|
||||||
glyph: ""
|
glyph: "",
|
||||||
|
label: "Log out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "suspend",
|
id: "suspend",
|
||||||
glyph: ""
|
glyph: "",
|
||||||
|
label: "Suspend"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "reboot",
|
id: "reboot",
|
||||||
glyph: ""
|
glyph: "",
|
||||||
|
label: "Reboot"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "shutdown",
|
id: "shutdown",
|
||||||
glyph: ""
|
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()
|
||||||
|
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: root.actions
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: action
|
id: action
|
||||||
required property var modelData
|
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.preferredWidth: root.buttonWidth
|
||||||
Layout.fillWidth: true
|
spacing: 3
|
||||||
Layout.preferredWidth: 1
|
|
||||||
spacing: 4
|
|
||||||
CCToggle {
|
CCToggle {
|
||||||
objectName: "power-" + action.modelData.id
|
objectName: "power-" + action.modelData.id
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
size: 38
|
size: root.buttonSize
|
||||||
glyph: action.modelData.glyph
|
glyph: action.modelData.glyph
|
||||||
fallback: action.label.charAt(0)
|
fallback: action.modelData.label.charAt(0)
|
||||||
checked: PowerService.pending === action.modelData.id
|
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)
|
onClicked: PowerService.request(action.modelData.id)
|
||||||
Accessible.name: action.label
|
Accessible.name: action.modelData.label
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: action.label
|
visible: root.labels
|
||||||
|
text: action.modelData.label
|
||||||
color: Theme.textSecondary
|
color: Theme.textSecondary
|
||||||
font.pixelSize: 10
|
font.pixelSize: 10
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
@@ -64,9 +103,95 @@ ControlCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RowLayout {
|
|
||||||
visible: PowerService.pending !== ""
|
// 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: confirm
|
||||||
|
ColumnLayout {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
Text {
|
Text {
|
||||||
text: "Confirm " + PowerService.pending + "? Unsaved work may be lost."
|
text: "Confirm " + PowerService.pending + "? Unsaved work may be lost."
|
||||||
@@ -75,6 +200,9 @@ ControlCard {
|
|||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
spacing: 8
|
||||||
GlassButton {
|
GlassButton {
|
||||||
objectName: "powerCancel"
|
objectName: "powerCancel"
|
||||||
text: "Cancel"
|
text: "Cancel"
|
||||||
@@ -89,3 +217,5 @@ ControlCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import ".."
|
import ".."
|
||||||
import "../../services"
|
import "../../services"
|
||||||
@@ -15,6 +16,7 @@ CCTile {
|
|||||||
title: "Power profile"
|
title: "Power profile"
|
||||||
detail: !info.available ? "Unavailable" : current ? current.charAt(0).toUpperCase() + current.slice(1).replace(/-/g, " ") : "—"
|
detail: !info.available ? "Unavailable" : current ? current.charAt(0).toUpperCase() + current.slice(1).replace(/-/g, " ") : "—"
|
||||||
glyph: current === "power-saver" ? "" : current === "performance" ? "" : ""
|
glyph: current === "power-saver" ? "" : current === "performance" ? "" : ""
|
||||||
|
page: "power"
|
||||||
fallback: "P"
|
fallback: "P"
|
||||||
checked: info.available && current !== "" && current !== "balanced"
|
checked: info.available && current !== "" && current !== "balanced"
|
||||||
enabled: !!info.available && profiles.length > 1 && !SystemService.acting
|
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()
|
||||||
|
}
|
||||||
@@ -4,3 +4,6 @@ ControlCard 1.0 ControlCard.qml
|
|||||||
SystemTile 1.0 SystemTile.qml
|
SystemTile 1.0 SystemTile.qml
|
||||||
CCToggle 1.0 CCToggle.qml
|
CCToggle 1.0 CCToggle.qml
|
||||||
CCTile 1.0 CCTile.qml
|
CCTile 1.0 CCTile.qml
|
||||||
|
CCModule 1.0 CCModule.qml
|
||||||
|
CCSlider 1.0 CCSlider.qml
|
||||||
|
AudioMixer 1.0 AudioMixer.qml
|
||||||
@@ -87,9 +87,9 @@ function validate(c) {
|
|||||||
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
|
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
|
||||||
const notes=c.notifications;
|
const notes=c.notifications;
|
||||||
if(!notes || ["enabled","doNotDisturb","criticalInDnd"].some(k=>typeof notes[k]!=="boolean") || !["slide","drop","fade","shrink"].includes(notes.animation) || !["top-right","top-center"].includes(notes.position) || !Number.isInteger(notes.timeout) || notes.timeout<1000 || notes.timeout>30000 || !Number.isInteger(notes.maxPopups) || notes.maxPopups<1 || notes.maxPopups>6)throw Error("Invalid notification preferences");
|
if(!notes || ["enabled","doNotDisturb","criticalInDnd"].some(k=>typeof notes[k]!=="boolean") || !["slide","drop","fade","shrink"].includes(notes.animation) || !["top-right","top-center"].includes(notes.position) || !Number.isInteger(notes.timeout) || notes.timeout<1000 || notes.timeout>30000 || !Number.isInteger(notes.maxPopups) || notes.maxPopups<1 || notes.maxPopups>6)throw Error("Invalid notification preferences");
|
||||||
if(c.controlCenter.version !== 1 || !Number.isFinite(c.controlCenter.width) || c.controlCenter.width < 320 || c.controlCenter.width > 600 || !Array.isArray(c.controlCenter.modules))throw Error("Invalid Control Center configuration");
|
if(c.controlCenter.version !== 2 || !Number.isFinite(c.controlCenter.width) || c.controlCenter.width < 320 || c.controlCenter.width > 600 || !Array.isArray(c.controlCenter.modules))throw Error("Invalid Control Center configuration");
|
||||||
const controlIds=new Set();
|
const controlIds=new Set();
|
||||||
for(const m of c.controlCenter.modules) { if(!m || typeof m.id!=="string" || controlIds.has(m.id) || typeof m.enabled!=="boolean")throw Error("Invalid Control Center module"); controlIds.add(m.id); }
|
for(const m of c.controlCenter.modules) { if(!m || typeof m.id!=="string" || controlIds.has(m.id) || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)))throw Error("Invalid Control Center module"); controlIds.add(m.id); }
|
||||||
for(const group of [c.system.brightness,c.system.nightLight]) for(const key of ["statusCommand","setCommand"])if(!Array.isArray(group[key]) || group[key].some(v=>typeof v!=="string" || !v.length))throw Error("Provider command must be an argument array");
|
for(const group of [c.system.brightness,c.system.nightLight]) for(const key of ["statusCommand","setCommand"])if(!Array.isArray(group[key]) || group[key].some(v=>typeof v!=="string" || !v.length))throw Error("Provider command must be an argument array");
|
||||||
if(typeof c.system.brightness.device!=="string" || !c.system.brightness.device || !Number.isInteger(c.system.nightLight.temperature) || c.system.nightLight.temperature<1000 || c.system.nightLight.temperature>6500 || !Array.isArray(c.system.power.lockCommand) || c.system.power.lockCommand.some(v=>typeof v!=="string" || !v.length))throw Error("Invalid system provider settings");
|
if(typeof c.system.brightness.device!=="string" || !c.system.brightness.device || !Number.isInteger(c.system.nightLight.temperature) || c.system.nightLight.temperature<1000 || c.system.nightLight.temperature>6500 || !Array.isArray(c.system.power.lockCommand) || c.system.power.lockCommand.some(v=>typeof v!=="string" || !v.length))throw Error("Invalid system provider settings");
|
||||||
if(!Number.isInteger(c.metrics.interval) || c.metrics.interval<1 || c.metrics.interval>30)throw Error("Invalid metrics geometry or interval");
|
if(!Number.isInteger(c.metrics.interval) || c.metrics.interval<1 || c.metrics.interval>30)throw Error("Invalid metrics geometry or interval");
|
||||||
@@ -123,6 +123,24 @@ function load(defaults, user) {
|
|||||||
migrated.controlCenter.modules = defaults.controlCenter.modules;
|
migrated.controlCenter.modules = defaults.controlCenter.modules;
|
||||||
migrated.controlCenter.version = 1;
|
migrated.controlCenter.version = 1;
|
||||||
}
|
}
|
||||||
|
// Version 2 lays modules on a grid: the combined Connectivity and Audio
|
||||||
|
// cards split into their own tiles, in place, and Caffeine is offered.
|
||||||
|
if (migrated.controlCenter.version === 1 && Array.isArray(migrated.controlCenter.modules)) {
|
||||||
|
const parts = {connectivity: ["wifi", "bluetooth", "network"], audio: ["output", "input"]};
|
||||||
|
const old = migrated.controlCenter.modules, modules = [];
|
||||||
|
for (const m of old) {
|
||||||
|
if (!m || !parts[m.id]) {
|
||||||
|
modules.push(m);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const id of parts[m.id])
|
||||||
|
if (!old.some(o => o && o.id === id) && !modules.some(o => o && o.id === id))
|
||||||
|
modules.push({id: id, enabled: m.enabled});
|
||||||
|
}
|
||||||
|
if (old.length && !modules.some(m => m && m.id === "caffeine"))
|
||||||
|
modules.push({id: "caffeine", enabled: true});
|
||||||
|
migrated.controlCenter = Object.assign({}, migrated.controlCenter, {version: 2, modules: modules});
|
||||||
|
}
|
||||||
migrated.schemaVersion = 3;
|
migrated.schemaVersion = 3;
|
||||||
return validate(merge(defaults, migrated));
|
return validate(merge(defaults, migrated));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ SettingsPage {
|
|||||||
}
|
}
|
||||||
SettingsSection {
|
SettingsSection {
|
||||||
title: "Modules"
|
title: "Modules"
|
||||||
description: "Drag modules to reorder them; the switch shows or hides each card"
|
description: "Drag modules to reorder them; the switch shows or hides each one. Resize tiles from Edit Controls in the Control Center"
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: rows
|
id: rows
|
||||||
objectName: "controlModuleList"
|
objectName: "controlModuleList"
|
||||||
@@ -117,7 +117,7 @@ SettingsPage {
|
|||||||
y: card.offset
|
y: card.offset
|
||||||
scale: card.lifted ? 1.02 : 1
|
scale: card.lifted ? 1.02 : 1
|
||||||
opacity: card.lifted ? 0.9 : 1
|
opacity: card.lifted ? 0.9 : 1
|
||||||
title: card.entry ? card.entry.title : card.modelData.id + " (unavailable)"
|
title: !card.entry ? card.modelData.id + " (unavailable)" : card.entry.section ? card.entry.title : card.entry.title + " · " + ControlRegistry.size(card.modelData).w + "×" + ControlRegistry.size(card.modelData).h
|
||||||
icon: ""
|
icon: ""
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
|||||||
@@ -35,6 +35,19 @@ Item {
|
|||||||
property bool muted: false
|
property bool muted: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
property var streamNode: QtObject {
|
||||||
|
property string name: "fixture-player"
|
||||||
|
property string description: ""
|
||||||
|
property bool isSink: false
|
||||||
|
property bool isStream: true
|
||||||
|
property var properties: ({
|
||||||
|
"application.name": "Fixture player"
|
||||||
|
})
|
||||||
|
property QtObject audio: QtObject {
|
||||||
|
property real volume: 0.5
|
||||||
|
property bool muted: false
|
||||||
|
}
|
||||||
|
}
|
||||||
property QtObject audioBackend: QtObject {
|
property QtObject audioBackend: QtObject {
|
||||||
property bool ready: true
|
property bool ready: true
|
||||||
property var defaultAudioSink: root.audioNode
|
property var defaultAudioSink: root.audioNode
|
||||||
@@ -42,7 +55,7 @@ Item {
|
|||||||
property var preferredDefaultAudioSink: root.audioNode
|
property var preferredDefaultAudioSink: root.audioNode
|
||||||
property var preferredDefaultAudioSource: root.audioInput
|
property var preferredDefaultAudioSource: root.audioInput
|
||||||
property QtObject nodes: QtObject {
|
property QtObject nodes: QtObject {
|
||||||
property var values: [root.audioNode, root.audioInput]
|
property var values: [root.audioNode, root.audioInput, root.streamNode]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property QtObject wifi: QtObject {
|
property QtObject wifi: QtObject {
|
||||||
@@ -139,6 +152,7 @@ Item {
|
|||||||
NetworkService.backend = root.networkBackend;
|
NetworkService.backend = root.networkBackend;
|
||||||
BluetoothService.backend = root.btBackend;
|
BluetoothService.backend = root.btBackend;
|
||||||
SystemService.helper = "testing/recording_system.py";
|
SystemService.helper = "testing/recording_system.py";
|
||||||
|
CaffeineService.command = ["sleep", "infinity"];
|
||||||
SystemService.refresh();
|
SystemService.refresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -158,6 +172,32 @@ Item {
|
|||||||
input.mouseClick(item, item.width * .75, item.height / 2);
|
input.mouseClick(item, item.width * .75, item.height / 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
function rightClick(name: string): bool {
|
||||||
|
const item = root.child(name);
|
||||||
|
if (!item || !item.enabled)
|
||||||
|
return false;
|
||||||
|
root.reveal(item);
|
||||||
|
// Near the corner: clear of sliders and buttons on every layout.
|
||||||
|
input.mouseClick(item, 14, 14, Qt.RightButton);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Presses an item and drags it by (dx, dy) in steps.
|
||||||
|
function drag(name: string, dx: real, dy: real): bool {
|
||||||
|
const item = root.child(name);
|
||||||
|
if (!item || !item.visible)
|
||||||
|
return false;
|
||||||
|
root.reveal(item);
|
||||||
|
// Window coordinates, like a real pointer: the item may move or grow.
|
||||||
|
const content = ShellState.controlCenterWindow.contentItem;
|
||||||
|
const p = item.mapToItem(content, item.width / 2, item.height / 2);
|
||||||
|
input.mousePress(content, p.x, p.y);
|
||||||
|
for (let i = 1; i <= 8; ++i)
|
||||||
|
input.mouseMove(content, p.x + dx * i / 8, p.y + dy * i / 8, 20);
|
||||||
|
input.wait(60);
|
||||||
|
input.mouseRelease(content, p.x + dx, p.y + dy);
|
||||||
|
input.wait(60);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
function clickSystem(): bool {
|
function clickSystem(): bool {
|
||||||
const pill = ShellState.systemPills.find(p => p.barScreen === ScreenService.active) || ShellState.systemPills[0];
|
const pill = ShellState.systemPills.find(p => p.barScreen === ScreenService.active) || ShellState.systemPills[0];
|
||||||
if (!pill)
|
if (!pill)
|
||||||
@@ -226,6 +266,14 @@ Item {
|
|||||||
muted: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.muted : false,
|
muted: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.muted : false,
|
||||||
microphone: AudioService.source && AudioService.source.audio ? AudioService.source.audio.muted : false,
|
microphone: AudioService.source && AudioService.source.audio ? AudioService.source.audio.muted : false,
|
||||||
scan: fixtureWifi.scannerEnabled,
|
scan: fixtureWifi.scannerEnabled,
|
||||||
|
editing: ShellState.controlCenterWindow.editing,
|
||||||
|
tiles: ShellState.controlCenterWindow.plan.items,
|
||||||
|
cellWidth: ShellState.controlCenterWindow.cellWidth,
|
||||||
|
extras: ShellState.controlCenterWindow.extras,
|
||||||
|
streamVolume: root.streamNode.audio.volume,
|
||||||
|
streamMuted: root.streamNode.audio.muted,
|
||||||
|
caffeine: CaffeineService.active,
|
||||||
|
caffeineRunning: CaffeineService.running,
|
||||||
active: ScreenService.active.name,
|
active: ScreenService.active.name,
|
||||||
screens: Quickshell.screens.map(s => s.name),
|
screens: Quickshell.screens.map(s => s.name),
|
||||||
x: ShellState.controlCenterWindow.panelScreenX,
|
x: ShellState.controlCenterWindow.panelScreenX,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ node "$project_dir/tests/polish.test.cjs"
|
|||||||
node "$project_dir/tests/dock.test.cjs"
|
node "$project_dir/tests/dock.test.cjs"
|
||||||
node "$project_dir/tests/launcher.test.cjs"
|
node "$project_dir/tests/launcher.test.cjs"
|
||||||
node "$project_dir/tests/widgets.test.cjs"
|
node "$project_dir/tests/widgets.test.cjs"
|
||||||
|
node "$project_dir/tests/controlcenter.test.cjs"
|
||||||
python3 "$project_dir/tests/providers_test.py"
|
python3 "$project_dir/tests/providers_test.py"
|
||||||
python3 "$project_dir/tests/system_providers_test.py"
|
python3 "$project_dir/tests/system_providers_test.py"
|
||||||
python3 "$project_dir/tests/metrics_test.py"
|
python3 "$project_dir/tests/metrics_test.py"
|
||||||
|
|||||||
@@ -70,11 +70,16 @@ console.log('Phase 5 preference merging, validation and immutable bar editing/re
|
|||||||
assert.throws(() => api.update(phase5, 'bar.modules', {}), /must be an array/);
|
assert.throws(() => api.update(phase5, 'bar.modules', {}), /must be an array/);
|
||||||
assert.equal(api.update(phase5, 'bar.modules', [{id:'nowPlaying',position:'right',enabled:true}]).bar.modules[0].id, 'nowPlaying');
|
assert.equal(api.update(phase5, 'bar.modules', [{id:'nowPlaying',position:'right',enabled:true}]).bar.modules[0].id, 'nowPlaying');
|
||||||
const phase7=api.load(defaults,{schemaVersion:3,controlCenter:{modules:[]},dock:{pinnedApps:['keep.desktop']},future:{keep:true}});
|
const phase7=api.load(defaults,{schemaVersion:3,controlCenter:{modules:[]},dock:{pinnedApps:['keep.desktop']},future:{keep:true}});
|
||||||
assert.equal(phase7.controlCenter.version,1);assert(phase7.controlCenter.modules.length>0);assert.equal(phase7.dock.pinnedApps[0],'keep.desktop');assert(phase7.future.keep);
|
assert.equal(phase7.controlCenter.version,2);assert(phase7.controlCenter.modules.length>0);assert.equal(phase7.dock.pinnedApps[0],'keep.desktop');assert(phase7.future.keep);
|
||||||
assert.equal(api.load(defaults,{controlCenter:{version:1,modules:[]}}).controlCenter.modules.length,0);
|
assert.equal(api.load(defaults,{controlCenter:{version:1,modules:[]}}).controlCenter.modules.length,0);
|
||||||
const customCenter=api.load(defaults,{controlCenter:{modules:[{id:'custom',enabled:false,metadata:'preserved'}]}});
|
const customCenter=api.load(defaults,{controlCenter:{modules:[{id:'custom',enabled:false,metadata:'preserved'}]}});
|
||||||
assert.equal(customCenter.controlCenter.modules[0].metadata,'preserved');assert.equal(customCenter.controlCenter.modules.length,1);
|
assert.equal(customCenter.controlCenter.modules[0].metadata,'preserved');assert.equal(customCenter.controlCenter.modules.map(m=>m.id).join(),'custom,caffeine');
|
||||||
for(const controlCenter of [{version:2},{version:1,width:100},{version:1,modules:[{id:'audio',enabled:true},{id:'audio',enabled:false}]}])assert.throws(()=>api.load(defaults,{controlCenter}));
|
for(const controlCenter of [{version:3},{version:1,width:100},{version:2,modules:[{id:'output',enabled:true},{id:'output',enabled:false}]},{version:2,modules:[{id:'wifi',enabled:true,w:5}]},{version:2,modules:[{id:'wifi',enabled:true,h:0}]},{version:2,modules:[{id:'wifi',enabled:true,w:1.5}]}])assert.throws(()=>api.load(defaults,{controlCenter}));
|
||||||
|
// Version 1 splits the combined cards in place, keeps enabled state and offers Caffeine.
|
||||||
|
const v1=api.load(defaults,{controlCenter:{version:1,modules:[{id:'connectivity',enabled:true},{id:'media',enabled:true},{id:'audio',enabled:false},{id:'notifications',enabled:true}]}}).controlCenter;
|
||||||
|
assert.equal(v1.version,2);assert.equal(v1.modules.map(m=>m.id+':'+m.enabled).join(),'wifi:true,bluetooth:true,network:true,media:true,output:false,input:false,notifications:true,caffeine:true');
|
||||||
|
assert.equal(JSON.stringify(api.load(defaults,{controlCenter:{version:2,modules:[{id:'wifi',enabled:true,w:4,h:1}]}}).controlCenter.modules),'[{"id":"wifi","enabled":true,"w":4,"h":1}]');
|
||||||
|
assert.equal(api.load(defaults,{controlCenter:{version:2,modules:[]}}).controlCenter.modules.length,0);
|
||||||
for(const system of [{brightness:{setCommand:'sh -c'}},{nightLight:{temperature:0}},{power:{lockCommand:['']}}])assert.throws(()=>api.load(defaults,{system}));
|
for(const system of [{brightness:{setCommand:'sh -c'}},{nightLight:{temperature:0}},{power:{lockCommand:['']}}])assert.throws(()=>api.load(defaults,{system}));
|
||||||
console.log('Phase 7 one-time module migration, intentional empty layouts, provider validation and preservation passed.');
|
console.log('Phase 7 one-time module migration, intentional empty layouts, provider validation and preservation passed.');
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
const assert = require('assert'), fs = require('fs'), path = require('path'), vm = require('vm');
|
||||||
|
const api = vm.createContext({});
|
||||||
|
vm.runInContext(fs.readFileSync(path.join(__dirname, '../quickshell/controlcenter/GridLogic.js'), 'utf8'), api);
|
||||||
|
const ids = plan => plan.items.map(i => i.id + '@' + i.col + ',' + i.row + ':' + i.w + 'x' + i.h).join(' ');
|
||||||
|
// First fit in list order; small tiles backfill gaps beside larger ones.
|
||||||
|
let plan = api.pack([{id: 'wifi', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'bt', w: 1, h: 1}, {id: 'dnd', w: 1, h: 1}, {id: 'sound', w: 4, h: 1}]);
|
||||||
|
assert.equal(ids(plan), 'wifi@0,0:2x1 media@2,0:2x2 bt@0,1:1x1 dnd@1,1:1x1 sound@0,2:4x1');
|
||||||
|
assert.equal(plan.rows, 3);
|
||||||
|
plan = api.pack([{id: 'a', w: 3, h: 1}, {id: 'b', w: 2, h: 1}, {id: 'c', w: 1, h: 1}]);
|
||||||
|
assert.equal(ids(plan), 'a@0,0:3x1 b@0,1:2x1 c@3,0:1x1');
|
||||||
|
// Sizes clamp to 1..4 cells.
|
||||||
|
assert.equal(ids(api.pack([{id: 'x', w: 9, h: 0}, {id: 'y', w: 1.4, h: 4.6}])), 'x@0,0:4x1 y@0,1:1x4');
|
||||||
|
assert.equal(api.pack([]).rows, 0);
|
||||||
|
// Hit testing covers spanned cells.
|
||||||
|
plan = api.pack([{id: 'wifi', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'bt', w: 1, h: 1}]);
|
||||||
|
assert.equal(api.at(plan, 3, 1).id, 'media');
|
||||||
|
assert.equal(api.at(plan, 3, 2), null);
|
||||||
|
// Dragging onto a tile takes its place in either direction; onto itself is a no-op.
|
||||||
|
const order = ['wifi', 'media', 'bt'];
|
||||||
|
assert.equal(api.reorder(order, plan, 'bt', 0, 0).join(), 'bt,wifi,media');
|
||||||
|
assert.equal(api.reorder(order, plan, 'wifi', 0, 1).join(), 'media,bt,wifi');
|
||||||
|
assert.equal(api.reorder(order, plan, 'wifi', 1, 0).join(), 'wifi,media,bt');
|
||||||
|
// Empty space puts it after the last tile before that cell.
|
||||||
|
assert.equal(api.reorder(order, plan, 'wifi', 1, 1).join(), 'media,bt,wifi');
|
||||||
|
assert.equal(api.reorder(order, plan, 'bt', 0, 5).join(), 'wifi,media,bt');
|
||||||
|
assert.equal(api.reorder(order, plan, 'nope', 0, 0).join(), order.join());
|
||||||
|
// Resizing rounds to whole cells within 1..4.
|
||||||
|
assert.equal(JSON.stringify(api.resize({w: 1, h: 1}, 50, 0, 80, 68, 10)), '{"w":2,"h":1}');
|
||||||
|
assert.equal(JSON.stringify(api.resize({w: 2, h: 2}, -30, 400, 80, 68, 10)), '{"w":2,"h":4}');
|
||||||
|
assert.equal(JSON.stringify(api.resize({w: 1, h: 1}, -500, -500, 80, 68, 10)), '{"w":1,"h":1}');
|
||||||
|
// Geometry: an expanded tile pushes down everything from its bottom row.
|
||||||
|
plan = api.pack([{id: 'out', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'a', w: 1, h: 1}, {id: 'b', w: 4, h: 1}]);
|
||||||
|
let g = api.geometry(plan, 80, 68, 10);
|
||||||
|
assert.equal(JSON.stringify(g.tiles.media), '{"x":180,"y":0,"w":170,"h":146}');
|
||||||
|
assert.equal(g.height, 3 * 78 - 10);
|
||||||
|
g = api.geometry(plan, 80, 68, 10, {out: 100});
|
||||||
|
assert.equal(g.tiles.out.h, 68 + 110);
|
||||||
|
assert.equal(g.tiles.media.y, 0);
|
||||||
|
assert.equal(g.tiles.a.y, 78 + 110);
|
||||||
|
assert.equal(g.tiles.b.y, 156 + 110);
|
||||||
|
assert.equal(g.height, 3 * 78 - 10 + 110);
|
||||||
|
console.log('Control Center grid packing, hit testing, reordering, resizing and expansion geometry passed.');
|
||||||
@@ -41,6 +41,15 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
|
|||||||
assert ipc('controlTest','click','volumeMute');wait(lambda:state()['muted'],'mute click')
|
assert ipc('controlTest','click','volumeMute');wait(lambda:state()['muted'],'mute click')
|
||||||
assert ipc('controlTest','slider','volumeSlider');wait(lambda:state()['volume']>.6,'volume slider')
|
assert ipc('controlTest','slider','volumeSlider');wait(lambda:state()['volume']>.6,'volume slider')
|
||||||
assert ipc('controlTest','click','microphoneMute');wait(lambda:state()['microphone'],'microphone click')
|
assert ipc('controlTest','click','microphoneMute');wait(lambda:state()['microphone'],'microphone click')
|
||||||
|
# Per-app volume: right click extends Sound with the app streams.
|
||||||
|
assert ipc('controlTest','rightClick','outputTile');wait(lambda:state()['extras'].get('output',0)>0,'Sound extends')
|
||||||
|
time.sleep(.4)
|
||||||
|
t=next(i for i in state()['tiles'] if i['id']=='input');assert t['row']>0
|
||||||
|
assert ipc('controlTest','slider','appSlider-Fixture player');wait(lambda:state()['streamVolume']>.6,'app volume slider')
|
||||||
|
assert ipc('controlTest','click','appMute-Fixture player');wait(lambda:state()['streamMuted'],'app mute')
|
||||||
|
assert ipc('controlTest','rightClick','outputTile');wait(lambda:not state()['extras'].get('output',0),'Sound folds back')
|
||||||
|
assert ipc('controlTest','click','caffeineToggle');wait(lambda:state()['caffeine'] and state()['caffeineRunning'],'Caffeine on')
|
||||||
|
assert ipc('controlTest','click','caffeineToggle');wait(lambda:not state()['caffeine'] and not state()['caffeineRunning'],'Caffeine off')
|
||||||
assert ipc('controlTest','click','wifiToggle');wait(lambda:not state()['wifi'],'Wi-Fi toggle')
|
assert ipc('controlTest','click','wifiToggle');wait(lambda:not state()['wifi'],'Wi-Fi toggle')
|
||||||
assert ipc('controlTest','click','bluetoothToggle');wait(lambda:not state()['bluetooth'],'Bluetooth toggle')
|
assert ipc('controlTest','click','bluetoothToggle');wait(lambda:not state()['bluetooth'],'Bluetooth toggle')
|
||||||
assert ipc('controlTest','click','bluetoothToggle')
|
assert ipc('controlTest','click','bluetoothToggle')
|
||||||
@@ -84,12 +93,38 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
|
|||||||
ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'reduced motion close')
|
ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'reduced motion close')
|
||||||
pref('animation.reducedMotion',False)
|
pref('animation.reducedMotion',False)
|
||||||
ipc('controlcenter','open');ipc('launcher','open');wait(lambda:not ipc('controlcenter','status')['opened'],'launcher exclusivity');ipc('launcher','close')
|
ipc('controlcenter','open');ipc('launcher','open');wait(lambda:not ipc('controlcenter','status')['opened'],'launcher exclusivity');ipc('launcher','close')
|
||||||
|
# Edit mode: drag to reorder, resize from the handle, remove and add, Escape leaves it.
|
||||||
|
ipc('controlcenter','open');wait(lambda:state()['windowVisible'],'reopen for editing');time.sleep(.4)
|
||||||
|
assert ipc('controlTest','click','controlEdit');wait(lambda:state()['editing'],'edit mode')
|
||||||
|
time.sleep(.6);assert ipc('controlTest','screenshot',str(ROOT/'.cache/controlcenter-editing.png'))
|
||||||
|
s=state();tiles={t['id']:t for t in s['tiles']};step=s['cellWidth']+10
|
||||||
|
bt,wifi=tiles['bluetooth'],tiles['wifi']
|
||||||
|
assert ipc('controlTest','drag','controlMove-bluetooth',(wifi['col']-bt['col'])*step,(wifi['row']-bt['row'])*78)
|
||||||
|
ids=lambda:[m['id'] for m in state()['modules']]
|
||||||
|
wait(lambda:ids().index('bluetooth')<ids().index('wifi'),'drag reorders')
|
||||||
|
time.sleep(.3)
|
||||||
|
assert ipc('controlTest','drag','controlResize-wifi',step,78)
|
||||||
|
wait(lambda:any(m['id']=='wifi' and m.get('w')==3 and m.get('h')==2 for m in state()['modules']),'resize to 3x2')
|
||||||
|
assert next(t for t in state()['tiles'] if t['id']=='wifi')['w']==3
|
||||||
|
assert ipc('controlTest','click','controlRemove-dnd')
|
||||||
|
wait(lambda:not next(m for m in state()['modules'] if m['id']=='dnd')['enabled'],'remove badge')
|
||||||
|
assert not any(t['id']=='dnd' for t in state()['tiles'])
|
||||||
|
assert ipc('controlTest','click','controlAdd-dnd')
|
||||||
|
wait(lambda:any(t['id']=='dnd' for t in state()['tiles']),'add from tray')
|
||||||
|
ipc('controlTest','pressEscape');wait(lambda:not state()['editing'],'Escape leaves edit mode')
|
||||||
|
assert ipc('controlcenter','status')['opened']
|
||||||
|
time.sleep(.6);assert ipc('controlTest','screenshot',str(ROOT/'.cache/controlcenter-edited.png'))
|
||||||
|
assert ipc('controlTest','click','controlEdit');wait(lambda:state()['editing'],'edit mode again')
|
||||||
|
assert ipc('controlTest','click','controlReset')
|
||||||
|
wait(lambda:all('w' not in m for m in state()['modules']) and ids()[0]=='wifi','reset layout')
|
||||||
|
assert ipc('controlTest','click','controlEdit');wait(lambda:not state()['editing'],'done')
|
||||||
|
ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'close after editing')
|
||||||
ipc('shell','openSettings','controlcenter');wait(lambda:state()['settingsVisible'],'module editor opens');time.sleep(.3)
|
ipc('shell','openSettings','controlcenter');wait(lambda:state()['settingsVisible'],'module editor opens');time.sleep(.3)
|
||||||
second=state()['modules'][1]['id']
|
second=state()['modules'][1]['id']
|
||||||
assert ipc('controlTest','settingsDrag','control-drag-connectivity','control-drag-'+second)
|
assert ipc('controlTest','settingsDrag','control-drag-wifi','control-drag-'+second)
|
||||||
wait(lambda:state()['modules'][1]['id']=='connectivity','visual module reorder')
|
wait(lambda:state()['modules'][1]['id']=='wifi','visual module reorder')
|
||||||
assert ipc('controlTest','settingsClick','control-enable-audio')
|
assert ipc('controlTest','settingsClick','control-enable-output')
|
||||||
wait(lambda:not next(m for m in state()['modules'] if m['id']=='audio')['enabled'],'visual module toggle')
|
wait(lambda:not next(m for m in state()['modules'] if m['id']=='output')['enabled'],'visual module toggle')
|
||||||
ipc('shell','close');wait(lambda:not state()['settingsVisible'],'settings closes')
|
ipc('shell','close');wait(lambda:not state()['settingsVisible'],'settings closes')
|
||||||
for page in ['controlcenter','audio','network','bluetooth','displays','notifications','power']:
|
for page in ['controlcenter','audio','network','bluetooth','displays','notifications','power']:
|
||||||
ipc('shell','openSettings',page);time.sleep(.3)
|
ipc('shell','openSettings',page);time.sleep(.3)
|
||||||
@@ -101,4 +136,4 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
|
|||||||
shell.terminate();shell.wait(timeout=5)
|
shell.terminate();shell.wait(timeout=5)
|
||||||
if original:subprocess.run(['hyprctl','dispatch','focusmonitor',original],capture_output=True)
|
if original:subprocess.run(['hyprctl','dispatch','focusmonitor',original],capture_output=True)
|
||||||
text=log.read_text();assert 'WARN' not in text and 'ERROR' not in text,text
|
text=log.read_text();assert 'WARN' not in text and 'ERROR' not in text,text
|
||||||
print('PASS: native read-only discovery, active-monitor placement, system pill, recording audio/network/Bluetooth/display/DND actions, power confirmation/cancel, outside/Escape/exclusivity, settings, clean logs.')
|
print('PASS: native read-only discovery, active-monitor placement, system pill, recording audio/per-app volume/Caffeine/network/Bluetooth/display/DND actions, grid edit mode (drag, resize, remove, add, reset), power confirmation/cancel, outside/Escape/exclusivity, settings, clean logs.')
|
||||||
Reference in new issue
Block a user