argdialog.h 2.4 KB

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