@@ -959,6 +959,7 @@ def __init__(self):
959959 self .image_files = []
960960 self .results = {} # {image_path: {sdk_name: ProcessingResult}}
961961 self .processing_thread = None # Initialize to None
962+ self ._updating_selection = False # Flag to prevent selection loops
962963
963964 # Setup UI
964965 self .setup_ui ()
@@ -1036,6 +1037,19 @@ def setup_ui(self):
10361037 self .file_list .setDragDropMode (QListWidget .DragDropMode .DropOnly )
10371038 self .file_list .setSelectionMode (QListWidget .SelectionMode .SingleSelection )
10381039
1040+ # Add custom styling for better visibility
1041+ self .file_list .setStyleSheet ("""
1042+ QListWidget::item:selected {
1043+ background-color: #007acc;
1044+ color: white;
1045+ font-weight: bold;
1046+ }
1047+ QListWidget::item:hover {
1048+ background-color: #4da6e0;
1049+ color: white;
1050+ }
1051+ """ )
1052+
10391053 # Connect selection change to processing
10401054 self .file_list .currentItemChanged .connect (self .on_image_selected )
10411055
@@ -1048,8 +1062,25 @@ def setup_ui(self):
10481062 results_layout = QVBoxLayout (results_group )
10491063
10501064 self .results_table = ResultsTableWidget ()
1065+
1066+ # Add custom styling for better visibility
1067+ self .results_table .setStyleSheet ("""
1068+ QTableWidget::item:selected {
1069+ background-color: #007acc;
1070+ color: white;
1071+ font-weight: bold;
1072+ }
1073+ QTableWidget::item:hover {
1074+ background-color: #4da6e0;
1075+ color: white;
1076+ }
1077+ """ )
1078+
10511079 results_layout .addWidget (self .results_table )
10521080
1081+ # Connect results table selection to file list synchronization
1082+ self .results_table .image_selected .connect (self .on_results_table_selection )
1083+
10531084 # Export button (after table creation)
10541085 export_btn = QPushButton ("📤 Export to CSV" )
10551086 export_btn .clicked .connect (self .results_table .export_to_csv )
@@ -1188,6 +1219,12 @@ def on_image_selected(self, current_item, previous_item):
11881219
11891220 self .status_bar .showMessage (f"Selected: { os .path .basename (image_path )} " )
11901221
1222+ # Synchronize with results table selection (avoid loops)
1223+ if not self ._updating_selection :
1224+ self ._updating_selection = True
1225+ self .highlight_results_table_row (image_path )
1226+ self ._updating_selection = False
1227+
11911228 # Check if we have SDK versions configured
11921229 if len (self .sdk_versions ) >= 2 :
11931230 # Process the selected image
@@ -1315,6 +1352,103 @@ def clear_all(self):
13151352 self .image_comparison .sdk2_results_text .clear ()
13161353 self .status_bar .showMessage ("Cleared all data" )
13171354
1355+ def on_results_table_selection (self , image_path : str ):
1356+ """Handle selection from results table - synchronize with file list"""
1357+ if self ._updating_selection :
1358+ return
1359+
1360+ self ._updating_selection = True
1361+
1362+ # Find and select the corresponding item in the file list
1363+ for i in range (self .file_list .count ()):
1364+ item = self .file_list .item (i )
1365+ if item and item .data (Qt .ItemDataRole .UserRole ) == image_path :
1366+ self .file_list .setCurrentItem (item )
1367+ break
1368+
1369+ self ._updating_selection = False
1370+
1371+ # Update the image comparison view
1372+ if image_path in self .results :
1373+ self .image_comparison .show_comparison (image_path , self .results [image_path ])
1374+
1375+ def highlight_results_table_row (self , image_path : str ):
1376+ """Highlight the row in results table corresponding to the selected image"""
1377+ if self ._updating_selection :
1378+ return
1379+
1380+ # Find and select the corresponding row in results table
1381+ for row in range (self .results_table .rowCount ()):
1382+ item = self .results_table .item (row , 0 )
1383+ if item and item .data (Qt .ItemDataRole .UserRole ) == image_path :
1384+ # Clear any previous highlighting
1385+ self .clear_results_table_highlighting ()
1386+
1387+ # Highlight the selected row with bright blue background
1388+ for col in range (self .results_table .columnCount ()):
1389+ cell_item = self .results_table .item (row , col )
1390+ if cell_item :
1391+ # Don't override the difference column colors, just make them brighter
1392+ if col == 3 : # Barcode Δ column - keep original logic but brighter
1393+ text = cell_item .text ()
1394+ if text .startswith ('+' ) and text != '+0' :
1395+ cell_item .setBackground (QColor (100 , 255 , 100 )) # Brighter green
1396+ elif text .startswith ('-' ) or (text .isdigit () and int (text ) < 0 ):
1397+ cell_item .setBackground (QColor (255 , 100 , 100 )) # Brighter red
1398+ elif text == '0' :
1399+ cell_item .setBackground (QColor (200 , 200 , 200 )) # Brighter gray
1400+ else :
1401+ cell_item .setBackground (QColor (0 , 122 , 204 )) # Bright blue
1402+ elif col == 4 : # Speed Δ column - keep original logic but brighter
1403+ text = cell_item .text ()
1404+ if text .endswith ('s' ) and not text .startswith ('+' ) and text != '0.000s' :
1405+ cell_item .setBackground (QColor (100 , 255 , 100 )) # Brighter green
1406+ elif text .startswith ('+' ):
1407+ cell_item .setBackground (QColor (255 , 100 , 100 )) # Brighter red
1408+ elif text == '0.000s' :
1409+ cell_item .setBackground (QColor (200 , 200 , 200 )) # Brighter gray
1410+ else :
1411+ cell_item .setBackground (QColor (0 , 122 , 204 )) # Bright blue
1412+ else :
1413+ # Use bright blue for other columns
1414+ cell_item .setBackground (QColor (0 , 122 , 204 )) # Bright blue
1415+ cell_item .setForeground (QColor (255 , 255 , 255 )) # White text
1416+
1417+ # Select the row
1418+ self .results_table .selectRow (row )
1419+ break
1420+
1421+ def clear_results_table_highlighting (self ):
1422+ """Clear blue highlighting from all rows in results table"""
1423+ for row in range (self .results_table .rowCount ()):
1424+ for col in range (self .results_table .columnCount ()):
1425+ item = self .results_table .item (row , col )
1426+ if item :
1427+ # Check if this is a difference column that should keep its color
1428+ if col == 3 : # Barcode Δ column
1429+ text = item .text ()
1430+ if text .startswith ('+' ) and text != '+0' :
1431+ item .setBackground (QColor (200 , 255 , 200 )) # Green for improvement
1432+ elif text .startswith ('-' ) or (text .isdigit () and int (text ) < 0 ):
1433+ item .setBackground (QColor (255 , 200 , 200 )) # Red for regression
1434+ elif text == '0' :
1435+ item .setBackground (QColor (240 , 240 , 240 )) # Gray for same
1436+ else :
1437+ item .setBackground (QColor ()) # Default
1438+ elif col == 4 : # Speed Δ column
1439+ text = item .text ()
1440+ if text .endswith ('s' ) and not text .startswith ('+' ) and text != '0.000s' :
1441+ item .setBackground (QColor (200 , 255 , 200 )) # Green for faster
1442+ elif text .startswith ('+' ):
1443+ item .setBackground (QColor (255 , 200 , 200 )) # Red for slower
1444+ elif text == '0.000s' :
1445+ item .setBackground (QColor (240 , 240 , 240 )) # Gray for same
1446+ else :
1447+ item .setBackground (QColor ()) # Default
1448+ else :
1449+ # Clear background for other columns
1450+ item .setBackground (QColor ()) # Default background
1451+
13181452class ProcessingThread (QThread ):
13191453 """Background thread for image processing"""
13201454
0 commit comments