forked from qt-creator/qt-creator
ExtensionManager: Display extension release status
Unless "status" is "published", write the status right to the extension name. In orange. Fixes: QTCREATORBUG-31588 Change-Id: I25f3385ca27a2d3719cd360f3fc8adf6d9163a8b Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -171,6 +171,8 @@ public:
|
||||
constexpr static QSize dividerS{1, 16};
|
||||
constexpr static TextFormat itemNameTF
|
||||
{Theme::Token_Text_Default, UiElement::UiElementH6};
|
||||
constexpr static TextFormat releaseStatusTF
|
||||
{Theme::Token_Notification_Alert, UiElement::UiElementLabelSmall};
|
||||
constexpr static TextFormat countTF
|
||||
{Theme::Token_Text_Default, UiElement::UiElementLabelSmall,
|
||||
Qt::AlignCenter | Qt::TextDontClip};
|
||||
@@ -190,23 +192,23 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
const override
|
||||
{
|
||||
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
||||
// +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+
|
||||
// | | | | (ExPaddingGapL) | | |
|
||||
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
||||
// | | | | <itemName> |(HGapXxs)|<status>|(HGapXxs)|<checkmark>| | |
|
||||
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
||||
// | | | +----------+---------+---------------+---------+--------------+---------+-----------+ | |
|
||||
// | | | |<itemName>|(HGapXxs)|<releaseStatus>|(HGapXxs)|<installState>|(HGapXxs)|<checkmark>| | |
|
||||
// | | | +----------+---------+---------------+---------+--------------+---------+-----------+ | |
|
||||
// | | | | (VGapXxs) | | |
|
||||
// | | | +--------+--------+--------------+--------+--------+---------+---------+ | |
|
||||
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)|<vendor>|(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
||||
// | |(50x50)| +--------+--------+--------------+--------+--------+---------+---------+ | |
|
||||
// | | | +---------------------+--------+--------------+--------+--------+---------+---------+ | |
|
||||
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)| <vendor> |(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
||||
// | |(50x50)| +---------------------+--------+--------------+--------+--------+---------+---------+ | |
|
||||
// | | | | (VGapXxs) | | |
|
||||
// | | | +----------------------------------------------------------------------+ | |
|
||||
// | | | +-----------------------------------------------------------------------------------+ | |
|
||||
// | | | | <tags> | | |
|
||||
// | | | +----------------------------------------------------------------------+ | |
|
||||
// | | | +-----------------------------------------------------------------------------------+ | |
|
||||
// | | | | (ExPaddingGapL) | | |
|
||||
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
||||
// +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+
|
||||
// | (gapSize) |
|
||||
// +----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
// +-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
const QRect bgRGlobal = option.rect.adjusted(0, 0, -gapSize, -gapSize);
|
||||
const QRect bgR = bgRGlobal.translated(-option.rect.topLeft());
|
||||
@@ -290,11 +292,32 @@ public:
|
||||
QRect effectiveR = itemNameR;
|
||||
if (showState)
|
||||
effectiveR.setRight(stateR.left() - HGapXxs - 1);
|
||||
const QString releaseStatus = statusDisplayString(index);
|
||||
const bool showReleaseStatus = !releaseStatus.isEmpty();
|
||||
|
||||
if (showReleaseStatus) {
|
||||
const QFont releaseStatusF = releaseStatusTF.font();
|
||||
const int releaseStatusAdv =
|
||||
QFontMetrics(releaseStatusF).horizontalAdvance(releaseStatus)
|
||||
+ (showState ? ExVPaddingGapXl - HGapXxs
|
||||
: HGapXxs);
|
||||
effectiveR.setWidth(effectiveR.width() - releaseStatusAdv);
|
||||
}
|
||||
|
||||
painter->setPen(itemNameTF.color());
|
||||
painter->setFont(itemNameTF.font());
|
||||
const QString titleElided
|
||||
= painter->fontMetrics().elidedText(itemName, Qt::ElideRight, effectiveR.width());
|
||||
painter->drawText(effectiveR, itemNameTF.drawTextFlags, titleElided);
|
||||
|
||||
if (showReleaseStatus) {
|
||||
const int titleElidedAdv = painter->fontMetrics().horizontalAdvance(titleElided);
|
||||
const QRect releaseStatusR(effectiveR.x() + titleElidedAdv + HGapXxs,
|
||||
effectiveR.y(), 1, effectiveR.height() - 1);
|
||||
painter->setPen(releaseStatusTF.color());
|
||||
painter->setFont(releaseStatusTF.font());
|
||||
painter->drawText(releaseStatusR, releaseStatusTF.drawTextFlags, releaseStatus);
|
||||
}
|
||||
}
|
||||
if (showState) {
|
||||
const FilePath checkmarkMask = ":/extensionmanager/images/checkmark.png";
|
||||
|
@@ -156,6 +156,8 @@ QVariant ExtensionsModelPrivate::dataFromRemoteExtension(int index, int role) co
|
||||
return json.value(EXTENSION_KEY_ID);
|
||||
case RoleDateUpdated:
|
||||
return QDate::fromString(json.value("updated_at").toString(), Qt::ISODate);
|
||||
case RoleStatus:
|
||||
return json.value("status");
|
||||
case RoleTags:
|
||||
return json.value("tags").toVariant().toStringList();
|
||||
case RoleVendor:
|
||||
@@ -338,4 +340,10 @@ PluginSpec *pluginSpecForId(const QString &pluginId)
|
||||
return findOrDefault(PluginManager::plugins(), equal(&PluginSpec::id, pluginId));
|
||||
}
|
||||
|
||||
QString statusDisplayString(const QModelIndex &index)
|
||||
{
|
||||
const QString statusString = index.data(RoleStatus).toString();
|
||||
return statusString != "published" ? statusString : QString();
|
||||
}
|
||||
|
||||
} // ExtensionManager::Internal
|
||||
|
@@ -42,6 +42,7 @@ enum Role {
|
||||
RolePlatforms,
|
||||
RolePlugins,
|
||||
RoleSearchText,
|
||||
RoleStatus,
|
||||
RoleTags,
|
||||
RoleVendor,
|
||||
RoleVendorId,
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
|
||||
QString customOsTypeToString(Utils::OsType osType);
|
||||
ExtensionSystem::PluginSpec *pluginSpecForId(const QString &pluginId);
|
||||
QString statusDisplayString(const QModelIndex &index);
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
QObject *createExtensionsModelTest();
|
||||
|
Reference in New Issue
Block a user