[vlc-commits] qt: improve time tooltip for hidpi
Romain Vimont
git at videolan.org
Thu May 3 11:42:31 CEST 2018
vlc/vlc-3.0 | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu May 3 10:21:21 2018 +0200| [b6637ba93d7e02544a97505d7c3ce72371526527] | committer: Hugo Beauzée-Luyssen
qt: improve time tooltip for hidpi
The time tooltip (for the seek slider) was pixelated on hidpi screens.
Both the polygon to draw the tooltip and the widget mask had low
definition.
Replace QPolygon by QPolygonF to fix the tooltip drawing.
Currently, Qt does not support hidpi masks. Instead, disable the mask,
set a translucent background and make the widget transparent for mouse
events.
It also fixes #20011 as a side effect.
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit 75c1522c87e992ba0ec1eb04dae04473621d8ebb)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b6637ba93d7e02544a97505d7c3ce72371526527
---
modules/gui/qt/util/timetooltip.cpp | 15 +++------------
modules/gui/qt/util/timetooltip.hpp | 2 --
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/modules/gui/qt/util/timetooltip.cpp b/modules/gui/qt/util/timetooltip.cpp
index 2e7e97d987..1314b520ea 100644
--- a/modules/gui/qt/util/timetooltip.cpp
+++ b/modules/gui/qt/util/timetooltip.cpp
@@ -40,6 +40,8 @@ TimeTooltip::TimeTooltip( QWidget *parent ) :
// Tell Qt that it doesn't need to erase the background before
// a paintEvent occurs. This should save some CPU cycles.
setAttribute( Qt::WA_OpaquePaintEvent );
+ setAttribute( Qt::WA_TranslucentBackground );
+ setAttribute( Qt::WA_TransparentForMouseEvents );
// Inherit from the system default font size -5
mFont = QFont( "Verdana", qMax( qApp->font().pointSize() - 5, 7 ) );
@@ -91,7 +93,6 @@ void TimeTooltip::adjustPosition()
resize( size );
buildPath();
- setMask( mMask );
}
}
@@ -105,7 +106,7 @@ void TimeTooltip::buildPath()
mPainterPath.addRect( mBox );
// Draw the tip
- QPolygon polygon;
+ QPolygonF polygon;
polygon << QPoint( qMax( 0, mTipX - 3 ), mBox.height() )
<< QPoint( mTipX, mBox.height() + TIP_HEIGHT )
<< QPoint( qMin( mTipX + 3, mBox.width() ), mBox.height() );
@@ -113,16 +114,6 @@ void TimeTooltip::buildPath()
// Store the simplified version of the path
mPainterPath = mPainterPath.simplified();
-
- // Create the mask used to erase the background
- // Note: this is a binary bitmap (black & white)
- mMask = QBitmap( size() );
- QPainter painter( &mMask );
- painter.fillRect( mMask.rect(), Qt::white );
- painter.setPen( Qt::black );
- painter.setBrush( Qt::black );
- painter.drawPath( mPainterPath );
- painter.end();
}
void TimeTooltip::setTip( const QPoint& target, const QString& time, const QString& text )
diff --git a/modules/gui/qt/util/timetooltip.hpp b/modules/gui/qt/util/timetooltip.hpp
index d239d9984b..e7e57f622a 100644
--- a/modules/gui/qt/util/timetooltip.hpp
+++ b/modules/gui/qt/util/timetooltip.hpp
@@ -25,7 +25,6 @@
#include "qt.hpp"
#include <QWidget>
-#include <QBitmap>
class QPaintEvent;
class QString;
@@ -54,7 +53,6 @@ private:
QFont mFont;
QRect mBox;
QPainterPath mPainterPath;
- QBitmap mMask;
int mTipX;
};
More information about the vlc-commits
mailing list