Mercurial > octave
diff libgui/graphics/PushButtonControl.cc @ 25788:88e87c69c8b8
Implement "cdata" property for pushbuttons (bug #44332).
* ToggleButtonControl.h (update): Add protected function to class.
* ToggleButtonControl.cc (ToggleButtonControl): In constructor,
create a QImage from "cdata" property and apply it using setIcon().
* ToggleButtonControl.cc (update): New function to handle changes to
object properties. Decode "ID_CDATA" in switch statement. Create a QImage
from "cdata" property and apply it using setIcon().
* PushButtonControl.cc (PushButtonControl): In constructor,
create a QImage from "cdata" property and apply it using setIcon().
* PushButtonControl.cc (update): Decode "ID_CDATA" in switch statement. Create
a QImage from "cdata" property and apply it using setIcon().
author | Rik <rik@octave.org> |
---|---|
date | Tue, 14 Aug 2018 11:52:38 -0700 |
parents | 6652d3823428 |
children | 1a12d4369beb |
line wrap: on
line diff
--- a/libgui/graphics/PushButtonControl.cc Tue Aug 14 11:17:26 2018 -0700 +++ b/libgui/graphics/PushButtonControl.cc Tue Aug 14 11:52:38 2018 -0700 @@ -54,7 +54,13 @@ QPushButton *btn) : ButtonControl (go, btn) { + uicontrol::properties& up = properties<uicontrol> (); + btn->setAutoFillBackground (true); + octave_value cdat = up.get_cdata (); + QImage img = Utils::makeImageFromCData (cdat, + cdat.rows (), cdat.columns ()); + btn->setIcon (QIcon (QPixmap::fromImage (img))); } PushButtonControl::~PushButtonControl (void) @@ -72,6 +78,16 @@ btn->setText (Utils::fromStdString (up.get_string_string ())); break; + case uicontrol::properties::ID_CDATA: + { + octave_value cdat = up.get_cdata (); + QImage img = Utils::makeImageFromCData (cdat, + cdat.rows (), + cdat.columns ()); + btn->setIcon (QIcon (QPixmap::fromImage (img))); + } + break; + default: BaseControl::update (pId); break;