32
32
from src .core .project_creation_dialog import ProjectCreationDialog
33
33
from src .core .project_opening_dialog import ProjectOpeningDialog
34
34
35
+ # Logger
36
+ from src .utils .logger_utility import logger
37
+
35
38
36
39
class Main (QWidget ):
37
40
"""Main class for the application"""
38
41
39
42
styleSheetUpdated = Signal (str )
40
43
videoEditorOpened = Signal (str )
41
44
45
+ @logger .catch
42
46
def __init__ (self , parent = None ):
43
47
"""Initializer"""
44
48
super ().__init__ (parent )
45
49
self .customStyleSheet = ""
46
50
self .settings = load_settings ()
47
51
self .themes = load_themes ()
48
52
self .current_theme = load_current_theme ()
49
-
53
+ logger . info ( "Main window initialized" )
50
54
self .load_ui ()
51
55
56
+ @logger .catch
52
57
def apply_stylesheet (self ):
53
58
"""Apply the stylesheet to the main window and update the image based on the theme"""
54
59
@@ -68,7 +73,9 @@ def apply_stylesheet(self):
68
73
self .ui .label .setPixmap (QPixmap (image_path ))
69
74
70
75
self .styleSheetUpdated .emit (self .customStyleSheet )
76
+ logger .info ("Stylesheet applied" )
71
77
78
+ @logger .catch
72
79
def load_ui (self ):
73
80
"""Load the UI from the .ui file"""
74
81
loader = QUiLoader ()
@@ -86,6 +93,9 @@ def load_ui(self):
86
93
self .ui .newProjectBtn .clicked .connect (self .showProjectCreationDialog )
87
94
self .ui .openProjectBtn .clicked .connect (self .showProjectOpenDialog )
88
95
96
+ logger .info ("UI loaded" )
97
+
98
+ @logger .catch
89
99
def open_settings_dialog (self ):
90
100
"""Open the settings dialog"""
91
101
self .settingsDialog = QDialog ()
@@ -124,6 +134,7 @@ def open_settings_dialog(self):
124
134
125
135
self .settingsDialog .exec ()
126
136
137
+ @logger .catch
127
138
def update_settings_from_dialog (self ):
128
139
"""Update the settings from the dialog, and update the UI"""
129
140
@@ -159,6 +170,7 @@ def update_settings_from_dialog(self):
159
170
# Apply the stylesheet
160
171
self .apply_stylesheet ()
161
172
173
+ @logger .catch
162
174
def showProjectCreationDialog (self ):
163
175
"""Show the project creation dialog"""
164
176
try :
@@ -176,8 +188,9 @@ def showProjectCreationDialog(self):
176
188
if dialog .exec ():
177
189
pass
178
190
except Exception as e :
179
- print (f"Error showing project creation dialog: { e } " )
191
+ logger . error (f"Error showing project creation dialog: { e } " )
180
192
193
+ @logger .catch
181
194
def showProjectOpenDialog (self ):
182
195
"""Show the project open dialog"""
183
196
try :
@@ -191,8 +204,9 @@ def showProjectOpenDialog(self):
191
204
) # Close the main window (WelcomeScreen) as well
192
205
dialog .exec ()
193
206
except Exception as e :
194
- print (f"Error showing project open dialog: { e } " )
207
+ logger . error (f"Error showing project open dialog: { e } " )
195
208
209
+ @logger .catch
196
210
def openVideoEditor (self , projectFilePath ):
197
211
"""Open the video editor with the project file"""
198
212
try :
@@ -206,10 +220,9 @@ def openVideoEditor(self, projectFilePath):
206
220
207
221
# Emit the signal after VideoEditor dialog is opened
208
222
self .videoEditorOpened .emit (projectFilePath )
209
-
210
223
self .videoEditor .exec ()
211
224
except Exception as e :
212
- print (f"Error opening video editor: { e } " )
225
+ logger . error (f"Error opening video editor: { e } " )
213
226
pass
214
227
215
228
0 commit comments