From d019fccceb470f2e1f60dd39e7096d281484a8cf Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 7 Jan 2021 07:53:38 +0100 Subject: [PATCH] Better UX add adblock add sub dialog. --- .../adblock/adblockaddsubscriptiondialog.cpp | 23 ++++++++------- .../adblock/adblockaddsubscriptiondialog.ui | 29 +++++++++---------- .../network-web/adblock/adblocktreewidget.cpp | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.cpp b/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.cpp index 6cbee418c..83ed5149a 100644 --- a/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.cpp +++ b/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.cpp @@ -20,12 +20,10 @@ #include "network-web/adblock/adblockaddsubscriptiondialog.h" #include "definitions/definitions.h" +#include "gui/guiutilities.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" -#include -#include - AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::AdBlockAddSubscriptionDialog) { m_ui->setupUi(this); @@ -55,13 +53,15 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent) m_ui->m_cmbPresets->addItem(subscription.m_title); } - connect(m_ui->m_cmbPresets, static_cast(&QComboBox::currentIndexChanged), this, - &AdBlockAddSubscriptionDialog::indexChanged); - connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, &AdBlockAddSubscriptionDialog::presetsEnabledChanged); + connect(m_ui->m_cmbPresets, static_cast(&QComboBox::currentIndexChanged), + this, &AdBlockAddSubscriptionDialog::indexChanged); + connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, + &AdBlockAddSubscriptionDialog::presetsEnabledChanged); + m_ui->m_cbUsePredefined->setChecked(true); - indexChanged(0); - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); - setWindowIcon(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)); + GuiUtilities::applyDialogProperties(*this, + qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE), + tr("Add subscription")); } QString AdBlockAddSubscriptionDialog::title() const { @@ -89,13 +89,16 @@ void AdBlockAddSubscriptionDialog::indexChanged(int index) { void AdBlockAddSubscriptionDialog::presetsEnabledChanged(bool enabled) { m_ui->m_txtTitle->setEnabled(!enabled); m_ui->m_txtUrl->setEnabled(!enabled); + m_ui->m_cmbPresets->setEnabled(enabled); if (!enabled) { - // Presets are disabled, clear txts. m_ui->m_txtTitle->clear(); m_ui->m_txtUrl->clear(); m_ui->m_txtTitle->setFocus(); } + else { + indexChanged(m_ui->m_cmbPresets->currentIndex()); + } } AdBlockAddSubscriptionDialog::~AdBlockAddSubscriptionDialog() { diff --git a/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.ui b/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.ui index 12ca7870e..592f5eb61 100644 --- a/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.ui +++ b/src/librssguard/network-web/adblock/adblockaddsubscriptiondialog.ui @@ -6,13 +6,10 @@ 0 0 - 557 + 440 145 - - Add subscription - @@ -69,16 +66,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -92,6 +79,16 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + @@ -103,7 +100,7 @@ - buttonBox + m_buttonBox accepted() AdBlockAddSubscriptionDialog accept() @@ -119,7 +116,7 @@ - buttonBox + m_buttonBox rejected() AdBlockAddSubscriptionDialog reject() diff --git a/src/librssguard/network-web/adblock/adblocktreewidget.cpp b/src/librssguard/network-web/adblock/adblocktreewidget.cpp index f0aa50bd0..cddc43ba4 100644 --- a/src/librssguard/network-web/adblock/adblocktreewidget.cpp +++ b/src/librssguard/network-web/adblock/adblocktreewidget.cpp @@ -36,7 +36,7 @@ AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* setLayoutDirection(Qt::LeftToRight); setIndentation(5); - connect(this, &AdBlockTreeWidget::customContextMenuRequested, this, &AdBlockTreeWidget::contextMenuRequested); + connect(this, &QWidget::customContextMenuRequested, this, &AdBlockTreeWidget::contextMenuRequested); connect(this, &AdBlockTreeWidget::itemChanged, this, &AdBlockTreeWidget::itemChanged); connect(m_subscription, &AdBlockSubscription::subscriptionUpdated, this, &AdBlockTreeWidget::subscriptionUpdated); connect(m_subscription, &AdBlockSubscription::subscriptionError, this, &AdBlockTreeWidget::subscriptionError);