Commit ab05bbd1 authored by Ludovic Fauvet's avatar Ludovic Fauvet Committed by Jean-Baptiste Kempf

Qt: don't try to show an uninitialized time tooltip

(cherry picked from commit 0891bbe7)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 041b92e4
/***************************************************************************** /*****************************************************************************
* Copyright © 2011 VideoLAN * Copyright © 2011-2012 VideoLAN
* $Id$ * $Id$
* *
* Authors: Ludovic Fauvet <etix@l0cal.com> * Authors: Ludovic Fauvet <etix@l0cal.com>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define TIP_HEIGHT 5 #define TIP_HEIGHT 5
TimeTooltip::TimeTooltip( QWidget *parent ) : TimeTooltip::TimeTooltip( QWidget *parent ) :
QWidget( parent ) QWidget( parent ), mInitialized( false )
{ {
setWindowFlags( Qt::Window | setWindowFlags( Qt::Window |
Qt::WindowStaysOnTopHint | Qt::WindowStaysOnTopHint |
...@@ -108,6 +108,7 @@ void TimeTooltip::buildPath() ...@@ -108,6 +108,7 @@ void TimeTooltip::buildPath()
void TimeTooltip::setText( const QString& time, const QString& text ) void TimeTooltip::setText( const QString& time, const QString& text )
{ {
mInitialized = true;
mDisplayedText = time; mDisplayedText = time;
if ( !text.isEmpty() ) if ( !text.isEmpty() )
mDisplayedText.append( " - " ).append( text ); mDisplayedText.append( " - " ).append( text );
...@@ -120,6 +121,11 @@ void TimeTooltip::setText( const QString& time, const QString& text ) ...@@ -120,6 +121,11 @@ void TimeTooltip::setText( const QString& time, const QString& text )
update(); update();
} }
void TimeTooltip::show()
{
QWidget::setVisible( mInitialized );
}
void TimeTooltip::paintEvent( QPaintEvent * ) void TimeTooltip::paintEvent( QPaintEvent * )
{ {
QPainter p( this ); QPainter p( this );
......
...@@ -37,6 +37,7 @@ class TimeTooltip : public QWidget ...@@ -37,6 +37,7 @@ class TimeTooltip : public QWidget
public: public:
explicit TimeTooltip( QWidget *parent = 0 ); explicit TimeTooltip( QWidget *parent = 0 );
void setText( const QString& time, const QString& text ); void setText( const QString& time, const QString& text );
virtual void show();
protected: protected:
virtual void paintEvent( QPaintEvent * ); virtual void paintEvent( QPaintEvent * );
...@@ -51,6 +52,7 @@ private: ...@@ -51,6 +52,7 @@ private:
QPainterPath mPainterPath; QPainterPath mPainterPath;
QBitmap mMask; QBitmap mMask;
int mPreviousMetricsWidth; int mPreviousMetricsWidth;
bool mInitialized;
}; };
#endif // TIMETOOLTIP_H #endif // TIMETOOLTIP_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment