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;
} }
@ -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);

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) {
@ -238,7 +238,9 @@ QString Feed::getAutoUpdateStatusDescription() const {
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

@ -16,13 +16,8 @@ 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 {
@ -205,11 +203,9 @@ void StandardFeed::fetchMetadataForItself() {
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 feed data"),
tr("Cannot save data for feed: %1").arg(ex.message()), tr("Cannot save data for feed: %1").arg(ex.message()),
QSystemTrayIcon::MessageIcon::Critical}); QSystemTrayIcon::MessageIcon::Critical});
} }
@ -237,14 +233,14 @@ 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 =
NetworkFactory::performNetworkOperation(source,
timeout, timeout,
QByteArray(), QByteArray(),
feed_contents, feed_contents,
@ -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();
} }
@ -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,11 +364,15 @@ 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();
@ -453,11 +447,8 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
// 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,12 +469,10 @@ 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();