2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2022-09-13 10:29:17 +00:00
|
|
|
#pragma once
|
|
|
|
#include "common/timer.h"
|
|
|
|
#include "common/types.h"
|
|
|
|
#include "qtprogresscallback.h"
|
|
|
|
#include "ui_coverdownloaddialog.h"
|
|
|
|
#include <QtWidgets/QDialog>
|
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class CoverDownloadDialog final : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CoverDownloadDialog(QWidget* parent = nullptr);
|
|
|
|
~CoverDownloadDialog();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void coverRefreshRequested();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent* ev);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onDownloadStatus(const QString& text);
|
|
|
|
void onDownloadProgress(int value, int range);
|
|
|
|
void onDownloadComplete();
|
|
|
|
void onStartClicked();
|
|
|
|
void onCloseClicked();
|
|
|
|
void updateEnabled();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class CoverDownloadThread : public QtAsyncProgressThread
|
|
|
|
{
|
|
|
|
public:
|
2022-09-17 05:51:05 +00:00
|
|
|
CoverDownloadThread(QWidget* parent, const QString& urls, bool use_serials);
|
2022-09-13 10:29:17 +00:00
|
|
|
~CoverDownloadThread();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void runAsync() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::string> m_urls;
|
2022-09-17 05:51:05 +00:00
|
|
|
bool m_use_serials;
|
2022-09-13 10:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void startThread();
|
|
|
|
void cancelThread();
|
|
|
|
|
|
|
|
Ui::CoverDownloadDialog m_ui;
|
|
|
|
std::unique_ptr<CoverDownloadThread> m_thread;
|
|
|
|
Common::Timer m_last_refresh_time;
|
|
|
|
};
|