Fix PyQt5 compatibility
This commit is contained in:
parent
1d4e34d9e0
commit
ed87c797ba
3 changed files with 15 additions and 15 deletions
12
irc.py
12
irc.py
|
@ -550,10 +550,14 @@ class PesterIRC(QtCore.QThread):
|
||||||
mood = Mood(0)
|
mood = Mood(0)
|
||||||
self.moodUpdated.emit(nick, mood)
|
self.moodUpdated.emit(nick, mood)
|
||||||
elif key.casefold() == "color":
|
elif key.casefold() == "color":
|
||||||
if QtGui.QColor.isValidColorName(value):
|
try:
|
||||||
color = QtGui.QColor.fromString(value)
|
if QtGui.QColor.isValidColorName(value):
|
||||||
else:
|
color = QtGui.QColor.fromString(value)
|
||||||
color = QtGui.QColor(0, 0, 0)
|
else:
|
||||||
|
color = QtGui.QColor(0, 0, 0)
|
||||||
|
except AttributeError:
|
||||||
|
# PyQt5?
|
||||||
|
color = QtGui.QColor(value)
|
||||||
self.colorUpdated.emit(nick, color)
|
self.colorUpdated.emit(nick, color)
|
||||||
|
|
||||||
def _tagmsg(self, prefix, tags, *args):
|
def _tagmsg(self, prefix, tags, *args):
|
||||||
|
|
|
@ -2403,16 +2403,14 @@ class PesterWindow(MovingWindow):
|
||||||
|
|
||||||
# Use the class we chose to build the sound set.
|
# Use the class we chose to build the sound set.
|
||||||
try:
|
try:
|
||||||
if "pygame" in sys.modules:
|
if "pygame" in globals():
|
||||||
if soundclass == pygame.mixer.Sound:
|
if soundclass == pygame.mixer.Sound:
|
||||||
self.alarm = soundclass(self.theme["main/sounds/alertsound"])
|
self.alarm = soundclass(self.theme["main/sounds/alertsound"])
|
||||||
self.memosound = soundclass(self.theme["main/sounds/memosound"])
|
self.memosound = soundclass(self.theme["main/sounds/memosound"])
|
||||||
self.namesound = soundclass("themes/namealarm.wav")
|
self.namesound = soundclass("themes/namealarm.wav")
|
||||||
self.ceasesound = soundclass(self.theme["main/sounds/ceasesound"])
|
self.ceasesound = soundclass(self.theme["main/sounds/ceasesound"])
|
||||||
self.honksound = soundclass("themes/honk.wav")
|
self.honksound = soundclass("themes/honk.wav")
|
||||||
if ("PyQt6.QtMultimedia" in sys.modules) or (
|
if "QtMultimedia" in globals():
|
||||||
"PyQt5.QtMultimedia" in sys.modules
|
|
||||||
):
|
|
||||||
if soundclass == QtMultimedia.QSoundEffect:
|
if soundclass == QtMultimedia.QSoundEffect:
|
||||||
self.alarm = soundclass()
|
self.alarm = soundclass()
|
||||||
self.memosound = soundclass()
|
self.memosound = soundclass()
|
||||||
|
@ -2459,12 +2457,10 @@ class PesterWindow(MovingWindow):
|
||||||
vol = vol_percent / 100.0
|
vol = vol_percent / 100.0
|
||||||
for sound in self.sounds:
|
for sound in self.sounds:
|
||||||
try:
|
try:
|
||||||
if "pygame" in sys.modules:
|
if "pygame" in globals():
|
||||||
if self.sound_type == pygame.mixer.Sound:
|
if self.sound_type == pygame.mixer.Sound:
|
||||||
sound.set_volume(vol)
|
sound.set_volume(vol)
|
||||||
if ("PyQt6.QtMultimedia" in sys.modules) or (
|
if "QtMultimedia" in globals():
|
||||||
"PyQt5.QtMultimedia" in sys.modules
|
|
||||||
):
|
|
||||||
if self.sound_type == QtMultimedia.QSoundEffect:
|
if self.sound_type == QtMultimedia.QSoundEffect:
|
||||||
sound.setVolume(vol)
|
sound.setVolume(vol)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -4325,11 +4321,11 @@ class MainProgram(QtCore.QObject):
|
||||||
msgbox.exec()
|
msgbox.exec()
|
||||||
|
|
||||||
# If we're using pygame for sound we need to init
|
# If we're using pygame for sound we need to init
|
||||||
if "pygame" in sys.modules:
|
if "pygame" in globals():
|
||||||
# we could set the frequency higher but i love how cheesy it sounds
|
# we could set the frequency higher but i love how cheesy it sounds
|
||||||
try:
|
try:
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
except (pygame.error, Exception) as err:
|
except Exception as err:
|
||||||
print("Warning: No sound! (pygame error: %s)" % err)
|
print("Warning: No sound! (pygame error: %s)" % err)
|
||||||
|
|
||||||
self.widget = PesterWindow(options, parent=self, app=self.app)
|
self.widget = PesterWindow(options, parent=self, app=self.app)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def get_ssl_context():
|
||||||
the system provided ones, instead relying on a bundle installed with the
|
the system provided ones, instead relying on a bundle installed with the
|
||||||
python installer."""
|
python installer."""
|
||||||
default_context = ssl.create_default_context()
|
default_context = ssl.create_default_context()
|
||||||
if "certifi" not in sys.modules:
|
if "certifi" not in globals():
|
||||||
return default_context
|
return default_context
|
||||||
|
|
||||||
# Get age of certifi module
|
# Get age of certifi module
|
||||||
|
|
Loading…
Reference in a new issue