[vlc-devel] [PATCH 08/10] qt: fix rendering of FramelessButton with HiDpi
Pierre Lamot
pierre at videolabs.io
Fri Sep 29 10:25:10 CEST 2017
---
modules/gui/qt/components/playlist/selector.cpp | 4 +++-
modules/gui/qt/util/customwidgets.cpp | 5 ++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/components/playlist/selector.cpp b/modules/gui/qt/components/playlist/selector.cpp
index 1d41f7f6af..a7cef6be13 100644
--- a/modules/gui/qt/components/playlist/selector.cpp
+++ b/modules/gui/qt/components/playlist/selector.cpp
@@ -93,7 +93,9 @@ void PLSelItem::addAction( ItemAction act, const QString& tooltip )
lblAction = new SelectorActionButton();
lblAction->setIcon( icon );
- lblAction->setMinimumWidth( lblAction->sizeHint().width() + 6 );
+ int icon_size = fontMetrics().height();
+ lblAction->setIconSize( QSize( icon_size, icon_size ) );
+ lblAction->setMinimumWidth( lblAction->sizeHint().width() + icon_size );
if( !tooltip.isEmpty() ) lblAction->setToolTip( tooltip );
diff --git a/modules/gui/qt/util/customwidgets.cpp b/modules/gui/qt/util/customwidgets.cpp
index 8ffb6d7870..dfb8307337 100644
--- a/modules/gui/qt/util/customwidgets.cpp
+++ b/modules/gui/qt/util/customwidgets.cpp
@@ -50,9 +50,8 @@ QFramelessButton::QFramelessButton( QWidget *parent )
void QFramelessButton::paintEvent( QPaintEvent * )
{
QPainter painter( this );
- QPixmap pix = icon().pixmap( size() );
- QPoint pos( (width() - pix.width()) / 2, (height() - pix.height()) / 2 );
- painter.drawPixmap( QRect( pos.x(), pos.y(), pix.width(), pix.height() ), pix );
+ icon().paint(&painter, QRect( 0, 0, width(), height()));
+
}
QElidingLabel::QElidingLabel( const QString &s, Qt::TextElideMode mode, QWidget * parent )
--
2.14.1
More information about the vlc-devel
mailing list