argdialog.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. virtual void accept() override;
  59. ~ArgDialog();
  60. signals:
  61. void uploadFiles(QVector<KFileData> files);
  62. void taskRequestReady(Task task, bool file_pending);
  63. private:
  64. void clearPost();
  65. void defaultPost();
  66. void clearTask();
  67. void addToArgList(QString value, QString type);
  68. void addOrReplaceInArgList(QString value, QString type);
  69. void addHashtag(QString tag);
  70. void addRequestedBy(QString value);
  71. void setTaskArguments();
  72. Ui::ArgDialog *ui;
  73. void addItem(QString value, QString type);
  74. void addFile(QString path);
  75. Task m_task;
  76. IGPost m_ig_post;
  77. QString m_file_path;
  78. };
  79. #endif // ARGDIALOG_H