Removed obsolete code, some refactorings.
This commit is contained in:
parent
8862b70638
commit
032fccc387
@ -40,6 +40,10 @@ else {
|
||||
DEFINES *= DEBUG=1
|
||||
gcc:QMAKE_CXXFLAGS_DEBUG *= -Wall
|
||||
clang:QMAKE_CXXFLAGS_DEBUG *= -Wall
|
||||
msvc:QMAKE_CXXFLAGS_DEBUG *= /W4 /wd4127
|
||||
msvc:QMAKE_CXXFLAGS_WARN_ON = ""
|
||||
msvc:QMAKE_CXXFLAGS_DEBUG -= /W3
|
||||
msvc:QMAKE_CXXFLAGS -= /W3
|
||||
}
|
||||
|
||||
MOC_DIR = $$OUT_PWD/moc
|
||||
|
@ -3,6 +3,7 @@
|
||||
<file>./graphics/Faenza/actions/64/application-exit.png</file>
|
||||
<file>./graphics/Faenza/actions/64/back.png</file>
|
||||
<file>./graphics/Faenza/actions/64/call-start.png</file>
|
||||
<file>./graphics/Faenza/actions/64/dialog-no.png</file>
|
||||
<file>./graphics/Faenza/actions/64/dialog-yes.png</file>
|
||||
<file>./graphics/Faenza/actions/64/document-edit.png</file>
|
||||
<file>./graphics/Faenza/actions/64/document-export.png</file>
|
||||
|
@ -389,7 +389,7 @@ QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QStack<const RootItem*>chain;
|
||||
QStack<const RootItem*> chain;
|
||||
|
||||
while (item->kind() != RootItemKind::Root) {
|
||||
chain.push(item);
|
||||
|
@ -14,7 +14,12 @@ Enclosure::Enclosure(QString url, QString mime) : m_url(std::move(url)), m_mimeT
|
||||
QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosures_data) {
|
||||
QList<Enclosure> enclosures;
|
||||
|
||||
for (const QString& single_enclosure : enclosures_data.split(ENCLOSURES_OUTER_SEPARATOR, QString::SkipEmptyParts)) {
|
||||
for (const QString& single_enclosure : enclosures_data.split(ENCLOSURES_OUTER_SEPARATOR,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts)) {
|
||||
#else
|
||||
QString::SkipEmptyParts)) {
|
||||
#endif
|
||||
Enclosure enclosure;
|
||||
|
||||
if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <QSqlField>
|
||||
|
||||
MessagesModel::MessagesModel(QObject* parent)
|
||||
: QSqlQueryModel(parent), m_cache(new MessagesModelCache(this)), m_messageHighlighter(NoHighlighting),
|
||||
: QSqlQueryModel(parent), m_cache(new MessagesModelCache(this)), m_messageHighlighter(MessageHighlighter::NoHighlighting),
|
||||
m_customDateFormat(QString()), m_selectedItem(nullptr), m_itemHeight(-1) {
|
||||
setupFonts();
|
||||
setupIcons();
|
||||
@ -286,21 +286,21 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
||||
|
||||
case Qt::ForegroundRole:
|
||||
switch (m_messageHighlighter) {
|
||||
case HighlightImportant: {
|
||||
case MessageHighlighter::HighlightImportant: {
|
||||
QModelIndex idx_important = index(idx.row(), MSG_DB_IMPORTANT_INDEX);
|
||||
QVariant dta = m_cache->containsData(idx_important.row()) ? m_cache->data(idx_important) : QSqlQueryModel::data(idx_important);
|
||||
|
||||
return dta.toInt() == 1 ? qApp->skins()->currentSkin().m_colorPalette[Skin::PaletteColors::Highlight] : QVariant();
|
||||
}
|
||||
|
||||
case HighlightUnread: {
|
||||
case MessageHighlighter::HighlightUnread: {
|
||||
QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX);
|
||||
QVariant dta = m_cache->containsData(idx_read.row()) ? m_cache->data(idx_read) : QSqlQueryModel::data(idx_read);
|
||||
|
||||
return dta.toInt() == 0 ? qApp->skins()->currentSkin().m_colorPalette[Skin::PaletteColors::Highlight] : QVariant();
|
||||
}
|
||||
|
||||
case NoHighlighting:
|
||||
case MessageHighlighter::NoHighlighting:
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||
|
||||
// Enum which describes basic filtering schemes
|
||||
// for messages.
|
||||
enum MessageHighlighter {
|
||||
enum class MessageHighlighter {
|
||||
NoHighlighting = 100,
|
||||
HighlightUnread = 101,
|
||||
HighlightImportant = 102
|
||||
|
@ -23,7 +23,10 @@ FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader, const Q
|
||||
|
||||
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("view-list-details")));
|
||||
|
||||
m_ui.m_treeFeeds->setIndentation(FEEDS_VIEW_INDENTATION);
|
||||
m_ui.m_treeFeeds->setModel(m_feedsModel);
|
||||
m_ui.m_btnCheckAll->setIcon(qApp->icons()->fromTheme(QSL("dialog-yes")));
|
||||
m_ui.m_btnUncheckAll->setIcon(qApp->icons()->fromTheme(QSL("dialog-no")));
|
||||
m_ui.m_btnAddNew->setIcon(qApp->icons()->fromTheme(QSL("list-add")));
|
||||
m_ui.m_btnRemoveSelected->setIcon(qApp->icons()->fromTheme(QSL("list-remove")));
|
||||
m_ui.m_btnBeautify->setIcon(qApp->icons()->fromTheme(QSL("format-justify-fill")));
|
||||
@ -47,6 +50,8 @@ FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader, const Q
|
||||
loadSelectedAccount();
|
||||
loadFilterFeedAssignments();
|
||||
});
|
||||
connect(m_ui.m_btnCheckAll, &QPushButton::clicked, m_feedsModel, &AccountCheckModel::checkAllItems);
|
||||
connect(m_ui.m_btnUncheckAll, &QPushButton::clicked, m_feedsModel, &AccountCheckModel::uncheckAllItems);
|
||||
|
||||
initializeTestingMessage();
|
||||
loadFilter();
|
||||
|
@ -77,6 +77,9 @@
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -88,14 +91,14 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="m_btnCheckAll">
|
||||
<property name="text">
|
||||
<string>&Check all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="m_btnUncheckAll">
|
||||
<property name="text">
|
||||
<string>&Uncheck all</string>
|
||||
</property>
|
||||
@ -406,8 +409,8 @@
|
||||
<tabstop>m_btnRemoveSelected</tabstop>
|
||||
<tabstop>m_cmbAccounts</tabstop>
|
||||
<tabstop>m_treeFeeds</tabstop>
|
||||
<tabstop>pushButton</tabstop>
|
||||
<tabstop>pushButton_2</tabstop>
|
||||
<tabstop>m_btnCheckAll</tabstop>
|
||||
<tabstop>m_btnUncheckAll</tabstop>
|
||||
<tabstop>m_txtTitle</tabstop>
|
||||
<tabstop>m_txtScript</tabstop>
|
||||
<tabstop>m_btnTest</tabstop>
|
||||
|
@ -77,10 +77,20 @@ void FeedsToolBar::loadSpecificActions(const QList<QAction*>& actions, bool init
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::defaultActions() const {
|
||||
return QString(GUI::FeedsToolbarActionsDef).split(',', QString::SkipEmptyParts);
|
||||
return QString(GUI::FeedsToolbarActionsDef).split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::FeedsToolbarActions)).toString().split(',', QString::SkipEmptyParts);
|
||||
SETTING(GUI::FeedsToolbarActions)).toString().split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ void FeedsView::saveExpandStates(RootItem* item) {
|
||||
QList<RootItem*> items = item->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot);
|
||||
|
||||
// Iterate all categories and save their expand statuses.
|
||||
for (const RootItem* item : items) {
|
||||
const QString setting_name = item->hashCode();
|
||||
QModelIndex source_index = sourceModel()->indexForItem(item);
|
||||
for (const RootItem* it : items) {
|
||||
const QString setting_name = it->hashCode();
|
||||
QModelIndex source_index = sourceModel()->indexForItem(it);
|
||||
QModelIndex visible_index = model()->mapFromSource(source_index);
|
||||
|
||||
settings->setValue(GROUP(CategoriesExpandStates),
|
||||
|
@ -118,11 +118,11 @@ void MessagesToolBar::initializeSearchBox() {
|
||||
void MessagesToolBar::initializeHighlighter() {
|
||||
m_menuMessageHighlighter = new QMenu(tr("Menu for highlighting messages"), this);
|
||||
m_menuMessageHighlighter->addAction(qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("No extra highlighting"))->setData(QVariant::fromValue(MessagesModel::NoHighlighting));
|
||||
tr("No extra highlighting"))->setData(QVariant::fromValue(MessagesModel::MessageHighlighter::NoHighlighting));
|
||||
m_menuMessageHighlighter->addAction(qApp->icons()->fromTheme(QSL("mail-mark-unread")),
|
||||
tr("Highlight unread messages"))->setData(QVariant::fromValue(MessagesModel::HighlightUnread));
|
||||
tr("Highlight unread messages"))->setData(QVariant::fromValue(MessagesModel::MessageHighlighter::HighlightUnread));
|
||||
m_menuMessageHighlighter->addAction(qApp->icons()->fromTheme(QSL("mail-mark-important")),
|
||||
tr("Highlight important messages"))->setData(QVariant::fromValue(MessagesModel::HighlightImportant));
|
||||
tr("Highlight important messages"))->setData(QVariant::fromValue(MessagesModel::MessageHighlighter::HighlightImportant));
|
||||
m_btnMessageHighlighter = new QToolButton(this);
|
||||
m_btnMessageHighlighter->setToolTip(tr("Display all messages"));
|
||||
m_btnMessageHighlighter->setMenu(m_menuMessageHighlighter);
|
||||
@ -138,12 +138,20 @@ void MessagesToolBar::initializeHighlighter() {
|
||||
}
|
||||
|
||||
QStringList MessagesToolBar::defaultActions() const {
|
||||
return QString(GUI::MessagesToolbarDefaultButtonsDef).split(',',
|
||||
QString::SkipEmptyParts);
|
||||
return QString(GUI::MessagesToolbarDefaultButtonsDef).split(QL1C(','),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList MessagesToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(QL1C(','),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
@ -73,11 +73,22 @@ void StatusBar::saveChangeableActions(const QStringList& actions) {
|
||||
}
|
||||
|
||||
QStringList StatusBar::defaultActions() const {
|
||||
return QString(GUI::StatusbarActionsDef).split(',', QString::SkipEmptyParts);
|
||||
return QString(GUI::StatusbarActionsDef).split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList StatusBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::StatusbarActions)).toString().split(',', QString::SkipEmptyParts);
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::StatusbarActions)).toString().split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
||||
|
@ -72,17 +72,17 @@ void TabBar::wheelEvent(QWheelEvent* event) {
|
||||
|
||||
// Make sure rotating works.
|
||||
if (number_of_tabs > 1) {
|
||||
if (event->delta() > 0) {
|
||||
if (event->angleDelta().y() > 0) {
|
||||
// Scroll to the LEFT tab.
|
||||
setCurrentIndex(current_index == 0 ?
|
||||
number_of_tabs - 1 :
|
||||
current_index - 1);
|
||||
setCurrentIndex(current_index == 0
|
||||
? number_of_tabs - 1
|
||||
: current_index - 1);
|
||||
}
|
||||
else if (event->delta() < 0) {
|
||||
else if (event->angleDelta().y() < 0) {
|
||||
// Scroll to the RIGHT tab.
|
||||
setCurrentIndex(current_index == number_of_tabs - 1 ?
|
||||
0 :
|
||||
current_index + 1);
|
||||
setCurrentIndex(current_index == number_of_tabs - 1
|
||||
? 0
|
||||
: current_index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ void Application::onAboutToQuit() {
|
||||
finish();
|
||||
qDebug("Killing local peer connection to allow another instance to start.");
|
||||
|
||||
if (QProcess::startDetached(QString("\"") + QDir::toNativeSeparators(applicationFilePath()) + QString("\""))) {
|
||||
if (QProcess::startDetached(QDir::toNativeSeparators(applicationFilePath()), {})) {
|
||||
qDebug("New application instance was started.");
|
||||
}
|
||||
else {
|
||||
|
@ -218,7 +218,12 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
|
||||
qPrintable(APP_SQL_PATH));
|
||||
}
|
||||
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
database.transaction();
|
||||
|
||||
@ -327,7 +332,12 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c
|
||||
qPrintable(APP_SQL_PATH));
|
||||
}
|
||||
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
database.transaction();
|
||||
|
||||
@ -407,7 +417,12 @@ bool DatabaseFactory::sqliteUpdateDatabaseSchema(const QSqlDatabase& database, c
|
||||
qFatal("Updating of database schema failed. File '%s' cannot be opened.", qPrintable(QDir::toNativeSeparators(update_file_name)));
|
||||
}
|
||||
|
||||
const QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
const QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
for (const QString& statement : statements) {
|
||||
QSqlQuery query = database.exec(statement);
|
||||
@ -447,7 +462,12 @@ bool DatabaseFactory::mysqlUpdateDatabaseSchema(const QSqlDatabase& database,
|
||||
qFatal("Updating of database schema failed. File '%s' cannot be opened.", qPrintable(QDir::toNativeSeparators(update_file_name)));
|
||||
}
|
||||
|
||||
QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
for (QString statement : statements) {
|
||||
QSqlQuery query = database.exec(statement.replace(APP_DB_NAME_PLACEHOLDER, db_name));
|
||||
@ -676,7 +696,12 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_
|
||||
qPrintable(APP_SQL_PATH));
|
||||
}
|
||||
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
const QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
database.transaction();
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
IOFactory::IOFactory() = default;
|
||||
@ -70,6 +71,18 @@ QString IOFactory::filterBadCharsFromFilename(const QString& name) {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool IOFactory::startProcessDetached(const QString& program, const QStringList& arguments,
|
||||
const QString& native_arguments, const QString& working_directory) {
|
||||
QProcess process;
|
||||
|
||||
process.setProgram(program);
|
||||
process.setArguments(arguments);
|
||||
process.setNativeArguments(native_arguments);
|
||||
process.setWorkingDirectory(working_directory);
|
||||
|
||||
return process.startDetached(nullptr);
|
||||
}
|
||||
|
||||
QByteArray IOFactory::readFile(const QString& file_path) {
|
||||
QFile input_file(file_path);
|
||||
QByteArray input_data;
|
||||
|
@ -27,6 +27,10 @@ class IOFactory {
|
||||
|
||||
// Filters out shit characters from filename.
|
||||
static QString filterBadCharsFromFilename(const QString& name);
|
||||
static bool startProcessDetached(const QString& program,
|
||||
const QStringList& arguments,
|
||||
const QString& native_arguments = {},
|
||||
const QString& working_directory = {});
|
||||
|
||||
// Returns contents of a file.
|
||||
// Throws exception when no such file exists.
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QDataStream>
|
||||
#include <QDateTime>
|
||||
#include <QRandomGenerator>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
@ -38,16 +39,13 @@ SimpleCrypt::SimpleCrypt() :
|
||||
m_key(0),
|
||||
m_compressionMode(CompressionAlways),
|
||||
m_protectionMode(ProtectionHash),
|
||||
m_lastError(ErrorNoError) {
|
||||
qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF));
|
||||
}
|
||||
m_lastError(ErrorNoError) {}
|
||||
|
||||
SimpleCrypt::SimpleCrypt(quint64 key) :
|
||||
m_key(key),
|
||||
m_compressionMode(CompressionAlways),
|
||||
m_protectionMode(ProtectionHash),
|
||||
m_lastError(ErrorNoError) {
|
||||
qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF));
|
||||
splitKey();
|
||||
}
|
||||
|
||||
@ -116,7 +114,7 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
|
||||
}
|
||||
|
||||
//prepend a random char to the string
|
||||
char randomChar = char(qrand() & 0xFF);
|
||||
char randomChar = char(QRandomGenerator::global()->generate() & 0xFF);
|
||||
|
||||
ba = randomChar + integrityProtection + ba;
|
||||
int pos(0);
|
||||
@ -221,6 +219,7 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) {
|
||||
}
|
||||
|
||||
quint16 storedChecksum;
|
||||
|
||||
{
|
||||
QDataStream s(&ba, QIODevice::ReadOnly);
|
||||
|
||||
|
@ -59,7 +59,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||
return AutoStartStatus::Disabled;
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
|
||||
// Use proper freedesktop.org way to auto-start the application on Linux.
|
||||
// INFO: http://standards.freedesktop.org/autostart-spec/latest/
|
||||
const QString desktop_file_location = autostartDesktopFileLocation();
|
||||
@ -82,7 +81,6 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||
return AutoStartStatus::Disabled;
|
||||
}
|
||||
#else
|
||||
|
||||
// Disable auto-start functionality on unsupported platforms.
|
||||
return AutoStartStatus::Unavailable;
|
||||
#endif
|
||||
@ -139,7 +137,6 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
|
||||
return false;
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
|
||||
// Note that we expect here that no other program uses
|
||||
// "rssguard.desktop" desktop file.
|
||||
const QString destination_file = autostartDesktopFileLocation();
|
||||
@ -279,7 +276,8 @@ bool SystemFactory::isVersionEqualOrNewer(const QString& new_version, const QStr
|
||||
|
||||
bool SystemFactory::openFolderFile(const QString& file_path) {
|
||||
#if defined(Q_OS_WIN)
|
||||
return QProcess::startDetached(QString("explorer.exe /select, \"") + QDir::toNativeSeparators(file_path) + "\"");
|
||||
return QProcess::startDetached(QSL("explorer.exe"),
|
||||
{ "/select,", QDir::toNativeSeparators(file_path)});
|
||||
#else
|
||||
const QString folder = QDir::toNativeSeparators(QFileInfo(file_path).absoluteDir().absolutePath());
|
||||
|
||||
|
@ -370,7 +370,12 @@ void AdBlockRule::parseFilter() {
|
||||
int optionsIndex = parsedLine.indexOf(QL1C('$'));
|
||||
|
||||
if (optionsIndex >= 0) {
|
||||
const QStringList options = parsedLine.mid(optionsIndex + 1).split(QL1C(','), QString::SkipEmptyParts);
|
||||
const QStringList options = parsedLine.mid(optionsIndex + 1).split(QL1C(','),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
int handledOptions = 0;
|
||||
|
||||
for (const QString& option : options) {
|
||||
@ -497,7 +502,12 @@ void AdBlockRule::parseFilter() {
|
||||
}
|
||||
|
||||
void AdBlockRule::parseDomains(const QString& domains, const QChar& separator) {
|
||||
QStringList domainsList = domains.split(separator, QString::SkipEmptyParts);
|
||||
QStringList domainsList = domains.split(separator,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
for (const QString& domain : domainsList) {
|
||||
if (domain.isEmpty()) {
|
||||
@ -618,15 +628,15 @@ QString AdBlockRule::createRegExpFromFilter(const QString& filter) const {
|
||||
}
|
||||
|
||||
QList<QStringMatcher> AdBlockRule::createStringMatchers(const QStringList& filters) const {
|
||||
QList<QStringMatcher> matchers;
|
||||
QList<QStringMatcher> mtchrs;
|
||||
|
||||
matchers.reserve(filters.size());
|
||||
mtchrs.reserve(filters.size());
|
||||
|
||||
for (const QString& filter : filters) {
|
||||
matchers.append(QStringMatcher(filter, m_caseSensitivity));
|
||||
mtchrs.append(QStringMatcher(filter, m_caseSensitivity));
|
||||
}
|
||||
|
||||
return matchers;
|
||||
return mtchrs;
|
||||
}
|
||||
|
||||
int AdBlockRule::regexMatched(const QString& str, int offset) const {
|
||||
|
@ -89,8 +89,7 @@ const AdBlockRule* AdBlockSearchTree::prefixSearch(const QWebEngineUrlRequestInf
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QChar c = choppedUrlString.at(0);
|
||||
Node* node = m_root->children.value(c);
|
||||
Node* node = m_root->children.value(choppedUrlString.at(0));
|
||||
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
|
@ -290,11 +290,11 @@ void AdBlockCustomList::loadSubscription(const QStringList& disabledRules) {
|
||||
stream.setCodec("UTF-8");
|
||||
|
||||
if (!rules.contains(ddg1 + QL1S("\n"))) {
|
||||
stream << ddg1 << endl;
|
||||
stream << ddg1 << Qt::endl;
|
||||
}
|
||||
|
||||
if (!rules.contains(QL1S("\n") + ddg2)) {
|
||||
stream << ddg2 << endl;
|
||||
stream << ddg2 << Qt::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,12 +313,12 @@ void AdBlockCustomList::saveSubscription() {
|
||||
QTextStream textStream(&file);
|
||||
|
||||
textStream.setCodec("UTF-8");
|
||||
textStream << "Title: " << title() << endl;
|
||||
textStream << "Url: " << url().toString() << endl;
|
||||
textStream << "[Adblock Plus 1.1.1]" << endl;
|
||||
textStream << "Title: " << title() << Qt::endl;
|
||||
textStream << "Url: " << url().toString() << Qt::endl;
|
||||
textStream << "[Adblock Plus 1.1.1]" << Qt::endl;
|
||||
|
||||
for (const AdBlockRule* rule : m_rules) {
|
||||
textStream << rule->filter() << endl;
|
||||
textStream << rule->filter() << Qt::endl;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
@ -181,7 +181,13 @@ QList<HttpResponse> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
|
||||
QString content_type = reply->header(QNetworkRequest::KnownHeaders::ContentTypeHeader).toString();
|
||||
QString boundary = content_type.mid(content_type.indexOf(QL1S("boundary=")) + 9);
|
||||
QRegularExpression regex(QL1S("--") + boundary + QL1S("(--)?(\\r\\n)?"));
|
||||
QStringList list = QString::fromUtf8(data).split(regex, QString::SplitBehavior::SkipEmptyParts);
|
||||
QStringList list = QString::fromUtf8(data).split(regex,
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
QList<HttpResponse> parts;
|
||||
|
||||
parts.reserve(list.size());
|
||||
@ -197,7 +203,12 @@ QList<HttpResponse> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
|
||||
start_of_body - start_of_headers).replace(QRegularExpression(QSL("[\\n\\r]+")),
|
||||
QSL("\n"));
|
||||
|
||||
for (const QString& header_line : headers.split(QL1C('\n'), QString::SplitBehavior::SkipEmptyParts)) {
|
||||
for (const QString& header_line : headers.split(QL1C('\n'),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts)) {
|
||||
#else
|
||||
QString::SkipEmptyParts)) {
|
||||
#endif
|
||||
int index_colon = header_line.indexOf(QL1C(':'));
|
||||
|
||||
if (index_colon > 0) {
|
||||
|
@ -55,7 +55,13 @@ void DownloadItem::init() {
|
||||
m_reply->setParent(this);
|
||||
|
||||
connect(m_reply, &QNetworkReply::readyRead, this, &DownloadItem::downloadReadyRead);
|
||||
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
connect(m_reply, &QNetworkReply::errorOccurred, this, &DownloadItem::error);
|
||||
#else
|
||||
connect(m_reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DownloadItem::error);
|
||||
#endif
|
||||
|
||||
connect(m_reply, &QNetworkReply::downloadProgress, this, &DownloadItem::downloadProgress);
|
||||
connect(m_reply, &QNetworkReply::metaDataChanged, this, &DownloadItem::metaDataChanged);
|
||||
connect(m_reply, &QNetworkReply::finished, this, &DownloadItem::finished);
|
||||
|
@ -33,8 +33,7 @@ bool WebFactory::sendMessageViaEmail(const Message& message) {
|
||||
const QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString();
|
||||
const QString arguments = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString();
|
||||
|
||||
return QProcess::startDetached(QString("\"") + browser + QSL("\" ") + arguments.arg(message.m_title,
|
||||
stripTags(message.m_contents)));
|
||||
return IOFactory::startProcessDetached(browser, {}, arguments.arg(message.m_title, stripTags(message.m_contents)));
|
||||
}
|
||||
else {
|
||||
// Send it via mailto protocol.
|
||||
@ -49,10 +48,11 @@ bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
|
||||
if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()) {
|
||||
const QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString();
|
||||
const QString arguments = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString();
|
||||
const QString call_line = "\"" + browser + "\" \"" + arguments.arg(url) + "\"";
|
||||
auto nice_args = arguments.arg(url);
|
||||
|
||||
qDebug("Running command '%s'.", qPrintable(call_line));
|
||||
const bool result = QProcess::startDetached(call_line);
|
||||
qDebug("Arguments for external browser: '%s'.", qPrintable(nice_args));
|
||||
|
||||
const bool result = IOFactory::startProcessDetached(browser, {}, nice_args);
|
||||
|
||||
if (!result) {
|
||||
qDebug("External web browser call failed.");
|
||||
@ -75,7 +75,6 @@ QString WebFactory::escapeHtml(const QString& html) {
|
||||
}
|
||||
|
||||
QString output = html;
|
||||
|
||||
QMapIterator<QString, QString> i(m_escapes);
|
||||
|
||||
while (i.hasNext()) {
|
||||
@ -92,7 +91,6 @@ QString WebFactory::deEscapeHtml(const QString& text) {
|
||||
}
|
||||
|
||||
QString output = text;
|
||||
|
||||
QMapIterator<QString, QString> i(m_deEscapes);
|
||||
|
||||
while (i.hasNext()) {
|
||||
@ -174,6 +172,7 @@ void WebFactory::createMenu(QMenu* menu) {
|
||||
|
||||
menu->clear();
|
||||
QList<QAction*> actions;
|
||||
|
||||
actions << createEngineSettingsAction(tr("Auto-load images"), QWebEngineSettings::AutoLoadImages);
|
||||
actions << createEngineSettingsAction(tr("JS enabled"), QWebEngineSettings::JavascriptEnabled);
|
||||
actions << createEngineSettingsAction(tr("JS can open popup windows"), QWebEngineSettings::JavascriptCanOpenWindows);
|
||||
@ -204,6 +203,7 @@ void WebFactory::webEngineSettingChanged(bool enabled) {
|
||||
const QAction* const act = qobject_cast<QAction*>(sender());
|
||||
|
||||
QWebEngineSettings::WebAttribute attribute = static_cast<QWebEngineSettings::WebAttribute>(act->data().toInt());
|
||||
|
||||
qApp->settings()->setValue(WebEngineAttributes::ID, QString::number(static_cast<int>(attribute)), enabled);
|
||||
QWebEngineProfile::defaultProfile()->settings()->setAttribute(attribute, act->isChecked());
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ void AccountCheckModel::setRootItem(RootItem* root_item, bool delete_previous_ro
|
||||
m_rootItem->deleteLater();
|
||||
}
|
||||
|
||||
m_checkStates.clear();
|
||||
m_rootItem = root_item;
|
||||
|
||||
if (with_layout_change) {
|
||||
@ -172,7 +173,7 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
|
||||
else if (role == Qt::DecorationRole) {
|
||||
auto ic = item->icon();
|
||||
|
||||
return ic.isNull() ? QVariant() : ic;
|
||||
return item->data(0, Qt::ItemDataRole::DecorationRole);
|
||||
}
|
||||
else if (role == Qt::EditRole) {
|
||||
return QVariant::fromValue(item);
|
||||
@ -206,6 +207,7 @@ bool AccountCheckModel::setData(const QModelIndex& index, const QVariant& value,
|
||||
// Change data for the actual item.
|
||||
m_checkStates[item] = static_cast<Qt::CheckState>(value.toInt());
|
||||
emit dataChanged(index, index);
|
||||
emit checkStateChanged(item, m_checkStates[item]);
|
||||
|
||||
if (m_recursiveChange) {
|
||||
return true;
|
||||
|
@ -43,6 +43,9 @@ class AccountCheckModel : public QAbstractItemModel {
|
||||
void checkAllItems();
|
||||
void uncheckAllItems();
|
||||
|
||||
signals:
|
||||
void checkStateChanged(RootItem* item, Qt::CheckState);
|
||||
|
||||
protected:
|
||||
RootItem* m_rootItem;
|
||||
|
||||
|
@ -394,9 +394,9 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
||||
QString title = subscription["title"].toString();
|
||||
QString url = subscription["htmlUrl"].toString();
|
||||
QString parent_label;
|
||||
QJsonArray categories = subscription["categories"].toArray();
|
||||
QJsonArray assigned_categories = subscription["categories"].toArray();
|
||||
|
||||
for (const QJsonValue& cat : categories) {
|
||||
for (const QJsonValue& cat : assigned_categories) {
|
||||
QString potential_id = cat.toObject()["id"].toString();
|
||||
|
||||
if (potential_id.contains(QSL("/label/"))) {
|
||||
|
@ -22,6 +22,7 @@ bool OwnCloudFeed::canBeEdited() const {
|
||||
|
||||
bool OwnCloudFeed::editViaGui() {
|
||||
QPointer<FormOwnCloudFeedDetails> form_pointer = new FormOwnCloudFeedDetails(serviceRoot(), qApp->mainFormWidget());
|
||||
|
||||
form_pointer.data()->addEditFeed(this, nullptr);
|
||||
delete form_pointer.data();
|
||||
return false;
|
||||
@ -79,6 +80,4 @@ QList<Message> OwnCloudFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||
*error_during_obtaining = false;
|
||||
return messages.messages();
|
||||
}
|
||||
|
||||
return QList<Message>();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user