diff --git a/src/librssguard/gui/litehtml/litehtmlviewer.cpp b/src/librssguard/gui/litehtml/litehtmlviewer.cpp
index 36866bb03..5e841be0f 100755
--- a/src/librssguard/gui/litehtml/litehtmlviewer.cpp
+++ b/src/librssguard/gui/litehtml/litehtmlviewer.cpp
@@ -16,6 +16,7 @@
LiteHtmlViewer::LiteHtmlViewer(QWidget* parent) : QLiteHtmlWidget(parent) {
setResourceHandler([this](const QUrl& url) {
+ emit loadProgress(-1);
return handleResource(url);
});
}
@@ -30,19 +31,11 @@ void LiteHtmlViewer::bindToBrowser(WebBrowser* browser) {
connect(this, &LiteHtmlViewer::linkHighlighted, browser, [browser](const QUrl& url) {
browser->onLinkHovered(url.toString());
});
-
- // TODO: změna ikon, změna stavu akcí.
-
- /*
- connect(this, &WebEngineViewer::urlChanged, browser, &WebBrowser::updateUrl);
- connect(this, &WebEngineViewer::loadStarted, browser, &WebBrowser::onLoadingStarted);
- connect(this, &WebEngineViewer::loadProgress, browser, &WebBrowser::onLoadingProgress);
- connect(this, &WebEngineViewer::loadFinished, browser, &WebBrowser::onLoadingFinished);
- connect(this, &WebEngineViewer::titleChanged, browser, &WebBrowser::onTitleChanged);
- connect(this, &WebEngineViewer::iconChanged, browser, &WebBrowser::onIconChanged);
-
- connect(page(), &WebEnginePage::windowCloseRequested, browser, &WebBrowser::closeRequested);
- */
+ connect(this, &LiteHtmlViewer::titleChanged, browser, &WebBrowser::onTitleChanged);
+ connect(this, &LiteHtmlViewer::urlChanged, browser, &WebBrowser::updateUrl);
+ connect(this, &LiteHtmlViewer::loadStarted, browser, &WebBrowser::onLoadingStarted);
+ connect(this, &LiteHtmlViewer::loadProgress, browser, &WebBrowser::onLoadingProgress);
+ connect(this, &LiteHtmlViewer::loadFinished, browser, &WebBrowser::onLoadingFinished);
}
void LiteHtmlViewer::findText(const QString& text, bool backwards) {
@@ -52,21 +45,48 @@ void LiteHtmlViewer::findText(const QString& text, bool backwards) {
}
void LiteHtmlViewer::setUrl(const QUrl& url) {
- QByteArray output;
+ emit loadStarted();
+ AdblockRequestInfo block_request(url);
- NetworkFactory::performNetworkOperation(
+ if (url.path().endsWith(QSL("css"))) {
+ block_request.setResourceType(QSL("stylesheet"));
+ }
+ else {
+ block_request.setResourceType(QSL("image"));
+ }
+
+ if (qApp->web()->adBlock()->block(block_request).m_blocked) {
+ qWarningNN << LOGSEC_ADBLOCK << "Blocked request:" << QUOTE_W_SPACE_DOT(block_request.requestUrl().toString());
+ return;
+ }
+
+ QByteArray output;
+ auto net_res = NetworkFactory::performNetworkOperation(
url.toString(),
5000,
{},
output,
QNetworkAccessManager::Operation::GetOperation);
+ QString html_str;
- setHtml(QString::fromUtf8(output), url);
+ if (net_res.m_networkError != QNetworkReply::NetworkError::NoError) {
+ html_str = "Error!";
+ }
+ else {
+ html_str = QString::fromUtf8(output);
+ }
+
+ setHtml(html_str, url);
+
+ emit loadFinished(net_res.m_networkError == QNetworkReply::NetworkError::NoError);
}
void LiteHtmlViewer::setHtml(const QString& html, const QUrl& base_url) {
QLiteHtmlWidget::setUrl(base_url);
QLiteHtmlWidget::setHtml(html);
+
+ emit titleChanged(title());
+ emit urlChanged(base_url);
}
QString LiteHtmlViewer::html() const {
@@ -151,6 +171,7 @@ void LiteHtmlViewer::loadMessages(const QList& messages, RootItem* root
}
setHtml(msg_contents, QUrl::fromUserInput(base_url));
+ emit loadFinished(true);
}
double LiteHtmlViewer::verticalScrollBarPosition() const {
diff --git a/src/librssguard/gui/litehtml/litehtmlviewer.h b/src/librssguard/gui/litehtml/litehtmlviewer.h
index 8736be1d2..065f23372 100755
--- a/src/librssguard/gui/litehtml/litehtmlviewer.h
+++ b/src/librssguard/gui/litehtml/litehtmlviewer.h
@@ -35,6 +35,11 @@ class LiteHtmlViewer : public QLiteHtmlWidget, public WebViewer {
signals:
void zoomFactorChanged();
+ void titleChanged(const QString& new_title);
+ void urlChanged(const QUrl& url);
+ void loadStarted();
+ void loadProgress(int progress);
+ void loadFinished(bool success);
protected:
virtual void wheelEvent(QWheelEvent* event);
diff --git a/src/librssguard/gui/webbrowser.cpp b/src/librssguard/gui/webbrowser.cpp
index ccb333908..89b6b4f47 100644
--- a/src/librssguard/gui/webbrowser.cpp
+++ b/src/librssguard/gui/webbrowser.cpp
@@ -270,7 +270,7 @@ void WebBrowser::initializeLayout() {
m_toolBar->addWidget(m_txtLocation);
m_loadingProgress = new QProgressBar(this);
- m_loadingProgress->setFixedHeight(5);
+ m_loadingProgress->setFixedHeight(10);
m_loadingProgress->setMinimum(0);
m_loadingProgress->setTextVisible(false);
m_loadingProgress->setMaximum(100);
@@ -295,7 +295,8 @@ void WebBrowser::onLoadingStarted() {
}
void WebBrowser::onLoadingProgress(int progress) {
- m_loadingProgress->setValue(progress);
+ m_loadingProgress->setMaximum(progress < 0 ? 0 : 100);
+ m_loadingProgress->setValue(progress < 0 ? 0 : progress);
}
void WebBrowser::onLoadingFinished(bool success) {
diff --git a/src/librssguard/gui/webengine/webengineviewer.h b/src/librssguard/gui/webengine/webengineviewer.h
index cd269daec..5120e27c3 100644
--- a/src/librssguard/gui/webengine/webengineviewer.h
+++ b/src/librssguard/gui/webengine/webengineviewer.h
@@ -40,8 +40,8 @@ class WebEngineViewer : public QWebEngineView, public WebViewer {
virtual QString html() const;
virtual QUrl url() const;
- signals:
- void zoomFactorChanged();
+ signals:
+ void zoomFactorChanged();
protected:
virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);