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

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

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4a9aaa84
/***************************************************************************** /*****************************************************************************
* Copyright © 2011 VideoLAN * Copyright © 2011-2012 VideoLAN
* $Id$ * $Id$
* *
* Authors: Ludovic Fauvet <etix@l0cal.com> * Authors: Ludovic Fauvet <etix@l0cal.com>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,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 |
...@@ -123,6 +123,7 @@ void TimeTooltip::buildPath() ...@@ -123,6 +123,7 @@ void TimeTooltip::buildPath()
void TimeTooltip::setTip( const QPoint& target, const QString& time, const QString& text ) void TimeTooltip::setTip( const QPoint& target, 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 );
...@@ -138,6 +139,11 @@ void TimeTooltip::setTip( const QPoint& target, const QString& time, const QStri ...@@ -138,6 +139,11 @@ void TimeTooltip::setTip( const QPoint& target, const QString& time, const QStri
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 setTip( const QPoint& pos, const QString& time, const QString& text ); void setTip( const QPoint& pos, const QString& time, const QString& text );
virtual void show();
protected: protected:
virtual void paintEvent( QPaintEvent * ); virtual void paintEvent( QPaintEvent * );
...@@ -53,6 +54,7 @@ private: ...@@ -53,6 +54,7 @@ private:
QPainterPath mPainterPath; QPainterPath mPainterPath;
QBitmap mMask; QBitmap mMask;
int mTipX; int mTipX;
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