Browse Source

preview images with spaces in filename
fix order of events in events vector, to match UI
simplified UI
consistent button colours
fix issue with display of image previes
fixed default behaviour when clearing the args

logicp 5 years ago
parent
commit
9625106606
5 changed files with 17 additions and 125 deletions
  1. 3 44
      argdialog.ui
  2. 1 1
      headers/util.hpp
  3. 9 39
      src/argdialog.cpp
  4. 1 1
      src/mainwindow.cpp
  5. 3 40
      ui_argdialog.h

+ 3 - 44
argdialog.ui

@@ -158,7 +158,7 @@ font-weight: 700;
     <item>
      <widget class="QPushButton" name="addArgument">
       <property name="styleSheet">
-       <string notr="true">background-color: rgb(255, 85, 0);
+       <string notr="true">background-color: #2f535f;
 font: 87 11pt &quot;Noto Sans&quot;;
 color: rgb(0, 43, 54);
 font-weight: 700;
@@ -204,7 +204,7 @@ font-weight: 700;</string>
       <item>
        <widget class="QPushButton" name="addFile">
         <property name="styleSheet">
-         <string notr="true">background-color: rgb(255, 85, 0);
+         <string notr="true">background-color: #2f535f;
 font: 87 11pt &quot;Noto Sans&quot;;
 color: rgb(0, 43, 54);
 font-weight: 700;
@@ -276,27 +276,6 @@ font-size: 16pt;</string>
     </item>
     <item>
      <layout class="QHBoxLayout" name="horizontalLayout_5">
-      <item>
-       <widget class="QPushButton" name="devTestButton">
-        <property name="styleSheet">
-         <string notr="true">background-color: rgb(130, 255, 121);
-background-color: rgb(2, 180, 43);
-font: 87 11pt &quot;Noto Sans&quot;;
-color: rgb(0, 0, 0);
-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>DEV TEST</string>
-        </property>
-       </widget>
-      </item>
       <item>
        <widget class="QDialogButtonBox" name="argCommandButtons">
         <property name="sizePolicy">
@@ -436,30 +415,10 @@ padding-left: 2px;</string>
     </item>
     <item>
      <layout class="QHBoxLayout" name="horizontalLayout_7">
-      <item>
-       <widget class="QPushButton" name="default_args">
-        <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>Default</string>
-        </property>
-       </widget>
-      </item>
       <item>
        <widget class="QPushButton" name="clear">
         <property name="styleSheet">
-         <string notr="true">background-color: rgb(255, 85, 0);
+         <string notr="true">background-color: #2f535f;
 font: 87 11pt &quot;Noto Sans&quot;;
 color: rgb(0, 43, 54);
 font-weight: 700;

+ 1 - 1
headers/util.hpp

@@ -369,7 +369,7 @@ QString generatePreview(QString video_path, QString video_name) {
 //    QString command{
 //        "ffmpeg -ss 0 -i " + video_path + " -vf select=\"eq(pict_type\\,I)\" -vframes 1 ./assets/previews/" + preview_name};
     QString command {
-        "ffmpeg -y -ss 0 -i " + video_path + " -vf \"scale=w=640:h=640:force_original_aspect_ratio=decrease,pad=w=640:h=640:x=(iw-ow)/2:y=(ih-oh/2):color=white\" -vframes 1 ./assets/previews/" + preview_name
+        "ffmpeg -y -ss 0 -i '" + video_path + "' -vf \"scale=w=640:h=640:force_original_aspect_ratio=decrease,pad=w=640:h=640:x=(iw-ow)/2:y=(ih-oh/2):color=white\" -vframes 1 './assets/previews/" + preview_name + "'"
     };
 
     std::system(command.toUtf8());

+ 9 - 39
src/argdialog.cpp

@@ -17,6 +17,8 @@ ArgDialog::ArgDialog(QWidget *parent) :
     m_ig_post(IGPost{})
 {
     ui->setupUi(this);
+
+    ui->argCommandButtons->button(QDialogButtonBox::Cancel)->setStyleSheet(QString("background:%1").arg("#2f535f"));
     QObject::connect(ui->addFile, &QPushButton::clicked, this, [this]() {
         KFileDialog file_dialog{};
         auto file_path = file_dialog.openFileDialog();
@@ -50,7 +52,7 @@ ArgDialog::ArgDialog(QWidget *parent) :
         }
     });
 
-    ui->argList->setHorizontalHeaderLabels(QStringList{"Value", "Type"});
+    ui->argList->setHorizontalHeaderLabels(QStringList{"Value", "Type", "Preview", "Delete"});
     ui->argList->setColumnWidth(0, 300);
     ui->argList->setColumnWidth(1, 40);
     ui->argList->setColumnWidth(2, 100);
@@ -79,8 +81,6 @@ ArgDialog::ArgDialog(QWidget *parent) :
         }
     });
 
