windowsvista style default on windows

This commit is contained in:
Martin Rotter 2022-08-26 10:53:54 +02:00
parent 35e9f299a6
commit 3d93a40284
6 changed files with 159 additions and 156 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url> <url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="4.2.3" date="2022-08-22"/> <release version="4.2.3" date="2022-08-26"/>
</releases> </releases>
<content_rating type="oars-1.0"> <content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute> <content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -75,7 +75,10 @@ QStringList FeedsModel::mimeTypes() const {
return QStringList() << QSL(MIME_TYPE_ITEM_POINTER); return QStringList() << QSL(MIME_TYPE_ITEM_POINTER);
} }
bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, bool FeedsModel::dropMimeData(const QMimeData* data,
Qt::DropAction action,
int row,
int column,
const QModelIndex& parent) { const QModelIndex& parent) {
Q_UNUSED(row) Q_UNUSED(row)
Q_UNUSED(column) Q_UNUSED(column)
@ -106,8 +109,8 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
ServiceRoot* target_item_root = target_item->getParentServiceRoot(); ServiceRoot* target_item_root = target_item->getParentServiceRoot();
if (dragged_item == target_item || dragged_item->parent() == target_item) { if (dragged_item == target_item || dragged_item->parent() == target_item) {
qDebug( qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop "
"Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action."); "action.");
return false; return false;
} }
@ -154,27 +157,27 @@ QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int ro
} }
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
if (section == FDS_MODEL_TITLE_INDEX) { if (section == FDS_MODEL_TITLE_INDEX) {
return m_headerData.at(FDS_MODEL_TITLE_INDEX); return m_headerData.at(FDS_MODEL_TITLE_INDEX);
} }
else { else {
return QVariant();
}
case Qt::ToolTipRole:
return m_tooltipData.at(section);
case Qt::DecorationRole:
if (section == FDS_MODEL_COUNTS_INDEX) {
return m_countsIcon;
}
else {
return QVariant();
}
default:
return QVariant(); return QVariant();
}
case Qt::ToolTipRole:
return m_tooltipData.at(section);
case Qt::DecorationRole:
if (section == FDS_MODEL_COUNTS_INDEX) {
return m_countsIcon;
}
else {
return QVariant();
}
default:
return QVariant();
} }
} }
@ -309,36 +312,36 @@ QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
for (Feed* feed : qAsConst(stf)) { for (Feed* feed : qAsConst(stf)) {
switch (feed->autoUpdateType()) { switch (feed->autoUpdateType()) {
case Feed::AutoUpdateType::DontAutoUpdate: case Feed::AutoUpdateType::DontAutoUpdate:
// Do not auto-update this feed ever. // Do not auto-update this feed ever.
continue; continue;
case Feed::AutoUpdateType::DefaultAutoUpdate: case Feed::AutoUpdateType::DefaultAutoUpdate:
if (auto_update_now) { if (auto_update_now) {
feeds_for_update.append(feed); feeds_for_update.append(feed);
} }
break; break;
case Feed::AutoUpdateType::SpecificAutoUpdate: case Feed::AutoUpdateType::SpecificAutoUpdate:
default: default:
int remaining_interval = feed->autoUpdateRemainingInterval(); int remaining_interval = feed->autoUpdateRemainingInterval();
if (--remaining_interval <= 0) { if (--remaining_interval <= 0) {
// Interval of this feed passed, include this feed in the output list // Interval of this feed passed, include this feed in the output list
// and reset the interval. // and reset the interval.
feeds_for_update.append(feed); feeds_for_update.append(feed);
feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval()); feed->setAutoUpdateRemainingInterval(feed->autoUpdateInitialInterval());
} }
else { else {
// Interval did not pass, set new decremented interval and do NOT // Interval did not pass, set new decremented interval and do NOT
// include this feed in the output list. // include this feed in the output list.
feed->setAutoUpdateRemainingInterval(remaining_interval); feed->setAutoUpdateRemainingInterval(remaining_interval);
} }
break; break;
} }
} }
@ -445,8 +448,9 @@ void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
void FeedsModel::setupFonts() { void FeedsModel::setupFonts() {
QFont fon; QFont fon;
fon.fromString( fon.fromString(qApp->settings()
qApp->settings()->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString()).toString()); ->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString())
.toString());
m_normalFont = fon; m_normalFont = fon;
@ -473,7 +477,9 @@ bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
endInsertRows(); endInsertRows();
// Connect. // Connect.
connect(root, &ServiceRoot::itemRemovalRequested, this, connect(root,
&ServiceRoot::itemRemovalRequested,
this,
static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem)); static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent); connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged); connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);
@ -572,26 +578,26 @@ bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {
QVariant FeedsModel::data(const QModelIndex& index, int role) const { QVariant FeedsModel::data(const QModelIndex& index, int role) const {
switch (role) { switch (role) {
case Qt::ItemDataRole::FontRole: { case Qt::ItemDataRole::FontRole: {
RootItem* it = itemForIndex(index); RootItem* it = itemForIndex(index);
bool is_bold = it->countOfUnreadMessages() > 0; bool is_bold = it->countOfUnreadMessages() > 0;
bool is_striked = it->kind() == RootItem::Kind::Feed ? qobject_cast<Feed*>(it)->isSwitchedOff() : false; bool is_striked = it->kind() == RootItem::Kind::Feed ? qobject_cast<Feed*>(it)->isSwitchedOff() : false;
if (is_bold) { if (is_bold) {
return is_striked ? m_boldStrikedFont : m_boldFont; return is_striked ? m_boldStrikedFont : m_boldFont;
} }
else { else {
return is_striked ? m_normalStrikedFont : m_normalFont; return is_striked ? m_normalStrikedFont : m_normalFont;
} }
}
case Qt::ItemDataRole::ToolTipRole:
if (!qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::EnableTooltipsFeedsMessages)).toBool()) {
return QVariant();
} }
default: case Qt::ItemDataRole::ToolTipRole:
return itemForIndex(index)->data(index.column(), role); if (!qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::EnableTooltipsFeedsMessages)).toBool()) {
; return QVariant();
}
default:
return itemForIndex(index)->data(index.column(), role);
;
} }
} }

