mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-23 03:28:58 +02:00
[desktop] Display currently applied update in tooltip alongside playtime (#3611)
Also nicely formats both it and play time, alongside fallbacks if they have nothing Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3611 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
d8b2971a2e
commit
80d6172084
2 changed files with 24 additions and 4 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
@ -76,15 +77,34 @@ public:
|
||||||
GameListItemPath() = default;
|
GameListItemPath() = default;
|
||||||
GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data,
|
GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data,
|
||||||
const QString& game_name, const QString& game_type, u64 program_id,
|
const QString& game_name, const QString& game_type, u64 program_id,
|
||||||
u64 play_time) {
|
u64 play_time, const QString &patch_versions) {
|
||||||
setData(type(), TypeRole);
|
setData(type(), TypeRole);
|
||||||
setData(game_path, FullPathRole);
|
setData(game_path, FullPathRole);
|
||||||
setData(game_name, TitleRole);
|
setData(game_name, TitleRole);
|
||||||
setData(qulonglong(program_id), ProgramIdRole);
|
setData(qulonglong(program_id), ProgramIdRole);
|
||||||
setData(game_type, FileTypeRole);
|
setData(game_type, FileTypeRole);
|
||||||
|
|
||||||
setData(QString::fromStdString(PlayTime::PlayTimeManager::GetReadablePlayTime(play_time)),
|
const auto readable_play_time =
|
||||||
Qt::ToolTipRole);
|
play_time > 0
|
||||||
|
? QObject::tr("Play Time: %1").arg(QString::fromStdString(PlayTime::PlayTimeManager::GetReadablePlayTime(play_time)))
|
||||||
|
: QObject::tr("Never Played");
|
||||||
|
|
||||||
|
const auto enabled_update = [patch_versions]() -> QString {
|
||||||
|
const QStringList lines = patch_versions.split(QLatin1Char('\n'));
|
||||||
|
const QRegularExpression regex{QStringLiteral(R"(^Update \(([0-9\.]+)\))")};
|
||||||
|
for (const QString &line : std::as_const(lines)) {
|
||||||
|
const auto match = regex.match(line);
|
||||||
|
if (match.hasMatch() && match.hasCaptured(1))
|
||||||
|
return QObject::tr("Version: %1").arg(match.captured(1));
|
||||||
|
}
|
||||||
|
return QObject::tr("Version: 1.0.0");
|
||||||
|
}();
|
||||||
|
|
||||||
|
const auto tooltip = QStringLiteral("%1\n%2").arg(
|
||||||
|
readable_play_time,
|
||||||
|
enabled_update);
|
||||||
|
|
||||||
|
setData(tooltip, Qt::ToolTipRole);
|
||||||
|
|
||||||
const u32 size = UISettings::values.game_icon_size.GetValue();
|
const u32 size = UISettings::values.game_icon_size.GetValue();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path,
|
||||||
u64 play_time = play_time_manager.GetPlayTime(program_id);
|
u64 play_time = play_time_manager.GetPlayTime(program_id);
|
||||||
return QList<QStandardItem*>{
|
return QList<QStandardItem*>{
|
||||||
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
|
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
|
||||||
file_type_string, program_id, play_time),
|
file_type_string, program_id, play_time, patch_versions),
|
||||||
new GameListItem(file_type_string),
|
new GameListItem(file_type_string),
|
||||||
new GameListItemSize(size),
|
new GameListItemSize(size),
|
||||||
new GameListItemPlayTime(play_time),
|
new GameListItemPlayTime(play_time),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue