diff --git a/hexrd/ui/config_dialog.py b/hexrd/ui/config_dialog.py new file mode 100644 index 000000000..467a9a22d --- /dev/null +++ b/hexrd/ui/config_dialog.py @@ -0,0 +1,49 @@ +from hexrd.ui.hexrd_config import HexrdConfig +from hexrd.ui.ui_loader import UiLoader + + +class ConfigDialog: + def __init__(self, parent=None): + self.ui = UiLoader().load_file('config_dialog.ui', parent) + + self.update_gui() + self.setup_connections() + + def setup_connections(self): + self.ui.accepted.connect(self.on_accepted) + + def exec_(self): + self.update_gui() + self.ui.exec_() + + def update_gui(self): + self.max_cpus_ui = self.max_cpus_config + + def update_config(self): + self.max_cpus_config = self.max_cpus_ui + + def on_accepted(self): + self.update_config() + + @property + def max_cpus_ui(self): + if not self.ui.limit_cpus.isChecked(): + return None + + return self.ui.max_cpus.value() + + @max_cpus_ui.setter + def max_cpus_ui(self, v): + self.ui.limit_cpus.setChecked(v is not None) + if v is None: + return + + self.ui.max_cpus.setValue(v) + + @property + def max_cpus_config(self): + return HexrdConfig().max_cpus + + @max_cpus_config.setter + def max_cpus_config(self, v): + HexrdConfig().max_cpus = v diff --git a/hexrd/ui/main_window.py b/hexrd/ui/main_window.py index 9ef69c1d9..3e5a81dad 100644 --- a/hexrd/ui/main_window.py +++ b/hexrd/ui/main_window.py @@ -22,6 +22,7 @@ from hexrd.ui.calibration_slider_widget import CalibrationSliderWidget from hexrd.ui.create_hedm_instrument import create_hedm_instrument from hexrd.ui.color_map_editor import ColorMapEditor +from hexrd.ui.config_dialog import ConfigDialog from hexrd.ui.progress_dialog import ProgressDialog from hexrd.ui.cal_tree_view import CalTreeView from hexrd.ui.hand_drawn_mask_dialog import HandDrawnMaskDialog @@ -219,6 +220,8 @@ def setup_connections(self): self.on_action_transform_detectors_triggered) self.ui.action_image_calculator.triggered.connect( self.open_image_calculator) + self.ui.action_edit_config.triggered.connect( + self.on_action_edit_config_triggered) self.ui.action_open_mask_manager.triggered.connect( self.on_action_open_mask_manager_triggered) self.ui.action_show_live_updates.toggled.connect( @@ -1238,6 +1241,9 @@ def on_accepted(): dialog.accepted.connect(on_accepted) + def on_action_edit_config_triggered(self): + ConfigDialog(self.ui).exec_() + def update_enable_states(self): has_images = HexrdConfig().has_images num_images = HexrdConfig().imageseries_length diff --git a/hexrd/ui/resources/ui/config_dialog.ui b/hexrd/ui/resources/ui/config_dialog.ui new file mode 100644 index 000000000..79aa7d6b1 --- /dev/null +++ b/hexrd/ui/resources/ui/config_dialog.ui @@ -0,0 +1,117 @@ + + + config_dialog + + + + 0 + 0 + 374 + 94 + + + + HEXRDGUI Configuration + + + + + + false + + + 1 + + + 10000 + + + + + + + <html><head/><body><p>Limit the number of CPUs used for multiprocessing.</p></body></html> + + + Limit CPUs? + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + limit_cpus + max_cpus + + + + + limit_cpus + toggled(bool) + max_cpus + setEnabled(bool) + + + 97 + 25 + + + 276 + 25 + + + + + button_box + accepted() + config_dialog + accept() + + + 186 + 68 + + + 186 + 46 + + + + + button_box + rejected() + config_dialog + reject() + + + 186 + 68 + + + 186 + 46 + + + + + diff --git a/hexrd/ui/resources/ui/main_window.ui b/hexrd/ui/resources/ui/main_window.ui index 9187a3657..6ebb072fd 100644 --- a/hexrd/ui/resources/ui/main_window.ui +++ b/hexrd/ui/resources/ui/main_window.ui @@ -41,7 +41,7 @@ 0 0 1600 - 22 + 26 @@ -206,6 +206,7 @@ + @@ -316,7 +317,7 @@ 0 0 550 - 775 + 753 @@ -329,7 +330,7 @@ 0 0 550 - 775 + 753 @@ -839,6 +840,11 @@ Threshold + + + Configuration + +