Wizards: scale smaller icons if necessary

Change-Id: I26b51668b1f2d1be1b96e43bbc42f49d39249e83
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tim Jenssen
2017-07-17 12:30:15 +02:00
parent 3be1af37e6
commit 1646510ffa

View File

@@ -91,6 +91,21 @@ public:
return true;
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
{
if (role == Qt::DecorationRole) {
// scale too small icons to have one size for all
QIcon icon = qvariant_cast<QIcon>(QSortFilterProxyModel::data(index, role));
if (!icon.isNull()) {
QPixmap pixmap(icon.pixmap(ICON_SIZE, ICON_SIZE));
if (pixmap.size() != QSize(ICON_SIZE, ICON_SIZE))
return pixmap.scaled(ICON_SIZE, ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
}
return QSortFilterProxyModel::data(index, role);
}
private:
Core::Id m_platform;
};