Browse Source

adding clear functionality

Emmanuel Buckshi 5 years ago
parent
commit
b1f4530a31
3 changed files with 53 additions and 0 deletions
  1. 20 0
      argdialog.ui
  2. 15 0
      src/argdialog.cpp
  3. 18 0
      ui_argdialog.h

+ 20 - 0
argdialog.ui

@@ -433,6 +433,26 @@ padding-left: 2px;</string>
       </item>
      </layout>
     </item>
+    <item>
+     <widget class="QPushButton" name="clear">
+      <property name="styleSheet">
+       <string notr="true">background-color: rgb(255, 85, 0);
+font: 87 11pt &quot;Noto Sans&quot;;
+color: rgb(0, 43, 54);
+font-weight: 700;
+padding: 4px;
+border-style: outset;
+border-width: 2px;
+border-radius: 4px;
+border-color: #00000f;
+min-width: 4em;
+padding: 4px;</string>
+      </property>
+      <property name="text">
+       <string>Clear</string>
+      </property>
+     </widget>
+    </item>
    </layout>
   </widget>
  </widget>

+ 15 - 0
src/argdialog.cpp

@@ -132,6 +132,21 @@ ArgDialog::ArgDialog(QWidget *parent) :
             .files = {{ .name = "holy.jpg", .path = "/data/c/ky_gui/assets/holy.jpg", .type = FileType::IMAGE }}
         };
     });
+
+    QObject::connect(ui->clear, &QPushButton::clicked, this, [this]() {
+        m_task.args.clear();
+        m_ig_post.files.clear();
+        m_ig_post.datetime = "";
+        m_ig_post.hashtags.clear();
+        m_ig_post.description = "";
+        m_ig_post.link_in_bio = "";
+        m_ig_post.requested_by.clear();
+        m_ig_post.promote_share = "";
+        m_ig_post.is_video = false;
+        ui->argList->clear();
+        ui->argList->setRowCount(0);
+        qDebug() << "Task cleared";
+    });
 }
 
 void ArgDialog::setTaskArguments() {

+ 18 - 0
ui_argdialog.h

@@ -57,6 +57,7 @@ public:
     QSpacerItem *horizontalSpacer;
     QTableWidget *argList;
     QSpacerItem *horizontalSpacer_2;
+    QPushButton *clear;
 
     void setupUi(QDialog *ArgDialog)
     {
@@ -328,6 +329,22 @@ public:
 
         verticalLayout_2->addLayout(horizontalLayout_6);
 
+        clear = new QPushButton(verticalLayoutWidget_2);
+        clear->setObjectName(QString::fromUtf8("clear"));
+        clear->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+"font: 87 11pt \"Noto Sans\";\n"
+"color: rgb(0, 43, 54);\n"
+"font-weight: 700;\n"
+"padding: 4px;\n"
+"border-style: outset;\n"
+"border-width: 2px;\n"
+"border-radius: 4px;\n"
+"border-color: #00000f;\n"
+"min-width: 4em;\n"
+"padding: 4px;"));
+
+        verticalLayout_2->addWidget(clear);
+
 
         retranslateUi(ArgDialog);
         QObject::connect(argCommandButtons, SIGNAL(accepted()), ArgDialog, SLOT(accept()));
@@ -354,6 +371,7 @@ public:
         label_5->setText(QCoreApplication::translate("ArgDialog", "Time", nullptr));
         devTestButton->setText(QCoreApplication::translate("ArgDialog", "DEV TEST", nullptr));
         label->setText(QCoreApplication::translate("ArgDialog", "Items to send", nullptr));
+        clear->setText(QCoreApplication::translate("ArgDialog", "Clear", nullptr));
     } // retranslateUi
 
 };