diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml
index e3513577a..5c511a7be 100644
--- a/resources/desktop/com.github.rssguard.appdata.xml
+++ b/resources/desktop/com.github.rssguard.appdata.xml
@@ -30,7 +30,7 @@
https://martinrotter.github.io/donate/
-
+
none
diff --git a/resources/rssguard.qrc b/resources/rssguard.qrc
index b0ba56fda..9632c12dc 100755
--- a/resources/rssguard.qrc
+++ b/resources/rssguard.qrc
@@ -7,7 +7,6 @@
text/COPYING_GNU_GPL_HTML
sounds/boing.wav
- sounds/doorbell.wav
sounds/rooster.wav
sounds/sheep.wav
diff --git a/resources/sounds/doorbell.wav b/resources/sounds/doorbell.wav
deleted file mode 100755
index ec05baa00..000000000
Binary files a/resources/sounds/doorbell.wav and /dev/null differ
diff --git a/src/librssguard/gui/notifications/notificationseditor.cpp b/src/librssguard/gui/notifications/notificationseditor.cpp
index 5bb9a45de..a5d16252d 100755
--- a/src/librssguard/gui/notifications/notificationseditor.cpp
+++ b/src/librssguard/gui/notifications/notificationseditor.cpp
@@ -3,6 +3,7 @@
#include "gui/notifications/notificationseditor.h"
#include "3rd-party/boolinq/boolinq.h"
+#include "definitions/definitions.h"
#include "gui/notifications/singlenotificationeditor.h"
#include
@@ -24,14 +25,15 @@ void NotificationsEditor::loadNotifications(const QList& notificat
return n.event() == ev;
}), this);
- notif_editor->setNotificationEnabled(true);
+ connect(notif_editor, &SingleNotificationEditor::notificationChanged, this, &NotificationsEditor::someNotificationChanged);
m_layout->addWidget(notif_editor);
}
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);
}
@@ -39,3 +41,11 @@ void NotificationsEditor::loadNotifications(const QList& notificat
m_layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
+
+QList NotificationsEditor::allNotifications() const {
+ auto lst = boolinq::from(findChildren()).select([](const SingleNotificationEditor* ed) {
+ return ed->notification();
+ }).toStdList();
+
+ return FROM_STD_LIST(QList, lst);
+}
diff --git a/src/librssguard/gui/notifications/notificationseditor.h b/src/librssguard/gui/notifications/notificationseditor.h
index df7d66561..04f6a2db3 100755
--- a/src/librssguard/gui/notifications/notificationseditor.h
+++ b/src/librssguard/gui/notifications/notificationseditor.h
@@ -19,6 +19,11 @@ class NotificationsEditor : public QScrollArea {
void loadNotifications(const QList& notifications);
+ QList allNotifications() const;
+
+ signals:
+ void someNotificationChanged();
+
private:
Ui::NotificationsEditor m_ui;
QVBoxLayout* m_layout;
diff --git a/src/librssguard/gui/notifications/singlenotificationeditor.cpp b/src/librssguard/gui/notifications/singlenotificationeditor.cpp
index 934fdd236..199784c32 100755
--- a/src/librssguard/gui/notifications/singlenotificationeditor.cpp
+++ b/src/librssguard/gui/notifications/singlenotificationeditor.cpp
@@ -6,35 +6,30 @@
#include "miscellaneous/iconfactory.h"
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.m_btnBrowseSound->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
m_ui.m_btnPlaySound->setIcon(qApp->icons()->fromTheme(QSL("media-playback-start")));
- connect(m_ui.m_btnPlaySound, &QPushButton::clicked, this, &SingleNotificationEditor::playSound);
-
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 {
- return Notification(m_notificationEvent, 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);
+ return Notification(m_notificationEvent, m_ui.m_cbBalloon->isChecked(), m_ui.m_txtSound->text());
}
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) {
m_ui.m_txtSound->setText(notification.soundPath());
+ m_ui.m_cbBalloon->setChecked(notification.balloonEnabled());
m_ui.m_gbNotification->setTitle(Notification::nameForEvent(notification.event()));
m_notificationEvent = notification.event();
diff --git a/src/librssguard/gui/notifications/singlenotificationeditor.h b/src/librssguard/gui/notifications/singlenotificationeditor.h
index bf9d1020f..e3c69cc1a 100755
--- a/src/librssguard/gui/notifications/singlenotificationeditor.h
+++ b/src/librssguard/gui/notifications/singlenotificationeditor.h
@@ -17,8 +17,8 @@ class SingleNotificationEditor : public QWidget {
Notification notification() const;
- bool notificationEnabled() const;
- void setNotificationEnabled(bool enabled);
+ signals:
+ void notificationChanged();
private slots:
void playSound();
diff --git a/src/librssguard/gui/notifications/singlenotificationeditor.ui b/src/librssguard/gui/notifications/singlenotificationeditor.ui
index e04d22d0e..af4d85ade 100755
--- a/src/librssguard/gui/notifications/singlenotificationeditor.ui
+++ b/src/librssguard/gui/notifications/singlenotificationeditor.ui
@@ -40,18 +40,18 @@
0
-
- true
-
- -
+
-
Sound
+
+ m_txtSound
+
- -
+
-
-
@@ -76,11 +76,24 @@
+ -
+
+
+ Balloon notification
+
+
+
+
+ m_cbBalloon
+ m_txtSound
+ m_btnBrowseSound
+ m_btnPlaySound
+
diff --git a/src/librssguard/gui/settings/settingsgui.ui b/src/librssguard/gui/settings/settingsgui.ui
index e895d0966..244b21b9a 100644
--- a/src/librssguard/gui/settings/settingsgui.ui
+++ b/src/librssguard/gui/settings/settingsgui.ui
@@ -116,7 +116,7 @@
- Tray area && notifications
+ Tray area
-
diff --git a/src/librssguard/gui/settings/settingsnotifications.cpp b/src/librssguard/gui/settings/settingsnotifications.cpp
index 3416f8cb2..64b432919 100755
--- a/src/librssguard/gui/settings/settingsnotifications.cpp
+++ b/src/librssguard/gui/settings/settingsnotifications.cpp
@@ -15,8 +15,10 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
m_ui.setupUi(this);
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_editor, &NotificationsEditor::someNotificationChanged, this, &SettingsNotifications::dirtifySettings);
}
void SettingsNotifications::loadSettings() {
@@ -43,6 +45,7 @@ void SettingsNotifications::saveSettings() {
// Save notifications.
settings()->setValue(GROUP(Notifications), Notifications::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked());
+ qApp->notifications()->save(m_ui.m_editor->allNotifications(), settings());
onEndSaveSettings();
}
diff --git a/src/librssguard/gui/settings/settingsnotifications.ui b/src/librssguard/gui/settings/settingsnotifications.ui
index 5a193102e..a8894275e 100755
--- a/src/librssguard/gui/settings/settingsnotifications.ui
+++ b/src/librssguard/gui/settings/settingsnotifications.ui
@@ -26,14 +26,14 @@
0
-
-
+
-
Enable notifications
- -
+
-
false
@@ -46,9 +46,16 @@
- -
+
-
+ -
+
+
+ You must have "tray icon" activated to have notifications working.
+
+
+
diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp
index 724cd4055..e93e956ed 100755
--- a/src/librssguard/miscellaneous/application.cpp
+++ b/src/librssguard/miscellaneous/application.cpp
@@ -90,6 +90,7 @@ Application::Application(const QString& id, int& argc, char** argv)
if (isFirstRun()) {
m_notifications->save({
Notification(Notification::Event::NewArticlesFetched,
+ true,
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY))
}, settings());
}
diff --git a/src/librssguard/miscellaneous/notification.cpp b/src/librssguard/miscellaneous/notification.cpp
index b9a80877b..37d1a1d59 100755
--- a/src/librssguard/miscellaneous/notification.cpp
+++ b/src/librssguard/miscellaneous/notification.cpp
@@ -7,9 +7,8 @@
#include
#include
-Notification::Notification() {}
-
-Notification::Notification(Notification::Event event, const QString& sound_path) : m_event(event), m_soundPath(sound_path) {}
+Notification::Notification(Notification::Event event, bool balloon, const QString& sound_path)
+ : m_event(event), m_balloonEnabled(balloon), m_soundPath(sound_path) {}
Notification::Event Notification::event() const {
return m_event;
@@ -54,3 +53,8 @@ QString Notification::nameForEvent(Notification::Event event) {
return QObject::tr("Unknown event");
}
}
+
+bool Notification::balloonEnabled() const
+{
+ return m_balloonEnabled;
+}
diff --git a/src/librssguard/miscellaneous/notification.h b/src/librssguard/miscellaneous/notification.h
index 51c46972d..6a5c73b34 100755
--- a/src/librssguard/miscellaneous/notification.h
+++ b/src/librssguard/miscellaneous/notification.h
@@ -10,7 +10,9 @@ class Application;
class Notification {
public:
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.
NewArticlesFetched = 1,
@@ -26,8 +28,9 @@ class Notification {
// TODO: app update is available
};
- explicit Notification();
- explicit Notification(Event event, const QString& sound_path);
+ explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {});
+
+ bool balloonEnabled() const;
Event event() const;
void setEvent(const Event& event);
@@ -45,6 +48,7 @@ class Notification {
private:
Event m_event;
+ bool m_balloonEnabled;
QString m_soundPath;
};
diff --git a/src/librssguard/miscellaneous/notificationfactory.cpp b/src/librssguard/miscellaneous/notificationfactory.cpp
index 54c1171b8..c311db968 100755
--- a/src/librssguard/miscellaneous/notificationfactory.cpp
+++ b/src/librssguard/miscellaneous/notificationfactory.cpp
@@ -5,6 +5,7 @@
#include "3rd-party/boolinq/boolinq.h"
#include "definitions/definitions.h"
#include "exceptions/applicationexception.h"
+#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include
@@ -16,12 +17,21 @@ QList NotificationFactory::allNotifications() 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) {
return n.event() == event;
});
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 {
return good_n.first();
@@ -35,9 +45,11 @@ void NotificationFactory::load(Settings* settings) {
for (const auto& key : notif_keys) {
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& new_notifications, Set
m_notifications = new_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()
+ });
}
}