Add Add Gem Repo Dialog

Signed-off-by: nggieber <nggieber@amazon.com>
monroegm-disable-blank-issue-2
nggieber 4 years ago
parent e76ed67e95
commit 536ef46e2b

@ -600,3 +600,7 @@ QProgressBar::chunk {
#gemRepoInspector { #gemRepoInspector {
background: #444444; background: #444444;
} }
#gemRepoAddDialogInstructionTitleLabel {
font-size:14px;
}

@ -7,12 +7,74 @@
*/ */
#include <GemRepo/GemRepoAddDialog.h> #include <GemRepo/GemRepoAddDialog.h>
#include <FormLineEditWidget.h>
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit.h>
#include <QPushButton>
namespace O3DE::ProjectManager namespace O3DE::ProjectManager
{ {
GemRepoAddDialog::GemRepoAddDialog(QWidget* parent) GemRepoAddDialog::GemRepoAddDialog(QWidget* parent)
: QDialog(parent) : QDialog(parent)
{ {
setWindowTitle(tr("Add a User Repository"));
setModal(true);
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(500);
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* continueButton = dialogButtons->addButton(tr("Add"), QDialogButtonBox::ApplyRole);
connect(cancelButton, &QPushButton::clicked, this, &GemRepoAddDialog::CancelButtonPressed);
connect(continueButton, &QPushButton::clicked, this, &GemRepoAddDialog::ContinueButtonPressed);
}
QDialogButtonBox::ButtonRole GemRepoAddDialog::GetButtonResult()
{
return m_buttonResult;
}
QString GemRepoAddDialog::GetRepoPath()
{
return m_repoPath->lineEdit()->text();
}
void GemRepoAddDialog::CancelButtonPressed()
{
m_buttonResult = QDialogButtonBox::RejectRole;
close();
}
void GemRepoAddDialog::ContinueButtonPressed()
{
m_buttonResult = QDialogButtonBox::ApplyRole;
close();
} }
} // namespace O3DE::ProjectManager } // namespace O3DE::ProjectManager

@ -10,15 +10,30 @@
#if !defined(Q_MOC_RUN) #if !defined(Q_MOC_RUN)
#include <QDialog.h> #include <QDialog.h>
#include <QDialogButtonBox>
#endif #endif
namespace O3DE::ProjectManager namespace O3DE::ProjectManager
{ {
QT_FORWARD_DECLARE_CLASS(FormLineEditWidget)
class GemRepoAddDialog class GemRepoAddDialog
: public QDialog : public QDialog
{ {
public: public:
explicit GemRepoAddDialog(QWidget* parent = nullptr); explicit GemRepoAddDialog(QWidget* parent = nullptr);
~GemRepoAddDialog() = default; ~GemRepoAddDialog() = default;
QDialogButtonBox::ButtonRole GetButtonResult();
QString GetRepoPath();
private:
void CancelButtonPressed();
void ContinueButtonPressed();
FormLineEditWidget* m_repoPath = nullptr;
QDialogButtonBox::ButtonRole m_buttonResult = QDialogButtonBox::RejectRole;
}; };
} // namespace O3DE::ProjectManager } // namespace O3DE::ProjectManager

@ -10,6 +10,7 @@
#include <GemRepo/GemRepoItemDelegate.h> #include <GemRepo/GemRepoItemDelegate.h>
#include <GemRepo/GemRepoListView.h> #include <GemRepo/GemRepoListView.h>
#include <GemRepo/GemRepoModel.h> #include <GemRepo/GemRepoModel.h>
#include <GemRepo/GemRepoAddDialog.h>
#include <PythonBindingsInterface.h> #include <PythonBindingsInterface.h>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -70,6 +71,32 @@ namespace O3DE::ProjectManager
}); });
} }
void GemRepoScreen::HandleAddRepoButton()
{
GemRepoAddDialog* repoAddDialog = new GemRepoAddDialog(this);
repoAddDialog->exec();
if (repoAddDialog->GetButtonResult() == QDialogButtonBox::ApplyRole)
{
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.\nError:\n%2").arg(repoUrl, addGemRepoResult.GetError().c_str()));
}
}
}
void GemRepoScreen::FillModel() void GemRepoScreen::FillModel()
{ {
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos(); AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
@ -114,10 +141,12 @@ namespace O3DE::ProjectManager
hLayout->addStretch(); hLayout->addStretch();
m_AddRepoButton = new QPushButton(tr("Add Repository"), this); QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this);
m_AddRepoButton->setObjectName("gemRepoAddButton"); addRepoButton->setObjectName("gemRepoAddButton");
m_AddRepoButton->setMinimumWidth(120); addRepoButton->setMinimumWidth(120);
hLayout->addWidget(m_AddRepoButton); hLayout->addWidget(addRepoButton);
connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton);
hLayout->addStretch(); hLayout->addStretch();
@ -165,9 +194,11 @@ namespace O3DE::ProjectManager
topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
m_AddRepoButton = new QPushButton(tr("Add Repository"), this); QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this);
m_AddRepoButton->setObjectName("gemRepoAddButton"); addRepoButton->setObjectName("gemRepoAddButton");
topMiddleHLayout->addWidget(m_AddRepoButton); topMiddleHLayout->addWidget(addRepoButton);
connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton);
topMiddleHLayout->addSpacing(30); topMiddleHLayout->addSpacing(30);

@ -36,6 +36,9 @@ namespace O3DE::ProjectManager
GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; } GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; }
public slots:
void HandleAddRepoButton();
private: private:
void FillModel(); void FillModel();
QFrame* CreateNoReposContent(); QFrame* CreateNoReposContent();
@ -53,6 +56,5 @@ namespace O3DE::ProjectManager
QLabel* m_lastAllUpdateLabel; QLabel* m_lastAllUpdateLabel;
QPushButton* m_AllUpdateButton; QPushButton* m_AllUpdateButton;
QPushButton* m_AddRepoButton;
}; };
} // namespace O3DE::ProjectManager } // namespace O3DE::ProjectManager

@ -913,6 +913,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) GemRepoInfo PythonBindings::GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath)
{ {
/* Placeholder Logic */ /* Placeholder Logic */

@ -57,6 +57,7 @@ namespace O3DE::ProjectManager
AZ::Outcome<QVector<ProjectTemplateInfo>> GetProjectTemplates(const QString& projectPath = {}) override; AZ::Outcome<QVector<ProjectTemplateInfo>> GetProjectTemplates(const QString& projectPath = {}) override;
// Gem Repos // Gem Repos
AZ::Outcome<void, AZStd::string> AddGemRepo(const QString& repoUri = {}) override;
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> GetAllGemRepoInfos() override; AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> GetAllGemRepoInfos() override;
private: private:

@ -159,6 +159,13 @@ namespace O3DE::ProjectManager
// Gem Repos // 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. * Get all available gem repo infos. Gathers all repos registered with the engine.
* @return A list of gem repo infos. * @return A list of gem repo infos.

Loading…
Cancel
Save