argdialog.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. namespace Args {
  11. const QString DESCRIPTION_TYPE = "description";
  12. const QString HASHTAG_TYPE = "hashtag";
  13. const QString PROMOTE_TYPE = "promote/share";
  14. const QString LINK_BIO_TYPE = "link/bio";
  15. const QString REQUESTED_BY_TYPE = "requested by";
  16. } // namespace Args
  17. typedef std::string Str;
  18. //namespace Emoji {
  19. // Str SmilingFaceEyes{"U+1F60A"};
  20. // const char* SmilingFaceEyesBytes = "😊";
  21. //}
  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. } KFile;
  30. typedef struct IGPost {
  31. std::string description;
  32. std::string datetime;
  33. std::string promote_share = "Promote share";
  34. // std::string link_in_bio = u8"Download a FREE PDF of basic 245 verbs (link 🔗 in bio 👆)";
  35. std::string link_in_bio = "Link inbio";
  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. KFile video;
  40. bool isReady() {
  41. return description.size() > 0 && datetime.size() > 0 &&
  42. promote_share.size() > 0 && link_in_bio.size() > 0 &&
  43. hashtags.size() > 0 && requested_by.size() > 0 &&
  44. video.path.size() > 0;
  45. }
  46. } IGPost;
  47. namespace Ui {
  48. class ArgDialog;
  49. }
  50. class ArgDialog : public QDialog {
  51. Q_OBJECT
  52. public:
  53. explicit ArgDialog(QWidget *parent = nullptr);
  54. ~ArgDialog();
  55. signals:
  56. void uploadFile(QByteArray bytes);
  57. void taskRequestReady(Task task, bool file_pending);
  58. private:
  59. void clearPost();
  60. void clearTask();
  61. void addToArgList(QString value, QString type);
  62. void addOrReplaceInArgList(QString value, QString type);
  63. void addHashtag(QString tag);
  64. void addRequestedBy(QString value);
  65. void setTaskArguments();
  66. Ui::ArgDialog *ui;
  67. void addItem(QString value, QString type);
  68. Task m_task;
  69. IGPost m_ig_post;
  70. };
  71. #endif // ARGDIALOG_H