From 87b8342b08bb480caeaf38bc6e74d639e4a8e14e Mon Sep 17 00:00:00 2001 From: offtkp Date: Wed, 25 Sep 2024 15:46:21 +0300 Subject: [PATCH] Fix toml errors hopefully --- src/common/config.cpp | 9 ++++----- src/common/config.h | 4 ++-- src/qt_gui/game_install_dialog.cpp | 2 +- src/qt_gui/main.cpp | 2 +- src/qt_gui/main_window.cpp | 5 +++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 370a4d27a..4b264b140 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -35,7 +35,7 @@ static bool vkMarkers = false; static bool vkCrashDiagnostic = false; // Gui -std::filesystem::path settings_install_dir = ""; +std::filesystem::path settings_install_dir = {}; u32 main_window_geometry_x = 400; u32 main_window_geometry_y = 400; u32 main_window_geometry_w = 1280; @@ -241,7 +241,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) { main_window_geometry_w = w; main_window_geometry_h = h; } -void setGameInstallDir(const std::string& dir) { +void setGameInstallDir(const std::filesystem::path& dir) { settings_install_dir = dir; } void setMainWindowTheme(u32 theme) { @@ -297,7 +297,7 @@ u32 getMainWindowGeometryW() { u32 getMainWindowGeometryH() { return main_window_geometry_h; } -std::string getGameInstallDir() { +std::filesystem::path getGameInstallDir() { return settings_install_dir; } u32 getMainWindowTheme() { @@ -415,8 +415,7 @@ void load(const std::filesystem::path& path) { mw_themes = toml::find_or(gui, "theme", 0); m_window_size_W = toml::find_or(gui, "mw_width", 0); m_window_size_H = toml::find_or(gui, "mw_height", 0); - settings_install_dir = - toml::find_or(gui, "installDir", {}); + settings_install_dir = toml::find_or(gui, "installDir", {}); main_window_geometry_x = toml::find_or(gui, "geometry_x", 0); main_window_geometry_y = toml::find_or(gui, "geometry_y", 0); main_window_geometry_w = toml::find_or(gui, "geometry_w", 0); diff --git a/src/common/config.h b/src/common/config.h index 7e717fe71..abc4b4b2d 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -66,7 +66,7 @@ bool vkCrashDiagnosticEnabled(); // Gui void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h); -void setGameInstallDir(const std::string& dir); +void setGameInstallDir(const std::filesystem::path& dir); void setMainWindowTheme(u32 theme); void setIconSize(u32 size); void setIconSizeGrid(u32 size); @@ -84,7 +84,7 @@ u32 getMainWindowGeometryX(); u32 getMainWindowGeometryY(); u32 getMainWindowGeometryW(); u32 getMainWindowGeometryH(); -std::string getGameInstallDir(); +std::filesystem::path getGameInstallDir(); u32 getMainWindowTheme(); u32 getIconSize(); u32 getIconSizeGrid(); diff --git a/src/qt_gui/game_install_dialog.cpp b/src/qt_gui/game_install_dialog.cpp index 4cfd66fb8..d8cc7a837 100644 --- a/src/qt_gui/game_install_dialog.cpp +++ b/src/qt_gui/game_install_dialog.cpp @@ -78,7 +78,7 @@ void GameInstallDialog::Save() { return; } - Config::setGameInstallDir(gamesDirectory.toStdString()); + Config::setGameInstallDir(Common::FS::PathFromQString(gamesDirectory)); const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::save(config_dir / "config.toml"); accept(); diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 68a674f5e..50de68509 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) { bool has_command_line_argument = argc > 1; // Check if the game install directory is set - if (Config::getGameInstallDir() == "" && !has_command_line_argument) { + if (Config::getGameInstallDir().empty() && !has_command_line_argument) { GameInstallDialog dlg; dlg.exec(); } diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 08a973c86..808058b73 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -631,7 +631,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int pkg = PKG(); pkg.Open(file); std::string failreason; - auto extract_path = std::filesystem::path(Config::getGameInstallDir()) / pkg.GetTitleID(); + auto extract_path = Config::getGameInstallDir() / pkg.GetTitleID(); QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); QString gameDirPath; Common::FS::PathToQString(gameDirPath, extract_path); @@ -779,7 +779,8 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int QFutureWatcher futureWatcher; connect(&futureWatcher, &QFutureWatcher::finished, this, [=, this]() { if (pkgNum == nPkg) { - QString path = QString::fromStdString(Config::getGameInstallDir()); + QString path; + Common::FS::PathToQString(path, Config::getGameInstallDir()); QMessageBox extractMsgBox(this); extractMsgBox.setWindowTitle(tr("Extraction Finished")); extractMsgBox.setText(