3
3
from PyQt6 .QtCore import Qt
4
4
from PyQt6 .QtWidgets import QMainWindow , QApplication , QProgressBar , QFileDialog
5
5
6
+ from src .log .log import Log
6
7
from src .configuration .config_manager import ConfigManager
7
8
from src .ui .actions import Actions
8
9
from src .ui .menubar import MenuBarManager
@@ -18,7 +19,7 @@ class MainWindow(QMainWindow):
18
19
def __init__ (self ):
19
20
super ().__init__ ()
20
21
#
21
- # First of all, get config manager up and running so we have access to any settings that it manages for us
22
+ # First of all, get config manager up and running so that we have access to any settings that it manages for us
22
23
#
23
24
self ._config_manager = ConfigManager ()
24
25
@@ -46,6 +47,13 @@ def __init__(self):
46
47
self ._actions .set_file_options .triggered .connect (self ._action_set_file_options )
47
48
self ._actions .exit .triggered .connect (self ._action_exit )
48
49
50
+ # Internal variable(s) to communicate from dialogs to main after they are closed
51
+ self ._open_file_dialog_chosen_files = None
52
+
53
+ # Main variables to keep details of current open logs etc.
54
+ self ._log = None
55
+ self ._log_file_names = None
56
+
49
57
# Canvas etc. comments TODO
50
58
51
59
self .canvas = TrackAnalysisCanvas ()
@@ -78,13 +86,20 @@ def make_status_bar_tall_enough_to_contain_progress_bar(self):
78
86
79
87
def _action_open_file (self ):
80
88
dlg = OpenFileDialog (self , self ._please_wait , self ._current_track , self ._config_manager .get_log_directory (), self ._chosen_open_file_callback )
81
- if dlg .exec ():
82
- print ("Success!" )
83
- else :
84
- print ("Cancel!" )
85
-
86
- def _chosen_open_file_callback (self , file_names ):
87
- print ("Will open file(s): " , file_names )
89
+ if not dlg .exec ():
90
+ print ("Cancelled dialog" )
91
+ return
92
+
93
+ self .setWindowTitle (self ._open_file_dialog_chosen_model_title )
94
+ self ._log_file_names = self ._open_file_dialog_chosen_files
95
+ self ._log = Log (self ._config_manager .get_log_directory ())
96
+ self ._log .load_all (self ._log_file_names , self ._please_wait , self ._current_track ,
97
+ self ._config_manager .get_calculate_new_reward (),
98
+ self ._config_manager .get_calculate_alternate_discount_factors ())
99
+
100
+ def _chosen_open_file_callback (self , file_names , model_title ):
101
+ self ._open_file_dialog_chosen_files = file_names
102
+ self ._open_file_dialog_chosen_model_title = model_title
88
103
89
104
def _action_file_info (self ):
90
105
print ("File Info - NOT IMPLEMENTED YET IN VERSION 4" )
0 commit comments