View File

@ -215,7 +215,12 @@
#define APP_SKIN_USER_FOLDER "skins" #define APP_SKIN_USER_FOLDER "skins"
#define APP_SKIN_DEFAULT "nudus-light" #define APP_SKIN_DEFAULT "nudus-light"
#define APP_SKIN_METADATA_FILE "metadata.xml" #define APP_SKIN_METADATA_FILE "metadata.xml"
#if defined(Q_OS_WIN)
#define APP_STYLE_DEFAULT "windowsvista"
#else
#define APP_STYLE_DEFAULT "Fusion" #define APP_STYLE_DEFAULT "Fusion"
#endif
#if defined(FORCE_BUNDLE_ICONS) #if defined(FORCE_BUNDLE_ICONS)
// Forcibly bundle icons. // Forcibly bundle icons.

View File

@ -20,9 +20,10 @@
#include <QThread> #include <QThread>
Feed::Feed(RootItem* parent) Feed::Feed(RootItem* parent)
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), : RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()),
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
m_isSwitchedOff(false), m_openArticlesDirectly(false), m_messageFilters(QList<QPointer<MessageFilter>>()) { m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_isSwitchedOff(false), m_openArticlesDirectly(false),
m_messageFilters(QList<QPointer<MessageFilter>>()) {
setKind(RootItem::Kind::Feed); setKind(RootItem::Kind::Feed);
} }
@ -187,9 +188,8 @@ void Feed::appendMessageFilter(MessageFilter* filter) {
void Feed::updateCounts(bool including_total_count) { void Feed::updateCounts(bool including_total_count) {
bool is_main_thread = QThread::currentThread() == qApp->thread(); bool is_main_thread = QThread::currentThread() == qApp->thread();
QSqlDatabase database = is_main_thread ? QSqlDatabase database = is_main_thread ? qApp->database()->driver()->connection(metaObject()->className())
qApp->database()->driver()->connection(metaObject()->className()) : : qApp->database()->driver()->connection(QSL("feed_upd"));
qApp->database()->driver()->connection(QSL("feed_upd"));
int account_id = getParentServiceRoot()->accountId(); int account_id = getParentServiceRoot()->accountId();
if (including_total_count) { if (including_total_count) {
@ -228,17 +228,19 @@ QString Feed::getAutoUpdateStatusDescription() const {
//: Describes feed auto-update status. //: Describes feed auto-update status.
auto_update_string = qApp->feedReader()->autoUpdateEnabled() auto_update_string = qApp->feedReader()->autoUpdateEnabled()
? tr("uses global settings (%n minute(s) to next auto-fetch of articles)", ? tr("uses global settings (%n minute(s) to next auto-fetch of articles)",
nullptr, nullptr,
qApp->feedReader()->autoUpdateRemainingInterval()) qApp->feedReader()->autoUpdateRemainingInterval())
: tr("uses global settings (global auto-fetching of articles is disabled)"); : tr("uses global settings (global auto-fetching of articles is disabled)");
break; break;
case AutoUpdateType::SpecificAutoUpdate: case AutoUpdateType::SpecificAutoUpdate:
default: default:
//: Describes feed auto-update status. //: Describes feed auto-update status.
auto_update_string = tr("uses specific settings (%n minute(s) to next auto-fetching of new articles)", nullptr, autoUpdateRemainingInterval()); auto_update_string = tr("uses specific settings (%n minute(s) to next auto-fetching of new articles)",
nullptr,
autoUpdateRemainingInterval());
break; break;
} }
@ -304,7 +306,10 @@ QString Feed::additionalTooltip() const {
return tr("Auto-update status: %1\n" return tr("Auto-update status: %1\n"
"Active message filters: %2\n" "Active message filters: %2\n"
"Status: %3").arg(getAutoUpdateStatusDescription(), "Status: %3")
QString::number(m_messageFilters.size()), .arg(getAutoUpdateStatusDescription(), QString::number(m_messageFilters.size()), stat);
stat); }
Qt::ItemFlags Feed::additionalFlags() const {
return Qt::ItemFlag::ItemNeverHasChildren;
} }

View File

@ -13,16 +13,11 @@
// Base class for "feed" nodes. // Base class for "feed" nodes.
class Feed : public RootItem { class Feed : public RootItem {
Q_OBJECT Q_OBJECT
public: public:
// Specifies the auto-download strategy for the feed. // Specifies the auto-download strategy for the feed.
enum class AutoUpdateType { enum class AutoUpdateType { DontAutoUpdate = 0, DefaultAutoUpdate = 1, SpecificAutoUpdate = 2 };
DontAutoUpdate = 0,
DefaultAutoUpdate = 1,
SpecificAutoUpdate = 2
};
// Specifies the actual "status" of the feed. // Specifies the actual "status" of the feed.
// For example if it has new messages, error // For example if it has new messages, error
@ -44,6 +39,7 @@ class Feed : public RootItem {
virtual QList<Message> undeletedMessages() const; virtual QList<Message> undeletedMessages() const;
virtual QString additionalTooltip() const; virtual QString additionalTooltip() const;
virtual Qt::ItemFlags additionalFlags() const;
virtual bool markAsReadUnread(ReadStatus status); virtual bool markAsReadUnread(ReadStatus status);
virtual bool cleanMessages(bool clean_read_only); virtual bool cleanMessages(bool clean_read_only);
virtual int countOfAllMessages() const; virtual int countOfAllMessages() const;

View File

@ -9,7 +9,6 @@
#include "exceptions/applicationexception.h" #include "exceptions/applicationexception.h"
#include "exceptions/networkexception.h" #include "exceptions/networkexception.h"
#include "exceptions/scriptexception.h" #include "exceptions/scriptexception.h"
#include "exceptions/scriptexception.h"
#include "gui/feedmessageviewer.h" #include "gui/feedmessageviewer.h"
#include "gui/feedsview.h" #include "gui/feedsview.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
@ -38,8 +37,7 @@
#include <QVariant> #include <QVariant>
#include <QXmlStreamReader> #include <QXmlStreamReader>
StandardFeed::StandardFeed(RootItem* parent_item) StandardFeed::StandardFeed(RootItem* parent_item) : Feed(parent_item) {
: Feed(parent_item) {
m_type = Type::Rss0X; m_type = Type::Rss0X;
m_sourceType = SourceType::Url; m_sourceType = SourceType::Url;
m_encoding = m_postProcessScript = QString(); m_encoding = m_postProcessScript = QString();
@ -49,8 +47,7 @@ StandardFeed::StandardFeed(RootItem* parent_item)
m_password = QString(); m_password = QString();
} }
StandardFeed::StandardFeed(const StandardFeed& other) StandardFeed::StandardFeed(const StandardFeed& other) : Feed(other) {
: Feed(other) {
m_type = other.type(); m_type = other.type();
m_postProcessScript = other.postProcessScript(); m_postProcessScript = other.postProcessScript();
m_sourceType = other.sourceType(); m_sourceType = other.sourceType();
@ -66,7 +63,8 @@ QList<QAction*> StandardFeed::contextMenuFeedsList() {
QString StandardFeed::additionalTooltip() const { QString StandardFeed::additionalTooltip() const {
return Feed::additionalTooltip() + tr("\nEncoding: %2\n" return Feed::additionalTooltip() + tr("\nEncoding: %2\n"
"Type: %3").arg(encoding(), StandardFeed::typeToString(type())); "Type: %3")
.arg(encoding(), StandardFeed::typeToString(type()));
} }
bool StandardFeed::canBeDeleted() const { bool StandardFeed::canBeDeleted() const {
@ -202,16 +200,14 @@ void StandardFeed::fetchMetadataForItself() {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className()); QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
DatabaseQueries::createOverwriteFeed(database, this, getParentServiceRoot()->accountId(), parent()->id()); DatabaseQueries::createOverwriteFeed(database, this, getParentServiceRoot()->accountId(), parent()->id());
serviceRoot()->itemChanged({ this }); serviceRoot()->itemChanged({this});
} }
catch (const ApplicationException& ex) { catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_DB qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message());
<< "Cannot overwrite feed:" qApp->showGuiMessage(Notification::Event::GeneralEvent,
<< QUOTE_W_SPACE_DOT(ex.message()); {tr("Cannot save feed data"),
qApp->showGuiMessage(Notification::Event::GeneralEvent, { tr("Cannot save data for feed: %1").arg(ex.message()),
tr("Cannot save feed data"), QSystemTrayIcon::MessageIcon::Critical});
tr("Cannot save data for feed: %1").arg(ex.message()),
QSystemTrayIcon::MessageIcon::Critical });
} }
} }
@ -237,23 +233,23 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
const QString& username, const QString& username,
const QString& password, const QString& password,
const QNetworkProxy& custom_proxy) { const QNetworkProxy& custom_proxy) {
auto timeout = qApp->settings()->value(GROUP(Feeds), auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray feed_contents; QByteArray feed_contents;
QString content_type; QString content_type;
if (source_type == StandardFeed::SourceType::Url) { if (source_type == StandardFeed::SourceType::Url) {
QList<QPair<QByteArray, QByteArray>> headers = { NetworkFactory::generateBasicAuthHeader(username, password) }; QList<QPair<QByteArray, QByteArray>> headers = {NetworkFactory::generateBasicAuthHeader(username, password)};
NetworkResult network_result = NetworkFactory::performNetworkOperation(source, NetworkResult network_result =
timeout, NetworkFactory::performNetworkOperation(source,
QByteArray(), timeout,
feed_contents, QByteArray(),
QNetworkAccessManager::Operation::GetOperation, feed_contents,
headers, QNetworkAccessManager::Operation::GetOperation,
false, headers,
{}, false,
{}, {},
custom_proxy); {},
custom_proxy);
content_type = network_result.m_contentType; content_type = network_result.m_contentType;
@ -262,18 +258,14 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
} }
} }
else { else {
qDebugNN << LOGSEC_CORE qDebugNN << LOGSEC_CORE << "Running custom script for guessing" << QUOTE_W_SPACE(source) << "to obtain feed data.";
<< "Running custom script for guessing"
<< QUOTE_W_SPACE(source)
<< "to obtain feed data.";
// Use script to generate feed file. // Use script to generate feed file.
feed_contents = generateFeedFileWithScript(source, timeout).toUtf8(); feed_contents = generateFeedFileWithScript(source, timeout).toUtf8();
} }
if (!post_process_script.simplified().isEmpty()) { if (!post_process_script.simplified().isEmpty()) {
qDebugNN << LOGSEC_CORE qDebugNN << LOGSEC_CORE << "Post-processing obtained feed data with custom script for guessing"
<< "Post-processing obtained feed data with custom script for guessing"
<< QUOTE_W_SPACE_DOT(post_process_script); << QUOTE_W_SPACE_DOT(post_process_script);
feed_contents = postProcessFeedFileWithScript(post_process_script, feed_contents, timeout).toUtf8(); feed_contents = postProcessFeedFileWithScript(post_process_script, feed_contents, timeout).toUtf8();
} }
@ -309,7 +301,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
auto home_page = json.object()[QSL("home_page_url")].toString(); auto home_page = json.object()[QSL("home_page_url")].toString();
if (!home_page.isEmpty()) { if (!home_page.isEmpty()) {
icon_possible_locations.prepend({ home_page, false }); icon_possible_locations.prepend({home_page, false});
} }
auto icon = json.object()[QSL("favicon")].toString(); auto icon = json.object()[QSL("favicon")].toString();
@ -320,7 +312,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
if (!icon.isEmpty()) { if (!icon.isEmpty()) {
// Low priority, download directly. // Low priority, download directly.
icon_possible_locations.append({ icon, true }); icon_possible_locations.append({icon, true});
} }
} }
else { else {
@ -328,8 +320,10 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
// its encoding before we can read further data. // its encoding before we can read further data.
QString xml_schema_encoding; QString xml_schema_encoding;
QString xml_contents_encoded; QString xml_contents_encoded;
QString enc = QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""), QString enc =
QRegularExpression::PatternOption::CaseInsensitiveOption).match(feed_contents).captured(1); QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""), QRegularExpression::PatternOption::CaseInsensitiveOption)
.match(feed_contents)
.captured(1);
if (!enc.isEmpty()) { if (!enc.isEmpty()) {
// Some "encoding" attribute was found get the encoding // Some "encoding" attribute was found get the encoding
@ -357,11 +351,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
QString error_msg; QString error_msg;
int error_line, error_column; int error_line, error_column;
if (!xml_document.setContent(xml_contents_encoded, if (!xml_document.setContent(xml_contents_encoded, true, &error_msg, &error_line, &error_column)) {
true,
&error_msg,
&error_line,
&error_column)) {
throw ApplicationException(tr("XML is not well-formed, %1").arg(error_msg)); throw ApplicationException(tr("XML is not well-formed, %1").arg(error_msg));
} }
@ -374,16 +364,20 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
if (root_element.namespaceURI() == rdf.rdfNamespace()) { if (root_element.namespaceURI() == rdf.rdfNamespace()) {
// We found RDF feed. // We found RDF feed.
QDomElement channel_element = root_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("channel")).at(0).toElement(); QDomElement channel_element =
root_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("channel")).at(0).toElement();
feed->setType(Type::Rdf); feed->setType(Type::Rdf);
feed->setTitle(channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("title")).at(0).toElement().text()); feed->setTitle(channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("title")).at(0).toElement().text());
feed->setDescription(channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("description")).at(0).toElement().text()); feed->setDescription(channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("description"))
.at(0)
.toElement()
.text());
QString home_page = channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("link")).at(0).toElement().text(); QString home_page = channel_element.elementsByTagNameNS(rdf.rssNamespace(), QSL("link")).at(0).toElement().text();
if (!home_page.isEmpty()) { if (!home_page.isEmpty()) {
icon_possible_locations.prepend({ home_page, false }); icon_possible_locations.prepend({home_page, false});
} }
} }
else if (root_element.tagName() == QL1S("rss")) { else if (root_element.tagName() == QL1S("rss")) {
@ -405,7 +399,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
QString icon_url_link = channel_element.namedItem(QSL("image")).namedItem(QSL("url")).toElement().text(); QString icon_url_link = channel_element.namedItem(QSL("image")).namedItem(QSL("url")).toElement().text();
if (!icon_url_link.isEmpty()) { if (!icon_url_link.isEmpty()) {
icon_possible_locations.append({ icon_url_link, true }); icon_possible_locations.append({icon_url_link, true});
} }
auto channel_links = channel_element.elementsByTagName(QSL("link")); auto channel_links = channel_element.elementsByTagName(QSL("link"));
@ -414,7 +408,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
QString home_page = channel_links.at(i).toElement().text(); QString home_page = channel_links.at(i).toElement().text();
if (!home_page.isEmpty()) { if (!home_page.isEmpty()) {
icon_possible_locations.prepend({ home_page, false }); icon_possible_locations.prepend({home_page, false});
break; break;
} }
} }
@ -428,13 +422,13 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
QString icon_link = root_element.namedItem(QSL("icon")).toElement().text(); QString icon_link = root_element.namedItem(QSL("icon")).toElement().text();
if (!icon_link.isEmpty()) { if (!icon_link.isEmpty()) {
icon_possible_locations.append({ icon_link, true }); icon_possible_locations.append({icon_link, true});
} }
QString home_page = root_element.namedItem(QSL("link")).toElement().attribute(QSL("href")); QString home_page = root_element.namedItem(QSL("link")).toElement().attribute(QSL("href"));
if (!home_page.isEmpty()) { if (!home_page.isEmpty()) {
icon_possible_locations.prepend({ home_page, false }); icon_possible_locations.prepend({home_page, false});
} }
} }
else { else {
@ -447,17 +441,14 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
if (source_type == SourceType::Url && icon_possible_locations.isEmpty()) { if (source_type == SourceType::Url && icon_possible_locations.isEmpty()) {
// We have no source for feed icon, we use the URL of the feed file itself. // We have no source for feed icon, we use the URL of the feed file itself.
icon_possible_locations.append({ source, false }); icon_possible_locations.append({source, false});
} }
// Try to obtain icon. // Try to obtain icon.
QIcon icon_data; QIcon icon_data;
if (NetworkFactory::downloadIcon(icon_possible_locations, if (NetworkFactory::downloadIcon(icon_possible_locations, DOWNLOAD_TIMEOUT, icon_data, {}, custom_proxy) ==
DOWNLOAD_TIMEOUT, QNetworkReply::NetworkError::NoError) {
icon_data,
{},
custom_proxy) == QNetworkReply::NetworkError::NoError) {
// Icon for feed was downloaded and is stored now in _icon_data. // Icon for feed was downloaded and is stored now in _icon_data.
feed->setIcon(icon_data); feed->setIcon(icon_data);
} }
@ -466,7 +457,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
} }
Qt::ItemFlags StandardFeed::additionalFlags() const { Qt::ItemFlags StandardFeed::additionalFlags() const {
return Qt::ItemFlag::ItemIsDragEnabled; return Feed::additionalFlags() | Qt::ItemFlag::ItemIsDragEnabled;
} }
bool StandardFeed::performDragDropChange(RootItem* target_item) { bool StandardFeed::performDragDropChange(RootItem* target_item) {
@ -478,14 +469,12 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) {
return true; return true;
} }
catch (const ApplicationException& ex) { catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_DB qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message());
<< "Cannot overwrite feed:"
<< QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent, { qApp->showGuiMessage(Notification::Event::GeneralEvent,
tr("Cannot move feed"), {tr("Cannot move feed"),
tr("Cannot move feed, detailed information was logged via debug log."), tr("Cannot move feed, detailed information was logged via debug log."),
QSystemTrayIcon::MessageIcon::Critical }); QSystemTrayIcon::MessageIcon::Critical});
return false; return false;
} }
} }
@ -518,8 +507,11 @@ QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
return qApp->replaceDataUserDataFolderPlaceholder(args); return qApp->replaceDataUserDataFolderPlaceholder(args);
} }
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory, QString StandardFeed::runScriptProcess(const QStringList& cmd_args,
int run_timeout, bool provide_input, const QString& input) { const QString& working_directory,
int run_timeout,
bool provide_input,
const QString& input) {
QProcess process; QProcess process;
if (provide_input) { if (provide_input) {
@ -547,8 +539,7 @@ QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QStrin
process.closeWriteChannel(); process.closeWriteChannel();
} }
if (process.waitForFinished(run_timeout) && if (process.waitForFinished(run_timeout) && process.exitStatus() == QProcess::ExitStatus::NormalExit &&
process.exitStatus() == QProcess::ExitStatus::NormalExit &&
process.exitCode() == EXIT_SUCCESS) { process.exitCode() == EXIT_SUCCESS) {
auto raw_output = process.readAllStandardOutput(); auto raw_output = process.readAllStandardOutput();
auto raw_error = process.readAllStandardError(); auto raw_error = process.readAllStandardError();