Skip to content

Commit d80b1b6

Browse files
committed
Use gray background, white text for disabled value
Signed-off-by: Patrick Avery <[email protected]>
1 parent af8ed08 commit d80b1b6

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

hexrdgui/calibration/calibration_dialog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ def update_disabled_editor_paths(self):
500500
# The value is uneditable
501501
uneditable_paths.append(self.tardis_ip4_y_path + (value_idx,))
502502

503+
# A tree view update is necessary after changing the disabled editors
504+
self.update_tree_view()
505+
503506
@property
504507
def has_tardis_constraints(self):
505508
return self.engineering_constraints == 'TARDIS'

hexrdgui/calibration/tree_item_models.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ def set_config_val(self, path, value):
5252

5353
setattr(param, attribute, value)
5454

55+
def data(self, index, role):
56+
if (
57+
role in (Qt.BackgroundRole, Qt.ForegroundRole) and
58+
index.column() in (self.VALUE_IDX, self.VARY_IDX) and
59+
self.has_uneditable_paths
60+
):
61+
# Check if this value is uneditable. If so, gray it out.
62+
item = self.get_item(index)
63+
path = tuple(self.path_to_item(item) + [self.VALUE_IDX])
64+
if path in self.uneditable_paths:
65+
color = 'gray'
66+
if (
67+
index.column() == self.VALUE_IDX and
68+
role == Qt.ForegroundRole
69+
):
70+
color = 'white'
71+
72+
return QColor(color)
73+
74+
return super().data(index, role)
75+
5576

5677
class DefaultCalibrationTreeItemModel(CalibrationTreeItemModel):
5778
"""This model uses minimum/maximum for the boundary constraints"""
@@ -86,16 +107,6 @@ def data(self, index, role):
86107

87108
if abs(item.data(pair[0]) - item.data(pair[1])) < atol:
88109
return QColor('red')
89-
if (
90-
role == Qt.ForegroundRole and
91-
index.column() == self.VALUE_IDX and
92-
self.has_uneditable_paths
93-
):
94-
# Check if this value is uneditable. If so, gray it out.
95-
item = self.get_item(index)
96-
path = tuple(self.path_to_item(item) + [index.column()])
97-
if path in self.uneditable_paths:
98-
return QColor('gray')
99110

100111
return super().data(index, role)
101112

hexrdgui/resources/ui/calibration_dialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<item row="3" column="1">
5151
<widget class="QComboBox" name="engineering_constraints">
5252
<property name="toolTip">
53-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add engineering constraints for certain instrument types. This may add extra parameters to the table.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;For example, for TARDIS, the distance between IMAGE-PLATE-2 and IMAGE-PLATE-4 must be within a certain range. If TARDIS is selected, a new parameter is added with default values for this distance.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If the instrument type can be guessed, it will be selected automatically when the dialog first appears. For example, TARDIS is automatically selected if any of the detector names are IMAGE-PLATE-2, IMAGE-PLATE-3, or IMAGE-PLATE-4.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
53+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add engineering constraints for certain instrument types. This may add extra parameters to the table.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;For example, for TARDIS, the distance between IMAGE-PLATE-2 and IMAGE-PLATE-4 must be within a certain range. If TARDIS is selected, a new parameter is added with default values for this distance, and the y value of IMAGE-PLATE-4 is disabled for editing/refinement since it is computed from the distance instead.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If the instrument type can be guessed, it will be selected automatically when the dialog first appears. For example, TARDIS is automatically selected if IMAGE-PLATE-2 and IMAGE-PLATE-4 are present.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
5454
</property>
5555
<item>
5656
<property name="text">

0 commit comments

Comments
 (0)