Open CMake GUI from Project Manager (#4360)

This provides a fast way for engineers who want to configure -> generate -> open project in IDE -> build & run to do so without waiting for a potentially lengthy Project Manager build.

Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
Alex Peterson
2021-10-04 13:20:42 -07:00
committed by GitHub
parent c9608846a1
commit 555e95679d
10 changed files with 190 additions and 19 deletions
@@ -88,6 +88,7 @@ namespace O3DE::ProjectManager
QHBoxLayout* horizontalButtonLayout = new QHBoxLayout();
horizontalButtonLayout->addSpacing(34);
m_actionButton = new QPushButton(tr("Project Action"), this);
m_actionButton->setObjectName("projectActionButton");
m_actionButton->setVisible(false);
horizontalButtonLayout->addWidget(m_actionButton);
horizontalButtonLayout->addSpacing(34);
@@ -198,6 +199,7 @@ namespace O3DE::ProjectManager
QMenu* menu = new QMenu(this);
menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); });
menu->addAction(tr("Build"), this, [this]() { emit BuildProject(m_projectInfo); });
menu->addAction(tr("Open CMake GUI..."), this, [this]() { emit OpenCMakeGUI(m_projectInfo); });
menu->addSeparator();
menu->addAction(tr("Open Project folder..."), this, [this]()
{
@@ -259,15 +261,39 @@ namespace O3DE::ProjectManager
}
projectActionButton->setText(text);
projectActionButton->setMenu(nullptr);
m_actionButtonConnection = connect(projectActionButton, &QPushButton::clicked, lambda);
}
void ProjectButton::SetProjectBuildButtonAction()
void ProjectButton::ShowDefaultBuildButton()
{
m_projectImageLabel->GetWarningLabel()->setText(tr("Building project required."));
m_projectImageLabel->GetWarningIcon()->setVisible(true);
m_projectImageLabel->GetWarningLabel()->setVisible(true);
SetProjectButtonAction(tr("Build Project"), [this]() { emit BuildProject(m_projectInfo); });
QPushButton* projectActionButton = m_projectImageLabel->GetActionButton();
projectActionButton->setVisible(true);
projectActionButton->setText(tr("Build Project"));
disconnect(m_actionButtonConnection);
QMenu* menu = new QMenu(this);
QAction* autoBuildAction = menu->addAction(tr("Build Now"));
connect( autoBuildAction, &QAction::triggered, this, [this](){ emit BuildProject(m_projectInfo); });
QAction* openCMakeAction = menu->addAction(tr("Open CMake GUI..."));
connect( openCMakeAction, &QAction::triggered, this, [this](){ emit OpenCMakeGUI(m_projectInfo); });
projectActionButton->setMenu(menu);
}
void ProjectButton::ShowBuildRequired()
{
ShowWarning(true, tr("Building project required"));
ShowDefaultBuildButton();
}
void ProjectButton::ShowWarning(bool show, const QString& warning)
{
m_projectImageLabel->GetWarningLabel()->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
m_projectImageLabel->GetWarningLabel()->setText(warning);
m_projectImageLabel->GetWarningLabel()->setVisible(show);
m_projectImageLabel->GetWarningIcon()->setVisible(show);
}
void ProjectButton::SetBuildLogsLink(const QUrl& logUrl)
@@ -279,18 +305,15 @@ namespace O3DE::ProjectManager
{
if (!logUrl.isEmpty())
{
m_projectImageLabel->GetWarningLabel()->setText(tr("Failed to build. Click to <a href=\"logs\">view logs</a>."));
ShowWarning(show, tr("Failed to build. Click to <a href=\"logs\">view logs</a>."));
}
else
{
m_projectImageLabel->GetWarningLabel()->setText(tr("Project failed to build."));
ShowWarning(show, tr("Project failed to build."));
}
m_projectImageLabel->GetWarningLabel()->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
m_projectImageLabel->GetWarningIcon()->setVisible(show);
m_projectImageLabel->GetWarningLabel()->setVisible(show);
m_projectImageLabel->SetLogUrl(logUrl);
SetProjectButtonAction(tr("Build Project"), [this]() { emit BuildProject(m_projectInfo); });
SetBuildLogsLink(logUrl);
ShowDefaultBuildButton();
}
void ProjectButton::SetProjectBuilding()
@@ -82,9 +82,9 @@ namespace O3DE::ProjectManager
void RestoreDefaultState();
void SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda);
void SetProjectBuildButtonAction();
void SetBuildLogsLink(const QUrl& logUrl);
void ShowBuildFailed(bool show, const QUrl& logUrl);
void ShowBuildRequired();
void SetProjectBuilding();
void SetLaunchButtonEnabled(bool enabled);
@@ -99,10 +99,13 @@ namespace O3DE::ProjectManager
void RemoveProject(const QString& projectName);
void DeleteProject(const QString& projectName);
void BuildProject(const ProjectInfo& projectInfo);
void OpenCMakeGUI(const ProjectInfo& projectInfo);
private:
void enterEvent(QEvent* event) override;
void leaveEvent(QEvent* event) override;
void ShowWarning(bool show, const QString& warning);
void ShowDefaultBuildButton();
ProjectInfo m_projectInfo;
@@ -9,6 +9,8 @@
#include <ProjectUtils.h>
#include <ProjectManagerDefs.h>
#include <PythonBindingsInterface.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/IO/Path/Path.h>
#include <QFileDialog>
#include <QDir>
@@ -537,5 +539,33 @@ namespace O3DE::ProjectManager
QString resultOutput = execProcess.readAllStandardOutput();
return AZ::Success(resultOutput);
}
AZ::Outcome<QString, QString> GetProjectBuildPath(const QString& projectPath)
{
auto registry = AZ::SettingsRegistry::Get();
// the project_build_path should be in the user settings registry inside the project folder
AZ::IO::FixedMaxPath projectUserPath(projectPath.toUtf8().constData());
projectUserPath /= AZ::SettingsRegistryInterface::DevUserRegistryFolder;
if (!QDir(projectUserPath.c_str()).exists())
{
return AZ::Failure(QObject::tr("Failed to find the user registry folder %1").arg(projectUserPath.c_str()));
}
AZ::SettingsRegistryInterface::Specializations specializations;
if(!registry->MergeSettingsFolder(projectUserPath.Native(), specializations, AZ_TRAIT_OS_PLATFORM_CODENAME))
{
return AZ::Failure(QObject::tr("Failed to merge registry settings in user registry folder %1").arg(projectUserPath.c_str()));
}
AZ::IO::FixedMaxPath projectBuildPath;
if (!registry->Get(projectBuildPath.Native(), AZ::SettingsRegistryMergeUtils::ProjectBuildPath))
{
return AZ::Failure(QObject::tr("No project build path setting was found in the user registry folder %1").arg(projectUserPath.c_str()));
}
return AZ::Success(QString(projectBuildPath.c_str()));
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -42,6 +42,8 @@ namespace O3DE::ProjectManager
int commandTimeoutSeconds = ProjectCommandLineTimeoutSeconds);
AZ::Outcome<QProcessEnvironment, QString> GetCommandLineProcessEnvironment();
AZ::Outcome<QString, QString> GetProjectBuildPath(const QString& projectPath);
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath);
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -185,6 +185,15 @@ namespace O3DE::ProjectManager
connect(projectButton, &ProjectButton::RemoveProject, this, &ProjectsScreen::HandleRemoveProject);
connect(projectButton, &ProjectButton::DeleteProject, this, &ProjectsScreen::HandleDeleteProject);
connect(projectButton, &ProjectButton::BuildProject, this, &ProjectsScreen::QueueBuildProject);
connect(projectButton, &ProjectButton::OpenCMakeGUI, this,
[this](const ProjectInfo& projectInfo)
{
AZ::Outcome result = ProjectUtils::OpenCMakeGUI(projectInfo.m_path);
if (!result)
{
QMessageBox::critical(this, tr("Failed to open CMake GUI"), result.GetError(), QMessageBox::Ok);
}
});
return projectButton;
}
@@ -308,7 +317,7 @@ namespace O3DE::ProjectManager
}
else
{
projectIter.value()->SetProjectBuildButtonAction();
projectIter.value()->ShowBuildRequired();
}
}
}