MenuBar: Add action which opens the user folder

This commit is contained in:
OatmealDome 2023-01-16 03:36:24 -05:00
parent c4f4ecbb62
commit 869aa9eb55
4 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDateTime> #include <QDateTime>
#include <QDesktopServices>
#include <QDir> #include <QDir>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDropEvent> #include <QDropEvent>
@ -480,6 +481,7 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::ChangeDisc, this, &MainWindow::ChangeDisc); connect(m_menu_bar, &MenuBar::ChangeDisc, this, &MainWindow::ChangeDisc);
connect(m_menu_bar, &MenuBar::BootDVDBackup, this, connect(m_menu_bar, &MenuBar::BootDVDBackup, this,
[this](const QString& drive) { StartGame(drive, ScanForSecondDisc::No); }); [this](const QString& drive) { StartGame(drive, ScanForSecondDisc::No); });
connect(m_menu_bar, &MenuBar::OpenUserFolder, this, &MainWindow::OpenUserFolder);
// Emulation // Emulation
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause); connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
@ -752,6 +754,14 @@ void MainWindow::EjectDisc()
Core::RunAsCPUThread([] { DVDInterface::EjectDisc(DVDInterface::EjectCause::User); }); Core::RunAsCPUThread([] { DVDInterface::EjectDisc(DVDInterface::EjectCause::User); });
} }
void MainWindow::OpenUserFolder()
{
std::string path = File::GetUserPath(D_USER_IDX);
QUrl url = QUrl::fromLocalFile(QString::fromStdString(path));
QDesktopServices::openUrl(url);
}
void MainWindow::Open() void MainWindow::Open()
{ {
QStringList files = PromptFileNames(); QStringList files = PromptFileNames();

View File

@ -188,6 +188,8 @@ private:
void ChangeDisc(); void ChangeDisc();
void EjectDisc(); void EjectDisc();
void OpenUserFolder();
QStringList PromptFileNames(); QStringList PromptFileNames();
void UpdateScreenSaverInhibition(); void UpdateScreenSaverInhibition();

View File

@ -216,6 +216,11 @@ void MenuBar::AddFileMenu()
file_menu->addSeparator(); file_menu->addSeparator();
m_open_user_folder =
file_menu->addAction(tr("Open &User Folder"), this, &MenuBar::OpenUserFolder);
file_menu->addSeparator();
m_exit_action = file_menu->addAction(tr("E&xit"), this, &MenuBar::Exit); m_exit_action = file_menu->addAction(tr("E&xit"), this, &MenuBar::Exit);
m_exit_action->setShortcuts({QKeySequence::Quit, QKeySequence(Qt::ALT | Qt::Key_F4)}); m_exit_action->setShortcuts({QKeySequence::Quit, QKeySequence(Qt::ALT | Qt::Key_F4)});
} }

View File

@ -56,6 +56,7 @@ signals:
void ChangeDisc(); void ChangeDisc();
void BootDVDBackup(const QString& backup); void BootDVDBackup(const QString& backup);
void EjectDisc(); void EjectDisc();
void OpenUserFolder();
// Emulation // Emulation
void Play(); void Play();
@ -194,6 +195,7 @@ private:
QAction* m_change_disc; QAction* m_change_disc;
QAction* m_eject_disc; QAction* m_eject_disc;
QMenu* m_backup_menu; QMenu* m_backup_menu;
QAction* m_open_user_folder;
// Tools // Tools
QAction* m_wad_install_action; QAction* m_wad_install_action;