mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-01-15 05:00:10 +01:00
ISO: Move icon loading to a common function in qt_utils.h
This commit is contained in:
parent
bc1d0b9e65
commit
714359b544
|
|
@ -1,8 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "qt_utils.h"
|
||||
#include "game_list_base.h"
|
||||
|
||||
#include "Loader/ISO.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QPainter>
|
||||
|
||||
|
|
@ -54,18 +53,10 @@ void game_list_base::IconLoadFunction(game_info game, qreal device_pixel_ratio,
|
|||
{
|
||||
if (game->icon_in_archive)
|
||||
{
|
||||
iso_archive archive(game->info.path);
|
||||
auto icon_file = archive.open(game->info.icon_path);
|
||||
auto icon_size = icon_file.size();
|
||||
QByteArray data(icon_size, 0);
|
||||
icon_file.read(data.data(), icon_size);
|
||||
QImage iconImage;
|
||||
if (iconImage.loadFromData(data))
|
||||
{
|
||||
game->icon = QPixmap::fromImage(iconImage);
|
||||
}
|
||||
game->icon_in_archive = gui::utils::load_icon(game->icon, game->info.icon_path, game->info.path);
|
||||
}
|
||||
else if (game_list_log.warning)
|
||||
|
||||
if (!game->icon_in_archive && game_list_log.warning)
|
||||
{
|
||||
bool logged = false;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "Emu/system_utils.hpp"
|
||||
#include "Utilities/File.h"
|
||||
#include "Loader/ISO.h"
|
||||
#include <cmath>
|
||||
|
||||
LOG_CHANNEL(gui_log, "GUI");
|
||||
|
|
@ -682,6 +683,29 @@ namespace gui
|
|||
return QString("%1 days ago %2").arg(current_date - exctrated_date).arg(date.toString(fmt_relative));
|
||||
}
|
||||
|
||||
bool load_icon(QPixmap& icon, const std::string& icon_path,
|
||||
const std::string& archive_path)
|
||||
{
|
||||
if (!is_file_iso(archive_path)) return false;
|
||||
|
||||
iso_archive archive(archive_path);
|
||||
if (!archive.exists(icon_path)) return false;
|
||||
|
||||
auto icon_file = archive.open(icon_path);
|
||||
auto icon_size = icon_file.size();
|
||||
|
||||
QByteArray data(icon_size, 0);
|
||||
icon_file.read(data.data(), icon_size);
|
||||
QImage iconImage;
|
||||
|
||||
if (iconImage.loadFromData(data))
|
||||
{
|
||||
icon = QPixmap::fromImage(iconImage);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString format_timestamp(s64 time, const QString& fmt)
|
||||
{
|
||||
return format_datetime(datetime(time), fmt);
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ namespace gui
|
|||
return color_scheme() == Qt::ColorScheme::Dark;
|
||||
}
|
||||
|
||||
// Loads an icon from an (ISO) archive file.
|
||||
bool load_icon(QPixmap& icon, const std::string& icon_path, const std::string& archive_path);
|
||||
|
||||
template <typename T>
|
||||
void stop_future_watcher(QFutureWatcher<T>& watcher, bool cancel, std::shared_ptr<atomic_t<bool>> cancel_flag = nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -450,16 +450,7 @@ void savestate_manager_dialog::ResizeGameIcons()
|
|||
|
||||
if (!archive_path.empty())
|
||||
{
|
||||
iso_archive archive(archive_path);
|
||||
auto icon_file = archive.open(icon_path);
|
||||
auto icon_size = icon_file.size();
|
||||
QByteArray data(icon_size, 0);
|
||||
icon_file.read(data.data(), icon_size);
|
||||
QImage iconImage;
|
||||
if (iconImage.loadFromData(data))
|
||||
{
|
||||
icon = QPixmap::fromImage(iconImage);
|
||||
}
|
||||
gui::utils::load_icon(icon, icon_path, archive_path);
|
||||
}
|
||||
|
||||
if (cancel && cancel->load())
|
||||
|
|
|
|||
Loading…
Reference in a new issue