Parcourir la source

providing and updating user argument

logicp il y a 5 ans
Parent
commit
693fca7959
3 fichiers modifiés avec 20 ajouts et 9 suppressions
  1. 4 3
      include/argdialog.h
  2. 7 1
      src/argdialog.cpp
  3. 9 5
      src/client.cpp

+ 4 - 3
include/argdialog.h

@@ -39,12 +39,13 @@ typedef struct IGPost {
   std::vector<std::string> requested_by;
   const char *requested_by_phrase = "The phrase was requested by ";
   std::vector<KFile> files;
+  std::string user;
   bool is_video;
   bool isReady() {
-      return header.size() > 0 && description.size() > 0 && datetime.size() > 0 &&
+    return header.size() > 0 && description.size() > 0 && datetime.size() > 0 &&
            promote_share.size() > 0 && link_in_bio.size() > 0 &&
-             hashtags.size() > 0 && requested_by.size() > 0 && !files.empty() &&
-             files.at(0).path.size() > 0;
+           hashtags.size() > 0 && requested_by.size() > 0 && !files.empty() &&
+           files.at(0).path.size() > 0 && user.size() > 0;
   }
 } IGPost;
 

+ 7 - 1
src/argdialog.cpp

@@ -53,6 +53,11 @@ ArgDialog::ArgDialog(QWidget *parent)
     }
   });
 
+  QObject::connect(ui->user, &QComboBox::currentTextChanged, this,
+                   [this](const QString &text) {
+                     m_ig_post.user = text.toUtf8().constData();
+                   });
+
   ui->argList->setHorizontalHeaderLabels(
       QStringList{"Type", "Value", "Preview", "Delete"});
   ui->argList->setColumnWidth(0, 40);
@@ -145,7 +150,6 @@ void ArgDialog::setTaskArguments() {
         requested_by.pop_back();
     }
 
-//    m_task.args.push_back(m_ig_post.file.name.toUtf8().constData());
     m_task.args.push_back(m_ig_post.datetime);
     m_task.args.push_back(m_ig_post.description);
     m_task.args.push_back(hashtags);
@@ -155,6 +159,7 @@ void ArgDialog::setTaskArguments() {
     m_task.args.push_back(m_ig_post.link_in_bio);
     m_task.args.push_back(std::to_string(m_ig_post.is_video));
     m_task.args.push_back(m_ig_post.header);
+    m_task.args.push_back(m_ig_post.user);
 }
 
 void ArgDialog::addItem(QString value, QString type) {
@@ -198,6 +203,7 @@ void ArgDialog::clearPost() {
   m_ig_post.requested_by.clear();
   m_ig_post.promote_share = "Share the post through IG story if you enjoy the phrase 🙋‍♀️";
   m_ig_post.requested_by_phrase = "The phrase was requested by ";
+  m_ig_post.user = ui->user->currentText().toUtf8().constData();
   ui->argType->setCurrentIndex(0);
   ui->argList->setRowCount(0);
 }

+ 9 - 5
src/client.cpp

@@ -237,10 +237,10 @@ std::string getTaskFileInfo(std::vector<SentFile> files) {
  */
 void Client::sendTaskEncoded(TaskType type, std::vector<std::string> args) {
     if (type == TaskType::INSTAGRAM) {
-        if (args.size() < 7) {
-            qDebug() << "Not enough arguments to send an IGTask";
-            return;
-        }
+      if (args.size() < 8) {
+        qDebug() << "Not enough arguments to send an IGTask";
+        return;
+      }
         auto file_info = builder.CreateString(getTaskFileInfo(sent_files));
         auto time = builder.CreateString(args.at(0).c_str(), args.at(0).size());
         auto description = builder.CreateString(args.at(1).c_str(), args.at(1).size());
@@ -251,8 +251,12 @@ void Client::sendTaskEncoded(TaskType type, std::vector<std::string> args) {
         auto link_bio = builder.CreateString(args.at(6).c_str(), args.at(6).size());
         auto is_video = args.at(7) == "1";
         auto header = builder.CreateString(args.at(8).c_str(), args.at(8).size());
+        auto user = builder.CreateString(args.at(9).c_str(), args.at(9).size());
 
-        flatbuffers::Offset<IGTask> ig_task = CreateIGTask(builder, 96, file_info, time, description, hashtags, requested_by, requested_by_phrase, promote_share, link_bio, is_video, 16, header);
+        flatbuffers::Offset<IGTask> ig_task =
+            CreateIGTask(builder, 96, file_info, time, description, hashtags,
+                         requested_by, requested_by_phrase, promote_share,
+                         link_bio, is_video, 16, header, user);
 
         builder.Finish(ig_task);