Files
DankMaterialShell/quickshell/Modules/DankIsland/IslandSystemSource.qml
T
purian23 5623476126 feat(island): host the island as a widget in any bar configuration
- The island is now a bar widget so any bar can host one alongside the island layout and dot
- Routing got simpler: pick which shortcuts open here, the rest follow the shared rules
- IPC close/hide take down every surface showing the activity
- Qt 6.11 pointer prune workaround so the expanded island stays clickable
2026-09-27 02:02:30 -04:00

80 lines
3.1 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Services
QtObject {
id: root
required property IslandController controller
property string kind: "volume"
// Off: volume and brightness keep their OSDs and only the face's own controls open this activity.
property bool enabled: true
readonly property bool volumeActivity: kind === "volume"
readonly property bool available: volumeActivity ? !!AudioService.sink?.audio : BrightnessService.brightnessAvailable
readonly property bool muted: volumeActivity && (AudioService.sink?.audio?.muted ?? false)
readonly property real value: volumeActivity ? AudioService.sinkVolumePercent : BrightnessService.brightnessLevel
readonly property var brightnessDevice: BrightnessService.getCurrentDeviceInfo()
readonly property real maximum: volumeActivity ? AudioService.sinkMaxVolume : BrightnessService.brightnessMaximum(brightnessDevice)
readonly property int minimum: volumeActivity ? 0 : BrightnessService.brightnessMinimum(brightnessDevice)
readonly property real ratio: maximum > 0 ? Math.max(0, Math.min(1, value / maximum)) : 0
readonly property string title: volumeActivity ? I18n.tr("Volume", "island system face: volume title") : I18n.tr("Brightness", "island system face: brightness title")
readonly property string unit: volumeActivity ? "%" : BrightnessService.brightnessUnit(brightnessDevice)
readonly property string displayValue: muted ? I18n.tr("Muted", "island system face: muted value label") : Math.round(value) + unit
readonly property string iconName: volumeActivity ? AudioService.sinkVolumeIconName : BrightnessService.brightnessIconName(brightnessDevice, value)
function show(activityKind) {
if (!enabled || SessionData.suppressOSD)
return;
open(activityKind);
}
function open(activityKind) {
if (controller.requestSystemActivity(activityKind))
kind = activityKind;
}
function setRatio(nextRatio) {
const clampedRatio = Math.max(0, Math.min(1, nextRatio));
SessionData.suppressOSDTemporarily();
if (volumeActivity) {
AudioService.setVolume(Math.round(clampedRatio * maximum));
return;
}
BrightnessService.setBrightness(Math.round(clampedRatio * maximum), BrightnessService.lastIpcDevice, true);
}
function toggleMute() {
if (!volumeActivity || !available)
return;
SessionData.suppressOSDTemporarily();
AudioService.toggleMute();
}
property Connections audioConnection: Connections {
target: AudioService.sink?.audio ?? null
function onVolumeChanged() {
if (SettingsData.osdVolumeEnabled)
root.show("volume");
}
function onMutedChanged() {
if (SettingsData.osdVolumeEnabled)
root.show("volume");
}
}
property Connections brightnessConnection: Connections {
target: BrightnessService
function onBrightnessChanged(showOsd) {
if (showOsd && SettingsData.osdBrightnessEnabled)
root.show("brightness");
}
}
}