mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
Qt: Fix translation of %n hours
This commit is contained in:
parent
e444eb713a
commit
a59a42f35b
|
@ -1065,7 +1065,7 @@ TinyString GameList::FormatTimespan(std::time_t timespan, bool long_format)
|
|||
else
|
||||
{
|
||||
if (hours > 0)
|
||||
ret.format(TRANSLATE_FS("GameList", "{} hours"), hours);
|
||||
ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n hours", "", hours));
|
||||
else
|
||||
ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n minutes", "", minutes));
|
||||
}
|
||||
|
|
|
@ -213,6 +213,17 @@ void GameListModel::invalidateCoverForPath(const std::string& path)
|
|||
emit dataChanged(mi, mi, {Qt::DecorationRole});
|
||||
}
|
||||
|
||||
QString GameListModel::formatTimespan(time_t timespan)
|
||||
{
|
||||
// avoid an extra string conversion
|
||||
const u32 hours = static_cast<u32>(timespan / 3600);
|
||||
const u32 minutes = static_cast<u32>((timespan % 3600) / 60);
|
||||
if (hours > 0)
|
||||
return qApp->translate("GameList", "%n hours", "", hours);
|
||||
else
|
||||
return qApp->translate("GameList", "%n minutes", "", minutes);
|
||||
}
|
||||
|
||||
int GameListModel::getCoverArtWidth() const
|
||||
{
|
||||
return std::max(static_cast<int>(static_cast<float>(COVER_ART_WIDTH) * m_cover_scale), 1);
|
||||
|
@ -316,7 +327,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
if (ge->total_played_time == 0)
|
||||
return {};
|
||||
else
|
||||
return QtUtils::StringViewToQString(GameList::FormatTimespan(ge->total_played_time));
|
||||
return formatTimespan(ge->total_played_time);
|
||||
}
|
||||
|
||||
case Column_LastPlayed:
|
||||
|
|
|
@ -84,6 +84,8 @@ private:
|
|||
void loadOrGenerateCover(const GameList::Entry* ge);
|
||||
void invalidateCoverForPath(const std::string& path);
|
||||
|
||||
static QString formatTimespan(time_t timespan);
|
||||
|
||||
float m_cover_scale = 0.0f;
|
||||
bool m_show_titles_for_covers = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue