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 QSize dividerS{1, 16};
|
||||||
constexpr static TextFormat itemNameTF
|
constexpr static TextFormat itemNameTF
|
||||||
{Theme::Token_Text_Default, UiElement::UiElementH6};
|
{Theme::Token_Text_Default, UiElement::UiElementH6};
|
||||||
|
constexpr static TextFormat releaseStatusTF
|
||||||
|
{Theme::Token_Notification_Alert, UiElement::UiElementLabelSmall};
|
||||||
constexpr static TextFormat countTF
|
constexpr static TextFormat countTF
|
||||||
{Theme::Token_Text_Default, UiElement::UiElementLabelSmall,
|
{Theme::Token_Text_Default, UiElement::UiElementLabelSmall,
|
||||||
Qt::AlignCenter | Qt::TextDontClip};
|
Qt::AlignCenter | Qt::TextDontClip};
|
||||||
@@ -190,23 +192,23 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||||
const override
|
const override
|
||||||
{
|
{
|
||||||
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
// +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+
|
||||||
// | | | | (ExPaddingGapL) | | |
|
// | | | | (ExPaddingGapL) | | |
|
||||||
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
// | | | +----------+---------+---------------+---------+--------------+---------+-----------+ | |
|
||||||
// | | | | <itemName> |(HGapXxs)|<status>|(HGapXxs)|<checkmark>| | |
|
// | | | |<itemName>|(HGapXxs)|<releaseStatus>|(HGapXxs)|<installState>|(HGapXxs)|<checkmark>| | |
|
||||||
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
// | | | +----------+---------+---------------+---------+--------------+---------+-----------+ | |
|
||||||
// | | | | (VGapXxs) | | |
|
// | | | | (VGapXxs) | | |
|
||||||
// | | | +--------+--------+--------------+--------+--------+---------+---------+ | |
|
// | | | +---------------------+--------+--------------+--------+--------+---------+---------+ | |
|
||||||
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)| <vendor> |(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)| <vendor> |(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
||||||
// | |(50x50)| +--------+--------+--------------+--------+--------+---------+---------+ | |
|
// | |(50x50)| +---------------------+--------+--------------+--------+--------+---------+---------+ | |
|
||||||
// | | | | (VGapXxs) | | |
|
// | | | | (VGapXxs) | | |
|
||||||
// | | | +----------------------------------------------------------------------+ | |
|
// | | | +-----------------------------------------------------------------------------------+ | |
|
||||||
// | | | | <tags> | | |
|
// | | | | <tags> | | |
|
||||||
// | | | +----------------------------------------------------------------------+ | |
|
// | | | +-----------------------------------------------------------------------------------+ | |
|
||||||
// | | | | (ExPaddingGapL) | | |
|
// | | | | (ExPaddingGapL) | | |
|
||||||
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
// +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+
|
||||||
// | (gapSize) |
|
// | (gapSize) |
|
||||||
// +----------------------------------------------------------------------------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
const QRect bgRGlobal = option.rect.adjusted(0, 0, -gapSize, -gapSize);
|
const QRect bgRGlobal = option.rect.adjusted(0, 0, -gapSize, -gapSize);
|
||||||
const QRect bgR = bgRGlobal.translated(-option.rect.topLeft());
|
const QRect bgR = bgRGlobal.translated(-option.rect.topLeft());
|
||||||
@@ -290,11 +292,32 @@ public:
|
|||||||
QRect effectiveR = itemNameR;
|
QRect effectiveR = itemNameR;
|
||||||
if (showState)
|
if (showState)
|
||||||
effectiveR.setRight(stateR.left() - HGapXxs - 1);
|
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->setPen(itemNameTF.color());
|
||||||
painter->setFont(itemNameTF.font());
|
painter->setFont(itemNameTF.font());
|
||||||
const QString titleElided
|
const QString titleElided
|
||||||
= painter->fontMetrics().elidedText(itemName, Qt::ElideRight, effectiveR.width());
|
= painter->fontMetrics().elidedText(itemName, Qt::ElideRight, effectiveR.width());
|
||||||
painter->drawText(effectiveR, itemNameTF.drawTextFlags, titleElided);
|
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) {
|
if (showState) {
|
||||||
const FilePath checkmarkMask = ":/extensionmanager/images/checkmark.png";
|
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);
|
return json.value(EXTENSION_KEY_ID);
|
||||||
case RoleDateUpdated:
|
case RoleDateUpdated:
|
||||||
return QDate::fromString(json.value("updated_at").toString(), Qt::ISODate);
|
return QDate::fromString(json.value("updated_at").toString(), Qt::ISODate);
|
||||||
|
case RoleStatus:
|
||||||
|
return json.value("status");
|
||||||
case RoleTags:
|
case RoleTags:
|
||||||
return json.value("tags").toVariant().toStringList();
|
return json.value("tags").toVariant().toStringList();
|
||||||
case RoleVendor:
|
case RoleVendor:
|
||||||
@@ -338,4 +340,10 @@ PluginSpec *pluginSpecForId(const QString &pluginId)
|
|||||||
return findOrDefault(PluginManager::plugins(), equal(&PluginSpec::id, 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
|
} // ExtensionManager::Internal
|
||||||
|
@@ -42,6 +42,7 @@ enum Role {
|
|||||||
RolePlatforms,
|
RolePlatforms,
|
||||||
RolePlugins,
|
RolePlugins,
|
||||||
RoleSearchText,
|
RoleSearchText,
|
||||||
|
RoleStatus,
|
||||||
RoleTags,
|
RoleTags,
|
||||||
RoleVendor,
|
RoleVendor,
|
||||||
RoleVendorId,
|
RoleVendorId,
|
||||||
@@ -66,6 +67,7 @@ private:
|
|||||||
|
|
||||||
QString customOsTypeToString(Utils::OsType osType);
|
QString customOsTypeToString(Utils::OsType osType);
|
||||||
ExtensionSystem::PluginSpec *pluginSpecForId(const QString &pluginId);
|
ExtensionSystem::PluginSpec *pluginSpecForId(const QString &pluginId);
|
||||||
|
QString statusDisplayString(const QModelIndex &index);
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
QObject *createExtensionsModelTest();
|
QObject *createExtensionsModelTest();
|
||||||
|
Reference in New Issue
Block a user