# HG changeset patch # User Rik # Date 1587869097 25200 # Node ID cba489221baba4197d0c9db16cf9042cf3aa3b13 # Parent 7739d3eb952b717e357f99e669bd06aebc44dae0 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. diff -r 7739d3eb952b -r cba489221bab libgui/graphics/BaseControl.cc --- a/libgui/graphics/BaseControl.cc Sat Apr 25 14:35:00 2020 -0700 +++ b/libgui/graphics/BaseControl.cc Sat Apr 25 19:44:57 2020 -0700 @@ -50,14 +50,19 @@ if (props.style_is ("edit") || props.style_is ("listbox")) { - p.setColor (QPalette::Base, + p.setColor (QPalette::Active, QPalette::Base, + Utils::fromRgb (props.get_backgroundcolor_rgb ())); + p.setColor (QPalette::Inactive, QPalette::Base, Utils::fromRgb (props.get_backgroundcolor_rgb ())); - p.setColor (QPalette::Text, + p.setColor (QPalette::Active, QPalette::Text, + Utils::fromRgb (props.get_foregroundcolor_rgb ())); + p.setColor (QPalette::Inactive, QPalette::Text, Utils::fromRgb (props.get_foregroundcolor_rgb ())); } else if (props.style_is ("popupmenu")) { - // popumenu (QComboBox) is a listbox with a button, so needs set colors for both + // popupmenu (QComboBox) is a listbox with a button. + // This requires setting colors for both. QColor bcol = Utils::fromRgb (props.get_backgroundcolor_rgb ()); QColor fcol = Utils::fromRgb (props.get_foregroundcolor_rgb ()); QString qss = QString ("background: %1 none;\n" @@ -119,7 +124,7 @@ octave::math::round (bb(2)), octave::math::round (bb(3))); w->setFont (Utils::computeFont (up, bb(3))); updatePalette (up, w); - w->setEnabled (up.enable_is ("on")); + w->setEnabled (! up.enable_is ("off")); w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); w->setVisible (up.is_visible ()); m_keyPressHandlerDefined = ! up.get_keypressfcn ().isempty (); @@ -174,7 +179,7 @@ break; case uicontrol::properties::ID_ENABLE: - w->setEnabled (up.enable_is ("on")); + w->setEnabled (! up.enable_is ("off")); break; case uicontrol::properties::ID_TOOLTIPSTRING: diff -r 7739d3eb952b -r cba489221bab libgui/graphics/EditControl.cc --- a/libgui/graphics/EditControl.cc Sat Apr 25 14:35:00 2020 -0700 +++ b/libgui/graphics/EditControl.cc Sat Apr 25 19:44:57 2020 -0700 @@ -85,6 +85,10 @@ uicontrol::properties& up = properties (); + if (up.enable_is ("inactive")) + edit->setReadOnly (true); + else + edit->setEnabled (up.enable_is ("on")); edit->setText (Utils::fromStdString (up.get_string_string ())); edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), up.get_verticalalignment ())); @@ -117,6 +121,10 @@ uicontrol::properties& up = properties (); + if (up.enable_is ("inactive")) + edit->setReadOnly (true); + else + edit->setEnabled (up.enable_is ("on")); edit->setAcceptRichText (false); edit->setPlainText (Utils::fromStringVector (up.get_string_vector ()).join ("\n")); @@ -179,6 +187,16 @@ up.get_verticalalignment ())); return true; + case uicontrol::properties::ID_ENABLE: + if (up.enable_is ("inactive")) + edit->setReadOnly (true); + else + { + edit->setReadOnly (false); + edit->setEnabled (up.enable_is ("on")); + } + return true; + case uicontrol::properties::ID_MIN: case uicontrol::properties::ID_MAX: if ((up.get_max () - up.get_min ()) > 1) @@ -216,6 +234,16 @@ up.get_verticalalignment ())); return true; + case uicontrol::properties::ID_ENABLE: + if (up.enable_is ("inactive")) + edit->setReadOnly (true); + else + { + edit->setReadOnly (false); + edit->setEnabled (up.enable_is ("on")); + } + return true; + case uicontrol::properties::ID_MIN: case uicontrol::properties::ID_MAX: if ((up.get_max () - up.get_min ()) <= 1)