Display Gem Icons in Gem Catalog (#7294)

Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com>

Co-authored-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
AMZN-nggieber
2022-01-31 17:06:06 -08:00
committed by GitHub
parent e1c7dce7a7
commit f5fcab75d6
70 changed files with 205 additions and 79 deletions
@@ -10,6 +10,7 @@
#include <GemCatalog/GemModel.h>
#include <GemCatalog/GemSortFilterProxyModel.h>
#include <AdjustableHeaderWidget.h>
#include <ProjectManagerDefs.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
@@ -25,6 +26,7 @@
#include <QDesktopServices>
#include <QMovie>
#include <QHeaderView>
#include <QDir>
namespace O3DE::ProjectManager
{
@@ -117,18 +119,27 @@ namespace O3DE::ProjectManager
painter->restore();
}
// Gem preview
QString previewPath = QDir(GemModel::GetPath(modelIndex)).filePath(ProjectPreviewImagePath);
QPixmap gemPreviewImage(previewPath);
QRect gemPreviewRect(
contentRect.left() + AdjustableHeaderWidget::s_headerTextIndent,
contentRect.center().y() - GemPreviewImageHeight / 2,
GemPreviewImageWidth, GemPreviewImageHeight);
painter->drawPixmap(gemPreviewRect, gemPreviewImage);
// Gem name
QString gemName = GemModel::GetDisplayName(modelIndex);
QFont gemNameFont(options.font);
QPair<int, int> nameXBounds = CalcColumnXBounds(HeaderOrder::Name);
const int nameStartX = nameXBounds.first;
const int firstColumnTextStartX = s_itemMargins.left() + nameStartX + AdjustableHeaderWidget::s_headerTextIndent;
const int firstColumnMaxTextWidth = nameXBounds.second - nameStartX - AdjustableHeaderWidget::s_headerTextIndent;
const int nameColumnTextStartX = s_itemMargins.left() + nameStartX + AdjustableHeaderWidget::s_headerTextIndent;
const int nameColumnMaxTextWidth = nameXBounds.second - nameStartX - AdjustableHeaderWidget::s_headerTextIndent;
gemNameFont.setPixelSize(static_cast<int>(s_gemNameFontSize));
gemNameFont.setBold(true);
gemName = QFontMetrics(gemNameFont).elidedText(gemName, Qt::TextElideMode::ElideRight, firstColumnMaxTextWidth);
gemName = QFontMetrics(gemNameFont).elidedText(gemName, Qt::TextElideMode::ElideRight, nameColumnMaxTextWidth);
QRect gemNameRect = GetTextRect(gemNameFont, gemName, s_gemNameFontSize);
gemNameRect.moveTo(firstColumnTextStartX, contentRect.top());
gemNameRect.moveTo(nameColumnTextStartX, contentRect.top());
painter->setFont(gemNameFont);
painter->setPen(m_textColor);
gemNameRect = painter->boundingRect(gemNameRect, Qt::TextSingleLine, gemName);
@@ -136,9 +147,9 @@ namespace O3DE::ProjectManager
// Gem creator
QString gemCreator = GemModel::GetCreator(modelIndex);
gemCreator = standardFontMetrics.elidedText(gemCreator, Qt::TextElideMode::ElideRight, firstColumnMaxTextWidth);
gemCreator = standardFontMetrics.elidedText(gemCreator, Qt::TextElideMode::ElideRight, nameColumnMaxTextWidth);
QRect gemCreatorRect = GetTextRect(standardFont, gemCreator, s_fontSize);
gemCreatorRect.moveTo(firstColumnTextStartX, contentRect.top() + gemNameRect.height());
gemCreatorRect.moveTo(nameColumnTextStartX, contentRect.top() + gemNameRect.height());
painter->setFont(standardFont);
gemCreatorRect = painter->boundingRect(gemCreatorRect, Qt::TextSingleLine, gemCreator);
@@ -161,7 +172,7 @@ namespace O3DE::ProjectManager
QRect GemItemDelegate::CalcSummaryRect(const QRect& contentRect, bool hasTags) const
{
const int featureTagAreaHeight = 30;
const int featureTagAreaHeight = 40;
const int summaryHeight = contentRect.height() - (hasTags * featureTagAreaHeight);
const auto [summaryStartX, summaryEndX] = CalcColumnXBounds(HeaderOrder::Summary);
@@ -316,7 +327,7 @@ namespace O3DE::ProjectManager
QRect GemItemDelegate::CalcButtonRect(const QRect& contentRect) const
{
const QPoint topLeft = QPoint(
const QPoint topLeft = QPoint(
s_itemMargins.left() + CalcColumnXBounds(HeaderOrder::Status).first + AdjustableHeaderWidget::s_headerTextIndent + s_statusIconSize +
s_statusButtonSpacing,
contentRect.center().y() - s_buttonHeight / 2);
@@ -327,7 +338,7 @@ namespace O3DE::ProjectManager
void GemItemDelegate::DrawPlatformIcons(QPainter* painter, const QRect& contentRect, const QModelIndex& modelIndex) const
{
const GemInfo::Platforms platforms = GemModel::GetPlatforms(modelIndex);
int startX = 0;
int startX = s_itemMargins.left() + CalcColumnXBounds(HeaderOrder::Name).first + AdjustableHeaderWidget::s_headerTextIndent;
// Iterate and draw the platforms in the order they are defined in the enum.
for (int i = 0; i < GemInfo::NumPlatforms; ++i)
@@ -453,7 +464,7 @@ namespace O3DE::ProjectManager
}
else
{
circleCenter = buttonRect.center() + QPoint(-buttonRect.width() / 2 + s_buttonBorderRadius, 1);
circleCenter = buttonRect.center() + QPoint(-buttonRect.width() / 2 + s_buttonBorderRadius + 1, 1);
}
// Rounded rect