From 52e1881c2340b84d21f3592881d06f20632fad8d Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 17 Apr 2021 15:59:09 +0000 Subject: [PATCH] T(Float)SpinEdit: QT(4): fix not obeying the value of EditorEnabled if ReadOnly is set to False git-svn-id: trunk@65015 - --- lcl/interfaces/qt/qtwsspin.pp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lcl/interfaces/qt/qtwsspin.pp b/lcl/interfaces/qt/qtwsspin.pp index 38429516a4..3910c3c101 100644 --- a/lcl/interfaces/qt/qtwsspin.pp +++ b/lcl/interfaces/qt/qtwsspin.pp @@ -51,6 +51,7 @@ type class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override; class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); override; + class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override; (*TODO: seperation into properties instead of bulk update class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual; @@ -148,6 +149,23 @@ begin QLineEdit_setReadOnly(LineEdit, NewRO); end; +class procedure TQtWSCustomFloatSpinEdit.SetReadOnly( + const ACustomEdit: TCustomEdit; NewReadOnly: boolean); +var + Widget: TQtWidget; + QtEdit: IQtEdit; +begin + if not WSCheckHandleAllocated(ACustomEdit, 'SetReadOnly') then + Exit; + Widget := TQtWidget(ACustomEdit.Handle); + if Supports(Widget, IQtEdit, QtEdit) then + QtEdit.setReadOnly(NewReadOnly); + //if we set ReadOnly to False, the internal LineEdit will become ReadWrite as well, which may be unwanted. + if (not NewReadOnly) and (ACustomEdit is TCustomFloatSpinEdit) and (not TCustomFloatSpinEdit(ACustomEdit).EditorEnabled) then + SetEditorEnabled(TCustomFloatSpinEdit(ACustomEdit), False); +end; + + class procedure TQtWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); var CurrentSpinWidget: TQtAbstractSpinBox;