fix nested QJsonObject

This commit is contained in:
faith 2024-12-06 13:22:25 +08:00
parent 5ee5b98aba
commit 6696964e4b
2 changed files with 11 additions and 11 deletions

View File

@ -19,7 +19,7 @@ CompatibilityInfoClass::~CompatibilityInfoClass() = default;
void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
QFileInfo check_file(m_compatibility_filename);
const auto modified_delta = check_file.lastModified() - QDateTime::currentDateTime();
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) {
if (LoadCompatibilityFile())
@ -192,11 +192,9 @@ void CompatibilityInfoClass::ExtractCompatibilityInfo(QByteArray response) {
}
}
QJsonValueRef compatibility_object_ref = m_compatibility_database[title_id];
// QJson does not support editing nested objects directly..
if (compatibility_object_ref.isNull()) {
compatibility_object_ref = QJsonObject({});
}
QJsonObject compatibility_obj = m_compatibility_database[title_id].toObject();
QJsonObject compatibility_data{
{{"status", compatibility_status},
@ -205,7 +203,9 @@ void CompatibilityInfoClass::ExtractCompatibilityInfo(QByteArray response) {
? "unknown"
: issue_obj["milestone"].toObject()["title"].toString()}}};
compatibility_object_ref.toObject().insert(current_os, compatibility_data);
compatibility_obj[current_os] = compatibility_data;
m_compatibility_database[title_id] = compatibility_obj;
}
}

View File

@ -23,7 +23,7 @@ GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
this->verticalScrollBar()->installEventFilter(this);
this->verticalScrollBar()->setSingleStep(20);
this->horizontalScrollBar()->setSingleStep(20);
this->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
this->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
this->verticalHeader()->setVisible(false);
this->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
this->horizontalHeader()->setHighlightSections(false);
@ -45,8 +45,8 @@ GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
this->setHorizontalHeaderLabels(headers);
this->horizontalHeader()->setSortIndicatorShown(true);
this->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
this->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
this->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Fixed);
this->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Fixed);
PopulateGameList();
connect(this, &QTableWidget::currentCellChanged, this, &GameListFrame::onCurrentCellChanged);
@ -255,7 +255,7 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
QLabel* label = new QLabel(m_compat_info->CompatStatusToString.at(entry.status), widget);
label->setStyleSheet("color: white; font-size: 16px; font-weight: bold;");
label->setStyleSheet("color: white; font-size: 12px; font-weight: bold;");
// Create shadow effect
QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect();
@ -266,8 +266,8 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry
label->setGraphicsEffect(shadowEffect); // Apply shadow effect to the QLabel
QLabel* version_label =
new QLabel(QString("%1, (%2)").arg(entry.last_tested.toString(), entry.version), widget);
version_label->setStyleSheet("color: white; font-size: 12px;");
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(label, 0, 1, 1, 1);