Added context menu on game folder status bar item to open project path in file explorer.

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
monroegm-disable-blank-issue-2
Chris Galvan 4 years ago
parent 0750dd59ca
commit bec568c8bd

@ -15,6 +15,7 @@
// AzQtComponents // AzQtComponents
#include <AzQtComponents/Components/Widgets/CheckBox.h> #include <AzQtComponents/Components/Widgets/CheckBox.h>
#include <AzQtComponents/Components/Style.h> #include <AzQtComponents/Components/Style.h>
#include <AzQtComponents/Utilities/DesktopUtilities.h>
// Qt // Qt
#include <QMenu> #include <QMenu>
@ -209,7 +210,7 @@ MainStatusBar::MainStatusBar(QWidget* parent)
addPermanentWidget(new StatusBarItem(QStringLiteral("connection"), true, this, true), 1); 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); addPermanentWidget(new MemoryStatusItem(QStringLiteral("memory"), this), 1);
} }
@ -221,11 +222,6 @@ void MainStatusBar::Init()
500 500
}; //in ms, so 2 FPS }; //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 //ask for updates for items regularly. This is basically what MFC does
auto timer = new QTimer(this); auto timer = new QTimer(this);
timer->setInterval(statusbarTimerUpdateInterval); timer->setInterval(statusbarTimerUpdateInterval);
@ -436,5 +432,29 @@ QString GeneralStatusItem::CurrentText() const
return StatusBarItem::CurrentText(); 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 <moc_MainStatusBar.cpp> #include <moc_MainStatusBar.cpp>
#include <moc_MainStatusBarItems.cpp> #include <moc_MainStatusBarItems.cpp>

@ -71,3 +71,17 @@ public:
private: private:
void updateStatus(); 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;
};

Loading…
Cancel
Save