diff --git a/Code/Editor/MainStatusBar.cpp b/Code/Editor/MainStatusBar.cpp index a1e51ec553..f955035bd8 100644 --- a/Code/Editor/MainStatusBar.cpp +++ b/Code/Editor/MainStatusBar.cpp @@ -15,6 +15,7 @@ // AzQtComponents #include #include +#include // Qt #include @@ -209,7 +210,7 @@ MainStatusBar::MainStatusBar(QWidget* parent) addPermanentWidget(new StatusBarItem(QStringLiteral("connection"), true, this, true), 1); - addPermanentWidget(new StatusBarItem(QStringLiteral("game_info"), this, true), 1); + addPermanentWidget(new GameInfoItem(QStringLiteral("game_info"), this), 1); addPermanentWidget(new MemoryStatusItem(QStringLiteral("memory"), this), 1); } @@ -221,11 +222,6 @@ void MainStatusBar::Init() 500 }; //in ms, so 2 FPS - AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath(); - QString strGameInfo; - strGameInfo = tr("GameFolder: '%1'").arg(projectPath.c_str()); - SetItem(QStringLiteral("game_info"), strGameInfo, tr("Game Info"), QPixmap()); - //ask for updates for items regularly. This is basically what MFC does auto timer = new QTimer(this); timer->setInterval(statusbarTimerUpdateInterval); @@ -436,5 +432,29 @@ QString GeneralStatusItem::CurrentText() const return StatusBarItem::CurrentText(); } +GameInfoItem::GameInfoItem(QString name, MainStatusBar* parent) + : StatusBarItem(name, parent, true) +{ + m_projectPath = QString::fromUtf8(AZ::Utils::GetProjectPath().c_str()); + + SetText(QObject::tr("GameFolder: '%1'").arg(m_projectPath)); + SetToolTip(QObject::tr("Game Info")); + + setContextMenuPolicy(Qt::CustomContextMenu); + QObject::connect(this, &QWidget::customContextMenuRequested, this, &GameInfoItem::OnShowContextMenu); +} + +void GameInfoItem::OnShowContextMenu(const QPoint& pos) +{ + QMenu contextMenu(this); + + // Context menu action to open the project folder in file browser + contextMenu.addAction(AzQtComponents::fileBrowserActionName(), this, [this]() { + AzQtComponents::ShowFileOnDesktop(m_projectPath); + }); + + contextMenu.exec(mapToGlobal(pos)); +} + #include #include diff --git a/Code/Editor/MainStatusBarItems.h b/Code/Editor/MainStatusBarItems.h index 2a3a21e72a..5f8d618dca 100644 --- a/Code/Editor/MainStatusBarItems.h +++ b/Code/Editor/MainStatusBarItems.h @@ -71,3 +71,17 @@ public: private: void updateStatus(); }; + +class GameInfoItem + : public StatusBarItem +{ + Q_OBJECT +public: + GameInfoItem(QString name, MainStatusBar* parent); + +private Q_SLOTS: + void OnShowContextMenu(const QPoint& pos); + +private: + QString m_projectPath; +};