Skip to content

Commit

Permalink
Merge pull request #646 from bitcraze/krichardsson/distable-param
Browse files Browse the repository at this point in the history
Disable params on disconnect
  • Loading branch information
victorhook authored Dec 13, 2022
2 parents 44d6694 + 58d7a5e commit fe29266
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions src/cfclient/ui/tabs/ParamTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,35 +355,42 @@ def _set_param_value(self):
self.currentValue.setStyleSheet('border: 1px solid red')

def _paramChanged(self):

group = None
param = None
indexes = self.paramTree.selectionModel().selectedIndexes()
selectedIndex = indexes[0]
if len(indexes) > 0:
selectedIndex = indexes[0]
if selectedIndex.parent().isValid():
group = selectedIndex.parent().data()
param = selectedIndex.data()
else:
group = selectedIndex.data()

# Made visible in _persistent_state_cb()
self.persistentFrame.setVisible(False)

param = None
if selectedIndex.parent().isValid():
group = selectedIndex.parent().data()
param = selectedIndex.data()
else:
group = selectedIndex.data()

self.paramDetailsLabel.setText(f'{group}.{param}' if param is not None else group)
if cfclient.log_param_doc is not None:
try:
desc = str()
group_doc = cfclient.log_param_doc['params'][group]
if param is None:
desc = group_doc['desc']
else:
desc = group_doc['variables'][param]['short_desc']

self.paramDetailsDescription.setWordWrap(True)
self.paramDetailsDescription.setText(desc.replace('\n', ''))
except: # noqa
self.paramDetailsDescription.setText('')

self.valueFrame.setVisible(param is not None)
are_details_visible = param is not None
self.valueFrame.setVisible(are_details_visible)
self.paramDetailsLabel.setVisible(are_details_visible)
self.paramDetailsDescription.setVisible(are_details_visible)

if param:
self.paramDetailsLabel.setText(f'{group}.{param}' if param is not None else group)
if cfclient.log_param_doc is not None:
try:
desc = str()
group_doc = cfclient.log_param_doc['params'][group]
if param is None:
desc = group_doc['desc']
else:
desc = group_doc['variables'][param]['short_desc']

self.paramDetailsDescription.setWordWrap(True)
self.paramDetailsDescription.setText(desc.replace('\n', ''))
except: # noqa
self.paramDetailsDescription.setText('')

complete = f'{group}.{param}'
elem = self.cf.param.toc.get_element_by_complete_name(complete)
value = round_if_float(self.cf.param.get_value(complete))
Expand All @@ -408,7 +415,7 @@ def _connected(self, link_uri):
self._helper.cf.param.request_update_of_all_params()

def _disconnected(self, link_uri):
#
# This will gray out all rows
#

self._model.reset()
self._paramChanged()
self._model.set_enabled(False)

0 comments on commit fe29266

Please sign in to comment.