-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a dialog where config settings can be changed
This adds a dialog where the user can modify HEXRDGUI configuration settings. Right now, the only option is to modify the number of processes used for multiprocessing. Fixes: #1578 Signed-off-by: Patrick Avery <[email protected]>
- Loading branch information
Showing
4 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>config_dialog</class> | ||
<widget class="QDialog" name="config_dialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>374</width> | ||
<height>94</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>HEXRDGUI Configuration</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout_2"> | ||
<item row="0" column="1"> | ||
<widget class="QSpinBox" name="max_cpus"> | ||
<property name="enabled"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="minimum"> | ||
<number>1</number> | ||
</property> | ||
<property name="maximum"> | ||
<number>10000</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0"> | ||
<widget class="QCheckBox" name="limit_cpus"> | ||
<property name="toolTip"> | ||
<string><html><head/><body><p>Limit the number of CPUs used for multiprocessing.</p></body></html></string> | ||
</property> | ||
<property name="text"> | ||
<string>Limit CPUs?</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0" colspan="2"> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="2" column="0" colspan="2"> | ||
<widget class="QDialogButtonBox" name="button_box"> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<tabstops> | ||
<tabstop>limit_cpus</tabstop> | ||
<tabstop>max_cpus</tabstop> | ||
</tabstops> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>limit_cpus</sender> | ||
<signal>toggled(bool)</signal> | ||
<receiver>max_cpus</receiver> | ||
<slot>setEnabled(bool)</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>97</x> | ||
<y>25</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>276</x> | ||
<y>25</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>button_box</sender> | ||
<signal>accepted()</signal> | ||
<receiver>config_dialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>186</x> | ||
<y>68</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>186</x> | ||
<y>46</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>button_box</sender> | ||
<signal>rejected()</signal> | ||
<receiver>config_dialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>186</x> | ||
<y>68</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>186</x> | ||
<y>46</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters