comparison libgui/graphics/EditControl.cc @ 28244:cba489221bab

Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128) * BaseControl.cc (updatePalette): Call setColor() with additional argument of "QPalette::Active" and again with "QPalette::Inactive" so that colors are set only for specific roles. When Qt widget disabled it should now go gray. * BaseControl.cc (init): Call 'setEnabled (! properties.enable_is ("off"))' so that "Inactive" value still causes Qt Widget to be enabled. * BaseControl.cc (update): Call 'setEnabled (! properties.enable_is ("off"))' so that "Inactive" value still causes Qt Widget to be enabled. * EditControl.cc (init): Check Octave "Enable" property and call Qt setReadOnly() if value is "Inactive", but otherwise call Qt setEnabled() with property value. * EditControl.cc (updateSingleLine, updateMultiLine): Check Octave "Enable" property and call Qt setReadOnly() if value is "Inactive", but otherwise call Qt setEnabled() with property value.
author Rik <rik@octave.org>
date Sat, 25 Apr 2020 19:44:57 -0700
parents 2757f267a198
children 7854d5752dd2
comparison
equal deleted inserted replaced
28243:7739d3eb952b 28244:cba489221bab
83 m_multiLine = false; 83 m_multiLine = false;
84 initCommon (edit); 84 initCommon (edit);
85 85
86 uicontrol::properties& up = properties<uicontrol> (); 86 uicontrol::properties& up = properties<uicontrol> ();
87 87
88 if (up.enable_is ("inactive"))
89 edit->setReadOnly (true);
90 else
91 edit->setEnabled (up.enable_is ("on"));
88 edit->setText (Utils::fromStdString (up.get_string_string ())); 92 edit->setText (Utils::fromStdString (up.get_string_string ()));
89 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), 93 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (),
90 up.get_verticalalignment ())); 94 up.get_verticalalignment ()));
91 95
92 connect (edit, SIGNAL (textEdited (const QString&)), 96 connect (edit, SIGNAL (textEdited (const QString&)),
115 m_multiLine = true; 119 m_multiLine = true;
116 initCommon (edit); 120 initCommon (edit);
117 121
118 uicontrol::properties& up = properties<uicontrol> (); 122 uicontrol::properties& up = properties<uicontrol> ();
119 123
124 if (up.enable_is ("inactive"))
125 edit->setReadOnly (true);
126 else
127 edit->setEnabled (up.enable_is ("on"));
120 edit->setAcceptRichText (false); 128 edit->setAcceptRichText (false);
121 edit->setPlainText (Utils::fromStringVector 129 edit->setPlainText (Utils::fromStringVector
122 (up.get_string_vector ()).join ("\n")); 130 (up.get_string_vector ()).join ("\n"));
123 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), 131 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (),
124 up.get_verticalalignment ())); 132 up.get_verticalalignment ()));
177 case uicontrol::properties::ID_VERTICALALIGNMENT: 185 case uicontrol::properties::ID_VERTICALALIGNMENT:
178 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), 186 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (),
179 up.get_verticalalignment ())); 187 up.get_verticalalignment ()));
180 return true; 188 return true;
181 189
190 case uicontrol::properties::ID_ENABLE:
191 if (up.enable_is ("inactive"))
192 edit->setReadOnly (true);
193 else
194 {
195 edit->setReadOnly (false);
196 edit->setEnabled (up.enable_is ("on"));
197 }
198 return true;
199
182 case uicontrol::properties::ID_MIN: 200 case uicontrol::properties::ID_MIN:
183 case uicontrol::properties::ID_MAX: 201 case uicontrol::properties::ID_MAX:
184 if ((up.get_max () - up.get_min ()) > 1) 202 if ((up.get_max () - up.get_min ()) > 1)
185 { 203 {
186 QWidget *container = edit->parentWidget (); 204 QWidget *container = edit->parentWidget ();
212 230
213 case uicontrol::properties::ID_HORIZONTALALIGNMENT: 231 case uicontrol::properties::ID_HORIZONTALALIGNMENT:
214 case uicontrol::properties::ID_VERTICALALIGNMENT: 232 case uicontrol::properties::ID_VERTICALALIGNMENT:
215 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), 233 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (),
216 up.get_verticalalignment ())); 234 up.get_verticalalignment ()));
235 return true;
236
237 case uicontrol::properties::ID_ENABLE:
238 if (up.enable_is ("inactive"))
239 edit->setReadOnly (true);
240 else
241 {
242 edit->setReadOnly (false);
243 edit->setEnabled (up.enable_is ("on"));
244 }
217 return true; 245 return true;
218 246
219 case uicontrol::properties::ID_MIN: 247 case uicontrol::properties::ID_MIN:
220 case uicontrol::properties::ID_MAX: 248 case uicontrol::properties::ID_MAX:
221 if ((up.get_max () - up.get_min ()) <= 1) 249 if ((up.get_max () - up.get_min ()) <= 1)