Uncrustify reformat.

This commit is contained in:
Martin Rotter 2017-09-19 10:18:21 +02:00
parent dd4a96f51f
commit 0fe6b3e686
297 changed files with 21045 additions and 20234 deletions

View file

@ -1,27 +0,0 @@
--style=java
--indent=spaces=2
--indent-classes
--indent-namespaces
--indent-switches
--indent-labels
--indent-preproc-define
--indent-col1-comments
--max-continuation-indent=100
--break-blocks
--unpad-paren
--pad-oper
--pad-comma
--pad-header
--align-pointer=type
--align-reference=type
--break-closing-braces
--break-one-line-headers
--add-braces
--convert-tabs
--close-templates
--max-code-length=140
--lineend=linux
#--delete-empty-lines
--mode=c
-t -p
-M60Ucv

View file

@ -27,16 +27,14 @@ if [ $# -eq 0 ]; then
usage usage
fi fi
ASTYLE_CMD="astyle" ASTYLE_CMD="uncrustify"
if [[ "$(uname -o)" == "Cygwin" ]]; then if [[ "$(uname -o)" == "Cygwin" ]]; then
ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/.astylerc" ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/uncrustify.cfg"
else else
ASTYLE_RC="$(realpath $(dirname $0))/.astylerc" ASTYLE_RC="$(realpath $(dirname $0))/uncrustify.cfg"
fi fi
ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/.astylerc"
echo "ASTYLE config file: $ASTYLE_RC" echo "ASTYLE config file: $ASTYLE_RC"
# Check all args. # Check all args.
@ -58,11 +56,11 @@ for dir in "$@"; do
-o -name '*.h' \ -o -name '*.h' \
-o -name '*.hh' \ -o -name '*.hh' \
-o -name '*.hpp'); do -o -name '*.hpp'); do
"${ASTYLE_CMD}" --options="$ASTYLE_RC" "${f}" "${ASTYLE_CMD}" -c "$ASTYLE_RC" --replace "${f}"
done done
# Remove backup files. # Remove backup files.
find . -name "*.orig" | xargs --no-run-if-empty rm -v find . -name "*-backup*~*" | xargs --no-run-if-empty rm -v
popd popd
done done

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,15 +18,14 @@
#include "core/feeddownloader.h" #include "core/feeddownloader.h"
#include "services/abstract/feed.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "services/abstract/feed.h"
#include <QThread>
#include <QDebug> #include <QDebug>
#include <QThreadPool>
#include <QMutexLocker> #include <QMutexLocker>
#include <QString> #include <QString>
#include <QThread>
#include <QThreadPool>
FeedDownloader::FeedDownloader(QObject* parent) FeedDownloader::FeedDownloader(QObject* parent)
: QObject(parent), m_feeds(QList<Feed*>()), m_mutex(new QMutex()), m_threadPool(new QThreadPool(this)), : QObject(parent), m_feeds(QList<Feed*>()), m_mutex(new QMutex()), m_threadPool(new QThreadPool(this)),
@ -75,8 +75,10 @@ void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
m_feedsOriginalCount = m_feeds.size(); m_feedsOriginalCount = m_feeds.size();
m_results.clear(); m_results.clear();
m_feedsUpdated = m_feedsUpdating = 0; m_feedsUpdated = m_feedsUpdating = 0;
// Job starts now. // Job starts now.
emit updateStarted(); emit updateStarted();
updateAvailableFeeds(); updateAvailableFeeds();
} }
} }
@ -88,12 +90,16 @@ void FeedDownloader::stopRunningUpdate() {
void FeedDownloader::oneFeedUpdateFinished(const QList<Message>& messages, bool error_during_obtaining) { void FeedDownloader::oneFeedUpdateFinished(const QList<Message>& messages, bool error_during_obtaining) {
QMutexLocker locker(m_mutex); QMutexLocker locker(m_mutex);
m_feedsUpdated++; m_feedsUpdated++;
m_feedsUpdating--; m_feedsUpdating--;
Feed* feed = qobject_cast<Feed*>(sender()); Feed* feed = qobject_cast<Feed*>(sender());
disconnect(feed, &Feed::messagesObtained, this, &FeedDownloader::oneFeedUpdateFinished); disconnect(feed, &Feed::messagesObtained, this, &FeedDownloader::oneFeedUpdateFinished);
// Now, we check if there are any feeds we would like to update too. // Now, we check if there are any feeds we would like to update too.
updateAvailableFeeds(); updateAvailableFeeds();
// Now make sure, that messages are actually stored to SQL in a locked state. // Now make sure, that messages are actually stored to SQL in a locked state.
qDebug().nospace() << "Saving messages of feed " qDebug().nospace() << "Saving messages of feed "
<< feed->id() << " in thread: \'" << feed->id() << " in thread: \'"
@ -121,6 +127,7 @@ void FeedDownloader::oneFeedUpdateFinished(const QList<Message>& messages, bool
void FeedDownloader::finalizeUpdate() { void FeedDownloader::finalizeUpdate() {
qDebug().nospace() << "Finished feed updates in thread: \'" << QThread::currentThreadId() << "\'."; qDebug().nospace() << "Finished feed updates in thread: \'" << QThread::currentThreadId() << "\'.";
m_results.sort(); m_results.sort();
// Update of feeds has finished. // Update of feeds has finished.
// NOTE: This means that now "update lock" can be unlocked // NOTE: This means that now "update lock" can be unlocked
// and feeds can be added/edited/deleted and application // and feeds can be added/edited/deleted and application
@ -128,8 +135,7 @@ void FeedDownloader::finalizeUpdate() {
emit updateFinished(m_results); emit updateFinished(m_results);
} }
FeedDownloadResults::FeedDownloadResults() : m_updatedFeeds(QList<QPair<QString, int>>()) { FeedDownloadResults::FeedDownloadResults() : m_updatedFeeds(QList<QPair<QString, int>>()) {}
}
QString FeedDownloadResults::overview(int how_many_feeds) const { QString FeedDownloadResults::overview(int how_many_feeds) const {
QStringList result; QStringList result;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -24,7 +25,6 @@
#include "core/message.h" #include "core/message.h"
class Feed; class Feed;
class QThreadPool; class QThreadPool;
class QMutex; class QMutex;
@ -44,6 +44,7 @@ class FeedDownloadResults {
static bool lessThan(const QPair<QString, int>& lhs, const QPair<QString, int>& rhs); static bool lessThan(const QPair<QString, int>& lhs, const QPair<QString, int>& rhs);
private: private:
// QString represents title if the feed, int represents count of newly downloaded messages. // QString represents title if the feed, int represents count of newly downloaded messages.
QList<QPair<QString, int>> m_updatedFeeds; QList<QPair<QString, int>> m_updatedFeeds;
}; };
@ -54,6 +55,7 @@ class FeedDownloader : public QObject {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FeedDownloader(QObject* parent = 0); explicit FeedDownloader(QObject* parent = 0);
virtual ~FeedDownloader(); virtual ~FeedDownloader();
@ -61,6 +63,7 @@ class FeedDownloader : public QObject {
bool isUpdateRunning() const; bool isUpdateRunning() const;
public slots: public slots:
// Performs update of all feeds from the "feeds" parameter. // Performs update of all feeds from the "feeds" parameter.
// New messages are downloaded for each feed and they // New messages are downloaded for each feed and they
// are stored persistently in the database. // are stored persistently in the database.
@ -74,6 +77,7 @@ class FeedDownloader : public QObject {
void oneFeedUpdateFinished(const QList<Message>& messages, bool error_during_obtaining); void oneFeedUpdateFinished(const QList<Message>& messages, bool error_during_obtaining);
signals: signals:
// Emitted if feed updates started. // Emitted if feed updates started.
void updateStarted(); void updateStarted();
@ -95,7 +99,6 @@ class FeedDownloader : public QObject {
QMutex* m_mutex; QMutex* m_mutex;
QThreadPool* m_threadPool; QThreadPool* m_threadPool;
FeedDownloadResults m_results; FeedDownloadResults m_results;
int m_feedsUpdated; int m_feedsUpdated;
int m_feedsUpdating; int m_feedsUpdating;
int m_feedsOriginalCount; int m_feedsOriginalCount;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,14 +18,13 @@
#include "core/feedsproxymodel.h" #include "core/feedsproxymodel.h"
#include "core/feedsmodel.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "core/feedsmodel.h"
#include "services/abstract/rootitem.h" #include "services/abstract/rootitem.h"
#include <QTimer> #include <QTimer>
FeedsProxyModel::FeedsProxyModel(FeedsModel* source_model, QObject* parent) FeedsProxyModel::FeedsProxyModel(FeedsModel* source_model, QObject* parent)
: QSortFilterProxyModel(parent), m_sourceModel(source_model), m_selectedItem(nullptr), : QSortFilterProxyModel(parent), m_sourceModel(source_model), m_selectedItem(nullptr),
m_showUnreadOnly(false), m_hiddenIndices(QList<QPair<int, QModelIndex>>()) { m_showUnreadOnly(false), m_hiddenIndices(QList<QPair<int, QModelIndex>>()) {
@ -71,6 +71,7 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex& start, int role, const
result.append(idx); result.append(idx);
} }
} }
// QString based matching. // QString based matching.
else { else {
if (entered_text.isEmpty()) { if (entered_text.isEmpty()) {
@ -126,7 +127,8 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex& start, int role, const
} }
if (recurse && hasChildren(idx)) { if (recurse && hasChildren(idx)) {
result += match(index(0, idx.column(), idx), role, (entered_text.isEmpty() ? value : entered_text), (all_hits ? -1 : hits - result.count()), result +=
match(index(0, idx.column(), idx), role, (entered_text.isEmpty() ? value : entered_text), (all_hits ? -1 : hits - result.count()),
flags); flags);
} }
} }
@ -191,6 +193,7 @@ bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source
if (should_show && m_hiddenIndices.contains(QPair<int, QModelIndex>(source_row, source_parent))) { if (should_show && m_hiddenIndices.contains(QPair<int, QModelIndex>(source_row, source_parent))) {
const_cast<FeedsProxyModel*>(this)->m_hiddenIndices.removeAll(QPair<int, QModelIndex>(source_row, source_parent)); const_cast<FeedsProxyModel*>(this)->m_hiddenIndices.removeAll(QPair<int, QModelIndex>(source_row, source_parent));
// Load status. // Load status.
emit expandAfterFilterIn(m_sourceModel->index(source_row, 0, source_parent)); emit expandAfterFilterIn(m_sourceModel->index(source_row, 0, source_parent));
} }
@ -219,7 +222,7 @@ bool FeedsProxyModel::filterAcceptsRowInternal(int source_row, const QModelIndex
// Recycle bin is always displayed. // Recycle bin is always displayed.
return true; return true;
} }
else if (item->isParentOf(m_selectedItem)/* || item->isChildOf(m_selectedItem)*/ || m_selectedItem == item) { else if (item->isParentOf(m_selectedItem) /* || item->isChildOf(m_selectedItem)*/ || m_selectedItem == item) {
// Currently selected item and all its parents and children must be displayed. // Currently selected item and all its parents and children must be displayed.
return true; return true;
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class FeedsModel; class FeedsModel;
class RootItem; class RootItem;
@ -28,6 +28,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FeedsProxyModel(FeedsModel* source_model, QObject* parent = 0); explicit FeedsProxyModel(FeedsModel* source_model, QObject* parent = 0);
virtual ~FeedsProxyModel(); virtual ~FeedsProxyModel();
@ -43,6 +44,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
void setShowUnreadOnly(bool show_unread_only); void setShowUnreadOnly(bool show_unread_only);
const RootItem* selectedItem() const; const RootItem* selectedItem() const;
void setSelectedItem(const RootItem* selected_item); void setSelectedItem(const RootItem* selected_item);
public slots: public slots:
@ -55,6 +57,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
void expandAfterFilterIn(QModelIndex idx) const; void expandAfterFilterIn(QModelIndex idx) const;
private: private:
// Compares two rows of data. // Compares two rows of data.
bool lessThan(const QModelIndex& left, const QModelIndex& right) const; bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
@ -64,6 +67,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
FeedsModel* m_sourceModel; FeedsModel* m_sourceModel;
const RootItem* m_selectedItem; const RootItem* m_selectedItem;
bool m_showUnreadOnly; bool m_showUnreadOnly;
QList<QPair<int, QModelIndex>> m_hiddenIndices; QList<QPair<int, QModelIndex>> m_hiddenIndices;
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -21,9 +22,7 @@
#include <QVariant> #include <QVariant>
Enclosure::Enclosure(const QString& url, const QString& mime) : m_url(url), m_mimeType(mime) {}
Enclosure::Enclosure(const QString& url, const QString& mime) : m_url(url), m_mimeType(mime) {
}
QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosures_data) { QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosures_data) {
QList<Enclosure> enclosures; QList<Enclosure> enclosures;
@ -33,6 +32,7 @@ QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosure
if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) { if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) {
QStringList mime_url = single_enclosure.split(ECNLOSURES_INNER_SEPARATOR); QStringList mime_url = single_enclosure.split(ECNLOSURES_INNER_SEPARATOR);
enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit()); enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit());
enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit()); enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit());
} }
@ -79,6 +79,7 @@ Message Message::fromSqlRecord(const QSqlRecord& record, bool* result) {
} }
Message message; Message message;
message.m_id = record.value(MSG_DB_ID_INDEX).toInt(); message.m_id = record.value(MSG_DB_ID_INDEX).toInt();
message.m_isRead = record.value(MSG_DB_READ_INDEX).toBool(); message.m_isRead = record.value(MSG_DB_READ_INDEX).toBool();
message.m_isImportant = record.value(MSG_DB_IMPORTANT_INDEX).toBool(); message.m_isImportant = record.value(MSG_DB_IMPORTANT_INDEX).toBool();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,10 @@
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include <QDateTime>
#include <QStringList>
#include <QSqlRecord>
#include <QDataStream> #include <QDataStream>
#include <QDateTime>
#include <QSqlRecord>
#include <QStringList>
// Represents single enclosure. // Represents single enclosure.
struct Enclosure { struct Enclosure {
@ -50,7 +50,6 @@ class Message {
// Creates Message from given record, which contains // Creates Message from given record, which contains
// row from query SELECT * FROM Messages WHERE ....; // row from query SELECT * FROM Messages WHERE ....;
static Message fromSqlRecord(const QSqlRecord& record, bool* result = nullptr); static Message fromSqlRecord(const QSqlRecord& record, bool* result = nullptr);
QString m_title; QString m_title;
QString m_url; QString m_url;
QString m_author; QString m_author;
@ -61,7 +60,6 @@ class Message {
int m_id; int m_id;
QString m_customId; QString m_customId;
QString m_customHash; QString m_customHash;
bool m_isRead; bool m_isRead;
bool m_isImportant; bool m_isImportant;
@ -78,6 +76,7 @@ class Message {
friend inline bool operator!=(const Message& lhs, const Message& rhs) { friend inline bool operator!=(const Message& lhs, const Message& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
}; };
// Serialize message state. // Serialize message state.

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,19 +18,18 @@
#include "core/messagesmodel.h" #include "core/messagesmodel.h"
#include "core/messagesmodelcache.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/textfactory.h"
#include "miscellaneous/databasefactory.h" #include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/databasequeries.h" #include "miscellaneous/databasequeries.h"
#include "services/abstract/serviceroot.h" #include "miscellaneous/iconfactory.h"
#include "core/messagesmodelcache.h" #include "miscellaneous/textfactory.h"
#include "services/abstract/recyclebin.h" #include "services/abstract/recyclebin.h"
#include "services/abstract/serviceroot.h"
#include <QSqlField> #include <QSqlField>
MessagesModel::MessagesModel(QObject* parent) MessagesModel::MessagesModel(QObject* parent)
: QSqlQueryModel(parent), MessagesModelSqlLayer(), : QSqlQueryModel(parent), MessagesModelSqlLayer(),
m_cache(new MessagesModelCache(this)), m_messageHighlighter(NoHighlighting), m_customDateFormat(QString()) { m_cache(new MessagesModelCache(this)), m_messageHighlighter(NoHighlighting), m_customDateFormat(QString()) {
@ -65,7 +65,6 @@ bool MessagesModel::setData(const QModelIndex& index, const QVariant& value, int
return true; return true;
} }
void MessagesModel::setupFonts() { void MessagesModel::setupFonts() {
m_normalFont = Application::font("MessagesView"); m_normalFont = Application::font("MessagesView");
m_boldFont = m_normalFont; m_boldFont = m_normalFont;
@ -153,20 +152,35 @@ Message MessagesModel::messageAt(int row_index) const {
void MessagesModel::setupHeaderData() { void MessagesModel::setupHeaderData() {
m_headerData << /*: Tooltip for ID of message.*/ tr("Id") << m_headerData << /*: Tooltip for ID of message.*/ tr("Id") <<
/*: Tooltip for "read" column in msg list.*/ tr("Read") << /*: Tooltip for "read" column in msg list.*/ tr("Read") <<
/*: Tooltip for "deleted" column in msg list.*/ tr("Deleted") << /*: Tooltip for "deleted" column in msg list.*/ tr("Deleted") <<
/*: Tooltip for "important" column in msg list.*/ tr("Important") << /*: Tooltip for "important" column in msg list.*/ tr("Important") <<
/*: Tooltip for name of feed for message.*/ tr("Feed") << /*: Tooltip for name of feed for message.*/ tr("Feed") <<
/*: Tooltip for title of message.*/ tr("Title") << /*: Tooltip for title of message.*/ tr("Title") <<
/*: Tooltip for url of message.*/ tr("Url") << /*: Tooltip for url of message.*/ tr("Url") <<
/*: Tooltip for author of message.*/ tr("Author") << /*: Tooltip for author of message.*/ tr("Author") <<
/*: Tooltip for creation date of message.*/ tr("Created on") << /*: Tooltip for creation date of message.*/ tr("Created on") <<
/*: Tooltip for contents of message.*/ tr("Contents") << /*: Tooltip for contents of message.*/ tr("Contents") <<
/*: Tooltip for "pdeleted" column in msg list.*/ tr("Permanently deleted") << /*: Tooltip for "pdeleted" column in msg list.*/ tr("Permanently deleted") <<
/*: Tooltip for attachments of message.*/ tr("Attachments") << /*: Tooltip for attachments of message.*/ tr("Attachments") <<
/*: Tooltip for account ID of message.*/ tr("Account ID") << /*: Tooltip for account ID of message.*/ tr("Account ID") <<
/*: Tooltip for custom ID of message.*/ tr("Custom ID") << /*: Tooltip for custom ID of message.*/ tr("Custom ID") <<
/*: Tooltip for custom hash string of message.*/ tr("Custom hash") << /*: Tooltip for custom hash string of message.*/ tr("Custom hash") <<
/*: Tooltip for custom ID of feed of message.*/ tr("Feed ID");; /*: Tooltip for custom ID of feed of message.*/ tr("Feed ID");;
m_tooltipData << tr("Id of the message.") << tr("Is message read?") << m_tooltipData << tr("Id of the message.") << tr("Is message read?") <<
tr("Is message deleted?") << tr("Is message important?") << tr("Is message deleted?") << tr("Is message important?") <<
@ -206,6 +220,7 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
} }
else if (index_column == MSG_DB_AUTHOR_INDEX) { else if (index_column == MSG_DB_AUTHOR_INDEX) {
const QString author_name = QSqlQueryModel::data(idx, role).toString(); const QString author_name = QSqlQueryModel::data(idx, role).toString();
return author_name.isEmpty() ? QSL("-") : author_name; return author_name.isEmpty() ? QSL("-") : author_name;
} }
else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) { else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) {
@ -227,10 +242,12 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
if (is_bin) { if (is_bin) {
QModelIndex idx_del = index(idx.row(), MSG_DB_PDELETED_INDEX); QModelIndex idx_del = index(idx.row(), MSG_DB_PDELETED_INDEX);
is_deleted = data(idx_del, Qt::EditRole).toBool(); is_deleted = data(idx_del, Qt::EditRole).toBool();
} }
else { else {
QModelIndex idx_del = index(idx.row(), MSG_DB_DELETED_INDEX); QModelIndex idx_del = index(idx.row(), MSG_DB_DELETED_INDEX);
is_deleted = data(idx_del, Qt::EditRole).toBool(); is_deleted = data(idx_del, Qt::EditRole).toBool();
} }
@ -249,12 +266,14 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
case HighlightImportant: { case HighlightImportant: {
QModelIndex idx_important = index(idx.row(), MSG_DB_IMPORTANT_INDEX); 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); QVariant dta = m_cache->containsData(idx_important.row()) ? m_cache->data(idx_important) : QSqlQueryModel::data(idx_important);
return dta.toInt() == 1 ? QColor(Qt::blue) : QVariant(); return dta.toInt() == 1 ? QColor(Qt::blue) : QVariant();
} }
case HighlightUnread: { case HighlightUnread: {
QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX); 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); QVariant dta = m_cache->containsData(idx_read.row()) ? m_cache->data(idx_read) : QSqlQueryModel::data(idx_read);
return dta.toInt() == 0 ? QColor(Qt::blue) : QVariant(); return dta.toInt() == 0 ? QColor(Qt::blue) : QVariant();
} }
@ -269,11 +288,13 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
if (index_column == MSG_DB_READ_INDEX) { if (index_column == MSG_DB_READ_INDEX) {
QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX); 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); QVariant dta = m_cache->containsData(idx_read.row()) ? m_cache->data(idx_read) : QSqlQueryModel::data(idx_read);
return dta.toInt() == 1 ? m_readIcon : m_unreadIcon; return dta.toInt() == 1 ? m_readIcon : m_unreadIcon;
} }
else if (index_column == MSG_DB_IMPORTANT_INDEX) { else if (index_column == MSG_DB_IMPORTANT_INDEX) {
QModelIndex idx_important = index(idx.row(), MSG_DB_IMPORTANT_INDEX); 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); QVariant dta = m_cache->containsData(idx_important.row()) ? m_cache->data(idx_important) : QSqlQueryModel::data(idx_important);
return dta.toInt() == 1 ? m_favoriteIcon : QVariant(); return dta.toInt() == 1 ? m_favoriteIcon : QVariant();
} }
else { else {
@ -360,6 +381,7 @@ bool MessagesModel::switchMessageImportance(int row_index) {
// Commit changes. // Commit changes.
if (DatabaseQueries::markMessageImportant(m_db, message.m_id, next_importance)) { if (DatabaseQueries::markMessageImportant(m_db, message.m_id, next_importance)) {
emit dataChanged(index(row_index, 0), index(row_index, MSG_DB_FEED_CUSTOM_ID_INDEX), QVector<int>() << Qt::FontRole); emit dataChanged(index(row_index, 0), index(row_index, MSG_DB_FEED_CUSTOM_ID_INDEX), QVector<int>() << Qt::FontRole);
return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem, return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem,
QList<QPair<Message, RootItem::Importance>>() << pair); QList<QPair<Message, RootItem::Importance>>() << pair);
} }
@ -370,17 +392,20 @@ bool MessagesModel::switchMessageImportance(int row_index) {
bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages) { bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages) {
QStringList message_ids; QStringList message_ids;
QList<QPair<Message, RootItem::Importance>> message_states; QList<QPair<Message, RootItem::Importance>> message_states;
// Obtain IDs of all desired messages. // Obtain IDs of all desired messages.
foreach (const QModelIndex& message, messages) { foreach (const QModelIndex& message, messages) {
const Message msg = messageAt(message.row()); const Message msg = messageAt(message.row());
RootItem::Importance message_importance = messageImportance((message.row())); RootItem::Importance message_importance = messageImportance((message.row()));
message_states.append(QPair<Message, RootItem::Importance>(msg, message_importance == RootItem::Important ? message_states.append(QPair<Message, RootItem::Importance>(msg, message_importance == RootItem::Important ?
RootItem::NotImportant : RootItem::NotImportant :
RootItem::Important)); RootItem::Important));
message_ids.append(QString::number(msg.m_id)); message_ids.append(QString::number(msg.m_id));
QModelIndex idx_msg_imp = index(message.row(), MSG_DB_IMPORTANT_INDEX); QModelIndex idx_msg_imp = index(message.row(), MSG_DB_IMPORTANT_INDEX);
setData(idx_msg_imp, message_importance == RootItem::Important ? setData(idx_msg_imp, message_importance == RootItem::Important ?
(int) RootItem::NotImportant : (int) RootItem::NotImportant :
(int) RootItem::Important); (int) RootItem::Important);
@ -402,11 +427,13 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages
bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) { bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) {
QStringList message_ids; QStringList message_ids;
QList<Message> msgs; QList<Message> msgs;
// Obtain IDs of all desired messages. // Obtain IDs of all desired messages.
foreach (const QModelIndex& message, messages) { foreach (const QModelIndex& message, messages) {
const Message msg = messageAt(message.row()); const Message msg = messageAt(message.row());
msgs.append(msg); msgs.append(msg);
message_ids.append(QString::number(msg.m_id)); message_ids.append(QString::number(msg.m_id));
@ -443,11 +470,13 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) {
bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootItem::ReadStatus read) { bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootItem::ReadStatus read) {
QStringList message_ids; QStringList message_ids;
QList<Message> msgs; QList<Message> msgs;
// Obtain IDs of all desired messages. // Obtain IDs of all desired messages.
foreach (const QModelIndex& message, messages) { foreach (const QModelIndex& message, messages) {
Message msg = messageAt(message.row()); Message msg = messageAt(message.row());
msgs.append(msg); msgs.append(msg);
message_ids.append(QString::number(msg.m_id)); message_ids.append(QString::number(msg.m_id));
setData(index(message.row(), MSG_DB_READ_INDEX), (int) read); setData(index(message.row(), MSG_DB_READ_INDEX), (int) read);
@ -469,11 +498,13 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt
bool MessagesModel::setBatchMessagesRestored(const QModelIndexList& messages) { bool MessagesModel::setBatchMessagesRestored(const QModelIndexList& messages) {
QStringList message_ids; QStringList message_ids;
QList<Message> msgs; QList<Message> msgs;
// Obtain IDs of all desired messages. // Obtain IDs of all desired messages.
foreach (const QModelIndex& message, messages) { foreach (const QModelIndex& message, messages) {
const Message msg = messageAt(message.row()); const Message msg = messageAt(message.row());
msgs.append(msg); msgs.append(msg);
message_ids.append(QString::number(msg.m_id)); message_ids.append(QString::number(msg.m_id));
setData(index(message.row(), MSG_DB_PDELETED_INDEX), 0); setData(index(message.row(), MSG_DB_PDELETED_INDEX), 0);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,23 +19,23 @@
#ifndef MESSAGESMODEL_H #ifndef MESSAGESMODEL_H
#define MESSAGESMODEL_H #define MESSAGESMODEL_H
#include <QSqlQueryModel>
#include "core/messagesmodelsqllayer.h" #include "core/messagesmodelsqllayer.h"
#include <QSqlQueryModel>
#include "definitions/definitions.h"
#include "core/message.h" #include "core/message.h"
#include "definitions/definitions.h"
#include "services/abstract/rootitem.h" #include "services/abstract/rootitem.h"
#include <QFont> #include <QFont>
#include <QIcon> #include <QIcon>
class MessagesModelCache; class MessagesModelCache;
class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer { class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
Q_OBJECT Q_OBJECT
public: public:
// Enum which describes basic filtering schemes // Enum which describes basic filtering schemes
// for messages. // for messages.
enum MessageHighlighter { enum MessageHighlighter {
@ -64,6 +65,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
RootItem::Importance messageImportance(int row_index) const; RootItem::Importance messageImportance(int row_index) const;
RootItem* loadedItem() const; RootItem* loadedItem() const;
void updateDateFormat(); void updateDateFormat();
void reloadWholeLayout(); void reloadWholeLayout();
@ -84,6 +86,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
void loadMessages(RootItem* item); void loadMessages(RootItem* item);
public slots: public slots:
// NOTE: These methods DO NOT actually change data in the DB, just in the model. // NOTE: These methods DO NOT actually change data in the DB, just in the model.
// These are particularly used by msg browser. // These are particularly used by msg browser.
bool setMessageImportantById(int id, RootItem::Importance important); bool setMessageImportantById(int id, RootItem::Importance important);
@ -96,9 +99,9 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
MessagesModelCache* m_cache; MessagesModelCache* m_cache;
MessageHighlighter m_messageHighlighter; MessageHighlighter m_messageHighlighter;
QString m_customDateFormat; QString m_customDateFormat;
RootItem* m_selectedItem; RootItem* m_selectedItem;
QList<QString> m_headerData; QList<QString> m_headerData;
QList<QString> m_tooltipData; QList<QString> m_tooltipData;
@ -106,7 +109,6 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
QFont m_boldFont; QFont m_boldFont;
QFont m_normalStrikedFont; QFont m_normalStrikedFont;
QFont m_boldStrikedFont; QFont m_boldStrikedFont;
QIcon m_favoriteIcon; QIcon m_favoriteIcon;
QIcon m_readIcon; QIcon m_readIcon;
QIcon m_unreadIcon; QIcon m_unreadIcon;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,12 +20,9 @@
#include "miscellaneous/textfactory.h" #include "miscellaneous/textfactory.h"
MessagesModelCache::MessagesModelCache(QObject* parent) : QObject(parent), m_msgCache(QHash<int, QSqlRecord>()) {}
MessagesModelCache::MessagesModelCache(QObject* parent) : QObject(parent), m_msgCache(QHash<int, QSqlRecord>()) { MessagesModelCache::~MessagesModelCache() {}
}
MessagesModelCache::~MessagesModelCache() {
}
void MessagesModelCache::setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record) { void MessagesModelCache::setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record) {
if (!m_msgCache.contains(index.row())) { if (!m_msgCache.contains(index.row())) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,9 +23,8 @@
#include "core/message.h" #include "core/message.h"
#include <QVariant>
#include <QModelIndex> #include <QModelIndex>
#include <QVariant>
class MessagesModelCache : public QObject { class MessagesModelCache : public QObject {
Q_OBJECT Q_OBJECT
@ -46,6 +46,7 @@ class MessagesModelCache : public QObject {
} }
void setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record); void setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record);
QVariant data(const QModelIndex& idx); QVariant data(const QModelIndex& idx);
private: private:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
MessagesModelSqlLayer::MessagesModelSqlLayer() MessagesModelSqlLayer::MessagesModelSqlLayer()
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames(QMap<int, QString>()), : m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames(QMap<int, QString>()),
m_sortColumns(QList<int>()), m_sortOrders(QList<Qt::SortOrder>()) { m_sortColumns(QList<int>()), m_sortOrders(QList<Qt::SortOrder>()) {
@ -95,6 +95,7 @@ QString MessagesModelSqlLayer::orderByClause() const {
for (int i = 0; i < m_sortColumns.size(); i++) { for (int i = 0; i < m_sortColumns.size(); i++) {
QString field_name(m_fieldNames[m_sortColumns[i]]); QString field_name(m_fieldNames[m_sortColumns[i]]);
sorts.append(field_name + (m_sortOrders[i] == Qt::AscendingOrder ? QSL(" ASC") : QSL(" DESC"))); sorts.append(field_name + (m_sortOrders[i] == Qt::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -15,15 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef MESSAGESMODELSQLLAYER_H #ifndef MESSAGESMODELSQLLAYER_H
#define MESSAGESMODELSQLLAYER_H #define MESSAGESMODELSQLLAYER_H
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QMap>
#include <QList> #include <QList>
#include <QMap>
class MessagesModelSqlLayer { class MessagesModelSqlLayer {
public: public:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,7 +20,6 @@
#include "core/messagesmodel.h" #include "core/messagesmodel.h"
MessagesProxyModel::MessagesProxyModel(MessagesModel* source_model, QObject* parent) MessagesProxyModel::MessagesProxyModel(MessagesModel* source_model, QObject* parent)
: QSortFilterProxyModel(parent), m_sourceModel(source_model) { : QSortFilterProxyModel(parent), m_sourceModel(source_model) {
setObjectName(QSL("MessagesProxyModel")); setObjectName(QSL("MessagesProxyModel"));
@ -70,6 +70,7 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_
bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const { bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const {
Q_UNUSED(left) Q_UNUSED(left)
Q_UNUSED(right) Q_UNUSED(right)
// NOTE: Comparisons are done by SQL servers itself, not client-side. // NOTE: Comparisons are done by SQL servers itself, not client-side.
return false; return false;
} }
@ -117,6 +118,7 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
result.append(idx); result.append(idx);
} }
} }
// QString based matching. // QString based matching.
else { else {
if (entered_text.isEmpty()) { if (entered_text.isEmpty()) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,13 +21,13 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class MessagesModel; class MessagesModel;
class MessagesProxyModel : public QSortFilterProxyModel { class MessagesProxyModel : public QSortFilterProxyModel {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = 0); explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = 0);
virtual ~MessagesProxyModel(); virtual ~MessagesProxyModel();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -46,7 +47,8 @@
#define DEFAULT_LOCALE "en" #define DEFAULT_LOCALE "en"
#define DEFAULT_FEED_ENCODING "UTF-8" #define DEFAULT_FEED_ENCODING "UTF-8"
#define DEFAULT_FEED_TYPE "RSS" #define DEFAULT_FEED_TYPE "RSS"
#define URL_REGEXP "^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?$" #define URL_REGEXP \
"^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?$"
#define USER_AGENT_HTTP_HEADER "User-Agent" #define USER_AGENT_HTTP_HEADER "User-Agent"
#define TEXT_TITLE_LIMIT 30 #define TEXT_TITLE_LIMIT 30
#define RESELECT_MESSAGE_THRESSHOLD 500 #define RESELECT_MESSAGE_THRESSHOLD 500
@ -140,6 +142,7 @@
#define APP_THEME_SUFFIX ".png" #define APP_THEME_SUFFIX ".png"
#ifndef QSL #ifndef QSL
// Thin macro wrapper for literal strings. // Thin macro wrapper for literal strings.
// They are much more memory efficient and faster. // They are much more memory efficient and faster.
// Use it for all literals except for two cases: // Use it for all literals except for two cases:
@ -149,12 +152,14 @@
#endif #endif
#ifndef QL1S #ifndef QL1S
// Macro for latin strings. Latin strings are // Macro for latin strings. Latin strings are
// faster than QStrings created from literals. // faster than QStrings created from literals.
#define QL1S(x) QLatin1String(x) #define QL1S(x) QLatin1String(x)
#endif #endif
#ifndef QL1C #ifndef QL1C
// Macro for latin chars. // Macro for latin chars.
#define QL1C(x) QLatin1Char(x) #define QL1C(x) QLatin1Char(x)
#endif #endif

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -23,9 +24,7 @@
#include <QAction> #include <QAction>
DynamicShortcuts::DynamicShortcuts() {}
DynamicShortcuts::DynamicShortcuts() {
}
void DynamicShortcuts::save(const QList<QAction*>& actions) { void DynamicShortcuts::save(const QList<QAction*>& actions) {
Settings* settings = qApp->settings(); Settings* settings = qApp->settings();
@ -42,6 +41,7 @@ void DynamicShortcuts::load(const QList<QAction*>& actions) {
QString shortcut_for_action = settings->value(GROUP(Keyboard), QString shortcut_for_action = settings->value(GROUP(Keyboard),
action->objectName(), action->objectName(),
action->shortcut().toString(QKeySequence::PortableText)).toString(); action->shortcut().toString(QKeySequence::PortableText)).toString();
action->setShortcut(QKeySequence::fromString(shortcut_for_action, QKeySequence::PortableText)); action->setShortcut(QKeySequence::fromString(shortcut_for_action, QKeySequence::PortableText));
} }
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,11 @@
#include <QList> #include <QList>
class QAction; class QAction;
class DynamicShortcuts { class DynamicShortcuts {
public: public:
// Checks the application settings and then initializes shortcut of // Checks the application settings and then initializes shortcut of
// each action from actions from the settings. // each action from actions from the settings.
static void load(const QList<QAction*>& actions); static void load(const QList<QAction*>& actions);
@ -34,6 +35,7 @@ class DynamicShortcuts {
static void save(const QList<QAction*>& actions); static void save(const QList<QAction*>& actions);
private: private:
// Constructor. // Constructor.
explicit DynamicShortcuts(); explicit DynamicShortcuts();
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,15 +18,14 @@
#include "dynamic-shortcuts/dynamicshortcutswidget.h" #include "dynamic-shortcuts/dynamicshortcutswidget.h"
#include "dynamic-shortcuts/shortcutcatcher.h"
#include "dynamic-shortcuts/shortcutbutton.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "dynamic-shortcuts/shortcutbutton.h"
#include "dynamic-shortcuts/shortcutcatcher.h"
#include <QGridLayout>
#include <QAction> #include <QAction>
#include <QGridLayout>
#include <QLabel> #include <QLabel>
DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget* parent) : QWidget(parent) { DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget* parent) : QWidget(parent) {
// Create layout for this control and set is as active. // Create layout for this control and set is as active.
m_layout = new QGridLayout(this); m_layout = new QGridLayout(this);
@ -77,19 +77,24 @@ void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
foreach (QAction* action, actions) { foreach (QAction* action, actions) {
// Create shortcut catcher for this action and set default shortcut. // Create shortcut catcher for this action and set default shortcut.
ShortcutCatcher* catcher = new ShortcutCatcher(this); ShortcutCatcher* catcher = new ShortcutCatcher(this);
catcher->setDefaultShortcut(action->shortcut()); catcher->setDefaultShortcut(action->shortcut());
// Store information for re-initialization of shortcuts // Store information for re-initialization of shortcuts
// of actions when widget gets "confirmed". // of actions when widget gets "confirmed".
QPair<QAction*, ShortcutCatcher*> new_binding; QPair<QAction*, ShortcutCatcher*> new_binding;
new_binding.first = action; new_binding.first = action;
new_binding.second = catcher; new_binding.second = catcher;
m_actionBindings << new_binding; m_actionBindings << new_binding;
// Add new catcher to our control. // Add new catcher to our control.
QLabel* action_label = new QLabel(this); QLabel* action_label = new QLabel(this);
action_label->setText(action->text().remove(QSL("&"))); action_label->setText(action->text().remove(QSL("&")));
action_label->setToolTip(action->toolTip()); action_label->setToolTip(action->toolTip());
action_label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); action_label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
QLabel* action_icon = new QLabel(this); QLabel* action_icon = new QLabel(this);
action_icon->setPixmap(action->icon().pixmap(ICON_SIZE_SETTINGS, ICON_SIZE_SETTINGS)); action_icon->setPixmap(action->icon().pixmap(ICON_SIZE_SETTINGS, ICON_SIZE_SETTINGS));
action_icon->setToolTip(action->toolTip()); action_icon->setToolTip(action->toolTip());
m_layout->addWidget(action_icon, row_id, 0); m_layout->addWidget(action_icon, row_id, 0);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QWidget> #include <QWidget>
class QGridLayout; class QGridLayout;
class ShortcutCatcher; class ShortcutCatcher;
@ -30,6 +30,7 @@ class DynamicShortcutsWidget : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit DynamicShortcutsWidget(QWidget* parent = 0); explicit DynamicShortcutsWidget(QWidget* parent = 0);
virtual ~DynamicShortcutsWidget(); virtual ~DynamicShortcutsWidget();
@ -58,6 +59,7 @@ class DynamicShortcutsWidget : public QWidget {
private: private:
QGridLayout* m_layout; QGridLayout* m_layout;
QList<ActionBinding> m_actionBindings; QList<ActionBinding> m_actionBindings;
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -16,11 +17,11 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
/****************************************************************************** /******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com> Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
@ -31,17 +32,17 @@ modification, are permitted provided that the following conditions are met:
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/ *******************************************************************************/
#include "dynamic-shortcuts/shortcutbutton.h" #include "dynamic-shortcuts/shortcutbutton.h"
@ -49,14 +50,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QKeyEvent> #include <QKeyEvent>
ShortcutButton::ShortcutButton(ShortcutCatcher* catcher, QWidget* parent) ShortcutButton::ShortcutButton(ShortcutCatcher* catcher, QWidget* parent)
: QPushButton(parent), m_catcher(catcher) { : QPushButton(parent), m_catcher(catcher) {
setMinimumWidth(100); setMinimumWidth(100);
} }
ShortcutButton::~ShortcutButton() { ShortcutButton::~ShortcutButton() {}
}
void ShortcutButton::keyPressEvent(QKeyEvent* event) { void ShortcutButton::keyPressEvent(QKeyEvent* event) {
int pressed_key = event->key(); int pressed_key = event->key();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -16,11 +17,11 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
/****************************************************************************** /******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com> Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
@ -31,30 +32,30 @@ modification, are permitted provided that the following conditions are met:
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/ *******************************************************************************/
#ifndef SHORTCUTBUTTON_H #ifndef SHORTCUTBUTTON_H
#define SHORTCUTBUTTON_H #define SHORTCUTBUTTON_H
#include <QPushButton> #include <QPushButton>
class ShortcutCatcher; class ShortcutCatcher;
class ShortcutButton : public QPushButton { class ShortcutButton : public QPushButton {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit ShortcutButton(ShortcutCatcher* catcher, QWidget* parent = 0); explicit ShortcutButton(ShortcutCatcher* catcher, QWidget* parent = 0);
virtual ~ShortcutButton(); virtual ~ShortcutButton();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -16,11 +17,11 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
/****************************************************************************** /******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com> Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
@ -31,17 +32,17 @@ modification, are permitted provided that the following conditions are met:
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/ *******************************************************************************/
#include "dynamic-shortcuts/shortcutcatcher.h" #include "dynamic-shortcuts/shortcutcatcher.h"
@ -51,35 +52,40 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QHBoxLayout> #include <QHBoxLayout>
ShortcutCatcher::ShortcutCatcher(QWidget* parent) ShortcutCatcher::ShortcutCatcher(QWidget* parent)
: QWidget(parent) { : QWidget(parent) {
// Setup layout of the control // Setup layout of the control
m_layout = new QHBoxLayout(this); m_layout = new QHBoxLayout(this);
m_layout->setMargin(0); m_layout->setMargin(0);
m_layout->setSpacing(1); m_layout->setSpacing(1);
// Create reset button. // Create reset button.
m_btnReset = new PlainToolButton(this); m_btnReset = new PlainToolButton(this);
m_btnReset->setIcon(qApp->icons()->fromTheme(QSL("document-revert"))); m_btnReset->setIcon(qApp->icons()->fromTheme(QSL("document-revert")));
m_btnReset->setFocusPolicy(Qt::NoFocus); m_btnReset->setFocusPolicy(Qt::NoFocus);
m_btnReset->setToolTip(tr("Reset to original shortcut.")); m_btnReset->setToolTip(tr("Reset to original shortcut."));
// Create clear button. // Create clear button.
m_btnClear = new PlainToolButton(this); m_btnClear = new PlainToolButton(this);
m_btnClear->setIcon(qApp->icons()->fromTheme(QSL("list-remove"))); m_btnClear->setIcon(qApp->icons()->fromTheme(QSL("list-remove")));
m_btnClear->setFocusPolicy(Qt::NoFocus); m_btnClear->setFocusPolicy(Qt::NoFocus);
m_btnClear->setToolTip(tr("Clear current shortcut.")); m_btnClear->setToolTip(tr("Clear current shortcut."));
// Clear main shortcut catching button. // Clear main shortcut catching button.
m_btnChange = new ShortcutButton(this); m_btnChange = new ShortcutButton(this);
m_btnChange->setFocusPolicy(Qt::StrongFocus); m_btnChange->setFocusPolicy(Qt::StrongFocus);
m_btnChange->setToolTip(tr("Click and hit new shortcut.")); m_btnChange->setToolTip(tr("Click and hit new shortcut."));
// Add both buttons to the layout. // Add both buttons to the layout.
m_layout->addWidget(m_btnChange); m_layout->addWidget(m_btnChange);
m_layout->addWidget(m_btnReset); m_layout->addWidget(m_btnReset);
m_layout->addWidget(m_btnClear); m_layout->addWidget(m_btnClear);
// Establish needed connections. // Establish needed connections.
connect(m_btnReset, &QToolButton::clicked, this, &ShortcutCatcher::resetShortcut); connect(m_btnReset, &QToolButton::clicked, this, &ShortcutCatcher::resetShortcut);
connect(m_btnClear, &QToolButton::clicked, this, &ShortcutCatcher::clearShortcut); connect(m_btnClear, &QToolButton::clicked, this, &ShortcutCatcher::clearShortcut);
connect(m_btnChange, &QToolButton::clicked, this, &ShortcutCatcher::startRecording); connect(m_btnChange, &QToolButton::clicked, this, &ShortcutCatcher::startRecording);
// Prepare initial state of the control. // Prepare initial state of the control.
updateDisplayShortcut(); updateDisplayShortcut();
} }
@ -117,6 +123,7 @@ void ShortcutCatcher::controlModifierlessTimout() {
void ShortcutCatcher::updateDisplayShortcut() { void ShortcutCatcher::updateDisplayShortcut() {
QString str = m_currentSequence.toString(QKeySequence::NativeText); QString str = m_currentSequence.toString(QKeySequence::NativeText);
str.replace(QL1S("&"), QL1S("&&")); str.replace(QL1S("&"), QL1S("&&"));
if (m_isRecording) { if (m_isRecording) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -16,11 +17,11 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
/****************************************************************************** /******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com> Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
@ -31,24 +32,23 @@ modification, are permitted provided that the following conditions are met:
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/ *******************************************************************************/
#ifndef SHORTCUTCATCHER_H #ifndef SHORTCUTCATCHER_H
#define SHORTCUTCATCHER_H #define SHORTCUTCATCHER_H
#include <QWidget> #include <QWidget>
class QHBoxLayout; class QHBoxLayout;
class QToolButton; class QToolButton;
class ShortcutButton; class ShortcutButton;
@ -59,6 +59,7 @@ class ShortcutCatcher : public QWidget {
friend class ShortcutButton; friend class ShortcutButton;
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit ShortcutCatcher(QWidget* parent = 0); explicit ShortcutCatcher(QWidget* parent = 0);
virtual ~ShortcutCatcher(); virtual ~ShortcutCatcher();
@ -86,10 +87,8 @@ class ShortcutCatcher : public QWidget {
QToolButton* m_btnClear; QToolButton* m_btnClear;
ShortcutButton* m_btnChange; ShortcutButton* m_btnChange;
QHBoxLayout* m_layout; QHBoxLayout* m_layout;
QKeySequence m_currentSequence; QKeySequence m_currentSequence;
QKeySequence m_defaultSequence; QKeySequence m_defaultSequence;
bool m_isRecording; bool m_isRecording;
int m_numKey; int m_numKey;
uint m_modifierKeys; uint m_modifierKeys;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,12 +18,9 @@
#include "exceptions/applicationexception.h" #include "exceptions/applicationexception.h"
ApplicationException::ApplicationException(const QString& message) : m_message(message) {}
ApplicationException::ApplicationException(const QString& message) : m_message(message) { ApplicationException::~ApplicationException() {}
}
ApplicationException::~ApplicationException() {
}
QString ApplicationException::message() const { QString ApplicationException::message() const {
return m_message; return m_message;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QString> #include <QString>
class ApplicationException { class ApplicationException {
public: public:
explicit ApplicationException(const QString& message = QString()); explicit ApplicationException(const QString& message = QString());

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,9 +18,6 @@
#include "exceptions/ioexception.h" #include "exceptions/ioexception.h"
IOException::IOException(const QString& message) : ApplicationException(message) {}
IOException::IOException(const QString& message) : ApplicationException(message) { IOException::~IOException() {}
}
IOException::~IOException() {
}

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include "exceptions/applicationexception.h" #include "exceptions/applicationexception.h"
class IOException : public ApplicationException { class IOException : public ApplicationException {
public: public:
explicit IOException(const QString& message = QString()); explicit IOException(const QString& message = QString());

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,12 +20,9 @@
#include <QKeyEvent> #include <QKeyEvent>
BaseLineEdit::BaseLineEdit(QWidget* parent) : QLineEdit(parent) {}
BaseLineEdit::BaseLineEdit(QWidget* parent) : QLineEdit(parent) { BaseLineEdit::~BaseLineEdit() {}
}
BaseLineEdit::~BaseLineEdit() {
}
void BaseLineEdit::submit(const QString& text) { void BaseLineEdit::submit(const QString& text) {
setText(text); setText(text);
@ -34,6 +32,7 @@ void BaseLineEdit::submit(const QString& text) {
void BaseLineEdit::keyPressEvent(QKeyEvent* event) { void BaseLineEdit::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
emit submitted(text()); emit submitted(text());
event->accept(); event->accept();
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,11 @@
#include <QLineEdit> #include <QLineEdit>
class BaseLineEdit : public QLineEdit { class BaseLineEdit : public QLineEdit {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit BaseLineEdit(QWidget* parent = 0); explicit BaseLineEdit(QWidget* parent = 0);
virtual ~BaseLineEdit(); virtual ~BaseLineEdit();
@ -36,6 +37,7 @@ class BaseLineEdit : public QLineEdit {
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);
signals: signals:
// Emitted if user hits ENTER button. // Emitted if user hits ENTER button.
void submitted(const QString& text); void submitted(const QString& text);
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -23,10 +24,10 @@
#include <QWidgetAction> #include <QWidgetAction>
BaseToolBar::BaseToolBar(const QString& title, QWidget* parent) : QToolBar(title, parent) { BaseToolBar::BaseToolBar(const QString& title, QWidget* parent) : QToolBar(title, parent) {
// Update right margin of filter textbox. // Update right margin of filter textbox.
QMargins margins = contentsMargins(); QMargins margins = contentsMargins();
margins.setRight(margins.right() + FILTER_RIGHT_MARGIN); margins.setRight(margins.right() + FILTER_RIGHT_MARGIN);
setContentsMargins(margins); setContentsMargins(margins);
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,9 +21,9 @@
#include <QToolBar> #include <QToolBar>
class BaseBar { class BaseBar {
public: public:
// Returns all actions which can be added to the toolbar. // Returns all actions which can be added to the toolbar.
virtual QList<QAction*> availableActions() const = 0; virtual QList<QAction*> availableActions() const = 0;
@ -40,7 +41,6 @@ class BaseBar {
// Loads the toolbar state from settings. // Loads the toolbar state from settings.
virtual void loadSavedActions(); virtual void loadSavedActions();
virtual QList<QAction*> getSpecificActions(const QStringList& actions) = 0; virtual QList<QAction*> getSpecificActions(const QStringList& actions) = 0;
virtual void loadSpecificActions(const QList<QAction*>& actions) = 0; virtual void loadSpecificActions(const QList<QAction*>& actions) = 0;
@ -52,6 +52,7 @@ class BaseToolBar : public QToolBar, public BaseBar {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit BaseToolBar(const QString& title, QWidget* parent = 0); explicit BaseToolBar(const QString& title, QWidget* parent = 0);
virtual ~BaseToolBar(); virtual ~BaseToolBar();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,16 +18,14 @@
#include "gui/colorlabel.h" #include "gui/colorlabel.h"
#include <QPaintEvent>
#include <QPainter> #include <QPainter>
#include <QPaintEvent>
ColorLabel::ColorLabel(QWidget* parent) : QLabel(parent), m_color(QColor()) { ColorLabel::ColorLabel(QWidget* parent) : QLabel(parent), m_color(QColor()) {
setFixedWidth(20); setFixedWidth(20);
} }
ColorLabel::~ColorLabel() { ColorLabel::~ColorLabel() {}
}
QColor ColorLabel::color() const { QColor ColorLabel::color() const {
return m_color; return m_color;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QLabel> #include <QLabel>
class ColorLabel : public QLabel { class ColorLabel : public QLabel {
Q_OBJECT Q_OBJECT

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -21,17 +22,18 @@
#include <QHBoxLayout> #include <QHBoxLayout>
ComboBoxWithStatus::ComboBoxWithStatus(QWidget* parent) ComboBoxWithStatus::ComboBoxWithStatus(QWidget* parent)
: WidgetWithStatus(parent) { : WidgetWithStatus(parent) {
m_wdgInput = new QComboBox(this); m_wdgInput = new QComboBox(this);
// Set correct size for the tool button. // Set correct size for the tool button.
const int txt_input_height = m_wdgInput->sizeHint().height(); const int txt_input_height = m_wdgInput->sizeHint().height();
m_btnStatus->setFixedSize(txt_input_height, txt_input_height); m_btnStatus->setFixedSize(txt_input_height, txt_input_height);
// Compose the layout. // Compose the layout.
m_layout->addWidget(m_wdgInput); m_layout->addWidget(m_wdgInput);
m_layout->addWidget(m_btnStatus); m_layout->addWidget(m_btnStatus);
} }
ComboBoxWithStatus::~ComboBoxWithStatus() { ComboBoxWithStatus::~ComboBoxWithStatus() {}
}

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,11 +23,11 @@
#include <QComboBox> #include <QComboBox>
class ComboBoxWithStatus : public WidgetWithStatus { class ComboBoxWithStatus : public WidgetWithStatus {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit ComboBoxWithStatus(QWidget* parent = 0); explicit ComboBoxWithStatus(QWidget* parent = 0);
virtual ~ComboBoxWithStatus(); virtual ~ComboBoxWithStatus();
@ -34,6 +35,7 @@ class ComboBoxWithStatus : public WidgetWithStatus {
inline QComboBox* comboBox() const { inline QComboBox* comboBox() const {
return static_cast<QComboBox*>(m_wdgInput); return static_cast<QComboBox*>(m_wdgInput);
} }
}; };
#endif // COMBOBOXWITHSTATUS_H #endif // COMBOBOXWITHSTATUS_H

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -24,11 +25,11 @@
#include "definitions/definitions.h" #include "definitions/definitions.h"
class FormAbout : public QDialog { class FormAbout : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FormAbout(QWidget* parent); explicit FormAbout(QWidget* parent);
virtual ~FormAbout(); virtual ~FormAbout();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,18 +18,18 @@
#include "gui/dialogs/formaddaccount.h" #include "gui/dialogs/formaddaccount.h"
#include "core/feedsmodel.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "core/feedsmodel.h"
#include "services/standard/standardserviceentrypoint.h" #include "services/standard/standardserviceentrypoint.h"
#include <QListWidget>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QListWidget>
FormAddAccount::FormAddAccount(const QList<ServiceEntryPoint*>& entry_points, FeedsModel* model, QWidget* parent) FormAddAccount::FormAddAccount(const QList<ServiceEntryPoint*>& entry_points, FeedsModel* model, QWidget* parent)
: QDialog(parent), m_ui(new Ui::FormAddAccount), m_model(model), m_entryPoints(entry_points) { : QDialog(parent), m_ui(new Ui::FormAddAccount), m_model(model), m_entryPoints(entry_points) {
m_ui->setupUi(this); m_ui->setupUi(this);
// Set flags and attributes. // Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("document-new"))); setWindowIcon(qApp->icons()->fromTheme(QSL("document-new")));
@ -57,6 +58,7 @@ void FormAddAccount::addSelectedAccount() {
void FormAddAccount::displayActiveEntryPointDetails() { void FormAddAccount::displayActiveEntryPointDetails() {
const ServiceEntryPoint* point = selectedEntryPoint(); const ServiceEntryPoint* point = selectedEntryPoint();
m_ui->m_txtAuthor->setText(point->author()); m_ui->m_txtAuthor->setText(point->author());
m_ui->m_txtDescription->setText(point->description()); m_ui->m_txtDescription->setText(point->description());
m_ui->m_txtName->setText(point->name()); m_ui->m_txtName->setText(point->name());

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_formaddaccount.h" #include "ui_formaddaccount.h"
class ServiceEntryPoint; class ServiceEntryPoint;
class FeedsModel; class FeedsModel;
@ -39,10 +39,12 @@ class FormAddAccount : public QDialog {
private: private:
ServiceEntryPoint* selectedEntryPoint() const; ServiceEntryPoint* selectedEntryPoint() const;
void loadEntryPoints(); void loadEntryPoints();
QScopedPointer<Ui::FormAddAccount> m_ui; QScopedPointer<Ui::FormAddAccount> m_ui;
FeedsModel* m_model; FeedsModel* m_model;
QList<ServiceEntryPoint*> m_entryPoints; QList<ServiceEntryPoint*> m_entryPoints;
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,16 +18,15 @@
#include "gui/dialogs/formbackupdatabasesettings.h" #include "gui/dialogs/formbackupdatabasesettings.h"
#include "exceptions/applicationexception.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "exceptions/applicationexception.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QCheckBox> #include <QCheckBox>
#include <QFileDialog>
#include <QDateTime> #include <QDateTime>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QPushButton>
FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget* parent) : QDialog(parent), m_ui(new Ui::FormBackupDatabaseSettings) { FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget* parent) : QDialog(parent), m_ui(new Ui::FormBackupDatabaseSettings) {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -40,7 +40,8 @@ FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget* parent) : QDialo
connect(m_ui->m_txtBackupName->lineEdit(), &BaseLineEdit::textChanged, this, &FormBackupDatabaseSettings::checkOkButton); connect(m_ui->m_txtBackupName->lineEdit(), &BaseLineEdit::textChanged, this, &FormBackupDatabaseSettings::checkOkButton);
connect(m_ui->m_btnSelectFolder, &QPushButton::clicked, this, &FormBackupDatabaseSettings::selectFolderInitial); connect(m_ui->m_btnSelectFolder, &QPushButton::clicked, this, &FormBackupDatabaseSettings::selectFolderInitial);
selectFolder(qApp->documentsFolder()); selectFolder(qApp->documentsFolder());
m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + QL1S("_") + QDateTime::currentDateTime().toString(QSL("yyyyMMddHHmm"))); m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + QL1S("_") +
QDateTime::currentDateTime().toString(QSL("yyyyMMddHHmm")));
m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
if (qApp->database()->activeDatabaseDriver() != DatabaseFactory::SQLITE && if (qApp->database()->activeDatabaseDriver() != DatabaseFactory::SQLITE &&

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,16 +23,15 @@
#include "ui_formbackupdatabasesettings.h" #include "ui_formbackupdatabasesettings.h"
class FormBackupDatabaseSettings : public QDialog { class FormBackupDatabaseSettings : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors // Constructors and destructors
explicit FormBackupDatabaseSettings(QWidget* parent = 0); explicit FormBackupDatabaseSettings(QWidget* parent = 0);
virtual ~FormBackupDatabaseSettings(); virtual ~FormBackupDatabaseSettings();
private slots: private slots:
void performBackup(); void performBackup();
void selectFolderInitial(); void selectFolderInitial();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,16 +19,16 @@
#include "gui/dialogs/formdatabasecleanup.h" #include "gui/dialogs/formdatabasecleanup.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/databasefactory.h" #include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QPushButton> #include <QPushButton>
FormDatabaseCleanup::FormDatabaseCleanup(QWidget* parent) : QDialog(parent), m_ui(new Ui::FormDatabaseCleanup), m_cleaner(nullptr) { FormDatabaseCleanup::FormDatabaseCleanup(QWidget* parent) : QDialog(parent), m_ui(new Ui::FormDatabaseCleanup), m_cleaner(nullptr) {
m_ui->setupUi(this); m_ui->setupUi(this);
// Set flags and attributes. // Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("edit-clear"))); setWindowIcon(qApp->icons()->fromTheme(QSL("edit-clear")));
@ -79,6 +80,7 @@ void FormDatabaseCleanup::updateDaysSuffix(int number) {
void FormDatabaseCleanup::startPurging() { void FormDatabaseCleanup::startPurging() {
CleanerOrders orders; CleanerOrders orders;
orders.m_removeRecycleBin = m_ui->m_checkRemoveRecycleBin->isChecked(); orders.m_removeRecycleBin = m_ui->m_checkRemoveRecycleBin->isChecked();
orders.m_removeOldMessages = m_ui->m_checkRemoveOldMessages->isChecked(); orders.m_removeOldMessages = m_ui->m_checkRemoveOldMessages->isChecked();
orders.m_barrierForRemovingOldMessagesInDays = m_ui->m_spinDays->value(); orders.m_barrierForRemovingOldMessagesInDays = m_ui->m_spinDays->value();
@ -120,6 +122,7 @@ void FormDatabaseCleanup::loadDatabaseInfo() {
qint64 data_size = qApp->database()->getDatabaseDataSize(); qint64 data_size = qApp->database()->getDatabaseDataSize();
QString file_size_str = file_size > 0 ? QString::number(file_size / 1000000.0) + QL1S(" MB") : tr("unknown"); QString file_size_str = file_size > 0 ? QString::number(file_size / 1000000.0) + QL1S(" MB") : tr("unknown");
QString data_size_str = data_size > 0 ? QString::number(data_size / 1000000.0) + QL1S(" MB") : tr("unknown"); QString data_size_str = data_size > 0 ? QString::number(data_size / 1000000.0) + QL1S(" MB") : tr("unknown");
m_ui->m_txtFileSize->setText(tr("file: %1, data: %2").arg(file_size_str, data_size_str)); m_ui->m_txtFileSize->setText(tr("file: %1, data: %2").arg(file_size_str, data_size_str));
m_ui->m_txtDatabaseType->setText(qApp->database()->humanDriverName(qApp->database()->activeDatabaseDriver())); m_ui->m_txtDatabaseType->setText(qApp->database()->humanDriverName(qApp->database()->activeDatabaseDriver()));
m_ui->m_checkShrink->setEnabled(qApp->database()->activeDatabaseDriver() == DatabaseFactory::SQLITE || m_ui->m_checkShrink->setEnabled(qApp->database()->activeDatabaseDriver() == DatabaseFactory::SQLITE ||

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -24,11 +25,11 @@
#include "miscellaneous/databasecleaner.h" #include "miscellaneous/databasecleaner.h"
class FormDatabaseCleanup : public QDialog { class FormDatabaseCleanup : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors. // Constructors.
explicit FormDatabaseCleanup(QWidget* parent = 0); explicit FormDatabaseCleanup(QWidget* parent = 0);
virtual ~FormDatabaseCleanup(); virtual ~FormDatabaseCleanup();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,49 +19,48 @@
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/application.h"
#include "miscellaneous/systemfactory.h"
#include "miscellaneous/mutex.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/feedreader.h"
#include "network-web/webfactory.h"
#include "gui/feedsview.h"
#include "gui/messagebox.h"
#include "gui/systemtrayicon.h"
#include "gui/tabbar.h"
#include "gui/statusbar.h"
#include "gui/messagesview.h"
#include "gui/feedmessageviewer.h"
#include "gui/plaintoolbutton.h"
#include "gui/feedstoolbar.h"
#include "gui/messagestoolbar.h"
#include "gui/dialogs/formabout.h" #include "gui/dialogs/formabout.h"
#include "gui/dialogs/formaddaccount.h"
#include "gui/dialogs/formbackupdatabasesettings.h"
#include "gui/dialogs/formdatabasecleanup.h"
#include "gui/dialogs/formrestoredatabasesettings.h"
#include "gui/dialogs/formsettings.h" #include "gui/dialogs/formsettings.h"
#include "gui/dialogs/formupdate.h" #include "gui/dialogs/formupdate.h"
#include "gui/dialogs/formdatabasecleanup.h" #include "gui/feedmessageviewer.h"
#include "gui/dialogs/formbackupdatabasesettings.h" #include "gui/feedstoolbar.h"
#include "gui/dialogs/formrestoredatabasesettings.h" #include "gui/feedsview.h"
#include "gui/dialogs/formaddaccount.h" #include "gui/messagebox.h"
#include "services/abstract/serviceroot.h" #include "gui/messagestoolbar.h"
#include "gui/messagesview.h"
#include "gui/plaintoolbutton.h"
#include "gui/statusbar.h"
#include "gui/systemtrayicon.h"
#include "gui/tabbar.h"
#include "miscellaneous/application.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/feedreader.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/mutex.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/systemfactory.h"
#include "network-web/webfactory.h"
#include "services/abstract/recyclebin.h" #include "services/abstract/recyclebin.h"
#include "services/standard/gui/formstandardimportexport.h" #include "services/abstract/serviceroot.h"
#include "services/owncloud/network/owncloudnetworkfactory.h" #include "services/owncloud/network/owncloudnetworkfactory.h"
#include "services/standard/gui/formstandardimportexport.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QRect> #include <QRect>
#include <QScopedPointer> #include <QScopedPointer>
#include <QDesktopWidget>
#include <QTimer> #include <QTimer>
#include <QFileDialog>
#if defined (USE_WEBENGINE) #if defined (USE_WEBENGINE)
#include "network-web/adblock/adblockmanager.h"
#include "network-web/adblock/adblockicon.h" #include "network-web/adblock/adblockicon.h"
#include "network-web/adblock/adblockmanager.h"
#endif #endif
FormMain::FormMain(QWidget* parent, Qt::WindowFlags f) FormMain::FormMain(QWidget* parent, Qt::WindowFlags f)
: QMainWindow(parent, f), m_ui(new Ui::FormMain) { : QMainWindow(parent, f), m_ui(new Ui::FormMain) {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -114,6 +114,7 @@ StatusBar* FormMain::statusBar() const {
void FormMain::showDbCleanupAssistant() { void FormMain::showDbCleanupAssistant() {
if (qApp->feedUpdateLock()->tryLock()) { if (qApp->feedUpdateLock()->tryLock()) {
FormDatabaseCleanup form(this); FormDatabaseCleanup form(this);
form.setCleaner(qApp->feedReader()->databaseCleaner()); form.setCleaner(qApp->feedReader()->databaseCleaner());
form.exec(); form.exec();
@ -131,6 +132,7 @@ void FormMain::showDbCleanupAssistant() {
QList<QAction*> FormMain::allActions() const { QList<QAction*> FormMain::allActions() const {
QList<QAction*> actions; QList<QAction*> actions;
// Add basic actions. // Add basic actions.
actions << m_ui->m_actionSettings; actions << m_ui->m_actionSettings;
actions << m_ui->m_actionDownloadManager; actions << m_ui->m_actionDownloadManager;
@ -205,6 +207,7 @@ void FormMain::prepareMenus() {
#else #else
m_trayMenu = new QMenu(QSL(APP_NAME), this); m_trayMenu = new QMenu(QSL(APP_NAME), this);
#endif #endif
// Add needed items to the menu. // Add needed items to the menu.
m_trayMenu->addAction(m_ui->m_actionSwitchMainWindow); m_trayMenu->addAction(m_ui->m_actionSwitchMainWindow);
m_trayMenu->addSeparator(); m_trayMenu->addSeparator();
@ -247,6 +250,7 @@ void FormMain::updateAddItemMenu() {
foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) { foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAddItem); QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAddItem);
root_menu->setIcon(activated_root->icon()); root_menu->setIcon(activated_root->icon());
root_menu->setToolTip(activated_root->description()); root_menu->setToolTip(activated_root->description());
QList<QAction*> specific_root_actions = activated_root->addItemMenu(); QList<QAction*> specific_root_actions = activated_root->addItemMenu();
@ -255,6 +259,7 @@ void FormMain::updateAddItemMenu() {
QAction* action_new_category = new QAction(qApp->icons()->fromTheme(QSL("folder")), QAction* action_new_category = new QAction(qApp->icons()->fromTheme(QSL("folder")),
tr("Add new category"), tr("Add new category"),
m_ui->m_menuAddItem); m_ui->m_menuAddItem);
root_menu->addAction(action_new_category); root_menu->addAction(action_new_category);
connect(action_new_category, &QAction::triggered, activated_root, &ServiceRoot::addNewCategory); connect(action_new_category, &QAction::triggered, activated_root, &ServiceRoot::addNewCategory);
} }
@ -263,7 +268,9 @@ void FormMain::updateAddItemMenu() {
QAction* action_new_feed = new QAction(qApp->icons()->fromTheme(QSL("application-rss+xml")), QAction* action_new_feed = new QAction(qApp->icons()->fromTheme(QSL("application-rss+xml")),
tr("Add new feed"), tr("Add new feed"),
m_ui->m_menuAddItem); m_ui->m_menuAddItem);
root_menu->addAction(action_new_feed); root_menu->addAction(action_new_feed);
// NOTE: Because of default arguments. // NOTE: Because of default arguments.
connect(action_new_feed, SIGNAL(triggered(bool)), activated_root, SLOT(addNewFeed())); connect(action_new_feed, SIGNAL(triggered(bool)), activated_root, SLOT(addNewFeed()));
} }
@ -294,15 +301,18 @@ void FormMain::updateRecycleBinMenu() {
foreach (const ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) { foreach (const ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuRecycleBin); QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuRecycleBin);
root_menu->setIcon(activated_root->icon()); root_menu->setIcon(activated_root->icon());
root_menu->setToolTip(activated_root->description()); root_menu->setToolTip(activated_root->description());
RecycleBin* bin = activated_root->recycleBin(); RecycleBin* bin = activated_root->recycleBin();
QList<QAction*> context_menu; QList<QAction*> context_menu;
if (bin == nullptr) { if (bin == nullptr) {
QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")), QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
tr("No recycle bin"), tr("No recycle bin"),
m_ui->m_menuRecycleBin); m_ui->m_menuRecycleBin);
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
@ -310,6 +320,7 @@ void FormMain::updateRecycleBinMenu() {
QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")), QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
tr("No actions possible"), tr("No actions possible"),
m_ui->m_menuRecycleBin); m_ui->m_menuRecycleBin);
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
@ -333,6 +344,7 @@ void FormMain::updateAccountsMenu() {
foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) { foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAccounts); QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAccounts);
root_menu->setIcon(activated_root->icon()); root_menu->setIcon(activated_root->icon());
root_menu->setToolTip(activated_root->description()); root_menu->setToolTip(activated_root->description());
QList<QAction*> root_actions = activated_root->serviceMenu(); QList<QAction*> root_actions = activated_root->serviceMenu();
@ -341,6 +353,7 @@ void FormMain::updateAccountsMenu() {
QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")), QAction* no_action = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
tr("No possible actions"), tr("No possible actions"),
m_ui->m_menuAccounts); m_ui->m_menuAccounts);
no_action->setEnabled(false); no_action->setEnabled(false);
root_menu->addAction(no_action); root_menu->addAction(no_action);
} }
@ -373,6 +386,7 @@ void FormMain::onFeedUpdatesStarted() {
void FormMain::onFeedUpdatesProgress(const Feed* feed, int current, int total) { void FormMain::onFeedUpdatesProgress(const Feed* feed, int current, int total) {
statusBar()->showProgressFeeds((current * 100.0) / total, statusBar()->showProgressFeeds((current * 100.0) / total,
//: Text display in status bar when particular feed is updated. //: Text display in status bar when particular feed is updated.
tr("Updated feed '%1'").arg(feed->title())); tr("Updated feed '%1'").arg(feed->title()));
} }
@ -382,6 +396,7 @@ void FormMain::updateMessageButtonsAvailability() {
const bool atleast_one_message_selected = !tabWidget()->feedMessageViewer()->messagesView()->selectionModel()->selectedRows().isEmpty(); const bool atleast_one_message_selected = !tabWidget()->feedMessageViewer()->messagesView()->selectionModel()->selectedRows().isEmpty();
const bool bin_loaded = tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem() != nullptr const bool bin_loaded = tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem() != nullptr
&& tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem()->kind() == RootItemKind::Bin; && tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem()->kind() == RootItemKind::Bin;
m_ui->m_actionDeleteSelectedMessages->setEnabled(atleast_one_message_selected); m_ui->m_actionDeleteSelectedMessages->setEnabled(atleast_one_message_selected);
m_ui->m_actionRestoreSelectedMessages->setEnabled(atleast_one_message_selected && bin_loaded); m_ui->m_actionRestoreSelectedMessages->setEnabled(atleast_one_message_selected && bin_loaded);
m_ui->m_actionMarkSelectedMessagesAsRead->setEnabled(atleast_one_message_selected); m_ui->m_actionMarkSelectedMessagesAsRead->setEnabled(atleast_one_message_selected);
@ -400,6 +415,7 @@ void FormMain::updateFeedButtonsAvailability() {
const bool feed_selected = anything_selected && selected_item->kind() == RootItemKind::Feed; const bool feed_selected = anything_selected && selected_item->kind() == RootItemKind::Feed;
const bool category_selected = anything_selected && selected_item->kind() == RootItemKind::Category; const bool category_selected = anything_selected && selected_item->kind() == RootItemKind::Category;
const bool service_selected = anything_selected && selected_item->kind() == RootItemKind::ServiceRoot; const bool service_selected = anything_selected && selected_item->kind() == RootItemKind::ServiceRoot;
m_ui->m_actionStopRunningItemsUpdate->setEnabled(is_update_running); m_ui->m_actionStopRunningItemsUpdate->setEnabled(is_update_running);
m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running); m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running); m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
@ -439,10 +455,12 @@ void FormMain::switchVisibility(bool force_hide) {
void FormMain::display() { void FormMain::display() {
// Make sure window is not minimized. // Make sure window is not minimized.
setWindowState(windowState() & ~Qt::WindowMinimized); setWindowState(windowState() & ~Qt::WindowMinimized);
// Display the window and make sure it is raised on top. // Display the window and make sure it is raised on top.
show(); show();
activateWindow(); activateWindow();
raise(); raise();
// Raise alert event. Check the documentation for more info on this. // Raise alert event. Check the documentation for more info on this.
Application::alert(this); Application::alert(this);
} }
@ -525,12 +543,14 @@ void FormMain::setupIcons() {
void FormMain::loadSize() { void FormMain::loadSize() {
const QRect screen = qApp->desktop()->screenGeometry(); const QRect screen = qApp->desktop()->screenGeometry();
const Settings* settings = qApp->settings(); const Settings* settings = qApp->settings();
// Reload main window size & position. // Reload main window size & position.
resize(settings->value(GROUP(GUI), GUI::MainWindowInitialSize, size()).toSize()); resize(settings->value(GROUP(GUI), GUI::MainWindowInitialSize, size()).toSize());
move(settings->value(GROUP(GUI), GUI::MainWindowInitialPosition, screen.center() - rect().center()).toPoint()); move(settings->value(GROUP(GUI), GUI::MainWindowInitialPosition, screen.center() - rect().center()).toPoint());
if (settings->value(GROUP(GUI), SETTING(GUI::MainWindowStartsMaximized)).toBool()) { if (settings->value(GROUP(GUI), SETTING(GUI::MainWindowStartsMaximized)).toBool()) {
setWindowState(windowState() | Qt::WindowMaximized); setWindowState(windowState() | Qt::WindowMaximized);
// We process events so that window is really maximized fast. // We process events so that window is really maximized fast.
qApp->processEvents(); qApp->processEvents();
} }
@ -543,11 +563,13 @@ void FormMain::loadSize() {
// Hide the main menu if user wants it. // Hide the main menu if user wants it.
m_ui->m_actionSwitchMainMenu->setChecked(settings->value(GROUP(GUI), SETTING(GUI::MainMenuVisible)).toBool()); m_ui->m_actionSwitchMainMenu->setChecked(settings->value(GROUP(GUI), SETTING(GUI::MainMenuVisible)).toBool());
// Adjust dimensions of "feeds & messages" widget. // Adjust dimensions of "feeds & messages" widget.
m_ui->m_tabWidget->feedMessageViewer()->loadSize(); m_ui->m_tabWidget->feedMessageViewer()->loadSize();
m_ui->m_actionSwitchToolBars->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ToolbarsVisible)).toBool()); m_ui->m_actionSwitchToolBars->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ToolbarsVisible)).toBool());
m_ui->m_actionSwitchListHeaders->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ListHeadersVisible)).toBool()); m_ui->m_actionSwitchListHeaders->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ListHeadersVisible)).toBool());
m_ui->m_actionSwitchStatusBar->setChecked(settings->value(GROUP(GUI), SETTING(GUI::StatusBarVisible)).toBool()); m_ui->m_actionSwitchStatusBar->setChecked(settings->value(GROUP(GUI), SETTING(GUI::StatusBarVisible)).toBool());
// Make sure that only unread feeds are shown if user has that feature set on. // Make sure that only unread feeds are shown if user has that feature set on.
m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool()); m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool());
} }
@ -559,15 +581,18 @@ void FormMain::saveSize() {
if (is_fullscreen) { if (is_fullscreen) {
m_ui->m_actionFullscreen->setChecked(false); m_ui->m_actionFullscreen->setChecked(false);
// We (process events to really) un-fullscreen, so that we can determine if window is really maximized. // We (process events to really) un-fullscreen, so that we can determine if window is really maximized.
qApp->processEvents(); qApp->processEvents();
} }
if (isMaximized()) { if (isMaximized()) {
is_maximized = true; is_maximized = true;
// Window is maximized, we store that fact to settings and unmaximize. // Window is maximized, we store that fact to settings and unmaximize.
qApp->settings()->setValue(GROUP(GUI), GUI::IsMainWindowMaximizedBeforeFullscreen, isMaximized()); qApp->settings()->setValue(GROUP(GUI), GUI::IsMainWindowMaximizedBeforeFullscreen, isMaximized());
setWindowState((windowState() & ~Qt::WindowMaximized) | Qt::WindowActive); setWindowState((windowState() & ~Qt::WindowMaximized) | Qt::WindowActive);
// We process events to really have window un-maximized. // We process events to really have window un-maximized.
qApp->processEvents(); qApp->processEvents();
} }
@ -715,6 +740,7 @@ void FormMain::backupDatabaseSettings() {
void FormMain::restoreDatabaseSettings() { void FormMain::restoreDatabaseSettings() {
FormRestoreDatabaseSettings form(*this); FormRestoreDatabaseSettings form(*this);
form.exec(); form.exec();
if (form.shouldRestart()) { if (form.shouldRestart()) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_formmain.h" #include "ui_formmain.h"
class StatusBar; class StatusBar;
class FormMain : public QMainWindow { class FormMain : public QMainWindow {
@ -33,6 +33,7 @@ class FormMain : public QMainWindow {
friend class FeedsView; friend class FeedsView;
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FormMain(QWidget* parent = 0, Qt::WindowFlags f = 0); explicit FormMain(QWidget* parent = 0, Qt::WindowFlags f = 0);
virtual ~FormMain(); virtual ~FormMain();
@ -56,6 +57,7 @@ class FormMain : public QMainWindow {
void saveSize(); void saveSize();
public slots: public slots:
// Displays window on top or switches its visibility. // Displays window on top or switches its visibility.
void display(); void display();
@ -87,6 +89,7 @@ class FormMain : public QMainWindow {
void donate(); void donate();
private: private:
// Event handler reimplementations. // Event handler reimplementations.
void changeEvent(QEvent* event); void changeEvent(QEvent* event);

View file

@ -93,10 +93,12 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
} }
const QDir selected_folder(folder); const QDir selected_folder(folder);
const QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_DATABASE, const QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString(
"*") + BACKUP_SUFFIX_DATABASE,
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks, QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks,
QDir::Name); QDir::Name);
const QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_SETTINGS, const QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString(
"*") + BACKUP_SUFFIX_SETTINGS,
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks, QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive | QDir::NoSymLinks,
QDir::Name); QDir::Name);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,11 +23,11 @@
#include "ui_formrestoredatabasesettings.h" #include "ui_formrestoredatabasesettings.h"
class FormRestoreDatabaseSettings : public QDialog { class FormRestoreDatabaseSettings : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FormRestoreDatabaseSettings(QWidget& parent); explicit FormRestoreDatabaseSettings(QWidget& parent);
virtual ~FormRestoreDatabaseSettings(); virtual ~FormRestoreDatabaseSettings();
@ -44,7 +45,6 @@ class FormRestoreDatabaseSettings : public QDialog {
private: private:
Ui::FormRestoreDatabaseSettings m_ui; Ui::FormRestoreDatabaseSettings m_ui;
QPushButton* m_btnRestart; QPushButton* m_btnRestart;
bool m_shouldRestart; bool m_shouldRestart;
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,10 +19,10 @@
#include "gui/dialogs/formsettings.h" #include "gui/dialogs/formsettings.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/iconfactory.h"
#include "gui/messagebox.h" #include "gui/messagebox.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/settings.h"
#include "gui/settings/settingsbrowsermail.h" #include "gui/settings/settingsbrowsermail.h"
#include "gui/settings/settingsdatabase.h" #include "gui/settings/settingsdatabase.h"
@ -32,15 +33,16 @@
#include "gui/settings/settingslocalization.h" #include "gui/settings/settingslocalization.h"
#include "gui/settings/settingsshortcuts.h" #include "gui/settings/settingsshortcuts.h"
FormSettings::FormSettings(QWidget& parent) FormSettings::FormSettings(QWidget& parent)
: QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) { : QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) {
m_ui.setupUi(this); m_ui.setupUi(this);
// Set flags and attributes. // Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system"))); setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system")));
m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply); m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply);
m_btnApply->setEnabled(false); m_btnApply->setEnabled(false);
// Establish needed connections. // Establish needed connections.
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings); connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings);
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormSettings::cancelSettings); connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormSettings::cancelSettings);
@ -86,10 +88,12 @@ void FormSettings::applySettings() {
const QMessageBox::StandardButton clicked_button = MessageBox::show(this, const QMessageBox::StandardButton clicked_button = MessageBox::show(this,
QMessageBox::Question, QMessageBox::Question,
tr("Critical settings were changed"), tr("Critical settings were changed"),
tr("Some critical settings were changed and will be applied after the application gets restarted. " tr(
"Some critical settings were changed and will be applied after the application gets restarted. "
"\n\nYou have to restart manually."), "\n\nYou have to restart manually."),
tr("Do you want to restart now?"), tr("Do you want to restart now?"),
tr("Changed categories of settings:\n%1.").arg(changed_settings_description .join(QSL(",\n"))), tr("Changed categories of settings:\n%1.").arg(
changed_settings_description.join(QSL(",\n"))),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (clicked_button == QMessageBox::Yes) { if (clicked_button == QMessageBox::Yes) {
@ -120,7 +124,7 @@ void FormSettings::cancelSettings() {
tr("Some settings are changed and will be lost"), tr("Some settings are changed and will be lost"),
tr("Some settings were changed and by cancelling this dialog, you would lose these changes."), tr("Some settings were changed and by cancelling this dialog, you would lose these changes."),
tr("Do you really want to close this dialog without saving any settings?"), tr("Do you really want to close this dialog without saving any settings?"),
tr("Changed categories of settings:\n%1.").arg(changed_settings_description .join(QSL(",\n"))), tr("Changed categories of settings:\n%1.").arg(changed_settings_description.join(QSL(",\n"))),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ==
QMessageBox::Yes) { QMessageBox::Yes) {
reject(); reject();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_formsettings.h" #include "ui_formsettings.h"
class Settings; class Settings;
class SettingsPanel; class SettingsPanel;
@ -30,11 +30,13 @@ class FormSettings : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FormSettings(QWidget& parent); explicit FormSettings(QWidget& parent);
virtual ~FormSettings(); virtual ~FormSettings();
private slots: private slots:
// Saves settings into global configuration. // Saves settings into global configuration.
void saveSettings(); void saveSettings();
void applySettings(); void applySettings();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,13 +19,13 @@
#include "gui/dialogs/formupdate.h" #include "gui/dialogs/formupdate.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "gui/guiutilities.h"
#include "gui/messagebox.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "miscellaneous/iofactory.h" #include "miscellaneous/iofactory.h"
#include "network-web/downloader.h"
#include "network-web/networkfactory.h" #include "network-web/networkfactory.h"
#include "network-web/webfactory.h" #include "network-web/webfactory.h"
#include "network-web/downloader.h"
#include "gui/messagebox.h"
#include "gui/guiutilities.h"
#include <QNetworkReply> #include <QNetworkReply>
@ -32,13 +33,13 @@
#include <windows.h> #include <windows.h>
#endif #endif
FormUpdate::FormUpdate(QWidget* parent) FormUpdate::FormUpdate(QWidget* parent)
: QDialog(parent) { : QDialog(parent) {
m_ui.setupUi(this); m_ui.setupUi(this);
m_ui.m_lblCurrentRelease->setText(APP_VERSION); m_ui.m_lblCurrentRelease->setText(APP_VERSION);
m_ui.m_tabInfo->removeTab(1); m_ui.m_tabInfo->removeTab(1);
m_ui.m_buttonBox->setEnabled(false); m_ui.m_buttonBox->setEnabled(false);
// Set flags and attributes. // Set flags and attributes.
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about"))); GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")));
connect(&m_downloader, &Downloader::progress, this, &FormUpdate::updateProgress); connect(&m_downloader, &Downloader::progress, this, &FormUpdate::updateProgress);
@ -58,8 +59,7 @@ FormUpdate::FormUpdate(QWidget* parent)
checkForUpdates(); checkForUpdates();
} }
FormUpdate::~FormUpdate() { FormUpdate::~FormUpdate() {}
}
bool FormUpdate::isSelfUpdateSupported() const { bool FormUpdate::isSelfUpdateSupported() const {
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
@ -77,6 +77,7 @@ void FormUpdate::checkForUpdates() {
if (update.second != QNetworkReply::NoError) { if (update.second != QNetworkReply::NoError) {
m_updateInfo = UpdateInfo(); m_updateInfo = UpdateInfo();
m_ui.m_tabInfo->setEnabled(false); m_ui.m_tabInfo->setEnabled(false);
//: Unknown release. //: Unknown release.
m_ui.m_lblAvailableRelease->setText(tr("unknown")); m_ui.m_lblAvailableRelease->setText(tr("unknown"));
m_ui.m_txtChanges->clear(); m_ui.m_txtChanges->clear();
@ -114,7 +115,9 @@ void FormUpdate::checkForUpdates() {
void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) { void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) {
if (bytes_received - m_lastDownloadedBytes > 500000 || m_lastDownloadedBytes == 0) { if (bytes_received - m_lastDownloadedBytes > 500000 || m_lastDownloadedBytes == 0) {
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Information, m_ui.m_lblStatus->setStatus(WidgetWithStatus::Information,
tr("Downloaded %1% (update size is %2 kB).").arg(QString::number(bytes_total == 0 ? 0 : (bytes_received * 100.0) / bytes_total, tr("Downloaded %1% (update size is %2 kB).").arg(QString::number(bytes_total ==
0 ? 0 : (bytes_received * 100.0) /
bytes_total,
'f', 'f',
2), 2),
QString::number(bytes_total / 1000, QString::number(bytes_total / 1000,
@ -159,6 +162,7 @@ void FormUpdate::loadAvailableFiles() {
foreach (const UpdateUrl& url, m_updateInfo.m_urls) { foreach (const UpdateUrl& url, m_updateInfo.m_urls) {
QListWidgetItem* item = new QListWidgetItem(url.m_name + tr(" (size ") + url.m_size + QSL(")")); QListWidgetItem* item = new QListWidgetItem(url.m_name + tr(" (size ") + url.m_size + QSL(")"));
item->setData(Qt::UserRole, url.m_fileUrl); item->setData(Qt::UserRole, url.m_fileUrl);
item->setToolTip(url.m_fileUrl); item->setToolTip(url.m_fileUrl);
m_ui.m_listFiles->addItem(item); m_ui.m_listFiles->addItem(item);
@ -226,7 +230,6 @@ void FormUpdate::startUpdate() {
else { else {
qApp->quit(); qApp->quit();
} }
#endif #endif
} }
else if (update_for_this_system) { else if (update_for_this_system) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -25,14 +26,14 @@
#include "miscellaneous/systemfactory.h" #include "miscellaneous/systemfactory.h"
#include "network-web/downloader.h" #include "network-web/downloader.h"
#include <QPushButton>
#include <QNetworkReply> #include <QNetworkReply>
#include <QPushButton>
class FormUpdate : public QDialog { class FormUpdate : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FormUpdate(QWidget* parent); explicit FormUpdate(QWidget* parent);
virtual ~FormUpdate(); virtual ~FormUpdate();
@ -42,6 +43,7 @@ class FormUpdate : public QDialog {
bool isSelfUpdateSupported() const; bool isSelfUpdateSupported() const;
private slots: private slots:
// Check for updates and interprets the results. // Check for updates and interprets the results.
void checkForUpdates(); void checkForUpdates();
void startUpdate(); void startUpdate();
@ -55,7 +57,6 @@ class FormUpdate : public QDialog {
Ui::FormUpdate m_ui; Ui::FormUpdate m_ui;
QPushButton* m_btnUpdate; QPushButton* m_btnUpdate;
Downloader m_downloader; Downloader m_downloader;
QString m_updateFilePath; QString m_updateFilePath;
UpdateInfo m_updateInfo; UpdateInfo m_updateInfo;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,27 +18,25 @@
#include "gui/discoverfeedsbutton.h" #include "gui/discoverfeedsbutton.h"
#include "miscellaneous/application.h" #include "core/feedsmodel.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/feedreader.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "gui/tabwidget.h"
#include "gui/feedmessageviewer.h" #include "gui/feedmessageviewer.h"
#include "gui/feedsview.h" #include "gui/feedsview.h"
#include "core/feedsmodel.h" #include "gui/tabwidget.h"
#include "miscellaneous/application.h"
#include "miscellaneous/feedreader.h"
#include "miscellaneous/iconfactory.h"
#include "services/abstract/serviceroot.h" #include "services/abstract/serviceroot.h"
#include <QVariant> #include <QVariant>
DiscoverFeedsButton::DiscoverFeedsButton(QWidget* parent) : QToolButton(parent), m_addresses(QStringList()) { DiscoverFeedsButton::DiscoverFeedsButton(QWidget* parent) : QToolButton(parent), m_addresses(QStringList()) {
setEnabled(false); setEnabled(false);
setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml"))); setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
setPopupMode(QToolButton::InstantPopup); setPopupMode(QToolButton::InstantPopup);
} }
DiscoverFeedsButton::~DiscoverFeedsButton() { DiscoverFeedsButton::~DiscoverFeedsButton() {}
}
void DiscoverFeedsButton::clearFeedAddresses() { void DiscoverFeedsButton::clearFeedAddresses() {
setFeedAddresses(QStringList()); setFeedAddresses(QStringList());
@ -84,6 +83,7 @@ void DiscoverFeedsButton::fillMenu() {
foreach (const QString& url, m_addresses) { foreach (const QString& url, m_addresses) {
if (root->supportsFeedAdding()) { if (root->supportsFeedAdding()) {
QAction* url_action = root_menu->addAction(root->icon(), url); QAction* url_action = root_menu->addAction(root->icon(), url);
url_action->setProperty("url", url); url_action->setProperty("url", url);
url_action->setProperty("root", QVariant::fromValue((void*) root)); url_action->setProperty("root", QVariant::fromValue((void*) root));
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,11 @@
#include <QToolButton> #include <QToolButton>
class DiscoverFeedsButton : public QToolButton { class DiscoverFeedsButton : public QToolButton {
Q_OBJECT Q_OBJECT
public: public:
// Constructors. // Constructors.
explicit DiscoverFeedsButton(QWidget* parent = 0); explicit DiscoverFeedsButton(QWidget* parent = 0);
virtual ~DiscoverFeedsButton(); virtual ~DiscoverFeedsButton();
@ -34,6 +35,7 @@ class DiscoverFeedsButton : public QToolButton {
void setFeedAddresses(const QStringList& addresses); void setFeedAddresses(const QStringList& addresses);
private slots: private slots:
// User chose any of addresses. // User chose any of addresses.
void linkTriggered(QAction* action); void linkTriggered(QAction* action);
void fillMenu(); void fillMenu();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,9 +20,7 @@
#include <QKeyEvent> #include <QKeyEvent>
EditTableView::EditTableView(QWidget* parent) : QTableView(parent) {}
EditTableView::EditTableView(QWidget* parent) : QTableView(parent) {
}
void EditTableView::keyPressEvent(QKeyEvent* event) { void EditTableView::keyPressEvent(QKeyEvent* event) {
if (model() && event->key() == Qt::Key_Delete) { if (model() && event->key() == Qt::Key_Delete) {
@ -48,6 +47,7 @@ void EditTableView::removeSelected() {
for (int i = selected_rows.count() - 1; i >= 0; i--) { for (int i = selected_rows.count() - 1; i >= 0; i--) {
QModelIndex idx = selected_rows.at(i); QModelIndex idx = selected_rows.at(i);
model()->removeRow(idx.row(), rootIndex()); model()->removeRow(idx.row(), rootIndex());
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QTableView> #include <QTableView>
class EditTableView : public QTableView { class EditTableView : public QTableView {
Q_OBJECT Q_OBJECT

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,21 +19,20 @@
#include "gui/feedstoolbar.h" #include "gui/feedstoolbar.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "miscellaneous/settings.h"
#include <QWidgetAction> #include <QWidgetAction>
FeedsToolBar::FeedsToolBar(const QString& title, QWidget* parent) : BaseToolBar(title, parent) { FeedsToolBar::FeedsToolBar(const QString& title, QWidget* parent) : BaseToolBar(title, parent) {
// Update right margin of filter textbox. // Update right margin of filter textbox.
QMargins margins = contentsMargins(); QMargins margins = contentsMargins();
margins.setRight(margins.right() + FILTER_RIGHT_MARGIN); margins.setRight(margins.right() + FILTER_RIGHT_MARGIN);
setContentsMargins(margins); setContentsMargins(margins);
} }
FeedsToolBar::~FeedsToolBar() { FeedsToolBar::~FeedsToolBar() {}
}
QList<QAction*> FeedsToolBar::availableActions() const { QList<QAction*> FeedsToolBar::availableActions() const {
return qApp->userActions(); return qApp->userActions();
@ -62,14 +62,17 @@ QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList& actions) {
else if (action_name == SEPARATOR_ACTION_NAME) { else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator. // Add new separator.
QAction* act = new QAction(this); QAction* act = new QAction(this);
act->setSeparator(true); act->setSeparator(true);
spec_actions.append(act); spec_actions.append(act);
} }
else if (action_name == SPACER_ACTION_NAME) { else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer. // Add new spacer.
QWidget* spacer = new QWidget(this); QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidgetAction* action = new QWidgetAction(this); QWidgetAction* action = new QWidgetAction(this);
action->setDefaultWidget(spacer); action->setDefaultWidget(spacer);
action->setIcon(qApp->icons()->fromTheme(QSL("system-search"))); action->setIcon(qApp->icons()->fromTheme(QSL("system-search")));
action->setProperty("type", SPACER_ACTION_NAME); action->setProperty("type", SPACER_ACTION_NAME);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,11 @@
#include "gui/basetoolbar.h" #include "gui/basetoolbar.h"
class FeedsToolBar : public BaseToolBar { class FeedsToolBar : public BaseToolBar {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FeedsToolBar(const QString& title, QWidget* parent = 0); explicit FeedsToolBar(const QString& title, QWidget* parent = 0);
virtual ~FeedsToolBar(); virtual ~FeedsToolBar();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,31 +18,30 @@
#include "gui/feedsview.h" #include "gui/feedsview.h"
#include "definitions/definitions.h"
#include "core/feedsmodel.h" #include "core/feedsmodel.h"
#include "core/feedsproxymodel.h" #include "core/feedsproxymodel.h"
#include "services/abstract/rootitem.h" #include "definitions/definitions.h"
#include "miscellaneous/systemfactory.h" #include "gui/dialogs/formmain.h"
#include "miscellaneous/feedreader.h"
#include "miscellaneous/mutex.h"
#include "gui/systemtrayicon.h"
#include "gui/messagebox.h" #include "gui/messagebox.h"
#include "gui/styleditemdelegatewithoutfocus.h" #include "gui/styleditemdelegatewithoutfocus.h"
#include "gui/dialogs/formmain.h" #include "gui/systemtrayicon.h"
#include "miscellaneous/feedreader.h"
#include "miscellaneous/mutex.h"
#include "miscellaneous/systemfactory.h"
#include "services/abstract/feed.h" #include "services/abstract/feed.h"
#include "services/abstract/rootitem.h"
#include "services/abstract/serviceroot.h" #include "services/abstract/serviceroot.h"
#include "services/standard/gui/formstandardcategorydetails.h"
#include "services/standard/standardcategory.h" #include "services/standard/standardcategory.h"
#include "services/standard/standardfeed.h" #include "services/standard/standardfeed.h"
#include "services/standard/gui/formstandardcategorydetails.h"
#include <QMenu>
#include <QHeaderView>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QPointer> #include <QHeaderView>
#include <QMenu>
#include <QPainter> #include <QPainter>
#include <QPointer>
#include <QTimer> #include <QTimer>
FeedsView::FeedsView(QWidget* parent) FeedsView::FeedsView(QWidget* parent)
: QTreeView(parent), : QTreeView(parent),
m_contextMenuCategories(nullptr), m_contextMenuCategories(nullptr),
@ -94,6 +94,7 @@ RootItem* FeedsView::selectedItem() const {
} }
else { else {
RootItem* selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); RootItem* selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0)));
return selected_item == m_sourceModel->rootItem() ? nullptr : selected_item; return selected_item == m_sourceModel->rootItem() ? nullptr : selected_item;
} }
} }
@ -108,6 +109,7 @@ void FeedsView::saveAllExpandStates() {
void FeedsView::saveExpandStates(RootItem* item) { void FeedsView::saveExpandStates(RootItem* item) {
Settings* settings = qApp->settings(); Settings* settings = qApp->settings();
QList<RootItem*> items = item->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot); QList<RootItem*> items = item->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot);
// Iterate all categories and save their expand statuses. // Iterate all categories and save their expand statuses.
@ -115,6 +117,7 @@ void FeedsView::saveExpandStates(RootItem* item) {
const QString setting_name = item->hashCode(); const QString setting_name = item->hashCode();
QModelIndex source_index = sourceModel()->indexForItem(item); QModelIndex source_index = sourceModel()->indexForItem(item);
QModelIndex visible_index = model()->mapFromSource(source_index); QModelIndex visible_index = model()->mapFromSource(source_index);
settings->setValue(GROUP(CategoriesExpandStates), settings->setValue(GROUP(CategoriesExpandStates),
setting_name, setting_name,
isExpanded(visible_index)); isExpanded(visible_index));
@ -123,12 +126,14 @@ void FeedsView::saveExpandStates(RootItem* item) {
void FeedsView::loadAllExpandStates() { void FeedsView::loadAllExpandStates() {
const Settings* settings = qApp->settings(); const Settings* settings = qApp->settings();
QList<RootItem*> expandable_items; QList<RootItem*> expandable_items;
expandable_items.append(sourceModel()->rootItem()->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot)); expandable_items.append(sourceModel()->rootItem()->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot));
// Iterate all categories and save their expand statuses. // Iterate all categories and save their expand statuses.
foreach (const RootItem* item, expandable_items) { foreach (const RootItem* item, expandable_items) {
const QString setting_name = item->hashCode(); const QString setting_name = item->hashCode();
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)), setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)),
settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool()); settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool());
} }
@ -218,6 +223,7 @@ void FeedsView::editSelectedItem() {
qApp->showGuiMessage(tr("Cannot edit item"), qApp->showGuiMessage(tr("Cannot edit item"),
tr("Selected item cannot be edited because another critical operation is ongoing."), tr("Selected item cannot be edited because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
return; return;
} }
@ -245,6 +251,7 @@ void FeedsView::deleteSelectedItem() {
qApp->showGuiMessage(tr("Cannot delete item"), qApp->showGuiMessage(tr("Cannot delete item"),
tr("Selected item cannot be deleted because another critical operation is ongoing."), tr("Selected item cannot be deleted because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
return; return;
} }
@ -532,9 +539,11 @@ void FeedsView::setupAppearance() {
void FeedsView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { void FeedsView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
RootItem* selected_item = selectedItem(); RootItem* selected_item = selectedItem();
m_proxyModel->setSelectedItem(selected_item); m_proxyModel->setSelectedItem(selected_item);
QTreeView::selectionChanged(selected, deselected); QTreeView::selectionChanged(selected, deselected);
emit itemSelected(selected_item); emit itemSelected(selected_item);
m_proxyModel->invalidateReadFeedsFilter(); m_proxyModel->invalidateReadFeedsFilter();
} }
@ -607,6 +616,7 @@ void FeedsView::onItemExpandRequested(const QList<RootItem*>& items, bool exp) {
foreach (const RootItem* item, items) { foreach (const RootItem* item, items) {
QModelIndex source_index = m_sourceModel->indexForItem(item); QModelIndex source_index = m_sourceModel->indexForItem(item);
QModelIndex proxy_index = m_proxyModel->mapFromSource(source_index); QModelIndex proxy_index = m_proxyModel->mapFromSource(source_index);
setExpanded(proxy_index, exp); setExpanded(proxy_index, exp);
} }
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -24,7 +25,6 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
class FeedsProxyModel; class FeedsProxyModel;
class Feed; class Feed;
class Category; class Category;
@ -33,6 +33,7 @@ class FeedsView : public QTreeView {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit FeedsView(QWidget* parent = 0); explicit FeedsView(QWidget* parent = 0);
virtual ~FeedsView(); virtual ~FeedsView();
@ -135,7 +136,6 @@ class FeedsView : public QTreeView {
QMenu* m_contextMenuFeeds; QMenu* m_contextMenuFeeds;
QMenu* m_contextMenuEmptySpace; QMenu* m_contextMenuEmptySpace;
QMenu* m_contextMenuOtherItems; QMenu* m_contextMenuOtherItems;
FeedsModel* m_sourceModel; FeedsModel* m_sourceModel;
FeedsProxyModel* m_proxyModel; FeedsProxyModel* m_proxyModel;
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,7 +20,6 @@
#include "definitions/definitions.h" #include "definitions/definitions.h"
void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) { void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) {
label.setMargin(6); label.setMargin(6);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,9 +19,8 @@
#ifndef GUIUTILITIES_H #ifndef GUIUTILITIES_H
#define GUIUTILITIES_H #define GUIUTILITIES_H
#include <QWidget>
#include <QLabel> #include <QLabel>
#include <QWidget>
class GuiUtilities { class GuiUtilities {
public: public:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -21,20 +22,21 @@
#include <QHBoxLayout> #include <QHBoxLayout>
LabelWithStatus::LabelWithStatus(QWidget* parent) LabelWithStatus::LabelWithStatus(QWidget* parent)
: WidgetWithStatus(parent) { : WidgetWithStatus(parent) {
m_wdgInput = new QLabel(this); m_wdgInput = new QLabel(this);
// Set correct size for the tool button. // Set correct size for the tool button.
int label_height = m_wdgInput->sizeHint().height(); int label_height = m_wdgInput->sizeHint().height();
m_btnStatus->setFixedSize(label_height, label_height); m_btnStatus->setFixedSize(label_height, label_height);
// Compose the layout. // Compose the layout.
m_layout->addWidget(m_wdgInput); m_layout->addWidget(m_wdgInput);
m_layout->addWidget(m_btnStatus); m_layout->addWidget(m_btnStatus);
} }
LabelWithStatus::~LabelWithStatus() { LabelWithStatus::~LabelWithStatus() {}
}
void LabelWithStatus::setStatus(WidgetWithStatus::StatusType status, void LabelWithStatus::setStatus(WidgetWithStatus::StatusType status,
const QString& label_text, const QString& label_text,

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,11 +23,11 @@
#include <QLabel> #include <QLabel>
class LabelWithStatus : public WidgetWithStatus { class LabelWithStatus : public WidgetWithStatus {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit LabelWithStatus(QWidget* parent = 0); explicit LabelWithStatus(QWidget* parent = 0);
virtual ~LabelWithStatus(); virtual ~LabelWithStatus();
@ -37,6 +38,7 @@ class LabelWithStatus : public WidgetWithStatus {
inline QLabel* label() const { inline QLabel* label() const {
return static_cast<QLabel*>(m_wdgInput); return static_cast<QLabel*>(m_wdgInput);
} }
}; };
#endif // LABELWITHSTATUS_H #endif // LABELWITHSTATUS_H

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,23 +18,24 @@
#include "gui/lineeditwithstatus.h" #include "gui/lineeditwithstatus.h"
#include "gui/plaintoolbutton.h"
#include "gui/baselineedit.h" #include "gui/baselineedit.h"
#include "gui/plaintoolbutton.h"
#include <QHBoxLayout> #include <QHBoxLayout>
LineEditWithStatus::LineEditWithStatus(QWidget* parent) LineEditWithStatus::LineEditWithStatus(QWidget* parent)
: WidgetWithStatus(parent) { : WidgetWithStatus(parent) {
m_wdgInput = new BaseLineEdit(this); m_wdgInput = new BaseLineEdit(this);
setFocusProxy(m_wdgInput); setFocusProxy(m_wdgInput);
// Set correct size for the tool button. // Set correct size for the tool button.
const int txt_input_height = m_wdgInput->sizeHint().height(); const int txt_input_height = m_wdgInput->sizeHint().height();
m_btnStatus->setFixedSize(txt_input_height, txt_input_height); m_btnStatus->setFixedSize(txt_input_height, txt_input_height);
// Compose the layout. // Compose the layout.
m_layout->addWidget(m_wdgInput); m_layout->addWidget(m_wdgInput);
m_layout->addWidget(m_btnStatus); m_layout->addWidget(m_btnStatus);
} }
LineEditWithStatus::~LineEditWithStatus() { LineEditWithStatus::~LineEditWithStatus() {}
}

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,11 +23,11 @@
#include "gui/baselineedit.h" #include "gui/baselineedit.h"
class LineEditWithStatus : public WidgetWithStatus { class LineEditWithStatus : public WidgetWithStatus {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit LineEditWithStatus(QWidget* parent = 0); explicit LineEditWithStatus(QWidget* parent = 0);
virtual ~LineEditWithStatus(); virtual ~LineEditWithStatus();
@ -35,6 +36,7 @@ class LineEditWithStatus : public WidgetWithStatus {
inline BaseLineEdit* lineEdit() const { inline BaseLineEdit* lineEdit() const {
return static_cast<BaseLineEdit*>(m_wdgInput); return static_cast<BaseLineEdit*>(m_wdgInput);
} }
}; };
#endif // LINEEDITWITHSTATUS_H #endif // LINEEDITWITHSTATUS_H

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -21,18 +22,17 @@
#include <QMouseEvent> #include <QMouseEvent>
LocationLineEdit::LocationLineEdit(QWidget* parent) LocationLineEdit::LocationLineEdit(QWidget* parent)
: BaseLineEdit(parent), m_mouseSelectsAllText(true), m_googleSuggest(new GoogleSuggest(this)) { : BaseLineEdit(parent), m_mouseSelectsAllText(true), m_googleSuggest(new GoogleSuggest(this)) {
setPlaceholderText(tr("Website address goes here")); setPlaceholderText(tr("Website address goes here"));
connect(this, &LocationLineEdit::submitted, m_googleSuggest, &GoogleSuggest::preventSuggest); connect(this, &LocationLineEdit::submitted, m_googleSuggest, &GoogleSuggest::preventSuggest);
} }
LocationLineEdit::~LocationLineEdit() { LocationLineEdit::~LocationLineEdit() {}
}
void LocationLineEdit::focusOutEvent(QFocusEvent* event) { void LocationLineEdit::focusOutEvent(QFocusEvent* event) {
BaseLineEdit::focusOutEvent(event); BaseLineEdit::focusOutEvent(event);
// User now left text box, when he enters it again and clicks, // User now left text box, when he enters it again and clicks,
// then all text should be selected. // then all text should be selected.
m_mouseSelectsAllText = true; m_mouseSelectsAllText = true;
@ -42,6 +42,7 @@ void LocationLineEdit::mousePressEvent(QMouseEvent* event) {
if (m_mouseSelectsAllText) { if (m_mouseSelectsAllText) {
event->ignore(); event->ignore();
selectAll(); selectAll();
// User clicked and all text was selected. // User clicked and all text was selected.
m_mouseSelectsAllText = false; m_mouseSelectsAllText = false;
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include "gui/baselineedit.h" #include "gui/baselineedit.h"
class WebBrowser; class WebBrowser;
class GoogleSuggest; class GoogleSuggest;
@ -28,6 +28,7 @@ class LocationLineEdit : public BaseLineEdit {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit LocationLineEdit(QWidget* parent = 0); explicit LocationLineEdit(QWidget* parent = 0);
virtual ~LocationLineEdit(); virtual ~LocationLineEdit();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -27,7 +28,6 @@
#include <QStyle> #include <QStyle>
#include <QtGlobal> #include <QtGlobal>
MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {} MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {}
MessageBox::~MessageBox() {} MessageBox::~MessageBox() {}
@ -72,9 +72,15 @@ QIcon MessageBox::iconForStatus(QMessageBox::Icon status) {
} }
} }
QMessageBox::StandardButton MessageBox::show(QWidget* parent, QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButton MessageBox::show(QWidget* parent,
const QString& informative_text, const QString& detailed_text, QMessageBox::StandardButtons buttons, QMessageBox::Icon icon,
QMessageBox::StandardButton default_button, bool* dont_show_again) { const QString& title,
const QString& text,
const QString& informative_text,
const QString& detailed_text,
QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton default_button,
bool* dont_show_again) {
// Create and find needed components. // Create and find needed components.
MessageBox msg_box(parent); MessageBox msg_box(parent);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,14 +19,14 @@
#ifndef MESSAGEBOX_H #ifndef MESSAGEBOX_H
#define MESSAGEBOX_H #define MESSAGEBOX_H
#include <QMessageBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QMessageBox>
class MessageBox : public QMessageBox { class MessageBox : public QMessageBox {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit MessageBox(QWidget* parent = 0); explicit MessageBox(QWidget* parent = 0);
virtual ~MessageBox(); virtual ~MessageBox();
@ -45,7 +46,6 @@ class MessageBox : public QMessageBox {
QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
QMessageBox::StandardButton default_button = QMessageBox::Ok, QMessageBox::StandardButton default_button = QMessageBox::Ok,
bool* dont_show_again = nullptr); bool* dont_show_again = nullptr);
static QIcon iconForStatus(QMessageBox::Icon status); static QIcon iconForStatus(QMessageBox::Icon status);
}; };

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,20 +18,19 @@
#include "gui/messagepreviewer.h" #include "gui/messagepreviewer.h"
#include "miscellaneous/application.h"
#include "network-web/webfactory.h"
#include "miscellaneous/databasequeries.h"
#include "gui/messagebox.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "gui/messagebox.h"
#include "miscellaneous/application.h"
#include "miscellaneous/databasequeries.h"
#include "network-web/webfactory.h"
#include "services/abstract/serviceroot.h" #include "services/abstract/serviceroot.h"
#include <QScrollBar> #include <QScrollBar>
#include <QToolBar> #include <QToolBar>
#include <QToolTip> #include <QToolTip>
void MessagePreviewer::createConnections() { void MessagePreviewer::createConnections() {
connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [ = ](const QUrl & url) { connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl& url) {
if (!url.isEmpty()) { if (!url.isEmpty()) {
bool open_externally_now = qApp->settings()->value(GROUP(Browser), bool open_externally_now = qApp->settings()->value(GROUP(Browser),
SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool(); SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool();
@ -88,7 +88,7 @@ void MessagePreviewer::createConnections() {
&MessagePreviewer::switchMessageImportance); &MessagePreviewer::switchMessageImportance);
connect(m_ui->m_txtMessage, connect(m_ui->m_txtMessage,
static_cast<void (QTextBrowser::*)(const QString&)>(&QTextBrowser::highlighted), static_cast<void (QTextBrowser::*)(const QString&)>(&QTextBrowser::highlighted),
[ = ](const QString & text) { [=](const QString& text) {
Q_UNUSED(text) Q_UNUSED(text)
QToolTip::showText(QCursor::pos(), tr("Click this link to download it or open it with external browser."), this); QToolTip::showText(QCursor::pos(), tr("Click this link to download it or open it with external browser."), this);
}); });
@ -107,12 +107,12 @@ MessagePreviewer::MessagePreviewer(QWidget* parent) : QWidget(parent),
clear(); clear();
} }
MessagePreviewer::~MessagePreviewer() { MessagePreviewer::~MessagePreviewer() {}
}
void MessagePreviewer::reloadFontSettings() { void MessagePreviewer::reloadFontSettings() {
const Settings* settings = qApp->settings(); const Settings* settings = qApp->settings();
QFont fon; QFont fon;
fon.fromString(settings->value(GROUP(Messages), fon.fromString(settings->value(GROUP(Messages),
SETTING(Messages::PreviewerFontStandard)).toString()); SETTING(Messages::PreviewerFontStandard)).toString());
m_ui->m_txtMessage->setFont(fon); m_ui->m_txtMessage->setFont(fon);
@ -162,6 +162,7 @@ void MessagePreviewer::markMessageAsReadUnread(RootItem::ReadStatus read) {
read); read);
m_message.m_isRead = read == RootItem::Read; m_message.m_isRead = read == RootItem::Read;
emit markMessageRead(m_message.m_id, read); emit markMessageRead(m_message.m_id, read);
updateButtons(); updateButtons();
} }
} }
@ -171,9 +172,12 @@ void MessagePreviewer::switchMessageImportance(bool checked) {
if (!m_root.isNull()) { if (!m_root.isNull()) {
if (m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(), if (m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
QList<ImportanceChange>() << ImportanceChange(m_message, QList<ImportanceChange>() << ImportanceChange(m_message,
m_message.m_isImportant ? m_message.
RootItem::NotImportant : m_isImportant ?
RootItem::Important))) { RootItem::NotImportant
:
RootItem::Important)))
{
DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings), DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
QStringList() << QString::number(m_message.m_id)); QStringList() << QString::number(m_message.m_id));
m_root->getParentServiceRoot()->onAfterSwitchMessageImportance(m_root.data(), m_root->getParentServiceRoot()->onAfterSwitchMessageImportance(m_root.data(),
@ -182,6 +186,7 @@ void MessagePreviewer::switchMessageImportance(bool checked) {
RootItem::NotImportant : RootItem::NotImportant :
RootItem::Important)); RootItem::Important));
emit markMessageImportant(m_message.m_id, checked ? RootItem::Important : RootItem::NotImportant); emit markMessageImportant(m_message.m_id, checked ? RootItem::Important : RootItem::NotImportant);
m_message.m_isImportant = checked; m_message.m_isImportant = checked;
} }
} }
@ -194,6 +199,7 @@ void MessagePreviewer::updateButtons() {
QString MessagePreviewer::prepareHtmlForMessage(const Message& message) { QString MessagePreviewer::prepareHtmlForMessage(const Message& message) {
QString html = QString("<h2 align=\"center\">%1</h2>").arg(message.m_title); QString html = QString("<h2 align=\"center\">%1</h2>").arg(message.m_title);
html += QString("[url] <a href=\"%1\">%1</a><br/>").arg(message.m_url); html += QString("[url] <a href=\"%1\">%1</a><br/>").arg(message.m_url);
foreach (const Enclosure& enc, message.m_enclosures) { foreach (const Enclosure& enc, message.m_enclosures) {
@ -202,6 +208,7 @@ QString MessagePreviewer::prepareHtmlForMessage(const Message& message) {
int offset = 0; int offset = 0;
QRegExp imgTagRegex("\\<img[^\\>]*src\\s*=\\s*\"([^\"]*)\"[^\\>]*\\>", Qt::CaseInsensitive); QRegExp imgTagRegex("\\<img[^\\>]*src\\s*=\\s*\"([^\"]*)\"[^\\>]*\\>", Qt::CaseInsensitive);
imgTagRegex.setMinimal(true); imgTagRegex.setMinimal(true);
while ((offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1) { while ((offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -27,7 +28,6 @@
#include <QPointer> #include <QPointer>
namespace Ui { namespace Ui {
class MessagePreviewer; class MessagePreviewer;
} }
@ -65,9 +65,11 @@ class MessagePreviewer : public QWidget {
QString prepareHtmlForMessage(const Message& message); QString prepareHtmlForMessage(const Message& message);
QToolBar* m_toolBar; QToolBar* m_toolBar;
QScopedPointer<Ui::MessagePreviewer> m_ui; QScopedPointer<Ui::MessagePreviewer> m_ui;
Message m_message; Message m_message;
QStringList m_pictures; QStringList m_pictures;
QPointer<RootItem> m_root; QPointer<RootItem> m_root;
QAction* m_actionMarkRead; QAction* m_actionMarkRead;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,9 +18,6 @@
#include "gui/messagessearchlineedit.h" #include "gui/messagessearchlineedit.h"
MessagesSearchLineEdit::MessagesSearchLineEdit(QWidget* parent) : BaseLineEdit(parent) {}
MessagesSearchLineEdit::MessagesSearchLineEdit(QWidget* parent) : BaseLineEdit(parent) { MessagesSearchLineEdit::~MessagesSearchLineEdit() {}
}
MessagesSearchLineEdit::~MessagesSearchLineEdit() {
}

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,13 +21,13 @@
#include "gui/baselineedit.h" #include "gui/baselineedit.h"
class PlainToolButton; class PlainToolButton;
class MessagesSearchLineEdit : public BaseLineEdit { class MessagesSearchLineEdit : public BaseLineEdit {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit MessagesSearchLineEdit(QWidget* parent = 0); explicit MessagesSearchLineEdit(QWidget* parent = 0);
virtual ~MessagesSearchLineEdit(); virtual ~MessagesSearchLineEdit();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -23,10 +24,9 @@
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "miscellaneous/settings.h" #include "miscellaneous/settings.h"
#include <QWidgetAction>
#include <QToolButton>
#include <QMenu> #include <QMenu>
#include <QToolButton>
#include <QWidgetAction>
MessagesToolBar::MessagesToolBar(const QString& title, QWidget* parent) MessagesToolBar::MessagesToolBar(const QString& title, QWidget* parent)
: BaseToolBar(title, parent) { : BaseToolBar(title, parent) {
@ -34,8 +34,7 @@ MessagesToolBar::MessagesToolBar(const QString& title, QWidget* parent)
initializeHighlighter(); initializeHighlighter();
} }
MessagesToolBar::~MessagesToolBar() { MessagesToolBar::~MessagesToolBar() {}
}
QList<QAction*> MessagesToolBar::availableActions() const { QList<QAction*> MessagesToolBar::availableActions() const {
QList<QAction*> available_actions = qApp->userActions(); QList<QAction*> available_actions = qApp->userActions();
@ -73,6 +72,7 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
else if (action_name == SEPARATOR_ACTION_NAME) { else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator. // Add new separator.
QAction* act = new QAction(this); QAction* act = new QAction(this);
act->setSeparator(true); act->setSeparator(true);
spec_actions.append(act); spec_actions.append(act);
} }
@ -87,8 +87,10 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
else if (action_name == SPACER_ACTION_NAME) { else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer. // Add new spacer.
QWidget* spacer = new QWidget(this); QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidgetAction* action = new QWidgetAction(this); QWidgetAction* action = new QWidgetAction(this);
action->setDefaultWidget(spacer); action->setDefaultWidget(spacer);
action->setIcon(qApp->icons()->fromTheme(QSL("go-jump"))); action->setIcon(qApp->icons()->fromTheme(QSL("go-jump")));
action->setProperty("type", SPACER_ACTION_NAME); action->setProperty("type", SPACER_ACTION_NAME);
@ -118,6 +120,7 @@ void MessagesToolBar::initializeSearchBox() {
m_txtSearchMessages = new MessagesSearchLineEdit(this); m_txtSearchMessages = new MessagesSearchLineEdit(this);
m_txtSearchMessages->setFixedWidth(FILTER_WIDTH); m_txtSearchMessages->setFixedWidth(FILTER_WIDTH);
m_txtSearchMessages->setPlaceholderText(tr("Search messages")); m_txtSearchMessages->setPlaceholderText(tr("Search messages"));
// Setup wrapping action for search box. // Setup wrapping action for search box.
m_actionSearchMessages = new QWidgetAction(this); m_actionSearchMessages = new QWidgetAction(this);
m_actionSearchMessages->setDefaultWidget(m_txtSearchMessages); m_actionSearchMessages->setDefaultWidget(m_txtSearchMessages);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "core/messagesmodel.h" #include "core/messagesmodel.h"
class MessagesSearchLineEdit; class MessagesSearchLineEdit;
class QWidgetAction; class QWidgetAction;
class QToolButton; class QToolButton;
@ -32,6 +32,7 @@ class MessagesToolBar : public BaseToolBar {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors. // Constructors and destructors.
explicit MessagesToolBar(const QString& title, QWidget* parent = 0); explicit MessagesToolBar(const QString& title, QWidget* parent = 0);
virtual ~MessagesToolBar(); virtual ~MessagesToolBar();
@ -43,6 +44,7 @@ class MessagesToolBar : public BaseToolBar {
// Implementation of BaseToolBar interface. // Implementation of BaseToolBar interface.
QList<QAction*> availableActions() const; QList<QAction*> availableActions() const;
QList<QAction*> changeableActions() const; QList<QAction*> changeableActions() const;
void saveChangeableActions(const QStringList& actions); void saveChangeableActions(const QStringList& actions);
@ -63,6 +65,7 @@ class MessagesToolBar : public BaseToolBar {
void messageFilterChanged(MessagesModel::MessageHighlighter filter); void messageFilterChanged(MessagesModel::MessageHighlighter filter);
private slots: private slots:
// Called when highlighter gets changed. // Called when highlighter gets changed.
void handleMessageHighlighterChange(QAction* action); void handleMessageHighlighterChange(QAction* action);
@ -74,7 +77,6 @@ class MessagesToolBar : public BaseToolBar {
QWidgetAction* m_actionMessageHighlighter; QWidgetAction* m_actionMessageHighlighter;
QToolButton* m_btnMessageHighlighter; QToolButton* m_btnMessageHighlighter;
QMenu* m_menuMessageHighlighter; QMenu* m_menuMessageHighlighter;
QWidgetAction* m_actionSearchMessages; QWidgetAction* m_actionSearchMessages;
MessagesSearchLineEdit* m_txtSearchMessages; MessagesSearchLineEdit* m_txtSearchMessages;
}; };

View file

@ -211,7 +211,9 @@ void MessagesView::initializeContextMenu() {
} }
m_contextMenu->addMenu(menu); m_contextMenu->addMenu(menu);
m_contextMenu->addActions(QList<QAction*>() << qApp->mainForm()->m_ui->m_actionSendMessageViaEmail << qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages << qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages); m_contextMenu->addActions(
QList<QAction*>() << qApp->mainForm()->m_ui->m_actionSendMessageViaEmail << qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
if (m_sourceModel->loadedItem() != nullptr && m_sourceModel->loadedItem()->kind() == RootItemKind::Bin) { if (m_sourceModel->loadedItem() != nullptr && m_sourceModel->loadedItem()->kind() == RootItemKind::Bin) {
m_contextMenu->addAction(qApp->mainForm()->m_ui->m_actionRestoreSelectedMessages); m_contextMenu->addAction(qApp->mainForm()->m_ui->m_actionRestoreSelectedMessages);
@ -267,7 +269,11 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS
const QModelIndex current_index = currentIndex(); const QModelIndex current_index = currentIndex();
const QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index); const QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
qDebug("Current row changed - row [%d,%d] source [%d, %d].",current_index.row(), current_index.column(),mapped_current_index.row(), mapped_current_index.column()); qDebug("Current row changed - row [%d,%d] source [%d, %d].",
current_index.row(),
current_index.column(),
mapped_current_index.row(),
mapped_current_index.column());
if (mapped_current_index.isValid() && selected_rows.count() > 0) { if (mapped_current_index.isValid() && selected_rows.count() > 0) {
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row()); Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(current_index).row());
@ -310,7 +316,9 @@ void MessagesView::openSelectedSourceMessagesExternally() {
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url; const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
if (!qApp->web()->openUrlInExternalBrowser(link)) { if (!qApp->web()->openUrlInExternalBrowser(link)) {
qApp->showGuiMessage(tr("Problem with starting external web browser"),tr("External web browser could not be started."),QSystemTrayIcon::Critical); qApp->showGuiMessage(tr("Problem with starting external web browser"),
tr("External web browser could not be started."),
QSystemTrayIcon::Critical);
return; return;
} }
} }
@ -338,7 +346,8 @@ void MessagesView::sendSelectedMessageViaEmail() {
const Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row()); const Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row());
if (!qApp->web()->sendMessageViaEmail(message)) { if (!qApp->web()->sendMessageViaEmail(message)) {
MessageBox::show(this,QMessageBox::Critical,tr("Problem with starting external e-mail client"),tr("External e-mail client could not be started.")); MessageBox::show(this, QMessageBox::Critical, tr("Problem with starting external e-mail client"),
tr("External e-mail client could not be started."));
} }
} }
} }
@ -520,7 +529,9 @@ void MessagesView::openSelectedMessagesWithExternalTool() {
if (!link.isEmpty()) { if (!link.isEmpty()) {
if (!QProcess::startDetached(tool.executable(), QStringList() << tool.parameters() << link)) { if (!QProcess::startDetached(tool.executable(), QStringList() << tool.parameters() << link)) {
qApp->showGuiMessage(tr("Cannot run external tool"), tr("External tool '%1' could not be started.").arg(tool.executable()),QSystemTrayIcon::Critical); qApp->showGuiMessage(tr("Cannot run external tool"),
tr("External tool '%1' could not be started.").arg(tool.executable()),
QSystemTrayIcon::Critical);
} }
} }
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -21,12 +22,9 @@
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "network-web/networkfactory.h" #include "network-web/networkfactory.h"
MessageTextBrowser::MessageTextBrowser(QWidget* parent) : QTextBrowser(parent) {}
MessageTextBrowser::MessageTextBrowser(QWidget* parent) : QTextBrowser(parent) { MessageTextBrowser::~MessageTextBrowser() {}
}
MessageTextBrowser::~MessageTextBrowser() {
}
QVariant MessageTextBrowser::loadResource(int type, const QUrl& name) { QVariant MessageTextBrowser::loadResource(int type, const QUrl& name) {
Q_UNUSED(name) Q_UNUSED(name)

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QTextBrowser> #include <QTextBrowser>
class MessageTextBrowser : public QTextBrowser { class MessageTextBrowser : public QTextBrowser {
Q_OBJECT Q_OBJECT

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,13 +18,12 @@
#include "gui/newspaperpreviewer.h" #include "gui/newspaperpreviewer.h"
#include "gui/messagepreviewer.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "gui/messagepreviewer.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include <QScrollBar> #include <QScrollBar>
NewspaperPreviewer::NewspaperPreviewer(RootItem* root, QList<Message> messages, QWidget* parent) NewspaperPreviewer::NewspaperPreviewer(RootItem* root, QList<Message> messages, QWidget* parent)
: TabContent(parent), m_ui(new Ui::NewspaperPreviewer), m_root(root), m_messages(messages) { : TabContent(parent), m_ui(new Ui::NewspaperPreviewer), m_root(root), m_messages(messages) {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -31,8 +31,7 @@ NewspaperPreviewer::NewspaperPreviewer(RootItem* root, QList<Message> messages,
showMoreMessages(); showMoreMessages();
} }
NewspaperPreviewer::~NewspaperPreviewer() { NewspaperPreviewer::~NewspaperPreviewer() {}
}
void NewspaperPreviewer::showMoreMessages() { void NewspaperPreviewer::showMoreMessages() {
if (!m_root.isNull()) { if (!m_root.isNull()) {
@ -42,6 +41,7 @@ void NewspaperPreviewer::showMoreMessages() {
Message msg = m_messages.takeFirst(); Message msg = m_messages.takeFirst();
MessagePreviewer* prev = new MessagePreviewer(this); MessagePreviewer* prev = new MessagePreviewer(this);
QMargins margins = prev->layout()->contentsMargins(); QMargins margins = prev->layout()->contentsMargins();
connect(prev, &MessagePreviewer::requestMessageListReload, this, &NewspaperPreviewer::requestMessageListReload); connect(prev, &MessagePreviewer::requestMessageListReload, this, &NewspaperPreviewer::requestMessageListReload);
margins.setRight(0); margins.setRight(0);
prev->layout()->setContentsMargins(margins); prev->layout()->setContentsMargins(margins);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -29,7 +30,6 @@
#include <QPointer> #include <QPointer>
namespace Ui { namespace Ui {
class NewspaperPreviewer; class NewspaperPreviewer;
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,24 +18,22 @@
#include "gui/plaintoolbutton.h" #include "gui/plaintoolbutton.h"
#include <QToolButton> #include <QAction>
#include <QStyle>
#include <QPainter> #include <QPainter>
#include <QPaintEvent> #include <QPaintEvent>
#include <QStyle>
#include <QStyleOption> #include <QStyleOption>
#include <QAction> #include <QToolButton>
PlainToolButton::PlainToolButton(QWidget* parent) : QToolButton(parent), m_padding(0) {}
PlainToolButton::PlainToolButton(QWidget* parent) : QToolButton(parent), m_padding(0) { PlainToolButton::~PlainToolButton() {}
}
PlainToolButton::~PlainToolButton() {
}
void PlainToolButton::paintEvent(QPaintEvent* e) { void PlainToolButton::paintEvent(QPaintEvent* e) {
Q_UNUSED(e) Q_UNUSED(e)
QPainter p(this); QPainter p(this);
QRect rect(QPoint(0, 0), size()); QRect rect(QPoint(0, 0), size());
// Set padding. // Set padding.
rect.adjust(m_padding, m_padding, -m_padding, -m_padding); rect.adjust(m_padding, m_padding, -m_padding, -m_padding);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,11 +21,11 @@
#include <QToolButton> #include <QToolButton>
class PlainToolButton : public QToolButton { class PlainToolButton : public QToolButton {
Q_OBJECT Q_OBJECT
public: public:
// Contructors and destructors. // Contructors and destructors.
explicit PlainToolButton(QWidget* parent = 0); explicit PlainToolButton(QWidget* parent = 0);
virtual ~PlainToolButton(); virtual ~PlainToolButton();
@ -39,6 +40,7 @@ class PlainToolButton : public QToolButton {
void reactOnSenderActionChange(); void reactOnSenderActionChange();
protected: protected:
// Custom look. // Custom look.
void paintEvent(QPaintEvent* e); void paintEvent(QPaintEvent* e);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,16 +18,15 @@
#include "gui/settings/settingsbrowsermail.h" #include "gui/settings/settingsbrowsermail.h"
#include "network-web/silentnetworkaccessmanager.h"
#include "miscellaneous/application.h"
#include "miscellaneous/textfactory.h"
#include "gui/guiutilities.h" #include "gui/guiutilities.h"
#include "miscellaneous/application.h"
#include "miscellaneous/externaltool.h" #include "miscellaneous/externaltool.h"
#include "miscellaneous/textfactory.h"
#include "network-web/silentnetworkaccessmanager.h"
#include <QNetworkProxy>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog> #include <QInputDialog>
#include <QNetworkProxy>
SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent) SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsBrowserMail) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsBrowserMail) {
@ -51,7 +51,8 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtProxyPassword, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyPassword, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtProxyUsername, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyUsername, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_spinProxyPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_spinProxyPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_grpCustomExternalBrowser, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_grpCustomExternalBrowser, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_grpCustomExternalEmail, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_grpCustomExternalEmail, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtExternalBrowserArguments, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtExternalBrowserArguments, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
@ -71,7 +72,7 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_btnAddTool, &QPushButton::clicked, this, &SettingsBrowserMail::addExternalTool); connect(m_ui->m_btnAddTool, &QPushButton::clicked, this, &SettingsBrowserMail::addExternalTool);
connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::deleteSelectedExternalTool); connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::deleteSelectedExternalTool);
connect(m_ui->m_listTools, &QTreeWidget::currentItemChanged, [this](QTreeWidgetItem * current, QTreeWidgetItem * previous) { connect(m_ui->m_listTools, &QTreeWidget::currentItemChanged, [this](QTreeWidgetItem* current, QTreeWidgetItem* previous) {
Q_UNUSED(previous) Q_UNUSED(previous)
m_ui->m_btnDeleteTool->setEnabled(current != nullptr); m_ui->m_btnDeleteTool->setEnabled(current != nullptr);
@ -92,6 +93,7 @@ void SettingsBrowserMail::selectBrowserExecutable() {
const QString executable_file = QFileDialog::getOpenFileName(this, const QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select web browser executable"), tr("Select web browser executable"),
qApp->homeFolder(), qApp->homeFolder(),
//: File filter for external browser selection dialog. //: File filter for external browser selection dialog.
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
tr("Executables (*)")); tr("Executables (*)"));
@ -116,6 +118,7 @@ void SettingsBrowserMail::displayProxyPassword(int state) {
void SettingsBrowserMail::onProxyTypeChanged(int index) { void SettingsBrowserMail::onProxyTypeChanged(int index) {
const QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt()); const QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt());
const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy; const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy;
m_ui->m_txtProxyHost->setEnabled(is_proxy_selected); m_ui->m_txtProxyHost->setEnabled(is_proxy_selected);
m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected); m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected);
m_ui->m_txtProxyUsername->setEnabled(is_proxy_selected); m_ui->m_txtProxyUsername->setEnabled(is_proxy_selected);
@ -142,6 +145,7 @@ void SettingsBrowserMail::setExternalTools(const QList<ExternalTool>& list) {
foreach (const ExternalTool& tool, list) { foreach (const ExternalTool& tool, list) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools, QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools,
QStringList() << tool.executable() << tool.parameters().join(QL1C(' '))); QStringList() << tool.executable() << tool.parameters().join(QL1C(' ')));
item->setData(0, Qt::UserRole, QVariant::fromValue(tool)); item->setData(0, Qt::UserRole, QVariant::fromValue(tool));
m_ui->m_listTools->addTopLevelItem(item); m_ui->m_listTools->addTopLevelItem(item);
@ -158,6 +162,7 @@ void SettingsBrowserMail::selectEmailExecutable() {
QString executable_file = QFileDialog::getOpenFileName(this, QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select e-mail executable"), tr("Select e-mail executable"),
qApp->homeFolder(), qApp->homeFolder(),
//: File filter for external e-mail selection dialog. //: File filter for external e-mail selection dialog.
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
tr("Executables (*)")); tr("Executables (*)"));
@ -188,7 +193,8 @@ void SettingsBrowserMail::loadSettings() {
// Load settings of e-mail. // Load settings of e-mail.
m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\""));
m_ui->m_txtExternalEmailExecutable->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString()); m_ui->m_txtExternalEmailExecutable->setText(settings()->value(GROUP(Browser),
SETTING(Browser::CustomExternalEmailExecutable)).toString());
m_ui->m_txtExternalEmailArguments->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString()); m_ui->m_txtExternalEmailArguments->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString());
m_ui->m_grpCustomExternalEmail->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()); m_ui->m_grpCustomExternalEmail->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool());
m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy); m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
@ -244,6 +250,7 @@ void SettingsBrowserMail::addExternalTool() {
QString executable_file = QFileDialog::getOpenFileName(this, QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select external tool"), tr("Select external tool"),
qApp->homeFolder(), qApp->homeFolder(),
//: File filter for external tool selection dialog. //: File filter for external tool selection dialog.
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
tr("Executables (*)")); tr("Executables (*)"));
@ -254,13 +261,18 @@ void SettingsBrowserMail::addExternalTool() {
if (!executable_file.isEmpty()) { if (!executable_file.isEmpty()) {
executable_file = QDir::toNativeSeparators(executable_file); executable_file = QDir::toNativeSeparators(executable_file);
bool ok; bool ok;
QString parameters = QInputDialog::getText(this, tr("Enter parameters"), QString parameters = QInputDialog::getText(this,
tr("Enter (optional) parameters separated by single space to send to executable when opening URLs."), tr("Enter parameters"),
QLineEdit::Normal, QString(), &ok); tr(
"Enter (optional) parameters separated by single space to send to executable when opening URLs."),
QLineEdit::Normal,
QString(),
&ok);
if (ok) { if (ok) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools, QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools,
QStringList() << QDir::toNativeSeparators(executable_file) << parameters); QStringList() << QDir::toNativeSeparators(executable_file) << parameters);
item->setData(0, Qt::UserRole, QVariant::fromValue(ExternalTool(executable_file, parameters.split(QSL(" "))))); item->setData(0, Qt::UserRole, QVariant::fromValue(ExternalTool(executable_file, parameters.split(QSL(" ")))));
m_ui->m_listTools->addTopLevelItem(item); m_ui->m_listTools->addTopLevelItem(item);
} }

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -23,7 +24,6 @@
#include "miscellaneous/externaltool.h" #include "miscellaneous/externaltool.h"
#include "ui_settingsbrowsermail.h" #include "ui_settingsbrowsermail.h"
class SettingsBrowserMail : public SettingsPanel { class SettingsBrowserMail : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -36,6 +36,7 @@ class SettingsBrowserMail : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private slots: private slots:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,12 +18,11 @@
#include "gui/settings/settingsdatabase.h" #include "gui/settings/settingsdatabase.h"
#include "miscellaneous/databasefactory.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/textfactory.h"
#include "gui/guiutilities.h" #include "gui/guiutilities.h"
#include "miscellaneous/application.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/textfactory.h"
SettingsDatabase::SettingsDatabase(Settings* settings, QWidget* parent) SettingsDatabase::SettingsDatabase(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsDatabase) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsDatabase) {
@ -139,8 +139,10 @@ void SettingsDatabase::loadSettings() {
m_ui->m_checkUseTransactions->setChecked(qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool()); m_ui->m_checkUseTransactions->setChecked(qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool());
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information, tr("No connection test triggered so far."), m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information, tr("No connection test triggered so far."),
tr("You did not executed any connection test yet.")); tr("You did not executed any connection test yet."));
// Load SQLite. // Load SQLite.
m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::SQLITE), APP_DB_SQLITE_DRIVER); m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::SQLITE), APP_DB_SQLITE_DRIVER);
// Load in-memory database status. // Load in-memory database status.
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool()); m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool());
@ -149,8 +151,10 @@ void SettingsDatabase::loadSettings() {
onMysqlUsernameChanged(QString()); onMysqlUsernameChanged(QString());
onMysqlPasswordChanged(QString()); onMysqlPasswordChanged(QString());
onMysqlDatabaseChanged(QString()); onMysqlDatabaseChanged(QString());
// Load MySQL. // Load MySQL.
m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::MYSQL), APP_DB_MYSQL_DRIVER); m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::MYSQL), APP_DB_MYSQL_DRIVER);
// Setup placeholders. // Setup placeholders.
m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server")); m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server"));
m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with")); m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with"));
@ -177,13 +181,17 @@ void SettingsDatabase::loadSettings() {
void SettingsDatabase::saveSettings() { void SettingsDatabase::saveSettings() {
onBeginSaveSettings(); onBeginSaveSettings();
// Setup in-memory database status. // Setup in-memory database status.
const bool original_inmemory = settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool(); const bool original_inmemory = settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool();
const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked(); const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
qApp->settings()->setValue(GROUP(Database), Database::UseTransactions, m_ui->m_checkUseTransactions->isChecked()); qApp->settings()->setValue(GROUP(Database), Database::UseTransactions, m_ui->m_checkUseTransactions->isChecked());
// Save data storage settings. // Save data storage settings.
QString original_db_driver = settings()->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString(); QString original_db_driver = settings()->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString();
QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString(); QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
// Save SQLite. // Save SQLite.
settings()->setValue(GROUP(Database), Database::UseInMemory, new_inmemory); settings()->setValue(GROUP(Database), Database::UseInMemory, new_inmemory);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingsdatabase.h" #include "ui_settingsdatabase.h"
class SettingsDatabase : public SettingsPanel { class SettingsDatabase : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,6 +35,7 @@ class SettingsDatabase : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private: private:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,13 +18,12 @@
#include "gui/settings/settingsdownloads.h" #include "gui/settings/settingsdownloads.h"
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h" #include "miscellaneous/settings.h"
#include "network-web/downloadmanager.h" #include "network-web/downloadmanager.h"
#include "miscellaneous/application.h"
#include <QFileDialog> #include <QFileDialog>
SettingsDownloads::SettingsDownloads(Settings* settings, QWidget* parent) SettingsDownloads::SettingsDownloads(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsDownloads) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsDownloads) {
m_ui->setupUi(this); m_ui->setupUi(this);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingsdownloads.h" #include "ui_settingsdownloads.h"
class SettingsDownloads : public SettingsPanel { class SettingsDownloads : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,6 +35,7 @@ class SettingsDownloads : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private slots: private slots:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -18,18 +19,17 @@
#include "gui/settings/settingsfeedsmessages.h" #include "gui/settings/settingsfeedsmessages.h"
#include "definitions/definitions.h" #include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/feedreader.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "gui/feedmessageviewer.h" #include "gui/feedmessageviewer.h"
#include "gui/feedsview.h" #include "gui/feedsview.h"
#include "gui/guiutilities.h"
#include "gui/messagesview.h" #include "gui/messagesview.h"
#include "gui/timespinbox.h" #include "gui/timespinbox.h"
#include "gui/guiutilities.h" #include "miscellaneous/application.h"
#include "miscellaneous/feedreader.h"
#include <QFontDialog> #include <QFontDialog>
SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent) SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsFeedsMessages) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsFeedsMessages) {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -66,6 +66,7 @@ SettingsFeedsMessages::~SettingsFeedsMessages() {
void SettingsFeedsMessages::initializeMessageDateFormats() { void SettingsFeedsMessages::initializeMessageDateFormats() {
QStringList best_formats; QStringList best_formats;
best_formats << QSL("d/M/yyyy hh:mm:ss") << QSL("ddd, d. M. yy hh:mm:ss") << best_formats << QSL("d/M/yyyy hh:mm:ss") << QSL("ddd, d. M. yy hh:mm:ss") <<
QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-ddThh:mm:ss") << QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-ddThh:mm:ss") <<
QSL("MMM d yyyy hh:mm:ss");; QSL("MMM d yyyy hh:mm:ss");;
@ -112,6 +113,7 @@ void SettingsFeedsMessages::loadSettings() {
m_ui->m_lblMessagesFont->setText(tr("Font preview")); m_ui->m_lblMessagesFont->setText(tr("Font preview"));
QFont fon; QFont fon;
fon.fromString(settings()->value(GROUP(Messages), fon.fromString(settings()->value(GROUP(Messages),
SETTING(Messages::PreviewerFontStandard)).toString()); SETTING(Messages::PreviewerFontStandard)).toString());
m_ui->m_lblMessagesFont->setFont(fon); m_ui->m_lblMessagesFont->setFont(fon);
@ -132,6 +134,7 @@ void SettingsFeedsMessages::saveSettings() {
settings()->setValue(GROUP(Messages), Messages::MessageHeadImageHeight, m_ui->m_spinHeightImageAttachments->value()); settings()->setValue(GROUP(Messages), Messages::MessageHeadImageHeight, m_ui->m_spinHeightImageAttachments->value());
settings()->setValue(GROUP(Messages), Messages::CustomDateFormat, settings()->setValue(GROUP(Messages), Messages::CustomDateFormat,
m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString()); m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString());
// Save fonts. // Save fonts.
settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString()); settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString());
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts(); qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingsfeedsmessages.h" #include "ui_settingsfeedsmessages.h"
class SettingsFeedsMessages : public SettingsPanel { class SettingsFeedsMessages : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,6 +35,7 @@ class SettingsFeedsMessages : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private slots: private slots:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,9 +18,8 @@
#include "gui/settings/settingsgeneral.h" #include "gui/settings/settingsgeneral.h"
#include "miscellaneous/systemfactory.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/systemfactory.h"
SettingsGeneral::SettingsGeneral(Settings* settings, QWidget* parent) SettingsGeneral::SettingsGeneral(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsGeneral) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsGeneral) {
@ -37,6 +37,7 @@ SettingsGeneral::~SettingsGeneral() {
void SettingsGeneral::loadSettings() { void SettingsGeneral::loadSettings() {
onBeginLoadSettings(); onBeginLoadSettings();
m_ui->m_checkForUpdatesOnStart->setChecked(settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()); m_ui->m_checkForUpdatesOnStart->setChecked(settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool());
// Load auto-start status. // Load auto-start status.
const SystemFactory::AutoStartStatus autostart_status = qApp->system()->autoStartStatus(); const SystemFactory::AutoStartStatus autostart_status = qApp->system()->autoStartStatus();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingsgeneral.h" #include "ui_settingsgeneral.h"
class SettingsGeneral : public SettingsPanel { class SettingsGeneral : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,6 +35,7 @@ class SettingsGeneral : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private: private:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,21 +18,20 @@
#include "gui/settings/settingsgui.h" #include "gui/settings/settingsgui.h"
#include "gui/systemtrayicon.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "gui/tabwidget.h"
#include "gui/feedmessageviewer.h" #include "gui/feedmessageviewer.h"
#include "gui/feedstoolbar.h" #include "gui/feedstoolbar.h"
#include "gui/messagestoolbar.h" #include "gui/messagestoolbar.h"
#include "gui/statusbar.h" #include "gui/statusbar.h"
#include "gui/systemtrayicon.h"
#include "gui/tabwidget.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/settings.h"
#include <QDropEvent> #include <QDropEvent>
#include <QStyleFactory> #include <QStyleFactory>
SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(settings, parent), m_ui(new Ui::SettingsGui) { SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(settings, parent), m_ui(new Ui::SettingsGui) {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->m_editorMessagesToolbar->activeItemsWidget()->viewport()->installEventFilter(this); m_ui->m_editorMessagesToolbar->activeItemsWidget()->viewport()->installEventFilter(this);
@ -45,13 +45,15 @@ SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(se
<< /*: Version column of skin list. */ tr("Version") << /*: Version column of skin list. */ tr("Version")
<< tr("Author") << tr("Author")
<< tr("E-mail")); << tr("E-mail"));
// Setup skins. // Setup skins.
m_ui->m_treeSkins->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); m_ui->m_treeSkins->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); m_ui->m_treeSkins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
m_ui->m_treeSkins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); m_ui->m_treeSkins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
connect(m_ui->m_cmbIconTheme, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SettingsGui::requireRestart); connect(m_ui->m_cmbIconTheme, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SettingsGui::requireRestart);
connect(m_ui->m_cmbIconTheme, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SettingsGui::dirtifySettings); connect(m_ui->m_cmbIconTheme, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&SettingsGui::dirtifySettings);
connect(m_ui->m_treeSkins, &QTreeWidget::currentItemChanged, this, &SettingsGui::dirtifySettings); connect(m_ui->m_treeSkins, &QTreeWidget::currentItemChanged, this, &SettingsGui::dirtifySettings);
connect(m_ui->m_grpTray, &QGroupBox::toggled, this, &SettingsGui::dirtifySettings); connect(m_ui->m_grpTray, &QGroupBox::toggled, this, &SettingsGui::dirtifySettings);
connect(m_ui->m_checkEnableNotifications, &QCheckBox::toggled, this, &SettingsGui::dirtifySettings); connect(m_ui->m_checkEnableNotifications, &QCheckBox::toggled, this, &SettingsGui::dirtifySettings);
@ -90,7 +92,6 @@ bool SettingsGui::eventFilter(QObject* obj, QEvent* e) {
return false; return false;
} }
void SettingsGui::loadSettings() { void SettingsGui::loadSettings() {
onBeginLoadSettings(); onBeginLoadSettings();
@ -98,6 +99,7 @@ void SettingsGui::loadSettings() {
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool());
} }
// Tray icon is not supported on this machine. // Tray icon is not supported on this machine.
else { else {
m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)")); m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)"));
@ -106,8 +108,10 @@ void SettingsGui::loadSettings() {
m_ui->m_checkHidden->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool()); m_ui->m_checkHidden->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool());
m_ui->m_checkHideWhenMinimized->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool()); m_ui->m_checkHideWhenMinimized->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool());
// Load fancy notification settings. // Load fancy notification settings.
m_ui->m_checkEnableNotifications->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); m_ui->m_checkEnableNotifications->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
// Load settings of icon theme. // Load settings of icon theme.
const QString current_theme = qApp->icons()->currentIconTheme(); const QString current_theme = qApp->icons()->currentIconTheme();
@ -140,7 +144,9 @@ void SettingsGui::loadSettings() {
skin.m_version << skin.m_version <<
skin.m_author << skin.m_author <<
skin.m_email); skin.m_email);
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin)); new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
// Add this skin and mark it as active if its active now. // Add this skin and mark it as active if its active now.
m_ui->m_treeSkins->addTopLevelItem(new_item); m_ui->m_treeSkins->addTopLevelItem(new_item);
@ -173,6 +179,7 @@ void SettingsGui::loadSettings() {
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool()); m_ui->m_checkCloseTabsDoubleClick->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool());
m_ui->m_checkNewTabDoubleClick->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool()); m_ui->m_checkNewTabDoubleClick->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool());
m_ui->m_checkHideTabBarIfOneTabVisible->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool()); m_ui->m_checkHideTabBarIfOneTabVisible->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool());
// Load toolbar button style. // Load toolbar button style.
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly); m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly);
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text only"), Qt::ToolButtonTextOnly); m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text only"), Qt::ToolButtonTextOnly);
@ -180,7 +187,9 @@ void SettingsGui::loadSettings() {
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon); m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon);
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Follow OS style"), Qt::ToolButtonFollowStyle); m_ui->m_cmbToolbarButtonStyle->addItem(tr("Follow OS style"), Qt::ToolButtonFollowStyle);
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(settings()->value(GROUP(GUI), m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(settings()->value(GROUP(GUI),
SETTING(GUI::ToolbarStyle)).toInt())); SETTING(
GUI::ToolbarStyle)).toInt()));
// Load toolbars. // Load toolbars.
m_ui->m_editorFeedsToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsToolBar()); m_ui->m_editorFeedsToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsToolBar());
m_ui->m_editorMessagesToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesToolBar()); m_ui->m_editorMessagesToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesToolBar());
@ -190,8 +199,10 @@ void SettingsGui::loadSettings() {
void SettingsGui::saveSettings() { void SettingsGui::saveSettings() {
onBeginSaveSettings(); onBeginSaveSettings();
// Save toolbar. // Save toolbar.
settings()->setValue(GROUP(GUI), GUI::ToolbarStyle, m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex())); settings()->setValue(GROUP(GUI), GUI::ToolbarStyle,
m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
// Save tray icon. // Save tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
@ -207,11 +218,14 @@ void SettingsGui::saveSettings() {
settings()->setValue(GROUP(GUI), GUI::MainWindowStartsHidden, m_ui->m_checkHidden->isChecked()); settings()->setValue(GROUP(GUI), GUI::MainWindowStartsHidden, m_ui->m_checkHidden->isChecked());
settings()->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked()); settings()->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked());
// Save notifications. // Save notifications.
settings()->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_checkEnableNotifications->isChecked()); settings()->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_checkEnableNotifications->isChecked());
// Save selected icon theme. // Save selected icon theme.
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString(); QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
QString original_icon_theme = qApp->icons()->currentIconTheme(); QString original_icon_theme = qApp->icons()->currentIconTheme();
qApp->icons()->setCurrentIconTheme(selected_icon_theme); qApp->icons()->setCurrentIconTheme(selected_icon_theme);
// Check if icon theme was changed. // Check if icon theme was changed.

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingsgui.h" #include "ui_settingsgui.h"
class SettingsGui : public SettingsPanel { class SettingsGui : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,9 +35,11 @@ class SettingsGui : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
protected: protected:
// Does check of controls before dialog can be submitted. // Does check of controls before dialog can be submitted.
bool eventFilter(QObject* obj, QEvent* e); bool eventFilter(QObject* obj, QEvent* e);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,11 +18,10 @@
#include "gui/settings/settingslocalization.h" #include "gui/settings/settingslocalization.h"
#include "miscellaneous/localization.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h" #include "miscellaneous/iconfactory.h"
#include "miscellaneous/localization.h"
#include "miscellaneous/settings.h"
SettingsLocalization::SettingsLocalization(Settings* settings, QWidget* parent) SettingsLocalization::SettingsLocalization(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsLocalization) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsLocalization) {
@ -32,6 +32,7 @@ SettingsLocalization::SettingsLocalization(Settings* settings, QWidget* parent)
<< /*: Language column of language list. */ tr("Language") << /*: Language column of language list. */ tr("Language")
<< /*: Lang. code column of language list. */ tr("Code") << /*: Lang. code column of language list. */ tr("Code")
<< tr("Author")); << tr("Author"));
// Setup languages. // Setup languages.
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
@ -49,6 +50,7 @@ void SettingsLocalization::loadSettings() {
foreach (const Language& language, qApp->localization()->installedLanguages()) { foreach (const Language& language, qApp->localization()->installedLanguages()) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_treeLanguages); QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
item->setText(0, language.m_name); item->setText(0, language.m_name);
item->setText(1, language.m_code); item->setText(1, language.m_code);
item->setText(2, language.m_author); item->setText(2, language.m_author);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -22,7 +23,6 @@
#include "ui_settingslocalization.h" #include "ui_settingslocalization.h"
class SettingsLocalization : public SettingsPanel { class SettingsLocalization : public SettingsPanel {
Q_OBJECT Q_OBJECT
@ -35,6 +35,7 @@ class SettingsLocalization : public SettingsPanel {
} }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
private: private:

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -19,10 +20,8 @@
#include "miscellaneous/settings.h" #include "miscellaneous/settings.h"
SettingsPanel::SettingsPanel(Settings* settings, QWidget* parent) SettingsPanel::SettingsPanel(Settings* settings, QWidget* parent)
: QWidget(parent), m_requiresRestart(false), m_isDirty(false), m_isLoading(false), m_settings(settings) { : QWidget(parent), m_requiresRestart(false), m_isDirty(false), m_isLoading(false), m_settings(settings) {}
}
void SettingsPanel::onBeginLoadSettings() { void SettingsPanel::onBeginLoadSettings() {
m_isLoading = true; m_isLoading = true;
@ -34,8 +33,7 @@ void SettingsPanel::onEndLoadSettings() {
setIsDirty(false); setIsDirty(false);
} }
void SettingsPanel::onBeginSaveSettings() { void SettingsPanel::onBeginSaveSettings() {}
}
void SettingsPanel::onEndSaveSettings() { void SettingsPanel::onEndSaveSettings() {
setIsDirty(false); setIsDirty(false);

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -20,7 +21,6 @@
#include <QWidget> #include <QWidget>
class Settings; class Settings;
class SettingsPanel : public QWidget { class SettingsPanel : public QWidget {
@ -30,7 +30,6 @@ class SettingsPanel : public QWidget {
explicit SettingsPanel(Settings* settings, QWidget* parent = 0); explicit SettingsPanel(Settings* settings, QWidget* parent = 0);
virtual QString title() const = 0; virtual QString title() const = 0;
virtual void loadSettings() = 0; virtual void loadSettings() = 0;
virtual void saveSettings() = 0; virtual void saveSettings() = 0;
@ -50,6 +49,7 @@ class SettingsPanel : public QWidget {
Settings* settings() const; Settings* settings() const;
protected slots: protected slots:
// Sets this settings panel as dirty (some settings are changed) and emits the signal. // Sets this settings panel as dirty (some settings are changed) and emits the signal.
// NOTE: This will be probably called by subclasses when user changes some stuff. // NOTE: This will be probably called by subclasses when user changes some stuff.
void dirtifySettings(); void dirtifySettings();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard. // This file is part of RSS Guard.
// //
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com> // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
// //
@ -17,9 +18,8 @@
#include "gui/settings/settingsshortcuts.h" #include "gui/settings/settingsshortcuts.h"
#include "miscellaneous/application.h"
#include "dynamic-shortcuts/dynamicshortcuts.h" #include "dynamic-shortcuts/dynamicshortcuts.h"
#include "miscellaneous/application.h"
SettingsShortcuts::SettingsShortcuts(Settings* settings, QWidget* parent) SettingsShortcuts::SettingsShortcuts(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsShortcuts) { : SettingsPanel(settings, parent), m_ui(new Ui::SettingsShortcuts) {

Some files were not shown because too many files have changed in this diff Show more