Work on IconItem
The sizing we get is messed up, and the first pixmap (which we try to use) has size 0x0. Needs fixing.
This commit is contained in:
parent
47ee5be976
commit
e3149f9c77
@ -39,7 +39,7 @@
|
||||
#include "svgitem.h"
|
||||
// #include "theme.h"
|
||||
// #include "dialog.h"
|
||||
// #include "iconitem.h"
|
||||
#include "iconitem.h"
|
||||
// #include "tooltip.h"
|
||||
// #include "dataenginebindings_p.h"
|
||||
|
||||
@ -99,7 +99,7 @@ void CoreBindingsPlugin::registerTypes(const char *uri)
|
||||
// qRegisterMetaType<Plasma::QueryMatch *>("QueryMatch");
|
||||
//
|
||||
// qmlRegisterType<QQmlPropertyMap>();
|
||||
// qmlRegisterType<IconItem>(uri, 0, 1, "IconItem");
|
||||
qmlRegisterType<IconItem>(uri, 0, 1, "IconItem");
|
||||
|
||||
/*qmlRegisterInterface<Plasma::DataSource>("DataSource");
|
||||
qRegisterMetaType<Plasma::DataSource*>("DataSource");*/
|
||||
|
@ -27,8 +27,10 @@
|
||||
#include <plasma/paintutils.h>
|
||||
#include <plasma/svg.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
IconItem::IconItem(QQuickItem *parent)
|
||||
: QQuickItem(parent),
|
||||
: QQuickPaintedItem(parent),
|
||||
m_svgIcon(0),
|
||||
m_smooth(false),
|
||||
m_active(false),
|
||||
@ -207,14 +209,21 @@ bool IconItem::isValid() const
|
||||
void IconItem::paint(QPainter *painter)
|
||||
{
|
||||
if (m_iconPixmaps.isEmpty()) {
|
||||
qDebug() << "XXXXXXXXXX icons pixmap empty";
|
||||
return;
|
||||
}
|
||||
foreach (QPixmap pix, m_iconPixmaps) {
|
||||
qDebug() << "pixmap: " << pix.size();
|
||||
}
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||
|
||||
const QRect destRect(QPointF(boundingRect().center() - QPointF(m_iconPixmaps.first().width()/2, m_iconPixmaps.first().height()/2)).toPoint(),
|
||||
m_iconPixmaps.first().size());
|
||||
//QSize(32,32));
|
||||
qDebug() << "XXXXXXXXXX icons pixmap THERE" << destRect;
|
||||
|
||||
if (m_animation->state() == QAbstractAnimation::Running) {
|
||||
QPixmap result = m_iconPixmaps.first();
|
||||
@ -266,8 +275,6 @@ void IconItem::loadPixmap()
|
||||
//if size is more than 64, leave as is
|
||||
}
|
||||
|
||||
|
||||
|
||||
//final pixmap to paint
|
||||
QPixmap result;
|
||||
if (m_svgIcon) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define ICONITEM_H
|
||||
|
||||
#include <QIcon>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
#include <QPixmap>
|
||||
#include <QVariant>
|
||||
|
||||
@ -31,7 +31,7 @@ namespace Plasma {
|
||||
class Svg;
|
||||
}
|
||||
|
||||
class IconItem : public QQuickItem
|
||||
class IconItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user