mirror of
https://github.com/izzy2lost/xenia-edge.git
synced 2026-07-06 00:20:26 -07:00
[UI] Fix UTF8 path handling
This commit is contained in:
@@ -96,9 +96,7 @@ bool QtFilePicker::Show(Window* parent_window) {
|
||||
// Use static QFileDialog function to avoid Qt container ABI issues on Windows
|
||||
QString initial_dir;
|
||||
if (!initial_directory().empty()) {
|
||||
std::string dir_str = initial_directory().string();
|
||||
initial_dir =
|
||||
QString::fromUtf8(dir_str.c_str(), static_cast<int>(dir_str.size()));
|
||||
initial_dir = SafeQString(xe::path_to_utf8(initial_directory()));
|
||||
}
|
||||
|
||||
// Don't apply file filters - show all files
|
||||
|
||||
@@ -619,7 +619,8 @@ void GameListDialogQt::PopulateTable() {
|
||||
// Apply filter
|
||||
if (!filter_text.isEmpty()) {
|
||||
QString title = SafeQString(entry.title_name).toLower();
|
||||
QString path = SafeQString(entry.path_to_file.string()).toLower();
|
||||
QString path =
|
||||
SafeQString(xe::path_to_utf8(entry.path_to_file)).toLower();
|
||||
|
||||
if (!title.contains(filter_text) && !path.contains(filter_text)) {
|
||||
continue;
|
||||
@@ -714,7 +715,8 @@ void GameListDialogQt::PopulateTable() {
|
||||
|
||||
// Path - smaller font (only show if path is available)
|
||||
if (!entry.path_to_file.empty()) {
|
||||
auto* path_label = new QLabel(SafeQString(entry.path_to_file.string()));
|
||||
auto* path_label =
|
||||
new QLabel(SafeQString(xe::path_to_utf8(entry.path_to_file)));
|
||||
path_label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
path_label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
QFont path_font = path_label->font();
|
||||
@@ -769,7 +771,7 @@ void GameListDialogQt::PopulateTable() {
|
||||
// Store the path and title_id in the row for later retrieval
|
||||
table_widget_->setItem(row, 0, new QTableWidgetItem());
|
||||
table_widget_->item(row, 0)->setData(
|
||||
Qt::UserRole, SafeQString(entry.path_to_file.string()));
|
||||
Qt::UserRole, SafeQString(xe::path_to_utf8(entry.path_to_file)));
|
||||
table_widget_->item(row, 0)->setData(Qt::UserRole + 1, entry.title_id);
|
||||
}
|
||||
}
|
||||
@@ -959,7 +961,7 @@ void GameListDialogQt::OnGameRightClicked(const QPoint& pos) {
|
||||
for (const auto& patch_path : available_patches) {
|
||||
// Extract a display name from the filename
|
||||
// Format: "TITLEID - Game Name (Version).patch.toml"
|
||||
std::string filename = patch_path.filename().string();
|
||||
std::string filename = xe::path_to_utf8(patch_path.filename());
|
||||
|
||||
// Remove the title ID prefix and " - "
|
||||
std::string display_name = filename;
|
||||
@@ -1120,7 +1122,7 @@ void GameListDialogQt::LaunchGame(const std::filesystem::path& path,
|
||||
QString("The game file does not exist:\n\n%1\n\n"
|
||||
"The path will be removed from the game list.\n"
|
||||
"Please select the correct game file.")
|
||||
.arg(SafeQString(path.string())));
|
||||
.arg(SafeQString(xe::path_to_utf8(path))));
|
||||
|
||||
// Remove the bad path from all dashboard GPDs using ProfileManager
|
||||
if (title_id != 0) {
|
||||
@@ -1656,7 +1658,8 @@ std::vector<std::filesystem::path> GameListDialogQt::FindPatchesForTitle(
|
||||
}
|
||||
}
|
||||
} catch (const std::filesystem::filesystem_error& e) {
|
||||
XELOGE("Error scanning patches directory {}: {}", dir.string(), e.what());
|
||||
XELOGE("Error scanning patches directory {}: {}", xe::path_to_utf8(dir),
|
||||
e.what());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1711,7 +1714,7 @@ std::optional<std::filesystem::path> GameListDialogQt::ShowDiscSelectionDialog(
|
||||
QString disc_label = disc.label.empty() ? QString("Disc %1").arg(disc_num)
|
||||
: SafeQString(disc.label);
|
||||
auto* list_item = new QListWidgetItem(disc_label);
|
||||
list_item->setData(Qt::UserRole, SafeQString(disc.path.string()));
|
||||
list_item->setData(Qt::UserRole, SafeQString(xe::path_to_utf8(disc.path)));
|
||||
list_widget->addItem(list_item);
|
||||
disc_num++;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "third_party/fmt/include/fmt/format.h"
|
||||
#include "third_party/tomlplusplus/toml.hpp"
|
||||
#include "xenia/app/emulator_window.h"
|
||||
#include "xenia/base/filesystem.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/ui/qt_util.h"
|
||||
|
||||
@@ -51,7 +52,7 @@ void PatchesDialogQt::SetupUI() {
|
||||
auto* main_layout = new QVBoxLayout(this);
|
||||
|
||||
// Extract display name from patch file
|
||||
std::string filename = patch_file_.filename().string();
|
||||
std::string filename = xe::path_to_utf8(patch_file_.filename());
|
||||
std::string display_name = filename;
|
||||
|
||||
// Remove title ID prefix and " - "
|
||||
@@ -120,23 +121,25 @@ void PatchesDialogQt::LoadPatchFile() {
|
||||
patches_.clear();
|
||||
|
||||
if (!std::filesystem::exists(patch_file_)) {
|
||||
XELOGE("Patch file does not exist: {}", patch_file_.filename().string());
|
||||
XELOGE("Patch file does not exist: {}",
|
||||
xe::path_to_utf8(patch_file_.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
auto patch_toml = toml::parse_file(patch_file_.string());
|
||||
auto patch_toml = toml::parse_file(xe::path_to_utf8(patch_file_));
|
||||
|
||||
// Check if there's a patch array
|
||||
if (!patch_toml.contains("patch")) {
|
||||
XELOGE("No patches found in file: {}", patch_file_.filename().string());
|
||||
XELOGE("No patches found in file: {}",
|
||||
xe::path_to_utf8(patch_file_.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
auto patches_array = patch_toml["patch"].as_array();
|
||||
if (!patches_array) {
|
||||
XELOGE("'patch' is not an array in file: {}",
|
||||
patch_file_.filename().string());
|
||||
xe::path_to_utf8(patch_file_.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,8 +224,8 @@ void PatchesDialogQt::LoadPatchFile() {
|
||||
}
|
||||
|
||||
} catch (const toml::parse_error& err) {
|
||||
XELOGE("Failed to parse patch file {}: {}", patch_file_.filename().string(),
|
||||
err.what());
|
||||
XELOGE("Failed to parse patch file {}: {}",
|
||||
xe::path_to_utf8(patch_file_.filename()), err.what());
|
||||
|
||||
auto* error_label =
|
||||
new QLabel(QString("Error loading patches: %1").arg(err.what()),
|
||||
@@ -303,7 +306,8 @@ bool PatchesDialogQt::UpdateSinglePatchEnabledLine(
|
||||
|
||||
void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
if (!std::filesystem::exists(patch_file_)) {
|
||||
XELOGE("Patch file does not exist: {}", patch_file_.filename().string());
|
||||
XELOGE("Patch file does not exist: {}",
|
||||
xe::path_to_utf8(patch_file_.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,7 +330,7 @@ void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
std::filesystem::copy_options::overwrite_existing);
|
||||
|
||||
XELOGI("Copied bundled patch to storage_root: {}",
|
||||
patch_file_.filename().string());
|
||||
xe::path_to_utf8(patch_file_.filename()));
|
||||
}
|
||||
|
||||
// Now read from and write to the storage_root version
|
||||
@@ -336,7 +340,7 @@ void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
std::ifstream infile(write_path);
|
||||
if (!infile.is_open()) {
|
||||
XELOGE("Failed to open patch file for reading: {}",
|
||||
write_path.filename().string());
|
||||
xe::path_to_utf8(write_path.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -350,7 +354,7 @@ void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
// Update only the specific patch's is_enabled value
|
||||
if (!UpdateSinglePatchEnabledLine(lines, patch_index, new_value)) {
|
||||
XELOGE("Failed to update patch #{} enabled state in {}", patch_index + 1,
|
||||
write_path.filename().string());
|
||||
xe::path_to_utf8(write_path.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -358,7 +362,7 @@ void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
std::ofstream outfile(write_path, std::ios::out | std::ios::trunc);
|
||||
if (!outfile.is_open()) {
|
||||
XELOGE("Failed to open patch file for writing: {}",
|
||||
write_path.filename().string());
|
||||
xe::path_to_utf8(write_path.filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -371,7 +375,7 @@ void PatchesDialogQt::SavePatchToggle(size_t patch_index, bool new_value) {
|
||||
outfile.close();
|
||||
|
||||
XELOGI("Updated patch #{} in {}", patch_index + 1,
|
||||
write_path.filename().string());
|
||||
xe::path_to_utf8(write_path.filename()));
|
||||
|
||||
// Update info label to show changes pending
|
||||
info_label_->setText(
|
||||
|
||||
Reference in New Issue
Block a user