Preferences, singletons
Create a Preference dialog for fonts and audio output devices Turn Preferences and SoundOff into singletons. No matter how many times you request a new one, the same instance is returned. Stop using singals on the parent() to access other instances, such as sound and Preferences.
This commit is contained in:
@@ -11,6 +11,13 @@ from PyQt6.QtMultimedia import (
|
||||
|
||||
|
||||
class SoundOff(QObject):
|
||||
_instance = None
|
||||
def __new__(cls):
|
||||
if cls._instance:
|
||||
return cls._instance
|
||||
cls._instance = super(SoundOff, cls).__new__(cls)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#
|
||||
@@ -95,7 +102,6 @@ class SoundOff(QObject):
|
||||
self.localPlayer.play()
|
||||
if not self.virtualDevice:
|
||||
return
|
||||
return
|
||||
self.virtualPlayer.setSource(src)
|
||||
self.virtualPlayer.setPosition(0)
|
||||
if not self.virtualPlayer.audioOutput():
|
||||
|
||||
Reference in New Issue
Block a user