add #1032 but in a different way
This commit is contained in:
parent
f37d19e988
commit
b5c693ec42
3 changed files with 37 additions and 0 deletions
|
@ -181,6 +181,9 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
|
||||||
m_webFactory->engineProfile()->setHttpCacheType(QWebEngineProfile::HttpCacheType::DiskHttpCache);
|
m_webFactory->engineProfile()->setHttpCacheType(QWebEngineProfile::HttpCacheType::DiskHttpCache);
|
||||||
m_webFactory->engineProfile()->setPersistentStoragePath(web_data_root + QDir::separator() + QSL("storage"));
|
m_webFactory->engineProfile()->setPersistentStoragePath(web_data_root + QDir::separator() + QSL("storage"));
|
||||||
|
|
||||||
|
m_webFactory->loadCustomCss(userDataFolder() + QDir::separator() + QSL("web") + QDir::separator() +
|
||||||
|
QSL("user-styles.css"));
|
||||||
|
|
||||||
if (custom_ua.isEmpty()) {
|
if (custom_ua.isEmpty()) {
|
||||||
m_webFactory->engineProfile()->setHttpUserAgent(QString(HTTP_COMPLETE_USERAGENT));
|
m_webFactory->engineProfile()->setHttpUserAgent(QString(HTTP_COMPLETE_USERAGENT));
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,36 @@ bool WebFactory::sendMessageViaEmail(const Message& message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
void WebFactory::loadCustomCss(const QString user_styles_path) {
|
||||||
|
if (QFile::exists(user_styles_path)) {
|
||||||
|
QByteArray css_data = IOFactory::readFile(user_styles_path);
|
||||||
|
QString name = "rssguard-user-styles";
|
||||||
|
QWebEngineScript script;
|
||||||
|
QString s = QSL("(function() {"
|
||||||
|
" css = document.createElement('style');"
|
||||||
|
" css.type = 'text/css';"
|
||||||
|
" css.id = '%1';"
|
||||||
|
" document.head.appendChild(css);"
|
||||||
|
" css.innerText = '%2';"
|
||||||
|
"})()")
|
||||||
|
.arg(name, css_data.simplified());
|
||||||
|
script.setName(name);
|
||||||
|
script.setSourceCode(s);
|
||||||
|
script.setInjectionPoint(QWebEngineScript::DocumentReady);
|
||||||
|
script.setRunsOnSubFrames(false);
|
||||||
|
script.setWorldId(QWebEngineScript::ApplicationWorld);
|
||||||
|
|
||||||
|
m_engineProfile->scripts()->insert(script);
|
||||||
|
|
||||||
|
qDebugNN << LOGSEC_CORE << "Loading user CSS style file" << QUOTE_W_SPACE_DOT(user_styles_path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarningNN << LOGSEC_CORE << "User CSS style was not provided in file" << QUOTE_W_SPACE_DOT(user_styles_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
|
bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
|
||||||
qDebugNN << LOGSEC_NETWORK << "We are trying to open URL" << QUOTE_W_SPACE_DOT(url);
|
qDebugNN << LOGSEC_NETWORK << "We are trying to open URL" << QUOTE_W_SPACE_DOT(url);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,10 @@ class WebFactory : public QObject {
|
||||||
bool openUrlInExternalBrowser(const QString& url) const;
|
bool openUrlInExternalBrowser(const QString& url) const;
|
||||||
bool sendMessageViaEmail(const Message& message);
|
bool sendMessageViaEmail(const Message& message);
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
void loadCustomCss(const QString user_styles_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
QString customUserAgent() const;
|
QString customUserAgent() const;
|
||||||
void setCustomUserAgent(const QString& user_agent);
|
void setCustomUserAgent(const QString& user_agent);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue