-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprogressreport.cpp
42 lines (35 loc) · 1.19 KB
/
progressreport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "progressreport.h"
namespace CheatSh {
namespace Internal {
ProgressReport::ProgressReport()
{
}
void ProgressReport::startNew()
{
progress_.reset();
progress_ = std::make_unique<QFutureInterface<void>>();
progress_->setProgressRange(0, 2);
Core::FutureProgress* future_progress =
Core::ProgressManager::addTask( progress_->future(),
tr("Cheat.sh: Requesting cheat sheet"),
CheatSh::Constants::TASK_ID_REQUEST );
QObject::connect(future_progress, &Core::FutureProgress::canceled, this, &ProgressReport::cancelRequested);
progress_->reportStarted();
}
void ProgressReport::increment()
{
if(progress_) {
progress_->setProgressValue(progress_->progressValue()+1);
if(progress_->progressValue() == progress_->progressMaximum())
progress_->reportFinished();
}
}
void ProgressReport::cancel()
{
if(progress_) {
progress_->reportCanceled(); // It seems cancel() and reportCanceled do same thing
progress_->reportFinished(); // reportFinished should follow reportCanceled
}
}
} // namespace Internal
} // namespace CheatSh