Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11450 from OatmealDome/open-user-dir-qt
MenuBar: Add action which opens the user folder
  • Loading branch information
delroth committed Jan 16, 2023
2 parents c4f4ecb + 869aa9e commit 2d783f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Core/DolphinQt/MainWindow.cpp
Expand Up @@ -6,6 +6,7 @@
#include <QApplication>
#include <QCloseEvent>
#include <QDateTime>
#include <QDesktopServices>
#include <QDir>
#include <QDragEnterEvent>
#include <QDropEvent>
Expand Down Expand Up @@ -480,6 +481,7 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::ChangeDisc, this, &MainWindow::ChangeDisc);
connect(m_menu_bar, &MenuBar::BootDVDBackup, this,
[this](const QString& drive) { StartGame(drive, ScanForSecondDisc::No); });
connect(m_menu_bar, &MenuBar::OpenUserFolder, this, &MainWindow::OpenUserFolder);

// Emulation
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
Expand Down Expand Up @@ -752,6 +754,14 @@ void MainWindow::EjectDisc()
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()
{
QStringList files = PromptFileNames();
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinQt/MainWindow.h
Expand Up @@ -188,6 +188,8 @@ class MainWindow final : public QMainWindow
void ChangeDisc();
void EjectDisc();

void OpenUserFolder();

QStringList PromptFileNames();

void UpdateScreenSaverInhibition();
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinQt/MenuBar.cpp
Expand Up @@ -216,6 +216,11 @@ void MenuBar::AddFileMenu()

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->setShortcuts({QKeySequence::Quit, QKeySequence(Qt::ALT | Qt::Key_F4)});
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinQt/MenuBar.h
Expand Up @@ -56,6 +56,7 @@ class MenuBar final : public QMenuBar
void ChangeDisc();
void BootDVDBackup(const QString& backup);
void EjectDisc();
void OpenUserFolder();

// Emulation
void Play();
Expand Down Expand Up @@ -194,6 +195,7 @@ class MenuBar final : public QMenuBar
QAction* m_change_disc;
QAction* m_eject_disc;
QMenu* m_backup_menu;
QAction* m_open_user_folder;

// Tools
QAction* m_wad_install_action;
Expand Down

0 comments on commit 2d783f8

Please sign in to comment.