Skip to content

Commit d8685fd

Browse files
committed
BUG: stop designer from setting line-edits in ui file to be readOnly when PYDM_DESIGNER_ONLINE enabled
when editing a lineedit widget in designer after doinng 'export PYDM_DESIGNER_ONLINE=1', we want widgets to act as read-only so PVs are not accidentally changed when modifying screens. this is enforced by the dataplugins themselves and is_read_only() (set during designer setup: https://github.com/slaclab/pydm/blob/master/pydm/qtdesigner.py#L47) but we don't want the readOnly=true status to be saved into the ui file containting the lineedit. to avoid this, don't let lineedit set itself to readOnly if it's loaded in designer with live data enabled. (it will still act in a read-only way thanks to dataplugins themselves)
1 parent 5aaf9b9 commit d8685fd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pydm/widgets/line_edit.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .base import PyDMWritableWidget, TextFormatter, str_types, PostParentClassInitSetup
1111
from pydm import utilities
1212
from .display_format import DisplayFormat, parse_value_for_display
13-
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes
13+
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes, is_qt_designer
1414

1515
logger = logging.getLogger(__name__)
1616

@@ -162,14 +162,26 @@ def send_value(self):
162162

163163
def setReadOnly(self, readOnly):
164164
self._user_set_read_only = readOnly
165-
super().setReadOnly(True if self._user_set_read_only else not self._write_access)
165+
shouldSetReadOnly = True if self._user_set_read_only else (not self._write_access)
166+
# When in designer and reading in live data (DESIGNER_ONLINE), don't set and therefore save to
167+
# the ui file readOnly=True setting. While we do want widgets to act in read-only way in designer
168+
# (so don't accidentally write data during editing), this is handled in the data_plugins themselves.
169+
if is_qt_designer() and config.DESIGNER_ONLINE:
170+
shouldSetReadOnly = False
171+
super().setReadOnly(shouldSetReadOnly)
166172

167173
def write_access_changed(self, new_write_access):
168174
"""
169175
Change the PyDMLineEdit to read only if write access is denied
170176
"""
171177
super().write_access_changed(new_write_access)
172178
if not self._user_set_read_only:
179+
shouldSetReadOnly = not new_write_access
180+
# When in designer and reading in live data (DESIGNER_ONLINE), don't set and therefore save to
181+
# the ui file readOnly=True setting. While we do want widgets to act in read-only way in designer
182+
# (so don't accidentally write data during editing), this is handled in the data_plugins themselves.
183+
if is_qt_designer() and config.DESIGNER_ONLINE:
184+
shouldSetReadOnly = False
173185
super().setReadOnly(not new_write_access)
174186

175187
def unit_changed(self, new_unit):

0 commit comments

Comments
 (0)