init: working version

This commit is contained in:
Kiana Sheibani 2025-10-07 19:43:46 -04:00
commit 7d8d7dacae
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
109 changed files with 15066 additions and 0 deletions

View file

@ -0,0 +1,59 @@
import qs.config
import qs.services
import QtQuick
import QtQuick.Shapes
Shape {
id: root
required property Item wrapper
readonly property real rounding: Config.border.rounding
readonly property bool flatten: wrapper.width < rounding * 2
readonly property real roundingX: flatten ? wrapper.width / 2 : rounding
ShapePath {
startX: root.wrapper.width + 0.5
startY: -root.rounding
strokeWidth: -1
fillColor: Config.colors.bg
PathArc {
relativeX: -root.roundingX
relativeY: root.rounding
radiusX: Math.min(root.rounding, root.wrapper.width)
radiusY: root.rounding
}
PathLine {
relativeX: -(root.wrapper.width - root.roundingX * 2)
relativeY: 0
}
PathArc {
relativeX: -root.roundingX
relativeY: root.rounding
radiusX: Math.min(root.rounding, root.wrapper.width)
radiusY: root.rounding
direction: PathArc.Counterclockwise
}
PathLine {
relativeX: 0
relativeY: root.wrapper.height - root.rounding * 2
}
PathArc {
relativeX: root.roundingX
relativeY: root.rounding
radiusX: Math.min(root.rounding, root.wrapper.width)
radiusY: root.rounding
direction: PathArc.Counterclockwise
}
PathLine {
relativeX: root.wrapper.width - root.roundingX * 2
relativeY: 0
}
PathArc {
relativeX: root.roundingX
relativeY: root.rounding
radiusX: Math.min(root.rounding, root.wrapper.width)
radiusY: root.rounding
}
}
}

161
modules/osd/Content.qml Normal file
View file

@ -0,0 +1,161 @@
pragma ComponentBehavior: Bound
import qs.config
import qs.custom
import qs.services
import qs.util
import QtQuick
import QtQuick.Layouts
Item {
id: root
required property var uiState
required property Brightness.Monitor monitor
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
implicitWidth: layout.implicitWidth + 30
implicitHeight: layout.implicitHeight + sunset.height + 40
RowLayout {
id: layout
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 15
spacing: 10
// Speaker volume
CustomMouseArea {
implicitWidth: Config.osd.sliderWidth
implicitHeight: Config.osd.sliderLength
function onWheel(event: WheelEvent) {
if (event.angleDelta.y > 0)
Audio.increaseVolume();
else if (event.angleDelta.y < 0)
Audio.decreaseVolume();
}
acceptedButtons: Qt.RightButton
onClicked: Audio.sink.audio.muted = !Audio.muted
CustomFilledSlider {
anchors.fill: parent
color: Audio.muted ? Config.colors.error : Config.colors.volume
icon: Icons.getVolumeIcon(value, Audio.muted)
value: Audio.volume
onMoved: Audio.setVolume(value)
Behavior on color {
CAnim {
duration: Config.anim.durations.small
}
}
}
}
// Microphone
CustomMouseArea {
implicitWidth: Config.osd.sliderWidth
implicitHeight: Config.osd.sliderLength
function onWheel(event: WheelEvent) {
if (event.angleDelta.y > 0)
Audio.incrementSourceVolume();
else if (event.angleDelta.y < 0)
Audio.decrementSourceVolume();
}
acceptedButtons: Qt.RightButton
onClicked: Audio.source.audio.muted = !Audio.sourceMuted
CustomFilledSlider {
anchors.fill: parent
color: Audio.sourceMuted ? Config.colors.error : Config.colors.mic
icon: Icons.getMicVolumeIcon(value, Audio.sourceMuted)
value: Audio.sourceVolume
onMoved: Audio.setSourceVolume(value)
Behavior on color {
CAnim {
duration: Config.anim.durations.small
}
}
}
}
// Brightness
CustomMouseArea {
implicitWidth: Config.osd.sliderWidth
implicitHeight: Config.osd.sliderLength
function onWheel(event: WheelEvent) {
const monitor = root.monitor;
if (!monitor)
return;
if (event.angleDelta.y > 0)
monitor.setBrightness(monitor.brightness + 0.1);
else if (event.angleDelta.y < 0)
monitor.setBrightness(monitor.brightness - 0.1);
}
CustomFilledSlider {
anchors.fill: parent
color: Config.colors.brightness
icon: Icons.getBrightnessIcon(value)
value: root.monitor?.brightness ?? 0
onMoved: root.monitor?.setBrightness(value)
}
}
}
CustomRect {
id: sunset
anchors.top: layout.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
width: layout.width
height: 40
color: Hyprsunset.active ? Config.colors.brightness : Config.colors.container
radius: 7
Behavior on color {
CAnim { duration: Config.anim.durations.small }
}
StateLayer {
anchors.fill: parent
radius: parent.radius
color: Config.colors.secondary
function onClicked() {
if (Hyprsunset.active)
Hyprsunset.disable();
else
Hyprsunset.enable();
}
}
MaterialIcon {
anchors.centerIn: parent
text: "dark_mode"
font.pointSize: Config.font.size.large
color: Hyprsunset.active ? Config.colors.primaryDark : Config.colors.secondary
fill: Hyprsunset.active ? 1 : 0
Behavior on color {
CAnim { duration: Config.anim.durations.small }
}
}
}
}

View file

@ -0,0 +1,54 @@
import qs.services
import qs.config
import Quickshell
import QtQuick
Scope {
id: root
required property PersistentProperties uiState
required property ShellScreen screen
required property bool hovered
required property bool suppressed
readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(screen)
function show(): void {
if (!root.suppressed) {
root.uiState.osd = true;
timer.restart();
}
}
Connections {
target: Audio
function onMutedChanged(): void {
if (root.uiState.osdVolumeReact)
root.show();
}
function onVolumeChanged(): void {
if (root.uiState.osdVolumeReact)
root.show();
}
}
Connections {
target: root.monitor
function onBrightnessChanged(): void {
if (root.uiState.osdBrightnessReact)
root.show();
}
}
Timer {
id: timer
interval: Config.osd.hideDelay
onTriggered: {
if (!root.hovered)
root.uiState.osd = false;
}
}
}

66
modules/osd/Wrapper.qml Normal file
View file

@ -0,0 +1,66 @@
import qs.config
import qs.custom
import qs.services
import Quickshell
import QtQuick
Item {
id: root
required property var uiState
required property ShellScreen screen
visible: width > 0
implicitWidth: 0
implicitHeight: content.implicitHeight
states: State {
name: "visible"
when: root.uiState.osd
PropertyChanges {
root.implicitWidth: content.implicitWidth
}
}
transitions: [
Transition {
from: ""
to: "visible"
Anim {
target: root
property: "implicitWidth"
easing.bezierCurve: Config.anim.curves.expressiveDefaultSpatial
}
},
Transition {
from: "visible"
to: ""
Anim {
target: root
property: "implicitWidth"
easing.bezierCurve: Config.anim.curves.emphasized
}
}
]
Background {
id: background
visible: false
wrapper: root
}
GlowEffect {
source: background
glowColor: Config.colors.osd
}
Content {
id: content
uiState: root.uiState
monitor: Brightness.getMonitorForScreen(root.screen)
}
}