1616import gc
1717
1818# PySide6 Gui Imports
19- from PySide6 .QtGui import QFont , Qt
20- from PySide6 .QtCore import QObject , Signal , QThreadPool , QSize
19+ from PySide6 .QtGui import Qt
20+ from PySide6 .QtCore import QObject , Signal , QThreadPool
2121from PySide6 .QtWidgets import (
22- QMainWindow , QFileDialog , QListWidget , QLabel , QPushButton , QWidget , QGridLayout , QHBoxLayout , QScrollArea ,
22+ QMainWindow , QFileDialog , QListWidget , QLabel , QWidget , QGridLayout , QHBoxLayout , QScrollArea ,
2323 QSpacerItem , QSizePolicy )
2424
2525# Projects Libraries
3232
3333# The window
3434class CompareUi :
35- def __init__ (self , path_of_first_search , cache_file , parent ):
35+ def __init__ (self , path_of_first_search , cache_file , to_be_marked_files , parent ):
3636 # Debug
3737 logging .info ("Setting up the Compare_Window" )
3838 # Saving time
@@ -76,8 +76,9 @@ def __init__(self, path_of_first_search, cache_file, parent):
7676 self .Compare_Layout .addLayout (self .Bottom_Layout , 11 , 0 , 1 , 2 )
7777
7878 # Setting up the menu bar...
79- menu_bar = FF_Menubar .MenuBar (parent = self .Compare_Window , window = "compare" ,
80- listbox = None , cache_file_path = cache_file )
79+ menu_bar = FF_Menubar .MenuBar (parent = self .Compare_Window , window = "compare" , search_path = path_of_first_search ,
80+ search_path2 = compared_searches .path_of_second_search [0 ],
81+ cache_file_path = cache_file , bottom_layout = self .Bottom_Layout )
8182 logging .debug ("Done building MenuBar\n " )
8283
8384 # Set up both list-boxes
@@ -190,26 +191,10 @@ def __init__(self, path_of_first_search, cache_file, parent):
190191 self .Compare_Layout .addWidget (self .removed_files_label1 , 1 , 1 )
191192 self .Compare_Layout .addWidget (self .removed_files_label2 , 2 , 1 )
192193
193- # Buttons
194- # Button to open the File in Finder
195- move_file = self .generate_button ("Move / Rename" , menu_bar .move_file ,
196- icon = os .path .join (FF_Files .ASSETS_FOLDER , "Move_icon_small.png" ))
197- self .Bottom_Layout .addWidget (move_file )
198-
199- # Button to move the file to trash
200- delete_file = self .generate_button ("Move to Trash" , menu_bar .delete_file ,
201- icon = os .path .join (FF_Files .ASSETS_FOLDER , "Trash_icon_small.png" ))
202- self .Bottom_Layout .addWidget (delete_file )
203-
204- # Button to open the file
205- open_file = self .generate_button ("Open" , menu_bar .open_file ,
206- icon = os .path .join (FF_Files .ASSETS_FOLDER , "Open_icon_small.png" ))
207- self .Bottom_Layout .addWidget (open_file )
208-
209- # Button to show info about the file
210- file_info_button = self .generate_button ("Info" , menu_bar .file_info ,
211- icon = os .path .join (FF_Files .ASSETS_FOLDER , "Info_button_img_small.png" ))
212- self .Bottom_Layout .addWidget (file_info_button )
194+ # Mark the files that need to be marked, reference the two listbox widgets to the menu bar
195+ menu_bar .listbox = self .added_files_listbox
196+ menu_bar .listbox2 = self .removed_files_listbox
197+ menu_bar .mark_marked_files (to_be_marked_files )
213198
214199 # Update search status label
215200 FF_Search .ACTIVE_SEARCH_THREADS -= 1
@@ -230,10 +215,6 @@ def __init__(self, path_of_first_search, cache_file, parent):
230215
231216 time_stamp = time ()
232217
233- # Setting a Font
234- small_text_font = QFont (FF_Files .DEFAULT_FONT , FF_Files .NORMAL_FONT_SIZE )
235- small_text_font .setBold (True )
236-
237218 # Top Layout
238219 self .Top_Layout = QHBoxLayout ()
239220 self .Top_Layout .setContentsMargins (0 , 0 , 0 , 0 )
@@ -243,14 +224,14 @@ def __init__(self, path_of_first_search, cache_file, parent):
243224 time_text = QLabel (self .Compare_Window )
244225 total_time = compared_searches .time_dict ["time_after_building_ui" ] - compared_searches .time_dict ["start_time" ]
245226 time_text .setText (f"Time needed: { round (total_time , 3 )} s" )
246- time_text .setFont (small_text_font )
227+ time_text .setFont (FF_Additional_UI . BOLD_QT_FONT )
247228 # Displaying
248229 self .Top_Layout .addWidget (time_text )
249230
250231 # Saving time
251232 # Time stat Button
252- show_time = self .generate_button (None , lambda : show_time_stats (),
253- icon = os .path .join (FF_Files .ASSETS_FOLDER , "Time_button_img_small.png" ))
233+ show_time = menu_bar .generate_button (None , lambda : show_time_stats (),
234+ icon = os .path .join (FF_Files .ASSETS_FOLDER , "Time_button_img_small.png" ))
254235 # Resize
255236 show_time .setMaximumSize (50 , 50 )
256237 # Add to Layout
@@ -295,32 +276,12 @@ def show_time_stats():
295276 # Collect garbage
296277 gc .collect ()
297278
298- # Functions to automate Button
299- def generate_button (self , text , command , icon = None ):
300- # Define the Button
301- button = QPushButton (self .Compare_Window )
302- # Change the Text
303- button .setText (text )
304- # Set the command
305- button .clicked .connect (command )
306- # Set the icon
307- if icon is not None :
308- FF_Additional_UI .UIIcon (icon , button .setIcon )
309- button .setIconSize (QSize (23 , 22 ))
310- # Return the value of the Button, to move the Button
311- return button
312-
313279 # Function for generating the added / removed files labels
314280 def generate_title_label (self , text , text2 , light_color , dark_color , length_of_list ) -> tuple [QLabel , QLabel ]:
315281 # Label 1
316282 label1 = FF_Additional_UI .ColoredLabel (text , self .Compare_Window , light_color , dark_color )
317-
318- # Defining the font
319- font1 = QFont (FF_Files .DEFAULT_FONT , FF_Files .NORMAL_FONT_SIZE )
320- font1 .setBold (True )
321- label1 .setFont (font1 )
322-
323- label1 .setFixedHeight (FF_Files .NORMAL_FONT_SIZE + 2 )
283+ label1 .setFont (FF_Additional_UI .BOLD_QT_FONT )
284+ label1 .setFixedHeight (FF_Files .DEFAULT_FONT_SIZE + 2 )
324285 label1 .adjustSize ()
325286
326287 # Label 2
@@ -334,19 +295,17 @@ def generate_title_label(self, text, text2, light_color, dark_color, length_of_l
334295 # Set the label to the shortened string
335296 label2 .setText (text2_shortened )
336297
337- # Defining the font
338- font2 = QFont (FF_Files .DEFAULT_FONT , FF_Files .SMALLER_FONT_SIZE )
339298 # Configure the font
340- label2 .setFont (font2 )
299+ label2 .setFont (FF_Additional_UI . DEFAULT_QT_FONT )
341300 # Times two because it is two lines and plus two for some extra space
342- label2 .setFixedHeight (FF_Files .SMALLER_FONT_SIZE * 2 + 10 )
301+ label2 .setFixedHeight (FF_Files .DEFAULT_FONT_SIZE * 2 + 10 )
343302
344303 return label1 , label2
345304
346305
347306# The engine
348307class CompareSearches :
349- def __init__ (self , files_of_first_search : list , path_of_first_search , cache_file , parent ):
308+ def __init__ (self , files_of_first_search : list , path_of_first_search , cache_file , to_be_marked_files , parent ):
350309 # Debug
351310 logging .debug ("User pressed Compare Search" )
352311
@@ -357,7 +316,8 @@ class SignalsClass(QObject):
357316
358317 self .signals = SignalsClass ()
359318 # Connecting the signal to the user-interface class
360- self .signals .finished .connect (lambda : CompareUi (path_of_first_search , cache_file , parent ))
319+ self .signals .finished .connect (
320+ lambda : CompareUi (path_of_first_search , cache_file , to_be_marked_files , parent ))
361321
362322 # Thread
363323 comparing_thread = QThreadPool (parent )
0 commit comments