taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

LineEdit: enforce explicit disable #1117

Closed cpascual closed 4 years ago

cpascual commented 4 years ago

TaurusValueLineEdit auto enables/disables itself based based on events. This precludes the user from explicitly disable it. Fix by avoiding reenabling if setEnabled(False) is called. Note that auto-disabling on errors is still allowed even if setEnabled(True) is called, since the widget is not usable in case of error.

To test this you can use the following snippet (without this PR, the second widget will start disabled but will be autoenabled on the first change event, while with this PR it will stay disabled even if changes are forced with the first widget):

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.input import TaurusValueLineEdit
from taurus.external.qt import Qt

if __name__ == "__main__":
    import sys
    app = TaurusApplication(cmd_line_parser=None)

    w = Qt.QWidget()
    ly = Qt.QVBoxLayout()
    w.setLayout(ly)
    model = "sys/tg_test/1/short_scalar"

    e1 = TaurusValueLineEdit()
    e1.setModel(model)
    ly.addWidget(e1)

    e2 = TaurusValueLineEdit()
    e2.setModel(model)
    ly.addWidget(e2)
    e2.setEnabled(False)

    w.show()

    sys.exit(app.exec_())
cpascual commented 4 years ago

@taurus-org/integrators can you please integrate this?

teresanunez commented 4 years ago

i have tested and it works as expected. I merge it.