[kcm-tabbox] Use a QQuickPaintedItem for the ThumbnailItem
This commit is contained in:
parent
ab08d3da9b
commit
2baa345d10
2 changed files with 10 additions and 13 deletions
|
@ -20,21 +20,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "thumbnailitem.h"
|
||||
// Qt
|
||||
#include <QtDeclarative/QDeclarativeContext>
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
#include <QtDeclarative/QDeclarativeView>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QPainter>
|
||||
// KDE
|
||||
#include <KDE/KDebug>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
WindowThumbnailItem::WindowThumbnailItem(QDeclarativeItem* parent)
|
||||
: QDeclarativeItem(parent)
|
||||
WindowThumbnailItem::WindowThumbnailItem(QQuickPaintedItem* parent)
|
||||
: QQuickPaintedItem(parent)
|
||||
, m_wId(0)
|
||||
, m_image()
|
||||
{
|
||||
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
|
||||
}
|
||||
|
||||
WindowThumbnailItem::~WindowThumbnailItem()
|
||||
|
@ -75,11 +72,10 @@ void WindowThumbnailItem::findImage()
|
|||
}
|
||||
}
|
||||
|
||||
void WindowThumbnailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void WindowThumbnailItem::paint(QPainter *painter)
|
||||
{
|
||||
if (m_image.isNull()) {
|
||||
// no image: default behavior
|
||||
QDeclarativeItem::paint(painter, option, widget);
|
||||
return;
|
||||
}
|
||||
QSizeF difference(boundingRect().width() - m_image.width(), boundingRect().height() - m_image.height());
|
||||
const QRectF drawRect(boundingRect().x() + difference.width()/2.0, boundingRect().y(), m_image.width(), m_image.height());
|
||||
|
|
|
@ -21,24 +21,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef KWIN_THUMBNAILITEM_H
|
||||
#define KWIN_THUMBNAILITEM_H
|
||||
|
||||
#include <QtDeclarative/QDeclarativeItem>
|
||||
#include <QImage>
|
||||
#include <QQuickPaintedItem>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class WindowThumbnailItem : public QDeclarativeItem
|
||||
class WindowThumbnailItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true)
|
||||
public:
|
||||
explicit WindowThumbnailItem(QDeclarativeItem *parent = 0);
|
||||
explicit WindowThumbnailItem(QQuickPaintedItem *parent = 0);
|
||||
virtual ~WindowThumbnailItem();
|
||||
|
||||
qulonglong wId() const {
|
||||
return m_wId;
|
||||
}
|
||||
void setWId(qulonglong wId);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual void paint(QPainter *painter) override;
|
||||
|
||||
enum Thumbnail {
|
||||
Konqueror = 1,
|
||||
|
|
Loading…
Reference in a new issue