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