argdialog.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef ARGDIALOG_H
  2. #define ARGDIALOG_H
  3. #include <QDialog>
  4. #include <QFile>
  5. #include <QFileDialog>
  6. #include <QMessageBox>
  7. #include <QPushButton>
  8. #include <string_view>
  9. #include <unordered_map>
  10. #include <QKeyEvent>
  11. #include <headers/util.hpp>
  12. #include <include/kfiledialog.h>
  13. namespace Args {
  14. const QString HEADER_TYPE = "header";
  15. const QString DESCRIPTION_TYPE = "description";
  16. const QString HASHTAG_TYPE = "hashtag";
  17. const QString PROMOTE_TYPE = "promote/share";
  18. const QString LINK_BIO_TYPE = "link/bio";
  19. const QString REQUESTED_BY_TYPE = "requested by";
  20. } // namespace Args
  21. typedef std::string Str;
  22. typedef struct KFile {
  23. QString name;
  24. QString path;
  25. FileType type;
  26. } KFile;
  27. typedef struct IGPost {
  28. std::string header = "Learn to speak like native Korean speakers 🙆‍♀️🇰🇷";
  29. std::string description;
  30. std::string datetime;
  31. std::string promote_share = "Share the post through IG story if you enjoy the phrase 🙋‍♀️";
  32. std::string link_in_bio = "Subscribe to my YouTube channel (link 🔗in bio) to learn more about Korean language and culture ❤";
  33. std::vector<std::string> hashtags;
  34. std::vector<std::string> requested_by;
  35. const char *requested_by_phrase = "The phrase was requested by ";
  36. std::vector<KFile> files;
  37. bool is_video;
  38. bool isReady() {
  39. return header.size() > 0 && description.size() > 0 && datetime.size() > 0 &&
  40. promote_share.size() > 0 && link_in_bio.size() > 0 &&
  41. hashtags.size() > 0 && requested_by.size() > 0 && !files.empty() &&
  42. files.at(0).path.size() > 0;
  43. }
  44. } IGPost;
  45. namespace Ui {
  46. class ArgDialog;
  47. }
  48. class ArgDialog : public QDialog {
  49. Q_OBJECT
  50. public:
  51. explicit ArgDialog(QWidget *parent = nullptr);
  52. virtual void keyPressEvent(QKeyEvent* e);
  53. void setFilePath(QString path);
  54. virtual void accept() override;
  55. ~ArgDialog();
  56. signals:
  57. void uploadFiles(QVector<KFileData> files);
  58. void taskRequestReady(Task task, bool file_pending);
  59. private:
  60. void clearPost();
  61. void defaultPost();
  62. void clearTask();
  63. void addToArgList(QString value, QString type);
  64. void addOrReplaceInArgList(QString value, QString type);
  65. void addHashtag(QString tag);
  66. void addRequestedBy(QString value);
  67. void setTaskArguments();
  68. Ui::ArgDialog *ui;
  69. void addItem(QString value, QString type);
  70. void addFile(QString path);
  71. Task m_task;
  72. IGPost m_ig_post;
  73. QString m_file_path;
  74. };
  75. #endif // ARGDIALOG_H