do not require path to UI_ files

This commit is contained in:
Martin Rotter 2024-03-18 11:47:11 +01:00 committed by martinrotter
parent df0f831c3c
commit 7d709dcc81
17 changed files with 223 additions and 179 deletions

View file

@ -1,5 +1,8 @@
if(NOT DEFINED LIBRSSGUARD_BINARY_PATH)
set(LIBRSSGUARD_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../librssguard")
set(LIBRSSGUARD_BINARY_PATH "${CMAKE_BINARY_DIR}/src/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)

View file

@ -14,6 +14,8 @@ FormEditStandardAccount::FormEditStandardAccount(QWidget* parent)
activateTab(0);
}
FormEditStandardAccount::~FormEditStandardAccount() = default;
void FormEditStandardAccount::loadAccountData() {
FormAccountDetails::loadAccountData();

View file

@ -12,6 +12,7 @@ class FormEditStandardAccount : public FormAccountDetails {
public:
explicit FormEditStandardAccount(QWidget* parent = nullptr);
virtual ~FormEditStandardAccount();
protected:
virtual void loadAccountData();

View file

@ -13,7 +13,10 @@
#include "src/gui/standardfeeddetails.h"
#include "src/standardfeed.h"
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QGroupBox>
#include <QNetworkCookie>
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<MultiFeedEditCheckBox*>(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<MultiFeedEditCheckBox*>(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<MultiFeedEditCheckBox*>(QSL("m_mcbAuthType"))
->addActionWidget(m_authDetails->findChild<QComboBox*>(QSL("m_cbAuthType")));
m_authDetails->findChild<MultiFeedEditCheckBox*>(QSL("m_mcbAuthentication"))
->addActionWidget(m_authDetails->findChild<QGroupBox*>(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);

View file

@ -2,63 +2,67 @@
#include "gui/reusable/networkproxydetails.h"
#include "ui_networkproxydetails.h"
#include "definitions/definitions.h"
#include <QNetworkProxy>
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."),
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_txtProxyPassword->setPasswordMode(true);
connect(m_ui.m_cmbProxyType,
connect(m_ui->m_cmbProxyType,
static_cast<void (QComboBox::*)(int)>(&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<void (QComboBox::*)(int)>(&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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&NetworkProxyDetails::changed);
}
NetworkProxyDetails::~NetworkProxyDetails() = default;
QNetworkProxy NetworkProxyDetails::proxy() const {
QNetworkProxy proxy(static_cast<QNetworkProxy::ProxyType>(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<QNetworkProxy::ProxyType>(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<QNetworkProxy::ProxyType>(m_ui.m_cmbProxyType->itemData(index).toInt());
static_cast<QNetworkProxy::ProxyType>(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);
}

View file

@ -5,15 +5,18 @@
#include <QWidget>
#include "ui_networkproxydetails.h"
#include <QNetworkProxy>
namespace Ui {
class NetworkProxyDetails;
}
class NetworkProxyDetails : public QWidget {
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<Ui::NetworkProxyDetails> m_ui;
};
#endif // NETWORKPROXYDETAILS_H

View file

@ -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;

View file

@ -5,8 +5,6 @@
#include <QWidget>
#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<Ui::AccountDetails> m_ui;
};
#endif // ACCOUNTDETAILS_H

View file

@ -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"),
m_ui->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("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<int>::of(&QComboBox::currentIndexChanged),
this,
&AuthenticationDetails::onAuthenticationSwitched);
@ -32,23 +35,41 @@ 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<NetworkFactory::NetworkAuthentication>();
return m_ui->m_cbAuthType->currentData().value<NetworkFactory::NetworkAuthentication>();
}
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
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."));
@ -58,26 +79,26 @@ 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
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);
}

View file

@ -5,16 +5,25 @@
#include <QWidget>
#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<Ui::AuthenticationDetails> m_ui;
};
#endif // AUTHENTICATIONDETAILS_H

View file

@ -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);
}

View file

@ -5,14 +5,16 @@
#include <QDialog>
#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 <class T>
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<Ui::FormAccountDetails> m_ui;
NetworkProxyDetails* m_proxyDetails;
AccountDetails* m_accountDetails;
ServiceRoot* m_account;

View file

@ -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"

View file

@ -3,8 +3,6 @@
#ifndef FORMCATEGORYDETAILS_H
#define FORMCATEGORYDETAILS_H
#include "ui_formcategorydetails.h"
#include <QDialog>
#include "3rd-party/boolinq/boolinq.h"

View file

@ -20,21 +20,23 @@
#include <QTextCodec>
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<Feed::AutoUpdateType>(m_ui.m_cmbAutoUpdateType
->itemData(m_ui.m_cmbAutoUpdateType->currentIndex())
if (isChangeAllowed(m_ui->m_mcbAutoDownloading)) {
fd->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(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<Feed::AutoUpdateType>(m_ui.m_cmbAutoUpdateType->itemData(new_index).toInt());
static_cast<Feed::AutoUpdateType>(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<void (QComboBox::*)(int)>(&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"),
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"),
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"),
m_ui->m_cmbAutoUpdateType->addItem(tr("Disable auto-fetching of articles"),
QVariant::fromValue(int(Feed::AutoUpdateType::DontAutoUpdate)));
}

View file

@ -5,8 +5,6 @@
#include <QDialog>
#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 <class T>
QList<T*> addEditFeed(const QList<Feed*>& 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<Ui::FormFeedDetails> m_ui;
QList<Feed*> m_feeds;
ServiceRoot* m_serviceRoot;
bool m_creatingNew;

View file

@ -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.