diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index f5349a3e0e..58c6eb9524 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -373,10 +373,8 @@ QString game_list_frame::GetLastPlayedBySerial(const QString& serial) return m_persistent_settings->GetLastPlayed(serial); } -QString game_list_frame::GetPlayTimeBySerial(const QString& serial) +QString game_list_frame::GetPlayTimeByMs(int elapsed_ms) { - const qint64 elapsed_ms = m_persistent_settings->GetPlaytime(serial); - if (elapsed_ms <= 0) { return ""; @@ -1983,6 +1981,10 @@ int game_list_frame::PopulateGameList() app_version = tr("%0 (Update available: %1)").arg(app_version, game->compat.version); } + // Playtimes + const qint64 elapsed_ms = m_persistent_settings->GetPlaytime(serial); + const QString last_played = GetLastPlayedBySerial(serial); + m_gameList->setItem(row, gui::column_icon, icon_item); m_gameList->setItem(row, gui::column_name, title_item); m_gameList->setItem(row, gui::column_serial, serial_item); @@ -1994,8 +1996,8 @@ int game_list_frame::PopulateGameList() m_gameList->setItem(row, gui::column_resolution, new custom_table_widget_item(GetStringFromU32(game->info.resolution, resolution::mode, true))); m_gameList->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, sound::format, true))); m_gameList->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, parental::level), Qt::UserRole, game->info.parental_lvl)); - m_gameList->setItem(row, gui::column_last_play, new custom_table_widget_item(GetLastPlayedBySerial(serial))); - m_gameList->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeBySerial(serial))); + m_gameList->setItem(row, gui::column_last_play, new custom_table_widget_item(last_played, Qt::UserRole, QDate::fromString(last_played, gui::persistent::last_played_date_format))); + m_gameList->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms)); m_gameList->setItem(row, gui::column_compat, compat_item); if (selected_item == game->info.icon_path) diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 515db98548..a02f65c018 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -256,7 +256,7 @@ private: bool CreatePPUCache(const game_info& game); QString GetLastPlayedBySerial(const QString& serial); - QString GetPlayTimeBySerial(const QString& serial); + QString GetPlayTimeByMs(int elapsed_ms); std::string GetCacheDirBySerial(const std::string& serial); std::string GetDataDirBySerial(const std::string& serial); std::string CurrentSelectionIconPath(); diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index c3782868f4..e6d0d13dbe 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -237,7 +237,7 @@ void gui_application::StopPlaytime() const qint64 playtime = m_persistent_settings->GetPlaytime(serial) + m_timer_playtime.elapsed(); m_persistent_settings->SetPlaytime(serial, playtime); - m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString("MMMM d yyyy")); + m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString(gui::persistent::last_played_date_format)); m_timer_playtime.invalidate(); } diff --git a/rpcs3/rpcs3qt/persistent_settings.cpp b/rpcs3/rpcs3qt/persistent_settings.cpp index d46940612c..3b15b957d2 100644 --- a/rpcs3/rpcs3qt/persistent_settings.cpp +++ b/rpcs3/rpcs3qt/persistent_settings.cpp @@ -8,13 +8,13 @@ persistent_settings::persistent_settings(QObject* parent) : settings(parent) void persistent_settings::SetPlaytime(const QString& serial, const qint64& elapsed) { - m_playtime[serial] = elapsed; - SetValue(gui::persistent::playtime, serial, elapsed); + m_playtime[serial] = std::max(0, elapsed); + SetValue(gui::persistent::playtime, serial, m_playtime[serial]); } qint64 persistent_settings::GetPlaytime(const QString& serial) { - return m_playtime[serial]; + return std::max(0, m_playtime[serial]); } void persistent_settings::SetLastPlayed(const QString& serial, const QString& date) diff --git a/rpcs3/rpcs3qt/persistent_settings.h b/rpcs3/rpcs3qt/persistent_settings.h index b6f8dd7ded..86a8c963b4 100644 --- a/rpcs3/rpcs3qt/persistent_settings.h +++ b/rpcs3/rpcs3qt/persistent_settings.h @@ -12,6 +12,9 @@ namespace gui // Entry names const QString playtime = "Playtime"; const QString last_played = "LastPlayed"; + + // Date format + const QString last_played_date_format = "MMMM d yyyy"; } }