|
@@ -25,7 +25,8 @@ from PySide2.QtWidgets import (
|
25
|
25
|
QWidget,
|
26
|
26
|
)
|
27
|
27
|
from PySide2.QtGui import QIcon
|
28
|
|
-from PySide2.QtCore import QObject, QSize, Qt, Signal, Slot
|
|
28
|
+from PySide2.QtMultimedia import QSoundEffect
|
|
29
|
+from PySide2.QtCore import QObject, QSize, Qt, Signal, Slot, QUrl
|
29
|
30
|
|
30
|
31
|
# pylint: enable=E0611
|
31
|
32
|
|
|
@@ -34,7 +35,6 @@ try:
|
34
|
35
|
except ImportError:
|
35
|
36
|
dbus = None
|
36
|
37
|
|
37
|
|
-from piket_client.sound import PLOP_WAVE, UNDO_WAVE
|
38
|
38
|
from piket_client.model import (
|
39
|
39
|
Person,
|
40
|
40
|
ConsumptionType,
|
|
@@ -46,10 +46,8 @@ import piket_client.logger
|
46
|
46
|
|
47
|
47
|
LOG = logging.getLogger(__name__)
|
48
|
48
|
|
49
|
|
-
|
50
|
|
-def plop() -> None:
|
51
|
|
- """ Asynchronously play the plop sound. """
|
52
|
|
- PLOP_WAVE.play()
|
|
49
|
+PLOP_WAVE = QSoundEffect()
|
|
50
|
+UNDO_WAVE = QSoundEffect()
|
53
|
51
|
|
54
|
52
|
|
55
|
53
|
class NameButton(QPushButton):
|
|
@@ -97,7 +95,7 @@ class NameButton(QPushButton):
|
97
|
95
|
LOG.debug("Button clicked.")
|
98
|
96
|
result = self.person.add_consumption(self.active_id)
|
99
|
97
|
if result:
|
100
|
|
- plop()
|
|
98
|
+ PLOP_WAVE.play()
|
101
|
99
|
self.setText(self.current_label)
|
102
|
100
|
self.consumption_created.emit(result)
|
103
|
101
|
else:
|
|
@@ -423,6 +421,12 @@ def main() -> None:
|
423
|
421
|
# Set dark theme
|
424
|
422
|
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside2())
|
425
|
423
|
|
|
424
|
+ # Load sounds
|
|
425
|
+ global PLOP_WAVE, UNDO_WAVE
|
|
426
|
+ sounds_dir = os.path.join(os.path.dirname(__file__), "sounds")
|
|
427
|
+ PLOP_WAVE.setSource(QUrl.fromLocalFile(os.path.join(sounds_dir, "plop.wav")))
|
|
428
|
+ UNDO_WAVE.setSource(QUrl.fromLocalFile(os.path.join(sounds_dir, "undo.wav")))
|
|
429
|
+
|
426
|
430
|
# Enlarge font size
|
427
|
431
|
font = app.font()
|
428
|
432
|
size = font.pointSize()
|