Adds Inspector to Gem Repo Screen (#4242)
* Adds the gem repo screen with the UI built but with mocked data and not connected to the o3de scripts Signed-off-by: nggieber <nggieber@amazon.com> * Changed name of added to enabled, disabled define, removed unused functions Signed-off-by: nggieber <nggieber@amazon.com> * Added Repo Screen Inspector UI Signed-off-by: nggieber <nggieber@amazon.com> * Addressed minor PR feedback Signed-off-by: nggieber <nggieber@amazon.com> * Add some more minor PR changes Signed-off-by: nggieber <nggieber@amazon.com>monroegm-disable-blank-issue-2
parent
967d535464
commit
9b14d49f87
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||||
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GemRepo/GemRepoInspector.h>
|
||||||
|
#include <GemRepo/GemRepoItemDelegate.h>
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
namespace O3DE::ProjectManager
|
||||||
|
{
|
||||||
|
GemRepoInspector::GemRepoInspector(GemRepoModel* model, QWidget* parent)
|
||||||
|
: QScrollArea(parent)
|
||||||
|
, m_model(model)
|
||||||
|
{
|
||||||
|
setObjectName("gemRepoInspector");
|
||||||
|
setWidgetResizable(true);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
|
||||||
|
m_mainWidget = new QWidget();
|
||||||
|
setWidget(m_mainWidget);
|
||||||
|
|
||||||
|
m_mainLayout = new QVBoxLayout();
|
||||||
|
m_mainLayout->setMargin(15);
|
||||||
|
m_mainLayout->setAlignment(Qt::AlignTop);
|
||||||
|
m_mainWidget->setLayout(m_mainLayout);
|
||||||
|
|
||||||
|
InitMainWidget();
|
||||||
|
|
||||||
|
connect(m_model->GetSelectionModel(), &QItemSelectionModel::selectionChanged, this, &GemRepoInspector::OnSelectionChanged);
|
||||||
|
Update({});
|
||||||
|
}
|
||||||
|
|
||||||
|
void GemRepoInspector::OnSelectionChanged(const QItemSelection& selected, [[maybe_unused]] const QItemSelection& deselected)
|
||||||
|
{
|
||||||
|
const QModelIndexList selectedIndices = selected.indexes();
|
||||||
|
if (selectedIndices.empty())
|
||||||
|
{
|
||||||
|
Update({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Update(selectedIndices[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GemRepoInspector::Update(const QModelIndex& modelIndex)
|
||||||
|
{
|
||||||
|
if (!modelIndex.isValid())
|
||||||
|
{
|
||||||
|
m_mainWidget->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repo name and url link
|
||||||
|
m_nameLabel->setText(m_model->GetName(modelIndex));
|
||||||
|
m_repoLinkLabel->setText(m_model->GetRepoLink(modelIndex));
|
||||||
|
m_repoLinkLabel->SetUrl(m_model->GetRepoLink(modelIndex));
|
||||||
|
|
||||||
|
// Repo summary
|
||||||
|
m_summaryLabel->setText(m_model->GetSummary(modelIndex));
|
||||||
|
m_summaryLabel->adjustSize();
|
||||||
|
|
||||||
|
// Additional information
|
||||||
|
if (m_model->HasAdditionalInfo(modelIndex))
|
||||||
|
{
|
||||||
|
m_addInfoTitleLabel->show();
|
||||||
|
m_addInfoTextLabel->show();
|
||||||
|
|
||||||
|
m_addInfoSpacer->changeSize(0, 20, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
m_addInfoTextLabel->setText(m_model->GetAdditionalInfo(modelIndex));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_addInfoTitleLabel->hide();
|
||||||
|
m_addInfoTextLabel->hide();
|
||||||
|
|
||||||
|
m_addInfoSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Included Gems
|
||||||
|
m_includedGems->Update(tr("Included Gems"), "", m_model->GetIncludedGemNames(modelIndex));
|
||||||
|
|
||||||
|
m_mainWidget->adjustSize();
|
||||||
|
m_mainWidget->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GemRepoInspector::InitMainWidget()
|
||||||
|
{
|
||||||
|
// Repo name and url link
|
||||||
|
m_nameLabel = new QLabel();
|
||||||
|
m_nameLabel->setObjectName("gemRepoInspectorNameLabel");
|
||||||
|
m_mainLayout->addWidget(m_nameLabel);
|
||||||
|
|
||||||
|
m_repoLinkLabel = new LinkLabel(tr("Repo Url"), QUrl(""), 12, this);
|
||||||
|
m_mainLayout->addWidget(m_repoLinkLabel);
|
||||||
|
m_mainLayout->addSpacing(5);
|
||||||
|
|
||||||
|
// Repo summary
|
||||||
|
m_summaryLabel = new QLabel();
|
||||||
|
m_summaryLabel->setObjectName("gemRepoInspectorBodyLabel");
|
||||||
|
m_summaryLabel->setWordWrap(true);
|
||||||
|
m_summaryLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
m_summaryLabel->setOpenExternalLinks(true);
|
||||||
|
m_mainLayout->addWidget(m_summaryLabel);
|
||||||
|
m_mainLayout->addSpacing(20);
|
||||||
|
|
||||||
|
// Separating line
|
||||||
|
QFrame* hLine = new QFrame();
|
||||||
|
hLine->setFrameShape(QFrame::HLine);
|
||||||
|
hLine->setObjectName("horizontalSeparatingLine");
|
||||||
|
m_mainLayout->addWidget(hLine);
|
||||||
|
m_mainLayout->addSpacing(10);
|
||||||
|
|
||||||
|
// Additional information
|
||||||
|
m_addInfoTitleLabel = new QLabel();
|
||||||
|
m_addInfoTitleLabel->setObjectName("gemRepoInspectorAddInfoTitleLabel");
|
||||||
|
m_addInfoTitleLabel->setText(tr("Additional Information"));
|
||||||
|
m_mainLayout->addWidget(m_addInfoTitleLabel);
|
||||||
|
|
||||||
|
m_addInfoTextLabel = new QLabel();
|
||||||
|
m_addInfoTextLabel->setObjectName("gemRepoInspectorBodyLabel");
|
||||||
|
m_addInfoTextLabel->setWordWrap(true);
|
||||||
|
m_addInfoTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
m_addInfoTextLabel->setOpenExternalLinks(true);
|
||||||
|
m_mainLayout->addWidget(m_addInfoTextLabel);
|
||||||
|
|
||||||
|
// Conditional spacing for additional info section
|
||||||
|
m_addInfoSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding);
|
||||||
|
m_mainLayout->addSpacerItem(m_addInfoSpacer);
|
||||||
|
|
||||||
|
// Included Gems
|
||||||
|
m_includedGems = new GemsSubWidget();
|
||||||
|
m_mainLayout->addWidget(m_includedGems);
|
||||||
|
m_mainLayout->addSpacing(20);
|
||||||
|
}
|
||||||
|
} // namespace O3DE::ProjectManager
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||||
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if !defined(Q_MOC_RUN)
|
||||||
|
#include <GemRepo/GemRepoModel.h>
|
||||||
|
#include <LinkWidget.h>
|
||||||
|
#include <GemsSubWidget.h>
|
||||||
|
|
||||||
|
#include <QItemSelection>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
#include <QWidget>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||||
|
|
||||||
|
namespace O3DE::ProjectManager
|
||||||
|
{
|
||||||
|
class GemRepoInspector : public QScrollArea
|
||||||
|
{
|
||||||
|
Q_OBJECT // AUTOMOC
|
||||||
|
|
||||||
|
public : explicit GemRepoInspector(GemRepoModel* model, QWidget* parent = nullptr);
|
||||||
|
~GemRepoInspector() = default;
|
||||||
|
|
||||||
|
void Update(const QModelIndex& modelIndex);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitMainWidget();
|
||||||
|
|
||||||
|
GemRepoModel* m_model = nullptr;
|
||||||
|
QWidget* m_mainWidget = nullptr;
|
||||||
|
QVBoxLayout* m_mainLayout = nullptr;
|
||||||
|
|
||||||
|
// General info section
|
||||||
|
QLabel* m_nameLabel = nullptr;
|
||||||
|
LinkLabel* m_repoLinkLabel = nullptr;
|
||||||
|
QLabel* m_summaryLabel = nullptr;
|
||||||
|
|
||||||
|
// Additional information
|
||||||
|
QLabel* m_addInfoTitleLabel = nullptr;
|
||||||
|
QLabel* m_addInfoTextLabel = nullptr;
|
||||||
|
QSpacerItem* m_addInfoSpacer = nullptr;
|
||||||
|
|
||||||
|
// Included Gems
|
||||||
|
GemsSubWidget* m_includedGems = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace O3DE::ProjectManager
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||||
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GemsSubWidget.h>
|
||||||
|
#include <TagWidget.h>
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
namespace O3DE::ProjectManager
|
||||||
|
{
|
||||||
|
GemsSubWidget::GemsSubWidget(QWidget* parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
m_layout = new QVBoxLayout();
|
||||||
|
m_layout->setAlignment(Qt::AlignTop);
|
||||||
|
m_layout->setMargin(0);
|
||||||
|
setLayout(m_layout);
|
||||||
|
|
||||||
|
m_titleLabel = new QLabel();
|
||||||
|
m_titleLabel->setObjectName("gemSubWidgetTitleLabel");
|
||||||
|
m_layout->addWidget(m_titleLabel);
|
||||||
|
|
||||||
|
m_textLabel = new QLabel();
|
||||||
|
m_textLabel->setObjectName("gemSubWidgetTextLabel");
|
||||||
|
m_textLabel->setWordWrap(true);
|
||||||
|
m_layout->addWidget(m_textLabel);
|
||||||
|
|
||||||
|
m_tagWidget = new TagContainerWidget();
|
||||||
|
m_layout->addWidget(m_tagWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GemsSubWidget::Update(const QString& title, const QString& text, const QStringList& gemNames)
|
||||||
|
{
|
||||||
|
m_titleLabel->setText(title);
|
||||||
|
m_textLabel->setText(text);
|
||||||
|
m_tagWidget->Update(gemNames);
|
||||||
|
}
|
||||||
|
} // namespace O3DE::ProjectManager
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||||
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if !defined(Q_MOC_RUN)
|
||||||
|
#include <QWidget>
|
||||||
|
#include <TagWidget.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||||
|
|
||||||
|
namespace O3DE::ProjectManager
|
||||||
|
{
|
||||||
|
// Title, description and tag widget container used for the depending and conflicting gems
|
||||||
|
class GemsSubWidget
|
||||||
|
: public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GemsSubWidget(QWidget* parent = nullptr);
|
||||||
|
void Update(const QString& title, const QString& text, const QStringList& gemNames);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel* m_titleLabel = nullptr;
|
||||||
|
QLabel* m_textLabel = nullptr;
|
||||||
|
QVBoxLayout* m_layout = nullptr;
|
||||||
|
TagContainerWidget* m_tagWidget = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace O3DE::ProjectManager
|
||||||
Loading…
Reference in New Issue