[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [phonon] phonon: Insert a subicon for an object if it has the 'discovererIcon' property set
From:       Casian Andrei <skeletk13 () gmail ! com>
Date:       2012-02-21 16:06:14
Message-ID: 20120221160614.5F71EA60A6 () git ! kde ! org
[Download RAW message or body]

Git commit c954be36e16c83ba745710e869c69583a79c0775 by Casian Andrei.
Committed on 25/09/2011 at 15:16.
Pushed by casianandrei into branch 'master'.

Insert a subicon for an object if it has the 'discovererIcon' property set

This will allow identifying who discovered the device (possibly in the
Phonon KCM) if there are problems with it.

The subicon would represent either a backend or a platform plugin. The
value of the "discovererIcon" property is either the icon or it's name.

M  +20   -3    phonon/objectdescriptionmodel.cpp

http://commits.kde.org/phonon/c954be36e16c83ba745710e869c69583a79c0775

diff --git a/phonon/objectdescriptionmodel.cpp b/phonon/objectdescriptionmodel.cpp
index bb0c4f5..666621c 100644
--- a/phonon/objectdescriptionmodel.cpp
+++ b/phonon/objectdescriptionmodel.cpp
@@ -30,6 +30,7 @@
 #include <QtCore/QMimeData>
 #include <QtCore/QStringList>
 #include <QtGui/QIcon>
+#include <QtGui/QPainter>
 #include "factory_p.h"
 
 QT_BEGIN_NAMESPACE
@@ -162,12 +163,28 @@ QVariant ObjectDescriptionModelData::data(const QModelIndex &index, int role) co
         break;
     case Qt::DecorationRole:
         {
+            /* Returns an icon if available. Paint a subicon representing the entity (platform
+             * plugin or backend) which discovered this object, if it is specified */
             QVariant icon = d->data.at(index.row())->property("icon");
+            QVariant discovererIcon = d->data.at(index.row())->property("discovererIcon");
             if (icon.isValid()) {
                 if (icon.type() == QVariant::String) {
-                    return Platform::icon(icon.toString());
-                } else if (icon.type() == QVariant::Icon) {
-                    return icon;
+                    icon = Platform::icon(icon.toString());
+                }
+                if (discovererIcon.type() == QVariant::String) {
+                    discovererIcon = Platform::icon(discovererIcon.toString());
+                }
+                if (icon.type() == QVariant::Icon) {
+                    if (discovererIcon.type() == QVariant::Icon) {
+                        // Insert the subicon in the top-right corner of the icon
+                        QPixmap pixmap = icon.value<QIcon>().pixmap(QSize(64, 64));
+                        QPixmap subPixmap = discovererIcon.value<QIcon>().pixmap(QSize(22, 22));
+                        QPainter painter(&pixmap);
+                        painter.drawPixmap(42, 0, subPixmap);
+                        return QIcon(pixmap);
+                    } else {
+                        return icon;
+                    }
                 }
             }
         }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic