Open editor button and new project and failed warnings.
Signed-off-by: AMZN-Phil <pconroy@amazon.com>
This commit is contained in:
@@ -92,10 +92,18 @@ namespace O3DE::ProjectManager
|
||||
// Open application assigned to this file type
|
||||
QDesktopServices::openUrl(QUrl("file:///" + m_worker->GetLogFilePath()));
|
||||
}
|
||||
|
||||
m_projectInfo.m_buildFailed = true;
|
||||
m_projectInfo.m_logUrl = QUrl("file:///" + m_worker->GetLogFilePath());
|
||||
emit NotifyBuildProject(m_projectInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(m_parent, tr("Project Failed to Build!"), result);
|
||||
|
||||
m_projectInfo.m_buildFailed = true;
|
||||
m_projectInfo.m_logUrl = QUrl();
|
||||
emit NotifyBuildProject(m_projectInfo);
|
||||
}
|
||||
|
||||
emit Done(false);
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
signals:
|
||||
void Done(bool success = true);
|
||||
void NotifyBuildProject(const ProjectInfo& projectInfo);
|
||||
|
||||
private:
|
||||
ProjectInfo m_projectInfo;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
const QString ProjectBuilderWorker::BuildCancelled = ProjectBuilderWorker::tr("Build Cancelled.");
|
||||
const QString ProjectBuilderWorker::BuildCancelled = QObject::tr("Build Cancelled.");
|
||||
|
||||
ProjectBuilderWorker::ProjectBuilderWorker(const ProjectInfo& projectInfo)
|
||||
: QObject()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
@@ -20,6 +21,7 @@
|
||||
#include <QProgressBar>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDesktopServices>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -40,8 +42,57 @@ namespace O3DE::ProjectManager
|
||||
m_overlayLabel->setVisible(false);
|
||||
vLayout->addWidget(m_overlayLabel);
|
||||
|
||||
m_buildOverlayLayout = new QVBoxLayout();
|
||||
m_buildOverlayLayout->addSpacing(10);
|
||||
|
||||
QHBoxLayout* horizontalMessageLayout = new QHBoxLayout();
|
||||
|
||||
horizontalMessageLayout->addSpacing(10);
|
||||
m_warningIcon = new QLabel(this);
|
||||
m_warningIcon->setPixmap(QIcon(":/Warning.svg").pixmap(20, 20));
|
||||
m_warningIcon->setAlignment(Qt::AlignTop);
|
||||
m_warningIcon->setVisible(false);
|
||||
horizontalMessageLayout->addWidget(m_warningIcon);
|
||||
|
||||
horizontalMessageLayout->addSpacing(10);
|
||||
|
||||
m_warningText = new QLabel("", this);
|
||||
m_warningText->setObjectName("projectWarningOverlay");
|
||||
m_warningText->setWordWrap(true);
|
||||
m_warningText->setAlignment(Qt::AlignLeft);
|
||||
m_warningText->setVisible(false);
|
||||
connect(m_warningText, &QLabel::linkActivated, this, &LabelButton::OnLinkActivated);
|
||||
horizontalMessageLayout->addWidget(m_warningText);
|
||||
|
||||
QSpacerItem* textSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
horizontalMessageLayout->addSpacerItem(textSpacer);
|
||||
|
||||
m_buildOverlayLayout->addLayout(horizontalMessageLayout);
|
||||
|
||||
QSpacerItem* buttonSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_buildOverlayLayout->addSpacerItem(buttonSpacer);
|
||||
|
||||
QHBoxLayout* horizontalOpenEditorButtonLayout = new QHBoxLayout();
|
||||
horizontalOpenEditorButtonLayout->addSpacing(34);
|
||||
m_openEditorButton = new QPushButton(tr("Open Editor"), this);
|
||||
m_openEditorButton->setObjectName("openEditorButton");
|
||||
m_openEditorButton->setDefault(true);
|
||||
m_openEditorButton->setVisible(false);
|
||||
horizontalOpenEditorButtonLayout->addWidget(m_openEditorButton);
|
||||
horizontalOpenEditorButtonLayout->addSpacing(34);
|
||||
m_buildOverlayLayout->addLayout(horizontalOpenEditorButtonLayout);
|
||||
|
||||
QHBoxLayout* horizontalButtonLayout = new QHBoxLayout();
|
||||
horizontalButtonLayout->addSpacing(34);
|
||||
m_actionButton = new QPushButton(tr("Project Action"), this);
|
||||
m_actionButton->setVisible(false);
|
||||
horizontalButtonLayout->addWidget(m_actionButton);
|
||||
horizontalButtonLayout->addSpacing(34);
|
||||
|
||||
m_buildOverlayLayout->addLayout(horizontalButtonLayout);
|
||||
m_buildOverlayLayout->addSpacing(16);
|
||||
|
||||
vLayout->addItem(m_buildOverlayLayout);
|
||||
|
||||
m_progressBar = new QProgressBar(this);
|
||||
m_progressBar->setObjectName("labelButtonProgressBar");
|
||||
@@ -73,16 +124,41 @@ namespace O3DE::ProjectManager
|
||||
return m_overlayLabel;
|
||||
}
|
||||
|
||||
void LabelButton::SetLogUrl(const QUrl& url)
|
||||
{
|
||||
m_logUrl = url;
|
||||
}
|
||||
|
||||
QProgressBar* LabelButton::GetProgressBar()
|
||||
{
|
||||
return m_progressBar;
|
||||
}
|
||||
|
||||
QPushButton* LabelButton::GetOpenEditorButton()
|
||||
{
|
||||
return m_openEditorButton;
|
||||
}
|
||||
|
||||
QPushButton* LabelButton::GetActionButton()
|
||||
{
|
||||
return m_actionButton;
|
||||
}
|
||||
|
||||
QLabel* LabelButton::GetWarningLabel()
|
||||
{
|
||||
return m_warningText;
|
||||
}
|
||||
|
||||
QLabel* LabelButton::GetWarningIcon()
|
||||
{
|
||||
return m_warningIcon;
|
||||
}
|
||||
|
||||
void LabelButton::OnLinkActivated(const QString& /*link*/)
|
||||
{
|
||||
QDesktopServices::openUrl(m_logUrl);
|
||||
}
|
||||
|
||||
ProjectButton::ProjectButton(const ProjectInfo& projectInfo, QWidget* parent, bool processing)
|
||||
: QFrame(parent)
|
||||
, m_projectInfo(projectInfo)
|
||||
@@ -110,7 +186,6 @@ namespace O3DE::ProjectManager
|
||||
m_projectImageLabel = new LabelButton(this);
|
||||
m_projectImageLabel->setFixedSize(ProjectPreviewImageWidth, ProjectPreviewImageHeight);
|
||||
m_projectImageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
connect(m_projectImageLabel, &LabelButton::triggered, [this]() { emit OpenProject(m_projectInfo.m_path); });
|
||||
vLayout->addWidget(m_projectImageLabel);
|
||||
|
||||
QString projectPreviewPath = QDir(m_projectInfo.m_path).filePath(m_projectInfo.m_iconPath);
|
||||
@@ -145,6 +220,8 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ProjectButton::ReadySetup()
|
||||
{
|
||||
connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); });
|
||||
|
||||
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); });
|
||||
@@ -170,9 +247,6 @@ namespace O3DE::ProjectManager
|
||||
QPushButton* projectActionButton = m_projectImageLabel->GetActionButton();
|
||||
if (!m_actionButtonConnection)
|
||||
{
|
||||
QSpacerItem* buttonSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
m_projectImageLabel->layout()->addItem(buttonSpacer);
|
||||
m_projectImageLabel->layout()->addWidget(projectActionButton);
|
||||
projectActionButton->setVisible(true);
|
||||
}
|
||||
else
|
||||
@@ -186,6 +260,27 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ProjectButton::SetProjectBuildButtonAction()
|
||||
{
|
||||
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); });
|
||||
}
|
||||
|
||||
void ProjectButton::ShowBuildFailed(bool show, const QUrl& logUrl)
|
||||
{
|
||||
if (!logUrl.isEmpty())
|
||||
{
|
||||
m_projectImageLabel->GetWarningLabel()->setText(tr("Failed to build. Click to <a href=\"logs\">view logs</a>."));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_projectImageLabel->GetWarningLabel()->setText(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); });
|
||||
}
|
||||
|
||||
@@ -209,6 +304,16 @@ namespace O3DE::ProjectManager
|
||||
m_projectImageLabel->GetProgressBar()->setValue(progress);
|
||||
}
|
||||
|
||||
void ProjectButton::enterEvent(QEvent* /*event*/)
|
||||
{
|
||||
m_projectImageLabel->GetOpenEditorButton()->setVisible(true);
|
||||
}
|
||||
|
||||
void ProjectButton::leaveEvent(QEvent* /*event*/)
|
||||
{
|
||||
m_projectImageLabel->GetOpenEditorButton()->setVisible(false);
|
||||
}
|
||||
|
||||
LabelButton* ProjectButton::GetLabelButton()
|
||||
{
|
||||
return m_projectImageLabel;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
QT_FORWARD_DECLARE_CLASS(QPixmap)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
QT_FORWARD_DECLARE_CLASS(QProgressBar)
|
||||
QT_FORWARD_DECLARE_CLASS(QLayout)
|
||||
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
|
||||
QT_FORWARD_DECLARE_CLASS(QEvent)
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -34,21 +37,32 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
void SetOverlayText(const QString& text);
|
||||
void SetLogUrl(const QUrl& url);
|
||||
|
||||
QLabel* GetOverlayLabel();
|
||||
QProgressBar* GetProgressBar();
|
||||
QPushButton* GetOpenEditorButton();
|
||||
QPushButton* GetActionButton();
|
||||
QLabel* GetWarningLabel();
|
||||
QLabel* GetWarningIcon();
|
||||
QLayout* GetBuildOverlayLayout();
|
||||
|
||||
signals:
|
||||
void triggered();
|
||||
|
||||
public slots:
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void OnLinkActivated(const QString& link);
|
||||
|
||||
private:
|
||||
QVBoxLayout* m_buildOverlayLayout;
|
||||
QLabel* m_overlayLabel;
|
||||
QProgressBar* m_progressBar;
|
||||
QPushButton* m_openEditorButton;
|
||||
QPushButton* m_actionButton;
|
||||
QLabel* m_warningText;
|
||||
QLabel* m_warningIcon;
|
||||
QUrl m_logUrl;
|
||||
bool m_enabled = true;
|
||||
};
|
||||
|
||||
@@ -63,6 +77,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda);
|
||||
void SetProjectBuildButtonAction();
|
||||
void ShowBuildFailed(bool show, const QUrl& logUrl);
|
||||
|
||||
void SetLaunchButtonEnabled(bool enabled);
|
||||
void SetButtonOverlayText(const QString& text);
|
||||
@@ -81,11 +96,14 @@ namespace O3DE::ProjectManager
|
||||
void BaseSetup();
|
||||
void ProcessingSetup();
|
||||
void ReadySetup();
|
||||
void enterEvent(QEvent* event) override;
|
||||
void leaveEvent(QEvent* event) override;
|
||||
void BuildThisProject();
|
||||
|
||||
ProjectInfo m_projectInfo;
|
||||
LabelButton* m_projectImageLabel;
|
||||
QFrame* m_projectFooter;
|
||||
QLayout* m_requiresBuildLayout;
|
||||
|
||||
QMetaObject::Connection m_actionButtonConnection;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <QUrl>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#endif
|
||||
@@ -54,5 +55,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
// Used in project creation
|
||||
bool m_needsBuild = false; //! Does this project need to be built
|
||||
bool m_buildFailed = false;
|
||||
QUrl m_logUrl;
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -193,7 +193,19 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
else if (RequiresBuildProjectIterator(project.m_path) != m_requiresBuild.end())
|
||||
{
|
||||
projectButtonWidget->SetProjectBuildButtonAction();
|
||||
auto buildProjectIterator = RequiresBuildProjectIterator(project.m_path);
|
||||
if (buildProjectIterator != m_requiresBuild.end())
|
||||
{
|
||||
if (buildProjectIterator->m_buildFailed)
|
||||
{
|
||||
projectButtonWidget->ShowBuildFailed(true, buildProjectIterator->m_logUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectButtonWidget->SetProjectBuildButtonAction();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +430,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ProjectsScreen::SuggestBuildProjectMsg(const ProjectInfo& projectInfo, bool showMessage)
|
||||
{
|
||||
if (RequiresBuildProjectIterator(projectInfo.m_path) == m_requiresBuild.end())
|
||||
if (RequiresBuildProjectIterator(projectInfo.m_path) == m_requiresBuild.end() || projectInfo.m_buildFailed)
|
||||
{
|
||||
m_requiresBuild.append(projectInfo);
|
||||
}
|
||||
@@ -517,6 +529,7 @@ namespace O3DE::ProjectManager
|
||||
m_currentBuilder = new ProjectBuilderController(projectInfo, nullptr, this);
|
||||
ResetProjectsContent();
|
||||
connect(m_currentBuilder, &ProjectBuilderController::Done, this, &ProjectsScreen::ProjectBuildDone);
|
||||
connect(m_currentBuilder, &ProjectBuilderController::NotifyBuildProject, this, &ProjectsScreen::SuggestBuildProject);
|
||||
|
||||
m_currentBuilder->Start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user