Edit style

This commit is contained in:
faith 2024-12-07 20:34:43 +08:00
parent e24179a380
commit 014840b8ee
3 changed files with 43 additions and 36 deletions

View File

@ -122,7 +122,7 @@ CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::strin
QString title_id = QString::fromStdString(serial); QString title_id = QString::fromStdString(serial);
if (m_compatibility_database.contains(title_id)) { if (m_compatibility_database.contains(title_id)) {
{ {
for (int os_int = 0; os_int != OSType::Last; os_int++) { for (int os_int = 0; os_int != static_cast<int>(OSType::Last); os_int++) {
QString os_string = OSTypeToString.at(static_cast<OSType>(os_int)); QString os_string = OSTypeToString.at(static_cast<OSType>(os_int));
QJsonObject compatibility_obj = m_compatibility_database[title_id].toObject(); QJsonObject compatibility_obj = m_compatibility_database[title_id].toObject();
if (compatibility_obj.contains(os_string)) { if (compatibility_obj.contains(os_string)) {

View File

@ -11,7 +11,7 @@
#include "common/config.h" #include "common/config.h"
#include "core/file_format/psf.h" #include "core/file_format/psf.h"
enum CompatibilityStatus { enum class CompatibilityStatus {
Unknown, Unknown,
Nothing, Nothing,
Boots, Boots,
@ -21,22 +21,22 @@ enum CompatibilityStatus {
}; };
// Prioritize different compatibility reports based on user's platform // Prioritize different compatibility reports based on user's platform
enum OSType { enum class OSType {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
Win32OS = 0, Win32 = 0,
UnknownOS, Unknown,
LinuxOS, Linux,
macOS, macOS,
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
LinuxOS = 0, Linux = 0,
UnknownOS, Unknown,
Win32OS, Win32,
macOS, macOS,
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
macOS = 0, macOS = 0,
UnknownOS, Unknown,
LinuxOS, Linux,
Win32OS, Win32,
#endif #endif
// Fake enum to allow for iteration // Fake enum to allow for iteration
Last Last
@ -59,9 +59,9 @@ public:
{QStringLiteral("status-ingame"), CompatibilityStatus::Ingame}, {QStringLiteral("status-ingame"), CompatibilityStatus::Ingame},
{QStringLiteral("status-playable"), CompatibilityStatus::Playable}}; {QStringLiteral("status-playable"), CompatibilityStatus::Playable}};
inline static const std::unordered_map<QString, OSType> LabelToOSType = { inline static const std::unordered_map<QString, OSType> LabelToOSType = {
{QStringLiteral("os-linux"), OSType::LinuxOS}, {QStringLiteral("os-linux"), OSType::Linux},
{QStringLiteral("os-macOS"), OSType::macOS}, {QStringLiteral("os-macOS"), OSType::macOS},
{QStringLiteral("os-windows"), OSType::Win32OS}, {QStringLiteral("os-windows"), OSType::Win32},
}; };
inline static const std::unordered_map<CompatibilityStatus, QString> CompatStatusToString = { inline static const std::unordered_map<CompatibilityStatus, QString> CompatStatusToString = {
@ -72,10 +72,10 @@ public:
{CompatibilityStatus::Ingame, QStringLiteral("Ingame")}, {CompatibilityStatus::Ingame, QStringLiteral("Ingame")},
{CompatibilityStatus::Playable, QStringLiteral("Playable")}}; {CompatibilityStatus::Playable, QStringLiteral("Playable")}};
inline static const std::unordered_map<OSType, QString> OSTypeToString = { inline static const std::unordered_map<OSType, QString> OSTypeToString = {
{OSType::LinuxOS, QStringLiteral("os-linux")}, {OSType::Linux, QStringLiteral("os-linux")},
{OSType::macOS, QStringLiteral("os-macOS")}, {OSType::macOS, QStringLiteral("os-macOS")},
{OSType::Win32OS, QStringLiteral("os-windows")}, {OSType::Win32, QStringLiteral("os-windows")},
{OSType::UnknownOS, QStringLiteral("os-unknown")}}; {OSType::Unknown, QStringLiteral("os-unknown")}};
CompatibilityInfoClass(); CompatibilityInfoClass();
~CompatibilityInfoClass(); ~CompatibilityInfoClass();

View File

@ -221,36 +221,48 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
widget->setStyleSheet("QToolTip {background-color: black; color: white;}"); widget->setStyleSheet("QToolTip {background-color: black; color: white;}");
QColor color; QColor color;
QString tooltip_string; QString status_explanation;
switch (entry.status) { switch (entry.status) {
case Unknown: case CompatibilityStatus::Unknown:
color = QStringLiteral("#000000"); color = QStringLiteral("#000000");
tooltip_string = tr("Compatibility is untested"); status_explanation = tr("Compatibility is untested");
break; break;
case Nothing: case CompatibilityStatus::Nothing:
color = QStringLiteral("#212121"); color = QStringLiteral("#212121");
tooltip_string = tr("Games that do not initialize properly / crash the emulator"); status_explanation = tr("Games does not initialize properly / crashes the emulator");
break; break;
case Boots: case CompatibilityStatus::Boots:
color = QStringLiteral("#828282"); color = QStringLiteral("#828282");
tooltip_string = tr("Games that are able to boot, but only display a blank screen"); status_explanation = tr("Game boots, but only displays a blank screen");
break; break;
case Menus: case CompatibilityStatus::Menus:
color = QStringLiteral("#FF0000"); color = QStringLiteral("#FF0000");
tooltip_string = tr("Games that displays an image but do not go past the menus"); status_explanation = tr("Game displays an image but does not go past the menu");
break; break;
case Ingame: case CompatibilityStatus::Ingame:
color = QStringLiteral("#F2D624"); color = QStringLiteral("#F2D624");
tooltip_string = tr("Games that have game-breaking glitches or unplayable performance"); status_explanation = tr("Game has game-breaking glitches or unplayable performance");
break; break;
case Playable: case CompatibilityStatus::Playable:
color = QStringLiteral("#47D35C"); color = QStringLiteral("#47D35C");
tooltip_string = 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;
if (entry.status == CompatibilityStatus::Unknown) {
tooltip_string = status_explanation;
} else {
tooltip_string =
tr("Last updated") +
QString(": %1 (%2)\n").arg(entry.last_tested.toString("yyyy-MM-dd"), entry.version) +
status_explanation;
}
QPixmap circle_pixmap(16, 16); QPixmap circle_pixmap(16, 16);
circle_pixmap.fill(Qt::transparent); circle_pixmap.fill(Qt::transparent);
QPainter painter(&circle_pixmap); QPainter painter(&circle_pixmap);
@ -264,7 +276,7 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
QLabel* label = new QLabel(m_compat_info->CompatStatusToString.at(entry.status), widget); QLabel* label = new QLabel(m_compat_info->CompatStatusToString.at(entry.status), widget);
label->setStyleSheet("color: white; font-size: 12px; font-weight: bold;"); label->setStyleSheet("color: white; font-size: 16px; font-weight: bold;");
// Create shadow effect // Create shadow effect
QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect(); QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect();
@ -274,13 +286,8 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
label->setGraphicsEffect(shadowEffect); // Apply shadow effect to the QLabel label->setGraphicsEffect(shadowEffect); // Apply shadow effect to the QLabel
QLabel* version_label = new QLabel(
QString("%1, (%2)").arg(entry.last_tested.toString("yyyy-MM-dd"), entry.version), widget);
version_label->setStyleSheet("color: white; font-size: 10px;");
layout->addWidget(dotLabel, 0, 0, -1, 1); layout->addWidget(dotLabel, 0, 0, -1, 1);
layout->addWidget(label, 0, 1, 1, 1); layout->addWidget(label, 0, 1, 1, 1);
layout->addWidget(version_label, 1, 1, 1, 1);
layout->setAlignment(Qt::AlignLeft); layout->setAlignment(Qt::AlignLeft);
widget->setLayout(layout); widget->setLayout(layout);
widget->setToolTip(tooltip_string); widget->setToolTip(tooltip_string);