save
This commit is contained in:
parent
5e4ae7657b
commit
48469bb635
@ -30,7 +30,7 @@
|
|||||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="3.9.2" date="2021-06-15"/>
|
<release version="3.9.2" date="2021-06-17"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<file>text/COPYING_GNU_GPL_HTML</file>
|
<file>text/COPYING_GNU_GPL_HTML</file>
|
||||||
|
|
||||||
<file>sounds/boing.wav</file>
|
<file>sounds/boing.wav</file>
|
||||||
<file>sounds/doorbell.wav</file>
|
|
||||||
<file>sounds/rooster.wav</file>
|
<file>sounds/rooster.wav</file>
|
||||||
<file>sounds/sheep.wav</file>
|
<file>sounds/sheep.wav</file>
|
||||||
|
|
||||||
|
Binary file not shown.
@ -3,6 +3,7 @@
|
|||||||
#include "gui/notifications/notificationseditor.h"
|
#include "gui/notifications/notificationseditor.h"
|
||||||
|
|
||||||
#include "3rd-party/boolinq/boolinq.h"
|
#include "3rd-party/boolinq/boolinq.h"
|
||||||
|
#include "definitions/definitions.h"
|
||||||
#include "gui/notifications/singlenotificationeditor.h"
|
#include "gui/notifications/singlenotificationeditor.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@ -24,14 +25,15 @@ void NotificationsEditor::loadNotifications(const QList<Notification>& notificat
|
|||||||
return n.event() == ev;
|
return n.event() == ev;
|
||||||
}), this);
|
}), this);
|
||||||
|
|
||||||
notif_editor->setNotificationEnabled(true);
|
connect(notif_editor, &SingleNotificationEditor::notificationChanged, this, &NotificationsEditor::someNotificationChanged);
|
||||||
|
|
||||||
m_layout->addWidget(notif_editor);
|
m_layout->addWidget(notif_editor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto* notif_editor = new SingleNotificationEditor(Notification(ev, {}), this);
|
auto* notif_editor = new SingleNotificationEditor(Notification(ev), this);
|
||||||
|
|
||||||
|
connect(notif_editor, &SingleNotificationEditor::notificationChanged, this, &NotificationsEditor::someNotificationChanged);
|
||||||
|
|
||||||
notif_editor->setNotificationEnabled(false);
|
|
||||||
m_layout->addWidget(notif_editor);
|
m_layout->addWidget(notif_editor);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -39,3 +41,11 @@ void NotificationsEditor::loadNotifications(const QList<Notification>& notificat
|
|||||||
|
|
||||||
m_layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
m_layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Notification> NotificationsEditor::allNotifications() const {
|
||||||
|
auto lst = boolinq::from(findChildren<SingleNotificationEditor*>()).select([](const SingleNotificationEditor* ed) {
|
||||||
|
return ed->notification();
|
||||||
|
}).toStdList();
|
||||||
|
|
||||||
|
return FROM_STD_LIST(QList<Notification>, lst);
|
||||||
|
}
|
||||||
|
@ -19,6 +19,11 @@ class NotificationsEditor : public QScrollArea {
|
|||||||
|
|
||||||
void loadNotifications(const QList<Notification>& notifications);
|
void loadNotifications(const QList<Notification>& notifications);
|
||||||
|
|
||||||
|
QList<Notification> allNotifications() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void someNotificationChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NotificationsEditor m_ui;
|
Ui::NotificationsEditor m_ui;
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
|
@ -6,35 +6,30 @@
|
|||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
|
||||||
SingleNotificationEditor::SingleNotificationEditor(const Notification& notification, QWidget* parent)
|
SingleNotificationEditor::SingleNotificationEditor(const Notification& notification, QWidget* parent)
|
||||||
: QWidget(parent), m_notificationEvent(Notification::Event::UnknownEvent) {
|
: QWidget(parent), m_notificationEvent(Notification::Event::NoEvent) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_ui.m_btnBrowseSound->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
|
m_ui.m_btnBrowseSound->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
|
||||||
m_ui.m_btnPlaySound->setIcon(qApp->icons()->fromTheme(QSL("media-playback-start")));
|
m_ui.m_btnPlaySound->setIcon(qApp->icons()->fromTheme(QSL("media-playback-start")));
|
||||||
|
|
||||||
connect(m_ui.m_btnPlaySound, &QPushButton::clicked, this, &SingleNotificationEditor::playSound);
|
|
||||||
|
|
||||||
loadNotification(notification);
|
loadNotification(notification);
|
||||||
|
|
||||||
|
connect(m_ui.m_btnPlaySound, &QPushButton::clicked, this, &SingleNotificationEditor::playSound);
|
||||||
|
connect(m_ui.m_txtSound, &QLineEdit::textChanged, this, &SingleNotificationEditor::notificationChanged);
|
||||||
|
connect(m_ui.m_cbBalloon, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification SingleNotificationEditor::notification() const {
|
Notification SingleNotificationEditor::notification() const {
|
||||||
return Notification(m_notificationEvent, m_ui.m_txtSound->text());
|
return Notification(m_notificationEvent, m_ui.m_cbBalloon->isChecked(), m_ui.m_txtSound->text());
|
||||||
}
|
|
||||||
|
|
||||||
bool SingleNotificationEditor::notificationEnabled() const {
|
|
||||||
return m_ui.m_gbNotification->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SingleNotificationEditor::setNotificationEnabled(bool enabled) {
|
|
||||||
m_ui.m_gbNotification->setChecked(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleNotificationEditor::playSound() {
|
void SingleNotificationEditor::playSound() {
|
||||||
Notification({}, m_ui.m_txtSound->text()).playSound(qApp);
|
Notification({}, {}, m_ui.m_txtSound->text()).playSound(qApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleNotificationEditor::loadNotification(const Notification& notification) {
|
void SingleNotificationEditor::loadNotification(const Notification& notification) {
|
||||||
m_ui.m_txtSound->setText(notification.soundPath());
|
m_ui.m_txtSound->setText(notification.soundPath());
|
||||||
|
m_ui.m_cbBalloon->setChecked(notification.balloonEnabled());
|
||||||
m_ui.m_gbNotification->setTitle(Notification::nameForEvent(notification.event()));
|
m_ui.m_gbNotification->setTitle(Notification::nameForEvent(notification.event()));
|
||||||
|
|
||||||
m_notificationEvent = notification.event();
|
m_notificationEvent = notification.event();
|
||||||
|
@ -17,8 +17,8 @@ class SingleNotificationEditor : public QWidget {
|
|||||||
|
|
||||||
Notification notification() const;
|
Notification notification() const;
|
||||||
|
|
||||||
bool notificationEnabled() const;
|
signals:
|
||||||
void setNotificationEnabled(bool enabled);
|
void notificationChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void playSound();
|
void playSound();
|
||||||
|
@ -40,18 +40,18 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Sound</string>
|
<string>Sound</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtSound</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="m_txtSound">
|
<widget class="QLineEdit" name="m_txtSound">
|
||||||
@ -76,11 +76,24 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_cbBalloon">
|
||||||
|
<property name="text">
|
||||||
|
<string>Balloon notification</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_cbBalloon</tabstop>
|
||||||
|
<tabstop>m_txtSound</tabstop>
|
||||||
|
<tabstop>m_btnBrowseSound</tabstop>
|
||||||
|
<tabstop>m_btnPlaySound</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -116,7 +116,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="m_tabNotifications">
|
<widget class="QWidget" name="m_tabNotifications">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Tray area && notifications</string>
|
<string>Tray area</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QFormLayout" name="formLayout_3">
|
<layout class="QFormLayout" name="formLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -15,8 +15,10 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
|
|||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
GuiUtilities::setLabelAsNotice(*m_ui.m_lblAvailableSounds, false);
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblAvailableSounds, false);
|
||||||
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
|
||||||
|
|
||||||
connect(m_ui.m_checkEnableNotifications, &QCheckBox::toggled, this, &SettingsNotifications::dirtifySettings);
|
connect(m_ui.m_checkEnableNotifications, &QCheckBox::toggled, this, &SettingsNotifications::dirtifySettings);
|
||||||
|
connect(m_ui.m_editor, &NotificationsEditor::someNotificationChanged, this, &SettingsNotifications::dirtifySettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsNotifications::loadSettings() {
|
void SettingsNotifications::loadSettings() {
|
||||||
@ -43,6 +45,7 @@ void SettingsNotifications::saveSettings() {
|
|||||||
|
|
||||||
// Save notifications.
|
// Save notifications.
|
||||||
settings()->setValue(GROUP(Notifications), Notifications::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked());
|
settings()->setValue(GROUP(Notifications), Notifications::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked());
|
||||||
|
qApp->notifications()->save(m_ui.m_editor->allNotifications(), settings());
|
||||||
|
|
||||||
onEndSaveSettings();
|
onEndSaveSettings();
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="m_checkEnableNotifications">
|
<widget class="QCheckBox" name="m_checkEnableNotifications">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable notifications</string>
|
<string>Enable notifications</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="NotificationsEditor" name="m_editor" native="true">
|
<widget class="NotificationsEditor" name="m_editor" native="true">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -46,9 +46,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="m_lblAvailableSounds"/>
|
<widget class="QLabel" name="m_lblAvailableSounds"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="m_lblInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string>You must have "tray icon" activated to have notifications working.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -90,6 +90,7 @@ Application::Application(const QString& id, int& argc, char** argv)
|
|||||||
if (isFirstRun()) {
|
if (isFirstRun()) {
|
||||||
m_notifications->save({
|
m_notifications->save({
|
||||||
Notification(Notification::Event::NewArticlesFetched,
|
Notification(Notification::Event::NewArticlesFetched,
|
||||||
|
true,
|
||||||
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY))
|
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY))
|
||||||
}, settings());
|
}, settings());
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,8 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSound>
|
#include <QSound>
|
||||||
|
|
||||||
Notification::Notification() {}
|
Notification::Notification(Notification::Event event, bool balloon, const QString& sound_path)
|
||||||
|
: m_event(event), m_balloonEnabled(balloon), m_soundPath(sound_path) {}
|
||||||
Notification::Notification(Notification::Event event, const QString& sound_path) : m_event(event), m_soundPath(sound_path) {}
|
|
||||||
|
|
||||||
Notification::Event Notification::event() const {
|
Notification::Event Notification::event() const {
|
||||||
return m_event;
|
return m_event;
|
||||||
@ -54,3 +53,8 @@ QString Notification::nameForEvent(Notification::Event event) {
|
|||||||
return QObject::tr("Unknown event");
|
return QObject::tr("Unknown event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notification::balloonEnabled() const
|
||||||
|
{
|
||||||
|
return m_balloonEnabled;
|
||||||
|
}
|
||||||
|
@ -10,7 +10,9 @@ class Application;
|
|||||||
class Notification {
|
class Notification {
|
||||||
public:
|
public:
|
||||||
enum class Event {
|
enum class Event {
|
||||||
UnknownEvent = 0,
|
// Is here to provide "empty" events - events which should
|
||||||
|
// not trigger any notifications.
|
||||||
|
NoEvent = 0,
|
||||||
|
|
||||||
// New (unread) messages were downloaded for some feed.
|
// New (unread) messages were downloaded for some feed.
|
||||||
NewArticlesFetched = 1,
|
NewArticlesFetched = 1,
|
||||||
@ -26,8 +28,9 @@ class Notification {
|
|||||||
// TODO: app update is available
|
// TODO: app update is available
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Notification();
|
explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {});
|
||||||
explicit Notification(Event event, const QString& sound_path);
|
|
||||||
|
bool balloonEnabled() const;
|
||||||
|
|
||||||
Event event() const;
|
Event event() const;
|
||||||
void setEvent(const Event& event);
|
void setEvent(const Event& event);
|
||||||
@ -45,6 +48,7 @@ class Notification {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Event m_event;
|
Event m_event;
|
||||||
|
bool m_balloonEnabled;
|
||||||
QString m_soundPath;
|
QString m_soundPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "3rd-party/boolinq/boolinq.h"
|
#include "3rd-party/boolinq/boolinq.h"
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "exceptions/applicationexception.h"
|
#include "exceptions/applicationexception.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@ -16,12 +17,21 @@ QList<Notification> NotificationFactory::allNotifications() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Notification NotificationFactory::notificationForEvent(Notification::Event event) const {
|
Notification NotificationFactory::notificationForEvent(Notification::Event event) const {
|
||||||
|
if (!qApp->settings()->value(GROUP(Notifications), SETTING(Notifications::EnableNotifications)).toBool()) {
|
||||||
|
return Notification();
|
||||||
|
}
|
||||||
|
|
||||||
auto good_n = boolinq::from(m_notifications).where([event](const Notification& n) {
|
auto good_n = boolinq::from(m_notifications).where([event](const Notification& n) {
|
||||||
return n.event() == event;
|
return n.event() == event;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (good_n.count() <= 0) {
|
if (good_n.count() <= 0) {
|
||||||
throw ApplicationException(QSL("notification for event %1 was not found").arg(QString::number(int(event))));
|
qCriticalNN << LOGSEC_CORE
|
||||||
|
<< "Notification for event"
|
||||||
|
<< QUOTE_W_SPACE(int(event))
|
||||||
|
<< "not found";
|
||||||
|
|
||||||
|
return Notification();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return good_n.first();
|
return good_n.first();
|
||||||
@ -35,9 +45,11 @@ void NotificationFactory::load(Settings* settings) {
|
|||||||
|
|
||||||
for (const auto& key : notif_keys) {
|
for (const auto& key : notif_keys) {
|
||||||
auto event = Notification::Event(key.toInt());
|
auto event = Notification::Event(key.toInt());
|
||||||
auto sound = settings->value(GROUP(Notifications), key).toString();
|
auto data = settings->value(GROUP(Notifications), key).toStringList();
|
||||||
|
auto enabled = data.at(0).toInt() != 0;
|
||||||
|
auto sound = data.at(1);
|
||||||
|
|
||||||
m_notifications.append(Notification(event, sound));
|
m_notifications.append(Notification(event, enabled, sound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +58,9 @@ void NotificationFactory::save(const QList<Notification>& new_notifications, Set
|
|||||||
m_notifications = new_notifications;
|
m_notifications = new_notifications;
|
||||||
|
|
||||||
for (const auto& n : qAsConst(m_notifications)) {
|
for (const auto& n : qAsConst(m_notifications)) {
|
||||||
settings->setValue(GROUP(Notifications), QString::number(int(n.event())), n.soundPath());
|
settings->setValue(GROUP(Notifications), QString::number(int(n.event())), QStringList {
|
||||||
|
n.balloonEnabled() ? QSL("1") : QSL("0"),
|
||||||
|
n.soundPath()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user