Skip to content

Commit

Permalink
Qt: fix opening folders by using util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Dec 10, 2022
1 parent 8399516 commit 8058f8c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions rpcs3/emucore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@
</ClCompile>
<ClCompile Include="Emu\Io\recording_config.cpp">
<Filter>Emu\Io</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\Modules\HLE_PATCHES.cpp">
<Filter>Emu\Cell\Modules</Filter>
</ClCompile>
Expand Down
12 changes: 11 additions & 1 deletion rpcs3/rpcs3qt/qt_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "stdafx.h"
#include "qt_utils.h"
#include <QApplication>
#include <QBitmap>
Expand All @@ -12,6 +13,8 @@
#include "Utilities/File.h"
#include <cmath>

LOG_CHANNEL(gui_log, "GUI");

inline std::string sstr(const QString& _in) { return _in.toStdString(); }
constexpr auto qstr = QString::fromStdString;

Expand Down Expand Up @@ -394,7 +397,8 @@ namespace gui

void open_dir(const std::string& spath)
{
fs::create_dir(spath);
gui_log.notice("gui::utils::open_dir: About to open path '%s'", spath);

const QString path = qstr(spath);

if (fs::is_file(spath))
Expand All @@ -413,6 +417,12 @@ namespace gui
return;
}

if (!fs::is_dir && !fs::create_path(spath))
{
gui_log.error("gui::utils::open_dir: Failed to create path '%s' (%s)", spath, fs::g_tls_error);
return;
}

QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/save_manager_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void save_manager_dialog::Init()
}
const int idx_real = item->data(Qt::UserRole).toInt();
const QString path = qstr(m_dir + m_save_entries[idx_real].dirName + "/");
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
gui::utils::open_dir(path);
});
connect(slider_icon_size, &QAbstractSlider::valueChanged, this, &save_manager_dialog::SetIconSize);
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_manager_dialog::OnSort);
Expand Down Expand Up @@ -488,7 +488,7 @@ void save_manager_dialog::ShowContextMenu(const QPoint &pos)
}
const int idx_real = item->data(Qt::UserRole).toInt();
const QString path = qstr(m_dir + m_save_entries[idx_real].dirName + "/");
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
gui::utils::open_dir(path);
});

menu->exec(m_list->viewport()->mapToGlobal(pos));
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/trophy_manager_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ void trophy_manager_dialog::ShowTrophyTableContextMenu(const QPoint& pos)
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
{
const QString path = qstr(m_trophies_db[db_ind]->path);
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
gui::utils::open_dir(path);
});

menu->addAction(show_trophy_dir);
Expand Down Expand Up @@ -802,7 +802,7 @@ void trophy_manager_dialog::ShowGameTableContextMenu(const QPoint& pos)
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
{
const QString path = qstr(m_trophies_db[db_ind]->path);
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
gui::utils::open_dir(path);
});

menu->addAction(show_trophy_dir);
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/rpcs3qt/user_manager_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "main_application.h"
#include "gui_settings.h"
#include "persistent_settings.h"
#include "qt_utils.h"

#include "Emu/System.h"
#include "Emu/system_utils.hpp"
Expand Down Expand Up @@ -426,7 +427,7 @@ void user_manager_dialog::ShowContextMenu(const QPoint &pos)
connect(show_dir_act, &QAction::triggered, this, [this, key]()
{
const QString path = qstr(m_user_list[key].GetUserDir());
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
gui::utils::open_dir(path);
});

connect(user_id_act, &QAction::triggered, this, [this] {OnSort(0); });
Expand Down

0 comments on commit 8058f8c

Please sign in to comment.