argdialog.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef ARGDIALOG_H
  2. #define ARGDIALOG_H
  3. #include <include/ui/kfiledialog.h>
  4. #include <QDialog>
  5. #include <QFile>
  6. #include <QFileDialog>
  7. #include <QKeyEvent>
  8. #include <QMessageBox>
  9. #include <QPushButton>
  10. #include <headers/util.hpp>
  11. #include <include/task/instagram_task.hpp>
  12. #include <include/task/generic_task.hpp>
  13. #include <include/task/task.hpp>
  14. #include <string_view>
  15. #include <unordered_map>
  16. #include <QVBoxLayout>
  17. #include <QLabel>
  18. #include <QMovie>
  19. using namespace Scheduler;
  20. inline Task* createTask(QString task_name = GENERIC_NAME) {
  21. Task* task;
  22. if (task_name == INSTAGRAM_NAME) {
  23. task = new InstagramTask{};
  24. } else {
  25. task = new GenericTask{};
  26. }
  27. task->defineTaskArguments();
  28. task->setDefaultValues();
  29. return task;
  30. }
  31. namespace Ui {
  32. class ArgDialog;
  33. }
  34. class ArgDialog : public QDialog {
  35. Q_OBJECT
  36. public:
  37. explicit ArgDialog(QWidget *parent = nullptr);
  38. virtual void keyPressEvent(QKeyEvent* e) override;
  39. void setFilePath(QString path);
  40. virtual void accept() override;
  41. void setAppName(QString task_name);
  42. void setConfig(QJsonObject config);
  43. void notifyClientSuccess();
  44. ~ArgDialog();
  45. signals:
  46. void taskRequestReady(Scheduler::Task *task);
  47. protected:
  48. void showEvent(QShowEvent* event) override;
  49. private:
  50. void clearPost();
  51. void defaultPost();
  52. void clearTask();
  53. void displayLoader(bool visible);
  54. void addToArgList(QString value, QString type);
  55. void addOrReplaceInArgList(QString value, QString type);
  56. void addHashtag(QString tag);
  57. void addRequestedBy(QString value);
  58. void setTaskArguments();
  59. void setArgTypes();
  60. Ui::ArgDialog *ui;
  61. void addItem(QString value, QString type);
  62. void addFile(QString path);
  63. Task* m_task;
  64. Task* m_pending_task;
  65. QString m_file_path;
  66. QJsonObject m_config;
  67. QString m_app_name;
  68. QMovie* m_loader;
  69. QWidget m_loader_widget;
  70. QVBoxLayout m_loader_layout;
  71. };
  72. #endif // ARGDIALOG_H