9
9
QLineEdit ,
10
10
QComboBox ,
11
11
QSpinBox ,
12
+ QCheckBox ,
12
13
QPushButton ,
13
14
QSizePolicy ,
14
15
QHeaderView ,
@@ -45,11 +46,25 @@ def __init__(self, parent=None):
45
46
self .camera_table .setMinimumSize (1 , 1 )
46
47
self .camera_table .setSizePolicy (QSizePolicy .Policy .Minimum , QSizePolicy .Policy .Minimum )
47
48
49
+ # Initialise Refresh button
50
+ self .refresh_layout = QHBoxLayout ()
51
+ self .refresh_cameras_button = QPushButton ()
52
+ self .refresh_cameras_button .setIcon (QIcon (os .path .join (self .paths ["assets_dir" ], "refresh.svg" )))
53
+ self .refresh_cameras_button .clicked .connect (self .refresh )
54
+ self .refresh_cameras_button .setToolTip ("Refresh the list of connected cameras" )
55
+
56
+ # Initialise a check box that allows automatic refreshing
57
+ self .auto_refresh_checkbox = QCheckBox ("Auto Refresh" )
58
+ self .auto_refresh_checkbox .stateChanged .connect (self .toggle_auto_refresh )
59
+ self .refresh_layout .addWidget (self .refresh_cameras_button , alignment = Qt .AlignmentFlag .AlignRight )
60
+ self .refresh_layout .addWidget (self .auto_refresh_checkbox , alignment = Qt .AlignmentFlag .AlignRight )
61
+
48
62
self .camera_table_layout = QVBoxLayout ()
49
63
self .camera_table_layout .addWidget (self .camera_table )
50
64
self .camera_table_groupbox .setLayout (self .camera_table_layout )
51
65
52
66
self .page_layout = QVBoxLayout ()
67
+ self .page_layout .addLayout (self .refresh_layout )
53
68
self .page_layout .addWidget (self .camera_table_groupbox )
54
69
self .setLayout (self .page_layout )
55
70
@@ -62,19 +77,34 @@ def __init__(self, parent=None):
62
77
self .refresh_timer = QTimer ()
63
78
self .refresh_timer .timeout .connect (self .refresh )
64
79
80
+ # Refresh timer / tab changing logic -------------------------------------------------------------------------------
81
+
82
+ def toggle_auto_refresh (self ):
83
+ """Based on the value of the checkbox start or stop the timer and enable/disable the refresh button"""
84
+ if self .auto_refresh_checkbox .isChecked ():
85
+ self .refresh_timer .start (1000 )
86
+ self .refresh_cameras_button .setEnabled (False )
87
+ else :
88
+ self .refresh_timer .stop ()
89
+ self .refresh_cameras_button .setEnabled (True )
90
+
65
91
def tab_selected (self ):
66
92
"""Called when tab deselected."""
67
- self .refresh_timer .start (1000 )
93
+ if self .auto_refresh_checkbox .isChecked ():
94
+ self .refresh_timer .start (1000 )
68
95
69
96
def tab_deselected (self ):
70
97
"""Called when tab deselected."""
71
- self .refresh_timer .stop ()
98
+ if self .refresh_timer .isActive ():
99
+ self .refresh_timer .stop ()
72
100
# Deinitialise all camera apis on tab being deselected
73
101
for unique_id in self .setups :
74
102
if self .GUI .preview_showing :
75
103
self .setups [unique_id ].close_preview_camera ()
76
104
self .setups [unique_id ].camera_api .stop_capturing ()
77
105
106
+ # Reading / Writing the Camera setups saved function --------------------------------------------------------
107
+
78
108
def get_saved_setups (self , unique_id : str = None , name : str = None ) -> CameraSettingsConfig :
79
109
"""Get a saved CameraSettingsConfig object from a name or unique_id from self.saved_setups."""
80
110
if unique_id :
@@ -276,7 +306,9 @@ def __init__(self, setups_table, name, unique_id, fps, exposure_time, gain, down
276
306
# Preview button.
277
307
self .preview_camera_button = QPushButton ("Preview" )
278
308
self .preview_camera_button .clicked .connect (self .open_preview_camera )
279
- self .preview_camera_button .setToolTip (f"Preview camera: { self .settings .name if self .settings .name is not None else self .settings .unique_id } " )
309
+ self .preview_camera_button .setToolTip (
310
+ f"Preview camera: { self .settings .name if self .settings .name is not None else self .settings .unique_id } "
311
+ )
280
312
281
313
# Populate the table
282
314
self .setups_table .insertRow (0 )
0 commit comments