Remember previous volume after muting

#2
This commit is contained in:
Wiktor Zykubek 2023-07-11 17:53:51 +02:00
parent 1a95171bb0
commit 85be796276
No known key found for this signature in database
GPG Key ID: 0DAA9DC01449FCA2

View File

@ -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)