Mercurial > octave
changeset 26337:5f321f799cb1 stable
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
* BaseControl.cc (updatePalette): Use stylesheets instead of palettes in order
to set foregroundcolor and backgroundcolor of uicontrol objects with styles
"popupmenu" and "pushbutton".
author | Torsten <mttl@mailbox.org> |
---|---|
date | Sat, 08 Dec 2018 21:58:30 +0100 |
parents | a6694db4bd41 |
children | 358bed84511b |
files | libgui/graphics/BaseControl.cc |
diffstat | 1 files changed, 14 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/BaseControl.cc Sun Dec 30 11:05:41 2018 +0100 +++ b/libgui/graphics/BaseControl.cc Sat Dec 08 21:58:30 2018 +0100 @@ -52,14 +52,13 @@ else if (props.style_is ("popupmenu")) { // popumenu (QComboBox) is a listbox with a button, so needs set colors for both - p.setColor (QPalette::Base, - Utils::fromRgb (props.get_backgroundcolor_rgb ())); - p.setColor (QPalette::Text, - Utils::fromRgb (props.get_foregroundcolor_rgb ())); - p.setColor (QPalette::Button, - Utils::fromRgb (props.get_backgroundcolor_rgb ())); - p.setColor (QPalette::ButtonText, - Utils::fromRgb (props.get_foregroundcolor_rgb ())); + 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;") + .arg(bcol.name ()).arg (fcol.name ()); + w->setStyleSheet(qss); + return; } else if (props.style_is ("radiobutton") || props.style_is ("checkbox")) @@ -72,10 +71,13 @@ else if (props.style_is ("pushbutton") || props.style_is ("togglebutton")) { - p.setColor (QPalette::Button, - Utils::fromRgb (props.get_backgroundcolor_rgb ())); - p.setColor (QPalette::ButtonText, - Utils::fromRgb (props.get_foregroundcolor_rgb ())); + 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;") + .arg(bcol.name ()).arg (fcol.name ()); + w->setStyleSheet(qss); + return; } else {