Fix Windows UNC Path Handling

In Windows, when using Open Install Folder etc with UNC paths, nothing would happen.
This replaces the "file://"+path usage with QUrl::fromLocalFile(path) which appears to handle this better.
Needs testing under non-Windows.
This commit is contained in:
Bevan Weiss 2020-08-26 18:07:29 +10:00 committed by Megamouse
parent 5669c7497d
commit c39ad1ee12
4 changed files with 7 additions and 7 deletions

View file

@ -300,13 +300,13 @@ namespace gui
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("file:///" + qstr(fs::get_parent_dir(spath)))); QDesktopServices::openUrl(QUrl::fromLocalFile(qstr(fs::get_parent_dir(spath))));
#endif #endif
return; return;
} }
QDesktopServices::openUrl(QUrl("file:///" + path)); QDesktopServices::openUrl(QUrl::fromLocalFile(path));
} }
void open_dir(const QString& path) void open_dir(const QString& path)

View file

@ -203,7 +203,7 @@ void save_manager_dialog::Init(std::string dir)
} }
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("file:///" + path)); QDesktopServices::openUrl(QUrl::fromLocalFile(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);
@ -480,7 +480,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("file:///" + path)); QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}); });
menu->exec(m_list->viewport()->mapToGlobal(pos)); menu->exec(m_list->viewport()->mapToGlobal(pos));

View file

@ -668,7 +668,7 @@ void trophy_manager_dialog::ShowContextMenu(const QPoint& pos)
connect(show_trophy_dir, &QAction::triggered, [=, this]() connect(show_trophy_dir, &QAction::triggered, [=, this]()
{ {
QString path = qstr(m_trophies_db[db_ind]->path); QString path = qstr(m_trophies_db[db_ind]->path);
QDesktopServices::openUrl(QUrl("file:///" + path)); QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}); });
menu->addAction(show_trophy_dir); menu->addAction(show_trophy_dir);

View file

@ -460,7 +460,7 @@ void user_manager_dialog::ShowContextMenu(const QPoint &pos)
connect(show_dir_act, &QAction::triggered, [=, this]() connect(show_dir_act, &QAction::triggered, [=, this]()
{ {
QString path = qstr(m_user_list[key].GetUserDir()); QString path = qstr(m_user_list[key].GetUserDir());
QDesktopServices::openUrl(QUrl("file:///" + path)); QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}); });
connect(user_id_act, &QAction::triggered, this, [=, this] {OnSort(0); }); connect(user_id_act, &QAction::triggered, this, [=, this] {OnSort(0); });