Skip to content

Commit

Permalink
universal2 binary for macOS (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
DasAmpharos authored May 16, 2024
1 parent cbb8c44 commit dc014b0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
2 changes: 0 additions & 2 deletions EonTimer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
import os
import platform
import signal
import sys
Expand Down Expand Up @@ -41,5 +40,4 @@ def main() -> int:

if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = 'hide'
sys.exit(main())
2 changes: 1 addition & 1 deletion EonTimer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exe = EXE(
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
target_arch='universal2',
codesign_identity=None,
entitlements_file=None,
icon='eon_timer/resources/icon-512.png'
Expand Down
24 changes: 13 additions & 11 deletions eon_timer/action/sound_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

import pygame.mixer
from PySide6.QtCore import QUrl
from PySide6.QtMultimedia import QSoundEffect

from eon_timer import resources
from eon_timer.settings.action.model import ActionSound
Expand All @@ -10,25 +11,26 @@
@component()
class SoundManager:
def __init__(self):
def predefined_sound(filename: str) -> pygame.mixer.Sound:
def predefined_sound(filename: str) -> QSoundEffect:
sound = QSoundEffect()
filepath = resources.get_filepath(f'sounds/{filename}')
return pygame.mixer.Sound(filepath)
url = QUrl.fromLocalFile(filepath)
sound.setSource(url)
return sound

pygame.mixer.init()
self.__sounds = {
ActionSound.BEEP: predefined_sound('beep.wav'),
ActionSound.DING: predefined_sound('ding.wav'),
ActionSound.POP: predefined_sound('pop.wav'),
ActionSound.TICK: predefined_sound('tick.wav'),
}

def get_sound(self, action_sound: ActionSound) -> Optional[pygame.mixer.Sound]:
def get_sound(self, action_sound: ActionSound) -> Optional[QSoundEffect]:
return self.__sounds.get(action_sound, None)

def set_custom_sound(self, filepath: str) -> bool:
try:
sound = pygame.mixer.Sound(filepath)
self.__sounds[ActionSound.CUSTOM] = sound
return True
except pygame.error:
return False
sound = QSoundEffect()
self.__sounds[ActionSound.CUSTOM] = sound
url = QUrl.fromLocalFile(filepath)
sound.setSource(url)
return True
12 changes: 1 addition & 11 deletions eon_timer/settings/action/widget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import functools
from typing import Final

import pygame
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtWidgets import QColorDialog, QPushButton, QSpinBox
Expand Down Expand Up @@ -58,8 +57,7 @@ def __init_components(self) -> None:
bindings.bind_enum_combobox(field, self.sound)
# ----- custom_sound -----
field = FileSelectorWidget(title='Select Sound',
filter='Sound Files (*.wav *.mp3)',
validator=self.__is_valid_sound)
filter='Sound Files (*.wav *.mp3)')
self.add_field(self.Field.CUSTOM_SOUND, field,
visible=self.sound.get() == ActionSound.CUSTOM,
name='actionSettingsCustomSound')
Expand Down Expand Up @@ -96,14 +94,6 @@ def __set_icon_color(self, button: QPushButton) -> None:
pixmap.fill(self.color.get())
button.setIcon(QIcon(pixmap))

@staticmethod
def __is_valid_sound(filepath: str) -> bool:
try:
pygame.mixer.Sound(filepath)
return True
except pygame.error:
return False

def on_accepted(self):
self.model.mode.update(self.mode)
self.model.sound.update(self.sound)
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
altgraph==0.17.4
certifi==2024.2.2
charset-normalizer==3.3.2
charset-normalizer @ git+https://github.com/Ousret/charset_normalizer.git@79dce4857914fead2ffe55eb787cad6d5cf14643
idna==3.7
libsass==0.23.0
libsass @ git+https://github.com/sass/libsass-python.git@af3c4bf4ab0b852447fc2b2f46001e499c615011
macholib==1.16.3
packaging==24.0
pillow==10.3.0
pip-autoremove==0.10.0
pipdeptree==2.20.0
platformdirs==4.2.1
pygame==2.5.2
pyinstaller==6.6.0
pyinstaller-hooks-contrib==2024.6
PySide6==6.7.0
Expand Down

0 comments on commit dc014b0

Please sign in to comment.