2********************************************************************************
4@brief Application data storage model
5********************************************************************************
10from typing
import Optional, TYPE_CHECKING
14from Source.Util.app_data import S_DEFAULT_OUTPUT_PATH, write_output_path_settings, read_last_dir, write_last_dir, \
15 read_show_price_settings, write_show_price_settings, read_print_report_settings, write_print_report_settings, \
16 read_output_path_settings
31log = logging.getLogger(__title__)
33S_WRITE_TEST_FILE_NAME =
"_write_test.txt"
38 @brief Holds the data of the application
39 @param ui : main window object
40 @param log_config : log configuration of the application
43 def __init__(self, ui:
"MainWindow", log_config: LogConfig) ->
None:
69 @brief Update report enable status.
70 @param b_enable_report : [True] enable print report; [False] disable print report; [None] toggle print report
72 if b_enable_report
is None:
77 s_statusbar_text = [
"Enable Print Report",
"Druckbericht aktiviert"]
79 s_statusbar_text = [
"Disable Print Report",
"Druckbericht deaktiviert"]
80 self.
ui.set_status(s_statusbar_text)
81 self.
ui.update_screen()
85 @brief Update Show price status.
86 @param b_show_price : [True] show price below article name; [False] show not; [None] toggle actual setting
88 if b_show_price
is None:
93 s_statusbar_text = [
"Show Price",
"Preis anzeigen"]
95 s_statusbar_text = [
"Hide Price",
"Preis verbergen"]
96 self.
ui.set_status(s_statusbar_text)
97 self.
ui.update_screen()
101 @brief Update output path
102 @param s_output_path : new output path to set
104 if not os.path.exists(s_output_path):
105 self.
ui.set_status([f
"Path not exist: {s_output_path}",
106 f
"Pfad existiert nicht: {s_output_path}"],
True)
107 if not os.path.exists(S_DEFAULT_OUTPUT_PATH):
108 log.debug(
"Create default output folder")
109 os.mkdir(S_DEFAULT_OUTPUT_PATH)
110 s_output_path = S_DEFAULT_OUTPUT_PATH
113 s_test_file = s_output_path +
"/" + S_WRITE_TEST_FILE_NAME
114 with open(s_test_file, mode=
"w", encoding=
"utf-8")
as file:
115 file.write(
"Write Access Test")
116 os.remove(s_test_file)
117 except BaseException:
125 self.
ui.set_status([f
"Output path changed to: {s_output_path}",
126 f
"Ausgangsverzeichnis geƤndert zu: {s_output_path}"])
128 self.
ui.set_status([f
"No Write access to path: {s_output_path}",
129 f
"Kein Schreibzugriff auf das Verzeichnis: {s_output_path}"],
True)
133 @brief Get last path to open dialog
146 @brief Set last path and save in persistent storage
147 @param path : path to set as last path
Class Authentication: Part of the module to hold the data of the current authentication session.
Class Calculator: Hold actual data to calculate.
Class Configuration: Read/Write configuration data (user or articles)
Holds the data of the application.
None update_enable_report_status(self, Optional[bool] b_enable_report=None)
Update report enable status.
None update_output_path(self, str s_output_path)
Update output path.
None update_show_price_status(self, Optional[bool] b_show_price=None)
Update Show price status.
None __init__(self, "MainWindow" ui, LogConfig log_config)
monitor.MonitorScale c_monitor
None set_last_path(self, str path)
Set last path and save in persistent storage.
str|None get_last_path(self)
Get last path to open dialog.
printer.Printer c_printer
language.Language c_language
Class to scale text and item positions.
Report class to log and create sales articles.
Class create bons and printout.