Added better "add feed from website" feature accounts/plugins integration.
This commit is contained in:
parent
d50038f6ed
commit
9f4e38f30a
@ -6,6 +6,8 @@ Added:
|
||||
▪ Background color of notifications is now changeable. (issue #134)
|
||||
▪ Auto-update setting of individual Tiny Tiny RSS feeds can now be changed.
|
||||
▪ RSS Guard is now useable as external RSS reader by common web browsers like Firefox etc. (issue #135)
|
||||
▪ Tiny Tiny RSS plugin now supports adding of new feeds.
|
||||
▪ Activated accounts are now integrated into built-in web browser "add feed from website" feature.
|
||||
|
||||
Fixed:
|
||||
|
||||
|
@ -19,9 +19,17 @@
|
||||
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
DiscoverFeedsButton::DiscoverFeedsButton(QWidget *parent) : QToolButton(parent) {
|
||||
DiscoverFeedsButton::DiscoverFeedsButton(QWidget *parent) : QToolButton(parent), m_addresses(QStringList()) {
|
||||
setEnabled(false);
|
||||
setIcon(qApp->icons()->fromTheme(QSL("folder-feed")));
|
||||
setPopupMode(QToolButton::InstantPopup);
|
||||
@ -44,19 +52,34 @@ void DiscoverFeedsButton::setFeedAddresses(const QStringList &addresses) {
|
||||
// Initialize the menu.
|
||||
setMenu(new QMenu(this));
|
||||
connect(menu(), SIGNAL(triggered(QAction*)), this, SLOT(linkTriggered(QAction*)));
|
||||
connect(menu(), SIGNAL(aboutToShow()), this, SLOT(fillMenu()));
|
||||
}
|
||||
|
||||
menu()->hide();
|
||||
|
||||
if (!addresses.isEmpty()) {
|
||||
menu()->clear();
|
||||
|
||||
foreach (const QString &feed, addresses) {
|
||||
menu()->addAction(feed);
|
||||
}
|
||||
}
|
||||
m_addresses = addresses;
|
||||
}
|
||||
|
||||
void DiscoverFeedsButton::linkTriggered(QAction *action) {
|
||||
emit addingOfFeedRequested(action->text());
|
||||
// TODO: Obtain link and root.
|
||||
QString url = action->property("url").toString();
|
||||
ServiceRoot *root = static_cast<ServiceRoot*>(action->property("root").value<void*>());
|
||||
|
||||
root->addFeedByUrl(url);
|
||||
}
|
||||
|
||||
void DiscoverFeedsButton::fillMenu() {
|
||||
menu()->clear();
|
||||
|
||||
foreach (ServiceRoot *root, qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) {
|
||||
QMenu *root_menu = menu()->addMenu(root->icon(), root->title());
|
||||
|
||||
foreach (const QString &url, m_addresses) {
|
||||
if (root->supportsFeedAddingByUrl()) {
|
||||
QAction *url_action = root_menu->addAction(root->icon(), url);
|
||||
|
||||
url_action->setProperty("url", url);
|
||||
url_action->setProperty("root", QVariant::fromValue((void*) root));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
src/gui/discoverfeedsbutton.h
Normal file → Executable file
6
src/gui/discoverfeedsbutton.h
Normal file → Executable file
@ -36,10 +36,10 @@ class DiscoverFeedsButton : public QToolButton {
|
||||
private slots:
|
||||
// User chose any of addresses.
|
||||
void linkTriggered(QAction *action);
|
||||
void fillMenu();
|
||||
|
||||
signals:
|
||||
// User requests addition of selected address.
|
||||
void addingOfFeedRequested(const QString &feed_link);
|
||||
private:
|
||||
QStringList m_addresses;
|
||||
};
|
||||
|
||||
#endif // DISCOVERFEEDSBUTTON_H
|
||||
|
@ -206,30 +206,12 @@ void WebBrowser::createConnections() {
|
||||
|
||||
// Misc connections.
|
||||
connect(m_webView, SIGNAL(zoomFactorChanged()), this, SLOT(updateZoomGui()));
|
||||
connect(m_btnDiscoverFeeds, SIGNAL(addingOfFeedRequested(QString)), this, SLOT(addFeedFromWebsite(QString)));
|
||||
}
|
||||
|
||||
void WebBrowser::onIconChanged() {
|
||||
emit iconChanged(m_index, m_webView->icon());
|
||||
}
|
||||
|
||||
void WebBrowser::addFeedFromWebsite(const QString &feed_link) {
|
||||
qApp->clipboard()->setText(feed_link);
|
||||
|
||||
StandardServiceRoot *service = qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot();
|
||||
|
||||
if (service != NULL) {
|
||||
service->addNewFeed();
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(tr("Cannot add feed"),
|
||||
tr("You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first.").arg(APP_NAME),
|
||||
QSystemTrayIcon::Warning,
|
||||
qApp->mainForm(),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::onTitleChanged(const QString &new_title) {
|
||||
if (new_title.isEmpty()) {
|
||||
//: Webbrowser tab title when no title is available.
|
||||
|
@ -42,7 +42,7 @@ class TabWidget;
|
||||
|
||||
class WebBrowser : public TabContent {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit WebBrowser(QWidget *parent = 0);
|
||||
@ -136,10 +136,6 @@ class WebBrowser : public TabContent {
|
||||
void onTitleChanged(const QString &new_title);
|
||||
void onIconChanged();
|
||||
|
||||
// User selected any feed from website to add to reader.
|
||||
// This copies feed link to clipboard and triggers "add feed" dialog.
|
||||
void addFeedFromWebsite(const QString &feed_link);
|
||||
|
||||
signals:
|
||||
// User requests opening of new tab or clicks the link
|
||||
// with middle mouse button
|
||||
|
@ -52,6 +52,9 @@ class ServiceRoot : public RootItem {
|
||||
|
||||
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:
|
||||
// a) Add new feed
|
||||
|
@ -124,6 +124,15 @@ bool StandardServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
return ServiceRoot::markAsReadUnread(status);
|
||||
}
|
||||
|
||||
bool StandardServiceRoot::supportsFeedAddingByUrl() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void StandardServiceRoot::addFeedByUrl(const QString &url) {
|
||||
qApp->clipboard()->setText(url);
|
||||
addNewFeed();
|
||||
}
|
||||
|
||||
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
|
@ -49,6 +49,9 @@ 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;
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QSqlError>
|
||||
#include <QPointer>
|
||||
#include <QPair>
|
||||
#include <QClipboard>
|
||||
|
||||
|
||||
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent)
|
||||
@ -108,6 +109,15 @@ bool TtRssServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
}
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::supportsFeedAddingByUrl() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::addFeedByUrl(const QString &url) {
|
||||
qApp->clipboard()->setText(url);
|
||||
addNewFeed();
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::canBeEdited() {
|
||||
return true;
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class TtRssServiceRoot : public ServiceRoot {
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
bool supportsFeedAddingByUrl() const;
|
||||
void addFeedByUrl(const QString &url);
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
|
||||
QList<QAction*> addItemMenu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user