- The notch's cog edits a separate tile layout (notch.controls); normal mode keeps the Control Center's. Reset follows the Control Center again. - Notch islands draw no bar behind their modules. - The notch strip picker comes first in Settings → Notch, and an empty strip offers a shortcut to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
756 lines
35 KiB
QML
756 lines
35 KiB
QML
pragma ComponentBehavior: Bound
|
||
import QtQuick
|
||
import QtQuick.Controls
|
||
import QtQuick.Layouts
|
||
import Quickshell
|
||
import Quickshell.Io
|
||
import Quickshell.Wayland
|
||
import "../components"
|
||
import "../services"
|
||
import "../core"
|
||
import "../theme"
|
||
import "GridLogic.js" as Grid
|
||
|
||
// 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.
|
||
// qmllint disable uncreatable-type
|
||
PanelWindow {
|
||
id: root
|
||
screen: ScreenService.current(ShellState.controlCenterScreen)
|
||
anchors {
|
||
top: true
|
||
right: true
|
||
}
|
||
readonly property int screenWidth: screen ? screen.width : 1920
|
||
readonly property int screenHeight: screen ? screen.height : 1080
|
||
// Drops out of the bar's right side; the right ear stays on its straight edge.
|
||
readonly property real rightInset: BarDrawers.margin + BarDrawers.radius
|
||
// Panel position on the output, for tests and diagnostics.
|
||
readonly property real panelScreenX: screenWidth - rightInset - width + panel.ear
|
||
readonly property real panelScreenY: BarDrawers.bottom
|
||
// The layer starts at the screen top so the bar join is inside its box.
|
||
// Margins is present at runtime but unresolved in 0.3.1 qmltypes.
|
||
// qmllint disable unqualified unresolved-type
|
||
margins {
|
||
right: root.rightInset
|
||
}
|
||
// qmllint enable unqualified unresolved-type
|
||
implicitWidth: Math.round(panel.width)
|
||
implicitHeight: Math.round(BarDrawers.bottom + panel.contentHeight)
|
||
visible: ShellState.controlCenterOpen || panel.shown
|
||
color: Theme.transparent
|
||
exclusionMode: ExclusionMode.Ignore
|
||
WlrLayershell.layer: WlrLayer.Overlay
|
||
WlrLayershell.namespace: "glassMxrph-controlcenter"
|
||
WlrLayershell.keyboardFocus: ShellState.controlCenterOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||
Component.onCompleted: ShellState.controlCenterWindow = root
|
||
Component.onDestruction: ShellState.controlCenterWindow = null
|
||
|
||
// Modules sit freely on a 4-column grid at their saved cell, so gaps stay
|
||
// where they are left; tiles without a position take the first free spot.
|
||
// Notifications is a section under it. Edit mode moves tiles by dragging and
|
||
// resizes them from the corner handle (tiles in the way are pushed down),
|
||
// removes them with the badge and adds them from a tray.
|
||
readonly property int gap: 10
|
||
readonly property int cellHeight: 68
|
||
readonly property real gridWidth: panel.targetWidth - 28
|
||
readonly property real cellWidth: (gridWidth - 3 * gap) / Grid.COLS
|
||
// The notch's cog edits the notch's own tile layout here.
|
||
readonly property bool notchLayout: ShellState.controlCenterTarget === "notch"
|
||
readonly property string layoutPath: notchLayout ? "notch.controls" : "controlCenter.modules"
|
||
readonly property var entries: !ConfigService.ready ? [] : notchLayout ? ControlRegistry.notchModules : ConfigService.data.controlCenter.modules
|
||
readonly property var tiles: entries.filter(m => m.enabled && !!ControlRegistry.entry(m.id) && !ControlRegistry.entry(m.id).section)
|
||
readonly property bool notifications: entries.some(m => m.id === "notifications" && m.enabled)
|
||
readonly property var addable: ControlRegistry.ids.filter(id => !entries.some(m => m.id === id && m.enabled))
|
||
property bool editing: false
|
||
// Live edit preview while a tile is dragged or resized.
|
||
property var preview: null
|
||
property string dragId: ""
|
||
property point dragPoint
|
||
property point grabOffset
|
||
property string resizeId: ""
|
||
// Tile id -> pixels a tile extends below its cells.
|
||
property var extras: ({})
|
||
readonly property var savedPlan: Grid.layout(tiles.map(m => {
|
||
const size = ControlRegistry.size(m);
|
||
return {
|
||
id: m.id,
|
||
w: size.w,
|
||
h: size.h,
|
||
x: m.x,
|
||
y: m.y
|
||
};
|
||
}))
|
||
readonly property var plan: preview || savedPlan
|
||
// Edit mode shows one empty row below the tiles to drop into.
|
||
readonly property int shownRows: plan.rows + (editing ? 1 : 0)
|
||
readonly property var geometry: Grid.geometry(plan, cellWidth, cellHeight, gap, editing ? {} : extras)
|
||
function setExtra(id, value) {
|
||
if ((extras[id] || 0) === value)
|
||
return;
|
||
const next = Object.assign({}, extras);
|
||
next[id] = value;
|
||
extras = next;
|
||
}
|
||
// Writes every tile's cell (and changed sizes) back, so nothing repacks
|
||
// and gaps stay.
|
||
function save(plan, patch) {
|
||
ConfigService.setValue(root.layoutPath, entries.map(m => {
|
||
const i = plan.items.find(t => t.id === m.id);
|
||
let next = Object.assign({}, m);
|
||
if (i) {
|
||
const def = ControlRegistry.size({
|
||
id: m.id
|
||
});
|
||
next.x = i.col;
|
||
next.y = i.row;
|
||
if (m.w !== undefined || m.h !== undefined || i.w !== def.w || i.h !== def.h) {
|
||
next.w = i.w;
|
||
next.h = i.h;
|
||
}
|
||
}
|
||
if (patch && patch[m.id])
|
||
next = patch[m.id](next);
|
||
return next;
|
||
}));
|
||
}
|
||
function setEnabled(id, on) {
|
||
if (!on) {
|
||
// The rest keep their cells; the removed tile forgets its own.
|
||
save(savedPlan, {
|
||
[id]: m => {
|
||
const next = Object.assign({}, m, {
|
||
enabled: false
|
||
});
|
||
delete next.x;
|
||
delete next.y;
|
||
return next;
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
const e = ControlRegistry.entry(id);
|
||
const known = entries.find(m => m.id === id);
|
||
const size = ControlRegistry.size(known || {
|
||
id: id
|
||
});
|
||
const spot = e && !e.section ? Grid.freeSpot(savedPlan, size.w, size.h) : null;
|
||
const added = Object.assign({}, known || {
|
||
id: id
|
||
}, {
|
||
enabled: true
|
||
}, spot ? {
|
||
x: spot.col,
|
||
y: spot.row
|
||
} : {});
|
||
ConfigService.setValue(root.layoutPath, known ? entries.map(m => m.id === id ? added : m) : entries.concat([added]));
|
||
}
|
||
function reset() {
|
||
// The notch resets to following the Control Center again.
|
||
ConfigService.setValue(root.layoutPath, notchLayout ? [] : ConfigService.defaults.controlCenter.modules);
|
||
}
|
||
Connections {
|
||
target: ShellState
|
||
function onControlCenterOpenChanged() {
|
||
if (!ShellState.controlCenterOpen)
|
||
root.editing = false;
|
||
else if (ShellState.controlCenterEditRequested) {
|
||
ShellState.controlCenterEditRequested = false;
|
||
root.editing = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
component ModuleSlot: Loader {
|
||
property string moduleId
|
||
Layout.fillWidth: true
|
||
Layout.preferredWidth: 1
|
||
active: ShellState.controlCenterOpen
|
||
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 {
|
||
id: headerButton
|
||
property string glyph
|
||
property string fallback
|
||
signal clicked
|
||
implicitWidth: 28
|
||
implicitHeight: 28
|
||
radius: 14
|
||
color: headerArea.containsMouse ? Qt.alpha(Theme.text, 0.12) : Theme.transparent
|
||
Accessible.role: Accessible.Button
|
||
GlassIcon {
|
||
anchors.centerIn: parent
|
||
size: 28
|
||
glyphSize: 14
|
||
glyph: headerButton.glyph
|
||
fallback: headerButton.fallback
|
||
color: Theme.transparent
|
||
border.width: 0
|
||
glyphColor: Theme.textSecondary
|
||
}
|
||
MouseArea {
|
||
id: headerArea
|
||
anchors.fill: parent
|
||
hoverEnabled: true
|
||
cursorShape: Qt.PointingHandCursor
|
||
onClicked: headerButton.clicked()
|
||
}
|
||
}
|
||
|
||
// Hyprland routes every pointer event to a layer with exclusive keyboard
|
||
// focus, so clicks outside the panel arrive here with out-of-bounds
|
||
// coordinates. Qt Quick still delivers them to items extending past the
|
||
// window, so this catcher (behind the panel) dismisses on outside clicks.
|
||
MouseArea {
|
||
objectName: "controlCenterOutside"
|
||
x: -20000
|
||
y: -20000
|
||
width: 40000
|
||
height: 40000
|
||
onPressed: ShellState.controlCenterOpen = false
|
||
}
|
||
|
||
BarDrawer {
|
||
id: panel
|
||
objectName: "controlCenterSurface"
|
||
readonly property real targetWidth: Math.min(ConfigService.ready ? ConfigService.data.controlCenter.width : 400, root.screenWidth - 2 * root.rightInset - 2 * ear)
|
||
readonly property real targetHeight: Math.min(content.implicitHeight + 28, root.screenHeight - BarDrawers.bottom - 20)
|
||
y: BarDrawers.bottom
|
||
open: ShellState.controlCenterOpen
|
||
contentWidth: targetWidth
|
||
contentHeight: targetHeight
|
||
drawerId: "controlcenter"
|
||
screenName: root.screen ? root.screen.name : ""
|
||
screenX: root.screenWidth - root.rightInset - width
|
||
focus: open
|
||
onOpenChanged: if (open)
|
||
forceActiveFocus()
|
||
Keys.onEscapePressed: {
|
||
if (PowerService.pending)
|
||
PowerService.cancel();
|
||
else if (root.editing)
|
||
root.editing = false;
|
||
else
|
||
ShellState.controlCenterOpen = false;
|
||
}
|
||
Behavior on contentHeight {
|
||
enabled: panel.settled
|
||
NumberAnimation {
|
||
duration: Theme.duration
|
||
easing.type: Easing.OutCubic
|
||
}
|
||
}
|
||
MouseArea {
|
||
anchors.fill: parent
|
||
}
|
||
ScrollView {
|
||
anchors.fill: parent
|
||
anchors.margins: 14
|
||
clip: true
|
||
contentWidth: panel.targetWidth - 28
|
||
ColumnLayout {
|
||
id: content
|
||
width: panel.targetWidth - 28
|
||
spacing: 10
|
||
RowLayout {
|
||
Layout.fillWidth: true
|
||
Layout.leftMargin: 4
|
||
spacing: 2
|
||
Text {
|
||
text: root.notchLayout ? (root.editing ? "Edit Notch Controls" : "Notch Controls") : root.editing ? "Edit Controls" : "Control Center"
|
||
color: Theme.text
|
||
font.pixelSize: 14
|
||
font.weight: Font.DemiBold
|
||
Layout.fillWidth: true
|
||
}
|
||
HeaderButton {
|
||
visible: root.editing
|
||
glyph: ""
|
||
fallback: "⚙"
|
||
onClicked: ShellState.openSettings("controlcenter")
|
||
Accessible.name: "Control Center settings"
|
||
}
|
||
HeaderButton {
|
||
glyph: ""
|
||
fallback: "×"
|
||
onClicked: ShellState.controlCenterOpen = false
|
||
Accessible.name: "Close Control Center"
|
||
}
|
||
}
|
||
Item {
|
||
id: grid
|
||
objectName: "controlGrid"
|
||
Layout.fillWidth: true
|
||
implicitHeight: root.geometry.height + (root.editing ? root.cellHeight + root.gap : 0)
|
||
visible: root.tiles.length > 0 || root.editing
|
||
Behavior on implicitHeight {
|
||
enabled: panel.settled && !root.dragId
|
||
NumberAnimation {
|
||
duration: Theme.duration
|
||
easing.type: Easing.OutCubic
|
||
}
|
||
}
|
||
// Edit mode: faint cells show the grid, and where a dragged tile lands.
|
||
Repeater {
|
||
// Only the empty cells: tiles are translucent.
|
||
model: root.editing ? Array.from({
|
||
length: Grid.COLS * root.shownRows
|
||
}, (_, i) => i).filter(i => !root.plan.items.some(t => i % Grid.COLS >= t.col && i % Grid.COLS < t.col + t.w && Math.floor(i / Grid.COLS) >= t.row && Math.floor(i / Grid.COLS) < t.row + t.h)) : []
|
||
Rectangle {
|
||
required property int modelData
|
||
x: (modelData % Grid.COLS) * (root.cellWidth + root.gap)
|
||
y: Math.floor(modelData / Grid.COLS) * (root.cellHeight + root.gap)
|
||
width: root.cellWidth
|
||
height: root.cellHeight
|
||
radius: 16
|
||
color: Qt.alpha(Theme.text, 0.03)
|
||
border.width: 1
|
||
border.color: Qt.alpha(Theme.text, 0.07)
|
||
}
|
||
}
|
||
Rectangle {
|
||
readonly property var target: root.dragId ? root.geometry.tiles[root.dragId] : null
|
||
visible: !!target
|
||
x: target ? target.x : 0
|
||
y: target ? target.y : 0
|
||
width: target ? target.w : 0
|
||
height: target ? target.h : 0
|
||
radius: Math.min(30, height / 2, width / 2)
|
||
color: Qt.alpha(Theme.accent, 0.12)
|
||
border.width: 2
|
||
border.color: Qt.alpha(Theme.accent, 0.6)
|
||
}
|
||
Repeater {
|
||
// Keyed by id so moving or resizing keeps each module alive.
|
||
model: ScriptModel {
|
||
values: root.tiles.map(m => m.id)
|
||
}
|
||
Item {
|
||
id: slot
|
||
required property string 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
|
||
property: "moduleId"
|
||
value: slot.modelData
|
||
}
|
||
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 var lastCell: null
|
||
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 = null;
|
||
}
|
||
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.dragId = slot.modelData;
|
||
}
|
||
root.dragPoint = p;
|
||
// The cell nearest the tile's top-left corner, at most one row below the rest.
|
||
const c = Grid.cellAt(p.x - root.grabOffset.x, p.y - root.grabOffset.y, root.cellWidth, root.cellHeight, root.gap);
|
||
c.row = Math.min(c.row, root.savedPlan.rows);
|
||
if (lastCell && c.col === lastCell.col && c.row === lastCell.row)
|
||
return;
|
||
lastCell = c;
|
||
// Always from the saved layout, so tiles pushed aside come back.
|
||
root.preview = Grid.moveTo(root.savedPlan, slot.modelData, c);
|
||
}
|
||
onReleased: {
|
||
const plan = root.preview;
|
||
root.dragId = "";
|
||
root.preview = null;
|
||
if (plan)
|
||
root.save(plan);
|
||
}
|
||
onCanceled: {
|
||
root.dragId = "";
|
||
root.preview = 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.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 !== slot.cell.w || next.h !== slot.cell.h)
|
||
root.preview = Grid.moveTo(root.savedPlan, slot.modelData, next);
|
||
}
|
||
onReleased: {
|
||
const plan = root.preview;
|
||
root.resizeId = "";
|
||
root.preview = null;
|
||
if (plan)
|
||
root.save(plan);
|
||
}
|
||
onCanceled: {
|
||
root.resizeId = "";
|
||
root.preview = 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 {
|
||
visible: SystemService.acting
|
||
text: "Updating system controls…"
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 11
|
||
Layout.fillWidth: true
|
||
Layout.leftMargin: 4
|
||
}
|
||
Text {
|
||
visible: !!SystemService.error
|
||
text: SystemService.error
|
||
color: Theme.urgent
|
||
font.pixelSize: 11
|
||
wrapMode: Text.Wrap
|
||
Layout.fillWidth: true
|
||
Layout.leftMargin: 4
|
||
}
|
||
ModuleSlot {
|
||
moduleId: "notifications"
|
||
visible: root.notifications && !root.editing
|
||
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
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
IpcHandler {
|
||
target: "controlcenter"
|
||
function toggle(): void {
|
||
ShellState.toggleControlCenter();
|
||
}
|
||
function open(): void {
|
||
ShellState.openControlCenter();
|
||
}
|
||
function close(): void {
|
||
ShellState.controlCenterOpen = false;
|
||
}
|
||
function status(): string {
|
||
return JSON.stringify({
|
||
opened: ShellState.controlCenterOpen,
|
||
screen: root.screen ? root.screen.name : "",
|
||
busy: SystemService.busy,
|
||
error: SystemService.error,
|
||
pendingPower: PowerService.pending
|
||
});
|
||
}
|
||
}
|
||
}
|