-    QDateTime date_time = QDateTime::currentDateTime();
-//    date_time.
     ui->dateTime->setDateTime(QDateTime::currentDateTime());
 
     QObject::connect(ui->dateTime, &QDateTimeEdit::dateTimeChanged, this, [this]() {
@@ -118,34 +118,14 @@ ArgDialog::ArgDialog(QWidget *parent) :
 
                 emit ArgDialog::taskRequestReady(m_task, true);
             }
-            defaultPost(); // reset m_ig_post to default values
+            clearPost(); // reset m_ig_post to default values
         }
     });
 
-    QObject::connect(ui->devTestButton, &QPushButton::clicked, this, [this]() {
-        clearPost();
-
-        m_ig_post = IGPost{
-            .description = escapeText("My description yay!!!").toUtf8().constData(),
-            .datetime = std::to_string(QDateTime::currentDateTime().toTime_t() + 12000),
-            .promote_share = escapeText("If you enjoy the phrase, please like and share 🙋‍♀️").toUtf8().constData(),
-            .link_in_bio = escapeText("Download a FREE PDF of 245 basic verbs (link 🔗 in bio 👆").toUtf8().constData(),
-            .hashtags = {"love", "life"},
-            .requested_by = {"unwillingagent"},
-            .files = {{ .name = "holy.jpg", .path = "/data/c/ky_gui/assets/holy.jpg", .type = FileType::IMAGE }}
-        };
-    });
-
     QObject::connect(ui->clear, &QPushButton::clicked, this, [this]() {
         clearPost();
         ui->argList->setRowCount(0);
-        qDebug() << "Task cleared";
-    });
-
-    QObject::connect(ui->default_args, &QPushButton::clicked, this, [this]() {
-        defaultPost();
-        ui->argList->setRowCount(0);
-        qDebug() << "Task set to default values";
+        qDebug() << "Task cleared and restored to default values";
     });
 }
 
@@ -190,7 +170,7 @@ void ArgDialog::addItem(QString value, QString type) {
     });
     ui->argList->setItem(row, 0, item);
     ui->argList->setItem(row, 1, item2);
