BonPrinter v1.2.0
Thermal Printer tool
Loading...
Searching...
No Matches
sound.py
Go to the documentation of this file.
1"""!
2********************************************************************************
3@file sound.py
4@brief Sound module
5********************************************************************************
6"""
7
8import sys
9import logging
10from typing import Optional, TYPE_CHECKING
11
12from Source.version import __title__
13from Source.Util.app_data import S_SOUND_CASH_PATH, S_SOUND_CLEAR_PATH, S_SOUND_UNLOCK_PATH, S_SOUND_TOUCH_PATH, \
14 ICON_SOUND_LIGHT, ICON_SOUND_DARK, ICON_SOUND_MUTE_LIGHT, ICON_SOUND_MUTE_DARK, write_sound_settings
15from Source.Util.gui_toolkit import config_menu, create_sound
16if TYPE_CHECKING:
17 from Source.Controller.main_window import MainWindow
18
19log = logging.getLogger(__title__)
20
21
22class Sound:
23 """!
24 @brief Sounds for actions
25 @param ui : main window object
26 """
27
28 def __init__(self, ui: "MainWindow") -> None:
29 self.ui = ui
30 self.b_sound = False
31 self.c_sound_print = create_sound(S_SOUND_CASH_PATH)
32 self.c_sound_clear = create_sound(S_SOUND_CLEAR_PATH)
33 self.c_sound_unlock = create_sound(S_SOUND_UNLOCK_PATH)
34 self.c_sound_touch = create_sound(S_SOUND_TOUCH_PATH)
35
36 def update_sound_status(self, b_sound: Optional[bool] = None, b_update_settings: bool = True) -> None:
37 """!
38 @brief Update sound status.
39 @param b_sound : [True] sound active; [False] sound muted; [None] toggle actual sound state
40 @param b_update_settings : [True] print sound info at status bar; [False] no output on status bar
41 """
42 if b_sound is None:
43 b_sound = not self.b_sound # toggle sound status if no sound state set
44 if b_update_settings:
45 self.b_sound = b_sound
46 write_sound_settings(self.b_sound)
47 if self.b_sound:
48 s_sound_icon = ICON_SOUND_LIGHT if self.ui.model.c_monitor.is_light_theme() else ICON_SOUND_DARK
49 s_statusbar_text = ["Sound On", "Ton an"]
50 else:
51 s_sound_icon = ICON_SOUND_MUTE_LIGHT if self.ui.model.c_monitor.is_light_theme() else ICON_SOUND_MUTE_DARK
52 s_statusbar_text = ["Sound Off", "Ton aus"]
53 if b_update_settings:
54 self.ui.set_status(s_statusbar_text)
55 config_menu(self.ui.action_sound, icon=s_sound_icon)
Sounds for actions.
Definition sound.py:22
None update_sound_status(self, Optional[bool] b_sound=None, bool b_update_settings=True)
Update sound status.
Definition sound.py:36
None __init__(self, "MainWindow" ui)
Definition sound.py:28