Add "Rename rule" button to RSS Downloader

PR #18141.
This commit is contained in:
BallsOfSpaghetti 2022-12-11 09:18:40 +01:00 committed by GitHub
parent d2e595aac3
commit c3936cd4b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View file

@ -75,6 +75,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
// Icons // Icons
m_ui->renameRuleBtn->setIcon(UIThemeManager::instance()->getIcon(u"edit-rename"_qs));
m_ui->removeRuleBtn->setIcon(UIThemeManager::instance()->getIcon(u"edit-clear"_qs)); m_ui->removeRuleBtn->setIcon(UIThemeManager::instance()->getIcon(u"edit-clear"_qs));
m_ui->addRuleBtn->setIcon(UIThemeManager::instance()->getIcon(u"list-add"_qs)); m_ui->addRuleBtn->setIcon(UIThemeManager::instance()->getIcon(u"list-add"_qs));
m_ui->addCategoryBtn->setIcon(UIThemeManager::instance()->getIcon(u"list-add"_qs)); m_ui->addCategoryBtn->setIcon(UIThemeManager::instance()->getIcon(u"list-add"_qs));
@ -250,6 +251,13 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
{ {
const QList<QListWidgetItem *> selection = m_ui->listRules->selectedItems(); const QList<QListWidgetItem *> selection = m_ui->listRules->selectedItems();
QListWidgetItem *currentRuleItem = ((selection.count() == 1) ? selection.first() : nullptr); QListWidgetItem *currentRuleItem = ((selection.count() == 1) ? selection.first() : nullptr);
// Enable the edit rule button but only if we have 1 rule selected
if (selection.count() == 1)
m_ui->renameRuleBtn->setEnabled(true);
else
m_ui->renameRuleBtn->setEnabled(false);
if (m_currentRuleItem != currentRuleItem) if (m_currentRuleItem != currentRuleItem)
{ {
saveEditedRule(); // Save previous rule first saveEditedRule(); // Save previous rule first
@ -427,6 +435,11 @@ void AutomatedRssDownloader::on_addCategoryBtn_clicked()
} }
} }
void AutomatedRssDownloader::on_renameRuleBtn_clicked()
{
renameSelectedRule();
}
void AutomatedRssDownloader::on_exportBtn_clicked() void AutomatedRssDownloader::on_exportBtn_clicked()
{ {
if (RSS::AutoDownloader::instance()->rules().isEmpty()) if (RSS::AutoDownloader::instance()->rules().isEmpty())

View file

@ -66,6 +66,7 @@ private slots:
void on_addCategoryBtn_clicked(); void on_addCategoryBtn_clicked();
void on_exportBtn_clicked(); void on_exportBtn_clicked();
void on_importBtn_clicked(); void on_importBtn_clicked();
void on_renameRuleBtn_clicked();
void handleRuleCheckStateChange(QListWidgetItem *ruleItem); void handleRuleCheckStateChange(QListWidgetItem *ruleItem);
void handleFeedCheckStateChange(QListWidgetItem *feedItem); void handleFeedCheckStateChange(QListWidgetItem *feedItem);

View file

@ -60,6 +60,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="renameRuleBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Rename selected rule. You can also use the F2 hotkey to rename.</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="removeRuleBtn"> <widget class="QToolButton" name="removeRuleBtn">
<property name="iconSize"> <property name="iconSize">
@ -466,6 +482,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>renameRuleBtn</tabstop>
<tabstop>removeRuleBtn</tabstop> <tabstop>removeRuleBtn</tabstop>
<tabstop>addRuleBtn</tabstop> <tabstop>addRuleBtn</tabstop>
<tabstop>listRules</tabstop> <tabstop>listRules</tabstop>