[vlc-commits] qt: improve rendering of simple_pref icons for HiDpi
Pierre Lamot
git at videolan.org
Wed Nov 15 16:11:18 CET 2017
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Nov 15 11:57:36 2017 +0100| [995870c54c2d6daa729ed4c9008730d06af2070b] | committer: Jean-Baptiste Kempf
qt: improve rendering of simple_pref icons for HiDpi
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=995870c54c2d6daa729ed4c9008730d06af2070b
---
modules/gui/qt/components/simple_preferences.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp
index 218630896f..48de52746b 100644
--- a/modules/gui/qt/components/simple_preferences.cpp
+++ b/modules/gui/qt/components/simple_preferences.cpp
@@ -48,6 +48,7 @@
#include <math.h>
#define ICON_HEIGHT 48
+#define ICON_WIDTH 48
#ifdef _WIN32
# include <vlc_charset.h>
@@ -191,19 +192,25 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
CONNECT( mapper, mapped(int), this, switchPanel(int) );
QPixmap scaled;
+#if HAS_QT56
+ qreal dpr = devicePixelRatioF();
+#else
+ qreal dpr = devicePixelRatio();
+#endif
#define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
QToolButton * button = new QToolButton( this ); \
/* Scale icon to non native size outside of toolbutton to avoid widget size */\
/* computation using native size */\
scaled = QPixmap( ":/prefsmenu/" #icon ".png" )\
- .scaledToHeight( ICON_HEIGHT , Qt::SmoothTransformation );\
+ .scaledToHeight( ICON_HEIGHT * dpr, Qt::SmoothTransformation );\
+ scaled.setDevicePixelRatio( dpr ); \
button->setIcon( scaled ); \
button->setText( label ); \
button->setToolTip( ltooltip ); \
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
- button->setIconSize( QSize( scaled.width(), scaled.height() ) ); \
- button->setMinimumWidth( 40 + scaled.width() );\
+ button->setIconSize( QSize( ICON_WIDTH, ICON_HEIGHT ) ); \
+ button->setMinimumWidth( 40 + ICON_WIDTH );\
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); \
button->setAutoRaise( true ); \
button->setCheckable( true ); \
More information about the vlc-commits
mailing list