11 #include "util/threading.h"
20 destructor_(new QAction(this)),
22 connect(destructor_, &QAction::triggered,
this, [
this]() {
28 if (progress_bar_ !=
nullptr) {
29 progress_bar_->hide();
38 CHECK_NOTNULL(thread);
40 thread_.reset(thread);
42 if (progress_bar_ ==
nullptr) {
43 progress_bar_ =
new QProgressDialog(
this);
44 progress_bar_->setWindowModality(Qt::ApplicationModal);
45 progress_bar_->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
46 Qt::CustomizeWindowHint);
49 progress_bar_->setWindowTitle(
" ");
50 progress_bar_->setLabel(
new QLabel(
this));
51 progress_bar_->setMaximum(0);
52 progress_bar_->setMinimum(0);
53 progress_bar_->setValue(0);
54 connect(progress_bar_, &QProgressDialog::canceled,
55 [
this]() { destructor_->trigger(); });
59 QPushButton* cancel_button =
60 progress_bar_->findChildren<QPushButton*>().
at(0);
61 cancel_button->setEnabled(stoppable);
63 progress_bar_->setLabelText(progress_text);
67 parentWidget()->mapToGlobal(parentWidget()->
rect().center());
68 progress_bar_->move(global.x() - progress_bar_->width() / 2,
69 global.y() - progress_bar_->height() / 2);
71 progress_bar_->show();
72 progress_bar_->raise();
74 thread_->AddCallback(Thread::FINISHED_CALLBACK,
75 [
this]() { destructor_->trigger(); });
80 const std::function<
void()>& func) {
81 class FunctionThread :
public Thread {
83 explicit FunctionThread(
const std::function<
void()>& f) : func_(f) {}
86 void Run() { func_(); }
87 const std::function<void()> func_;
90 StartThread(progress_text,
false,
new FunctionThread(func));
int Run(int argc, const char *argv[])
utility::CountingProgressReporter * progress_bar_
Generic file read and write utility for python interface.