# HG changeset patch # User Pantxo Diribarne # Date 1443733778 -7200 # Node ID d0f886a030b72c55a69aecfd7729c8448b7748bf # Parent 6256f6e366ac3b366462604a0fdd31507b68b039 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 diff -r 6256f6e366ac -r d0f886a030b7 libgui/graphics/Figure.cc --- 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); }