From 0690ef31d1fa7d06325bc7f186590c8633dc0fe6 Mon Sep 17 00:00:00 2001 From: Si Yong Kim Date: Sat, 6 Feb 2021 05:13:57 -0800 Subject: [PATCH 1/2] Add category button on AutomatedRSSDownloader on GUI Closes #7629 --- src/gui/rss/automatedrssdownloader.cpp | 13 +++++++++++++ src/gui/rss/automatedrssdownloader.h | 1 + src/gui/rss/automatedrssdownloader.ui | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index bd062997e..ddcc8fe7f 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -50,6 +50,7 @@ #include "base/utils/fs.h" #include "base/utils/string.h" #include "gui/autoexpandabledialog.h" +#include "gui/torrentcategorydialog.h" #include "gui/uithememanager.h" #include "gui/utils.h" #include "ui_automatedrssdownloader.h" @@ -68,6 +69,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) // Icons m_ui->removeRuleBtn->setIcon(UIThemeManager::instance()->getIcon("list-remove")); m_ui->addRuleBtn->setIcon(UIThemeManager::instance()->getIcon("list-add")); + m_ui->addCategoryBtn->setIcon(UIThemeManager::instance()->getIcon("list-add")); // Ui Settings m_ui->listRules->setSortingEnabled(true); @@ -405,6 +407,17 @@ void AutomatedRssDownloader::on_removeRuleBtn_clicked() RSS::AutoDownloader::instance()->removeRule(item->text()); } +void AutomatedRssDownloader::on_addCategoryBtn_clicked() +{ + const QString newCategoryName = TorrentCategoryDialog::createCategory(this); + + if (!newCategoryName.isEmpty()) + { + m_ui->comboCategory->addItem(newCategoryName); + m_ui->comboCategory->setCurrentText(newCategoryName); + } +} + void AutomatedRssDownloader::on_exportBtn_clicked() { if (RSS::AutoDownloader::instance()->rules().isEmpty()) diff --git a/src/gui/rss/automatedrssdownloader.h b/src/gui/rss/automatedrssdownloader.h index 9a964ee4d..f2fabbd72 100644 --- a/src/gui/rss/automatedrssdownloader.h +++ b/src/gui/rss/automatedrssdownloader.h @@ -61,6 +61,7 @@ public: private slots: void on_addRuleBtn_clicked(); void on_removeRuleBtn_clicked(); + void on_addCategoryBtn_clicked(); void on_exportBtn_clicked(); void on_importBtn_clicked(); diff --git a/src/gui/rss/automatedrssdownloader.ui b/src/gui/rss/automatedrssdownloader.ui index b17c71bbc..e80e2e800 100644 --- a/src/gui/rss/automatedrssdownloader.ui +++ b/src/gui/rss/automatedrssdownloader.ui @@ -209,7 +209,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also - Assign Category: + Category: @@ -220,6 +220,9 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also + + + From 0d0d0a7c237a2c16c39c458ad1d7f8afa22e0797 Mon Sep 17 00:00:00 2001 From: Si Yong Kim Date: Sat, 6 Feb 2021 11:48:13 -0800 Subject: [PATCH 2/2] Add empty name error handling on new category dialog --- src/gui/torrentcategorydialog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/torrentcategorydialog.cpp b/src/gui/torrentcategorydialog.cpp index d3ce24519..076776d05 100644 --- a/src/gui/torrentcategorydialog.cpp +++ b/src/gui/torrentcategorydialog.cpp @@ -29,6 +29,7 @@ #include "torrentcategorydialog.h" #include +#include #include "base/bittorrent/session.h" #include "ui_torrentcategorydialog.h" @@ -40,6 +41,13 @@ TorrentCategoryDialog::TorrentCategoryDialog(QWidget *parent) m_ui->setupUi(this); m_ui->comboSavePath->setMode(FileSystemPathEdit::Mode::DirectorySave); m_ui->comboSavePath->setDialogCaption(tr("Choose save path")); + + // disable save button + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + connect(m_ui->textCategoryName, &QLineEdit::textChanged, this, [this](const QString &text) + { + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); + }); } TorrentCategoryDialog::~TorrentCategoryDialog()