Use fs::path::native whenever possible, avoid unnecessary fs->string conversions in GUI code (#1064)

* Use filesystem::path whenever possible, remove fs::path::string

* My hatred for Windows grows with every passing day

* More Qt stuff

* custom u8string formatter for fmt library

* Use u8string for imgui

* Fix toml errors hopefully

* Fix not printing issue

* Oh and on SDL

* I hate Windows even more today

* fix toml reading utf-8 paths

also small fix for fmt::UTF

* Formatting

* Fix QT path to run games

* Fix path logging in save data

* Fix trophy path handling

* Update game_list_frame.cpp

fixed snd0path

* Update main_window.cpp

fix snd0path

* Update main_window.cpp

* paths finally fixed

* git info in WIP versions title

---------

Co-authored-by: Vinicius Rangel <me@viniciusrangel.dev>
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
Paris Oplopoios 2024-09-26 11:41:59 +03:00 committed by GitHub
parent 54e2179337
commit 6295d6c416
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 271 additions and 125 deletions

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/path_util.h"
#include "common/string_util.h"
#include "game_list_frame.h"
GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent)
@ -73,7 +74,8 @@ void GameListFrame::PlayBackgroundMusic(QTableWidgetItem* item) {
BackgroundMusicPlayer::getInstance().stopMusic();
return;
}
const auto snd0path = QString::fromStdString(m_game_info->m_games[item->row()].snd0_path);
QString snd0path;
Common::FS::PathToQString(snd0path, m_game_info->m_games[item->row()].snd0_path);
BackgroundMusicPlayer::getInstance().playMusic(snd0path);
}
@ -88,7 +90,9 @@ void GameListFrame::PopulateGameList() {
SetTableItem(i, 4, QString::fromStdString(m_game_info->m_games[i].fw));
SetTableItem(i, 5, QString::fromStdString(m_game_info->m_games[i].size));
SetTableItem(i, 6, QString::fromStdString(m_game_info->m_games[i].version));
SetTableItem(i, 7, QString::fromStdString(m_game_info->m_games[i].path));
QString path;
Common::FS::PathToQString(path, m_game_info->m_games[i].path);
SetTableItem(i, 7, path);
}
}
@ -98,14 +102,12 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
return;
}
QString pic1Path = QString::fromStdString(m_game_info->m_games[item->row()].pic_path);
QString pic1Path;
Common::FS::PathToQString(pic1Path, m_game_info->m_games[item->row()].pic_path);
const auto blurredPic1Path = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
m_game_info->m_games[item->row()].serial / "pic1.png";
#ifdef _WIN32
const auto blurredPic1PathQt = QString::fromStdWString(blurredPic1Path.wstring());
#else
const auto blurredPic1PathQt = QString::fromStdString(blurredPic1Path.string());
#endif
QString blurredPic1PathQt;
Common::FS::PathToQString(blurredPic1PathQt, blurredPic1Path);
backgroundImage = QImage(blurredPic1PathQt);
if (backgroundImage.isNull()) {