ExtensionManager: Change position of the short description

The short description is currently shown as initial part of the
description, followed by the long description.

With this change, the long description is shown by its own. And the
short description moves to other places: on the bottom of the card
(replacing the tags) and on the bottom of the details-top element.

Fixes: QTCREATORBUG-31813
Change-Id: I927573b9699ad830896fdebec4077aadf2df7b9e
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Alessandro Portale
2024-10-14 15:01:54 +02:00
parent 9f08d874b6
commit 1dc7d69e25
2 changed files with 17 additions and 30 deletions

View File

@@ -147,7 +147,7 @@ public:
static const TextFormat dlTF static const TextFormat dlTF
{Theme::Token_Text_Muted, vendorTF.uiElement}; {Theme::Token_Text_Muted, vendorTF.uiElement};
static const TextFormat detailsTF static const TextFormat detailsTF
{Theme::Token_Text_Default, UiElementBody2}; {titleTF.themeColor, Utils::StyleHelper::UiElementCaption};
m_title = tfLabel(titleTF); m_title = tfLabel(titleTF);
m_vendor = new Button({}, Button::SmallLink); m_vendor = new Button({}, Button::SmallLink);
@@ -229,14 +229,8 @@ public:
m_dlCount->setText(QString::number(dlCount)); m_dlCount->setText(QString::number(dlCount));
m_dlCountItems->setVisible(showDlCount); m_dlCountItems->setVisible(showDlCount);
const QStringList plugins = current.data(RolePlugins).toStringList(); const QString description = current.data(RoleDescriptionShort).toString();
if (current.data(RoleItemType).toInt() == ItemTypePack) { m_details->setText(description);
const int pluginsCount = plugins.count();
const QString details = Tr::tr("Pack contains %n plugins.", nullptr, pluginsCount);
m_details->setText(details);
} else {
m_details->setText({});
}
const ItemType itemType = current.data(RoleItemType).value<ItemType>(); const ItemType itemType = current.data(RoleItemType).value<ItemType>();
const bool isPack = itemType == ItemTypePack; const bool isPack = itemType == ItemTypePack;
@@ -907,14 +901,8 @@ void ExtensionManagerWidget::updateView(const QModelIndex &current)
m_currentId = current.data(RoleVendorId).toString() + "." + current.data(RoleId).toString(); m_currentId = current.data(RoleVendorId).toString() + "." + current.data(RoleId).toString();
{ {
const QStringList description = { const QString description = current.data(RoleDescriptionLong).toString();
"# " + m_currentItemName, setMarkdown(m_description->document(), description);
current.data(RoleDescriptionShort).toString(),
"",
current.data(RoleDescriptionLong).toString()
};
const QString descriptionMarkdown = description.join("\n");
setMarkdown(m_description->document(), descriptionMarkdown);
} }
{ {

View File

@@ -181,8 +181,8 @@ public:
Qt::AlignVCenter | Qt::TextDontClip}; Qt::AlignVCenter | Qt::TextDontClip};
constexpr static TextFormat stateTF constexpr static TextFormat stateTF
{vendorTF.themeColor, UiElement::UiElementCaption, vendorTF.drawTextFlags}; {vendorTF.themeColor, UiElement::UiElementCaption, vendorTF.drawTextFlags};
constexpr static TextFormat tagsTF constexpr static TextFormat descriptionTF
{Theme::Token_Text_Default, UiElement::UiElementCaption}; {itemNameTF.themeColor, UiElement::UiElementCaption};
explicit ExtensionItemDelegate(QObject *parent = nullptr) explicit ExtensionItemDelegate(QObject *parent = nullptr)
: QItemDelegate(parent) : QItemDelegate(parent)
@@ -203,7 +203,7 @@ public:
// | |(50x50)| +---------------------+--------+--------------+--------+--------+---------+---------+ | | // | |(50x50)| +---------------------+--------+--------------+--------+--------+---------+---------+ | |
// | | | | (VGapXxs) | | | // | | | | (VGapXxs) | | |
// | | | +-----------------------------------------------------------------------------------+ | | // | | | +-----------------------------------------------------------------------------------+ | |
// | | | | <tags> | | | // | | | | <shortDescription> | | |
// | | | +-----------------------------------------------------------------------------------+ | | // | | | +-----------------------------------------------------------------------------------+ | |
// | | | | (ExPaddingGapL) | | | // | | | | (ExPaddingGapL) | | |
// +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+ // +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+
@@ -244,9 +244,9 @@ public:
QRect vendorR = vendorRowR; QRect vendorR = vendorRowR;
y += vendorRowR.height() + VGapXxs; y += vendorRowR.height() + VGapXxs;
const QRect tagsR(x, y, middleColumnW, tagsTF.lineHeight()); const QRect descriptionR(x, y, middleColumnW, descriptionTF.lineHeight());
QTC_CHECK(option.rect.height() - 1 == tagsR.bottom() + ExPaddingGapL + gapSize); QTC_CHECK(option.rect.height() - 1 == descriptionR.bottom() + ExPaddingGapL + gapSize);
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);
@@ -366,13 +366,12 @@ public:
painter->drawText(vendorR, vendorTF.drawTextFlags, vendorElided); painter->drawText(vendorR, vendorTF.drawTextFlags, vendorElided);
} }
{ {
const QStringList tagList = index.data(RoleTags).toStringList(); const QString description = index.data(RoleDescriptionShort).toString();
const QString tags = tagList.join(", "); painter->setPen(descriptionTF.color());
painter->setPen(tagsTF.color()); painter->setFont(descriptionTF.font());
painter->setFont(tagsTF.font()); const QString descriptionElided = painter->fontMetrics()
const QString tagsElided .elidedText(description, Qt::ElideRight, descriptionR.width());
= painter->fontMetrics().elidedText(tags, Qt::ElideRight, tagsR.width()); painter->drawText(descriptionR, descriptionTF.drawTextFlags, descriptionElided);
painter->drawText(tagsR, tagsTF.drawTextFlags, tagsElided);
} }
painter->restore(); painter->restore();
@@ -391,7 +390,7 @@ public:
+ VGapXxs + VGapXxs
+ vendorRowHeight() + vendorRowHeight()
+ VGapXxs + VGapXxs
+ tagsTF.lineHeight(); + descriptionTF.lineHeight();
const int height = const int height =
ExPaddingGapL ExPaddingGapL
+ qMax(iconBgSizeSmall.height(), middleColumnH) + qMax(iconBgSizeSmall.height(), middleColumnH)