@@ -7,12 +7,74 @@
|
||||
*/
|
||||
|
||||
#include <GemRepo/GemRepoAddDialog.h>
|
||||
#include <FormLineEditWidget.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit.h>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
GemRepoAddDialog::GemRepoAddDialog(QWidget* 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
|
||||
|
||||
@@ -10,15 +10,30 @@
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#endif
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
QT_FORWARD_DECLARE_CLASS(FormLineEditWidget)
|
||||
|
||||
class GemRepoAddDialog
|
||||
: public QDialog
|
||||
{
|
||||
public:
|
||||
explicit GemRepoAddDialog(QWidget* parent = nullptr);
|
||||
~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
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <GemRepo/GemRepoItemDelegate.h>
|
||||
#include <GemRepo/GemRepoListView.h>
|
||||
#include <GemRepo/GemRepoModel.h>
|
||||
#include <GemRepo/GemRepoAddDialog.h>
|
||||
#include <PythonBindingsInterface.h>
|
||||
|
||||
#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()
|
||||
{
|
||||
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
|
||||
@@ -114,10 +141,12 @@ namespace O3DE::ProjectManager
|
||||
|
||||
hLayout->addStretch();
|
||||
|
||||
m_AddRepoButton = new QPushButton(tr("Add Repository"), this);
|
||||
m_AddRepoButton->setObjectName("gemRepoAddButton");
|
||||
m_AddRepoButton->setMinimumWidth(120);
|
||||
hLayout->addWidget(m_AddRepoButton);
|
||||
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();
|
||||
|
||||
@@ -165,9 +194,11 @@ namespace O3DE::ProjectManager
|
||||
|
||||
topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
m_AddRepoButton = new QPushButton(tr("Add Repository"), this);
|
||||
m_AddRepoButton->setObjectName("gemRepoAddButton");
|
||||
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);
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ namespace O3DE::ProjectManager
|
||||
|
||||
GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; }
|
||||
|
||||
public slots:
|
||||
void HandleAddRepoButton();
|
||||
|
||||
private:
|
||||
void FillModel();
|
||||
QFrame* CreateNoReposContent();
|
||||
@@ -53,6 +56,5 @@ namespace O3DE::ProjectManager
|
||||
|
||||
QLabel* m_lastAllUpdateLabel;
|
||||
QPushButton* m_AllUpdateButton;
|
||||
QPushButton* m_AddRepoButton;
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user