mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-10-11 22:49:56 +00:00
Qt: Save cover downloader URLs
This commit is contained in:
@@ -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<int>(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)
|
||||
|
||||
@@ -51,6 +51,9 @@ private:
|
||||
void startThread();
|
||||
void cancelThread();
|
||||
|
||||
void loadCoverURLs();
|
||||
void saveCoverURLs();
|
||||
|
||||
Ui::CoverDownloadDialog m_ui;
|
||||
std::unique_ptr<CoverDownloadThread> m_thread;
|
||||
Common::Timer m_last_refresh_time;
|
||||
|
||||
@@ -67,7 +67,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="urls"/>
|
||||
<widget class="QTextEdit" name="urls">
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
||||
Reference in New Issue
Block a user