forked from qt-creator/qt-creator
ExtensionManager: Draw icon of disabled items with less intensity
Since recently, the green background is used for enabled plugins and grey is for disabled ones. With that change comes the requirement to draw the icon for disabled icons with less intensity, to make it really appear disabled. I took this opportunity to unify the drawing of small/big enabled/ disabled pack/extension icon variants in a central helper function. Change-Id: Ia68218c774ccb8e9e7ed48620ac36f4bca0724fd Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -113,7 +113,6 @@ private:
|
||||
|
||||
class HeadingWidget : public QWidget
|
||||
{
|
||||
static constexpr QSize iconBgS{68, 68};
|
||||
static constexpr int dividerH = 16;
|
||||
|
||||
Q_OBJECT
|
||||
@@ -123,7 +122,7 @@ public:
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_icon = new QLabel;
|
||||
m_icon->setFixedSize(iconBgS);
|
||||
m_icon->setFixedSize(iconBgSizeBig);
|
||||
|
||||
static const TextFormat titleTF
|
||||
{Theme::Token_Text_Default, UiElementH4};
|
||||
@@ -200,7 +199,7 @@ public:
|
||||
if (!current.isValid())
|
||||
return;
|
||||
|
||||
m_icon->setPixmap(icon(current));
|
||||
m_icon->setPixmap(itemIcon(current, SizeBig));
|
||||
|
||||
const QString name = current.data(RoleName).toString();
|
||||
m_title->setText(name);
|
||||
@@ -236,32 +235,6 @@ signals:
|
||||
void vendorClicked(const QString &vendor);
|
||||
|
||||
private:
|
||||
static QPixmap icon(const QModelIndex &index)
|
||||
{
|
||||
const qreal dpr = qApp->devicePixelRatio();
|
||||
QPixmap pixmap(iconBgS * dpr);
|
||||
pixmap.fill(Qt::transparent);
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
const QRect bgR(QPoint(), pixmap.deviceIndependentSize().toSize());
|
||||
|
||||
QPainter p(&pixmap);
|
||||
QLinearGradient gradient(bgR.topRight(), bgR.bottomLeft());
|
||||
gradient.setStops(iconGradientStops(index));
|
||||
constexpr int iconRectRounding = 4;
|
||||
WelcomePageHelpers::drawCardBackground(&p, bgR, gradient, Qt::NoPen, iconRectRounding);
|
||||
|
||||
// Icon
|
||||
constexpr Theme::Color color = Theme::Token_Basic_White;
|
||||
static const QIcon pack = Icon({{":/extensionmanager/images/packbig.png", color}},
|
||||
Icon::Tint).icon();
|
||||
static const QIcon extension = Icon({{":/extensionmanager/images/extensionbig.png",
|
||||
color}}, Icon::Tint).icon();
|
||||
const ItemType itemType = index.data(RoleItemType).value<ItemType>();
|
||||
(itemType == ItemTypePack ? pack : extension).paint(&p, bgR);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QLabel *m_icon;
|
||||
QLabel *m_title;
|
||||
Button *m_vendor;
|
||||
|
||||
Reference in New Issue
Block a user