BackgroundTask.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef BACKGROUNDTASK_H
  2. #define BACKGROUNDTASK_H
  3. #include <QObject>
  4. #include <QRunnable>
  5. #include <string>
  6. #include <functional>
  7. #include "ImageExport.h"
  8. #include "MandelVideoGenerator.h"
  9. class BackgroundTask : public QObject, public QRunnable
  10. {
  11. Q_OBJECT
  12. protected:
  13. std::string shortDescription;
  14. std::function<bool(void)> stopCallback;
  15. public:
  16. BackgroundTask(const std::string& shortDescription, std::function<bool(void)> stopCallback = [] () { return false; });
  17. void run(void) = 0;
  18. inline const std::string& getShortDescription(void) const { return shortDescription; }
  19. signals:
  20. void progress(float percentage);
  21. void finished(bool success, QString message);
  22. };
  23. class ImageExportTask : public BackgroundTask
  24. {
  25. Q_OBJECT
  26. private:
  27. const alm::ImageExportInfo iei;
  28. public:
  29. ImageExportTask(const alm::ImageExportInfo& iei, std::function<bool(void)> stopCallback = [] () { return false; });
  30. void run(void) override;
  31. };
  32. class VideoExportTask : public BackgroundTask
  33. {
  34. Q_OBJECT
  35. private:
  36. MandelVideoGenerator mvg;
  37. mnd::MandelGenerator& generator;
  38. public:
  39. VideoExportTask(MandelVideoGenerator mvg, mnd::MandelGenerator& generator);
  40. void run(void) override;
  41. };
  42. #endif // BACKGROUNDTASK_H