mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-29 00:30:12 +01:00
Some minor tweaks + fixed #320.
This commit is contained in:
parent
c61561a742
commit
4a0b1a90b7
@ -239,10 +239,10 @@ nl_before_cpp_comment = 2 # unsigned number
|
|||||||
nl_before_class = 0 # unsigned number
|
nl_before_class = 0 # unsigned number
|
||||||
|
|
||||||
# The number of newlines after '}' or ';' of a class definition
|
# The number of newlines after '}' or ';' of a class definition
|
||||||
nl_after_class = 0 # unsigned number
|
nl_after_class = 2 # unsigned number
|
||||||
|
|
||||||
# The number of newlines after '}' or ';' of a struct/enum/union definition.
|
# The number of newlines after '}' or ';' of a struct/enum/union definition.
|
||||||
nl_after_struct = 0 # unsigned number
|
nl_after_struct = 2 # unsigned number
|
||||||
|
|
||||||
# The number of newlines after '}' of a multi-line function body
|
# The number of newlines after '}' of a multi-line function body
|
||||||
nl_after_func_body = 2 # unsigned number
|
nl_after_func_body = 2 # unsigned number
|
||||||
|
@ -29,8 +29,8 @@ void DiscoverFeedsButton::clearFeedAddresses() {
|
|||||||
void DiscoverFeedsButton::setFeedAddresses(const QStringList& addresses) {
|
void DiscoverFeedsButton::setFeedAddresses(const QStringList& addresses) {
|
||||||
setEnabled(!addresses.isEmpty());
|
setEnabled(!addresses.isEmpty());
|
||||||
setToolTip(addresses.isEmpty() ?
|
setToolTip(addresses.isEmpty() ?
|
||||||
tr("This website does not contain any feeds.") :
|
tr("This website does not contain any feeds") :
|
||||||
tr("Click me to add feeds from this website.\nThis website contains %n feed(s).", 0, addresses.size()));
|
tr("Add one of %n feed(s)", 0, addresses.size()));
|
||||||
|
|
||||||
if (menu() == nullptr) {
|
if (menu() == nullptr) {
|
||||||
// Initialize the menu.
|
// Initialize the menu.
|
||||||
|
@ -32,7 +32,7 @@ class RSSGUARD_DLLSPEC FeedMessageViewer : public TabContent {
|
|||||||
virtual ~FeedMessageViewer();
|
virtual ~FeedMessageViewer();
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
WebBrowser* webBrowser() const;
|
virtual WebBrowser* webBrowser() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FeedsView* feedsView() const;
|
FeedsView* feedsView() const;
|
||||||
|
@ -31,7 +31,7 @@ class NewspaperPreviewer : public TabContent {
|
|||||||
explicit NewspaperPreviewer(int msg_height, RootItem* root, QList<Message> messages, QWidget* parent = nullptr);
|
explicit NewspaperPreviewer(int msg_height, RootItem* root, QList<Message> messages, QWidget* parent = nullptr);
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
WebBrowser* webBrowser() const;
|
virtual WebBrowser* webBrowser() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -23,7 +23,6 @@ class TabContent : public QWidget {
|
|||||||
virtual void setIndex(int index);
|
virtual void setIndex(int index);
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
|
|
||||||
// Obtains instance contained in this TabContent or nullptr.
|
// Obtains instance contained in this TabContent or nullptr.
|
||||||
// This can be used for obtaining the menu from the instance and so on.
|
// This can be used for obtaining the menu from the instance and so on.
|
||||||
virtual WebBrowser* webBrowser() const = 0;
|
virtual WebBrowser* webBrowser() const = 0;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "gui/webviewer.h"
|
#include "gui/webviewer.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/databasequeries.h"
|
#include "miscellaneous/databasequeries.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "network-web/networkfactory.h"
|
#include "network-web/networkfactory.h"
|
||||||
#include "network-web/webfactory.h"
|
#include "network-web/webfactory.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
@ -31,7 +32,10 @@ WebBrowser::WebBrowser(QWidget* parent) : TabContent(parent),
|
|||||||
m_actionBack(m_webView->pageAction(QWebEnginePage::Back)),
|
m_actionBack(m_webView->pageAction(QWebEnginePage::Back)),
|
||||||
m_actionForward(m_webView->pageAction(QWebEnginePage::Forward)),
|
m_actionForward(m_webView->pageAction(QWebEnginePage::Forward)),
|
||||||
m_actionReload(m_webView->pageAction(QWebEnginePage::Reload)),
|
m_actionReload(m_webView->pageAction(QWebEnginePage::Reload)),
|
||||||
m_actionStop(m_webView->pageAction(QWebEnginePage::Stop)) {
|
m_actionStop(m_webView->pageAction(QWebEnginePage::Stop)),
|
||||||
|
m_actionOpenInSystemBrowser(new QAction(qApp->icons()->fromTheme(QSL("document-open")),
|
||||||
|
tr("Open this website in system web browser"),
|
||||||
|
this)) {
|
||||||
// Initialize the components and layout.
|
// Initialize the components and layout.
|
||||||
initializeLayout();
|
initializeLayout();
|
||||||
setFocusProxy(m_txtLocation);
|
setFocusProxy(m_txtLocation);
|
||||||
@ -58,6 +62,8 @@ void WebBrowser::createConnections() {
|
|||||||
m_searchWidget->setFocus();
|
m_searchWidget->setFocus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_actionOpenInSystemBrowser, &QAction::triggered, this, &WebBrowser::openCurrentSiteInSystemBrowser);
|
||||||
|
|
||||||
connect(m_txtLocation, &LocationLineEdit::submitted,
|
connect(m_txtLocation, &LocationLineEdit::submitted,
|
||||||
this, static_cast<void (WebBrowser::*)(const QString&)>(&WebBrowser::loadUrl));
|
this, static_cast<void (WebBrowser::*)(const QString&)>(&WebBrowser::loadUrl));
|
||||||
connect(m_webView, &WebViewer::urlChanged, this, &WebBrowser::updateUrl);
|
connect(m_webView, &WebViewer::urlChanged, this, &WebBrowser::updateUrl);
|
||||||
@ -172,6 +178,22 @@ bool WebBrowser::eventFilter(QObject* watched, QEvent* event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebBrowser::openCurrentSiteInSystemBrowser() {
|
||||||
|
auto url = m_webView->url();
|
||||||
|
|
||||||
|
if (!url.isValid() || url.host().contains(APP_LOW_NAME)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qApp->web()->openUrlInExternalBrowser(url.toString())) {
|
||||||
|
qApp->showGuiMessage(tr("Failed to open URL in web browser"),
|
||||||
|
tr("URL '%1' could not be opened in system's web browser.").arg(url.toString()),
|
||||||
|
QSystemTrayIcon::MessageIcon::Critical,
|
||||||
|
qApp->mainFormWidget(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebBrowser::onTitleChanged(const QString& new_title) {
|
void WebBrowser::onTitleChanged(const QString& new_title) {
|
||||||
if (new_title.isEmpty()) {
|
if (new_title.isEmpty()) {
|
||||||
//: Webbrowser tab title when no title is available.
|
//: Webbrowser tab title when no title is available.
|
||||||
@ -189,19 +211,16 @@ void WebBrowser::onIconChanged(const QIcon& icon) {
|
|||||||
void WebBrowser::initializeLayout() {
|
void WebBrowser::initializeLayout() {
|
||||||
m_toolBar->setFloatable(false);
|
m_toolBar->setFloatable(false);
|
||||||
m_toolBar->setMovable(false);
|
m_toolBar->setMovable(false);
|
||||||
m_toolBar->setAllowedAreas(Qt::TopToolBarArea);
|
m_toolBar->setAllowedAreas(Qt::ToolBarArea::TopToolBarArea);
|
||||||
|
|
||||||
// Modify action texts.
|
// Modify action texts.
|
||||||
m_actionBack->setText(tr("Back"));
|
m_actionBack->setText(tr("Back"));
|
||||||
m_actionBack->setToolTip(tr("Go back."));
|
|
||||||
m_actionForward->setText(tr("Forward"));
|
m_actionForward->setText(tr("Forward"));
|
||||||
m_actionForward->setToolTip(tr("Go forward."));
|
|
||||||
m_actionReload->setText(tr("Reload"));
|
m_actionReload->setText(tr("Reload"));
|
||||||
m_actionReload->setToolTip(tr("Reload current web page."));
|
|
||||||
m_actionStop->setText(tr("Stop"));
|
m_actionStop->setText(tr("Stop"));
|
||||||
m_actionStop->setToolTip(tr("Stop web page loading."));
|
|
||||||
QWidgetAction* act_discover = new QWidgetAction(this);
|
QWidgetAction* act_discover = new QWidgetAction(this);
|
||||||
|
|
||||||
|
m_actionOpenInSystemBrowser->setEnabled(false);
|
||||||
act_discover->setDefaultWidget(m_btnDiscoverFeeds);
|
act_discover->setDefaultWidget(m_btnDiscoverFeeds);
|
||||||
|
|
||||||
// Add needed actions into toolbar.
|
// Add needed actions into toolbar.
|
||||||
@ -209,6 +228,7 @@ void WebBrowser::initializeLayout() {
|
|||||||
m_toolBar->addAction(m_actionForward);
|
m_toolBar->addAction(m_actionForward);
|
||||||
m_toolBar->addAction(m_actionReload);
|
m_toolBar->addAction(m_actionReload);
|
||||||
m_toolBar->addAction(m_actionStop);
|
m_toolBar->addAction(m_actionStop);
|
||||||
|
m_toolBar->addAction(m_actionOpenInSystemBrowser);
|
||||||
m_toolBar->addAction(act_discover);
|
m_toolBar->addAction(act_discover);
|
||||||
m_toolBar->addWidget(m_txtLocation);
|
m_toolBar->addWidget(m_txtLocation);
|
||||||
m_loadingProgress = new QProgressBar(this);
|
m_loadingProgress = new QProgressBar(this);
|
||||||
@ -232,6 +252,7 @@ void WebBrowser::initializeLayout() {
|
|||||||
void WebBrowser::onLoadingStarted() {
|
void WebBrowser::onLoadingStarted() {
|
||||||
m_btnDiscoverFeeds->clearFeedAddresses();
|
m_btnDiscoverFeeds->clearFeedAddresses();
|
||||||
m_loadingProgress->show();
|
m_loadingProgress->show();
|
||||||
|
m_actionOpenInSystemBrowser->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::onLoadingProgress(int progress) {
|
void WebBrowser::onLoadingProgress(int progress) {
|
||||||
@ -240,6 +261,12 @@ void WebBrowser::onLoadingProgress(int progress) {
|
|||||||
|
|
||||||
void WebBrowser::onLoadingFinished(bool success) {
|
void WebBrowser::onLoadingFinished(bool success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
|
auto url = m_webView->url();
|
||||||
|
|
||||||
|
if (url.isValid() && !url.host().contains(APP_LOW_NAME)) {
|
||||||
|
m_actionOpenInSystemBrowser->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Let's check if there are any feeds defined on the web and eventually
|
// Let's check if there are any feeds defined on the web and eventually
|
||||||
// display "Add feeds" button.
|
// display "Add feeds" button.
|
||||||
m_webView->page()->toHtml([this](const QString& result) {
|
m_webView->page()->toHtml([this](const QString& result) {
|
||||||
@ -252,7 +279,6 @@ void WebBrowser::onLoadingFinished(bool success) {
|
|||||||
|
|
||||||
m_loadingProgress->hide();
|
m_loadingProgress->hide();
|
||||||
m_loadingProgress->setValue(0);
|
m_loadingProgress->setValue(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Message* WebBrowser::findMessage(int id) {
|
Message* WebBrowser::findMessage(int id) {
|
||||||
|
@ -31,7 +31,8 @@ class WebBrowser : public TabContent {
|
|||||||
explicit WebBrowser(QWidget* parent = nullptr);
|
explicit WebBrowser(QWidget* parent = nullptr);
|
||||||
virtual ~WebBrowser();
|
virtual ~WebBrowser();
|
||||||
|
|
||||||
WebBrowser* webBrowser() const;
|
virtual WebBrowser* webBrowser() const;
|
||||||
|
|
||||||
WebViewer* viewer() const;
|
WebViewer* viewer() const;
|
||||||
|
|
||||||
double verticalScrollBarPosition() const;
|
double verticalScrollBarPosition() const;
|
||||||
@ -54,8 +55,8 @@ class WebBrowser : public TabContent {
|
|||||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void openCurrentSiteInSystemBrowser();
|
||||||
void updateUrl(const QUrl& url);
|
void updateUrl(const QUrl& url);
|
||||||
|
|
||||||
void onLoadingStarted();
|
void onLoadingStarted();
|
||||||
void onLoadingProgress(int progress);
|
void onLoadingProgress(int progress);
|
||||||
void onLoadingFinished(bool success);
|
void onLoadingFinished(bool success);
|
||||||
@ -85,6 +86,7 @@ class WebBrowser : public TabContent {
|
|||||||
QAction* m_actionForward;
|
QAction* m_actionForward;
|
||||||
QAction* m_actionReload;
|
QAction* m_actionReload;
|
||||||
QAction* m_actionStop;
|
QAction* m_actionStop;
|
||||||
|
QAction* m_actionOpenInSystemBrowser;
|
||||||
QList<Message> m_messages;
|
QList<Message> m_messages;
|
||||||
QPointer<RootItem> m_root;
|
QPointer<RootItem> m_root;
|
||||||
};
|
};
|
||||||
|
@ -14,23 +14,17 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class AutoSaver;
|
class AutoSaver;
|
||||||
|
|
||||||
class DownloadModel;
|
class DownloadModel;
|
||||||
|
|
||||||
class QFileIconProvider;
|
class QFileIconProvider;
|
||||||
|
|
||||||
class QMimeData;
|
class QMimeData;
|
||||||
|
|
||||||
class DownloadItem : public QWidget {
|
class DownloadItem : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// Friends of this class.
|
|
||||||
friend class DownloadManager;
|
friend class DownloadManager;
|
||||||
friend class DownloadModel;
|
friend class DownloadModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors.
|
|
||||||
explicit DownloadItem(QNetworkReply* reply = 0, QWidget* parent = nullptr);
|
explicit DownloadItem(QNetworkReply* reply = 0, QWidget* parent = nullptr);
|
||||||
virtual ~DownloadItem();
|
virtual ~DownloadItem();
|
||||||
|
|
||||||
@ -81,7 +75,6 @@ class DownloadItem : public QWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
|
|
||||||
class WebBrowser;
|
class WebBrowser;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -106,9 +99,7 @@ class DownloadManager : public TabContent {
|
|||||||
virtual ~DownloadManager();
|
virtual ~DownloadManager();
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
WebBrowser* webBrowser() const {
|
virtual WebBrowser* webBrowser() const;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SilentNetworkAccessManager* networkManager() const;
|
SilentNetworkAccessManager* networkManager() const;
|
||||||
@ -160,6 +151,13 @@ class DownloadManager : public TabContent {
|
|||||||
QString m_downloadDirectory;
|
QString m_downloadDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
inline WebBrowser* DownloadManager::webBrowser() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class DownloadModel : public QAbstractListModel {
|
class DownloadModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -168,11 +166,11 @@ class DownloadModel : public QAbstractListModel {
|
|||||||
public:
|
public:
|
||||||
explicit DownloadModel(DownloadManager* download_manager, QObject* parent = nullptr);
|
explicit DownloadModel(DownloadManager* download_manager, QObject* parent = nullptr);
|
||||||
|
|
||||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
|
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
|
||||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DownloadManager* m_downloadManager;
|
DownloadManager* m_downloadManager;
|
||||||
|
@ -47,10 +47,10 @@ class GoogleSuggest : public QObject {
|
|||||||
public:
|
public:
|
||||||
explicit GoogleSuggest(LocationLineEdit* editor, QObject* parent = nullptr);
|
explicit GoogleSuggest(LocationLineEdit* editor, QObject* parent = nullptr);
|
||||||
|
|
||||||
bool eventFilter(QObject* object, QEvent* event);
|
virtual bool eventFilter(QObject* object, QEvent* event);
|
||||||
void showCompletion(const QStringList& choices);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void showCompletion(const QStringList& choices);
|
||||||
void doneCompletion();
|
void doneCompletion();
|
||||||
void preventSuggest();
|
void preventSuggest();
|
||||||
void autoSuggest();
|
void autoSuggest();
|
||||||
|
@ -73,6 +73,7 @@ class OAuthHttpHandler : public QObject {
|
|||||||
QPair<quint8, quint8> m_version;
|
QPair<quint8, quint8> m_version;
|
||||||
QMap<QByteArray, QByteArray> m_headers;
|
QMap<QByteArray, QByteArray> m_headers;
|
||||||
};
|
};
|
||||||
|
|
||||||
QMap<QTcpSocket*, QHttpRequest> m_connectedClients;
|
QMap<QTcpSocket*, QHttpRequest> m_connectedClients;
|
||||||
QTcpServer m_httpServer;
|
QTcpServer m_httpServer;
|
||||||
QHostAddress m_listenAddress;
|
QHostAddress m_listenAddress;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user