mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Qt: use Localized::GetVerboseTimeByMs
This commit is contained in:
parent
425e032a62
commit
13e166084d
@ -386,80 +386,6 @@ QString game_list_frame::GetLastPlayedBySerial(const QString& serial)
|
||||
return m_persistent_settings->GetLastPlayed(serial);
|
||||
}
|
||||
|
||||
QString game_list_frame::GetPlayTimeByMs(int elapsed_ms)
|
||||
{
|
||||
if (elapsed_ms <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const qint64 elapsed_seconds = (elapsed_ms / 1000) + ((elapsed_ms % 1000) > 0 ? 1 : 0);
|
||||
const qint64 hours_played = elapsed_seconds / 3600;
|
||||
const qint64 minutes_played = (elapsed_seconds % 3600) / 60;
|
||||
const qint64 seconds_played = (elapsed_seconds % 3600) % 60;
|
||||
|
||||
// For anyone who was wondering why there need to be so many cases:
|
||||
// 1. Using variables won't work for future localization due to varying sentence structure in different languages.
|
||||
// 2. The provided Qt functionality only works if localization is already enabled
|
||||
// 3. The provided Qt functionality only works for single variables
|
||||
|
||||
if (hours_played <= 0)
|
||||
{
|
||||
if (minutes_played <= 0)
|
||||
{
|
||||
if (seconds_played == 1)
|
||||
{
|
||||
return tr("%0 second").arg(seconds_played);
|
||||
}
|
||||
return tr("%0 seconds").arg(seconds_played);
|
||||
}
|
||||
|
||||
if (seconds_played <= 0)
|
||||
{
|
||||
if (minutes_played == 1)
|
||||
{
|
||||
return tr("%0 minute").arg(minutes_played);
|
||||
}
|
||||
return tr("%0 minutes").arg(minutes_played);
|
||||
}
|
||||
if (minutes_played == 1 && seconds_played == 1)
|
||||
{
|
||||
return tr("%0 minute and %1 second").arg(minutes_played).arg(seconds_played);
|
||||
}
|
||||
if (minutes_played == 1)
|
||||
{
|
||||
return tr("%0 minute and %1 seconds").arg(minutes_played).arg(seconds_played);
|
||||
}
|
||||
if (seconds_played == 1)
|
||||
{
|
||||
return tr("%0 minutes and %1 second").arg(minutes_played).arg(seconds_played);
|
||||
}
|
||||
return tr("%0 minutes and %1 seconds").arg(minutes_played).arg(seconds_played);
|
||||
}
|
||||
|
||||
if (minutes_played <= 0)
|
||||
{
|
||||
if (hours_played == 1)
|
||||
{
|
||||
return tr("%0 hour").arg(hours_played);
|
||||
}
|
||||
return tr("%0 hours").arg(hours_played);
|
||||
}
|
||||
if (hours_played == 1 && minutes_played == 1)
|
||||
{
|
||||
return tr("%0 hour and %1 minute").arg(hours_played).arg(minutes_played);
|
||||
}
|
||||
if (hours_played == 1)
|
||||
{
|
||||
return tr("%0 hour and %1 minutes").arg(hours_played).arg(minutes_played);
|
||||
}
|
||||
if (minutes_played == 1)
|
||||
{
|
||||
return tr("%0 hours and %1 minute").arg(hours_played).arg(minutes_played);
|
||||
}
|
||||
return tr("%0 hours and %1 minutes").arg(hours_played).arg(minutes_played);
|
||||
}
|
||||
|
||||
std::string game_list_frame::GetCacheDirBySerial(const std::string& serial)
|
||||
{
|
||||
return fs::get_cache_dir() + "cache/" + serial;
|
||||
@ -2098,7 +2024,7 @@ void game_list_frame::PopulateGameList()
|
||||
m_game_list->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, localized.sound.format, true)));
|
||||
m_game_list->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, localized.parental.level), Qt::UserRole, game->info.parental_lvl));
|
||||
m_game_list->setItem(row, gui::column_last_play, new custom_table_widget_item(locale.toString(last_played, gui::persistent::last_played_date_format_new), Qt::UserRole, last_played));
|
||||
m_game_list->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms));
|
||||
m_game_list->setItem(row, gui::column_playtime, new custom_table_widget_item(localized.GetVerboseTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms));
|
||||
m_game_list->setItem(row, gui::column_compat, compat_item);
|
||||
|
||||
if (selected_item == game->info.icon_path)
|
||||
|
@ -113,7 +113,6 @@ private:
|
||||
bool CreatePPUCache(const game_info& game);
|
||||
|
||||
QString GetLastPlayedBySerial(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();
|
||||
|
@ -3,3 +3,78 @@
|
||||
Localized::Localized()
|
||||
{
|
||||
}
|
||||
|
||||
QString Localized::GetVerboseTimeByMs(qint64 elapsed_ms) const
|
||||
{
|
||||
if (elapsed_ms <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const qint64 elapsed_seconds = (elapsed_ms / 1000) + ((elapsed_ms % 1000) > 0 ? 1 : 0);
|
||||
|
||||
const qint64 hours = elapsed_seconds / 3600;
|
||||
const qint64 minutes = (elapsed_seconds % 3600) / 60;
|
||||
const qint64 seconds = (elapsed_seconds % 3600) % 60;
|
||||
|
||||
// For anyone who was wondering why there need to be so many cases:
|
||||
// 1. Using variables won't work for future localization due to varying sentence structure in different languages.
|
||||
// 2. The provided Qt functionality only works if localization is already enabled
|
||||
// 3. The provided Qt functionality only works for single variables
|
||||
|
||||
if (hours <= 0)
|
||||
{
|
||||
if (hours <= 0)
|
||||
{
|
||||
if (seconds == 1)
|
||||
{
|
||||
return tr("%0 second").arg(seconds);
|
||||
}
|
||||
return tr("%0 seconds").arg(seconds);
|
||||
}
|
||||
|
||||
if (seconds <= 0)
|
||||
{
|
||||
if (minutes == 1)
|
||||
{
|
||||
return tr("%0 minute").arg(minutes);
|
||||
}
|
||||
return tr("%0 minutes").arg(minutes);
|
||||
}
|
||||
if (minutes == 1 && seconds == 1)
|
||||
{
|
||||
return tr("%0 minute and %1 second").arg(minutes).arg(seconds);
|
||||
}
|
||||
if (minutes == 1)
|
||||
{
|
||||
return tr("%0 minute and %1 seconds").arg(minutes).arg(seconds);
|
||||
}
|
||||
if (seconds == 1)
|
||||
{
|
||||
return tr("%0 minutes and %1 second").arg(minutes).arg(seconds);
|
||||
}
|
||||
return tr("%0 minutes and %1 seconds").arg(minutes).arg(seconds);
|
||||
}
|
||||
|
||||
if (minutes <= 0)
|
||||
{
|
||||
if (hours == 1)
|
||||
{
|
||||
return tr("%0 hour").arg(hours);
|
||||
}
|
||||
return tr("%0 hours").arg(hours);
|
||||
}
|
||||
if (hours == 1 && minutes == 1)
|
||||
{
|
||||
return tr("%0 hour and %1 minute").arg(hours).arg(minutes);
|
||||
}
|
||||
if (hours == 1)
|
||||
{
|
||||
return tr("%0 hour and %1 minutes").arg(hours).arg(minutes);
|
||||
}
|
||||
if (minutes == 1)
|
||||
{
|
||||
return tr("%0 hours and %1 minute").arg(hours).arg(minutes);
|
||||
}
|
||||
return tr("%0 hours and %1 minutes").arg(hours).arg(minutes);
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public:
|
||||
|
||||
Localized();
|
||||
|
||||
QString GetVerboseTimeByMs(qint64 elapsed_ms) const;
|
||||
|
||||
const struct category // (see PARAM.SFO in psdevwiki.com) TODO: Disc Categories
|
||||
{
|
||||
// PS3 bootable
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "update_manager.h"
|
||||
#include "progress_dialog.h"
|
||||
#include "localized.h"
|
||||
#include "rpcs3_version.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
#include "Crypto/sha256.h"
|
||||
@ -222,34 +223,29 @@ bool update_manager::handle_json(bool automatic)
|
||||
const QDateTime cur_date = hash_found ? QDateTime::fromString(json_data["current_build"]["datetime"].toString(), date_fmt) : QDateTime::currentDateTimeUtc();
|
||||
const QDateTime lts_date = QDateTime::fromString(latest["datetime"].toString(), date_fmt);
|
||||
|
||||
const qint64 diff_sec = cur_date.secsTo(lts_date);
|
||||
const qint64 days = diff_sec / (60 * 60 * 24);
|
||||
const qint64 hours = (diff_sec / (60 * 60)) % 24;
|
||||
const qint64 minutes = (diff_sec / 60) % 60;
|
||||
const qint64 diff_msec = cur_date.msecsTo(lts_date);
|
||||
|
||||
update_log.notice("Current: %s, latest: %s, difference: %lld", cur_date.toString().toStdString(), lts_date.toString().toStdString(), diff_sec);
|
||||
update_log.notice("Current: %s, latest: %s, difference: %lld ms", cur_date.toString().toStdString(), lts_date.toString().toStdString(), diff_msec);
|
||||
|
||||
Localized localized;
|
||||
|
||||
QString message;
|
||||
|
||||
if (hash_found)
|
||||
{
|
||||
message = tr("A new version of RPCS3 is available!\n\nCurrent version: %0 (%1)\nLatest version: %2 (%3)\nYour version is %4 day(s), %5 hour(s) and %6 minute(s) old.\n\nDo you want to update?")
|
||||
message = tr("A new version of RPCS3 is available!\n\nCurrent version: %0 (%1)\nLatest version: %2 (%3)\nYour version is %4 old.\n\nDo you want to update?")
|
||||
.arg(json_data["current_build"]["version"].toString())
|
||||
.arg(cur_date.toString(date_fmt))
|
||||
.arg(latest["version"].toString())
|
||||
.arg(lts_date.toString(date_fmt))
|
||||
.arg(days)
|
||||
.arg(hours)
|
||||
.arg(minutes);
|
||||
.arg(localized.GetVerboseTimeByMs(diff_msec));
|
||||
}
|
||||
else
|
||||
{
|
||||
message = tr("You're currently using a custom or PR build.\n\nLatest version: %0 (%1)\nThe latest version is %2 day(s), %3 hour(s) and %4 minute(s) old.\n\nDo you want to update to the latest official RPCS3 version?")
|
||||
message = tr("You're currently using a custom or PR build.\n\nLatest version: %0 (%1)\nThe latest version is %2 old.\n\nDo you want to update to the latest official RPCS3 version?")
|
||||
.arg(latest["version"].toString())
|
||||
.arg(lts_date.toString(date_fmt))
|
||||
.arg(std::abs(days))
|
||||
.arg(std::abs(hours))
|
||||
.arg(std::abs(minutes));
|
||||
.arg(localized.GetVerboseTimeByMs(std::abs(diff_msec)));
|
||||
}
|
||||
|
||||
if (QMessageBox::question(m_progress_dialog, tr("Update Available"), message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
|
Loading…
Reference in New Issue
Block a user