Merge pull request #4351 from aws-lumberyard-dev/Prism/AddRepoDialog
Add Add Gem Repo Dialog
This commit is contained in:
@@ -568,17 +568,20 @@ QProgressBar::chunk {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#gemRepoNoReposLabel {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#gemRepoHeaderRefreshButton {
|
||||
background-color: transparent;
|
||||
qproperty-flat: true;
|
||||
qproperty-iconSize: 14px;
|
||||
}
|
||||
|
||||
#gemRepoHeaderAddButton {
|
||||
#gemRepoAddButton {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #888888, stop: 1.0 #555555);
|
||||
qproperty-flat: true;
|
||||
margin-right:30px;
|
||||
min-width:120px;
|
||||
max-width:120px;
|
||||
min-height:24px;
|
||||
@@ -588,11 +591,11 @@ QProgressBar::chunk {
|
||||
font-size:12px;
|
||||
font-weight:600;
|
||||
}
|
||||
#gemRepoHeaderAddButton:hover {
|
||||
#gemRepoAddButton:hover {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #999999, stop: 1.0 #666666);
|
||||
}
|
||||
#gemRepoHeaderAddButton:pressed {
|
||||
#gemRepoAddButton:pressed {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #555555, stop: 1.0 #777777);
|
||||
}
|
||||
@@ -610,6 +613,14 @@ QProgressBar::chunk {
|
||||
background: #444444;
|
||||
}
|
||||
|
||||
#gemRepoAddDialogInstructionTitleLabel {
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
#addGemRepoDialog #formFrame {
|
||||
margin-left:0px;
|
||||
}
|
||||
|
||||
/************** Gem Repo Inspector **************/
|
||||
|
||||
#gemRepoInspectorNameLabel {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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/GemRepoAddDialog.h>
|
||||
#include <FormLineEditWidget.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
GemRepoAddDialog::GemRepoAddDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Add a User Repository"));
|
||||
setModal(true);
|
||||
setObjectName("addGemRepoDialog");
|
||||
|
||||
QVBoxLayout* vLayout = new QVBoxLayout();
|
||||
vLayout->setContentsMargins(30, 30, 25, 10);
|
||||
vLayout->setSpacing(0);
|
||||
setLayout(vLayout);
|
||||
|
||||
QLabel* instructionTitleLabel = new QLabel(tr("Enter a valid path to add a new user repository"));
|
||||
instructionTitleLabel->setObjectName("gemRepoAddDialogInstructionTitleLabel");
|
||||
instructionTitleLabel->setAlignment(Qt::AlignLeft);
|
||||
vLayout->addWidget(instructionTitleLabel);
|
||||
|
||||
vLayout->addSpacing(10);
|
||||
|
||||
QLabel* instructionContextLabel = new QLabel(tr("The path can be a Repository URL or a Local Path in your directory."));
|
||||
instructionContextLabel->setAlignment(Qt::AlignLeft);
|
||||
vLayout->addWidget(instructionContextLabel);
|
||||
|
||||
m_repoPath = new FormLineEditWidget(tr("Repository Path"), "", this);
|
||||
m_repoPath->setFixedWidth(600);
|
||||
vLayout->addWidget(m_repoPath);
|
||||
|
||||
vLayout->addSpacing(40);
|
||||
|
||||
QDialogButtonBox* dialogButtons = new QDialogButtonBox();
|
||||
dialogButtons->setObjectName("footer");
|
||||
vLayout->addWidget(dialogButtons);
|
||||
|
||||
QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
|
||||
cancelButton->setProperty("secondary", true);
|
||||
QPushButton* applyButton = dialogButtons->addButton(tr("Add"), QDialogButtonBox::ApplyRole);
|
||||
|
||||
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
|
||||
connect(applyButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
}
|
||||
|
||||
QString GemRepoAddDialog::GetRepoPath()
|
||||
{
|
||||
return m_repoPath->lineEdit()->text();
|
||||
}
|
||||
} // namespace O3DE::ProjectManager
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 <QDialog>
|
||||
#endif
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
QT_FORWARD_DECLARE_CLASS(FormLineEditWidget)
|
||||
|
||||
class GemRepoAddDialog
|
||||
: public QDialog
|
||||
{
|
||||
public:
|
||||
explicit GemRepoAddDialog(QWidget* parent = nullptr);
|
||||
~GemRepoAddDialog() = default;
|
||||
|
||||
QString GetRepoPath();
|
||||
|
||||
private:
|
||||
FormLineEditWidget* m_repoPath = nullptr;
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <GemRepo/GemRepoItemDelegate.h>
|
||||
#include <GemRepo/GemRepoListView.h>
|
||||
#include <GemRepo/GemRepoModel.h>
|
||||
#include <GemRepo/GemRepoAddDialog.h>
|
||||
#include <GemRepo/GemRepoInspector.h>
|
||||
#include <PythonBindingsInterface.h>
|
||||
|
||||
@@ -21,6 +22,8 @@
|
||||
#include <QLabel>
|
||||
#include <QHeaderView>
|
||||
#include <QTableWidget>
|
||||
#include <QFrame>
|
||||
#include <QStackedWidget>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -34,11 +37,135 @@ namespace O3DE::ProjectManager
|
||||
vLayout->setSpacing(0);
|
||||
setLayout(vLayout);
|
||||
|
||||
m_contentStack = new QStackedWidget(this);
|
||||
|
||||
m_noRepoContent = CreateNoReposContent();
|
||||
m_contentStack->addWidget(m_noRepoContent);
|
||||
|
||||
m_repoContent = CreateReposContent();
|
||||
m_contentStack->addWidget(m_repoContent);
|
||||
|
||||
vLayout->addWidget(m_contentStack);
|
||||
|
||||
Reinit();
|
||||
}
|
||||
|
||||
void GemRepoScreen::Reinit()
|
||||
{
|
||||
m_gemRepoModel->clear();
|
||||
FillModel();
|
||||
|
||||
// If model contains any data show the repos
|
||||
if (m_gemRepoModel->rowCount())
|
||||
{
|
||||
m_contentStack->setCurrentWidget(m_repoContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_contentStack->setCurrentWidget(m_noRepoContent);
|
||||
}
|
||||
|
||||
// Select the first entry after everything got correctly sized
|
||||
QTimer::singleShot(200, [=]{
|
||||
QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0);
|
||||
m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect);
|
||||
});
|
||||
}
|
||||
|
||||
void GemRepoScreen::HandleAddRepoButton()
|
||||
{
|
||||
GemRepoAddDialog* repoAddDialog = new GemRepoAddDialog(this);
|
||||
|
||||
if (repoAddDialog->exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
QString repoUrl = repoAddDialog->GetRepoPath();
|
||||
if (repoUrl.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::string> addGemRepoResult = PythonBindingsInterface::Get()->AddGemRepo(repoUrl);
|
||||
if (addGemRepoResult.IsSuccess())
|
||||
{
|
||||
Reinit();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, tr("Operation failed"),
|
||||
QString("Failed to add gem repo: %1.<br>Error:<br>%2").arg(repoUrl, addGemRepoResult.GetError().c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GemRepoScreen::FillModel()
|
||||
{
|
||||
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
|
||||
if (allGemRepoInfosResult.IsSuccess())
|
||||
{
|
||||
// Add all available repos to the model
|
||||
const QVector<GemRepoInfo> allGemRepoInfos = allGemRepoInfosResult.GetValue();
|
||||
for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos)
|
||||
{
|
||||
m_gemRepoModel->AddGemRepo(gemRepoInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.<br>Error:<br>%2").arg(allGemRepoInfosResult.GetError().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
QFrame* GemRepoScreen::CreateNoReposContent()
|
||||
{
|
||||
QFrame* contentFrame = new QFrame(this);
|
||||
|
||||
QVBoxLayout* vLayout = new QVBoxLayout();
|
||||
vLayout->setAlignment(Qt::AlignHCenter);
|
||||
vLayout->setMargin(0);
|
||||
vLayout->setSpacing(0);
|
||||
contentFrame->setLayout(vLayout);
|
||||
|
||||
vLayout->addStretch();
|
||||
|
||||
QLabel* noRepoLabel = new QLabel(tr("No repositories have been added yet."), this);
|
||||
noRepoLabel->setObjectName("gemRepoNoReposLabel");
|
||||
vLayout->addWidget(noRepoLabel);
|
||||
vLayout->setAlignment(noRepoLabel, Qt::AlignHCenter);
|
||||
|
||||
vLayout->addSpacing(20);
|
||||
|
||||
// Size hint for button is wrong so horizontal layout with stretch is used to center it
|
||||
QHBoxLayout* hLayout = new QHBoxLayout();
|
||||
hLayout->setMargin(0);
|
||||
hLayout->setSpacing(0);
|
||||
|
||||
hLayout->addStretch();
|
||||
|
||||
QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this);
|
||||
addRepoButton->setObjectName("gemRepoAddButton");
|
||||
addRepoButton->setMinimumWidth(120);
|
||||
hLayout->addWidget(addRepoButton);
|
||||
|
||||
connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton);
|
||||
|
||||
hLayout->addStretch();
|
||||
|
||||
vLayout->addLayout(hLayout);
|
||||
|
||||
vLayout->addStretch();
|
||||
|
||||
return contentFrame;
|
||||
}
|
||||
|
||||
QFrame* GemRepoScreen::CreateReposContent()
|
||||
{
|
||||
QFrame* contentFrame = new QFrame(this);
|
||||
|
||||
QHBoxLayout* hLayout = new QHBoxLayout();
|
||||
hLayout->setMargin(0);
|
||||
hLayout->setSpacing(0);
|
||||
contentFrame->setLayout(hLayout);
|
||||
|
||||
hLayout->addSpacing(60);
|
||||
|
||||
QVBoxLayout* middleVLayout = new QVBoxLayout();
|
||||
@@ -63,9 +190,13 @@ namespace O3DE::ProjectManager
|
||||
|
||||
topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
m_AddRepoButton = new QPushButton(tr("Add Repository"), this);
|
||||
m_AddRepoButton->setObjectName("gemRepoHeaderAddButton");
|
||||
topMiddleHLayout->addWidget(m_AddRepoButton);
|
||||
QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this);
|
||||
addRepoButton->setObjectName("gemRepoAddButton");
|
||||
topMiddleHLayout->addWidget(addRepoButton);
|
||||
|
||||
connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton);
|
||||
|
||||
topMiddleHLayout->addSpacing(30);
|
||||
|
||||
middleVLayout->addLayout(topMiddleHLayout);
|
||||
|
||||
@@ -105,37 +236,7 @@ namespace O3DE::ProjectManager
|
||||
m_gemRepoInspector->setFixedWidth(240);
|
||||
hLayout->addWidget(m_gemRepoInspector);
|
||||
|
||||
Reinit();
|
||||
}
|
||||
|
||||
void GemRepoScreen::Reinit()
|
||||
{
|
||||
m_gemRepoModel->clear();
|
||||
FillModel();
|
||||
|
||||
// Select the first entry after everything got correctly sized
|
||||
QTimer::singleShot(200, [=]{
|
||||
QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0);
|
||||
m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect);
|
||||
});
|
||||
}
|
||||
|
||||
void GemRepoScreen::FillModel()
|
||||
{
|
||||
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
|
||||
if (allGemRepoInfosResult.IsSuccess())
|
||||
{
|
||||
// Add all available repos to the model
|
||||
const QVector<GemRepoInfo> allGemRepoInfos = allGemRepoInfosResult.GetValue();
|
||||
for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos)
|
||||
{
|
||||
m_gemRepoModel->AddGemRepo(gemRepoInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, tr("Operation failed"), tr("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str()));
|
||||
}
|
||||
return contentFrame;
|
||||
}
|
||||
|
||||
ProjectManagerScreen GemRepoScreen::GetScreenEnum()
|
||||
|
||||
@@ -16,6 +16,8 @@ QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QHeaderView)
|
||||
QT_FORWARD_DECLARE_CLASS(QTableWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QFrame)
|
||||
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -35,8 +37,17 @@ namespace O3DE::ProjectManager
|
||||
|
||||
GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; }
|
||||
|
||||
public slots:
|
||||
void HandleAddRepoButton();
|
||||
|
||||
private:
|
||||
void FillModel();
|
||||
QFrame* CreateNoReposContent();
|
||||
QFrame* CreateReposContent();
|
||||
|
||||
QStackedWidget* m_contentStack = nullptr;
|
||||
QFrame* m_noRepoContent;
|
||||
QFrame* m_repoContent;
|
||||
|
||||
QTableWidget* m_gemRepoHeaderTable = nullptr;
|
||||
QHeaderView* m_gemRepoListHeader = nullptr;
|
||||
@@ -46,6 +57,5 @@ namespace O3DE::ProjectManager
|
||||
|
||||
QLabel* m_lastAllUpdateLabel;
|
||||
QPushButton* m_AllUpdateButton;
|
||||
QPushButton* m_AddRepoButton;
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -921,6 +921,13 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::string> PythonBindings::AddGemRepo(const QString& repoUri)
|
||||
{
|
||||
// o3de scripts need method added
|
||||
(void)repoUri;
|
||||
return AZ::Failure<AZStd::string>("Adding Gem Repo not implemented yet in o3de scripts.");
|
||||
}
|
||||
|
||||
GemRepoInfo PythonBindings::GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath)
|
||||
{
|
||||
/* Placeholder Logic */
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace O3DE::ProjectManager
|
||||
AZ::Outcome<QVector<ProjectTemplateInfo>> GetProjectTemplates(const QString& projectPath = {}) override;
|
||||
|
||||
// Gem Repos
|
||||
AZ::Outcome<void, AZStd::string> AddGemRepo(const QString& repoUri) override;
|
||||
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> GetAllGemRepoInfos() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -160,6 +160,13 @@ namespace O3DE::ProjectManager
|
||||
|
||||
// Gem Repos
|
||||
|
||||
/**
|
||||
* A gem repo to engine. Registers this gem repo with the current engine.
|
||||
* @param repoUri the absolute filesystem path or url to the gem repo manifest file.
|
||||
* @return An outcome with the success flag as well as an error message in case of a failure.
|
||||
*/
|
||||
virtual AZ::Outcome<void, AZStd::string> AddGemRepo(const QString& repoUri) = 0;
|
||||
|
||||
/**
|
||||
* Get all available gem repo infos. Gathers all repos registered with the engine.
|
||||
* @return A list of gem repo infos.
|
||||
|
||||
@@ -104,6 +104,8 @@ set(FILES
|
||||
Source/GemCatalog/GemSortFilterProxyModel.cpp
|
||||
Source/GemRepo/GemRepoScreen.h
|
||||
Source/GemRepo/GemRepoScreen.cpp
|
||||
Source/GemRepo/GemRepoAddDialog.h
|
||||
Source/GemRepo/GemRepoAddDialog.cpp
|
||||
Source/GemRepo/GemRepoInfo.h
|
||||
Source/GemRepo/GemRepoInfo.cpp
|
||||
Source/GemRepo/GemRepoInspector.h
|
||||
|
||||
Reference in New Issue
Block a user