diff --git a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp index 3225c14266..39980e1d11 100644 --- a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace O3DE::ProjectManager { @@ -109,11 +110,11 @@ namespace O3DE::ProjectManager vLayout->addWidget(m_progressBar); } - void LabelButton::mousePressEvent([[maybe_unused]] QMouseEvent* event) + void LabelButton::mousePressEvent(QMouseEvent* event) { if(m_enabled) { - emit triggered(); + emit triggered(event); } } @@ -201,52 +202,64 @@ namespace O3DE::ProjectManager projectNameLabel->setToolTip(m_projectInfo.m_path); hLayout->addWidget(projectNameLabel); - QMenu* menu = new QMenu(this); - menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); }); - menu->addAction(tr("Configure Gems..."), this, [this]() { emit EditProjectGems(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]() - { - AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path); - }); - -#if AZ_TRAIT_PROJECT_MANAGER_CREATE_DESKTOP_SHORTCUT - menu->addAction(tr("Create Editor desktop shortcut..."), this, [this]() - { - AZ::IO::FixedMaxPath editorExecutablePath = ProjectUtils::GetEditorExecutablePath(m_projectInfo.m_path.toUtf8().constData()); - - const QString shortcutName = QString("%1 Editor").arg(m_projectInfo.m_displayName); - const QString arg = QString("--regset=\"/Amazon/AzCore/Bootstrap/project_path=%1\"").arg(m_projectInfo.m_path); - - auto result = ProjectUtils::CreateDesktopShortcut(shortcutName, editorExecutablePath.c_str(), { arg }); - if(result.IsSuccess()) - { - QMessageBox::information(this, tr("Desktop Shortcut Created"), result.GetValue()); - } - else - { - QMessageBox::critical(this, tr("Failed to create shortcut"), result.GetError()); - } - }); -#endif // AZ_TRAIT_PROJECT_MANAGER_CREATE_DESKTOP_SHORTCUT - - menu->addSeparator(); - menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); }); - menu->addSeparator(); - menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); }); - menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); }); - m_projectMenuButton = new QPushButton(this); m_projectMenuButton->setObjectName("projectMenuButton"); - m_projectMenuButton->setMenu(menu); + m_projectMenuButton->setMenu(CreateProjectMenu()); hLayout->addWidget(m_projectMenuButton); } vLayout->addWidget(projectFooter); connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); }); + connect(m_projectImageLabel, &LabelButton::triggered, [this](QMouseEvent* event) { + if (event->button() == Qt::RightButton) + { + m_projectMenuButton->menu()->move(event->globalPos()); + m_projectMenuButton->menu()->show(); + } + }); + } + + QMenu* ProjectButton::CreateProjectMenu() + { + QMenu* menu = new QMenu(this); + menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); }); + menu->addAction(tr("Configure Gems..."), this, [this]() { emit EditProjectGems(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]() + { + AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path); + }); + +#if AZ_TRAIT_PROJECT_MANAGER_CREATE_DESKTOP_SHORTCUT + menu->addAction(tr("Create Editor desktop shortcut..."), this, [this]() + { + AZ::IO::FixedMaxPath editorExecutablePath = ProjectUtils::GetEditorExecutablePath(m_projectInfo.m_path.toUtf8().constData()); + + const QString shortcutName = QString("%1 Editor").arg(m_projectInfo.m_displayName); + const QString arg = QString("--regset=\"/Amazon/AzCore/Bootstrap/project_path=%1\"").arg(m_projectInfo.m_path); + + auto result = ProjectUtils::CreateDesktopShortcut(shortcutName, editorExecutablePath.c_str(), { arg }); + if(result.IsSuccess()) + { + QMessageBox::information(this, tr("Desktop Shortcut Created"), result.GetValue()); + } + else + { + QMessageBox::critical(this, tr("Failed to create shortcut"), result.GetError()); + } + }); +#endif // AZ_TRAIT_PROJECT_MANAGER_CREATE_DESKTOP_SHORTCUT + + menu->addSeparator(); + menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); }); + menu->addSeparator(); + menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); }); + menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); }); + + return menu; } const ProjectInfo& ProjectButton::GetProjectInfo() const diff --git a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h index ccb644c458..358c1f249a 100644 --- a/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h +++ b/Code/Tools/ProjectManager/Source/ProjectButtonWidget.h @@ -24,6 +24,7 @@ QT_FORWARD_DECLARE_CLASS(QProgressBar) QT_FORWARD_DECLARE_CLASS(QLayout) QT_FORWARD_DECLARE_CLASS(QVBoxLayout) QT_FORWARD_DECLARE_CLASS(QEvent) +QT_FORWARD_DECLARE_CLASS(QMenu) namespace O3DE::ProjectManager { @@ -49,7 +50,7 @@ namespace O3DE::ProjectManager QLayout* GetBuildOverlayLayout(); signals: - void triggered(); + void triggered(QMouseEvent* event); public slots: void mousePressEvent(QMouseEvent* event) override; @@ -108,6 +109,8 @@ namespace O3DE::ProjectManager void ShowWarning(bool show, const QString& warning); void ShowDefaultBuildButton(); + QMenu* CreateProjectMenu(); + ProjectInfo m_projectInfo; LabelButton* m_projectImageLabel = nullptr;