argdialog.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <headers/util.hpp>
  11. namespace Args {
  12. const QString DESCRIPTION_TYPE = "description";
  13. const QString HASHTAG_TYPE = "hashtag";
  14. const QString PROMOTE_TYPE = "promote/share";
  15. const QString LINK_BIO_TYPE = "link/bio";
  16. const QString REQUESTED_BY_TYPE = "requested by";
  17. } // namespace Args
  18. typedef std::string Str;
  19. typedef struct Task {
  20. int mask;
  21. std::vector<std::string> args;
  22. } Task;
  23. typedef struct KFile {
  24. QString name;
  25. QString path;
  26. FileType type;
  27. } KFile;
  28. typedef struct IGPost {
  29. std::string description;
  30. std::string datetime;
  31. std::string promote_share = "Promote share";
  32. // std::string link_in_bio = u8"Download a FREE PDF of basic 245 verbs (link 🔗 in bio 👆)";
  33. std::string link_in_bio = "Link inbio";
  34. std::vector<std::string> hashtags;
  35. std::vector<std::string> requested_by;
  36. const char *requested_by_phrase = "The phrase was requested by ";
  37. std::vector<KFile> files;
  38. bool is_video;
  39. bool isReady() {
  40. return description.size() > 0 && datetime.size() > 0 &&
  41. promote_share.size() > 0 && link_in_bio.size() > 0 &&
  42. hashtags.size() > 0 && requested_by.size() > 0 && !files.empty() &&
  43. files.at(0).path.size() > 0;
  44. }
  45. } IGPost;
  46. namespace Ui {
  47. class ArgDialog;
  48. }
  49. class ArgDialog : public QDialog {
  50. Q_OBJECT
  51. public:
  52. explicit ArgDialog(QWidget *parent = nullptr);
  53. ~ArgDialog();
  54. signals:
  55. void uploadFiles(QVector<KFileData> files);
  56. void taskRequestReady(Task task, bool file_pending);
  57. private:
  58. void clearPost();
  59. void clearTask();
  60. void addToArgList(QString value, QString type);
  61. void addOrReplaceInArgList(QString value, QString type);
  62. void addHashtag(QString tag);
  63. void addRequestedBy(QString value);
  64. void setTaskArguments();
  65. Ui::ArgDialog *ui;
  66. void addItem(QString value, QString type);
  67. void addFile(QString path);
  68. Task m_task;
  69. IGPost m_ig_post;
  70. };
  71. #endif // ARGDIALOG_H