make readability use skins colors

This commit is contained in:
Martin Rotter 2023-07-25 08:55:18 +02:00
parent 03bd2e2baa
commit 7d62aa44fc
10 changed files with 29 additions and 8 deletions

View file

@ -268,7 +268,7 @@ void WebBrowser::newWindowRequested(WebViewer* viewer) {
void WebBrowser::setReadabledHtml(const QString& better_html) { void WebBrowser::setReadabledHtml(const QString& better_html) {
if (!better_html.isEmpty()) { if (!better_html.isEmpty()) {
m_webView->setHtml(better_html, m_webView->url()); m_webView->setReadabledHtml(better_html, m_webView->url());
} }
} }

View file

@ -556,6 +556,10 @@ void TextBrowserViewer::setHtml(const QString& html, const QUrl& base_url) {
*/ */
} }
void TextBrowserViewer::setReadabledHtml(const QString& html, const QUrl& base_url) {
setHtml(html, base_url);
}
void TextBrowserViewer::setHtmlPrivate(const QString& html, const QUrl& base_url) { void TextBrowserViewer::setHtmlPrivate(const QString& html, const QUrl& base_url) {
m_currentUrl = base_url; m_currentUrl = base_url;
m_currentHtml = html; m_currentHtml = html;

View file

@ -51,6 +51,7 @@ class TextBrowserViewer : public QTextBrowser, public WebViewer {
virtual void findText(const QString& text, bool backwards); virtual void findText(const QString& text, bool backwards);
virtual void setUrl(const QUrl& url); virtual void setUrl(const QUrl& url);
virtual void setHtml(const QString& html, const QUrl& base_url = {}); virtual void setHtml(const QString& html, const QUrl& base_url = {});
virtual void setReadabledHtml(const QString& html, const QUrl& base_url = {});
virtual QString html() const; virtual QString html() const;
virtual QUrl url() const; virtual QUrl url() const;
virtual void clear(); virtual void clear();

View file

@ -197,6 +197,12 @@ void WebEngineViewer::setHtml(const QString& html, const QUrl& base_url) {
QWebEngineView::setHtml(html, base_url); QWebEngineView::setHtml(html, base_url);
} }
void WebEngineViewer::setReadabledHtml(const QString& html, const QUrl& base_url) {
auto better_html = qApp->skins()->prepareHtml(html, base_url);
setHtml(better_html.m_html, better_html.m_baseUrl);
}
double WebEngineViewer::verticalScrollBarPosition() const { double WebEngineViewer::verticalScrollBarPosition() const {
double position; double position;
QEventLoop loop; QEventLoop loop;

View file

@ -29,6 +29,7 @@ class WebEngineViewer : public QWebEngineView, public WebViewer {
virtual void findText(const QString& text, bool backwards); virtual void findText(const QString& text, bool backwards);
virtual void setUrl(const QUrl& url); virtual void setUrl(const QUrl& url);
virtual void setHtml(const QString& html, const QUrl& base_url = {}); virtual void setHtml(const QString& html, const QUrl& base_url = {});
virtual void setReadabledHtml(const QString& html, const QUrl& base_url = {});
virtual void clear(); virtual void clear();
virtual double verticalScrollBarPosition() const; virtual double verticalScrollBarPosition() const;
virtual void setVerticalScrollBarPosition(double pos); virtual void setVerticalScrollBarPosition(double pos);

View file

@ -38,6 +38,9 @@ class WebViewer {
// Set static HTML into the viewer. // Set static HTML into the viewer.
virtual void setHtml(const QString& html, const QUrl& base_url = {}) = 0; virtual void setHtml(const QString& html, const QUrl& base_url = {}) = 0;
// Set HTML generated by "readability" into the viewer.
virtual void setReadabledHtml(const QString& html, const QUrl& base_url = {}) = 0;
// Returns current static HTML loaded in the viewer. // Returns current static HTML loaded in the viewer.
virtual QString html() const = 0; virtual QString html() const = 0;

View file

@ -78,7 +78,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
m_settings = Settings::setupSettings(this); m_settings = Settings::setupSettings(this);
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
if (!m_forcedNoWebEngine && qgetenv("QTWEBENGINE_CHROMIUM_FLAGS").isEmpty()) { if (!m_forcedNoWebEngine && qEnvironmentVariableIsEmpty("QTWEBENGINE_CHROMIUM_FLAGS")) {
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", qputenv("QTWEBENGINE_CHROMIUM_FLAGS",
settings()->value(GROUP(Browser), SETTING(Browser::WebEngineChromiumFlags)).toString().toLocal8Bit()); settings()->value(GROUP(Browser), SETTING(Browser::WebEngineChromiumFlags)).toString().toLocal8Bit());
} }
@ -292,8 +292,7 @@ void Application::loadDynamicShortcuts() {
DynamicShortcuts::load(userActions()); DynamicShortcuts::load(userActions());
} }
void Application::showPolls() const { void Application::offerPolls() const {
/*
if (isFirstRunCurrentVersion()) { if (isFirstRunCurrentVersion()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent,
{QSL("%1 survey").arg(QSL(APP_NAME)), {QSL("%1 survey").arg(QSL(APP_NAME)),
@ -301,10 +300,11 @@ void Application::showPolls() const {
QSystemTrayIcon::MessageIcon::Warning}, QSystemTrayIcon::MessageIcon::Warning},
{false, true, false}, {false, true, false},
{tr("Go to survey"), [] { {tr("Go to survey"), [] {
qApp->web()->openUrlInExternalBrowser(QSL("https://forms.gle/FdzrwFGozCGViK8QA")); qApp->web()->openUrlInExternalBrowser(QSL("https://docs.google.com/forms/d/e/"
"1FAIpQLScQ_r_EwM6qojPsIMQHGdnSktU-WGHgporN69mpU-"
"Tvq8y7XQ/viewform?usp=sf_link"));
}}); }});
} }
*/
} }
void Application::offerChanges() const { void Application::offerChanges() const {
@ -625,7 +625,7 @@ void Application::showTrayIcon() {
trayIcon()->show(); trayIcon()->show();
offerChanges(); offerChanges();
showPolls(); offerPolls();
} }
else { else {
m_feedReader->feedsModel()->notifyWithCounts(); m_feedReader->feedsModel()->notifyWithCounts();

View file

@ -89,7 +89,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
void reactOnForeignNotifications(); void reactOnForeignNotifications();
void hideOrShowMainForm(); void hideOrShowMainForm();
void loadDynamicShortcuts(); void loadDynamicShortcuts();
void showPolls() const; void offerPolls() const;
void offerChanges() const; void offerChanges() const;
bool isAlreadyRunning(); bool isAlreadyRunning();

View file

@ -224,6 +224,10 @@ QString SkinFactory::adBlockedPage(const QString& url, const QString& filter) {
return currentSkin().m_layoutMarkupWrapper.arg(tr("This page was blocked by AdBlock"), adblocked); return currentSkin().m_layoutMarkupWrapper.arg(tr("This page was blocked by AdBlock"), adblocked);
} }
PreparedHtml SkinFactory::prepareHtml(const QString& inner_html, const QUrl& base_url) {
return {currentSkin().m_layoutMarkupWrapper.arg(QString(), inner_html), base_url};
}
PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages, RootItem* root) const { PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages, RootItem* root) const {
Skin skin = currentSkin(); Skin skin = currentSkin();
QString messages_layout; QString messages_layout;

View file

@ -102,6 +102,8 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
QString adBlockedPage(const QString& url, const QString& filter); QString adBlockedPage(const QString& url, const QString& filter);
PreparedHtml prepareHtml(const QString& inner_html, const QUrl& base_url);
PreparedHtml generateHtmlOfArticles(const QList<Message>& messages, RootItem* root) const; PreparedHtml generateHtmlOfArticles(const QList<Message>& messages, RootItem* root) const;
// Gets skin about a particular skin. // Gets skin about a particular skin.