Sort / Formatting

This commit is contained in:
DanielSvoboda 2024-10-09 02:02:39 -03:00
parent 7af54db2f0
commit 5993a42908
3 changed files with 28 additions and 3 deletions

View File

@ -81,8 +81,8 @@ Emulator::Emulator() {
// Load renderdoc module.
VideoCore::LoadRenderDoc();
#ifdef ENABLE_QT_GUI
// Start the timer (Play Time)
#ifdef ENABLE_QT_GUI
start_time = std::chrono::steady_clock::now();
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
QString filePath = QString::fromStdString((user_dir / "play_time.txt").string());

View File

@ -60,6 +60,9 @@ public:
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
game.version = *app_ver;
}
if (const auto play_time = psf.GetString("PLAY_TIME"); play_time.has_value()) {
game.play_time = *play_time;
}
}
return game;
}

View File

@ -32,7 +32,6 @@ GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get, QWidg
this->setColumnWidth(5, 90); // Size
this->setColumnWidth(6, 90); // Version
this->setColumnWidth(7, 100); // Play Time
this->setColumnWidth(8, 90); // Path
QStringList headers;
headers << tr("Icon") << tr("Name") << tr("Serial") << tr("Region") << tr("Firmware")
<< tr("Size") << tr("Version") << tr("Play Time") << tr("Path");
@ -104,7 +103,30 @@ void GameListFrame::PopulateGameList() {
SetTableItem(i, 6, QString::fromStdString(m_game_info->m_games[i].version));
QString playTime = GetPlayTime(m_game_info->m_games[i].serial);
SetTableItem(i, 7, playTime);
if (playTime.isEmpty()) {
m_game_info->m_games[i].play_time = "0:00:00";
SetTableItem(i, 7, "0");
} else {
QStringList timeParts = playTime.split(':');
int hours = timeParts[0].toInt();
int minutes = timeParts[1].toInt();
int seconds = timeParts[2].toInt();
QString formattedPlayTime;
if (hours > 0) {
formattedPlayTime += QString("%1h ").arg(hours);
}
if (minutes > 0) {
formattedPlayTime += QString("%1m ").arg(minutes);
}
if (seconds > 0 || formattedPlayTime.isEmpty()) {
formattedPlayTime += QString("%1s").arg(seconds);
}
formattedPlayTime = formattedPlayTime.trimmed();
m_game_info->m_games[i].play_time = playTime.toStdString();
SetTableItem(i, 7, formattedPlayTime);
}
QString path;
Common::FS::PathToQString(path, m_game_info->m_games[i].path);