comparison libgui/graphics/Figure.cc @ 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 dcfbf4c1c3c8
children 46edfbd31ad7
comparison
equal deleted inserted replaced
20570:6256f6e366ac 20571:d0f886a030b7
164 m_menuBar->hide (); 164 m_menuBar->hide ();
165 165
166 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); 166 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
167 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); 167 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
168 168
169 //qDebug () << "Figure::Figure:" << m_innerRect;
170 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); 169 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
171 //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0); 170
172 win->setWindowTitle (Utils::fromStdString (fp.get_title ())); 171 // When this constructor gets called all properties are already
173 172 // set, even non default. We force "update" here to get things right.
174 int eventMask = 0; 173
175 if (! fp.get_keypressfcn ().is_empty ()) 174 // Figure title
176 eventMask |= Canvas::KeyPress; 175 update (figure::properties::ID_NUMBERTITLE);
177 if (! fp.get_keyreleasefcn ().is_empty ()) 176
178 eventMask |= Canvas::KeyRelease; 177 // Decide what keyboard events we listen to
179 m_container->canvas (m_handle)->setEventMask (eventMask); 178 m_container->canvas (m_handle)->setEventMask (0);
180 179 update (figure::properties::ID_KEYPRESSFCN);
181 if (! fp.get_windowbuttonmotionfcn ().is_empty ()) 180 update (figure::properties::ID_KEYRELEASEFCN);
182 { 181
183 m_container->setMouseTracking (true); 182 // Decide if the "currentpoint" is updated on mouse movements and
184 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); 183 // if the windowbuttonmotionfcn is executed
185 } 184 update (figure::properties::ID_WINDOWBUTTONMOTIONFCN);
185
186 // Visibility
187 update (figure::properties::ID_VISIBLE);
188
186 189
187 connect (this, SIGNAL (asyncUpdate (void)), 190 connect (this, SIGNAL (asyncUpdate (void)),
188 this, SLOT (updateContainer (void))); 191 this, SLOT (updateContainer (void)));
189
190 if (fp.is_visible ())
191 QTimer::singleShot (0, win, SLOT (show ()));
192 else
193 win->hide ();
194 192
195 win->addReceiver (this); 193 win->addReceiver (this);
196 m_container->addReceiver (this); 194 m_container->addReceiver (this);
197 } 195 }
198 196