From fc21f99df6a3547d64bf5a658755742c2726372c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 6 Dec 2013 16:23:22 +0100 Subject: [PATCH] [kwin] Remove the image provider for the TabBox No longer needed as we have the icon passed to QML. A nice side-effect: we don't need KIconThemes in KWin any more. --- CMakeLists.txt | 1 - tabbox/declarative.cpp | 63 ------------------------------------------ tabbox/declarative.h | 11 -------- 3 files changed, 75 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf59a18d73..c76939c137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,6 @@ set(kwin_KDE_LIBS KF5::KCoreAddons KF5::KCrash KF5::KI18n - KF5::KIconThemes KF5::KNotifications KF5::KService KF5::Plasma diff --git a/tabbox/declarative.cpp b/tabbox/declarative.cpp index 4d7f1cfcda..37b8806112 100644 --- a/tabbox/declarative.cpp +++ b/tabbox/declarative.cpp @@ -34,8 +34,6 @@ along with this program. If not, see . #include // include KDE -#include -#include #include #include #include @@ -53,66 +51,6 @@ namespace KWin namespace TabBox { -ImageProvider::ImageProvider(QAbstractItemModel *model) - : QQuickImageProvider(QQuickImageProvider::Pixmap) - , m_model(model) -{ -} - -QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) -{ - bool ok = false; - QStringList parts = id.split(QStringLiteral("/")); - const int row = parts.first().toInt(&ok); - if (!ok) { - return QPixmap(); - } - QModelIndex parentIndex; - const int parentRow = parts.at(1).toInt(&ok); - if (ok) { - // we have parent index - parentIndex = m_model->index(parentRow, 0); - if (!parentIndex.isValid()) { - return QPixmap(); - } - } - const QModelIndex index = m_model->index(row, 0, parentIndex); - if (!index.isValid()) { - return QPixmap(); - } - TabBoxClient* client = static_cast< TabBoxClient* >(index.model()->data(index, ClientModel::ClientRole).value()); - if (!client) { - return QPixmap(); - } - - QSize s(32, 32); - if (requestedSize.isValid()) { - s = requestedSize; - } - *size = s; - QPixmap icon = client->icon().pixmap(s); - if (s.width() > icon.width() || s.height() > icon.height()) { - // icon is smaller than what we requested - QML would scale it which looks bad - QPixmap temp(s); - temp.fill(Qt::transparent); - QPainter p(&temp); - p.drawPixmap(s.width()/2 - icon.width()/2, s.height()/2 - icon.height()/2, icon); - icon = temp; - } - if (parts.size() > 2) { - KIconEffect *effect = KIconLoader::global()->iconEffect(); - KIconLoader::States state = KIconLoader::DefaultState; - if (parts.last() == QLatin1String("selected")) { - state = KIconLoader::ActiveState; - } else if (parts.last() == QLatin1String("disabled")) { - state = KIconLoader::DisabledState; - } - icon = effect->apply(icon, KIconLoader::Desktop, state); - } - return icon; -} - - DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QQuickWindow *parent) : QQuickView(parent) , m_model(model) @@ -130,7 +68,6 @@ DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBox } else { setResizeMode(QQuickView::SizeViewToRootObject); } - engine()->addImageProvider(QLatin1String("client"), new ImageProvider(model)); KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); diff --git a/tabbox/declarative.h b/tabbox/declarative.h index bfcdd18588..33387ae2b9 100644 --- a/tabbox/declarative.h +++ b/tabbox/declarative.h @@ -20,7 +20,6 @@ along with this program. If not, see . #ifndef KWIN_TABBOX_DECLARATIVE_H #define KWIN_TABBOX_DECLARATIVE_H // includes -#include #include #include #include "tabboxconfig.h" @@ -40,16 +39,6 @@ namespace KWin namespace TabBox { -class ImageProvider : public QQuickImageProvider -{ -public: - explicit ImageProvider(QAbstractItemModel *model); - virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); - -private: - QAbstractItemModel *m_model; -}; - class DeclarativeView : public QQuickView { Q_OBJECT