Files
glassMxrph/quickshell/testing/ControlDriver.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

228 lines
8.8 KiB
QML

import QtQuick
import QtTest
import Quickshell
import Quickshell.Io
import Quickshell.Networking
import Quickshell.Bluetooth
import "../core"
import "../services"
Item {
id: root
parent: ShellState.controlCenterWindow ? ShellState.controlCenterWindow.contentItem : null
TestCase {
id: input
name: "ControlInput"
when: false
}
property QtObject audioNode: QtObject {
property string name: "fixture-output"
property string description: "Fixture audio"
property bool isSink: true
property bool isStream: false
property QtObject audio: QtObject {
property real volume: 0.4
property bool muted: false
}
}
property QtObject audioInput: QtObject {
property string name: "fixture-input"
property string description: "Fixture microphone"
property bool isSink: false
property bool isStream: false
property QtObject audio: QtObject {
property real volume: 0.6
property bool muted: false
}
}
property QtObject audioBackend: QtObject {
property bool ready: true
property var defaultAudioSink: root.audioNode
property var defaultAudioSource: root.audioInput
property var preferredDefaultAudioSink: root.audioNode
property var preferredDefaultAudioSource: root.audioInput
property QtObject nodes: QtObject {
property var values: [root.audioNode, root.audioInput]
}
}
property QtObject wifi: QtObject {
id: fixtureWifi
property int type: DeviceType.Wifi
property string name: "fixture-wifi"
property bool connected: fixtureNetwork.connected
property bool scannerEnabled: false
property QtObject networks: QtObject {
property var values: [root.network]
}
}
property QtObject network: QtObject {
id: fixtureNetwork
property string name: "Fixture network"
property var device: root.wifi
property bool known: true
property bool connected: false
property int state: ConnectionState.Disconnected
property bool stateChanging: false
property int security: WifiSecurityType.Wpa2Psk
signal connectionFailed(int reason)
function connect() {
connected = true;
state = ConnectionState.Connected;
}
function disconnect() {
connected = false;
state = ConnectionState.Disconnected;
}
function connectWithPsk(password) {
connect();
}
}
property QtObject networkBackend: QtObject {
property int backend: NetworkBackendType.NetworkManager
property bool wifiEnabled: true
property bool wifiHardwareEnabled: true
property QtObject devices: QtObject {
property var values: [root.wifi]
}
}
property QtObject btDevice: QtObject {
property string name: "Fixture headphones"
property bool connected: false
property bool paired: true
property int state: BluetoothDeviceState.Disconnected
property bool batteryAvailable: true
property real battery: 0.8
function connect() {
connected = true;
state = BluetoothDeviceState.Connected;
}
function disconnect() {
connected = false;
state = BluetoothDeviceState.Disconnected;
}
}
property QtObject btAdapter: QtObject {
property string name: "Fixture Bluetooth"
property string adapterId: "fixture"
property bool enabled: true
property int state: BluetoothAdapterState.Enabled
property QtObject devices: QtObject {
property var values: [root.btDevice]
}
}
property QtObject btBackend: QtObject {
property var defaultAdapter: root.btAdapter
property QtObject adapters: QtObject {
property var values: [root.btAdapter]
}
}
function child(name) {
return input.findChild(ShellState.controlCenterWindow.contentItem, name);
}
function reveal(item) {
let parent = item.parent;
while (parent) {
if (parent.contentY !== undefined && parent.contentItem && parent.contentHeight > parent.height) {
const pos = item.mapToItem(parent.contentItem, 0, 0);
parent.contentY = Math.max(0, Math.min(parent.contentHeight - parent.height, pos.y - parent.height / 2));
}
parent = parent.parent;
}
input.wait(40);
}
IpcHandler {
target: "controlTest"
function inject(): bool {
if (SystemService.busy)
return false;
AudioService.backend = root.audioBackend;
NetworkService.backend = root.networkBackend;
BluetoothService.backend = root.btBackend;
SystemService.helper = "testing/recording_system.py";
SystemService.refresh();
return true;
}
function click(name: string): bool {
const item = root.child(name);
if (!item || !item.enabled)
return false;
root.reveal(item);
input.mouseClick(item, item.width / 2, item.height / 2);
return true;
}
function slider(name: string): bool {
const item = root.child(name);
if (!item || !item.enabled)
return false;
root.reveal(item);
input.mouseClick(item, item.width * .75, item.height / 2);
return true;
}
function clickSystem(): bool {
const pill = ShellState.systemPills.find(p => p.barScreen === ScreenService.active) || ShellState.systemPills[0];
if (!pill)
return false;
input.mouseClick(pill, pill.width / 2, pill.height / 2);
return true;
}
function settingsClick(name: string): bool {
const item = input.findChild(ShellState.settingsWindow.contentItem, name);
if (!item || !item.enabled)
return false;
root.reveal(item);
input.mouseClick(item, item.width / 2, item.height / 2);
return true;
}
function value(name: string): real {
const item = root.child(name);
return item ? item.value : -1;
}
function checked(name: string): bool {
const item = root.child(name);
return item ? item.checked : false;
}
function pressEscape(): void {
input.keyClick(Qt.Key_Escape);
}
function outside(): void {
// Outside the panel-sized surface, as Hyprland delivers it.
input.mouseClick(ShellState.controlCenterWindow.contentItem, -40, ShellState.controlCenterWindow.height / 2);
}
function screenshot(path: string): bool {
return root.child("controlCenterSurface").grabToImage(result => result.saveToFile(path));
}
function snapshot(): string {
const panel = root.child("controlCenterSurface");
return JSON.stringify({
settingsVisible: ShellState.settingsWindow.visible,
modules: ConfigService.data.controlCenter.modules,
windowVisible: ShellState.controlCenterWindow.visible,
panelVisible: panel.visible,
panelOpacity: panel.opacity,
opened: ShellState.controlCenterOpen,
state: SystemService.state,
error: SystemService.error,
busy: SystemService.busy,
power: PowerService.pending,
wifi: NetworkService.enabled,
bluetooth: BluetoothService.enabled,
volume: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.volume : -1,
muted: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.muted : false,
microphone: AudioService.source && AudioService.source.audio ? AudioService.source.audio.muted : false,
scan: fixtureWifi.scannerEnabled,
active: ScreenService.active.name,
screens: Quickshell.screens.map(s => s.name),
x: ShellState.controlCenterWindow.panelScreenX,
y: ShellState.controlCenterWindow.panelScreenY,
width: panel.width,
height: panel.height,
screenWidth: ShellState.controlCenterWindow.screenWidth,
screenHeight: ShellState.controlCenterWindow.screenHeight
});
}
function connectFixtures(): bool {
return NetworkService.connectNetwork(root.network, "") && BluetoothService.connectDevice(root.btDevice);
}
}
}