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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,14 +18,13 @@
#include "core/feedsproxymodel.h"
#include "core/feedsmodel.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "core/feedsmodel.h"
#include "services/abstract/rootitem.h"
#include <QTimer>
FeedsProxyModel::FeedsProxyModel(FeedsModel* source_model, QObject* parent)
: QSortFilterProxyModel(parent), m_sourceModel(source_model), m_selectedItem(nullptr),
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);
}
}
// QString based matching.
else {
if (entered_text.isEmpty()) {
@ -126,7 +127,8 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex& start, int role, const
}
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);
}
}
@ -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))) {
const_cast<FeedsProxyModel*>(this)->m_hiddenIndices.removeAll(QPair<int, QModelIndex>(source_row, source_parent));
// Load status.
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.
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.
return true;
}

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -21,9 +22,7 @@
#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;
@ -33,6 +32,7 @@ QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosure
if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) {
QStringList mime_url = single_enclosure.split(ECNLOSURES_INNER_SEPARATOR);
enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).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.m_id = record.value(MSG_DB_ID_INDEX).toInt();
message.m_isRead = record.value(MSG_DB_READ_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.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -20,11 +21,10 @@
#include "definitions/definitions.h"
#include <QDateTime>
#include <QStringList>
#include <QSqlRecord>
#include <QDataStream>
#include <QDateTime>
#include <QSqlRecord>
#include <QStringList>
// Represents single enclosure.
struct Enclosure {
@ -50,7 +50,6 @@ class Message {
// Creates Message from given record, which contains
// row from query SELECT * FROM Messages WHERE ....;
static Message fromSqlRecord(const QSqlRecord& record, bool* result = nullptr);
QString m_title;
QString m_url;
QString m_author;
@ -61,7 +60,6 @@ class Message {
int m_id;
QString m_customId;
QString m_customHash;
bool m_isRead;
bool m_isImportant;
@ -78,6 +76,7 @@ class Message {
friend inline bool operator!=(const Message& lhs, const Message& rhs) {
return !(lhs == rhs);
}
};
// Serialize message state.

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -19,12 +20,9 @@
#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) {
if (!m_msgCache.contains(index.row())) {

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -20,7 +21,6 @@
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
MessagesModelSqlLayer::MessagesModelSqlLayer()
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames(QMap<int, QString>()),
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++) {
QString field_name(m_fieldNames[m_sortColumns[i]]);
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.
//
// 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
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef MESSAGESMODELSQLLAYER_H
#define MESSAGESMODELSQLLAYER_H
#include <QSqlDatabase>
#include <QMap>
#include <QList>
#include <QMap>
class MessagesModelSqlLayer {
public:

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -46,7 +47,8 @@
#define DEFAULT_LOCALE "en"
#define DEFAULT_FEED_ENCODING "UTF-8"
#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 TEXT_TITLE_LIMIT 30
#define RESELECT_MESSAGE_THRESSHOLD 500
@ -140,6 +142,7 @@
#define APP_THEME_SUFFIX ".png"
#ifndef QSL
// Thin macro wrapper for literal strings.
// They are much more memory efficient and faster.
// Use it for all literals except for two cases:
@ -149,12 +152,14 @@
#endif
#ifndef QL1S
// Macro for latin strings. Latin strings are
// faster than QStrings created from literals.
#define QL1S(x) QLatin1String(x)
#endif
#ifndef QL1C
// Macro for latin chars.
#define QL1C(x) QLatin1Char(x)
#endif

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// 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/>.
/******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
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
derived from this software without specific prior written permission.
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#include "dynamic-shortcuts/shortcutbutton.h"
@ -49,14 +50,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QKeyEvent>
ShortcutButton::ShortcutButton(ShortcutCatcher* catcher, QWidget* parent)
: QPushButton(parent), m_catcher(catcher) {
setMinimumWidth(100);
}
ShortcutButton::~ShortcutButton() {
}
ShortcutButton::~ShortcutButton() {}
void ShortcutButton::keyPressEvent(QKeyEvent* event) {
int pressed_key = event->key();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// 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/>.
/******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
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
derived from this software without specific prior written permission.
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef SHORTCUTBUTTON_H
#define SHORTCUTBUTTON_H
#include <QPushButton>
class ShortcutCatcher;
class ShortcutButton : public QPushButton {
Q_OBJECT
public:
// Constructors and destructors.
explicit ShortcutButton(ShortcutCatcher* catcher, QWidget* parent = 0);
virtual ~ShortcutButton();

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// 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/>.
/******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
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
derived from this software without specific prior written permission.
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#include "dynamic-shortcuts/shortcutcatcher.h"
@ -51,35 +52,40 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QHBoxLayout>
ShortcutCatcher::ShortcutCatcher(QWidget* parent)
: QWidget(parent) {
// Setup layout of the control
m_layout = new QHBoxLayout(this);
m_layout->setMargin(0);
m_layout->setSpacing(1);
// Create reset button.
m_btnReset = new PlainToolButton(this);
m_btnReset->setIcon(qApp->icons()->fromTheme(QSL("document-revert")));
m_btnReset->setFocusPolicy(Qt::NoFocus);
m_btnReset->setToolTip(tr("Reset to original shortcut."));
// Create clear button.
m_btnClear = new PlainToolButton(this);
m_btnClear->setIcon(qApp->icons()->fromTheme(QSL("list-remove")));
m_btnClear->setFocusPolicy(Qt::NoFocus);
m_btnClear->setToolTip(tr("Clear current shortcut."));
// Clear main shortcut catching button.
m_btnChange = new ShortcutButton(this);
m_btnChange->setFocusPolicy(Qt::StrongFocus);
m_btnChange->setToolTip(tr("Click and hit new shortcut."));
// Add both buttons to the layout.
m_layout->addWidget(m_btnChange);
m_layout->addWidget(m_btnReset);
m_layout->addWidget(m_btnClear);
// Establish needed connections.
connect(m_btnReset, &QToolButton::clicked, this, &ShortcutCatcher::resetShortcut);
connect(m_btnClear, &QToolButton::clicked, this, &ShortcutCatcher::clearShortcut);
connect(m_btnChange, &QToolButton::clicked, this, &ShortcutCatcher::startRecording);
// Prepare initial state of the control.
updateDisplayShortcut();
}
@ -117,6 +123,7 @@ void ShortcutCatcher::controlModifierlessTimout() {
void ShortcutCatcher::updateDisplayShortcut() {
QString str = m_currentSequence.toString(QKeySequence::NativeText);
str.replace(QL1S("&"), QL1S("&&"));
if (m_isRecording) {

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// 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/>.
/******************************************************************************
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Copyright (c) 2010, Artem Galichkin <doomer3d@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
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
derived from this software without specific prior written permission.
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef SHORTCUTCATCHER_H
#define SHORTCUTCATCHER_H
#include <QWidget>
class QHBoxLayout;
class QToolButton;
class ShortcutButton;
@ -59,6 +59,7 @@ class ShortcutCatcher : public QWidget {
friend class ShortcutButton;
public:
// Constructors and destructors.
explicit ShortcutCatcher(QWidget* parent = 0);
virtual ~ShortcutCatcher();
@ -86,10 +87,8 @@ class ShortcutCatcher : public QWidget {
QToolButton* m_btnClear;
ShortcutButton* m_btnChange;
QHBoxLayout* m_layout;
QKeySequence m_currentSequence;
QKeySequence m_defaultSequence;
bool m_isRecording;
int m_numKey;
uint m_modifierKeys;

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,12 +18,9 @@
#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 {
return m_message;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,16 +18,15 @@
#include "gui/dialogs/formbackupdatabasesettings.h"
#include "exceptions/applicationexception.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "exceptions/applicationexception.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QCheckBox>
#include <QFileDialog>
#include <QDateTime>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QPushButton>
FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget* parent) : QDialog(parent), m_ui(new Ui::FormBackupDatabaseSettings) {
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_btnSelectFolder, &QPushButton::clicked, this, &FormBackupDatabaseSettings::selectFolderInitial);
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."));
if (qApp->database()->activeDatabaseDriver() != DatabaseFactory::SQLITE &&

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -93,10 +93,12 @@ void FormRestoreDatabaseSettings::selectFolder(QString 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::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::Name);

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -18,10 +19,10 @@
#include "gui/dialogs/formsettings.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/iconfactory.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/settingsdatabase.h"
@ -32,15 +33,16 @@
#include "gui/settings/settingslocalization.h"
#include "gui/settings/settingsshortcuts.h"
FormSettings::FormSettings(QWidget& parent)
: QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) {
m_ui.setupUi(this);
// Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system")));
m_btnApply = m_ui.m_buttonBox->button(QDialogButtonBox::Apply);
m_btnApply->setEnabled(false);
// Establish needed connections.
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormSettings::saveSettings);
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,
QMessageBox::Question,
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."),
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);
if (clicked_button == QMessageBox::Yes) {
@ -120,7 +124,7 @@ void FormSettings::cancelSettings() {
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("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) {
reject();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -27,7 +28,6 @@
#include <QStyle>
#include <QtGlobal>
MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {}
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,
const QString& informative_text, const QString& detailed_text, QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton default_button, bool* dont_show_again) {
QMessageBox::StandardButton MessageBox::show(QWidget* parent,
QMessageBox::Icon icon,
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.
MessageBox msg_box(parent);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -211,7 +211,9 @@ void MessagesView::initializeContextMenu() {
}
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) {
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 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) {
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;
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;
}
}
@ -338,7 +346,8 @@ void MessagesView::sendSelectedMessageViaEmail() {
const Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row());
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 (!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.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -21,12 +22,9 @@
#include "miscellaneous/iconfactory.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) {
Q_UNUSED(name)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,16 +18,15 @@
#include "gui/settings/settingsbrowsermail.h"
#include "network-web/silentnetworkaccessmanager.h"
#include "miscellaneous/application.h"
#include "miscellaneous/textfactory.h"
#include "gui/guiutilities.h"
#include "miscellaneous/application.h"
#include "miscellaneous/externaltool.h"
#include "miscellaneous/textfactory.h"
#include "network-web/silentnetworkaccessmanager.h"
#include <QNetworkProxy>
#include <QFileDialog>
#include <QInputDialog>
#include <QNetworkProxy>
SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
: 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_txtProxyPassword, &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_grpCustomExternalEmail, &QGroupBox::toggled, 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_btnAddTool, &QPushButton::clicked, this, &SettingsBrowserMail::addExternalTool);
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)
m_ui->m_btnDeleteTool->setEnabled(current != nullptr);
@ -92,6 +93,7 @@ void SettingsBrowserMail::selectBrowserExecutable() {
const QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select web browser executable"),
qApp->homeFolder(),
//: File filter for external browser selection dialog.
#if defined(Q_OS_LINUX)
tr("Executables (*)"));
@ -116,6 +118,7 @@ void SettingsBrowserMail::displayProxyPassword(int state) {
void SettingsBrowserMail::onProxyTypeChanged(int index) {
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;
m_ui->m_txtProxyHost->setEnabled(is_proxy_selected);
m_ui->m_txtProxyPassword->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) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools,
QStringList() << tool.executable() << tool.parameters().join(QL1C(' ')));
item->setData(0, Qt::UserRole, QVariant::fromValue(tool));
m_ui->m_listTools->addTopLevelItem(item);
@ -158,6 +162,7 @@ void SettingsBrowserMail::selectEmailExecutable() {
QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select e-mail executable"),
qApp->homeFolder(),
//: File filter for external e-mail selection dialog.
#if defined(Q_OS_LINUX)
tr("Executables (*)"));
@ -188,7 +193,8 @@ void SettingsBrowserMail::loadSettings() {
// Load settings of e-mail.
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_grpCustomExternalEmail->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool());
m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
@ -244,6 +250,7 @@ void SettingsBrowserMail::addExternalTool() {
QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select external tool"),
qApp->homeFolder(),
//: File filter for external tool selection dialog.
#if defined(Q_OS_LINUX)
tr("Executables (*)"));
@ -254,13 +261,18 @@ void SettingsBrowserMail::addExternalTool() {
if (!executable_file.isEmpty()) {
executable_file = QDir::toNativeSeparators(executable_file);
bool ok;
QString parameters = QInputDialog::getText(this, tr("Enter parameters"),
tr("Enter (optional) parameters separated by single space to send to executable when opening URLs."),
QLineEdit::Normal, QString(), &ok);
QString parameters = QInputDialog::getText(this,
tr("Enter parameters"),
tr(
"Enter (optional) parameters separated by single space to send to executable when opening URLs."),
QLineEdit::Normal,
QString(),
&ok);
if (ok) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools,
QStringList() << QDir::toNativeSeparators(executable_file) << parameters);
item->setData(0, Qt::UserRole, QVariant::fromValue(ExternalTool(executable_file, parameters.split(QSL(" ")))));
m_ui->m_listTools->addTopLevelItem(item);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,21 +18,20 @@
#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/tabwidget.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedstoolbar.h"
#include "gui/messagestoolbar.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 <QStyleFactory>
SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(settings, parent), m_ui(new Ui::SettingsGui) {
m_ui->setupUi(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")
<< tr("Author")
<< tr("E-mail"));
// Setup skins.
m_ui->m_treeSkins->header()->setSectionResizeMode(0, 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(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::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_grpTray, &QGroupBox::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;
}
void SettingsGui::loadSettings() {
onBeginLoadSettings();
@ -98,6 +99,7 @@ void SettingsGui::loadSettings() {
if (SystemTrayIcon::isSystemTrayAvailable()) {
m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool());
}
// Tray icon is not supported on this machine.
else {
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_checkHideWhenMinimized->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool());
// Load fancy notification settings.
m_ui->m_checkEnableNotifications->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
// Load settings of icon theme.
const QString current_theme = qApp->icons()->currentIconTheme();
@ -140,7 +144,9 @@ void SettingsGui::loadSettings() {
skin.m_version <<
skin.m_author <<
skin.m_email);
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
// Add this skin and mark it as active if its active now.
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_checkNewTabDoubleClick->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool());
m_ui->m_checkHideTabBarIfOneTabVisible->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool());
// Load toolbar button style.
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly);
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("Follow OS style"), Qt::ToolButtonFollowStyle);
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(settings()->value(GROUP(GUI),
SETTING(GUI::ToolbarStyle)).toInt()));
SETTING(
GUI::ToolbarStyle)).toInt()));
// Load toolbars.
m_ui->m_editorFeedsToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsToolBar());
m_ui->m_editorMessagesToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesToolBar());
@ -190,8 +199,10 @@ void SettingsGui::loadSettings() {
void SettingsGui::saveSettings() {
onBeginSaveSettings();
// 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.
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::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked());
// Save notifications.
settings()->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_checkEnableNotifications->isChecked());
// Save selected icon theme.
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
QString original_icon_theme = qApp->icons()->currentIconTheme();
qApp->icons()->setCurrentIconTheme(selected_icon_theme);
// Check if icon theme was changed.

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -17,11 +18,10 @@
#include "gui/settings/settingslocalization.h"
#include "miscellaneous/localization.h"
#include "miscellaneous/settings.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/localization.h"
#include "miscellaneous/settings.h"
SettingsLocalization::SettingsLocalization(Settings* settings, QWidget* parent)
: 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")
<< /*: Lang. code column of language list. */ tr("Code")
<< tr("Author"));
// Setup languages.
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, 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()) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
item->setText(0, language.m_name);
item->setText(1, language.m_code);
item->setText(2, language.m_author);

View file

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

View file

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

View file

@ -1,4 +1,5 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
@ -20,7 +21,6 @@
#include <QWidget>
class Settings;
class SettingsPanel : public QWidget {
@ -30,7 +30,6 @@ class SettingsPanel : public QWidget {
explicit SettingsPanel(Settings* settings, QWidget* parent = 0);
virtual QString title() const = 0;
virtual void loadSettings() = 0;
virtual void saveSettings() = 0;
@ -50,6 +49,7 @@ class SettingsPanel : public QWidget {
Settings* settings() const;
protected slots:
// 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.
void dirtifySettings();

View file

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

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