# HG changeset patch # User Teemu Piippo # Date 1487052806 -7200 # Node ID 03aa7091cb4a5b2817af56b80c47f4df9a94cd79 # Parent 17f92eb2a30cb3ea0867dcfb4deb78c2ef0be7ac Simplified camera tooltip code. diff -r 17f92eb2a30c -r 03aa7091cb4a src/glRenderer.cpp --- a/src/glRenderer.cpp Tue Feb 14 08:08:17 2017 +0200 +++ b/src/glRenderer.cpp Tue Feb 14 08:13:26 2017 +0200 @@ -58,7 +58,7 @@ m_toolTipTimer = new QTimer (this); m_toolTipTimer->setSingleShot (true); setAcceptDrops (true); - connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); + connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (showCameraIconTooltip())); resetAllAngles(); m_needZoomToFit = true; @@ -554,15 +554,6 @@ painter.drawPixmap(info.targetRect, info.image, info.sourceRect); } - // Tool tips - if (m_drawToolTip) - { - if (not m_cameraIcons[static_cast(m_toolTipCamera)].targetRect.contains (m_mousePosition)) - m_drawToolTip = false; - else - QToolTip::showText(m_globalpos, m_cameras[static_cast(m_toolTipCamera)].name()); - } - // Draw a label for the current camera in the bottom left corner { QFontMetrics metrics {QFont {}}; @@ -638,8 +629,7 @@ } // Start the tool tip timer - if (not m_drawToolTip) - m_toolTipTimer->start (500); + m_toolTipTimer->start (500); // Update 2d position m_mousePosition = event->pos(); @@ -681,7 +671,6 @@ // void GLRenderer::leaveEvent(QEvent*) { - m_drawToolTip = false; m_toolTipTimer->stop(); update(); } @@ -819,19 +808,16 @@ return result; } -// ============================================================================= -// -void GLRenderer::slot_toolTipTimer() +/* + * Show a tooltip if the cursor is currently hovering over a camera icon. + */ +void GLRenderer::showCameraIconTooltip() { - // We come here if the cursor has stayed in one place for longer than a - // a second. Check if we're holding it over a camera icon - if so, draw - // a tooltip. for (CameraIcon & icon : m_cameraIcons) { if (icon.targetRect.contains (m_mousePosition)) { - m_toolTipCamera = icon.camera; - m_drawToolTip = true; + QToolTip::showText(m_globalpos, m_cameras[static_cast(icon.camera)].name()); update(); break; } diff -r 17f92eb2a30c -r 03aa7091cb4a src/glRenderer.h --- a/src/glRenderer.h Tue Feb 14 08:08:17 2017 +0200 +++ b/src/glRenderer.h Tue Feb 14 08:13:26 2017 +0200 @@ -149,7 +149,6 @@ QGenericMatrix<4, 4, GLfloat> m_rotationMatrix; GLCamera m_cameras[7]; bool m_useDarkBackground = false; - bool m_drawToolTip = false; bool m_takingScreenCapture = false; bool m_panning = false; bool m_initialized = false; @@ -161,7 +160,6 @@ QPoint m_globalpos; QPointF m_mousePositionF; Camera m_camera; - Camera m_toolTipCamera; GLuint m_axeslist; int m_totalMouseMove; QColor m_backgroundColor; @@ -174,7 +172,7 @@ void zoomAllToFit(); private slots: - void slot_toolTipTimer(); + void showCameraIconTooltip(); void initializeAxes(); void initializeLighting(); };