-    ui->argList->setCellWidget(row, 2, q_pb);
+    ui->argList->setCellWidget(row, 3, q_pb);
 }
 
 void ArgDialog::addFile(QString path) {
@@ -207,21 +187,11 @@ void ArgDialog::addFile(QString path) {
 }
 
 void ArgDialog::clearPost() {
-    m_ig_post.files.clear();
-    m_ig_post.header = "";
-    m_ig_post.datetime = "";
-    m_ig_post.hashtags = {};
-    m_ig_post.description = "";
-    m_ig_post.link_in_bio = "";
-    m_ig_post.requested_by = {};
-    m_ig_post.promote_share = "";
-    m_ig_post.requested_by_phrase = "";
-}
-
-void ArgDialog::defaultPost() {
     m_ig_post.files.clear();
     m_ig_post.header = "Learn to speak like native Korean speakers 🙆‍♀️🇰🇷";
-    m_ig_post.datetime = "";
+    QDateTime date_time = QDateTime::currentDateTime();
+    ui->dateTime->setDateTime(date_time);
+    m_ig_post.datetime = date_time.toTime_t();
     m_ig_post.hashtags.clear();
     m_ig_post.description = "";
     m_ig_post.link_in_bio = "Subscribe to my YouTube channel (link 🔗in bio) to learn more about Korean language and culture ❤";

+ 1 - 1
src/mainwindow.cpp

@@ -273,7 +273,7 @@ void MainWindow::updateMessages(int t, const QString& message, StringVec v) {
         } else {
             event_message += message;
         }
-        m_events.push_front(event_message);
+        m_events.push_back(event_message);
         m_event_model->setItem(m_event_model->rowCount(), createEventListItem(event_message));
     } else {
         qDebug() << "Unknown update type. Cannot update UI";

+ 3 - 40
ui_argdialog.h

@@ -48,7 +48,6 @@ public:
     QLabel *label_5;
     QDateTimeEdit *dateTime;
     QHBoxLayout *horizontalLayout_5;
-    QPushButton *devTestButton;
     QDialogButtonBox *argCommandButtons;
     QWidget *verticalLayoutWidget_2;
     QVBoxLayout *verticalLayout_2;
@@ -58,7 +57,6 @@ public:
     QTableWidget *argList;
     QSpacerItem *horizontalSpacer_2;
     QHBoxLayout *horizontalLayout_7;
-    QPushButton *default_args;
     QPushButton *clear;
 
     void setupUi(QDialog *ArgDialog)
@@ -157,7 +155,7 @@ public:
 
         addArgument = new QPushButton(verticalLayoutWidget);
         addArgument->setObjectName(QString::fromUtf8("addArgument"));
-        addArgument->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+        addArgument->setStyleSheet(QString::fromUtf8("background-color: #2f535f;\n"
 "font: 87 11pt \"Noto Sans\";\n"
 "color: rgb(0, 43, 54);\n"
 "font-weight: 700;\n"
@@ -189,7 +187,7 @@ public:
 
         addFile = new QPushButton(verticalLayoutWidget);
         addFile->setObjectName(QString::fromUtf8("addFile"));
-        addFile->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+        addFile->setStyleSheet(QString::fromUtf8("background-color: #2f535f;\n"
 "font: 87 11pt \"Noto Sans\";\n"
 "color: rgb(0, 43, 54);\n"
 "font-weight: 700;\n"
@@ -237,23 +235,6 @@ public:
 
         horizontalLayout_5 = new QHBoxLayout();
         horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5"));
-        devTestButton = new QPushButton(verticalLayoutWidget);
-        devTestButton->setObjectName(QString::fromUtf8("devTestButton"));
-        devTestButton->setStyleSheet(QString::fromUtf8("background-color: rgb(130, 255, 121);\n"
-"background-color: rgb(2, 180, 43);\n"
-"font: 87 11pt \"Noto Sans\";\n"
-"color: rgb(0, 0, 0);\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;"));
-
-        horizontalLayout_5->addWidget(devTestButton);
-
         argCommandButtons = new QDialogButtonBox(verticalLayoutWidget);
         argCommandButtons->setObjectName(QString::fromUtf8("argCommandButtons"));
         QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -333,25 +314,9 @@ public:
 
         horizontalLayout_7 = new QHBoxLayout();
         horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7"));
-        default_args = new QPushButton(verticalLayoutWidget_2);
-        default_args->setObjectName(QString::fromUtf8("default_args"));
-        default_args->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;"));
-
-        horizontalLayout_7->addWidget(default_args);
-
         clear = new QPushButton(verticalLayoutWidget_2);
         clear->setObjectName(QString::fromUtf8("clear"));
-        clear->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+        clear->setStyleSheet(QString::fromUtf8("background-color: #2f535f;\n"
 "font: 87 11pt \"Noto Sans\";\n"
 "color: rgb(0, 43, 54);\n"
 "font-weight: 700;\n"
@@ -392,9 +357,7 @@ public:
         label_4->setText(QCoreApplication::translate("ArgDialog", "Add file attachment", nullptr));
         addFile->setText(QCoreApplication::translate("ArgDialog", "Choose", nullptr));
         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));
-        default_args->setText(QCoreApplication::translate("ArgDialog", "Default", nullptr));
         clear->setText(QCoreApplication::translate("ArgDialog", "Clear", nullptr));
     } // retranslateUi