mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-30 16:20:20 +00:00
Qt: fix opening folders by using util functions
This commit is contained in:
parent
8399516475
commit
6f306121a6
@ -1101,6 +1101,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Emu\Io\recording_config.cpp">
|
<ClCompile Include="Emu\Io\recording_config.cpp">
|
||||||
<Filter>Emu\Io</Filter>
|
<Filter>Emu\Io</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="Emu\Cell\Modules\HLE_PATCHES.cpp">
|
<ClCompile Include="Emu\Cell\Modules\HLE_PATCHES.cpp">
|
||||||
<Filter>Emu\Cell\Modules</Filter>
|
<Filter>Emu\Cell\Modules</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
@ -12,6 +13,8 @@
|
|||||||
#include "Utilities/File.h"
|
#include "Utilities/File.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
LOG_CHANNEL(gui_log, "GUI");
|
||||||
|
|
||||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||||
constexpr auto qstr = QString::fromStdString;
|
constexpr auto qstr = QString::fromStdString;
|
||||||
|
|
||||||
@ -394,7 +397,6 @@ namespace gui
|
|||||||
|
|
||||||
void open_dir(const std::string& spath)
|
void open_dir(const std::string& spath)
|
||||||
{
|
{
|
||||||
fs::create_dir(spath);
|
|
||||||
const QString path = qstr(spath);
|
const QString path = qstr(spath);
|
||||||
|
|
||||||
if (fs::is_file(spath))
|
if (fs::is_file(spath))
|
||||||
@ -402,18 +404,46 @@ namespace gui
|
|||||||
// open directory and select file
|
// open directory and select file
|
||||||
// https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt
|
// https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
QProcess::startDetached("explorer.exe", { "/select,", QDir::toNativeSeparators(path) });
|
const QString cleaned_path = QDir::toNativeSeparators(path);
|
||||||
|
gui_log.notice("gui::utils::open_dir: About to open file path '%s' (original: '%s')", cleaned_path.toStdString(), spath);
|
||||||
|
|
||||||
|
if (!QProcess::startDetached("explorer.exe", {"/select,", cleaned_path}))
|
||||||
|
{
|
||||||
|
gui_log.error("gui::utils::open_dir: Failed to start explorer process");
|
||||||
|
}
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
gui_log.notice("gui::utils::open_dir: About to open file path '%s'", spath);
|
||||||
|
|
||||||
QProcess::execute("/usr/bin/osascript", { "-e", "tell application \"Finder\" to reveal POSIX file \"" + path + "\"" });
|
QProcess::execute("/usr/bin/osascript", { "-e", "tell application \"Finder\" to reveal POSIX file \"" + path + "\"" });
|
||||||
QProcess::execute("/usr/bin/osascript", { "-e", "tell application \"Finder\" to activate" });
|
QProcess::execute("/usr/bin/osascript", { "-e", "tell application \"Finder\" to activate" });
|
||||||
#else
|
#else
|
||||||
// open parent directory
|
// open parent directory
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(qstr(fs::get_parent_dir(spath))));
|
const QUrl url = QUrl::fromLocalFile(qstr(fs::get_parent_dir(spath)));
|
||||||
|
const std::string url_path = url.toString().toStdString();
|
||||||
|
gui_log.notice("gui::utils::open_dir: About to open parent dir url '%s' for path '%s'", url_path, spath);
|
||||||
|
|
||||||
|
if (!QDesktopServices::openUrl(url))
|
||||||
|
{
|
||||||
|
gui_log.error("gui::utils::open_dir: Failed to open parent dir url '%s' for path '%s'", url_path, spath);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QUrl url = QUrl::fromLocalFile(path);
|
||||||
|
const std::string url_path = url.toString().toStdString();
|
||||||
|
gui_log.notice("gui::utils::open_dir: About to open dir url '%s' for path '%s'", url_path, spath);
|
||||||
|
|
||||||
|
if (!QDesktopServices::openUrl(url))
|
||||||
|
{
|
||||||
|
gui_log.error("gui::utils::open_dir: Failed to open dir url '%s' for path '%s'", url_path, spath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_dir(const QString& path)
|
void open_dir(const QString& path)
|
||||||
|
@ -210,7 +210,7 @@ void save_manager_dialog::Init()
|
|||||||
}
|
}
|
||||||
const int idx_real = item->data(Qt::UserRole).toInt();
|
const int idx_real = item->data(Qt::UserRole).toInt();
|
||||||
const QString path = qstr(m_dir + m_save_entries[idx_real].dirName + "/");
|
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(slider_icon_size, &QAbstractSlider::valueChanged, this, &save_manager_dialog::SetIconSize);
|
||||||
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_manager_dialog::OnSort);
|
connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_manager_dialog::OnSort);
|
||||||
@ -488,7 +488,7 @@ void save_manager_dialog::ShowContextMenu(const QPoint &pos)
|
|||||||
}
|
}
|
||||||
const int idx_real = item->data(Qt::UserRole).toInt();
|
const int idx_real = item->data(Qt::UserRole).toInt();
|
||||||
const QString path = qstr(m_dir + m_save_entries[idx_real].dirName + "/");
|
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));
|
menu->exec(m_list->viewport()->mapToGlobal(pos));
|
||||||
|
@ -734,7 +734,7 @@ void trophy_manager_dialog::ShowTrophyTableContextMenu(const QPoint& pos)
|
|||||||
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
|
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
|
||||||
{
|
{
|
||||||
const QString path = qstr(m_trophies_db[db_ind]->path);
|
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);
|
menu->addAction(show_trophy_dir);
|
||||||
@ -802,7 +802,7 @@ void trophy_manager_dialog::ShowGameTableContextMenu(const QPoint& pos)
|
|||||||
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
|
connect(show_trophy_dir, &QAction::triggered, this, [this, db_ind]()
|
||||||
{
|
{
|
||||||
const QString path = qstr(m_trophies_db[db_ind]->path);
|
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);
|
menu->addAction(show_trophy_dir);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "main_application.h"
|
#include "main_application.h"
|
||||||
#include "gui_settings.h"
|
#include "gui_settings.h"
|
||||||
#include "persistent_settings.h"
|
#include "persistent_settings.h"
|
||||||
|
#include "qt_utils.h"
|
||||||
|
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "Emu/system_utils.hpp"
|
#include "Emu/system_utils.hpp"
|
||||||
@ -426,7 +427,7 @@ void user_manager_dialog::ShowContextMenu(const QPoint &pos)
|
|||||||
connect(show_dir_act, &QAction::triggered, this, [this, key]()
|
connect(show_dir_act, &QAction::triggered, this, [this, key]()
|
||||||
{
|
{
|
||||||
const QString path = qstr(m_user_list[key].GetUserDir());
|
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); });
|
connect(user_id_act, &QAction::triggered, this, [this] {OnSort(0); });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user