From 85be79627618bedad9168d27dcbd3223b51a31a1 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Tue, 11 Jul 2023 17:53:51 +0200 Subject: [PATCH] Remember previous volume after muting #2 --- openfm_qt/mainwindow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openfm_qt/mainwindow.py b/openfm_qt/mainwindow.py index e655b51..741d3f4 100644 --- a/openfm_qt/mainwindow.py +++ b/openfm_qt/mainwindow.py @@ -80,10 +80,11 @@ class MainWindow(QMainWindow): def toggleMute(self) -> None: """Toggle playback volume between 0 and DEFAULT_VOLUME.""" if self.ui.volumeHorizontalSlider.value() == 0: - self.ui.volumeHorizontalSlider.setValue(DEFAULT_VOLUME) + self.ui.volumeHorizontalSlider.setValue(self.previous_volume) icon = self.style().standardIcon(QStyle.SP_MediaVolume) - self.setVolume(DEFAULT_VOLUME) + self.setVolume(self.previous_volume) else: + self.previous_volume = self.__audio.volume() * 100 self.ui.volumeHorizontalSlider.setValue(0) icon = self.style().standardIcon(QStyle.SP_MediaVolumeMuted) self.setVolume(0)