MCPcopy Create free account
hub / github.com/MultiMC/Launcher / execWithTask

Method execWithTask

launcher/ui/dialogs/ProgressDialog.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61int ProgressDialog::execWithTask(Task *task)
62{
63 this->task = task;
64 QDialog::DialogCode result;
65
66 if(!task)
67 {
68 qDebug() << "Programmer error: progress dialog created with null task.";
69 return Accepted;
70 }
71
72 if(handleImmediateResult(result))
73 {
74 return result;
75 }
76
77 // Connect signals.
78 connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
79 connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString)));
80 connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded()));
81 connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString &)));
82 connect(task, SIGNAL(progress(qint64, qint64)), SLOT(changeProgress(qint64, qint64)));
83
84 // if this didn't connect to an already running task, invoke start
85 if(!task->isRunning())
86 {
87 task->start();
88 }
89 if(task->isRunning())
90 {
91 changeProgress(task->getProgress(), task->getTotalProgress());
92 changeStatus(task->getStatus());
93 return QDialog::exec();
94 }
95 else if(handleImmediateResult(result))
96 {
97 return result;
98 }
99 else
100 {
101 return QDialog::Rejected;
102 }
103}
104
105// TODO: only provide the unique_ptr overloads
106int ProgressDialog::execWithTask(std::unique_ptr<Task> &&task)

Callers 11

loginMethod · 0.80
onProgressRequestedMethod · 0.80
downloadUpdatesMethod · 0.80
runModalTaskMethod · 0.80
finalizeInstanceMethod · 0.80
uploadPasteMethod · 0.80
runModalTaskMethod · 0.80
on_buttonBox_acceptedMethod · 0.80

Calls 6

getProgressMethod · 0.80
getTotalProgressMethod · 0.80
getStatusMethod · 0.80
isRunningMethod · 0.45
startMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected