[vlc-commits] Qt: addons: tag addons with colors
Francois Cartegnie
git at videolan.org
Thu Feb 27 03:19:44 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Feb 27 02:55:12 2014 +0100| [0dd7de57435c1ee0ded750fccaef792a472b1063] | committer: Francois Cartegnie
Qt: addons: tag addons with colors
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0dd7de57435c1ee0ded750fccaef792a472b1063
---
modules/gui/qt4/dialogs/plugins.cpp | 44 ++++++++++++++++++++++++++++++++++-
modules/gui/qt4/dialogs/plugins.hpp | 2 ++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt4/dialogs/plugins.cpp b/modules/gui/qt4/dialogs/plugins.cpp
index 8093c3d..0cfee4c 100644
--- a/modules/gui/qt4/dialogs/plugins.cpp
+++ b/modules/gui/qt4/dialogs/plugins.cpp
@@ -57,7 +57,6 @@
#include <QCheckBox>
#include <QPixmap>
#include <QStylePainter>
-#include <QGraphicsColorizeEffect>
#include <QProgressBar>
#include <QTextEdit>
#include <QUrl>
@@ -846,6 +845,32 @@ bool AddonsListModel::setData( const QModelIndex &index, const QVariant &value,
return true;
}
+QColor AddonsListModel::getColorByAddonType( int i_type )
+{
+ QColor color;
+ switch( i_type )
+ {
+ case ADDON_EXTENSION:
+ color = QColor(0xDB, 0xC5, 0x40);
+ break;
+ case ADDON_PLAYLIST_PARSER:
+ color = QColor(0x36, 0xBB, 0x59);
+ break;
+ case ADDON_SERVICE_DISCOVERY:
+ color = QColor(0xDB, 0x52, 0x40);
+ break;
+ case ADDON_SKIN2:
+ color = QColor(0x8B, 0xD6, 0xFC);
+ break;
+ case ADDON_PLUGIN:
+ case ADDON_UNKNOWN:
+ case ADDON_OTHER:
+ default:
+ break;
+ }
+ return color;
+}
+
QVariant AddonsListModel::data( const QModelIndex& index, int role ) const
{
if( !index.isValid() )
@@ -1004,7 +1029,24 @@ void AddonItemDelegate::paint( QPainter *painter,
{
QStyleOptionViewItemV4 newopt = option;
int i_state = index.data( AddonsListModel::StateRole ).toInt();
+ int i_type = index.data( AddonsListModel::TypeRole ).toInt();
+
+ /* Draw Background gradient by addon type */
+ QColor backgroundColor = AddonsListModel::getColorByAddonType( i_type );
+
+ if ( backgroundColor.isValid() )
+ {
+ painter->save();
+ QLinearGradient gradient(
+ QPoint( option.rect.right() - 50, option.rect.top() ),
+ option.rect.bottomRight() );
+ gradient.setColorAt( 0, Qt::transparent );
+ gradient.setColorAt( 1.0, backgroundColor );
+ painter->fillRect( option.rect, gradient );
+ painter->restore();
+ }
+ /* Draw base info from parent */
ExtensionItemDelegate::paint( painter, newopt, index );
initStyleOption( &newopt, index );
diff --git a/modules/gui/qt4/dialogs/plugins.hpp b/modules/gui/qt4/dialogs/plugins.hpp
index e67f5b9..877e0e6 100644
--- a/modules/gui/qt4/dialogs/plugins.hpp
+++ b/modules/gui/qt4/dialogs/plugins.hpp
@@ -227,6 +227,8 @@ public:
ScoreRole
};
+ static QColor getColorByAddonType( int );
+
protected slots:
void addonAdded( addon_entry_t * );
void addonChanged( const addon_entry_t * );
More information about the vlc-commits
mailing list