From e939c8e84f7cf1053543806f4f4d8aa1aa445667 Mon Sep 17 00:00:00 2001 From: Nydragon Date: Sat, 24 Aug 2024 23:04:56 +0200 Subject: [PATCH] feat: add mouseregion for audio scrolling and volume icon Volume icon is temporary and from flaticon --- src/AudioOutput.qml | 70 ++++++++++++++++++++++++++++++++------------ src/speaker.png | Bin 0 -> 2549 bytes 2 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 src/speaker.png diff --git a/src/AudioOutput.qml b/src/AudioOutput.qml index c22f163..fc669ef 100644 --- a/src/AudioOutput.qml +++ b/src/AudioOutput.qml @@ -9,33 +9,65 @@ import Quickshell.Services.Pipewire // - adjust sink & source volume // - mute sinks & sources -MouseArea { +// BUG: When controlling audio from outside of QS, the change is reflected, but if audio in pavucontrol is not 100% +// QS can only change from 0 to whatever is set in pavucontrol +Rectangle { + id: test + width: parent.width + height: (icon.height + slider.height) * 1.5 + anchors.bottomMargin: 5 + anchors.topMargin: 5 + border.color: "black" + border.width: 2 + radius: 5 + property PwNode sink: Pipewire.defaultAudioSink - PwObjectTracker { - objects: [sink] - } + MouseArea { + id: audio_area - ColumnLayout { - anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent - Text { - id: label - text: `${Math.round(sink.audio.volume * 100)}%` + onClicked: {} - Layout.alignment: Qt.AlignHCenter + onWheel: { + const newVal = sink.audio.volume + (wheel.angleDelta.y / 12000); + sink.audio.volume = newVal < 1.0 ? (newVal > 0 ? newVal : 0.0) : 1.0; } - Slider { - id: slider - // BUG: For some reason need to hardcode the width as it is overflowing otherwise - Layout.maximumWidth: 25 + PwObjectTracker { + objects: [sink] + } - value: sink.audio.volume - stepSize: 0.01 - wheelEnabled: true - handle: Rectangle {} - onMoved: sink.audio.volume = value + Rectangle { + width: parent.width + color: "#00000000" + + height: icon.height + slider.height + anchors.verticalCenter: parent.verticalCenter + + // TODO: Make icon depend on sink type and volume level + Image { + id: icon + source: "speaker.png" + width: parent.width * (2 / 3) + + anchors.horizontalCenter: parent.horizontalCenter + fillMode: Image.PreserveAspectFit + } + Slider { + id: slider + anchors.top: icon.bottom + anchors.horizontalCenter: parent.horizontalCenter + + width: parent.width - 5 + + value: sink.audio.volume + stepSize: 0.01 + wheelEnabled: true + handle: Rectangle {} + onMoved: sink.audio.volume = value + } } } } diff --git a/src/speaker.png b/src/speaker.png new file mode 100644 index 0000000000000000000000000000000000000000..450986dfc1192751910905c0e587ffca44272bb9 GIT binary patch literal 2549 zcmeHH`#aNpAD?XwV{%ANtq>)1xHm1QoF;OJW%E_IE7P3ic9=sF*)U`b-E#^h)K)@; z6gQKbY0g5$?UaYw)8kYQu^Z1kf5r2|{kpFA=ly!W-=FLHysp>vx!xJBID2VHRY?#C zB<<*6OAzLy{g8kN&$XG{En$L?Z5#m!35ki>3p2tJ7Vh9l27wMr?T3gisB%o$REe_l zh;j?_kBaq)^aI7l#u^0u7D6WZg!>tUMF!kkGFJtGz-(7%z;17EPk8?y{Nup?xdSsv zRS80gpQ8vkH;@Pz0u>b#mw-u1!KDw#$jZqp98y$LR#82SICAuurq=Nj+9!38x_bHs zzn~0HVNM&Hnw>GXvc}q+wY58E@8IZk-q{6r!4*$%1KclO^6*pU36mmWE zx3KU?a#T#*&G=ghiMJ`#1^sH<~PHx`a-?8qRnXxO9fA2+p@w z2||>Qe%Z-@sG{|j=FS-YK*Rmf!*S@Tgja+hwM>o3{ubT-)Pk%LuO5_wL73y_k!S7_h6~0(Sz4Mq zW;;ZV`2A>b!o0)94R}^Ug=_sMZV=3zo{-fQsqnO>-~ffe*Jek%SDe%wGtA`lL}R>M z=}(^Zo>+OA>a{G6ZwgwZYpnd(HD+7Ts8oA9oSJ4sXYS}|vc1u1@#&e(rI!-{!yj@QSR!d8Z zXfC>M9iKj~G^0Fy-tS1>mBe%ybXJXgyezZ=NeZ76cAmrz04A)>=zNwh~Ea`NXlf9&MXQ_&qY!i}! z=d)7Q&6uhn1}a^>Cv>D08e+jbOc8}^c1Oovw5y-h;9BX?DY*qce{?$-D?7+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