GH-1053 add back update progress dialog

This commit is contained in:
Petr Mrázek
2015-07-26 17:55:29 +02:00
parent 6310f6569c
commit d8caab515a
35 changed files with 151 additions and 63 deletions

View File

@ -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);
}

View File

@ -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() {};

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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();

View File

@ -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())
@ -40,4 +47,4 @@ void Update::updateFinished()
emit logLine(reason, MessageLevel::Fatal);
emitFailed(reason);
}
}
}

View File

@ -32,6 +32,7 @@ public:
{
return false;
}
virtual void proceed();
private slots:
void updateFinished();