diff --git a/resources/scripts/uncrustify/uncrustify.cfg b/resources/scripts/uncrustify/uncrustify.cfg index 3277a9f5d..ac8db63c5 100644 --- a/resources/scripts/uncrustify/uncrustify.cfg +++ b/resources/scripts/uncrustify/uncrustify.cfg @@ -239,10 +239,10 @@ nl_before_cpp_comment = 2 # unsigned number nl_before_class = 0 # unsigned number # 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. -nl_after_struct = 0 # unsigned number +nl_after_struct = 2 # unsigned number # The number of newlines after '}' of a multi-line function body nl_after_func_body = 2 # unsigned number diff --git a/src/librssguard/gui/discoverfeedsbutton.cpp b/src/librssguard/gui/discoverfeedsbutton.cpp index c44777719..875dfcfc6 100644 --- a/src/librssguard/gui/discoverfeedsbutton.cpp +++ b/src/librssguard/gui/discoverfeedsbutton.cpp @@ -29,8 +29,8 @@ void DiscoverFeedsButton::clearFeedAddresses() { void DiscoverFeedsButton::setFeedAddresses(const QStringList& addresses) { setEnabled(!addresses.isEmpty()); setToolTip(addresses.isEmpty() ? - 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("This website does not contain any feeds") : + tr("Add one of %n feed(s)", 0, addresses.size())); if (menu() == nullptr) { // Initialize the menu. diff --git a/src/librssguard/gui/feedmessageviewer.h b/src/librssguard/gui/feedmessageviewer.h index d4303315a..26caa3f84 100644 --- a/src/librssguard/gui/feedmessageviewer.h +++ b/src/librssguard/gui/feedmessageviewer.h @@ -32,7 +32,7 @@ class RSSGUARD_DLLSPEC FeedMessageViewer : public TabContent { virtual ~FeedMessageViewer(); #if defined(USE_WEBENGINE) - WebBrowser* webBrowser() const; + virtual WebBrowser* webBrowser() const; #endif FeedsView* feedsView() const; diff --git a/src/librssguard/gui/newspaperpreviewer.h b/src/librssguard/gui/newspaperpreviewer.h index a789ba54e..a6a388efd 100644 --- a/src/librssguard/gui/newspaperpreviewer.h +++ b/src/librssguard/gui/newspaperpreviewer.h @@ -31,7 +31,7 @@ class NewspaperPreviewer : public TabContent { explicit NewspaperPreviewer(int msg_height, RootItem* root, QList messages, QWidget* parent = nullptr); #if defined(USE_WEBENGINE) - WebBrowser* webBrowser() const; + virtual WebBrowser* webBrowser() const; #endif public slots: diff --git a/src/librssguard/gui/tabcontent.h b/src/librssguard/gui/tabcontent.h index 3b382e02c..05eaf0b36 100644 --- a/src/librssguard/gui/tabcontent.h +++ b/src/librssguard/gui/tabcontent.h @@ -23,7 +23,6 @@ class TabContent : public QWidget { virtual void setIndex(int index); #if defined(USE_WEBENGINE) - // Obtains instance contained in this TabContent or nullptr. // This can be used for obtaining the menu from the instance and so on. virtual WebBrowser* webBrowser() const = 0; diff --git a/src/librssguard/gui/webbrowser.cpp b/src/librssguard/gui/webbrowser.cpp index 6feebb861..80d508073 100644 --- a/src/librssguard/gui/webbrowser.cpp +++ b/src/librssguard/gui/webbrowser.cpp @@ -9,6 +9,7 @@ #include "gui/webviewer.h" #include "miscellaneous/application.h" #include "miscellaneous/databasequeries.h" +#include "miscellaneous/iconfactory.h" #include "network-web/networkfactory.h" #include "network-web/webfactory.h" #include "services/abstract/serviceroot.h" @@ -31,7 +32,10 @@ WebBrowser::WebBrowser(QWidget* parent) : TabContent(parent), m_actionBack(m_webView->pageAction(QWebEnginePage::Back)), m_actionForward(m_webView->pageAction(QWebEnginePage::Forward)), 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. initializeLayout(); setFocusProxy(m_txtLocation); @@ -58,6 +62,8 @@ void WebBrowser::createConnections() { m_searchWidget->setFocus(); }); + connect(m_actionOpenInSystemBrowser, &QAction::triggered, this, &WebBrowser::openCurrentSiteInSystemBrowser); + connect(m_txtLocation, &LocationLineEdit::submitted, this, static_cast(&WebBrowser::loadUrl)); connect(m_webView, &WebViewer::urlChanged, this, &WebBrowser::updateUrl); @@ -172,6 +178,22 @@ bool WebBrowser::eventFilter(QObject* watched, QEvent* event) { 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) { if (new_title.isEmpty()) { //: Webbrowser tab title when no title is available. @@ -189,19 +211,16 @@ void WebBrowser::onIconChanged(const QIcon& icon) { void WebBrowser::initializeLayout() { m_toolBar->setFloatable(false); m_toolBar->setMovable(false); - m_toolBar->setAllowedAreas(Qt::TopToolBarArea); + m_toolBar->setAllowedAreas(Qt::ToolBarArea::TopToolBarArea); // Modify action texts. m_actionBack->setText(tr("Back")); - m_actionBack->setToolTip(tr("Go back.")); m_actionForward->setText(tr("Forward")); - m_actionForward->setToolTip(tr("Go forward.")); m_actionReload->setText(tr("Reload")); - m_actionReload->setToolTip(tr("Reload current web page.")); m_actionStop->setText(tr("Stop")); - m_actionStop->setToolTip(tr("Stop web page loading.")); QWidgetAction* act_discover = new QWidgetAction(this); + m_actionOpenInSystemBrowser->setEnabled(false); act_discover->setDefaultWidget(m_btnDiscoverFeeds); // Add needed actions into toolbar. @@ -209,6 +228,7 @@ void WebBrowser::initializeLayout() { m_toolBar->addAction(m_actionForward); m_toolBar->addAction(m_actionReload); m_toolBar->addAction(m_actionStop); + m_toolBar->addAction(m_actionOpenInSystemBrowser); m_toolBar->addAction(act_discover); m_toolBar->addWidget(m_txtLocation); m_loadingProgress = new QProgressBar(this); @@ -232,6 +252,7 @@ void WebBrowser::initializeLayout() { void WebBrowser::onLoadingStarted() { m_btnDiscoverFeeds->clearFeedAddresses(); m_loadingProgress->show(); + m_actionOpenInSystemBrowser->setEnabled(false); } void WebBrowser::onLoadingProgress(int progress) { @@ -240,6 +261,12 @@ void WebBrowser::onLoadingProgress(int progress) { void WebBrowser::onLoadingFinished(bool 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 // display "Add feeds" button. m_webView->page()->toHtml([this](const QString& result) { @@ -252,7 +279,6 @@ void WebBrowser::onLoadingFinished(bool success) { m_loadingProgress->hide(); m_loadingProgress->setValue(0); - } Message* WebBrowser::findMessage(int id) { diff --git a/src/librssguard/gui/webbrowser.h b/src/librssguard/gui/webbrowser.h index 2ef027e5c..b496d2965 100644 --- a/src/librssguard/gui/webbrowser.h +++ b/src/librssguard/gui/webbrowser.h @@ -31,7 +31,8 @@ class WebBrowser : public TabContent { explicit WebBrowser(QWidget* parent = nullptr); virtual ~WebBrowser(); - WebBrowser* webBrowser() const; + virtual WebBrowser* webBrowser() const; + WebViewer* viewer() const; double verticalScrollBarPosition() const; @@ -54,8 +55,8 @@ class WebBrowser : public TabContent { virtual bool eventFilter(QObject* watched, QEvent* event); private slots: + void openCurrentSiteInSystemBrowser(); void updateUrl(const QUrl& url); - void onLoadingStarted(); void onLoadingProgress(int progress); void onLoadingFinished(bool success); @@ -85,6 +86,7 @@ class WebBrowser : public TabContent { QAction* m_actionForward; QAction* m_actionReload; QAction* m_actionStop; + QAction* m_actionOpenInSystemBrowser; QList m_messages; QPointer m_root; }; diff --git a/src/librssguard/network-web/downloadmanager.h b/src/librssguard/network-web/downloadmanager.h index 4fc8b0049..8786e3971 100644 --- a/src/librssguard/network-web/downloadmanager.h +++ b/src/librssguard/network-web/downloadmanager.h @@ -14,23 +14,17 @@ #include class AutoSaver; - class DownloadModel; - class QFileIconProvider; - class QMimeData; class DownloadItem : public QWidget { Q_OBJECT - // Friends of this class. friend class DownloadManager; friend class DownloadModel; public: - - // Constructors. explicit DownloadItem(QNetworkReply* reply = 0, QWidget* parent = nullptr); virtual ~DownloadItem(); @@ -81,7 +75,6 @@ class DownloadItem : public QWidget { }; #if defined(USE_WEBENGINE) - class WebBrowser; #endif @@ -106,9 +99,7 @@ class DownloadManager : public TabContent { virtual ~DownloadManager(); #if defined(USE_WEBENGINE) - WebBrowser* webBrowser() const { - return nullptr; - } + virtual WebBrowser* webBrowser() const; #endif SilentNetworkAccessManager* networkManager() const; @@ -160,6 +151,13 @@ class DownloadManager : public TabContent { QString m_downloadDirectory; }; +#if defined(USE_WEBENGINE) +inline WebBrowser* DownloadManager::webBrowser() const { + return nullptr; +} + +#endif + class DownloadModel : public QAbstractListModel { Q_OBJECT @@ -168,11 +166,11 @@ class DownloadModel : public QAbstractListModel { public: explicit DownloadModel(DownloadManager* download_manager, QObject* parent = nullptr); - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); - Qt::ItemFlags flags(const QModelIndex& index) const; - QMimeData* mimeData(const QModelIndexList& indexes) const; + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); + virtual Qt::ItemFlags flags(const QModelIndex& index) const; + virtual QMimeData* mimeData(const QModelIndexList& indexes) const; private: DownloadManager* m_downloadManager; diff --git a/src/librssguard/network-web/googlesuggest.h b/src/librssguard/network-web/googlesuggest.h index 621f799b1..83ca844ba 100644 --- a/src/librssguard/network-web/googlesuggest.h +++ b/src/librssguard/network-web/googlesuggest.h @@ -47,10 +47,10 @@ class GoogleSuggest : public QObject { public: explicit GoogleSuggest(LocationLineEdit* editor, QObject* parent = nullptr); - bool eventFilter(QObject* object, QEvent* event); - void showCompletion(const QStringList& choices); + virtual bool eventFilter(QObject* object, QEvent* event); public slots: + void showCompletion(const QStringList& choices); void doneCompletion(); void preventSuggest(); void autoSuggest(); diff --git a/src/librssguard/network-web/oauthhttphandler.h b/src/librssguard/network-web/oauthhttphandler.h index d7315d50b..f6e58bd6f 100644 --- a/src/librssguard/network-web/oauthhttphandler.h +++ b/src/librssguard/network-web/oauthhttphandler.h @@ -73,6 +73,7 @@ class OAuthHttpHandler : public QObject { QPair m_version; QMap m_headers; }; + QMap m_connectedClients; QTcpServer m_httpServer; QHostAddress m_listenAddress;