From 1dc7d69e25d43d4708c70c2ea38594cacbe281ac Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 14 Oct 2024 15:01:54 +0200 Subject: [PATCH] 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 --- .../extensionmanagerwidget.cpp | 22 ++++------------ .../extensionmanager/extensionsbrowser.cpp | 25 +++++++++---------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/plugins/extensionmanager/extensionmanagerwidget.cpp b/src/plugins/extensionmanager/extensionmanagerwidget.cpp index 4550778270d..8bf7360fc80 100644 --- a/src/plugins/extensionmanager/extensionmanagerwidget.cpp +++ b/src/plugins/extensionmanager/extensionmanagerwidget.cpp @@ -147,7 +147,7 @@ public: static const TextFormat dlTF {Theme::Token_Text_Muted, vendorTF.uiElement}; static const TextFormat detailsTF - {Theme::Token_Text_Default, UiElementBody2}; + {titleTF.themeColor, Utils::StyleHelper::UiElementCaption}; m_title = tfLabel(titleTF); m_vendor = new Button({}, Button::SmallLink); @@ -229,14 +229,8 @@ public: m_dlCount->setText(QString::number(dlCount)); m_dlCountItems->setVisible(showDlCount); - const QStringList plugins = current.data(RolePlugins).toStringList(); - if (current.data(RoleItemType).toInt() == ItemTypePack) { - 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 QString description = current.data(RoleDescriptionShort).toString(); + m_details->setText(description); const ItemType itemType = current.data(RoleItemType).value(); const bool isPack = itemType == ItemTypePack; @@ -907,14 +901,8 @@ void ExtensionManagerWidget::updateView(const QModelIndex ¤t) m_currentId = current.data(RoleVendorId).toString() + "." + current.data(RoleId).toString(); { - const QStringList description = { - "# " + m_currentItemName, - current.data(RoleDescriptionShort).toString(), - "", - current.data(RoleDescriptionLong).toString() - }; - const QString descriptionMarkdown = description.join("\n"); - setMarkdown(m_description->document(), descriptionMarkdown); + const QString description = current.data(RoleDescriptionLong).toString(); + setMarkdown(m_description->document(), description); } { diff --git a/src/plugins/extensionmanager/extensionsbrowser.cpp b/src/plugins/extensionmanager/extensionsbrowser.cpp index f18bfc33aea..4e5b1ab85e8 100644 --- a/src/plugins/extensionmanager/extensionsbrowser.cpp +++ b/src/plugins/extensionmanager/extensionsbrowser.cpp @@ -181,8 +181,8 @@ public: Qt::AlignVCenter | Qt::TextDontClip}; constexpr static TextFormat stateTF {vendorTF.themeColor, UiElement::UiElementCaption, vendorTF.drawTextFlags}; - constexpr static TextFormat tagsTF - {Theme::Token_Text_Default, UiElement::UiElementCaption}; + constexpr static TextFormat descriptionTF + {itemNameTF.themeColor, UiElement::UiElementCaption}; explicit ExtensionItemDelegate(QObject *parent = nullptr) : QItemDelegate(parent) @@ -203,7 +203,7 @@ public: // | |(50x50)| +---------------------+--------+--------------+--------+--------+---------+---------+ | | // | | | | (VGapXxs) | | | // | | | +-----------------------------------------------------------------------------------+ | | - // | | | | | | | + // | | | | | | | // | | | +-----------------------------------------------------------------------------------+ | | // | | | | (ExPaddingGapL) | | | // +---------------+-------+---------------+-----------------------------------------------------------------------------------+---------------+---------+ @@ -244,9 +244,9 @@ public: QRect vendorR = vendorRowR; 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->setRenderHint(QPainter::Antialiasing); @@ -366,13 +366,12 @@ public: painter->drawText(vendorR, vendorTF.drawTextFlags, vendorElided); } { - const QStringList tagList = index.data(RoleTags).toStringList(); - const QString tags = tagList.join(", "); - painter->setPen(tagsTF.color()); - painter->setFont(tagsTF.font()); - const QString tagsElided - = painter->fontMetrics().elidedText(tags, Qt::ElideRight, tagsR.width()); - painter->drawText(tagsR, tagsTF.drawTextFlags, tagsElided); + const QString description = index.data(RoleDescriptionShort).toString(); + painter->setPen(descriptionTF.color()); + painter->setFont(descriptionTF.font()); + const QString descriptionElided = painter->fontMetrics() + .elidedText(description, Qt::ElideRight, descriptionR.width()); + painter->drawText(descriptionR, descriptionTF.drawTextFlags, descriptionElided); } painter->restore(); @@ -391,7 +390,7 @@ public: + VGapXxs + vendorRowHeight() + VGapXxs - + tagsTF.lineHeight(); + + descriptionTF.lineHeight(); const int height = ExPaddingGapL + qMax(iconBgSizeSmall.height(), middleColumnH)