Made volume OSD not restart every time volume is changed

This commit is contained in:
Ignacio Rivero 2025-03-07 19:36:46 -03:00
parent 7b4d251d7e
commit 20597acd64
4 changed files with 17 additions and 22 deletions

Binary file not shown.

View File

@ -48,11 +48,7 @@ def qt_process(to_qt_queue, from_qt_queue):
osd.update_codecs(command['vcodec'], command['acodec'], command['video_res'], command['interlaced'])
# Volume OSD commands
elif command['action'] == 'show_volume_osd':
# Close existing volume OSD if present
if volume_osd is not None:
volume_osd.close_widget()
elif command['action'] == 'show_volume_osd' or command['action'] == 'update_volume_osd':
# Get volume level and mute state
volume_level = command.get('volume_level', 0)
is_muted = command.get('is_muted', False)
@ -60,7 +56,15 @@ def qt_process(to_qt_queue, from_qt_queue):
# If muted, override volume display to 0
display_volume = 0 if is_muted else volume_level
# Create new volume OSD
# Update existing volume OSD if present, otherwise create new one
if volume_osd is not None and volume_osd.isVisible():
volume_osd.update_volume(display_volume)
volume_osd.start_close_timer()
else:
# Create new volume OSD if none exists or if it's not visible
if volume_osd is not None:
volume_osd.close_widget()
volume_osd = VolumeOsdWidget(display_volume)
if is_wayland:
volume_osd.showFullScreen()
@ -69,16 +73,6 @@ def qt_process(to_qt_queue, from_qt_queue):
# Start the close timer
volume_osd.start_close_timer()
elif command['action'] == 'update_volume_osd':
if volume_osd is not None:
volume_level = command.get('volume_level', 0)
is_muted = command.get('is_muted', False)
# If muted, override volume display to 0
display_volume = 0 if is_muted else volume_level
volume_osd.update_volume(display_volume)
volume_osd.start_close_timer()
elif command['action'] == 'close_volume_osd':
if volume_osd is not None:
volume_osd.close_widget()

View File

@ -168,6 +168,7 @@ class VolumeControl:
# Update OSD if queue is available
if self.to_qt_queue is not None:
# Always use 'show_volume_osd' action to ensure the OSD appears
self.to_qt_queue.put({
'action': 'show_volume_osd',
'volume_level': new_volume,