diff --git a/src/gui/discoverfeedsbutton.cpp b/src/gui/discoverfeedsbutton.cpp index 24f7e5331..c95323ffc 100755 --- a/src/gui/discoverfeedsbutton.cpp +++ b/src/gui/discoverfeedsbutton.cpp @@ -60,11 +60,18 @@ void DiscoverFeedsButton::setFeedAddresses(const QStringList &addresses) { } void DiscoverFeedsButton::linkTriggered(QAction *action) { - // TODO: Obtain link and root. QString url = action->property("url").toString(); ServiceRoot *root = static_cast(action->property("root").value()); - root->addFeedByUrl(url); + if (root->supportsFeedAddingByUrl()) { + root->addFeedByUrl(url); + } + else { + qApp->showGuiMessage(tr("Not supported"), + tr("Give account does not support adding feeds."), + QSystemTrayIcon::Warning, + qApp->mainForm(), true); + } } void DiscoverFeedsButton::fillMenu() { diff --git a/src/network-web/adblock/adblocktreewidget.cpp b/src/network-web/adblock/adblocktreewidget.cpp index 89981c8a1..f5909139b 100755 --- a/src/network-web/adblock/adblocktreewidget.cpp +++ b/src/network-web/adblock/adblocktreewidget.cpp @@ -19,11 +19,11 @@ #include "network-web/adblock/adblocktreewidget.h" #include "network-web/adblock/adblocksubscription.h" +#include "miscellaneous/application.h" #include #include #include -#include #include @@ -125,7 +125,7 @@ void AdBlockTreeWidget::copyFilter() { QTreeWidgetItem *item = currentItem(); if (item != NULL) { - QApplication::clipboard()->setText(item->text(0)); + Application::clipboard()->setText(item->text(0)); } } diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h index ecc63a6d1..55818e2f3 100755 --- a/src/services/abstract/serviceroot.h +++ b/src/services/abstract/serviceroot.h @@ -49,11 +49,9 @@ class ServiceRoot : public RootItem { ///////////////////////////////////////// bool deleteViaGui(); - bool markAsReadUnread(ReadStatus status); virtual bool supportsFeedAddingByUrl() const = 0; - virtual void addFeedByUrl(const QString &url) = 0; // Returns list of specific actions for "Add new item" main window menu. // So typical list of returned actions could look like: @@ -160,6 +158,9 @@ class ServiceRoot : public RootItem { int accountId() const; void setAccountId(int account_id); + public slots: + virtual void addFeedByUrl(const QString &url = QString()) = 0; + protected: // Takes lists of feeds/categories and assembles them into the tree structure. void assembleCategories(Assignment categories); diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index 88c3656a7..7d24e49f4 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -59,7 +59,7 @@ FormStandardFeedDetails::~FormStandardFeedDetails() { delete m_ui; } -int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) { +int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url) { // Load categories. loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot); @@ -90,8 +90,11 @@ int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_ } } - if (qApp->clipboard()->mimeData()->hasText()) { - m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text()); + if (!url.isEmpty()) { + m_ui->m_txtUrl->lineEdit()->setText(url); + } + else if (Application::clipboard()->mimeData()->hasText()) { + m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text()); } } else { diff --git a/src/services/standard/gui/formstandardfeeddetails.h b/src/services/standard/gui/formstandardfeeddetails.h index c5817a399..d53a534d0 100755 --- a/src/services/standard/gui/formstandardfeeddetails.h +++ b/src/services/standard/gui/formstandardfeeddetails.h @@ -42,7 +42,7 @@ class FormStandardFeedDetails : public QDialog { public slots: // Executes add/edit standard feed dialog. - int exec(StandardFeed *input_feed, RootItem *parent_to_select); + int exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url = QString()); protected slots: // Applies changes. diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 7b30ead52..d2ab9d2b2 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -130,8 +130,9 @@ bool StandardServiceRoot::supportsFeedAddingByUrl() const { } void StandardServiceRoot::addFeedByUrl(const QString &url) { - qApp->clipboard()->setText(url); - addNewFeed(); + QPointer form_pointer = new FormStandardFeedDetails(this, qApp->mainForm()); + form_pointer.data()->exec(NULL, NULL, url); + delete form_pointer.data(); } QVariant StandardServiceRoot::data(int column, int role) const { @@ -299,8 +300,7 @@ void StandardServiceRoot::checkArgumentsForFeedAdding() { void StandardServiceRoot::checkArgumentForFeedAdding(const QString &argument) { if (argument.startsWith(QL1S("feed:"))) { - qApp->clipboard()->setText(argument); - addNewFeed(); + addFeedByUrl(argument); } } @@ -415,12 +415,6 @@ void StandardServiceRoot::addNewCategory() { delete form_pointer.data(); } -void StandardServiceRoot::addNewFeed() { - QPointer form_pointer = new FormStandardFeedDetails(this, qApp->mainForm()); - form_pointer.data()->exec(NULL, NULL); - delete form_pointer.data(); -} - void StandardServiceRoot::importFeeds() { QPointer form = new FormStandardImportExport(this, qApp->mainForm()); form.data()->setMode(FeedsImportExportModel::Import); @@ -452,7 +446,7 @@ QList StandardServiceRoot::addItemMenu() { connect(action_new_category, SIGNAL(triggered()), this, SLOT(addNewCategory())); QAction *action_new_feed = new QAction(qApp->icons()->fromTheme("folder-feed"), tr("Add new feed"), this); - connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addNewFeed())); + connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addFeedByUrl())); m_addItemMenu.append(action_new_category); m_addItemMenu.append(action_new_feed); diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 216a082e5..bf8eb71cd 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -50,7 +50,6 @@ class StandardServiceRoot : public ServiceRoot { bool markAsReadUnread(ReadStatus status); bool supportsFeedAddingByUrl() const; - void addFeedByUrl(const QString &url); QVariant data(int column, int role) const; Qt::ItemFlags additionalFlags() const; @@ -101,8 +100,8 @@ class StandardServiceRoot : public ServiceRoot { void checkArgumentForFeedAdding(const QString &argument); public slots: + void addFeedByUrl(const QString &url = QString()); void addNewCategory(); - void addNewFeed(); void importFeeds(); void exportFeeds(); diff --git a/src/services/tt-rss/gui/formeditfeed.cpp b/src/services/tt-rss/gui/formeditfeed.cpp index df296917f..9c09c657a 100755 --- a/src/services/tt-rss/gui/formeditfeed.cpp +++ b/src/services/tt-rss/gui/formeditfeed.cpp @@ -55,9 +55,12 @@ int FormEditFeed::execForEdit(TtRssFeed *input_feed) { return QDialog::exec(); } -int FormEditFeed::execForAdd() { - if (qApp->clipboard()->mimeData()->hasText()) { - m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text()); +int FormEditFeed::execForAdd(const QString &url) { + if (!url.isEmpty()) { + m_ui->m_txtUrl->lineEdit()->setText(url); + } + else if (Application::clipboard()->mimeData()->hasText()) { + m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text()); } loadCategories(m_root->getSubTreeCategories(), m_root); diff --git a/src/services/tt-rss/gui/formeditfeed.h b/src/services/tt-rss/gui/formeditfeed.h index 57a9c19a1..be49d2277 100755 --- a/src/services/tt-rss/gui/formeditfeed.h +++ b/src/services/tt-rss/gui/formeditfeed.h @@ -40,7 +40,7 @@ class FormEditFeed : public QDialog { virtual ~FormEditFeed(); int execForEdit(TtRssFeed *input_feed); - int execForAdd(); + int execForAdd(const QString &url); private slots: void performAction(); diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index ec512a2aa..286565324 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -114,8 +114,10 @@ bool TtRssServiceRoot::supportsFeedAddingByUrl() const { } void TtRssServiceRoot::addFeedByUrl(const QString &url) { - qApp->clipboard()->setText(url); - addNewFeed(); + QPointer form_pointer = new FormEditFeed(this, qApp->mainForm()); + + form_pointer.data()->execForAdd(url); + delete form_pointer.data(); } bool TtRssServiceRoot::canBeEdited() { @@ -151,7 +153,7 @@ QVariant TtRssServiceRoot::data(int column, int role) const { QList TtRssServiceRoot::addItemMenu() { if (m_addItemMenu.isEmpty()) { QAction *action_new_feed = new QAction(qApp->icons()->fromTheme("folder-feed"), tr("Add new feed"), this); - connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addNewFeed())); + connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addFeedByUrl())); m_addItemMenu.append(action_new_feed); } @@ -605,13 +607,6 @@ void TtRssServiceRoot::syncIn() { itemChanged(QList() << this); } -void TtRssServiceRoot::addNewFeed() { - QPointer form_pointer = new FormEditFeed(this, qApp->mainForm()); - - form_pointer.data()->execForAdd(); - delete form_pointer.data(); -} - QStringList TtRssServiceRoot::customIDsOfMessages(const QList > &changes) { QStringList list; diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index 495a7ad8d..214029c88 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -48,7 +48,6 @@ class TtRssServiceRoot : public ServiceRoot { bool markAsReadUnread(ReadStatus status); bool supportsFeedAddingByUrl() const; - void addFeedByUrl(const QString &url); QVariant data(int column, int role) const; @@ -86,11 +85,9 @@ class TtRssServiceRoot : public ServiceRoot { void completelyRemoveAllData(); public slots: + void addFeedByUrl(const QString &url = QString()); void syncIn(); - private slots: - void addNewFeed(); - private: QStringList customIDsOfMessages(const QList > &changes); QStringList customIDsOfMessages(const QList &messages);