GH-1053 add back update progress dialog
This commit is contained in:
parent
6310f6569c
commit
d8caab515a
@ -131,6 +131,7 @@ ConsoleWindow::ConsoleWindow(std::shared_ptr<LaunchTask> proc, QWidget *parent)
|
||||
// Set up signal connections
|
||||
connect(m_proc.get(), &LaunchTask::succeeded, this, &ConsoleWindow::onSucceeded);
|
||||
connect(m_proc.get(), &LaunchTask::failed, this, &ConsoleWindow::onFailed);
|
||||
connect(m_proc.get(), &LaunchTask::requestProgress, this, &ConsoleWindow::onProgressRequested);
|
||||
|
||||
setMayClose(false);
|
||||
|
||||
@ -247,6 +248,14 @@ void ConsoleWindow::onFailed(QString reason)
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleWindow::onProgressRequested(Task* task)
|
||||
{
|
||||
ProgressDialog progDialog(this);
|
||||
m_proc->proceed();
|
||||
progDialog.exec(task);
|
||||
}
|
||||
|
||||
|
||||
ConsoleWindow::~ConsoleWindow()
|
||||
{
|
||||
|
||||
|
@ -46,6 +46,7 @@ slots:
|
||||
|
||||
void onSucceeded();
|
||||
void onFailed(QString reason);
|
||||
void onProgressRequested(Task *task);
|
||||
|
||||
// FIXME: add handlers for the other MinecraftLauncher signals (pre/post launch command
|
||||
// failures)
|
||||
|
@ -57,6 +57,12 @@ void ProgressDialog::updateSize()
|
||||
int ProgressDialog::exec(Task *task)
|
||||
{
|
||||
this->task = task;
|
||||
QDialog::DialogCode result;
|
||||
|
||||
if(handleImmediateResult(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Connect signals.
|
||||
connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
|
||||
@ -67,11 +73,40 @@ int ProgressDialog::exec(Task *task)
|
||||
|
||||
// if this didn't connect to an already running task, invoke start
|
||||
if(!task->isRunning())
|
||||
{
|
||||
task->start();
|
||||
}
|
||||
if(task->isRunning())
|
||||
{
|
||||
changeProgress(task->getProgress(), task->getTotalProgress());
|
||||
changeStatus(task->getStatus());
|
||||
return QDialog::exec();
|
||||
}
|
||||
else if(handleImmediateResult(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return QDialog::Accepted;
|
||||
{
|
||||
return QDialog::Rejected;
|
||||
}
|
||||
}
|
||||
|
||||
bool ProgressDialog::handleImmediateResult(QDialog::DialogCode &result)
|
||||
{
|
||||
if(task->isFinished())
|
||||
{
|
||||
if(task->successful())
|
||||
{
|
||||
result = QDialog::Accepted;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = QDialog::Rejected;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Task *ProgressDialog::getTask()
|
||||
|
@ -58,6 +58,9 @@ protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
virtual void closeEvent(QCloseEvent *e);
|
||||
|
||||
private:
|
||||
bool handleImmediateResult(QDialog::DialogCode &result);
|
||||
|
||||
private:
|
||||
Ui::ProgressDialog *ui;
|
||||
|
||||
|
@ -95,8 +95,8 @@ set(LOGIC_SOURCES
|
||||
# Game launch logic
|
||||
launch/steps/CheckJava.cpp
|
||||
launch/steps/CheckJava.h
|
||||
launch/steps/LaunchCommand.cpp
|
||||
launch/steps/LaunchCommand.h
|
||||
launch/steps/LaunchMinecraft.cpp
|
||||
launch/steps/LaunchMinecraft.h
|
||||
launch/steps/ModMinecraftJar.cpp
|
||||
launch/steps/ModMinecraftJar.h
|
||||
launch/steps/PostLaunchCommand.cpp
|
||||
|
@ -381,10 +381,8 @@ protected:
|
||||
{
|
||||
NetJob *fjob = new NetJob("Forge download");
|
||||
fjob->addNetAction(CacheDownload::make(forgeVersion->url(), entry));
|
||||
connect(fjob, &NetJob::progress, [this](qint64 current, qint64 total)
|
||||
{ setProgress(100 * current / qMax((qint64)1, total)); });
|
||||
connect(fjob, &NetJob::status, [this](const QString & msg)
|
||||
{ setStatus(msg); });
|
||||
connect(fjob, &NetJob::progress, this, &Task::setProgress);
|
||||
connect(fjob, &NetJob::status, this, &Task::setStatus);
|
||||
connect(fjob, &NetJob::failed, [this](QString reason)
|
||||
{ emitFailed(tr("Failure to download Forge:\n%1").arg(reason)); });
|
||||
connect(fjob, &NetJob::succeeded, installFunction);
|
||||
|
@ -110,7 +110,7 @@ void ForgeMirrors::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void ForgeMirrors::downloadReadyRead()
|
||||
|
@ -83,7 +83,7 @@ void ForgeXzDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void ForgeXzDownload::downloadError(QNetworkReply::NetworkError error)
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
// if this is already running, the action needs to be started right away!
|
||||
if (isRunning())
|
||||
{
|
||||
emit progress(current_progress, total_progress);
|
||||
setProgress(current_progress, total_progress);
|
||||
connect(base.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult)));
|
||||
|
||||
base->performCheck();
|
||||
|
@ -162,7 +162,7 @@ void JavaListLoadTask::executeTask()
|
||||
|
||||
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(progress(qint64,qint64)), this, SLOT(checkerProgress(qint64, qint64)));
|
||||
connect(m_job.get(), &Task::progress, this, &Task::setProgress);
|
||||
|
||||
qDebug() << "Probing the following Java paths: ";
|
||||
int id = 0;
|
||||
@ -181,12 +181,6 @@ void JavaListLoadTask::executeTask()
|
||||
m_job->start();
|
||||
}
|
||||
|
||||
void JavaListLoadTask::checkerProgress(qint64 current, qint64 total)
|
||||
{
|
||||
float progress = (current * 100.0) / total;
|
||||
this->setProgress((int) progress);
|
||||
}
|
||||
|
||||
void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
|
||||
{
|
||||
QList<JavaVersionPtr> candidates;
|
||||
|
@ -89,7 +89,6 @@ public:
|
||||
virtual void executeTask();
|
||||
public slots:
|
||||
void javaCheckerFinished(QList<JavaCheckResult> results);
|
||||
void checkerProgress(qint64 current, qint64 total);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<JavaCheckerJob> m_job;
|
||||
|
@ -23,4 +23,5 @@ void LaunchStep::bind(LaunchTask *parent)
|
||||
connect(this, &LaunchStep::logLine, parent, &LaunchTask::onLogLine);
|
||||
connect(this, &LaunchStep::logLines, parent, &LaunchTask::onLogLines);
|
||||
connect(this, &LaunchStep::finished, parent, &LaunchTask::onStepFinished);
|
||||
connect(this, &LaunchStep::progressReportingRequest, parent, &LaunchTask::onProgressReportingRequested);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ signals:
|
||||
void logLines(QStringList lines, MessageLevel::Enum level);
|
||||
void logLine(QString line, MessageLevel::Enum level);
|
||||
void readyForLaunch();
|
||||
void progressReportingRequest();
|
||||
|
||||
public slots:
|
||||
virtual void proceed() {};
|
||||
|
@ -103,6 +103,12 @@ void LaunchTask::onStepFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchTask::onProgressReportingRequested()
|
||||
{
|
||||
state = LaunchTask::Waiting;
|
||||
emit requestProgress(m_steps[currentStep].get());
|
||||
}
|
||||
|
||||
void LaunchTask::setCensorFilter(QMap<QString, QString> filter)
|
||||
{
|
||||
m_censorFilter = filter;
|
||||
|
@ -92,6 +92,10 @@ signals:
|
||||
*/
|
||||
void readyForLaunch();
|
||||
|
||||
void requestProgress(Task *task);
|
||||
|
||||
void requestLogging();
|
||||
|
||||
/**
|
||||
* @brief emitted when we want to log something
|
||||
* @param text the text to log
|
||||
@ -104,6 +108,7 @@ public slots:
|
||||
void onLogLine(QString line, MessageLevel::Enum defaultLevel = MessageLevel::MultiMC);
|
||||
void onReadyForLaunch();
|
||||
void onStepFinished();
|
||||
void onProgressReportingRequested();
|
||||
|
||||
protected: /* data */
|
||||
InstancePtr m_instance;
|
||||
|
@ -13,18 +13,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LaunchCommand.h"
|
||||
#include "LaunchMinecraft.h"
|
||||
#include <launch/LaunchTask.h>
|
||||
#include <minecraft/OneSixInstance.h>
|
||||
#include <QStandardPaths>
|
||||
|
||||
LaunchCommand::LaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
LaunchMinecraft::LaunchMinecraft(LaunchTask *parent) : LaunchStep(parent)
|
||||
{
|
||||
connect(&m_process, &LoggedProcess::log, this, &LaunchCommand::logLines);
|
||||
connect(&m_process, &LoggedProcess::stateChanged, this, &LaunchCommand::on_state);
|
||||
connect(&m_process, &LoggedProcess::log, this, &LaunchMinecraft::logLines);
|
||||
connect(&m_process, &LoggedProcess::stateChanged, this, &LaunchMinecraft::on_state);
|
||||
}
|
||||
|
||||
void LaunchCommand::executeTask()
|
||||
void LaunchMinecraft::executeTask()
|
||||
{
|
||||
auto instance = m_parent->instance();
|
||||
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
|
||||
@ -58,7 +58,7 @@ void LaunchCommand::executeTask()
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchCommand::on_state(LoggedProcess::State state)
|
||||
void LaunchMinecraft::on_state(LoggedProcess::State state)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
@ -103,12 +103,12 @@ void LaunchCommand::on_state(LoggedProcess::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchCommand::setWorkingDirectory(const QString &wd)
|
||||
void LaunchMinecraft::setWorkingDirectory(const QString &wd)
|
||||
{
|
||||
m_process.setWorkingDirectory(wd);
|
||||
}
|
||||
|
||||
void LaunchCommand::proceed()
|
||||
void LaunchMinecraft::proceed()
|
||||
{
|
||||
if(mayProceed)
|
||||
{
|
||||
@ -118,7 +118,7 @@ void LaunchCommand::proceed()
|
||||
}
|
||||
}
|
||||
|
||||
bool LaunchCommand::abort()
|
||||
bool LaunchMinecraft::abort()
|
||||
{
|
||||
if(mayProceed)
|
||||
{
|
@ -18,11 +18,11 @@
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <launch/LoggedProcess.h>
|
||||
|
||||
class LaunchCommand: public LaunchStep
|
||||
class LaunchMinecraft: public LaunchStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LaunchCommand(LaunchTask *parent);
|
||||
explicit LaunchMinecraft(LaunchTask *parent);
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
virtual void proceed();
|
@ -22,12 +22,19 @@ void Update::executeTask()
|
||||
if(m_updateTask)
|
||||
{
|
||||
connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
|
||||
m_updateTask->start();
|
||||
connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
|
||||
connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
|
||||
emit progressReportingRequest();
|
||||
return;
|
||||
}
|
||||
emitSucceeded();
|
||||
}
|
||||
|
||||
void Update::proceed()
|
||||
{
|
||||
m_updateTask->start();
|
||||
}
|
||||
|
||||
void Update::updateFinished()
|
||||
{
|
||||
if(m_updateTask->successful())
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void proceed();
|
||||
private slots:
|
||||
void updateFinished();
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "minecraft/LegacyUpdate.h"
|
||||
#include "icons/IconList.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include <launch/steps/LaunchCommand.h>
|
||||
#include <launch/steps/LaunchMinecraft.h>
|
||||
#include <launch/steps/PostLaunchCommand.h>
|
||||
#include <launch/steps/ModMinecraftJar.h>
|
||||
#include <launch/steps/Update.h>
|
||||
@ -156,7 +156,7 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess
|
||||
}
|
||||
// actually launch the game
|
||||
{
|
||||
auto step = std::make_shared<LaunchCommand>(pptr);
|
||||
auto step = std::make_shared<LaunchMinecraft>(pptr);
|
||||
step->setWorkingDirectory(minecraftRoot());
|
||||
step->setLaunchScript(launchScript);
|
||||
process->appendStep(step);
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include "net/URLConstants.h"
|
||||
#include "MMCZip.h"
|
||||
|
||||
#include "minecraft/LegacyUpdate.h"
|
||||
#include "LegacyUpdate.h"
|
||||
|
||||
#include "minecraft/LwjglVersionList.h"
|
||||
#include "minecraft/MinecraftVersionList.h"
|
||||
#include "minecraft/ModList.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "launch/LaunchTask.h"
|
||||
#include <launch/steps/PreLaunchCommand.h>
|
||||
#include <launch/steps/Update.h>
|
||||
#include <launch/steps/LaunchCommand.h>
|
||||
#include <launch/steps/LaunchMinecraft.h>
|
||||
#include <launch/steps/PostLaunchCommand.h>
|
||||
#include <launch/steps/TextPrint.h>
|
||||
#include <launch/steps/ModMinecraftJar.h>
|
||||
@ -263,7 +263,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess
|
||||
}
|
||||
// actually launch the game
|
||||
{
|
||||
auto step = std::make_shared<LaunchCommand>(pptr);
|
||||
auto step = std::make_shared<LaunchMinecraft>(pptr);
|
||||
step->setWorkingDirectory(minecraftRoot());
|
||||
step->setLaunchScript(launchScript);
|
||||
process->appendStep(step);
|
||||
|
@ -44,7 +44,7 @@ void ByteArrayDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
|
||||
|
@ -90,7 +90,7 @@ void CacheDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void CacheDownload::downloadError(QNetworkReply::NetworkError error)
|
||||
|
@ -99,7 +99,7 @@ void MD5EtagDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void MD5EtagDownload::downloadError(QNetworkReply::NetworkError error)
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
signals:
|
||||
void started(int index);
|
||||
void progress(int index, qint64 current, qint64 total);
|
||||
void netActionProgress(int index, qint64 current, qint64 total);
|
||||
void succeeded(int index);
|
||||
void failed(int index);
|
||||
|
||||
|
@ -61,7 +61,7 @@ void NetJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTotal)
|
||||
total_progress -= slot.total_progress;
|
||||
slot.total_progress = bytesTotal;
|
||||
total_progress += slot.total_progress;
|
||||
emit progress(current_progress, total_progress);
|
||||
setProgress(current_progress, total_progress);
|
||||
}
|
||||
|
||||
void NetJob::executeTask()
|
||||
@ -107,7 +107,7 @@ void NetJob::startMoreParts()
|
||||
// connect signals :D
|
||||
connect(part.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
|
||||
connect(part.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
|
||||
connect(part.get(), SIGNAL(progress(int, qint64, qint64)),
|
||||
connect(part.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
|
||||
SLOT(partProgress(int, qint64, qint64)));
|
||||
part->start();
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ public:
|
||||
// if this is already running, the action needs to be started right away!
|
||||
if (isRunning())
|
||||
{
|
||||
emit progress(current_progress, total_progress);
|
||||
setProgress(current_progress, total_progress);
|
||||
connect(base.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
|
||||
connect(base.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
|
||||
connect(base.get(), SIGNAL(progress(int, qint64, qint64)),
|
||||
connect(base.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
|
||||
SLOT(partProgress(int, qint64, qint64)));
|
||||
base->start();
|
||||
}
|
||||
|
@ -30,10 +30,8 @@ void PasteUpload::executeTask()
|
||||
|
||||
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||
setStatus(tr("Uploading to paste.ee"));
|
||||
connect(rep, &QNetworkReply::downloadProgress, [&](qint64 value, qint64 max)
|
||||
{ setProgress(value / qMax((qint64)1, max) * 100); });
|
||||
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this,
|
||||
SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||
connect(rep, &QNetworkReply::downloadProgress, this, &Task::setProgress);
|
||||
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
||||
}
|
||||
|
||||
|
@ -86,5 +86,5 @@ void ImgurAlbumCreation::downloadProgress(qint64 bytesReceived, qint64 bytesTota
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
@ -110,5 +110,5 @@ void ImgurUpload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
m_total_progress = bytesTotal;
|
||||
m_progress = bytesReceived;
|
||||
emit progress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
|
||||
}
|
||||
|
@ -48,12 +48,8 @@ void SequentialTask::subTaskProgress(qint64 current, qint64 total)
|
||||
{
|
||||
if(total == 0)
|
||||
{
|
||||
setProgress(0);
|
||||
setProgress(0, 100);
|
||||
return;
|
||||
}
|
||||
auto dcurrent = (double) current;
|
||||
auto dtotal = (double) total;
|
||||
auto partial = ((dcurrent / dtotal) * 100.0f)/* / double(m_queue.size())*/;
|
||||
// auto bigpartial = double(m_currentIndex) * 100.0f / double(m_queue.size());
|
||||
setProgress(partial);
|
||||
setProgress(current, total);
|
||||
}
|
||||
|
@ -23,12 +23,18 @@ Task::Task(QObject *parent) : QObject(parent)
|
||||
|
||||
void Task::setStatus(const QString &new_status)
|
||||
{
|
||||
emit status(new_status);
|
||||
if(m_status != new_status)
|
||||
{
|
||||
m_status = new_status;
|
||||
emit status(m_status);
|
||||
}
|
||||
}
|
||||
|
||||
void Task::setProgress(int new_progress)
|
||||
void Task::setProgress(qint64 current, qint64 total)
|
||||
{
|
||||
emit progress(new_progress, 100);
|
||||
m_progress = current;
|
||||
m_progressTotal = total;
|
||||
emit progress(m_progress, m_progressTotal);
|
||||
}
|
||||
|
||||
void Task::start()
|
||||
@ -41,6 +47,7 @@ void Task::start()
|
||||
void Task::emitFailed(QString reason)
|
||||
{
|
||||
m_running = false;
|
||||
m_finished = true;
|
||||
m_succeeded = false;
|
||||
m_failReason = reason;
|
||||
qCritical() << "Task failed: " << reason;
|
||||
@ -52,6 +59,7 @@ void Task::emitSucceeded()
|
||||
{
|
||||
if (!m_running) { return; } // Don't succeed twice.
|
||||
m_running = false;
|
||||
m_finished = true;
|
||||
m_succeeded = true;
|
||||
qDebug() << "Task succeeded";
|
||||
emit succeeded();
|
||||
@ -63,6 +71,11 @@ bool Task::isRunning() const
|
||||
return m_running;
|
||||
}
|
||||
|
||||
bool Task::isFinished() const
|
||||
{
|
||||
return m_finished;
|
||||
}
|
||||
|
||||
bool Task::successful() const
|
||||
{
|
||||
return m_succeeded;
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
|
||||
virtual bool isRunning() const;
|
||||
|
||||
virtual bool isFinished() const;
|
||||
|
||||
/*!
|
||||
* True if this task was successful.
|
||||
* If the task failed or is still running, returns false.
|
||||
@ -41,6 +43,21 @@ public:
|
||||
|
||||
virtual bool canAbort() const { return false; }
|
||||
|
||||
QString getStatus()
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
qint64 getProgress()
|
||||
{
|
||||
return m_progress;
|
||||
}
|
||||
|
||||
qint64 getTotalProgress()
|
||||
{
|
||||
return m_progressTotal;
|
||||
}
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void progress(qint64 current, qint64 total);
|
||||
@ -61,14 +78,17 @@ protected slots:
|
||||
virtual void emitSucceeded();
|
||||
virtual void emitFailed(QString reason);
|
||||
|
||||
protected
|
||||
slots:
|
||||
public slots:
|
||||
void setStatus(const QString &status);
|
||||
void setProgress(int progress);
|
||||
void setProgress(qint64 current, qint64 total);
|
||||
|
||||
protected:
|
||||
bool m_running = false;
|
||||
bool m_finished = false;
|
||||
bool m_succeeded = false;
|
||||
QString m_failReason = "";
|
||||
QString m_status;
|
||||
int m_progress = 0;
|
||||
int m_progressTotal = 100;
|
||||
};
|
||||
|
||||
|
@ -154,7 +154,7 @@ void DownloadTask::fileDownloadFailed(QString reason)
|
||||
|
||||
void DownloadTask::fileDownloadProgressChanged(qint64 current, qint64 total)
|
||||
{
|
||||
setProgress((int)(((float)current / (float)total) * 100));
|
||||
setProgress(current, total);
|
||||
}
|
||||
|
||||
QString DownloadTask::updateFilesDir()
|
||||
|
Loading…
Reference in New Issue
Block a user