Mercurial > octave-nkf
changeset 20571:d0f886a030b7
Use "update" method to initialize Qt Figures (cleanup + bug #46086)
* Figure.cc (Figure::Figure): call "update" method on "windowbuttonmotionfcn" property to decide wether to update currentpoint and execute the function.
* Figure.cc (Figure::Figure): call "update" method to avoid duplicate code for "visible", "keypresfcn" and "keyreleasefcn" properties.
* Figure.cc (Figure::Figure): don't enable mouse tracking twice
* Figure.cc (Figure::Figure): remove left-over debug comments
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Thu, 01 Oct 2015 23:09:38 +0200 |
parents | 6256f6e366ac |
children | 72cd24aa5f7a |
files | libgui/graphics/Figure.cc |
diffstat | 1 files changed, 17 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc Fri Oct 02 05:50:43 2015 +0200 +++ b/libgui/graphics/Figure.cc Thu Oct 01 23:09:38 2015 +0200 @@ -166,32 +166,30 @@ m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); - //qDebug () << "Figure::Figure:" << m_innerRect; win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); - //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0); - win->setWindowTitle (Utils::fromStdString (fp.get_title ())); + + // When this constructor gets called all properties are already + // set, even non default. We force "update" here to get things right. + + // Figure title + update (figure::properties::ID_NUMBERTITLE); - int eventMask = 0; - if (! fp.get_keypressfcn ().is_empty ()) - eventMask |= Canvas::KeyPress; - if (! fp.get_keyreleasefcn ().is_empty ()) - eventMask |= Canvas::KeyRelease; - m_container->canvas (m_handle)->setEventMask (eventMask); + // Decide what keyboard events we listen to + m_container->canvas (m_handle)->setEventMask (0); + update (figure::properties::ID_KEYPRESSFCN); + update (figure::properties::ID_KEYRELEASEFCN); - if (! fp.get_windowbuttonmotionfcn ().is_empty ()) - { - m_container->setMouseTracking (true); - m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); - } + // Decide if the "currentpoint" is updated on mouse movements and + // if the windowbuttonmotionfcn is executed + update (figure::properties::ID_WINDOWBUTTONMOTIONFCN); + + // Visibility + update (figure::properties::ID_VISIBLE); + connect (this, SIGNAL (asyncUpdate (void)), this, SLOT (updateContainer (void))); - if (fp.is_visible ()) - QTimer::singleShot (0, win, SLOT (show ())); - else - win->hide (); - win->addReceiver (this); m_container->addReceiver (this); }