[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.
This commit is contained in:
parent
7e2157bfe4
commit
fc21f99df6
3 changed files with 0 additions and 75 deletions
|
@ -249,7 +249,6 @@ set(kwin_KDE_LIBS
|
|||
KF5::KCoreAddons
|
||||
KF5::KCrash
|
||||
KF5::KI18n
|
||||
KF5::KIconThemes
|
||||
KF5::KNotifications
|
||||
KF5::KService
|
||||
KF5::Plasma
|
||||
|
|
|
@ -34,8 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QtCore/QStandardPaths>
|
||||
|
||||
// include KDE
|
||||
#include <KDE/KIconEffect>
|
||||
#include <KDE/KIconLoader>
|
||||
#include <KDE/KServiceTypeTrader>
|
||||
#include <KDE/Plasma/FrameSvg>
|
||||
#include <KDE/Plasma/Theme>
|
||||
|
@ -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<void *>());
|
||||
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();
|
||||
|
|
|
@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef KWIN_TABBOX_DECLARATIVE_H
|
||||
#define KWIN_TABBOX_DECLARATIVE_H
|
||||
// includes
|
||||
#include <QQuickImageProvider>
|
||||
#include <QQuickView>
|
||||
#include <KDE/KService>
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue