Rows drag from anywhere (or the grip, Ctrl+Up/Down from the keyboard) with an accent drop indicator, replacing the up/down buttons. The Control Center runtime test drags instead of clicking, and turns off built-in notifications since the live shell owns the bus name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
244 lines
9.6 KiB
QML
244 lines
9.6 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;
|
|
}
|
|
// Drags one module grip onto the lower half of another row.
|
|
function settingsDrag(name: string, target: string): bool {
|
|
const content = ShellState.settingsWindow.contentItem;
|
|
const source = input.findChild(content, name), over = input.findChild(content, target);
|
|
if (!source || !over)
|
|
return false;
|
|
root.reveal(source);
|
|
const end = source.mapFromItem(over, over.width / 2, over.height - 4);
|
|
input.mousePress(source, source.width / 2, source.height / 2);
|
|
input.mouseMove(source, source.width / 2, source.height / 2 + 10, 40);
|
|
input.mouseMove(source, end.x, end.y, 80);
|
|
input.wait(80);
|
|
input.mouseRelease(source, end.x, end.y);
|
|
input.wait(80);
|
|
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);
|
|
}
|
|
}
|
|
}
|