extract OsdSection base component from Volume and Backlight modules
This commit is contained in:
parent
e50dd155fa
commit
2ec24e3075
4 changed files with 33 additions and 34 deletions
|
|
@ -4,17 +4,15 @@ import "." as M
|
||||||
import "../services" as S
|
import "../services" as S
|
||||||
import "../applets" as C
|
import "../applets" as C
|
||||||
|
|
||||||
M.BarSection {
|
M.OsdSection {
|
||||||
id: root
|
id: root
|
||||||
spacing: S.Theme.moduleSpacing
|
spacing: S.Theme.moduleSpacing
|
||||||
opacity: S.Modules.backlight.enable && S.BacklightService.available ? 1 : 0
|
opacity: S.Modules.backlight.enable && S.BacklightService.available ? 1 : 0
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
tooltip: ""
|
_panelHovered: hoverPanel.panelHovered
|
||||||
|
|
||||||
property int percent: S.BacklightService.percent
|
property int percent: S.BacklightService.percent
|
||||||
property bool _osdActive: false
|
|
||||||
property bool _percentInit: false
|
property bool _percentInit: false
|
||||||
readonly property bool _showPanel: root._hovered || hoverPanel.panelHovered || _osdActive
|
|
||||||
|
|
||||||
onPercentChanged: {
|
onPercentChanged: {
|
||||||
if (!_percentInit) {
|
if (!_percentInit) {
|
||||||
|
|
@ -22,18 +20,7 @@ M.BarSection {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (percent > 0)
|
if (percent > 0)
|
||||||
_flashPanel();
|
flashPanel();
|
||||||
}
|
|
||||||
|
|
||||||
function _flashPanel() {
|
|
||||||
_osdActive = true;
|
|
||||||
_osdTimer.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: _osdTimer
|
|
||||||
interval: 1500
|
|
||||||
onTriggered: root._osdActive = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WheelHandler {
|
WheelHandler {
|
||||||
|
|
|
||||||
25
shell/modules/OsdSection.qml
Normal file
25
shell/modules/OsdSection.qml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
// Base component for bar modules with OSD flash behavior (Volume, Backlight).
|
||||||
|
// Panel shows on hover or when flashPanel() is called, auto-dismisses after 1.5s.
|
||||||
|
// Modules bind _panelHovered to their HoverPanel's panelHovered property.
|
||||||
|
BarSection {
|
||||||
|
id: root
|
||||||
|
tooltip: ""
|
||||||
|
|
||||||
|
property bool _panelHovered: false
|
||||||
|
property bool _osdActive: false
|
||||||
|
readonly property bool _anyHover: root._hovered || _panelHovered
|
||||||
|
readonly property bool _showPanel: _anyHover || _osdActive
|
||||||
|
|
||||||
|
function flashPanel() {
|
||||||
|
_osdActive = true;
|
||||||
|
_osdTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: _osdTimer
|
||||||
|
interval: 1500
|
||||||
|
onTriggered: root._osdActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,10 +5,10 @@ import "." as M
|
||||||
import "../services" as S
|
import "../services" as S
|
||||||
import "../applets" as C
|
import "../applets" as C
|
||||||
|
|
||||||
M.BarSection {
|
M.OsdSection {
|
||||||
id: root
|
id: root
|
||||||
spacing: S.Theme.moduleSpacing
|
spacing: S.Theme.moduleSpacing
|
||||||
tooltip: ""
|
_panelHovered: hoverPanel.panelHovered
|
||||||
|
|
||||||
PwObjectTracker {
|
PwObjectTracker {
|
||||||
objects: [Pipewire.defaultAudioSink, ...root._streamList]
|
objects: [Pipewire.defaultAudioSink, ...root._streamList]
|
||||||
|
|
@ -40,36 +40,22 @@ M.BarSection {
|
||||||
return streams;
|
return streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool _osdActive: false
|
|
||||||
property bool _volumeInit: false
|
property bool _volumeInit: false
|
||||||
property bool _mutedInit: false
|
property bool _mutedInit: false
|
||||||
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
|
|
||||||
readonly property bool _showPanel: _anyHover || _osdActive
|
|
||||||
|
|
||||||
onVolumeChanged: {
|
onVolumeChanged: {
|
||||||
if (!_volumeInit) {
|
if (!_volumeInit) {
|
||||||
_volumeInit = true;
|
_volumeInit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_flashPanel();
|
flashPanel();
|
||||||
}
|
}
|
||||||
onMutedChanged: {
|
onMutedChanged: {
|
||||||
if (!_mutedInit) {
|
if (!_mutedInit) {
|
||||||
_mutedInit = true;
|
_mutedInit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_flashPanel();
|
flashPanel();
|
||||||
}
|
|
||||||
|
|
||||||
function _flashPanel() {
|
|
||||||
_osdActive = true;
|
|
||||||
_osdTimer.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: _osdTimer
|
|
||||||
interval: 1500
|
|
||||||
onTriggered: root._osdActive = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
M.BarIcon {
|
M.BarIcon {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ NetworkModule 1.0 NetworkModule.qml
|
||||||
NotifCard 1.0 NotifCard.qml
|
NotifCard 1.0 NotifCard.qml
|
||||||
NotifPopup 1.0 NotifPopup.qml
|
NotifPopup 1.0 NotifPopup.qml
|
||||||
NotificationsModule 1.0 NotificationsModule.qml
|
NotificationsModule 1.0 NotificationsModule.qml
|
||||||
|
OsdSection 1.0 OsdSection.qml
|
||||||
OverviewBackdrop 1.0 OverviewBackdrop.qml
|
OverviewBackdrop 1.0 OverviewBackdrop.qml
|
||||||
PinnableSection 1.0 PinnableSection.qml
|
PinnableSection 1.0 PinnableSection.qml
|
||||||
PopupBackground 1.0 PopupBackground.qml
|
PopupBackground 1.0 PopupBackground.qml
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue