1818
1919
2020class QtApp :
21- """Qt application process"""
21+ """Qt application process
22+
23+ Attributes
24+ dota_notes: link to the main object of the application
25+ app: QT app
26+ window: QT Main window of the application
27+ last_selected_index: index of the last selected player
28+ last_selected_player: data of the last selected player
29+ """
2230
2331 def __init__ (self , dota_notes ):
2432 self .dota_notes = dota_notes
2533
2634 # Build Qt app components
2735 self .app = QApplication (sys .argv )
2836 self .window = MainWindow ()
29- self .lastSelectedIndex = 0
30- self .lastSelectedState = None
37+ self .last_selected_index = 0
38+ self .last_selected_player = None
3139
3240 # Connect actions
3341 self .window .actionSettings .triggered .connect (self .on_open_settings )
@@ -60,6 +68,7 @@ def __init__(self, dota_notes):
6068 self .window .show ()
6169
6270 def run (self ):
71+ """Start the QT application, enter the event loop and add a periodic dequeue of messages"""
6372 timer = QTimer ()
6473 timer .timeout .connect (self .process_queues )
6574 timer .start (100 )
@@ -68,6 +77,7 @@ def run(self):
6877 return return_code
6978
7079 def process_queues (self ):
80+ """Periodic process that checks message queues and process necessary jobs"""
7181 while not self .dota_notes .message_queue_qt .empty ():
7282 message = self .dota_notes .message_queue_qt .get (block = False )
7383 if isinstance (message , MessageGSI ):
@@ -90,6 +100,7 @@ def process_queues(self):
90100 self .window .draw_status_message ("No game found for player " + self .window .inputSteamId .text ())
91101
92102 def on_open_settings (self ):
103+ """User opens the settings panel"""
93104 settings = self .dota_notes .settings
94105 self .window .comboBoxSettingsMode .setCurrentText (settings .software_mode )
95106 self .window .lineEditStratzToken .setText (settings .stratz_token )
@@ -99,6 +110,7 @@ def on_open_settings(self):
99110 self .window .centralStackedWidget .setCurrentIndex (1 )
100111
101112 def on_settings_save (self ):
113+ """User saves settings modifications"""
102114 settings = self .dota_notes .settings
103115 settings .software_mode = self .window .comboBoxSettingsMode .currentText ()
104116 settings .stratz_token = self .window .lineEditStratzToken .text ()
@@ -111,30 +123,36 @@ def on_settings_save(self):
111123 self .window .centralStackedWidget .setCurrentIndex (0 )
112124
113125 def on_settings_cancel (self ):
126+ """User cancels settings modifications"""
114127 self .window .centralStackedWidget .setCurrentIndex (0 )
115128
116129 def on_connect_client (self ):
130+ """User clicks on connect button"""
117131 self .window .buttonConnect .setVisible (False )
118132 message = MessageConnect (self .dota_notes .settings .steam_user , self .dota_notes .settings .steam_password )
119133 self .dota_notes .message_queue_dota .put (message )
120134
121135 def on_disconnect_client (self ):
136+ """User clicks on disconnect button"""
122137 message = MessageDisconnect ()
123138 self .dota_notes .message_queue_dota .put (message )
124139
125140 def on_label_click (self , label_name , label_text ):
141+ """User clicks on a specific label"""
126142 row = 0
127143 for char in label_name :
128144 if char .isdigit ():
129145 row = int (char )
130146 self .on_select_player (row )
131147
132148 def on_select_player (self , player_slot ):
133- self .lastSelectedIndex = player_slot
134- self .lastSelectedState = self .dota_notes .state .players [player_slot ]
135- self .window .draw_details_with_player (self .lastSelectedState )
149+ """User select a player to have info off"""
150+ self .last_selected_index = player_slot
151+ self .last_selected_player = self .dota_notes .state .players [player_slot ]
152+ self .window .draw_details_with_player (self .last_selected_player )
136153
137154 def on_steam_live (self ):
155+ """Look for a live game a player is in"""
138156 steam_id = self .window .inputSteamId .text ()
139157 if self .is_valid_search (steam_id ):
140158 steam_id = SteamID (steam_id )
@@ -204,13 +222,14 @@ def on_stratz_info(self):
204222 if json is not None :
205223 self .dota_notes .state .enrich_players_with_stratz_info (json )
206224 self .window .draw_match_with_state (self .dota_notes .state )
207- self .on_select_player (self .lastSelectedIndex )
225+ self .on_select_player (self .last_selected_index )
208226 self .window .draw_status_message ("Updated player with Stratz info." )
209227 else :
210228 self .window .draw_status_message ("Error while fetching player info from Stratz." )
211229
212230 def on_save_player_details (self ):
213- player_state = self .lastSelectedState
231+ """User press 'save' on the player detail page"""
232+ player_state = self .last_selected_player
214233 player_state .custom_name = self .window .inputDetailsCustomName .text ()
215234 player_state .smurf = self .window .comboBoxDetailsSmurf .currentText ()
216235 player_state .is_racist = self .window .checkBoxDetailsRacist .isChecked ()
@@ -220,7 +239,7 @@ def on_save_player_details(self):
220239 player_state .gives_up = self .window .checkBoxDetailsGivesUp .isChecked ()
221240 player_state .destroys_items = self .window .checkBoxDetailsDestroysItems .isChecked ()
222241 player_state .note = self .window .inputDetailsNote .toPlainText ()
223- self .window .draw_match_player (self .lastSelectedIndex , player_state )
242+ self .window .draw_match_player (self .last_selected_index , player_state )
224243 with Session (self .dota_notes .database .engine ) as session :
225244 player_info = session .get (PlayerEntity , str (player_state .steam_id ))
226245 if player_info is None :
0 commit comments