[vlc-commits] Qt: remove toolbar icon size hack

Francois Cartegnie git at videolan.org
Tue Oct 17 19:35:31 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Oct 16 12:50:09 2017 +0200| [a1c68b71c6b497e19a92b10995e7e5bd434218ad] | committer: Francois Cartegnie

Qt: remove toolbar icon size hack

Text widget size is miscomputed due to a mix in non
native and scaled icon size.

This reverts commit 32930aa2e0c72371d4865a1ef18a0bab460be40a.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a1c68b71c6b497e19a92b10995e7e5bd434218ad
---

 modules/gui/qt/components/simple_preferences.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp
index 827fa29b1c..218630896f 100644
--- a/modules/gui/qt/components/simple_preferences.cpp
+++ b/modules/gui/qt/components/simple_preferences.cpp
@@ -190,16 +190,20 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
     QSignalMapper *mapper = new QSignalMapper( layout );
     CONNECT( mapper, mapped(int), this, switchPanel(int) );
 
-    short icon_height = ICON_HEIGHT;
+    QPixmap scaled;
 
 #define ADD_CATEGORY( button, label, ltooltip, icon, numb )                 \
     QToolButton * button = new QToolButton( this );                         \
-    button->setIcon( QIcon( ":/prefsmenu/" #icon ".png" ) );                \
+    /* 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 );\
+    button->setIcon( scaled );                \
     button->setText( label );                                               \
     button->setToolTip( ltooltip );                                         \
     button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );              \
-    button->setIconSize( QSize( icon_height, icon_height ) );               \
-    button->setMinimumSize( QSize( icon_height + 40, icon_height + 40 ) );  \
+    button->setIconSize( QSize( scaled.width(), scaled.height() ) );          \
+    button->setMinimumWidth( 40 + scaled.width() );\
     button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); \
     button->setAutoRaise( true );                                           \
     button->setCheckable( true );                                           \



More information about the vlc-commits mailing list