This commit is contained in:
Martin Rotter 2020-07-01 06:15:19 +02:00
parent 45cae956bc
commit 05025f7a04
8 changed files with 215 additions and 30 deletions

View File

@ -44,6 +44,7 @@
<file>./graphics/Faenza/actions/64/tab-new.png</file>
<file>./graphics/Faenza/actions/64/up.png</file>
<file>./graphics/Faenza/actions/64/view-fullscreen.png</file>
<file>./graphics/Faenza/actions/64/view-list-details.png</file>
<file>./graphics/Faenza/actions/64/view-refresh.png</file>
<file>./graphics/Faenza/actions/64/view-restore.png</file>
<file>./graphics/Faenza/actions/64/window-close.png</file>

View File

@ -120,6 +120,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
// Register the wrapper.
auto js_object = filter_engine.newQObject(&msg_obj);
filter_engine.installExtensions(QJSEngine::Extension::ConsoleExtension);
filter_engine.globalObject().setProperty("msg", js_object);
qDebug().nospace() << "Setting up JS evaluation took " << tmr.nsecsElapsed() / 1000 << " microseconds.";

View File

@ -32,6 +32,7 @@
#define RELEASES_LIST "https://api.github.com/repos/martinrotter/rssguard/releases"
#define DEFAULT_LOCALE "en"
#define DEFAULT_FEED_ENCODING "UTF-8"
#define MSG_FILTERING_HELP "https://github.com/martinrotter/rssguard/wiki/Message-filtering"
#define DEFAULT_FEED_TYPE "RSS"
#define URL_REGEXP "^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?$"
#define TEXT_TITLE_LIMIT 30

View File

@ -2,6 +2,7 @@
#include "gui/dialogs/formdatabasecleanup.h"
#include "gui/guiutilities.h"
#include "miscellaneous/application.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
@ -13,9 +14,7 @@
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")));
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("edit-clear")));
connect(m_ui->m_spinDays, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &FormDatabaseCleanup::updateDaysSuffix);
connect(m_ui->m_btnBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &FormDatabaseCleanup::startPurging);

View File

@ -184,6 +184,7 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionSelectPreviousMessage;
actions << m_ui->m_actionSelectNextUnreadMessage;
actions << m_ui->m_actionExpandCollapseItem;
actions << m_ui->m_actionMessageFilters;
#if defined(USE_WEBENGINE)
actions << m_ui->m_actionTabNewWebBrowser;
@ -525,6 +526,7 @@ void FormMain::setupIcons() {
m_ui->m_actionServiceDelete->setIcon(icon_theme_factory->fromTheme(QSL("list-remove")));
m_ui->m_actionAddFeedIntoSelectedAccount->setIcon(icon_theme_factory->fromTheme(QSL("application-rss+xml")));
m_ui->m_actionAddCategoryIntoSelectedAccount->setIcon(icon_theme_factory->fromTheme(QSL("folder")));
m_ui->m_actionMessageFilters->setIcon(icon_theme_factory->fromTheme(QSL("view-list-details")));
// Tabs & web browser.
m_ui->m_actionTabNewWebBrowser->setIcon(icon_theme_factory->fromTheme(QSL("tab-new")));
@ -753,6 +755,8 @@ void FormMain::createConnections() {
tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), &FeedsModel::restoreAllBins);
connect(m_ui->m_actionEmptyAllRecycleBins, &QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), &FeedsModel::emptyAllBins);
connect(m_ui->m_actionMessageFilters, &QAction::triggered,
qApp->feedReader(), &FeedReader::showMessageFiltersManager);
}
void FormMain::backupDatabaseSettings() {

View File

@ -2,6 +2,21 @@
#include "gui/dialogs/formmessagefiltersmanager.h"
FormMessageFiltersManager::FormMessageFiltersManager(QWidget *parent) : QDialog(parent) {
#include "gui/guiutilities.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "network-web/webfactory.h"
FormMessageFiltersManager::FormMessageFiltersManager(QWidget* parent) : QDialog(parent) {
m_ui.setupUi(this);
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("view-list-details")));
m_ui.m_btnAddNew->setIcon(qApp->icons()->fromTheme(QSL("list-add")));
m_ui.m_btnRemoveSelected->setIcon(qApp->icons()->fromTheme(QSL("list-remove")));
m_ui.m_txtScript->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont));
connect(m_ui.m_btnDetailedHelp, &QPushButton::clicked, this, []() {
qApp->web()->openUrlInExternalBrowser(MSG_FILTERING_HELP);
});
}

View File

@ -1,42 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>FormMessageFiltersManager</class>
<widget class="QDialog" name="FormMessageFiltersManager">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>737</width>
<height>592</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Message filters</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QTreeView" name="m_treeFeeds"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Message filter details</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Title</string>
</property>
<property name="buddy">
<cstring>m_txtTitle</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="m_txtTitle">
<property name="placeholderText">
<string>Title of message filter</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>JavaScript code</string>
</property>
<property name="buddy">
<cstring>m_txtScript</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Errors</string>
</property>
<property name="buddy">
<cstring>m_txtErrors</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="m_txtErrors">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="m_btnDetailedHelp">
<property name="text">
<string>&amp;Detailed help</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="m_txtScript">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Your JavaScript-based message filtering logic</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QTreeView" name="m_treeFilters"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="m_btnRemoveSelected">
<property name="text">
<string>Remove selected</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="m_btnAddNew">
<property name="text">
<string>Add new</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction/>
<tabstops>
<tabstop>m_treeFilters</tabstop>
<tabstop>m_treeFeeds</tabstop>
<tabstop>m_btnAddNew</tabstop>
<tabstop>m_btnRemoveSelected</tabstop>
<tabstop>m_txtTitle</tabstop>
<tabstop>m_txtScript</tabstop>
<tabstop>m_txtErrors</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<sender>m_buttonBox</sender>
<signal>accepted()</signal>
<receiver>FormMessageFiltersManager</receiver>
<slot>accept()</slot>
@ -52,7 +216,7 @@
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<sender>m_buttonBox</sender>
<signal>rejected()</signal>
<receiver>FormMessageFiltersManager</receiver>
<slot>reject()</slot>

View File

@ -59,7 +59,7 @@ QString TimeSpinBox::textFromValue(double val) const {
int seconds_val = int(val);
int minutes_total = seconds_val / 60;
int seconds_total = seconds_val - (minutes_total * 60);
QString seconds = tr("%n seconds(s)", "", seconds_total);
QString seconds = tr("%n second(s)", "", seconds_total);
QString minutes = tr("%n minute(s)", "", minutes_total);
return minutes + tr(" and ") + seconds;