Qt: add version update hint to game list

This commit is contained in:
Megamouse 2019-04-09 22:13:54 +02:00 committed by Ani
parent 40142420c1
commit ec2d882199
3 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,4 @@
#include "game_compatibility.h"
#include "game_compatibility.h"
#include <QLabel>
#include <QMessageBox>
@ -73,6 +73,9 @@ bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_downl
// Add date if possible
status.date = json_result.value("date").toString();
// Add version if possible
status.version = json_result.value("update").toString();
// Add status to map
m_compat_database.emplace(std::pair<std::string, compat_status>(sstr(key), status));
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <memory>
@ -22,6 +22,7 @@ struct compat_status
QString color;
QString text;
QString tooltip;
QString version;
};
class game_compatibility : public QObject

View File

@ -1300,11 +1300,19 @@ int game_list_frame::PopulateGameList()
compat_item->setData(Qt::DecorationRole, compat_pixmap(game->compat.color));
}
// Version
QString app_version = qstr(game->info.app_ver);
if (!game->compat.version.isEmpty() && (app_version == category::unknown || game->compat.version.toDouble() > app_version.toDouble()))
{
app_version = tr("%0 (Update available: %1)").arg(app_version, game->compat.version);
}
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);
m_gameList->setItem(row, gui::column_firmware, new custom_table_widget_item(game->info.fw));
m_gameList->setItem(row, gui::column_version, new custom_table_widget_item(game->info.app_ver));
m_gameList->setItem(row, gui::column_version, new custom_table_widget_item(app_version));
m_gameList->setItem(row, gui::column_category, new custom_table_widget_item(game->info.category));
m_gameList->setItem(row, gui::column_path, new custom_table_widget_item(game->info.path));
m_gameList->setItem(row, gui::column_move, new custom_table_widget_item(sstr(supports_move ? tr("Supported") : tr("Not Supported")), Qt::UserRole, !supports_move));