[vlc-commits] qt: plugins: Don't generate icons procedurally

Hugo Beauzée-Luyssen git at videolan.org
Tue Aug 22 11:06:05 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Aug 22 10:29:57 2017 +0200| [20d465183a4a9be21bf5c9f07f26a0b42b3b06a5] | committer: Hugo Beauzée-Luyssen

qt: plugins: Don't generate icons procedurally

Fix #18689

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

 modules/gui/qt/Makefile.am         |  6 ++++++
 modules/gui/qt/dialogs/plugins.cpp | 37 ++++++++++++++++++-------------------
 modules/gui/qt/vlc.qrc             |  6 ++++++
 3 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 3dd9667741..8ed48411d2 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -317,6 +317,12 @@ libqt_plugin_la_RES = \
 	gui/qt/pixmaps/go-next.png \
 	gui/qt/pixmaps/addons/addon.png \
 	gui/qt/pixmaps/addons/addon_broken.png \
+	gui/qt/pixmaps/addons/addon_blue.png \
+	gui/qt/pixmaps/addons/addon_cyan.png \
+	gui/qt/pixmaps/addons/addon_green.png \
+	gui/qt/pixmaps/addons/addon_magenta.png \
+	gui/qt/pixmaps/addons/addon_red.png \
+	gui/qt/pixmaps/addons/addon_yellow.png \
 	gui/qt/pixmaps/addons/score.png \
 	gui/qt/pixmaps/menus/exit_16px.png \
 	gui/qt/pixmaps/menus/help_16px.png \
diff --git a/modules/gui/qt/dialogs/plugins.cpp b/modules/gui/qt/dialogs/plugins.cpp
index c1d7463a20..d5f7edfdb5 100644
--- a/modules/gui/qt/dialogs/plugins.cpp
+++ b/modules/gui/qt/dialogs/plugins.cpp
@@ -300,24 +300,26 @@ void ExtensionTab::moreInformation()
     dlg.exec();
 }
 
-static QPixmap hueRotate( QImage image, const QColor &source, const QColor &target )
+static QIcon iconFromCategory( int type )
 {
-    int distance = target.hue() - source.hue();
-    /* must be indexed as we alter palette, not a whole pic */
-    Q_ASSERT( image.colorCount() );
-    if ( target.isValid() )
+    switch( type )
     {
-        /* color 1 = transparency */
-        for ( int i=1; i < image.colorCount(); i++ )
-        {
-            QColor color = image.color( i );
-            int newhue = color.hue() + distance;
-            if ( newhue < 0 ) newhue += 255;
-            color.setHsv( newhue, color.saturation(), color.value(), color.alpha() );
-            image.setColor( i, color.rgba() );
-        }
+        case ADDON_EXTENSION:
+            return QIcon( ":/addons/addon_yellow" );
+        case ADDON_PLAYLIST_PARSER:
+            return QIcon( ":/addons/addon_green" );
+        case ADDON_SERVICE_DISCOVERY:
+            return QIcon( ":/addons/addon_red" );
+        case ADDON_SKIN2:
+            return QIcon( ":/addons/addon_cyan" );
+        case ADDON_INTERFACE:
+            return QIcon( ":/addons/addon_blue" );
+        case ADDON_META:
+            return QIcon( ":/addons/addon_magenta" );
+        default:
+            return QIcon( ":/addons/default" );
     }
-    return QPixmap::fromImage( image );
+    vlc_assert_unreachable();
 }
 
 /* Add-ons tab */
@@ -352,12 +354,9 @@ AddonsTab::AddonsTab( intf_thread_t *p_intf_ ) : QVLCFrame( p_intf_ )
 
     QToolButton * button;
     signalMapper = new QSignalMapper();
-    QImage icon( ":/addons/default" );
-    QColor vlcorange( 0xEC, 0x83, 0x00 );
 #define ADD_CATEGORY( label, ltooltip, numb ) \
     button = new QToolButton( this );\
-    button->setIcon( QIcon( hueRotate( icon, vlcorange, \
-                     AddonsListModel::getColorByAddonType( numb ) ) ) );\
+    button->setIcon( iconFromCategory( numb ) ); \
     button->setText( label );\
     button->setToolTip( ltooltip );\
     button->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );\
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 59055fb6bb..0da18b08d0 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -147,5 +147,11 @@
         <file alias="default">pixmaps/addons/addon.png</file>
         <file alias="broken">pixmaps/addons/addon_broken.png</file>
         <file alias="score">pixmaps/addons/score.png</file>
+        <file alias="addon_blue">pixmaps/addons/addon_blue.png</file>
+        <file alias="addon_cyan">pixmaps/addons/addon_cyan.png</file>
+        <file alias="addon_green">pixmaps/addons/addon_green.png</file>
+        <file alias="addon_magenta">pixmaps/addons/addon_magenta.png</file>
+        <file alias="addon_red">pixmaps/addons/addon_red.png</file>
+        <file alias="addon_yellow">pixmaps/addons/addon_yellow.png</file>
     </qresource>
 </RCC>



More information about the vlc-commits mailing list