From a1152f5313a703bd44dd56949abd150720ab66f2 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Sat, 7 Mar 2026 17:20:48 +0000 Subject: [PATCH] Qt: Save cover downloader URLs --- pcsx2-qt/CoverDownloadDialog.cpp | 52 ++++++++++++++++++++++++++++++++ pcsx2-qt/CoverDownloadDialog.h | 3 ++ pcsx2-qt/CoverDownloadDialog.ui | 6 +++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/pcsx2-qt/CoverDownloadDialog.cpp b/pcsx2-qt/CoverDownloadDialog.cpp index 614aec0e93..bc3b48a582 100644 --- a/pcsx2-qt/CoverDownloadDialog.cpp +++ b/pcsx2-qt/CoverDownloadDialog.cpp @@ -5,8 +5,10 @@ #include "QtUtils.h" #include "pcsx2/GameList.h" +#include "pcsx2/Host.h" #include "common/Assertions.h" +#include "common/SettingsInterface.h" CoverDownloadDialog::CoverDownloadDialog(QWidget* parent /*= nullptr*/) : QDialog(parent) @@ -18,11 +20,15 @@ CoverDownloadDialog::CoverDownloadDialog(QWidget* parent /*= nullptr*/) connect(m_ui.start, &QPushButton::clicked, this, &CoverDownloadDialog::onStartClicked); connect(m_ui.close, &QPushButton::clicked, this, &CoverDownloadDialog::onCloseClicked); connect(m_ui.urls, &QTextEdit::textChanged, this, &CoverDownloadDialog::updateEnabled); + + loadCoverURLs(); } CoverDownloadDialog::~CoverDownloadDialog() { pxAssert(!m_thread); + + saveCoverURLs(); } void CoverDownloadDialog::closeEvent(QCloseEvent* ev) @@ -111,6 +117,52 @@ void CoverDownloadDialog::cancelThread() m_thread.reset(); } +void CoverDownloadDialog::loadCoverURLs() +{ + auto lock = Host::GetSecretsSettingsLock(); + SettingsInterface* secrets = Host::Internal::GetSecretsSettingsLayer(); + + QString text; + + int count = secrets->GetIntValue("UI/CoverURLs", "Count", 0); + for (int i = 0; i < count; i++) + { + std::string key = std::to_string(i); + + std::string url; + if (!secrets->GetStringValue("UI/CoverURLs", key.c_str(), &url)) + break; + + text += QString::fromStdString(url); + text += '\n'; + } + + m_ui.urls->setPlainText(text); +} + +void CoverDownloadDialog::saveCoverURLs() +{ + auto lock = Host::GetSecretsSettingsLock(); + SettingsInterface* secrets = Host::Internal::GetSecretsSettingsLayer(); + + secrets->RemoveSection("UI/CoverURLs"); + + QStringList urls = m_ui.urls->toPlainText().trimmed().split('\n'); + if (urls.count() == 1 && urls[0].isEmpty()) + urls = QStringList(); + + secrets->SetIntValue("UI/CoverURLs", "Count", static_cast(urls.count())); + + for (qsizetype i = 0; i < urls.count(); i++) + { + std::string key = std::to_string(i); + std::string url = urls[i].toStdString(); + secrets->SetStringValue("UI/CoverURLs", key.c_str(), url.c_str()); + } + + secrets->Save(); +} + CoverDownloadDialog::CoverDownloadThread::CoverDownloadThread(QWidget* parent, const QString& urls, bool use_serials) : QtAsyncProgressThread(parent) , m_use_serials(use_serials) diff --git a/pcsx2-qt/CoverDownloadDialog.h b/pcsx2-qt/CoverDownloadDialog.h index db2f8fec4c..3158981d6e 100644 --- a/pcsx2-qt/CoverDownloadDialog.h +++ b/pcsx2-qt/CoverDownloadDialog.h @@ -51,6 +51,9 @@ private: void startThread(); void cancelThread(); + void loadCoverURLs(); + void saveCoverURLs(); + Ui::CoverDownloadDialog m_ui; std::unique_ptr m_thread; Common::Timer m_last_refresh_time; diff --git a/pcsx2-qt/CoverDownloadDialog.ui b/pcsx2-qt/CoverDownloadDialog.ui index e0f0127561..f9c09c94a1 100644 --- a/pcsx2-qt/CoverDownloadDialog.ui +++ b/pcsx2-qt/CoverDownloadDialog.ui @@ -67,7 +67,11 @@ - + + + false + +