task: massively simplified task system

Made various changes and fixes to the task system:

- Tasks are built around QtConcurrent rather than QThread. Reduces
  code complexity significantly.
- Task error reporting is now streamlined in both TaskManager and
  TaskDialog.
- Moved ProjectImport/Save/LoadManager to the app/task folder
This commit is contained in:
itsmattkc
2020-05-19 02:44:32 +10:00
parent c4b0a53174
commit b9cd83eff1
49 changed files with 864 additions and 1332 deletions
+40
View File
@@ -21,9 +21,12 @@
#include "progress.h"
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
#include "window/mainwindow/mainwindow.h"
OLIVE_NAMESPACE_ENTER
ProgressDialog::ProgressDialog(const QString& message, const QString& title, QWidget *parent) :
@@ -56,9 +59,46 @@ ProgressDialog::ProgressDialog(const QString& message, const QString& title, QWi
cancel_layout->addStretch();
}
void ProgressDialog::showEvent(QShowEvent *e)
{
QDialog::showEvent(e);
#ifdef Q_OS_WINDOWS
Core::instance()->main_window()->SetTaskbarButtonState(TBPF_NORMAL);
#endif
}
void ProgressDialog::closeEvent(QCloseEvent *e)
{
QDialog::closeEvent(e);
#ifdef Q_OS_WINDOWS
Core::instance()->main_window()->SetTaskbarButtonState(TBPF_NOPROGRESS);
#endif
}
void ProgressDialog::SetProgress(int value)
{
bar_->setValue(value);
#ifdef Q_OS_WINDOWS
Core::instance()->main_window()->SetTaskbarButtonProgress(value, 100);
#endif
}
void ProgressDialog::ShowErrorMessage(const QString &title, const QString &message)
{
#ifdef Q_OS_WINDOWS
Core::instance()->main_window()->SetTaskbarButtonState(TBPF_ERROR);
#endif
QMessageBox b(this);
b.setIcon(QMessageBox::Critical);
b.setWindowModality(Qt::WindowModal);
b.setWindowTitle(title);
b.setText(message);
b.addButton(QMessageBox::Ok);
b.exec();
}
OLIVE_NAMESPACE_EXIT