summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/ConsoleWindow.cpp9
-rw-r--r--application/ConsoleWindow.h1
-rw-r--r--application/dialogs/ProgressDialog.cpp37
-rw-r--r--application/dialogs/ProgressDialog.h3
4 files changed, 49 insertions, 1 deletions
diff --git a/application/ConsoleWindow.cpp b/application/ConsoleWindow.cpp
index 9dc5874d..8f3f20bd 100644
--- a/application/ConsoleWindow.cpp
+++ b/application/ConsoleWindow.cpp
@@ -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()
{
diff --git a/application/ConsoleWindow.h b/application/ConsoleWindow.h
index f9e4c89e..ac5a6fd1 100644
--- a/application/ConsoleWindow.h
+++ b/application/ConsoleWindow.h
@@ -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)
diff --git a/application/dialogs/ProgressDialog.cpp b/application/dialogs/ProgressDialog.cpp
index 9a437d7a..939c5870 100644
--- a/application/dialogs/ProgressDialog.cpp
+++ b/application/dialogs/ProgressDialog.cpp
@@ -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()
diff --git a/application/dialogs/ProgressDialog.h b/application/dialogs/ProgressDialog.h
index fb80d0ce..44cbbe88 100644
--- a/application/dialogs/ProgressDialog.h
+++ b/application/dialogs/ProgressDialog.h
@@ -59,6 +59,9 @@ protected:
virtual void closeEvent(QCloseEvent *e);
private:
+ bool handleImmediateResult(QDialog::DialogCode &result);
+
+private:
Ui::ProgressDialog *ui;
Task *task;