mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
Add clickable status
This commit is contained in:
parent
014840b8ee
commit
5680008cae
@ -18,15 +18,8 @@ CompatibilityInfoClass::CompatibilityInfoClass()
|
|||||||
CompatibilityInfoClass::~CompatibilityInfoClass() = default;
|
CompatibilityInfoClass::~CompatibilityInfoClass() = default;
|
||||||
|
|
||||||
void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
||||||
QFileInfo check_file(m_compatibility_filename);
|
if (LoadCompatibilityFile())
|
||||||
const auto modified_delta = QDateTime::currentDateTime() - check_file.lastModified();
|
return;
|
||||||
if (check_file.exists() && check_file.isFile() &&
|
|
||||||
std::chrono::duration_cast<std::chrono::minutes>(modified_delta).count() < 60) {
|
|
||||||
if (LoadCompatibilityFile())
|
|
||||||
return;
|
|
||||||
QMessageBox::critical(parent, tr("Error"),
|
|
||||||
tr("Failure in reading compatibility_data.json."));
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkReply* reply = FetchPage(1);
|
QNetworkReply* reply = FetchPage(1);
|
||||||
WaitForReply(reply);
|
WaitForReply(reply);
|
||||||
@ -49,7 +42,7 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
parent, tr("Error"),
|
parent, tr("Error"),
|
||||||
tr("Unable to update compatibility data! Using old compatibility data..."));
|
tr("Unable to update compatibility data! Try again later."));
|
||||||
// Try loading compatibility_file.json again
|
// Try loading compatibility_file.json again
|
||||||
LoadCompatibilityFile();
|
LoadCompatibilityFile();
|
||||||
return;
|
return;
|
||||||
@ -83,6 +76,8 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument json_doc;
|
QJsonDocument json_doc;
|
||||||
|
m_compatibility_database["version"] = COMPAT_DB_VERSION;
|
||||||
|
|
||||||
json_doc.setObject(m_compatibility_database);
|
json_doc.setObject(m_compatibility_database);
|
||||||
compatibility_file.write(json_doc.toJson());
|
compatibility_file.write(json_doc.toJson());
|
||||||
compatibility_file.close();
|
compatibility_file.close();
|
||||||
@ -131,7 +126,9 @@ CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::strin
|
|||||||
LabelToCompatStatus.at(compatibility_entry_obj["status"].toString()),
|
LabelToCompatStatus.at(compatibility_entry_obj["status"].toString()),
|
||||||
compatibility_entry_obj["version"].toString(),
|
compatibility_entry_obj["version"].toString(),
|
||||||
QDateTime::fromString(compatibility_entry_obj["last_tested"].toString(),
|
QDateTime::fromString(compatibility_entry_obj["last_tested"].toString(),
|
||||||
Qt::ISODate)};
|
Qt::ISODate),
|
||||||
|
compatibility_entry_obj["url"].toString(),
|
||||||
|
compatibility_entry_obj["issue_number"].toInt()};
|
||||||
return compatibility_entry;
|
return compatibility_entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,6 +138,14 @@ CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CompatibilityInfoClass::LoadCompatibilityFile() {
|
bool CompatibilityInfoClass::LoadCompatibilityFile() {
|
||||||
|
// Returns true if compatibility is loaded succescfully
|
||||||
|
QFileInfo check_file(m_compatibility_filename);
|
||||||
|
const auto modified_delta = QDateTime::currentDateTime() - check_file.lastModified();
|
||||||
|
if (!check_file.exists() || !check_file.isFile() &&
|
||||||
|
std::chrono::duration_cast<std::chrono::minutes>(modified_delta).count() > 60) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QFile compatibility_file(m_compatibility_filename);
|
QFile compatibility_file(m_compatibility_filename);
|
||||||
if (!compatibility_file.open(QIODevice::ReadOnly)) {
|
if (!compatibility_file.open(QIODevice::ReadOnly)) {
|
||||||
compatibility_file.close();
|
compatibility_file.close();
|
||||||
@ -154,6 +159,14 @@ bool CompatibilityInfoClass::LoadCompatibilityFile() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check database version
|
||||||
|
int version_number;
|
||||||
|
if (json_doc.object()["version"].isDouble()) {
|
||||||
|
if (json_doc.object()["version"].toInt() < COMPAT_DB_VERSION)
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
m_compatibility_database = json_doc.object();
|
m_compatibility_database = json_doc.object();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -201,7 +214,9 @@ void CompatibilityInfoClass::ExtractCompatibilityInfo(QByteArray response) {
|
|||||||
{"last_tested", issue_obj["updated_at"]},
|
{"last_tested", issue_obj["updated_at"]},
|
||||||
{"version", issue_obj["milestone"].isNull()
|
{"version", issue_obj["milestone"].isNull()
|
||||||
? "unknown"
|
? "unknown"
|
||||||
: issue_obj["milestone"].toObject()["title"].toString()}}};
|
: issue_obj["milestone"].toObject()["title"].toString()},
|
||||||
|
{"url", issue_obj["html_url"]},
|
||||||
|
{"issue_number", issue_obj["number"]}}};
|
||||||
|
|
||||||
compatibility_obj[current_os] = compatibility_data;
|
compatibility_obj[current_os] = compatibility_data;
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "core/file_format/psf.h"
|
#include "core/file_format/psf.h"
|
||||||
|
|
||||||
|
static constexpr int COMPAT_DB_VERSION = 1;
|
||||||
|
|
||||||
enum class CompatibilityStatus {
|
enum class CompatibilityStatus {
|
||||||
Unknown,
|
Unknown,
|
||||||
Nothing,
|
Nothing,
|
||||||
@ -46,6 +48,8 @@ struct CompatibilityEntry {
|
|||||||
CompatibilityStatus status;
|
CompatibilityStatus status;
|
||||||
QString version;
|
QString version;
|
||||||
QDateTime last_tested;
|
QDateTime last_tested;
|
||||||
|
QString url;
|
||||||
|
int issue_number;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CompatibilityInfoClass : public QObject {
|
class CompatibilityInfoClass : public QObject {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <QToolTip>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "game_list_frame.h"
|
#include "game_list_frame.h"
|
||||||
#include "game_list_utils.h"
|
#include "game_list_utils.h"
|
||||||
#include <QToolTip>
|
|
||||||
|
|
||||||
GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
||||||
std::shared_ptr<CompatibilityInfoClass> compat_info_get,
|
std::shared_ptr<CompatibilityInfoClass> compat_info_get,
|
||||||
@ -74,6 +74,12 @@ GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
|||||||
connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) {
|
connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) {
|
||||||
m_gui_context_menus.RequestGameMenu(pos, m_game_info->m_games, this, true);
|
m_gui_context_menus.RequestGameMenu(pos, m_game_info->m_games, this, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(this, &QTableWidget::cellClicked, this, [=](int row, int column) {
|
||||||
|
if (column == 2 && !m_game_info->m_games[row].compatibility.url.isEmpty()) {
|
||||||
|
QDesktopServices::openUrl(QUrl(m_game_info->m_games[row].compatibility.url));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
void GameListFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
||||||
@ -223,7 +229,6 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
|
|||||||
QColor color;
|
QColor color;
|
||||||
QString status_explanation;
|
QString status_explanation;
|
||||||
|
|
||||||
|
|
||||||
switch (entry.status) {
|
switch (entry.status) {
|
||||||
case CompatibilityStatus::Unknown:
|
case CompatibilityStatus::Unknown:
|
||||||
color = QStringLiteral("#000000");
|
color = QStringLiteral("#000000");
|
||||||
@ -247,20 +252,23 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
|
|||||||
break;
|
break;
|
||||||
case CompatibilityStatus::Playable:
|
case CompatibilityStatus::Playable:
|
||||||
color = QStringLiteral("#47D35C");
|
color = QStringLiteral("#47D35C");
|
||||||
status_explanation =
|
status_explanation =
|
||||||
tr("Game can be completed with playable performance and no major glitches");
|
tr("Game can be completed with playable performance and no major glitches");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString tooltip_string;
|
QString tooltip_string;
|
||||||
|
|
||||||
if (entry.status == CompatibilityStatus::Unknown) {
|
if (entry.status == CompatibilityStatus::Unknown) {
|
||||||
tooltip_string = status_explanation;
|
tooltip_string = status_explanation;
|
||||||
} else {
|
} else {
|
||||||
tooltip_string =
|
tooltip_string =
|
||||||
|
"<p> <i>" + tr("Click to go to issue") + "</i>" +
|
||||||
|
"<br>" +
|
||||||
tr("Last updated") +
|
tr("Last updated") +
|
||||||
QString(": %1 (%2)\n").arg(entry.last_tested.toString("yyyy-MM-dd"), entry.version) +
|
QString(": %1 (%2)").arg(entry.last_tested.toString("yyyy-MM-dd"), entry.version) +
|
||||||
status_explanation;
|
"<br>" +
|
||||||
|
status_explanation + "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap circle_pixmap(16, 16);
|
QPixmap circle_pixmap(16, 16);
|
||||||
|
Loading…
Reference in New Issue
Block a user