From 7d709dcc819e6450bf004c89ca7382850b32e1bb Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 18 Mar 2024 11:47:11 +0100 Subject: [PATCH] do not require path to UI_ files --- src/librssguard-standard/CMakeLists.txt | 31 +----- .../src/gui/formeditstandardaccount.cpp | 2 + .../src/gui/formeditstandardaccount.h | 1 + .../src/gui/formstandardfeeddetails.cpp | 31 +++--- .../gui/reusable/networkproxydetails.cpp | 58 +++++------ .../gui/reusable/networkproxydetails.h | 11 ++- .../services/abstract/gui/accountdetails.cpp | 8 +- .../services/abstract/gui/accountdetails.h | 5 +- .../abstract/gui/authenticationdetails.cpp | 83 ++++++++++------ .../abstract/gui/authenticationdetails.h | 18 +++- .../abstract/gui/formaccountdetails.cpp | 31 +++--- .../abstract/gui/formaccountdetails.h | 9 +- .../abstract/gui/formcategorydetails.cpp | 2 + .../abstract/gui/formcategorydetails.h | 2 - .../services/abstract/gui/formfeeddetails.cpp | 96 ++++++++++--------- .../services/abstract/gui/formfeeddetails.h | 10 +- .../tt-rss/gui/formttrssfeeddetails.cpp | 4 +- 17 files changed, 223 insertions(+), 179 deletions(-) diff --git a/src/librssguard-standard/CMakeLists.txt b/src/librssguard-standard/CMakeLists.txt index aef9e8b33..316253c0c 100644 --- a/src/librssguard-standard/CMakeLists.txt +++ b/src/librssguard-standard/CMakeLists.txt @@ -1,5 +1,8 @@ -set(LIBRSSGUARD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../librssguard") -set(LIBRSSGUARD_BINARY_PATH "${CMAKE_BINARY_DIR}/src/librssguard") +if(NOT DEFINED LIBRSSGUARD_BINARY_PATH) + set(LIBRSSGUARD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../librssguard") +endif() + +#set(LIBRSSGUARD_BINARY_PATH "${CMAKE_BINARY_DIR}/src/librssguard") set(SOURCES src/definitions.h @@ -48,17 +51,6 @@ set(UI_FILES src/gui/standardfeeddetails.ui ) -# Add mimesis. -list(APPEND SOURCES - ${LIBRSSGUARD_SOURCE_PATH}/3rd-party/mimesis/mimesis.hpp - ${LIBRSSGUARD_SOURCE_PATH}/3rd-party/mimesis/quoted-printable.hpp -) - -# Add boolinq. -list(APPEND SOURCES - ${LIBRSSGUARD_SOURCE_PATH}/3rd-party/boolinq/boolinq.h -) - # Deal with .ui files. qt_wrap_ui(SOURCES ${UI_FILES}) @@ -81,7 +73,6 @@ target_include_directories(rssguard-standard PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${LIBRSSGUARD_SOURCE_PATH} - ${LIBRSSGUARD_BINARY_PATH} ) # Qt. @@ -103,18 +94,6 @@ if(QT_VERSION_MAJOR EQUAL 6) ) endif() -if(WIN32) - target_link_libraries(rssguard-standard PUBLIC - Qt${QT_VERSION_MAJOR}::GuiPrivate - ) -endif() - -#if(NO_LITE) -# target_link_libraries(rssguard-standard PUBLIC -# Qt${QT_VERSION_MAJOR}::WebEngineWidgets -# ) -#endif() - if(WIN32 OR OS2) install(TARGETS rssguard-standard DESTINATION plugins) elseif(UNIX AND NOT APPLE AND NOT ANDROID) diff --git a/src/librssguard-standard/src/gui/formeditstandardaccount.cpp b/src/librssguard-standard/src/gui/formeditstandardaccount.cpp index 54ebafac2..a53fb1652 100644 --- a/src/librssguard-standard/src/gui/formeditstandardaccount.cpp +++ b/src/librssguard-standard/src/gui/formeditstandardaccount.cpp @@ -14,6 +14,8 @@ FormEditStandardAccount::FormEditStandardAccount(QWidget* parent) activateTab(0); } +FormEditStandardAccount::~FormEditStandardAccount() = default; + void FormEditStandardAccount::loadAccountData() { FormAccountDetails::loadAccountData(); diff --git a/src/librssguard-standard/src/gui/formeditstandardaccount.h b/src/librssguard-standard/src/gui/formeditstandardaccount.h index 8acfa7306..98d905dcd 100644 --- a/src/librssguard-standard/src/gui/formeditstandardaccount.h +++ b/src/librssguard-standard/src/gui/formeditstandardaccount.h @@ -12,6 +12,7 @@ class FormEditStandardAccount : public FormAccountDetails { public: explicit FormEditStandardAccount(QWidget* parent = nullptr); + virtual ~FormEditStandardAccount(); protected: virtual void loadAccountData(); diff --git a/src/librssguard-standard/src/gui/formstandardfeeddetails.cpp b/src/librssguard-standard/src/gui/formstandardfeeddetails.cpp index 42aa5e9ae..2cf0701c3 100644 --- a/src/librssguard-standard/src/gui/formstandardfeeddetails.cpp +++ b/src/librssguard-standard/src/gui/formstandardfeeddetails.cpp @@ -13,7 +13,10 @@ #include "src/gui/standardfeeddetails.h" #include "src/standardfeed.h" +#include +#include #include +#include #include FormStandardFeedDetails::FormStandardFeedDetails(ServiceRoot* service_root, @@ -44,8 +47,8 @@ void FormStandardFeedDetails::guessFeed() { m_standardFeedDetails->m_ui.m_txtSource->textEdit()->toPlainText(), m_standardFeedDetails->m_ui.m_txtPostProcessScript->textEdit()->toPlainText(), m_authDetails->authenticationType(), - m_authDetails->m_txtUsername->lineEdit()->text(), - m_authDetails->m_txtPassword->lineEdit()->text(), + m_authDetails->username(), + m_authDetails->password(), m_serviceRoot->networkProxy()); } @@ -54,13 +57,13 @@ void FormStandardFeedDetails::guessIconOnly() { m_standardFeedDetails->m_ui.m_txtSource->textEdit()->toPlainText(), m_standardFeedDetails->m_ui.m_txtPostProcessScript->textEdit()->toPlainText(), m_authDetails->authenticationType(), - m_authDetails->m_txtUsername->lineEdit()->text(), - m_authDetails->m_txtPassword->lineEdit()->text(), + m_authDetails->username(), + m_authDetails->password(), m_serviceRoot->networkProxy()); } void FormStandardFeedDetails::onTitleChanged(const QString& title) { - m_ui.m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(!title.simplified().isEmpty()); + buttonBox()->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(!title.simplified().isEmpty()); } void FormStandardFeedDetails::apply() { @@ -109,13 +112,13 @@ void FormStandardFeedDetails::apply() { std_feed->setPostProcessScript(m_standardFeedDetails->m_ui.m_txtPostProcessScript->textEdit()->toPlainText()); } - if (isChangeAllowed(m_authDetails->m_mcbAuthType)) { + if (isChangeAllowed(m_authDetails->findChild(QSL("m_mcbAuthType")))) { std_feed->setProtection(m_authDetails->authenticationType()); } - if (isChangeAllowed(m_authDetails->m_mcbAuthentication)) { - std_feed->setUsername(m_authDetails->m_txtUsername->lineEdit()->text()); - std_feed->setPassword(m_authDetails->m_txtPassword->lineEdit()->text()); + if (isChangeAllowed(m_authDetails->findChild(QSL("m_mcbAuthentication")))) { + std_feed->setUsername(m_authDetails->username()); + std_feed->setPassword(m_authDetails->password()); } std_feed->setCreationDate(QDateTime::currentDateTime()); @@ -161,8 +164,10 @@ void FormStandardFeedDetails::loadFeedData() { m_standardFeedDetails->m_ui.m_mcbType->addActionWidget(m_standardFeedDetails->m_ui.m_cmbType); m_standardFeedDetails->m_ui.m_mcbEncoding->addActionWidget(m_standardFeedDetails->m_ui.m_cmbEncoding); - m_authDetails->m_mcbAuthType->addActionWidget(m_authDetails->m_cbAuthType); - m_authDetails->m_mcbAuthentication->addActionWidget(m_authDetails->m_gbAuthentication); + m_authDetails->findChild(QSL("m_mcbAuthType")) + ->addActionWidget(m_authDetails->findChild(QSL("m_cbAuthType"))); + m_authDetails->findChild(QSL("m_mcbAuthentication")) + ->addActionWidget(m_authDetails->findChild(QSL("m_gbAuthentication"))); m_standardFeedDetails->m_ui.m_btnFetchMetadata->setEnabled(false); } @@ -179,8 +184,8 @@ void FormStandardFeedDetails::loadFeedData() { m_standardFeedDetails->loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot); m_authDetails->setAuthenticationType(std_feed->protection()); - m_authDetails->m_txtUsername->lineEdit()->setText(std_feed->username()); - m_authDetails->m_txtPassword->lineEdit()->setText(std_feed->password()); + m_authDetails->setUsername(std_feed->username()); + m_authDetails->setPassword(std_feed->password()); if (m_creatingNew) { // auto processed_url = qApp->web()->processFeedUriScheme(m_urlToProcess); diff --git a/src/librssguard/gui/reusable/networkproxydetails.cpp b/src/librssguard/gui/reusable/networkproxydetails.cpp index 6e76f4a39..9eb786ee5 100644 --- a/src/librssguard/gui/reusable/networkproxydetails.cpp +++ b/src/librssguard/gui/reusable/networkproxydetails.cpp @@ -2,63 +2,67 @@ #include "gui/reusable/networkproxydetails.h" +#include "ui_networkproxydetails.h" + #include "definitions/definitions.h" #include -NetworkProxyDetails::NetworkProxyDetails(QWidget* parent) : QWidget(parent) { - m_ui.setupUi(this); +NetworkProxyDetails::NetworkProxyDetails(QWidget* parent) : QWidget(parent), m_ui(new Ui::NetworkProxyDetails()) { + m_ui->setupUi(this); - m_ui.m_lblProxyInfo->setHelpText(tr("Note that these settings are applied only on newly established connections."), - false); - m_ui.m_txtProxyPassword->setPasswordMode(true); + m_ui->m_lblProxyInfo->setHelpText(tr("Note that these settings are applied only on newly established connections."), + false); + m_ui->m_txtProxyPassword->setPasswordMode(true); - connect(m_ui.m_cmbProxyType, + connect(m_ui->m_cmbProxyType, static_cast(&QComboBox::currentIndexChanged), this, &NetworkProxyDetails::onProxyTypeChanged); - m_ui.m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::ProxyType::NoProxy); - m_ui.m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::ProxyType::DefaultProxy); - m_ui.m_cmbProxyType->addItem(QSL("Socks5"), QNetworkProxy::ProxyType::Socks5Proxy); - m_ui.m_cmbProxyType->addItem(QSL("Http"), QNetworkProxy::ProxyType::HttpProxy); + m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::ProxyType::NoProxy); + m_ui->m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::ProxyType::DefaultProxy); + m_ui->m_cmbProxyType->addItem(QSL("Socks5"), QNetworkProxy::ProxyType::Socks5Proxy); + m_ui->m_cmbProxyType->addItem(QSL("Http"), QNetworkProxy::ProxyType::HttpProxy); - connect(m_ui.m_cmbProxyType, + connect(m_ui->m_cmbProxyType, static_cast(&QComboBox::currentIndexChanged), this, &NetworkProxyDetails::changed); - connect(m_ui.m_txtProxyHost, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); - connect(m_ui.m_txtProxyPassword, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); - connect(m_ui.m_txtProxyUsername, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); - connect(m_ui.m_spinProxyPort, + connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); + connect(m_ui->m_txtProxyPassword, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); + connect(m_ui->m_txtProxyUsername, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed); + connect(m_ui->m_spinProxyPort, static_cast(&QSpinBox::valueChanged), this, &NetworkProxyDetails::changed); } +NetworkProxyDetails::~NetworkProxyDetails() = default; + QNetworkProxy NetworkProxyDetails::proxy() const { - QNetworkProxy proxy(static_cast(m_ui.m_cmbProxyType->currentData().toInt()), - m_ui.m_txtProxyHost->text(), - m_ui.m_spinProxyPort->value(), - m_ui.m_txtProxyUsername->text(), - m_ui.m_txtProxyPassword->text()); + QNetworkProxy proxy(static_cast(m_ui->m_cmbProxyType->currentData().toInt()), + m_ui->m_txtProxyHost->text(), + m_ui->m_spinProxyPort->value(), + m_ui->m_txtProxyUsername->text(), + m_ui->m_txtProxyPassword->text()); return proxy; } void NetworkProxyDetails::setProxy(const QNetworkProxy& proxy) { - m_ui.m_cmbProxyType->setCurrentIndex(m_ui.m_cmbProxyType->findData(proxy.type())); - m_ui.m_txtProxyHost->setText(proxy.hostName()); - m_ui.m_spinProxyPort->setValue(proxy.port()); - m_ui.m_txtProxyUsername->setText(proxy.user()); - m_ui.m_txtProxyPassword->setText(proxy.password()); + m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(proxy.type())); + m_ui->m_txtProxyHost->setText(proxy.hostName()); + m_ui->m_spinProxyPort->setValue(proxy.port()); + m_ui->m_txtProxyUsername->setText(proxy.user()); + m_ui->m_txtProxyPassword->setText(proxy.password()); } void NetworkProxyDetails::onProxyTypeChanged(int index) { const QNetworkProxy::ProxyType selected_type = - static_cast(m_ui.m_cmbProxyType->itemData(index).toInt()); + static_cast(m_ui->m_cmbProxyType->itemData(index).toInt()); const bool is_proxy_selected = selected_type != QNetworkProxy::ProxyType::NoProxy && selected_type != QNetworkProxy::ProxyType::DefaultProxy; - m_ui.m_proxyDetails->setEnabled(is_proxy_selected); + m_ui->m_proxyDetails->setEnabled(is_proxy_selected); } diff --git a/src/librssguard/gui/reusable/networkproxydetails.h b/src/librssguard/gui/reusable/networkproxydetails.h index a790627a3..f5e017066 100644 --- a/src/librssguard/gui/reusable/networkproxydetails.h +++ b/src/librssguard/gui/reusable/networkproxydetails.h @@ -5,15 +5,18 @@ #include -#include "ui_networkproxydetails.h" - #include +namespace Ui { + class NetworkProxyDetails; +} + class NetworkProxyDetails : public QWidget { - Q_OBJECT + Q_OBJECT public: explicit NetworkProxyDetails(QWidget* parent = nullptr); + virtual ~NetworkProxyDetails(); QNetworkProxy proxy() const; void setProxy(const QNetworkProxy& proxy); @@ -25,7 +28,7 @@ class NetworkProxyDetails : public QWidget { void onProxyTypeChanged(int index); private: - Ui::NetworkProxyDetails m_ui; + QScopedPointer m_ui; }; #endif // NETWORKPROXYDETAILS_H diff --git a/src/librssguard/services/abstract/gui/accountdetails.cpp b/src/librssguard/services/abstract/gui/accountdetails.cpp index cb5b4c6a6..1374278d5 100644 --- a/src/librssguard/services/abstract/gui/accountdetails.cpp +++ b/src/librssguard/services/abstract/gui/accountdetails.cpp @@ -2,6 +2,10 @@ #include "services/abstract/gui/accountdetails.h" -AccountDetails::AccountDetails(QWidget* parent) : QWidget(parent) { - m_ui.setupUi(this); +#include "ui_accountdetails.h" + +AccountDetails::AccountDetails(QWidget* parent) : QWidget(parent), m_ui(new Ui::AccountDetails()) { + m_ui->setupUi(this); } + +AccountDetails::~AccountDetails() = default; diff --git a/src/librssguard/services/abstract/gui/accountdetails.h b/src/librssguard/services/abstract/gui/accountdetails.h index e88a58fbd..96e995da4 100644 --- a/src/librssguard/services/abstract/gui/accountdetails.h +++ b/src/librssguard/services/abstract/gui/accountdetails.h @@ -5,8 +5,6 @@ #include -#include "ui_accountdetails.h" - namespace Ui { class AccountDetails; } @@ -18,9 +16,10 @@ class RSSGUARD_DLLSPEC AccountDetails : public QWidget { public: explicit AccountDetails(QWidget* parent = nullptr); + virtual ~AccountDetails(); private: - Ui::AccountDetails m_ui; + QScopedPointer m_ui; }; #endif // ACCOUNTDETAILS_H diff --git a/src/librssguard/services/abstract/gui/authenticationdetails.cpp b/src/librssguard/services/abstract/gui/authenticationdetails.cpp index 8ac1ea07a..78ef2db50 100644 --- a/src/librssguard/services/abstract/gui/authenticationdetails.cpp +++ b/src/librssguard/services/abstract/gui/authenticationdetails.cpp @@ -2,29 +2,32 @@ #include "services/abstract/gui/authenticationdetails.h" +#include "ui_authenticationdetails.h" + #include "definitions/definitions.h" -AuthenticationDetails::AuthenticationDetails(bool only_basic, QWidget* parent) : QWidget(parent) { - setupUi(this); +AuthenticationDetails::AuthenticationDetails(bool only_basic, QWidget* parent) + : QWidget(parent), m_ui(new Ui::AuthenticationDetails()) { + m_ui->setupUi(this); // Set text boxes. - m_txtPassword->lineEdit()->setPasswordMode(true); - m_txtUsername->lineEdit()->setPlaceholderText(tr("Username")); - m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed.")); - m_txtPassword->lineEdit()->setPlaceholderText(tr("Password")); - m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed.")); + m_ui->m_txtPassword->lineEdit()->setPasswordMode(true); + m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username")); + m_ui->m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed.")); + m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password")); + m_ui->m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed.")); - m_cbAuthType->addItem(tr("No authentication"), - QVariant::fromValue(NetworkFactory::NetworkAuthentication::NoAuthentication)); - m_cbAuthType->addItem(tr("HTTP Basic"), QVariant::fromValue(NetworkFactory::NetworkAuthentication::Basic)); + m_ui->m_cbAuthType->addItem(tr("No authentication"), + QVariant::fromValue(NetworkFactory::NetworkAuthentication::NoAuthentication)); + m_ui->m_cbAuthType->addItem(tr("HTTP Basic"), QVariant::fromValue(NetworkFactory::NetworkAuthentication::Basic)); if (!only_basic) { - m_cbAuthType->addItem(tr("Token"), QVariant::fromValue(NetworkFactory::NetworkAuthentication::Token)); + m_ui->m_cbAuthType->addItem(tr("Token"), QVariant::fromValue(NetworkFactory::NetworkAuthentication::Token)); } - connect(m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged); - connect(m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged); - connect(m_cbAuthType, + connect(m_ui->m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged); + connect(m_ui->m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged); + connect(m_ui->m_cbAuthType, QOverload::of(&QComboBox::currentIndexChanged), this, &AuthenticationDetails::onAuthenticationSwitched); @@ -32,52 +35,70 @@ AuthenticationDetails::AuthenticationDetails(bool only_basic, QWidget* parent) : onAuthenticationSwitched(); } +QString AuthenticationDetails::username() const { + return m_ui->m_txtUsername->lineEdit()->text(); +} + +void AuthenticationDetails::setUsername(const QString& username) { + m_ui->m_txtUsername->lineEdit()->setText(username); +} + +QString AuthenticationDetails::password() const { + return m_ui->m_txtPassword->lineEdit()->text(); +} + +void AuthenticationDetails::setPassword(const QString& password) { + m_ui->m_txtPassword->lineEdit()->setText(password); +} + +AuthenticationDetails::~AuthenticationDetails() = default; + void AuthenticationDetails::setAuthenticationType(NetworkFactory::NetworkAuthentication protect) { - auto fnd = m_cbAuthType->findData(QVariant::fromValue(protect)); + auto fnd = m_ui->m_cbAuthType->findData(QVariant::fromValue(protect)); if (fnd >= 0) { - m_cbAuthType->setCurrentIndex(fnd); + m_ui->m_cbAuthType->setCurrentIndex(fnd); } } NetworkFactory::NetworkFactory::NetworkAuthentication AuthenticationDetails::authenticationType() const { - return m_cbAuthType->currentData().value(); + return m_ui->m_cbAuthType->currentData().value(); } void AuthenticationDetails::onUsernameChanged(const QString& new_username) { bool is_username_ok = authenticationType() == NetworkFactory::NetworkAuthentication::NoAuthentication || !new_username.simplified().isEmpty(); - m_txtUsername->setStatus(is_username_ok ? LineEditWithStatus::StatusType::Ok - : LineEditWithStatus::StatusType::Warning, - is_username_ok ? tr("Username/token is ok or it is not needed.") - : tr("Username/token is empty.")); + m_ui->m_txtUsername->setStatus(is_username_ok ? LineEditWithStatus::StatusType::Ok + : LineEditWithStatus::StatusType::Warning, + is_username_ok ? tr("Username/token is ok or it is not needed.") + : tr("Username/token is empty.")); } void AuthenticationDetails::onPasswordChanged(const QString& new_password) { bool is_password_ok = authenticationType() == NetworkFactory::NetworkAuthentication::NoAuthentication || !new_password.simplified().isEmpty(); - m_txtPassword->setStatus(is_password_ok ? LineEditWithStatus::StatusType::Ok - : LineEditWithStatus::StatusType::Warning, - is_password_ok ? tr("Password is ok or it is not needed.") : tr("Password is empty.")); + m_ui->m_txtPassword->setStatus(is_password_ok ? LineEditWithStatus::StatusType::Ok + : LineEditWithStatus::StatusType::Warning, + is_password_ok ? tr("Password is ok or it is not needed.") : tr("Password is empty.")); } void AuthenticationDetails::onAuthenticationSwitched() { - onUsernameChanged(m_txtUsername->lineEdit()->text()); - onPasswordChanged(m_txtPassword->lineEdit()->text()); + onUsernameChanged(m_ui->m_txtUsername->lineEdit()->text()); + onPasswordChanged(m_ui->m_txtPassword->lineEdit()->text()); auto prot = authenticationType(); - m_lblPassword->setVisible(prot != NetworkFactory::NetworkAuthentication::Token); - m_txtPassword->setVisible(prot != NetworkFactory::NetworkAuthentication::Token); + m_ui->m_lblPassword->setVisible(prot != NetworkFactory::NetworkAuthentication::Token); + m_ui->m_txtPassword->setVisible(prot != NetworkFactory::NetworkAuthentication::Token); if (prot == NetworkFactory::NetworkAuthentication::Token) { - m_lblUsername->setText(tr("Access token")); + m_ui->m_lblUsername->setText(tr("Access token")); } else { - m_lblUsername->setText(tr("Username")); + m_ui->m_lblUsername->setText(tr("Username")); } - m_gbAuthentication->setEnabled(prot != NetworkFactory::NetworkAuthentication::NoAuthentication); + m_ui->m_gbAuthentication->setEnabled(prot != NetworkFactory::NetworkAuthentication::NoAuthentication); } diff --git a/src/librssguard/services/abstract/gui/authenticationdetails.h b/src/librssguard/services/abstract/gui/authenticationdetails.h index 181525ea0..1b7ef012c 100644 --- a/src/librssguard/services/abstract/gui/authenticationdetails.h +++ b/src/librssguard/services/abstract/gui/authenticationdetails.h @@ -5,16 +5,25 @@ #include -#include "ui_authenticationdetails.h" - #include "network-web/networkfactory.h" #include "services/abstract/feed.h" -class RSSGUARD_DLLSPEC AuthenticationDetails : public QWidget, public Ui::AuthenticationDetails { +namespace Ui { + class AuthenticationDetails; +} + +class RSSGUARD_DLLSPEC AuthenticationDetails : public QWidget { Q_OBJECT public: explicit AuthenticationDetails(bool only_basic, QWidget* parent = nullptr); + virtual ~AuthenticationDetails(); + + QString username() const; + void setUsername(const QString& username); + + QString password() const; + void setPassword(const QString& password); void setAuthenticationType(NetworkFactory::NetworkFactory::NetworkAuthentication protect); NetworkFactory::NetworkFactory::NetworkAuthentication authenticationType() const; @@ -23,6 +32,9 @@ class RSSGUARD_DLLSPEC AuthenticationDetails : public QWidget, public Ui::Authen void onUsernameChanged(const QString& new_username); void onPasswordChanged(const QString& new_password); void onAuthenticationSwitched(); + + private: + QScopedPointer m_ui; }; #endif // AUTHENTICATIONDETAILS_H diff --git a/src/librssguard/services/abstract/gui/formaccountdetails.cpp b/src/librssguard/services/abstract/gui/formaccountdetails.cpp index d7d93a404..8e30b18a6 100644 --- a/src/librssguard/services/abstract/gui/formaccountdetails.cpp +++ b/src/librssguard/services/abstract/gui/formaccountdetails.cpp @@ -2,6 +2,7 @@ #include "services/abstract/gui/formaccountdetails.h" +#include "ui_accountdetails.h" #include "ui_formaccountdetails.h" #include "gui/guiutilities.h" @@ -15,8 +16,8 @@ FormAccountDetails::FormAccountDetails(const QIcon& icon, QWidget* parent) : QDialog(parent), m_proxyDetails(new NetworkProxyDetails(this)), m_accountDetails(new AccountDetails(this)), - m_account(nullptr), m_creatingNew(false) { - m_ui.setupUi(this); + m_account(nullptr), m_creatingNew(false), m_ui(new Ui::FormAccountDetails()) { + m_ui->setupUi(this); insertCustomTab(m_accountDetails, tr("Miscellaneous"), 0); insertCustomTab(m_proxyDetails, tr("Network proxy"), 1); @@ -25,11 +26,13 @@ FormAccountDetails::FormAccountDetails(const QIcon& icon, QWidget* parent) createConnections(); } +FormAccountDetails::~FormAccountDetails() = default; + void FormAccountDetails::apply() { - m_account->setNodeShowImportant(m_accountDetails->m_ui.m_cbImportant->isChecked()); - m_account->setNodeShowLabels(m_accountDetails->m_ui.m_cbLabels->isChecked()); - m_account->setNodeShowProbes(m_accountDetails->m_ui.m_cbProbes->isChecked()); - m_account->setNodeShowUnread(m_accountDetails->m_ui.m_cbUnread->isChecked()); + m_account->setNodeShowImportant(m_accountDetails->m_ui->m_cbImportant->isChecked()); + m_account->setNodeShowLabels(m_accountDetails->m_ui->m_cbLabels->isChecked()); + m_account->setNodeShowProbes(m_accountDetails->m_ui->m_cbProbes->isChecked()); + m_account->setNodeShowUnread(m_accountDetails->m_ui->m_cbUnread->isChecked()); m_account->setNetworkProxy(m_proxyDetails->proxy()); @@ -42,15 +45,15 @@ void FormAccountDetails::apply() { } void FormAccountDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) { - m_ui.m_tabWidget->insertTab(index, custom_tab, title); + m_ui->m_tabWidget->insertTab(index, custom_tab, title); } void FormAccountDetails::activateTab(int index) { - m_ui.m_tabWidget->setCurrentIndex(index); + m_ui->m_tabWidget->setCurrentIndex(index); } void FormAccountDetails::clearTabs() { - m_ui.m_tabWidget->clear(); + m_ui->m_tabWidget->clear(); } void FormAccountDetails::loadAccountData() { @@ -69,14 +72,14 @@ void FormAccountDetails::loadAccountData() { } } - m_accountDetails->m_ui.m_cbImportant->setChecked(m_account->nodeShowImportant()); - m_accountDetails->m_ui.m_cbLabels->setChecked(m_account->nodeShowLabels()); - m_accountDetails->m_ui.m_cbProbes->setChecked(m_account->nodeShowProbes()); - m_accountDetails->m_ui.m_cbUnread->setChecked(m_account->nodeShowUnread()); + m_accountDetails->m_ui->m_cbImportant->setChecked(m_account->nodeShowImportant()); + m_accountDetails->m_ui->m_cbLabels->setChecked(m_account->nodeShowLabels()); + m_accountDetails->m_ui->m_cbProbes->setChecked(m_account->nodeShowProbes()); + m_accountDetails->m_ui->m_cbUnread->setChecked(m_account->nodeShowUnread()); m_proxyDetails->setProxy(m_account->networkProxy()); } void FormAccountDetails::createConnections() { - connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormAccountDetails::apply); + connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &FormAccountDetails::apply); } diff --git a/src/librssguard/services/abstract/gui/formaccountdetails.h b/src/librssguard/services/abstract/gui/formaccountdetails.h index 2a5a55c6e..ac492a078 100644 --- a/src/librssguard/services/abstract/gui/formaccountdetails.h +++ b/src/librssguard/services/abstract/gui/formaccountdetails.h @@ -5,14 +5,16 @@ #include -#include "ui_formaccountdetails.h" - #include "database/databasefactory.h" #include "database/databasequeries.h" #include "gui/reusable/networkproxydetails.h" #include "miscellaneous/application.h" #include "services/abstract/gui/accountdetails.h" +namespace Ui { + class FormAccountDetails; +} + class ServiceRoot; class RSSGUARD_DLLSPEC FormAccountDetails : public QDialog { @@ -20,6 +22,7 @@ class RSSGUARD_DLLSPEC FormAccountDetails : public QDialog { public: explicit FormAccountDetails(const QIcon& icon, QWidget* parent = nullptr); + virtual ~FormAccountDetails(); template T* addEditAccount(T* account_to_edit = nullptr); @@ -48,7 +51,7 @@ class RSSGUARD_DLLSPEC FormAccountDetails : public QDialog { void createConnections(); protected: - Ui::FormAccountDetails m_ui; + QScopedPointer m_ui; NetworkProxyDetails* m_proxyDetails; AccountDetails* m_accountDetails; ServiceRoot* m_account; diff --git a/src/librssguard/services/abstract/gui/formcategorydetails.cpp b/src/librssguard/services/abstract/gui/formcategorydetails.cpp index 61216b752..9c42d1f79 100644 --- a/src/librssguard/services/abstract/gui/formcategorydetails.cpp +++ b/src/librssguard/services/abstract/gui/formcategorydetails.cpp @@ -2,6 +2,8 @@ #include "services/abstract/gui/formcategorydetails.h" +#include "ui_formcategorydetails.h" + #include "3rd-party/boolinq/boolinq.h" #include "database/databasequeries.h" #include "definitions/definitions.h" diff --git a/src/librssguard/services/abstract/gui/formcategorydetails.h b/src/librssguard/services/abstract/gui/formcategorydetails.h index d698ab243..8251161f3 100644 --- a/src/librssguard/services/abstract/gui/formcategorydetails.h +++ b/src/librssguard/services/abstract/gui/formcategorydetails.h @@ -3,8 +3,6 @@ #ifndef FORMCATEGORYDETAILS_H #define FORMCATEGORYDETAILS_H -#include "ui_formcategorydetails.h" - #include #include "3rd-party/boolinq/boolinq.h" diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index 0567f76b7..426468225 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -20,21 +20,23 @@ #include FormFeedDetails::FormFeedDetails(ServiceRoot* service_root, QWidget* parent) - : QDialog(parent), m_serviceRoot(service_root) { + : QDialog(parent), m_ui(new Ui::FormFeedDetails()), m_serviceRoot(service_root) { initialize(); createConnections(); } +FormFeedDetails::~FormFeedDetails() = default; + void FormFeedDetails::activateTab(int index) { - m_ui.m_tabWidget->setCurrentIndex(index); + m_ui->m_tabWidget->setCurrentIndex(index); } void FormFeedDetails::clearTabs() { - m_ui.m_tabWidget->clear(); + m_ui->m_tabWidget->clear(); } void FormFeedDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) { - m_ui.m_tabWidget->insertTab(index, custom_tab, title); + m_ui->m_tabWidget->insertTab(index, custom_tab, title); } void FormFeedDetails::apply() { @@ -42,29 +44,29 @@ void FormFeedDetails::apply() { for (Feed* fd : fds) { // Setup common data for the feed. - if (isChangeAllowed(m_ui.m_mcbAutoDownloading)) { - fd->setAutoUpdateType(static_cast(m_ui.m_cmbAutoUpdateType - ->itemData(m_ui.m_cmbAutoUpdateType->currentIndex()) + if (isChangeAllowed(m_ui->m_mcbAutoDownloading)) { + fd->setAutoUpdateType(static_cast(m_ui->m_cmbAutoUpdateType + ->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()) .toInt())); - fd->setAutoUpdateInterval(int(m_ui.m_spinAutoUpdateInterval->value())); + fd->setAutoUpdateInterval(int(m_ui->m_spinAutoUpdateInterval->value())); } - if (isChangeAllowed(m_ui.m_mcbOpenArticlesAutomatically)) { - fd->setOpenArticlesDirectly(m_ui.m_cbOpenArticlesAutomatically->isChecked()); + if (isChangeAllowed(m_ui->m_mcbOpenArticlesAutomatically)) { + fd->setOpenArticlesDirectly(m_ui->m_cbOpenArticlesAutomatically->isChecked()); } - if (isChangeAllowed(m_ui.m_mcbFeedRtl)) { - fd->setIsRtl(m_ui.m_cbFeedRTL->isChecked()); + if (isChangeAllowed(m_ui->m_mcbFeedRtl)) { + fd->setIsRtl(m_ui->m_cbFeedRTL->isChecked()); } - m_ui.m_wdgArticleLimiting->saveFeed(fd, m_isBatchEdit); + m_ui->m_wdgArticleLimiting->saveFeed(fd, m_isBatchEdit); - if (isChangeAllowed(m_ui.m_mcbDisableFeed)) { - fd->setIsSwitchedOff(m_ui.m_cbDisableFeed->isChecked()); + if (isChangeAllowed(m_ui->m_mcbDisableFeed)) { + fd->setIsSwitchedOff(m_ui->m_cbDisableFeed->isChecked()); } - if (isChangeAllowed(m_ui.m_mcbSuppressFeed)) { - fd->setIsQuiet(m_ui.m_cbSuppressFeed->isChecked()); + if (isChangeAllowed(m_ui->m_mcbSuppressFeed)) { + fd->setIsQuiet(m_ui->m_cbSuppressFeed->isChecked()); } if (!m_creatingNew) { @@ -80,28 +82,32 @@ void FormFeedDetails::apply() { } } +QDialogButtonBox* FormFeedDetails::buttonBox() const { + return m_ui->m_buttonBox; +} + bool FormFeedDetails::isChangeAllowed(MultiFeedEditCheckBox* mcb) const { return !m_isBatchEdit || mcb->isChecked(); } void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) { Feed::AutoUpdateType auto_update_type = - static_cast(m_ui.m_cmbAutoUpdateType->itemData(new_index).toInt()); + static_cast(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt()); switch (auto_update_type) { case Feed::AutoUpdateType::DontAutoUpdate: case Feed::AutoUpdateType::DefaultAutoUpdate: - m_ui.m_spinAutoUpdateInterval->setEnabled(false); + m_ui->m_spinAutoUpdateInterval->setEnabled(false); break; default: - m_ui.m_spinAutoUpdateInterval->setEnabled(true); + m_ui->m_spinAutoUpdateInterval->setEnabled(true); } } void FormFeedDetails::createConnections() { - connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormFeedDetails::acceptIfPossible); - connect(m_ui.m_cmbAutoUpdateType, + connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &FormFeedDetails::acceptIfPossible); + connect(m_ui->m_cmbAutoUpdateType, static_cast(&QComboBox::currentIndexChanged), this, &FormFeedDetails::onAutoUpdateTypeChanged); @@ -112,11 +118,11 @@ void FormFeedDetails::loadFeedData() { if (m_isBatchEdit) { // We hook batch selectors. - m_ui.m_mcbAutoDownloading->addActionWidget(m_ui.m_wdgAutoUpdate); - m_ui.m_mcbOpenArticlesAutomatically->addActionWidget(m_ui.m_cbOpenArticlesAutomatically); - m_ui.m_mcbDisableFeed->addActionWidget(m_ui.m_cbDisableFeed); - m_ui.m_mcbSuppressFeed->addActionWidget(m_ui.m_cbSuppressFeed); - m_ui.m_mcbFeedRtl->addActionWidget(m_ui.m_cbFeedRTL); + m_ui->m_mcbAutoDownloading->addActionWidget(m_ui->m_wdgAutoUpdate); + m_ui->m_mcbOpenArticlesAutomatically->addActionWidget(m_ui->m_cbOpenArticlesAutomatically); + m_ui->m_mcbDisableFeed->addActionWidget(m_ui->m_cbDisableFeed); + m_ui->m_mcbSuppressFeed->addActionWidget(m_ui->m_cbSuppressFeed); + m_ui->m_mcbFeedRtl->addActionWidget(m_ui->m_cbFeedRTL); } else { // We hide batch selectors. @@ -125,7 +131,7 @@ void FormFeedDetails::loadFeedData() { } } - m_ui.m_wdgArticleLimiting->setForAppWideFeatures(false, m_isBatchEdit); + m_ui->m_wdgArticleLimiting->setForAppWideFeatures(false, m_isBatchEdit); if (m_creatingNew) { GuiUtilities::applyDialogProperties(*this, @@ -143,13 +149,13 @@ void FormFeedDetails::loadFeedData() { } } - m_ui.m_cmbAutoUpdateType - ->setCurrentIndex(m_ui.m_cmbAutoUpdateType->findData(QVariant::fromValue(int(fd->autoUpdateType())))); - m_ui.m_spinAutoUpdateInterval->setValue(fd->autoUpdateInterval()); - m_ui.m_cbOpenArticlesAutomatically->setChecked(fd->openArticlesDirectly()); - m_ui.m_cbFeedRTL->setChecked(fd->isRtl()); - m_ui.m_cbDisableFeed->setChecked(fd->isSwitchedOff()); - m_ui.m_cbSuppressFeed->setChecked(fd->isQuiet()); + m_ui->m_cmbAutoUpdateType + ->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue(int(fd->autoUpdateType())))); + m_ui->m_spinAutoUpdateInterval->setValue(fd->autoUpdateInterval()); + m_ui->m_cbOpenArticlesAutomatically->setChecked(fd->openArticlesDirectly()); + m_ui->m_cbFeedRTL->setChecked(fd->isRtl()); + m_ui->m_cbDisableFeed->setChecked(fd->isSwitchedOff()); + m_ui->m_cbSuppressFeed->setChecked(fd->isQuiet()); Feed::ArticleIgnoreLimit art_limit = Feed::ArticleIgnoreLimit(fd->articleIgnoreLimit()); @@ -166,7 +172,7 @@ void FormFeedDetails::loadFeedData() { art_limit.m_moveToBinDontPurge = false; */ - m_ui.m_wdgArticleLimiting->load(art_limit, true); + m_ui->m_wdgArticleLimiting->load(art_limit, true); } void FormFeedDetails::acceptIfPossible() { @@ -186,15 +192,15 @@ void FormFeedDetails::acceptIfPossible() { } void FormFeedDetails::initialize() { - m_ui.setupUi(this); + m_ui->setupUi(this); // Setup auto-update options. - m_ui.m_spinAutoUpdateInterval->setMode(TimeSpinBox::Mode::MinutesSeconds); - m_ui.m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL); - m_ui.m_cmbAutoUpdateType->addItem(tr("Fetch articles using global interval"), - QVariant::fromValue(int(Feed::AutoUpdateType::DefaultAutoUpdate))); - m_ui.m_cmbAutoUpdateType->addItem(tr("Fetch articles every"), - QVariant::fromValue(int(Feed::AutoUpdateType::SpecificAutoUpdate))); - m_ui.m_cmbAutoUpdateType->addItem(tr("Disable auto-fetching of articles"), - QVariant::fromValue(int(Feed::AutoUpdateType::DontAutoUpdate))); + m_ui->m_spinAutoUpdateInterval->setMode(TimeSpinBox::Mode::MinutesSeconds); + m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL); + m_ui->m_cmbAutoUpdateType->addItem(tr("Fetch articles using global interval"), + QVariant::fromValue(int(Feed::AutoUpdateType::DefaultAutoUpdate))); + m_ui->m_cmbAutoUpdateType->addItem(tr("Fetch articles every"), + QVariant::fromValue(int(Feed::AutoUpdateType::SpecificAutoUpdate))); + m_ui->m_cmbAutoUpdateType->addItem(tr("Disable auto-fetching of articles"), + QVariant::fromValue(int(Feed::AutoUpdateType::DontAutoUpdate))); } diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.h b/src/librssguard/services/abstract/gui/formfeeddetails.h index 60b4ec508..915c24d55 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.h +++ b/src/librssguard/services/abstract/gui/formfeeddetails.h @@ -5,8 +5,6 @@ #include -#include "ui_formfeeddetails.h" - #include "3rd-party/boolinq/boolinq.h" #include "definitions/definitions.h" @@ -18,13 +16,15 @@ class ServiceRoot; class Feed; class Category; class RootItem; +class QDialogButtonBox; +class MultiFeedEditCheckBox; class RSSGUARD_DLLSPEC FormFeedDetails : public QDialog { Q_OBJECT public: explicit FormFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr); - virtual ~FormFeedDetails() = default; + virtual ~FormFeedDetails(); template QList addEditFeed(const QList& feeds_to_edit = {}); @@ -47,6 +47,8 @@ class RSSGUARD_DLLSPEC FormFeedDetails : public QDialog { virtual void apply(); protected: + QDialogButtonBox* buttonBox() const; + bool isChangeAllowed(MultiFeedEditCheckBox* mcb) const; void insertCustomTab(QWidget* custom_tab, const QString& title, int index); @@ -64,7 +66,7 @@ class RSSGUARD_DLLSPEC FormFeedDetails : public QDialog { void initialize(); protected: - Ui::FormFeedDetails m_ui; + QScopedPointer m_ui; QList m_feeds; ServiceRoot* m_serviceRoot; bool m_creatingNew; diff --git a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp index e41d39f79..a91a33d11 100644 --- a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -36,8 +36,8 @@ void FormTtRssFeedDetails::apply() { m_serviceRoot->networkProxy(), m_authDetails->authenticationType() == NetworkFactory::NetworkAuthentication::Basic, - m_authDetails->m_txtUsername->lineEdit()->text(), - m_authDetails->m_txtPassword->lineEdit()->text()); + m_authDetails->username(), + m_authDetails->password()); if (response.code() == STF_INSERTED) { // Feed was added online.