osd attached to triggering module position, per-screen filtering
This commit is contained in:
parent
85a1260a35
commit
66dc628752
4 changed files with 19 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "." as M
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ M.BarSection {
|
|||
|
||||
property int percent: 0
|
||||
onPercentChanged: if (percent > 0)
|
||||
M.OsdState.show(percent / 100, "\uF185")
|
||||
M.OsdState.show(percent / 100, "\uF185", root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0), QsWindow.window?.screen ?? null)
|
||||
|
||||
Process {
|
||||
id: adjProc
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ PanelWindow {
|
|||
color: "transparent"
|
||||
|
||||
property bool _winVisible: false
|
||||
property bool _shown: M.OsdState.visible
|
||||
property bool _shown: M.OsdState.visible && M.OsdState.screen === root.screen
|
||||
|
||||
on_ShownChanged: {
|
||||
if (_shown) {
|
||||
|
|
@ -35,7 +35,10 @@ PanelWindow {
|
|||
anchors.left: true
|
||||
|
||||
margins.top: 0
|
||||
margins.left: Math.round((screen.width - implicitWidth) / 2)
|
||||
margins.left: Math.max(0, Math.min(
|
||||
Math.round(M.OsdState.itemX - implicitWidth / 2),
|
||||
screen.width - implicitWidth
|
||||
))
|
||||
|
||||
implicitWidth: 200
|
||||
implicitHeight: 48
|
||||
|
|
|
|||
|
|
@ -5,15 +5,19 @@ QtObject {
|
|||
property bool visible: false
|
||||
property real value: 0 // 0.0–1.0
|
||||
property string icon: ""
|
||||
property real itemX: 0
|
||||
property var screen: null
|
||||
|
||||
property Timer _timer: Timer {
|
||||
interval: 1500
|
||||
onTriggered: visible = false
|
||||
}
|
||||
|
||||
function show(val, ico) {
|
||||
function show(val, ico, x, scr) {
|
||||
value = val;
|
||||
icon = ico;
|
||||
itemX = x;
|
||||
screen = scr;
|
||||
visible = true;
|
||||
_timer.restart();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Pipewire
|
||||
import "." as M
|
||||
|
||||
|
|
@ -15,8 +16,12 @@ M.BarSection {
|
|||
readonly property real volume: sink?.audio?.volume ?? 0
|
||||
readonly property bool muted: sink?.audio?.muted ?? false
|
||||
|
||||
onVolumeChanged: M.OsdState.show(volume, root.muted ? "\uF026" : (volume > 0.5 ? "\uF028" : "\uF027"))
|
||||
onMutedChanged: M.OsdState.show(volume, root.muted ? "\uF026" : (volume > 0.5 ? "\uF028" : "\uF027"))
|
||||
function _showOsd() {
|
||||
const ico = root.muted ? "\uF026" : (volume > 0.5 ? "\uF028" : "\uF027");
|
||||
M.OsdState.show(volume, ico, root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0), QsWindow.window?.screen ?? null);
|
||||
}
|
||||
onVolumeChanged: _showOsd()
|
||||
onMutedChanged: _showOsd()
|
||||
|
||||
M.BarIcon {
|
||||
icon: root.muted ? "\uF026" : (root.volume > 0.5 ? "\uF028" : (root.volume > 0 ? "\uF027" : "\uF026"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue