Mercurial > octave
changeset 28245:46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
* BaseControl.cc (updatePalette): For pushbuttons & togglebuttons, add
":enabled" to beginning of StyleSheet specification so that custom colors are
only applied when widget is active.
* BaseControl.cc (init): Call blockSignals() if "Enable" property is "inactive"
during setup of widget. Otherwise, call setEnabled() with value of "Enable"
property.
* BaseControl.cc (update): When updating "Enable" property, call blockSignals()
if value is "inactive", otherwise call setEnabled().
author | Rik <rik@octave.org> |
---|---|
date | Sun, 26 Apr 2020 10:48:20 -0700 |
parents | cba489221bab |
children | c387a55aed05 |
files | libgui/graphics/BaseControl.cc |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/BaseControl.cc Sat Apr 25 19:44:57 2020 -0700 +++ b/libgui/graphics/BaseControl.cc Sun Apr 26 10:48:20 2020 -0700 @@ -84,8 +84,8 @@ { QColor bcol = Utils::fromRgb (props.get_backgroundcolor_rgb ()); QColor fcol = Utils::fromRgb (props.get_foregroundcolor_rgb ()); - QString qss = QString ("background: %1 none;\n" - "color: %2;") + QString qss = QString (":enabled { background: %1 none;\n" + "color: %2; }") .arg(bcol.name ()).arg (fcol.name ()); w->setStyleSheet(qss); return; @@ -124,7 +124,10 @@ octave::math::round (bb(2)), octave::math::round (bb(3))); w->setFont (Utils::computeFont<uicontrol> (up, bb(3))); updatePalette (up, w); - w->setEnabled (! up.enable_is ("off")); + if (up.enable_is ("inactive")) + w->blockSignals (true); + else + w->setEnabled (up.enable_is ("on")); w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); w->setVisible (up.is_visible ()); m_keyPressHandlerDefined = ! up.get_keypressfcn ().isempty (); @@ -179,7 +182,13 @@ break; case uicontrol::properties::ID_ENABLE: - w->setEnabled (! up.enable_is ("off")); + if (up.enable_is ("inactive")) + w->blockSignals (true); + else + { + w->blockSignals (false); + w->setEnabled (! up.enable_is ("off")); + } break; case uicontrol::properties::ID_TOOLTIPSTRING: