This commit is contained in:
Martin Rotter 2023-11-23 12:04:06 +01:00
parent 53c5994104
commit fed4560268
6 changed files with 85 additions and 68 deletions

View File

@ -160,7 +160,7 @@ Error: %1</source>
<context> <context>
<name>Application</name> <name>Application</name>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1147"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1155"/>
<source>Application is already running.</source> <source>Application is already running.</source>
<translation>Application is already running</translation> <translation>Application is already running</translation>
</message> </message>
@ -185,22 +185,22 @@ Error: %1</source>
<translation>Settings restoration was not initiated. Make sure that output directory is writable.</translation> <translation>Settings restoration was not initiated. Make sure that output directory is writable.</translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1165"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1173"/>
<source>Cannot add feed</source> <source>Cannot add feed</source>
<translation>Cannot add feed</translation> <translation>Cannot add feed</translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1166"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1174"/>
<source>Feed cannot be added because there is no active account which can add feeds.</source> <source>Feed cannot be added because there is no active account which can add feeds.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1324"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1332"/>
<source>Packages %1 were updated.</source> <source>Packages %1 were updated.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1031"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1039"/>
<source>Unread articles fetched</source> <source>Unread articles fetched</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -210,7 +210,7 @@ Error: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1096"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1104"/>
<source>AdBlock needs to be configured</source> <source>AdBlock needs to be configured</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -228,17 +228,17 @@ version by clicking this popup notification.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1097"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1105"/>
<source>AdBlock is not configured properly. Go to &quot;Settings&quot; -&gt; &quot;Node.js&quot; and check if your Node.js is properly configured.</source> <source>AdBlock is not configured properly. Go to &quot;Settings&quot; -&gt; &quot;Node.js&quot; and check if your Node.js is properly configured.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1146"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1154"/>
<source>Already running</source> <source>Already running</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/application.cpp" line="1315"/> <location filename="../src/librssguard/miscellaneous/application.cpp" line="1323"/>
<source>Packages %1 were NOT updated because of error: %2.</source> <source>Packages %1 were NOT updated because of error: %2.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -5732,37 +5732,37 @@ List of supported readers:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="598"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="608"/>
<source>interesting stuff</source> <source>interesting stuff</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="601"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="611"/>
<source>interesting stuff (highlighted)</source> <source>interesting stuff (highlighted)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="604"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="614"/>
<source>errored items</source> <source>errored items</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="607"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="617"/>
<source>errored items (highlighted)</source> <source>errored items (highlighted)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="610"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="620"/>
<source>items with new articles</source> <source>items with new articles</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="613"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="623"/>
<source>items with new articles (highlighted)</source> <source>items with new articles (highlighted)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="616"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="626"/>
<source>OK-ish color</source> <source>OK-ish color</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -7457,20 +7457,25 @@ Also, relaunch &quot;Settings&quot; dialog after you install Node.js.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="281"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="278"/>
<source>Written by </source> <source>Written by </source>
<translation type="unfinished">Written by </translation> <translation type="unfinished">Written by </translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="282"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="279"/>
<source>unknown author</source> <source>unknown author</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="297"/> <location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="294"/>
<source>Newspaper view</source> <source>Newspaper view</source>
<translation type="unfinished">Newspaper view</translation> <translation type="unfinished">Newspaper view</translation>
</message> </message>
<message>
<location filename="../src/librssguard/miscellaneous/skinfactory.cpp" line="526"/>
<source>file %1 not found</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SqliteDriver</name> <name>SqliteDriver</name>
@ -8041,12 +8046,12 @@ Unread news: %2</translation>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/gui/webviewers/qtextbrowser/textbrowserviewer.cpp" line="370"/> <location filename="../src/librssguard/gui/webviewers/qtextbrowser/textbrowserviewer.cpp" line="360"/>
<source>Enable external resources</source> <source>Enable external resources</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/librssguard/gui/webviewers/qtextbrowser/textbrowserviewer.cpp" line="372"/> <location filename="../src/librssguard/gui/webviewers/qtextbrowser/textbrowserviewer.cpp" line="362"/>
<source>Download</source> <source>Download</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -25,14 +25,14 @@ TextBrowserViewer::TextBrowserViewer(QWidget* parent)
m_placeholderImage(qApp->icons()->miscPixmap(QSL("image-placeholder"))), m_placeholderImage(qApp->icons()->miscPixmap(QSL("image-placeholder"))),
m_placeholderImageError(qApp->icons()->miscPixmap(QSL("image-placeholder-error"))), m_placeholderImageError(qApp->icons()->miscPixmap(QSL("image-placeholder-error"))),
m_downloader(new Downloader(this)), m_document(new TextBrowserDocument(this)) { m_downloader(new Downloader(this)), m_document(new TextBrowserDocument(this)) {
setAutoFillBackground(true); setAutoFillBackground(false);
setFrameShape(QFrame::Shape::NoFrame); setFrameShape(QFrame::Shape::NoFrame);
setFrameShadow(QFrame::Shadow::Plain); setFrameShadow(QFrame::Shadow::Plain);
setTabChangesFocus(true); setTabChangesFocus(true);
setOpenLinks(false); setOpenLinks(false);
setWordWrapMode(QTextOption::WrapMode::WordWrap); setWordWrapMode(QTextOption::WrapMode::WordWrap);
viewport()->setAutoFillBackground(true); viewport()->setAutoFillBackground(false);
setResourcesEnabled(qApp->settings()->value(GROUP(Messages), SETTING(Messages::ShowResourcesInArticles)).toBool()); setResourcesEnabled(qApp->settings()->value(GROUP(Messages), SETTING(Messages::ShowResourcesInArticles)).toBool());
setDocument(m_document.data()); setDocument(m_document.data());
@ -298,24 +298,14 @@ void TextBrowserViewer::loadMessages(const QList<Message>& messages, RootItem* r
emit loadingStarted(); emit loadingStarted();
m_root = root; m_root = root;
auto html_messages = prepareHtmlForMessage(messages, root); auto html_messages = qApp->skins()->generateHtmlOfArticles(messages, root);
// TODO: Make this switchable? To allow for more formatted output even in notwebengine. if (html_messages.m_html.isEmpty()) {
// auto html_messages = qApp->skins()->generateHtmlOfArticles(messages, root); html_messages = prepareHtmlForMessage(messages, root);
}
setHtml(html_messages.m_html, html_messages.m_baseUrl); setHtml(html_messages.m_html, html_messages.m_baseUrl);
/*
auto* feed = root != nullptr
? root->getParentServiceRoot()
->getItemFromSubTree([messages](const RootItem* it) {
return it->kind() == RootItem::Kind::Feed && it->customId() == messages.at(0).m_feedId;
})
->toFeed()
: nullptr;
bool is_rtl_feed = feed != nullptr && feed->isRtl();
*/
QTextOption op; QTextOption op;
op.setTextDirection(messages.at(0).m_isRtl ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight); op.setTextDirection(messages.at(0).m_isRtl ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight);
document()->setDefaultTextOption(op); document()->setDefaultTextOption(op);

View File

@ -148,7 +148,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
// and skin. // and skin.
m_icons->setupSearchPaths(); m_icons->setupSearchPaths();
m_icons->loadCurrentIconTheme(); m_icons->loadCurrentIconTheme();
m_skins->loadCurrentSkin(); m_skins->loadCurrentSkin(usingNoWebEngine());
if (m_toastNotifications != nullptr) { if (m_toastNotifications != nullptr) {
connect(m_toastNotifications, connect(m_toastNotifications,
@ -788,6 +788,14 @@ WebViewer* Application::createWebView() {
#endif #endif
} }
bool Application::usingNoWebEngine() const {
#if !defined(USE_WEBENGINE)
return true;
#else
return forcedNoWebEngine();
#endif
}
void Application::onCommitData(QSessionManager& manager) { void Application::onCommitData(QSessionManager& manager) {
qDebugNN << LOGSEC_CORE << "OS asked application to commit its data."; qDebugNN << LOGSEC_CORE << "OS asked application to commit its data.";

View File

@ -184,6 +184,8 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
WebViewer* createWebView(); WebViewer* createWebView();
bool usingNoWebEngine() const;
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
bool forcedNoWebEngine() const; bool forcedNoWebEngine() const;
#endif #endif

View File

@ -21,7 +21,7 @@
SkinFactory::SkinFactory(QObject* parent) : QObject(parent), m_styleIsFrozen(false), m_useSkinColors(false) {} SkinFactory::SkinFactory(QObject* parent) : QObject(parent), m_styleIsFrozen(false), m_useSkinColors(false) {}
void SkinFactory::loadCurrentSkin() { void SkinFactory::loadCurrentSkin(bool lite) {
QList<QString> skin_names_to_try = {selectedSkinName(), QSL(APP_SKIN_DEFAULT)}; QList<QString> skin_names_to_try = {selectedSkinName(), QSL(APP_SKIN_DEFAULT)};
bool skin_parsed; bool skin_parsed;
Skin skin_data; Skin skin_data;
@ -29,14 +29,14 @@ void SkinFactory::loadCurrentSkin() {
while (!skin_names_to_try.isEmpty()) { while (!skin_names_to_try.isEmpty()) {
skin_name = skin_names_to_try.takeFirst(); skin_name = skin_names_to_try.takeFirst();
skin_data = skinInfo(skin_name, &skin_parsed); skin_data = skinInfo(skin_name, lite, &skin_parsed);
if (skin_parsed) { if (skin_parsed) {
loadSkinFromData(skin_data); loadSkinFromData(skin_data);
// Set this 'Skin' object as active one. // Set this 'Skin' object as active one.
m_currentSkin = skin_data; m_currentSkin = skin_data;
qDebugNN << LOGSEC_GUI << "Skin" << QUOTE_W_SPACE(skin_name) << "loaded."; qDebugNN << LOGSEC_GUI << "Skin" << QUOTE_W_SPACE(skin_name) << "loaded. Lite:" << QUOTE_W_SPACE_DOT(lite);
return; return;
} }
else { else {
@ -242,9 +242,6 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages,
}) })
->toFeed() ->toFeed()
: nullptr; : nullptr;
/*
bool is_rtl_feed = feed != nullptr && feed->isRtl();
*/
for (const Message& message : messages) { for (const Message& message : messages) {
QString enclosures; QString enclosures;
@ -314,7 +311,7 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList<Message>& messages,
return {msg_contents, base_url}; return {msg_contents, base_url};
} }
Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const { Skin SkinFactory::skinInfo(const QString& skin_name, bool lite, bool* ok) const {
Skin skin; Skin skin;
const QStringList skins_root_folders = {APP_SKIN_PATH, customSkinBaseFolder()}; const QStringList skins_root_folders = {APP_SKIN_PATH, customSkinBaseFolder()};
@ -461,10 +458,11 @@ Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const {
// be safely loaded. // be safely loaded.
// //
// %style% placeholder is used in main wrapper HTML file to be replaced with custom skin-wide CSS. // %style% placeholder is used in main wrapper HTML file to be replaced with custom skin-wide CSS.
skin.m_layoutMarkupWrapper = loadSkinFile(skin_folder_no_sep, QSL("html_wrapper.html"), real_base_skin_folder); skin.m_layoutMarkupWrapper =
loadSkinFile(skin_folder_no_sep, lite, QSL("html_wrapper.html"), real_base_skin_folder);
try { try {
auto custom_css = loadSkinFile(skin_folder_no_sep, QSL("html_style.css"), real_base_skin_folder); auto custom_css = loadSkinFile(skin_folder_no_sep, lite, QSL("html_style.css"), real_base_skin_folder);
skin.m_layoutMarkupWrapper = skin.m_layoutMarkupWrapper.replace(QSL(SKIN_STYLE_PLACEHOLDER), custom_css); skin.m_layoutMarkupWrapper = skin.m_layoutMarkupWrapper.replace(QSL(SKIN_STYLE_PLACEHOLDER), custom_css);
} }
@ -473,12 +471,13 @@ Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const {
} }
skin.m_enclosureImageMarkup = skin.m_enclosureImageMarkup =
loadSkinFile(skin_folder_no_sep, QSL("html_enclosure_image.html"), real_base_skin_folder); loadSkinFile(skin_folder_no_sep, lite, QSL("html_enclosure_image.html"), real_base_skin_folder);
skin.m_layoutMarkup = loadSkinFile(skin_folder_no_sep, QSL("html_single_message.html"), real_base_skin_folder); skin.m_layoutMarkup =
loadSkinFile(skin_folder_no_sep, lite, QSL("html_single_message.html"), real_base_skin_folder);
skin.m_enclosureMarkup = skin.m_enclosureMarkup =
loadSkinFile(skin_folder_no_sep, QSL("html_enclosure_every.html"), real_base_skin_folder); loadSkinFile(skin_folder_no_sep, lite, QSL("html_enclosure_every.html"), real_base_skin_folder);
skin.m_rawData = loadSkinFile(skin_folder_no_sep, QSL("qt_style.qss"), real_base_skin_folder); skin.m_rawData = loadSkinFile(skin_folder_no_sep, lite, QSL("qt_style.qss"), real_base_skin_folder);
skin.m_adblocked = loadSkinFile(skin_folder_no_sep, QSL("html_adblocked.html"), real_base_skin_folder); skin.m_adblocked = loadSkinFile(skin_folder_no_sep, lite, QSL("html_adblocked.html"), real_base_skin_folder);
skin.m_skinFolder = skin_folder_no_sep; skin.m_skinFolder = skin_folder_no_sep;
if (ok != nullptr) { if (ok != nullptr) {
@ -498,22 +497,33 @@ Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const {
} }
QString SkinFactory::loadSkinFile(const QString& skin_folder, QString SkinFactory::loadSkinFile(const QString& skin_folder,
bool lite,
const QString& file_name, const QString& file_name,
const QString& base_folder) const { const QString& base_folder) const {
QString local_file = QDir::toNativeSeparators(skin_folder + QDir::separator() + file_name); QStringList prefixes = {QString()};
QString base_file = QDir::toNativeSeparators(base_folder + QDir::separator() + file_name);
QString data;
if (QFile::exists(local_file)) { if (lite) {
qDebugNN << LOGSEC_GUI << "Local file" << QUOTE_W_SPACE(local_file) << "exists, using it for the skin."; prefixes.prepend(QSL("lite_"));
data = QString::fromUtf8(IOFactory::readFile(local_file));
return data.replace(QSL(USER_DATA_PLACEHOLDER), skin_folder);
} }
else {
qDebugNN << LOGSEC_GUI << "Trying to load base file" << QUOTE_W_SPACE(base_file) << "for the skin."; for (const QString& prefix : prefixes) {
data = QString::fromUtf8(IOFactory::readFile(base_file)); QString local_file = QDir::toNativeSeparators(skin_folder + QDir::separator() + prefix + file_name);
return data.replace(QSL(USER_DATA_PLACEHOLDER), base_folder); QString base_file = QDir::toNativeSeparators(base_folder + QDir::separator() + prefix + file_name);
QString data;
if (QFile::exists(local_file)) {
qDebugNN << LOGSEC_GUI << "Local file" << QUOTE_W_SPACE(local_file) << "exists, using it for the skin.";
data = QString::fromUtf8(IOFactory::readFile(local_file));
return data.replace(QSL(USER_DATA_PLACEHOLDER), skin_folder);
}
else if (QFile::exists(base_file)) {
qDebugNN << LOGSEC_GUI << "Base file" << QUOTE_W_SPACE(base_file) << "exists, using it for the skin.";
data = QString::fromUtf8(IOFactory::readFile(base_file));
return data.replace(QSL(USER_DATA_PLACEHOLDER), base_folder);
}
} }
throw ApplicationException(tr("file %1 not found").arg(file_name));
} }
QString SkinFactory::currentStyle() const { QString SkinFactory::currentStyle() const {
@ -534,7 +544,7 @@ QList<Skin> SkinFactory::installedSkins() const {
.entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot | QDir::Filter::Readable)); .entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot | QDir::Filter::Readable));
for (const QString& base_directory : skin_directories) { for (const QString& base_directory : skin_directories) {
const Skin skin_info = skinInfo(base_directory, &skin_load_ok); const Skin skin_info = skinInfo(base_directory, false, &skin_load_ok);
if (skin_load_ok) { if (skin_load_ok) {
skins.append(skin_info); skins.append(skin_info);

View File

@ -88,7 +88,7 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
virtual ~SkinFactory() = default; virtual ~SkinFactory() = default;
// Loads skin name from settings and sets it as active. // Loads skin name from settings and sets it as active.
void loadCurrentSkin(); void loadCurrentSkin(bool lite);
Skin currentSkin() const; Skin currentSkin() const;
// Gets color for model from active skin. // Gets color for model from active skin.
@ -103,11 +103,10 @@ 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 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.
Skin skinInfo(const QString& skin_name, bool* ok = nullptr) const; Skin skinInfo(const QString& skin_name, bool lite, bool* ok = nullptr) const;
// Returns list of installed skins. // Returns list of installed skins.
QList<Skin> installedSkins() const; QList<Skin> installedSkins() const;
@ -123,7 +122,10 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
// Loads the skin from given skin_data. // Loads the skin from given skin_data.
void loadSkinFromData(const Skin& skin); void loadSkinFromData(const Skin& skin);
QString loadSkinFile(const QString& skin_folder, const QString& file_name, const QString& base_folder) const; QString loadSkinFile(const QString& skin_folder,
bool lite,
const QString& file_name,
const QString& base_folder) const;
// Holds name of the current skin. // Holds name of the current skin.
Skin m_currentSkin; Skin m_currentSkin;