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>
<content_rating type="oars-1.1" />
<releases>
<release version="4.2.3" date="2022-08-22"/>
<release version="4.2.3" date="2022-08-26"/>
</releases>
<content_rating type="oars-1.0">
<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);
}
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) {
Q_UNUSED(row)
Q_UNUSED(column)
@ -106,8 +109,8 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
ServiceRoot* target_item_root = target_item->getParentServiceRoot();
if (dragged_item == target_item || dragged_item->parent() == target_item) {
qDebug(
"Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action.");
qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop "
"action.");
return false;
}
@ -445,8 +448,9 @@ void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
void FeedsModel::setupFonts() {
QFont fon;
fon.fromString(
qApp->settings()->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString()).toString());
fon.fromString(qApp->settings()
->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString())
.toString());
m_normalFont = fon;
@ -473,7 +477,9 @@ bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
endInsertRows();
// Connect.
connect(root, &ServiceRoot::itemRemovalRequested, this,
connect(root,
&ServiceRoot::itemRemovalRequested,
this,
static_cast<void (FeedsModel::*)(RootItem*)>(&FeedsModel::removeItem));
connect(root, &ServiceRoot::itemReassignmentRequested, this, &FeedsModel::reassignNodeToNewParent);
connect(root, &ServiceRoot::dataChanged, this, &FeedsModel::onItemDataChanged);

View File

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

View File

@ -20,9 +20,10 @@
#include <QThread>
Feed::Feed(RootItem* parent)
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate),
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
m_isSwitchedOff(false), m_openArticlesDirectly(false), m_messageFilters(QList<QPointer<MessageFilter>>()) {
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()),
m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_isSwitchedOff(false), m_openArticlesDirectly(false),
m_messageFilters(QList<QPointer<MessageFilter>>()) {
setKind(RootItem::Kind::Feed);
}
@ -187,9 +188,8 @@ void Feed::appendMessageFilter(MessageFilter* filter) {
void Feed::updateCounts(bool including_total_count) {
bool is_main_thread = QThread::currentThread() == qApp->thread();
QSqlDatabase database = is_main_thread ?
qApp->database()->driver()->connection(metaObject()->className()) :
qApp->database()->driver()->connection(QSL("feed_upd"));
QSqlDatabase database = is_main_thread ? qApp->database()->driver()->connection(metaObject()->className())
: qApp->database()->driver()->connection(QSL("feed_upd"));
int account_id = getParentServiceRoot()->accountId();
if (including_total_count) {
@ -238,7 +238,9 @@ QString Feed::getAutoUpdateStatusDescription() const {
default:
//: 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;
}
@ -304,7 +306,10 @@ QString Feed::additionalTooltip() const {
return tr("Auto-update status: %1\n"
"Active message filters: %2\n"
"Status: %3").arg(getAutoUpdateStatusDescription(),
QString::number(m_messageFilters.size()),
stat);
"Status: %3")
.arg(getAutoUpdateStatusDescription(), QString::number(m_messageFilters.size()), stat);
}
Qt::ItemFlags Feed::additionalFlags() const {
return Qt::ItemFlag::ItemNeverHasChildren;
}

View File

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

View File

@ -9,7 +9,6 @@
#include "exceptions/applicationexception.h"
#include "exceptions/networkexception.h"
#include "exceptions/scriptexception.h"
#include "exceptions/scriptexception.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
#include "miscellaneous/iconfactory.h"
@ -38,8 +37,7 @@
#include <QVariant>
#include <QXmlStreamReader>
StandardFeed::StandardFeed(RootItem* parent_item)
: Feed(parent_item) {
StandardFeed::StandardFeed(RootItem* parent_item) : Feed(parent_item) {
m_type = Type::Rss0X;
m_sourceType = SourceType::Url;
m_encoding = m_postProcessScript = QString();
@ -49,8 +47,7 @@ StandardFeed::StandardFeed(RootItem* parent_item)
m_password = QString();
}
StandardFeed::StandardFeed(const StandardFeed& other)
: Feed(other) {
StandardFeed::StandardFeed(const StandardFeed& other) : Feed(other) {
m_type = other.type();
m_postProcessScript = other.postProcessScript();
m_sourceType = other.sourceType();
@ -66,7 +63,8 @@ QList<QAction*> StandardFeed::contextMenuFeedsList() {
QString StandardFeed::additionalTooltip() const {
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 {
@ -205,11 +203,9 @@ void StandardFeed::fetchMetadataForItself() {
serviceRoot()->itemChanged({this});
}
catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_DB
<< "Cannot overwrite feed:"
<< QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot save feed data"),
qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent,
{tr("Cannot save feed data"),
tr("Cannot save data for feed: %1").arg(ex.message()),
QSystemTrayIcon::MessageIcon::Critical});
}
@ -237,14 +233,14 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
const QString& username,
const QString& password,
const QNetworkProxy& custom_proxy) {
auto timeout = qApp->settings()->value(GROUP(Feeds),
SETTING(Feeds::UpdateTimeout)).toInt();
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray feed_contents;
QString content_type;
if (source_type == StandardFeed::SourceType::Url) {
QList<QPair<QByteArray, QByteArray>> headers = {NetworkFactory::generateBasicAuthHeader(username, password)};
NetworkResult network_result = NetworkFactory::performNetworkOperation(source,
NetworkResult network_result =
NetworkFactory::performNetworkOperation(source,
timeout,
QByteArray(),
feed_contents,
@ -262,18 +258,14 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
}
}
else {
qDebugNN << LOGSEC_CORE
<< "Running custom script for guessing"
<< QUOTE_W_SPACE(source)
<< "to obtain feed data.";
qDebugNN << LOGSEC_CORE << "Running custom script for guessing" << QUOTE_W_SPACE(source) << "to obtain feed data.";
// Use script to generate feed file.
feed_contents = generateFeedFileWithScript(source, timeout).toUtf8();
}
if (!post_process_script.simplified().isEmpty()) {
qDebugNN << LOGSEC_CORE
<< "Post-processing obtained feed data with custom script for guessing"
qDebugNN << LOGSEC_CORE << "Post-processing obtained feed data with custom script for guessing"
<< QUOTE_W_SPACE_DOT(post_process_script);
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.
QString xml_schema_encoding;
QString xml_contents_encoded;
QString enc = QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""),
QRegularExpression::PatternOption::CaseInsensitiveOption).match(feed_contents).captured(1);
QString enc =
QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""), QRegularExpression::PatternOption::CaseInsensitiveOption)
.match(feed_contents)
.captured(1);
if (!enc.isEmpty()) {
// Some "encoding" attribute was found get the encoding
@ -357,11 +351,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
QString error_msg;
int error_line, error_column;
if (!xml_document.setContent(xml_contents_encoded,
true,
&error_msg,
&error_line,
&error_column)) {
if (!xml_document.setContent(xml_contents_encoded, true, &error_msg, &error_line, &error_column)) {
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()) {
// 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->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();
@ -453,11 +447,8 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
// Try to obtain icon.
QIcon icon_data;
if (NetworkFactory::downloadIcon(icon_possible_locations,
DOWNLOAD_TIMEOUT,
icon_data,
{},
custom_proxy) == QNetworkReply::NetworkError::NoError) {
if (NetworkFactory::downloadIcon(icon_possible_locations, DOWNLOAD_TIMEOUT, icon_data, {}, custom_proxy) ==
QNetworkReply::NetworkError::NoError) {
// Icon for feed was downloaded and is stored now in _icon_data.
feed->setIcon(icon_data);
}
@ -466,7 +457,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
}
Qt::ItemFlags StandardFeed::additionalFlags() const {
return Qt::ItemFlag::ItemIsDragEnabled;
return Feed::additionalFlags() | Qt::ItemFlag::ItemIsDragEnabled;
}
bool StandardFeed::performDragDropChange(RootItem* target_item) {
@ -478,12 +469,10 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) {
return true;
}
catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_DB
<< "Cannot overwrite feed:"
<< QUOTE_W_SPACE_DOT(ex.message());
qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot move feed"),
qApp->showGuiMessage(Notification::Event::GeneralEvent,
{tr("Cannot move feed"),
tr("Cannot move feed, detailed information was logged via debug log."),
QSystemTrayIcon::MessageIcon::Critical});
return false;
@ -518,8 +507,11 @@ QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
return qApp->replaceDataUserDataFolderPlaceholder(args);
}
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
int run_timeout, bool provide_input, const QString& input) {
QString StandardFeed::runScriptProcess(const QStringList& cmd_args,
const QString& working_directory,
int run_timeout,
bool provide_input,
const QString& input) {
QProcess process;
if (provide_input) {
@ -547,8 +539,7 @@ QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QStrin
process.closeWriteChannel();
}
if (process.waitForFinished(run_timeout) &&
process.exitStatus() == QProcess::ExitStatus::NormalExit &&
if (process.waitForFinished(run_timeout) && process.exitStatus() == QProcess::ExitStatus::NormalExit &&
process.exitCode() == EXIT_SUCCESS) {
auto raw_output = process.readAllStandardOutput();
auto raw_error = process.readAllStandardError();