diff --git a/src/librssguard/librssguard.pro b/src/librssguard/librssguard.pro index 714c40b31..e0de68e54 100644 --- a/src/librssguard/librssguard.pro +++ b/src/librssguard/librssguard.pro @@ -160,7 +160,7 @@ HEADERS += core/feeddownloader.h \ services/owncloud/owncloudserviceroot.h \ services/standard/atomparser.h \ services/standard/feedparser.h \ - services/standard/gui/authenticationdetails.h \ + services/abstract/gui/authenticationdetails.h \ services/standard/gui/formstandardcategorydetails.h \ services/standard/gui/formstandardfeeddetails.h \ services/standard/gui/formstandardimportexport.h \ @@ -175,6 +175,8 @@ HEADERS += core/feeddownloader.h \ services/standard/standardserviceroot.h \ services/tt-rss/definitions.h \ services/tt-rss/gui/formeditttrssaccount.h \ + services/tt-rss/gui/formttrssfeeddetails.h \ + services/tt-rss/gui/ttrssfeeddetails.h \ services/tt-rss/network/ttrssnetworkfactory.h \ services/tt-rss/ttrssfeed.h \ services/tt-rss/ttrssserviceentrypoint.h \ @@ -308,7 +310,7 @@ SOURCES += core/feeddownloader.cpp \ services/owncloud/owncloudserviceroot.cpp \ services/standard/atomparser.cpp \ services/standard/feedparser.cpp \ - services/standard/gui/authenticationdetails.cpp \ + services/abstract/gui/authenticationdetails.cpp \ services/standard/gui/formstandardcategorydetails.cpp \ services/standard/gui/formstandardfeeddetails.cpp \ services/standard/gui/formstandardimportexport.cpp \ @@ -322,6 +324,8 @@ SOURCES += core/feeddownloader.cpp \ services/standard/standardserviceentrypoint.cpp \ services/standard/standardserviceroot.cpp \ services/tt-rss/gui/formeditttrssaccount.cpp \ + services/tt-rss/gui/formttrssfeeddetails.cpp \ + services/tt-rss/gui/ttrssfeeddetails.cpp \ services/tt-rss/network/ttrssnetworkfactory.cpp \ services/tt-rss/ttrssfeed.cpp \ services/tt-rss/ttrssserviceentrypoint.cpp \ @@ -363,7 +367,7 @@ FORMS += gui/dialogs/formabout.ui \ services/gmail/gui/formeditgmailaccount.ui \ services/inoreader/gui/formeditinoreaderaccount.ui \ services/owncloud/gui/formeditowncloudaccount.ui \ - services/standard/gui/authenticationdetails.ui \ + services/abstract/gui/authenticationdetails.ui \ services/standard/gui/formstandardcategorydetails.ui \ services/standard/gui/formstandardimportexport.ui \ services/standard/gui/standardfeeddetails.ui \ @@ -371,7 +375,8 @@ FORMS += gui/dialogs/formabout.ui \ services/gmail/gui/formdownloadattachment.ui \ services/gmail/gui/formaddeditemail.ui \ gui/searchtextwidget.ui \ - gui/newspaperpreviewer.ui + gui/newspaperpreviewer.ui \ + services/tt-rss/gui/ttrssfeeddetails.ui equals(USE_WEBENGINE, true) { HEADERS += gui/locationlineedit.h \ diff --git a/src/librssguard/services/abstract/gui/authenticationdetails.cpp b/src/librssguard/services/abstract/gui/authenticationdetails.cpp new file mode 100755 index 000000000..a47c87a7b --- /dev/null +++ b/src/librssguard/services/abstract/gui/authenticationdetails.cpp @@ -0,0 +1,47 @@ +// For license of this file, see /LICENSE.md. + +#include "services/abstract/gui/authenticationdetails.h" + +AuthenticationDetails::AuthenticationDetails(QWidget* parent) : QWidget(parent) { + setupUi(this); + + // Set text boxes. + 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.")); + + connect(m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged); + connect(m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged); + connect(m_gbAuthentication, &QGroupBox::toggled, this, &AuthenticationDetails::onAuthenticationSwitched); + + onUsernameChanged(QString()); + onPasswordChanged(QString()); +} + +void AuthenticationDetails::onUsernameChanged(const QString& new_username) { + bool is_username_ok = !m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty(); + + m_txtUsername->setStatus(is_username_ok ? + LineEditWithStatus::StatusType::Ok : + LineEditWithStatus::StatusType::Warning, + is_username_ok ? + tr("Username is ok or it is not needed.") : + tr("Username is empty.")); +} + +void AuthenticationDetails::onPasswordChanged(const QString& new_password) { + bool is_password_ok = !m_gbAuthentication->isChecked() || !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.")); +} + +void AuthenticationDetails::onAuthenticationSwitched() { + onUsernameChanged(m_txtUsername->lineEdit()->text()); + onPasswordChanged(m_txtPassword->lineEdit()->text()); +} diff --git a/src/librssguard/services/standard/gui/authenticationdetails.h b/src/librssguard/services/abstract/gui/authenticationdetails.h similarity index 74% rename from src/librssguard/services/standard/gui/authenticationdetails.h rename to src/librssguard/services/abstract/gui/authenticationdetails.h index d02c58148..7e8eb29e7 100755 --- a/src/librssguard/services/standard/gui/authenticationdetails.h +++ b/src/librssguard/services/abstract/gui/authenticationdetails.h @@ -7,11 +7,9 @@ #include "ui_authenticationdetails.h" -class AuthenticationDetails : public QWidget { +class AuthenticationDetails : public QWidget, public Ui::AuthenticationDetails { Q_OBJECT - friend class FormStandardFeedDetails; - public: explicit AuthenticationDetails(QWidget* parent = nullptr); @@ -19,9 +17,6 @@ class AuthenticationDetails : public QWidget { void onUsernameChanged(const QString& new_username); void onPasswordChanged(const QString& new_password); void onAuthenticationSwitched(); - - private: - Ui::AuthenticationDetails m_ui; }; #endif // AUTHENTICATIONDETAILS_H diff --git a/src/librssguard/services/standard/gui/authenticationdetails.ui b/src/librssguard/services/abstract/gui/authenticationdetails.ui similarity index 100% rename from src/librssguard/services/standard/gui/authenticationdetails.ui rename to src/librssguard/services/abstract/gui/authenticationdetails.ui diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index d6fc02f4f..b9312ce3e 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -37,6 +37,10 @@ void FormFeedDetails::activateTab(int index) { m_ui->m_tabWidget->setCurrentIndex(index); } +void FormFeedDetails::clearTabs() { + 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); } diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.h b/src/librssguard/services/abstract/gui/formfeeddetails.h index 245080778..4259233ce 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.h +++ b/src/librssguard/services/abstract/gui/formfeeddetails.h @@ -28,6 +28,7 @@ class FormFeedDetails : public QDialog { protected slots: void activateTab(int index); + void clearTabs(); void insertCustomTab(QWidget* custom_tab, const QString& title, int index); // Applies changes. diff --git a/src/librssguard/services/standard/gui/authenticationdetails.cpp b/src/librssguard/services/standard/gui/authenticationdetails.cpp deleted file mode 100755 index 456d86fce..000000000 --- a/src/librssguard/services/standard/gui/authenticationdetails.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// For license of this file, see /LICENSE.md. - -#include "services/standard/gui/authenticationdetails.h" - -AuthenticationDetails::AuthenticationDetails(QWidget* parent) : QWidget(parent) { - m_ui.setupUi(this); - - // Set text boxes. - 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.")); - - 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_gbAuthentication, &QGroupBox::toggled, this, &AuthenticationDetails::onAuthenticationSwitched); - - onUsernameChanged(QString()); - onPasswordChanged(QString()); -} - -void AuthenticationDetails::onUsernameChanged(const QString& new_username) { - bool is_username_ok = !m_ui.m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty(); - - m_ui.m_txtUsername->setStatus(is_username_ok ? - LineEditWithStatus::StatusType::Ok : - LineEditWithStatus::StatusType::Warning, - is_username_ok ? - tr("Username is ok or it is not needed.") : - tr("Username is empty.")); -} - -void AuthenticationDetails::onPasswordChanged(const QString& new_password) { - bool is_password_ok = !m_ui.m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty(); - - 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_ui.m_txtUsername->lineEdit()->text()); - onPasswordChanged(m_ui.m_txtPassword->lineEdit()->text()); -} diff --git a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp index e7cd61abe..fbe5275fb 100644 --- a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp @@ -6,8 +6,8 @@ #include "miscellaneous/iconfactory.h" #include "network-web/networkfactory.h" #include "services/abstract/category.h" +#include "services/abstract/gui/authenticationdetails.h" #include "services/abstract/serviceroot.h" -#include "services/standard/gui/authenticationdetails.h" #include "services/standard/gui/standardfeeddetails.h" #include "services/standard/standardfeed.h" @@ -39,19 +39,19 @@ int FormStandardFeedDetails::addEditFeed(StandardFeed* input_feed, RootItem* par } // Run the dialog. - return QDialog::exec(); + return exec(); } void FormStandardFeedDetails::guessFeed() { m_standardFeedDetails->guessFeed(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(), - m_authDetails->m_ui.m_txtUsername->lineEdit()->text(), - m_authDetails->m_ui.m_txtPassword->lineEdit()->text()); + m_authDetails->m_txtUsername->lineEdit()->text(), + m_authDetails->m_txtPassword->lineEdit()->text()); } void FormStandardFeedDetails::guessIconOnly() { m_standardFeedDetails->guessIconOnly(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(), - m_authDetails->m_ui.m_txtUsername->lineEdit()->text(), - m_authDetails->m_ui.m_txtPassword->lineEdit()->text()); + m_authDetails->m_txtUsername->lineEdit()->text(), + m_authDetails->m_txtPassword->lineEdit()->text()); } void FormStandardFeedDetails::apply() { @@ -71,9 +71,9 @@ void FormStandardFeedDetails::apply() { new_feed->setEncoding(m_standardFeedDetails->ui.m_cmbEncoding->currentText()); new_feed->setType(type); new_feed->setUrl(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text()); - new_feed->setPasswordProtected(m_authDetails->m_ui.m_gbAuthentication->isChecked()); - new_feed->setUsername(m_authDetails->m_ui.m_txtUsername->lineEdit()->text()); - new_feed->setPassword(m_authDetails->m_ui.m_txtPassword->lineEdit()->text()); + new_feed->setPasswordProtected(m_authDetails->m_gbAuthentication->isChecked()); + new_feed->setUsername(m_authDetails->m_txtUsername->lineEdit()->text()); + new_feed->setPassword(m_authDetails->m_txtPassword->lineEdit()->text()); new_feed->setAutoUpdateType(static_cast(m_ui->m_cmbAutoUpdateType->itemData( m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); new_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value())); @@ -115,7 +115,7 @@ void FormStandardFeedDetails::setEditableFeed(Feed* editable_feed) { FormFeedDetails::setEditableFeed(editable_feed); m_standardFeedDetails->setExistingFeed(qobject_cast(editable_feed)); - m_authDetails->m_ui.m_gbAuthentication->setChecked(editable_feed->passwordProtected()); - m_authDetails->m_ui.m_txtUsername->lineEdit()->setText(editable_feed->username()); - m_authDetails->m_ui.m_txtPassword->lineEdit()->setText(editable_feed->password()); + m_authDetails->m_gbAuthentication->setChecked(editable_feed->passwordProtected()); + m_authDetails->m_txtUsername->lineEdit()->setText(editable_feed->username()); + m_authDetails->m_txtPassword->lineEdit()->setText(editable_feed->password()); } diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp index d5272df71..3e065f03a 100644 --- a/src/librssguard/services/standard/standardserviceroot.cpp +++ b/src/librssguard/services/standard/standardserviceroot.cpp @@ -113,9 +113,8 @@ void StandardServiceRoot::addNewFeed(RootItem* selected_item, const QString& url // is quitting. qApp->showGuiMessage(tr("Cannot add item"), tr("Cannot add feed because another critical operation is ongoing."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::MessageIcon::Warning, qApp->mainFormWidget(), true); - // Thus, cannot delete and quit the method. return; } diff --git a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp new file mode 100755 index 000000000..688ffd511 --- /dev/null +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -0,0 +1,79 @@ +// For license of this file, see /LICENSE.md. + +#include "services/tt-rss/gui/formttrssfeeddetails.h" + +#include "miscellaneous/application.h" +#include "services/abstract/feed.h" +#include "services/abstract/gui/authenticationdetails.h" +#include "services/tt-rss/definitions.h" +#include "services/tt-rss/gui/ttrssfeeddetails.h" +#include "services/tt-rss/network/ttrssnetworkfactory.h" +#include "services/tt-rss/ttrssfeed.h" +#include "services/tt-rss/ttrssserviceroot.h" + +#include +#include +#include + +FormTtRssFeedDetails::FormTtRssFeedDetails(ServiceRoot* service_root, QWidget* parent) + : FormFeedDetails(service_root, parent), m_feedDetails(new TtRssFeedDetails(this)), + m_authDetails(new AuthenticationDetails(this)) {} + +int FormTtRssFeedDetails::addFeed(RootItem* parent_to_select, const QString& url) { + clearTabs(); + insertCustomTab(m_feedDetails, tr("General"), 0); + insertCustomTab(m_authDetails, tr("Network"), 1); + activateTab(0); + + setWindowTitle(tr("Add new feed")); + m_feedDetails->loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot, parent_to_select); + + if (!url.isEmpty()) { + m_feedDetails->ui.m_txtUrl->lineEdit()->setText(url); + } + else if (Application::clipboard()->mimeData()->hasText()) { + m_feedDetails->ui.m_txtUrl->lineEdit()->setText(Application::clipboard()->text()); + } + + m_feedDetails->ui.m_txtUrl->lineEdit()->selectAll(); + m_feedDetails->ui.m_txtUrl->setFocus(); + + return exec(); +} + +void FormTtRssFeedDetails::apply() { + if (m_editableFeed != nullptr) { + // NOTE: We can only edit base properties, therefore + // base method is fine. + FormFeedDetails::apply(); + } + else { + RootItem* parent = static_cast(m_feedDetails->ui.m_cmbParentCategory->itemData( + m_feedDetails->ui.m_cmbParentCategory->currentIndex()).value()); + auto* root = qobject_cast(parent->getParentServiceRoot()); + const int category_id = parent->kind() == RootItem::Kind::ServiceRoot ? + 0 : + parent->customId().toInt(); + const TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_feedDetails->ui.m_txtUrl->lineEdit()->text(), + category_id, + m_authDetails->m_gbAuthentication->isChecked(), + m_authDetails->m_txtUsername->lineEdit()->text(), + m_authDetails->m_txtPassword->lineEdit()->text()); + + if (response.code() == STF_INSERTED) { + // Feed was added online. + accept(); + qApp->showGuiMessage(tr("Feed added"), + tr("Feed was added, triggering sync in now."), + QSystemTrayIcon::MessageIcon::Information); + QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn); + } + else { + qApp->showGuiMessage(tr("Cannot add feed"), + tr("Feed was not added due to error."), + QSystemTrayIcon::MessageIcon::Critical, + qApp->mainFormWidget(), + true); + } + } +} diff --git a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.h b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.h new file mode 100755 index 000000000..899b7abf8 --- /dev/null +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.h @@ -0,0 +1,27 @@ +// For license of this file, see /LICENSE.md. + +#ifndef FORMTTRSSFEEDDETAILS_H +#define FORMTTRSSFEEDDETAILS_H + +#include "services/abstract/gui/formfeeddetails.h" + +class TtRssFeed; +class TtRssFeedDetails; +class AuthenticationDetails; + +class FormTtRssFeedDetails : public FormFeedDetails { + public: + explicit FormTtRssFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr); + + public slots: + int addFeed(RootItem* parent_to_select, const QString& url = QString()); + + protected slots: + virtual void apply(); + + private: + TtRssFeedDetails* m_feedDetails; + AuthenticationDetails* m_authDetails; +}; + +#endif // FORMTTRSSFEEDDETAILS_H diff --git a/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.cpp b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.cpp new file mode 100755 index 000000000..ea53bc7d2 --- /dev/null +++ b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.cpp @@ -0,0 +1,52 @@ +// For license of this file, see /LICENSE.md. + +#include "services/tt-rss/gui/ttrssfeeddetails.h" + +#include "services/abstract/category.h" + +TtRssFeedDetails::TtRssFeedDetails(QWidget* parent) : QWidget(parent) { + ui.setupUi(this); + + ui.m_txtUrl->lineEdit()->setPlaceholderText(tr("Full feed URL including scheme")); + ui.m_txtUrl->lineEdit()->setToolTip(tr("Provide URL for your feed.")); + + connect(ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &TtRssFeedDetails::onUrlChanged); + onUrlChanged(QString()); +} + +void TtRssFeedDetails::onUrlChanged(const QString& new_url) { + if (QRegularExpression(URL_REGEXP).match(new_url).hasMatch()) { + // New url is well-formed. + ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Ok, tr("The URL is ok.")); + } + else if (!new_url.simplified().isEmpty()) { + // New url is not well-formed but is not empty on the other hand. + ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Warning, + tr(R"(The URL does not meet standard pattern. Does your URL start with "http://" or "https://" prefix.)")); + } + else { + // New url is empty. + ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Error, tr("The URL is empty.")); + } +} + +void TtRssFeedDetails::loadCategories(const QList& categories, RootItem* root_item, RootItem* parent_to_select) { + ui.m_cmbParentCategory->addItem(root_item->fullIcon(), root_item->title(), QVariant::fromValue((void*) root_item)); + + for (Category* category : categories) { + ui.m_cmbParentCategory->addItem(category->fullIcon(), category->title(), QVariant::fromValue((void*) category)); + } + + if (parent_to_select != nullptr) { + if (parent_to_select->kind() == RootItem::Kind::Category) { + ui.m_cmbParentCategory->setCurrentIndex(ui.m_cmbParentCategory->findData(QVariant::fromValue((void*)parent_to_select))); + } + else if (parent_to_select->kind() == RootItem::Kind::Feed) { + int target_item = ui.m_cmbParentCategory->findData(QVariant::fromValue((void*)parent_to_select->parent())); + + if (target_item >= 0) { + ui.m_cmbParentCategory->setCurrentIndex(target_item); + } + } + } +} diff --git a/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.h b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.h new file mode 100755 index 000000000..b06c2ffbc --- /dev/null +++ b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.h @@ -0,0 +1,31 @@ +// For license of this file, see /LICENSE.md. + +#ifndef TTRSSFEEDDETAILS_H +#define TTRSSFEEDDETAILS_H + +#include + +#include "ui_ttrssfeeddetails.h" + +class Category; +class RootItem; + +class TtRssFeedDetails : public QWidget { + Q_OBJECT + + friend class FormTtRssFeedDetails; + + public: + explicit TtRssFeedDetails(QWidget* parent = nullptr); + + private slots: + void onUrlChanged(const QString& new_url); + + private: + void loadCategories(const QList& categories, RootItem* root_item, RootItem* parent_to_select = nullptr); + + private: + Ui::TtRssFeedDetails ui; +}; + +#endif // TTRSSFEEDDETAILS_H diff --git a/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.ui b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.ui new file mode 100755 index 000000000..1f318bc5d --- /dev/null +++ b/src/librssguard/services/tt-rss/gui/ttrssfeeddetails.ui @@ -0,0 +1,68 @@ + + + TtRssFeedDetails + + + + 0 + 0 + 367 + 202 + + + + Form + + + + + + Parent category + + + m_cmbParentCategory + + + + + + + Select parent item for your feed. + + + + 12 + 12 + + + + true + + + + + + + URL + + + m_txtUrl + + + + + + + + + + + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
+
+ + +
diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp index d13d00ec8..633452d47 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp @@ -14,6 +14,7 @@ #include "services/abstract/recyclebin.h" #include "services/tt-rss/definitions.h" #include "services/tt-rss/gui/formeditttrssaccount.h" +#include "services/tt-rss/gui/formttrssfeeddetails.h" #include "services/tt-rss/network/ttrssnetworkfactory.h" #include "services/tt-rss/ttrssfeed.h" #include "services/tt-rss/ttrssserviceentrypoint.h" @@ -83,13 +84,33 @@ bool TtRssServiceRoot::deleteViaGui() { } bool TtRssServiceRoot::supportsFeedAdding() const { - return false; + return true; } bool TtRssServiceRoot::supportsCategoryAdding() const { return false; } +void TtRssServiceRoot::addNewFeed(RootItem* selected_item, const QString& url) { + if (!qApp->feedUpdateLock()->tryLock()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + qApp->showGuiMessage(tr("Cannot add item"), + tr("Cannot add feed because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning, + qApp->mainFormWidget(), + true); + + return; + } + + QScopedPointer form_pointer(new FormTtRssFeedDetails(this, qApp->mainFormWidget())); + + form_pointer->addFeed(selected_item, url); + qApp->feedUpdateLock()->unlock(); +} + bool TtRssServiceRoot::canBeEdited() const { return true; } diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.h b/src/librssguard/services/tt-rss/ttrssserviceroot.h index 19c424bfc..07f89c647 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.h +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.h @@ -30,6 +30,7 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot { virtual bool deleteViaGui(); virtual bool supportsFeedAdding() const; virtual bool supportsCategoryAdding() const; + virtual void addNewFeed(RootItem* selected_item, const QString& url = QString()); virtual QString additionalTooltip() const; virtual void saveAllCachedData(bool async = true);