NOISSUE eliminate ProgressProvider
This commit is contained in:
parent
84549ed807
commit
f8650e3965
@ -44,11 +44,11 @@ void LoginDialog::accept()
|
|||||||
// Setup the login task and start it
|
// Setup the login task and start it
|
||||||
m_account = MojangAccount::createFromUsername(ui->userTextBox->text());
|
m_account = MojangAccount::createFromUsername(ui->userTextBox->text());
|
||||||
m_loginTask = m_account->login(nullptr, ui->passTextBox->text());
|
m_loginTask = m_account->login(nullptr, ui->passTextBox->text());
|
||||||
connect(m_loginTask.get(), &ProgressProvider::failed, this, &LoginDialog::onTaskFailed);
|
connect(m_loginTask.get(), &Task::failed, this, &LoginDialog::onTaskFailed);
|
||||||
connect(m_loginTask.get(), &ProgressProvider::succeeded, this,
|
connect(m_loginTask.get(), &Task::succeeded, this,
|
||||||
&LoginDialog::onTaskSucceeded);
|
&LoginDialog::onTaskSucceeded);
|
||||||
connect(m_loginTask.get(), &ProgressProvider::status, this, &LoginDialog::onTaskStatus);
|
connect(m_loginTask.get(), &Task::status, this, &LoginDialog::onTaskStatus);
|
||||||
connect(m_loginTask.get(), &ProgressProvider::progress, this, &LoginDialog::onTaskProgress);
|
connect(m_loginTask.get(), &Task::progress, this, &LoginDialog::onTaskProgress);
|
||||||
m_loginTask->start();
|
m_loginTask->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ void ProgressDialog::updateSize()
|
|||||||
resize(QSize(480, minimumSizeHint().height()));
|
resize(QSize(480, minimumSizeHint().height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProgressDialog::exec(ProgressProvider *task)
|
int ProgressDialog::exec(Task *task)
|
||||||
{
|
{
|
||||||
this->task = task;
|
this->task = task;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ int ProgressDialog::exec(ProgressProvider *task)
|
|||||||
return QDialog::Accepted;
|
return QDialog::Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressProvider *ProgressDialog::getTask()
|
Task *ProgressDialog::getTask()
|
||||||
{
|
{
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class ProgressProvider;
|
class Task;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -34,11 +34,11 @@ public:
|
|||||||
|
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
int exec(ProgressProvider *task);
|
int exec(Task *task);
|
||||||
|
|
||||||
void setSkipButton(bool present, QString label = QString());
|
void setSkipButton(bool present, QString label = QString());
|
||||||
|
|
||||||
ProgressProvider *getTask();
|
Task *getTask();
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
@ -61,5 +61,5 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Ui::ProgressDialog *ui;
|
Ui::ProgressDialog *ui;
|
||||||
|
|
||||||
ProgressProvider *task;
|
Task *task;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "java/JavaChecker.h"
|
#include "java/JavaChecker.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "minecraft/OneSixInstance.h"
|
#include "minecraft/OneSixInstance.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "pages/BasePage.h"
|
#include "pages/BasePage.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "minecraft/OneSixInstance.h"
|
#include "minecraft/OneSixInstance.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "minecraft/OneSixInstance.h"
|
#include "minecraft/OneSixInstance.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -72,7 +71,6 @@ private:
|
|||||||
Ui::VersionPage *ui;
|
Ui::VersionPage *ui;
|
||||||
std::shared_ptr<MinecraftProfile> m_version;
|
std::shared_ptr<MinecraftProfile> m_version;
|
||||||
OneSixInstance *m_inst;
|
OneSixInstance *m_inst;
|
||||||
NetJobPtr forgeJob;
|
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
|
@ -21,7 +21,7 @@ class OneSixInstance;
|
|||||||
class QDir;
|
class QDir;
|
||||||
class QString;
|
class QString;
|
||||||
class QObject;
|
class QObject;
|
||||||
class ProgressProvider;
|
class Task;
|
||||||
struct BaseVersion;
|
struct BaseVersion;
|
||||||
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
|
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
virtual bool add(OneSixInstance *to);
|
virtual bool add(OneSixInstance *to);
|
||||||
virtual bool remove(OneSixInstance *from);
|
virtual bool remove(OneSixInstance *from);
|
||||||
|
|
||||||
virtual ProgressProvider *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) = 0;
|
virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString id() const = 0;
|
virtual QString id() const = 0;
|
||||||
|
@ -177,7 +177,6 @@ SET(LOGIC_SOURCES
|
|||||||
icons/IconList.cpp
|
icons/IconList.cpp
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
tasks/ProgressProvider.h
|
|
||||||
tasks/Task.h
|
tasks/Task.h
|
||||||
tasks/Task.cpp
|
tasks/Task.cpp
|
||||||
tasks/ThreadTask.h
|
tasks/ThreadTask.h
|
||||||
|
@ -384,8 +384,8 @@ protected:
|
|||||||
{ setProgress(100 * current / qMax((qint64)1, total)); });
|
{ setProgress(100 * current / qMax((qint64)1, total)); });
|
||||||
connect(fjob, &NetJob::status, [this](const QString & msg)
|
connect(fjob, &NetJob::status, [this](const QString & msg)
|
||||||
{ setStatus(msg); });
|
{ setStatus(msg); });
|
||||||
connect(fjob, &NetJob::failed, [this]()
|
connect(fjob, &NetJob::failed, [this](QString reason)
|
||||||
{ emitFailed(tr("Failure to download forge")); });
|
{ emitFailed(tr("Failure to download forge:\n%1").arg(reason)); });
|
||||||
connect(fjob, &NetJob::succeeded, installFunction);
|
connect(fjob, &NetJob::succeeded, installFunction);
|
||||||
fjob->start();
|
fjob->start();
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ private:
|
|||||||
BaseVersionPtr m_version;
|
BaseVersionPtr m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProgressProvider *ForgeInstaller::createInstallTask(OneSixInstance *instance,
|
Task *ForgeInstaller::createInstallTask(OneSixInstance *instance,
|
||||||
BaseVersionPtr version, QObject *parent)
|
BaseVersionPtr version, QObject *parent)
|
||||||
{
|
{
|
||||||
if (!version)
|
if (!version)
|
||||||
|
@ -30,7 +30,7 @@ class ForgeInstaller : public BaseInstaller
|
|||||||
public:
|
public:
|
||||||
ForgeInstaller();
|
ForgeInstaller();
|
||||||
virtual ~ForgeInstaller(){}
|
virtual ~ForgeInstaller(){}
|
||||||
virtual ProgressProvider *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
||||||
virtual QString id() const override { return "net.minecraftforge"; }
|
virtual QString id() const override { return "net.minecraftforge"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -33,7 +33,7 @@ void JavaCheckerJob::partFinished(JavaCheckResult result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaCheckerJob::start()
|
void JavaCheckerJob::executeTask()
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " started.";
|
qDebug() << m_job_name.toLocal8Bit() << " started.";
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "JavaChecker.h"
|
#include "JavaChecker.h"
|
||||||
#include "tasks/ProgressProvider.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
class JavaCheckerJob;
|
class JavaCheckerJob;
|
||||||
typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr;
|
typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr;
|
||||||
|
|
||||||
class JavaCheckerJob : public ProgressProvider
|
class JavaCheckerJob : public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit JavaCheckerJob(QString job_name) : ProgressProvider(), m_job_name(job_name) {};
|
explicit JavaCheckerJob(QString job_name) : Task(), m_job_name(job_name) {};
|
||||||
|
|
||||||
bool addJavaCheckerAction(JavaCheckerPtr base)
|
bool addJavaCheckerAction(JavaCheckerPtr base)
|
||||||
{
|
{
|
||||||
@ -66,17 +66,17 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
void progress(int current, int total);
|
|
||||||
void finished(QList<JavaCheckResult>);
|
void finished(QList<JavaCheckResult>);
|
||||||
public
|
|
||||||
slots:
|
public slots:
|
||||||
virtual void start();
|
|
||||||
// FIXME: implement
|
|
||||||
virtual void abort() {};
|
virtual void abort() {};
|
||||||
private
|
|
||||||
slots:
|
private slots:
|
||||||
void partFinished(JavaCheckResult result);
|
void partFinished(JavaCheckResult result);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void executeTask() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_job_name;
|
QString m_job_name;
|
||||||
QList<JavaCheckerPtr> javacheckers;
|
QList<JavaCheckerPtr> javacheckers;
|
||||||
|
@ -178,7 +178,7 @@ void JavaListLoadTask::executeTask()
|
|||||||
|
|
||||||
m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
|
m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
|
||||||
connect(m_job.get(), SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
|
connect(m_job.get(), SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
|
||||||
connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int)));
|
connect(m_job.get(), SIGNAL(progress(qint64,qint64)), this, SLOT(checkerProgress(qint64, qint64)));
|
||||||
|
|
||||||
qDebug() << "Probing the following Java paths: ";
|
qDebug() << "Probing the following Java paths: ";
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -197,7 +197,7 @@ void JavaListLoadTask::executeTask()
|
|||||||
m_job->start();
|
m_job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaListLoadTask::checkerProgress(int current, int total)
|
void JavaListLoadTask::checkerProgress(qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
float progress = (current * 100.0) / total;
|
float progress = (current * 100.0) / total;
|
||||||
this->setProgress((int) progress);
|
this->setProgress((int) progress);
|
||||||
|
@ -87,7 +87,7 @@ public:
|
|||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
public slots:
|
public slots:
|
||||||
void javaCheckerFinished(QList<JavaCheckResult> results);
|
void javaCheckerFinished(QList<JavaCheckResult> results);
|
||||||
void checkerProgress(int current, int total);
|
void checkerProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<JavaCheckerJob> m_job;
|
std::shared_ptr<JavaCheckerJob> m_job;
|
||||||
|
@ -136,7 +136,7 @@ private:
|
|||||||
BaseVersionPtr m_version;
|
BaseVersionPtr m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProgressProvider *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance,
|
Task *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance,
|
||||||
BaseVersionPtr version,
|
BaseVersionPtr version,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
bool add(OneSixInstance *to) override;
|
bool add(OneSixInstance *to) override;
|
||||||
virtual QString id() const override { return "com.mumfrey.liteloader"; }
|
virtual QString id() const override { return "com.mumfrey.liteloader"; }
|
||||||
|
|
||||||
ProgressProvider *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LiteLoaderVersionPtr m_version;
|
LiteLoaderVersionPtr m_version;
|
||||||
|
@ -72,7 +72,7 @@ void OneSixUpdate::executeTask()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(versionUpdateTask.get(), SIGNAL(succeeded()), SLOT(jarlibStart()));
|
connect(versionUpdateTask.get(), SIGNAL(succeeded()), SLOT(jarlibStart()));
|
||||||
connect(versionUpdateTask.get(), SIGNAL(failed(QString)), SLOT(versionUpdateFailed(QString)));
|
connect(versionUpdateTask.get(), &NetJob::failed, this, &OneSixUpdate::versionUpdateFailed);
|
||||||
connect(versionUpdateTask.get(), SIGNAL(progress(qint64, qint64)),
|
connect(versionUpdateTask.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
setStatus(tr("Getting the version files from Mojang..."));
|
setStatus(tr("Getting the version files from Mojang..."));
|
||||||
@ -100,7 +100,7 @@ void OneSixUpdate::assetIndexStart()
|
|||||||
jarlibDownloadJob.reset(job);
|
jarlibDownloadJob.reset(job);
|
||||||
|
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetIndexFinished()));
|
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetIndexFinished()));
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetIndexFailed()));
|
connect(jarlibDownloadJob.get(), &NetJob::failed, this, &OneSixUpdate::assetIndexFailed);
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ void OneSixUpdate::assetIndexFinished()
|
|||||||
job->addNetAction(dl);
|
job->addNetAction(dl);
|
||||||
jarlibDownloadJob.reset(job);
|
jarlibDownloadJob.reset(job);
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
|
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetsFailed()));
|
connect(jarlibDownloadJob.get(), &NetJob::failed, this, &OneSixUpdate::assetsFailed);
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
jarlibDownloadJob->start();
|
jarlibDownloadJob->start();
|
||||||
@ -155,9 +155,9 @@ void OneSixUpdate::assetIndexFinished()
|
|||||||
assetsFinished();
|
assetsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::assetIndexFailed()
|
void OneSixUpdate::assetIndexFailed(QString reason)
|
||||||
{
|
{
|
||||||
emitFailed(tr("Failed to download the assets index!"));
|
emitFailed(tr("Failed to download the assets index:\n%1").arg(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::assetsFinished()
|
void OneSixUpdate::assetsFinished()
|
||||||
@ -165,9 +165,9 @@ void OneSixUpdate::assetsFinished()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::assetsFailed()
|
void OneSixUpdate::assetsFailed(QString reason)
|
||||||
{
|
{
|
||||||
emitFailed(tr("Failed to download assets!"));
|
emitFailed(tr("Failed to download assets:\n%1").arg(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::jarlibStart()
|
void OneSixUpdate::jarlibStart()
|
||||||
@ -280,7 +280,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed()));
|
connect(jarlibDownloadJob.get(), &NetJob::failed, this, &OneSixUpdate::jarlibFailed);
|
||||||
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
|
|
||||||
@ -336,12 +336,12 @@ void OneSixUpdate::jarlibFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::jarlibFailed()
|
void OneSixUpdate::jarlibFailed(QString reason)
|
||||||
{
|
{
|
||||||
QStringList failed = jarlibDownloadJob->getFailedFiles();
|
QStringList failed = jarlibDownloadJob->getFailedFiles();
|
||||||
QString failed_all = failed.join("\n");
|
QString failed_all = failed.join("\n");
|
||||||
emitFailed(
|
emitFailed(
|
||||||
tr("Failed to download the following files:\n%1\n\nPlease try again.").arg(failed_all));
|
tr("Failed to download the following files:\n%1\n\nReason:%2\nPlease try again.").arg(failed_all, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::fmllibsStart()
|
void OneSixUpdate::fmllibsStart()
|
||||||
@ -400,7 +400,7 @@ void OneSixUpdate::fmllibsStart()
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished()));
|
connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished()));
|
||||||
connect(dljob, SIGNAL(failed()), SLOT(fmllibsFailed()));
|
connect(dljob, &NetJob::failed, this, &OneSixUpdate::fmllibsFailed);
|
||||||
connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||||
legacyDownloadJob.reset(dljob);
|
legacyDownloadJob.reset(dljob);
|
||||||
legacyDownloadJob->start();
|
legacyDownloadJob->start();
|
||||||
@ -437,9 +437,9 @@ void OneSixUpdate::fmllibsFinished()
|
|||||||
assetIndexStart();
|
assetIndexStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::fmllibsFailed()
|
void OneSixUpdate::fmllibsFailed(QString reason)
|
||||||
{
|
{
|
||||||
emitFailed("Game update failed: it was impossible to fetch the required FML libraries.");
|
emitFailed(tr("Game update failed: it was impossible to fetch the required FML libraries.\nReason:\n%1").arg(reason));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,18 +40,18 @@ slots:
|
|||||||
|
|
||||||
void jarlibStart();
|
void jarlibStart();
|
||||||
void jarlibFinished();
|
void jarlibFinished();
|
||||||
void jarlibFailed();
|
void jarlibFailed(QString reason);
|
||||||
|
|
||||||
void fmllibsStart();
|
void fmllibsStart();
|
||||||
void fmllibsFinished();
|
void fmllibsFinished();
|
||||||
void fmllibsFailed();
|
void fmllibsFailed(QString reason);
|
||||||
|
|
||||||
void assetIndexStart();
|
void assetIndexStart();
|
||||||
void assetIndexFinished();
|
void assetIndexFinished();
|
||||||
void assetIndexFailed();
|
void assetIndexFailed(QString reason);
|
||||||
|
|
||||||
void assetsFinished();
|
void assetsFinished();
|
||||||
void assetsFailed();
|
void assetsFailed(QString reason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetJobPtr jarlibDownloadJob;
|
NetJobPtr jarlibDownloadJob;
|
||||||
|
@ -95,10 +95,10 @@ void NewsChecker::rssDownloadFinished()
|
|||||||
succeed();
|
succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewsChecker::rssDownloadFailed()
|
void NewsChecker::rssDownloadFailed(QString reason)
|
||||||
{
|
{
|
||||||
// Set an error message and fail.
|
// Set an error message and fail.
|
||||||
fail("Failed to load news RSS feed.");
|
fail(tr("Failed to load news RSS feed:\n%1").arg(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ signals:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void rssDownloadFinished();
|
void rssDownloadFinished();
|
||||||
void rssDownloadFailed();
|
void rssDownloadFailed(QString reason);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! The URL for the RSS feed to fetch.
|
//! The URL for the RSS feed to fetch.
|
||||||
|
@ -104,9 +104,9 @@ void StatusChecker::statusDownloadFinished()
|
|||||||
succeed();
|
succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusChecker::statusDownloadFailed()
|
void StatusChecker::statusDownloadFailed(QString reason)
|
||||||
{
|
{
|
||||||
fail("Failed to load status JSON.");
|
fail(tr("Failed to load status JSON:\n%1").arg(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ signals:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void statusDownloadFinished();
|
void statusDownloadFinished();
|
||||||
void statusDownloadFailed();
|
void statusDownloadFailed(QString reason);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMap<QString, QString> m_prevEntries;
|
QMap<QString, QString> m_prevEntries;
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
/* Copyright 2013-2015 MultiMC Contributors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class ProgressProvider : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
protected:
|
|
||||||
explicit ProgressProvider(QObject *parent = 0) : QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
signals:
|
|
||||||
void started();
|
|
||||||
void progress(qint64 current, qint64 total);
|
|
||||||
void succeeded();
|
|
||||||
void failed(QString reason);
|
|
||||||
void status(QString status);
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~ProgressProvider() {}
|
|
||||||
virtual bool isRunning() const = 0;
|
|
||||||
public
|
|
||||||
slots:
|
|
||||||
virtual void start() = 0;
|
|
||||||
virtual void abort() = 0;
|
|
||||||
};
|
|
@ -4,7 +4,7 @@ SequentialTask::SequentialTask(QObject *parent) : Task(parent), m_currentIndex(-
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequentialTask::addTask(std::shared_ptr<ProgressProvider> task)
|
void SequentialTask::addTask(std::shared_ptr<Task> task)
|
||||||
{
|
{
|
||||||
m_queue.append(task);
|
m_queue.append(task);
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ void SequentialTask::startNext()
|
|||||||
{
|
{
|
||||||
if (m_currentIndex != -1)
|
if (m_currentIndex != -1)
|
||||||
{
|
{
|
||||||
std::shared_ptr<ProgressProvider> previous = m_queue[m_currentIndex];
|
std::shared_ptr<Task> previous = m_queue[m_currentIndex];
|
||||||
disconnect(previous.get(), 0, this, 0);
|
disconnect(previous.get(), 0, this, 0);
|
||||||
}
|
}
|
||||||
m_currentIndex++;
|
m_currentIndex++;
|
||||||
@ -28,7 +28,7 @@ void SequentialTask::startNext()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::shared_ptr<ProgressProvider> next = m_queue[m_currentIndex];
|
std::shared_ptr<Task> next = m_queue[m_currentIndex];
|
||||||
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
|
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
|
||||||
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
|
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
|
||||||
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
|
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
|
||||||
|
@ -11,7 +11,7 @@ class SequentialTask : public Task
|
|||||||
public:
|
public:
|
||||||
explicit SequentialTask(QObject *parent = 0);
|
explicit SequentialTask(QObject *parent = 0);
|
||||||
|
|
||||||
void addTask(std::shared_ptr<ProgressProvider> task);
|
void addTask(std::shared_ptr<Task> task);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask();
|
void executeTask();
|
||||||
@ -24,6 +24,6 @@ slots:
|
|||||||
void subTaskProgress(qint64 current, qint64 total);
|
void subTaskProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQueue<std::shared_ptr<ProgressProvider> > m_queue;
|
QQueue<std::shared_ptr<Task> > m_queue;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "Task.h"
|
#include "Task.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Task::Task(QObject *parent) : ProgressProvider(parent)
|
Task::Task(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "ProgressProvider.h"
|
|
||||||
|
|
||||||
class Task : public ProgressProvider
|
class Task : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -40,6 +39,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual QString failReason() const;
|
virtual QString failReason() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void started();
|
||||||
|
void progress(qint64 current, qint64 total);
|
||||||
|
void succeeded();
|
||||||
|
void failed(QString reason);
|
||||||
|
void status(QString status);
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
@ -39,15 +39,15 @@ void TranslationDownloader::indexRecieved()
|
|||||||
connect(m_dl_job.get(), &NetJob::failed, this, &TranslationDownloader::dlFailed);
|
connect(m_dl_job.get(), &NetJob::failed, this, &TranslationDownloader::dlFailed);
|
||||||
m_dl_job->start();
|
m_dl_job->start();
|
||||||
}
|
}
|
||||||
void TranslationDownloader::dlFailed()
|
void TranslationDownloader::dlFailed(QString reason)
|
||||||
{
|
{
|
||||||
qCritical() << "Translations Download Failed!";
|
qCritical() << "Translations Download Failed:" << reason;
|
||||||
}
|
}
|
||||||
void TranslationDownloader::dlGood()
|
void TranslationDownloader::dlGood()
|
||||||
{
|
{
|
||||||
qDebug() << "Got translations!";
|
qDebug() << "Got translations!";
|
||||||
}
|
}
|
||||||
void TranslationDownloader::indexFailed()
|
void TranslationDownloader::indexFailed(QString reason)
|
||||||
{
|
{
|
||||||
qCritical() << "Translations Index Download Failed!";
|
qCritical() << "Translations Index Download Failed:" << reason;
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void indexRecieved();
|
void indexRecieved();
|
||||||
void indexFailed();
|
void indexFailed(QString reason);
|
||||||
void dlFailed();
|
void dlFailed(QString reason);
|
||||||
void dlGood();
|
void dlGood();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user