39 destructor_(new QAction(this)),
41 connect(destructor_, &QAction::triggered,
this, [
this]() {
47 if (progress_bar_ !=
nullptr) {
48 progress_bar_->hide();
54 const bool stoppable,
Thread* thread) {
56 CHECK_NOTNULL(thread);
58 thread_.reset(thread);
60 if (progress_bar_ ==
nullptr) {
61 progress_bar_ =
new QProgressDialog(
this);
62 progress_bar_->setWindowModality(Qt::ApplicationModal);
63 progress_bar_->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
64 Qt::CustomizeWindowHint);
67 progress_bar_->setWindowTitle(
" ");
68 progress_bar_->setLabel(
new QLabel(
this));
69 progress_bar_->setMaximum(0);
70 progress_bar_->setMinimum(0);
71 progress_bar_->setValue(0);
72 connect(progress_bar_, &QProgressDialog::canceled,
73 [
this]() { destructor_->trigger(); });
77 QPushButton* cancel_button =
78 progress_bar_->findChildren<QPushButton*>().
at(0);
79 cancel_button->setEnabled(stoppable);
81 progress_bar_->setLabelText(progress_text);
85 parentWidget()->mapToGlobal(parentWidget()->rect().center());
86 progress_bar_->move(global.x() - progress_bar_->width() / 2,
87 global.y() - progress_bar_->height() / 2);
89 progress_bar_->show();
90 progress_bar_->raise();
93 [
this]() { destructor_->trigger(); });
98 const std::function<
void()>& func) {
99 class FunctionThread :
public Thread {
101 explicit FunctionThread(
const std::function<
void()>& f) : func_(f) {}
104 void Run() { func_(); }
105 const std::function<void()> func_;
108 StartThread(progress_text,
false,
new FunctionThread(func));
int Run(int argc, const char *argv[])
utility::CountingProgressReporter * progress_bar_