allow finetuning of showing of dialogs depending on notification/event type
This commit is contained in:
parent
9ae52dcc14
commit
83fed6b7cd
7 changed files with 35 additions and 8 deletions
|
@ -488,7 +488,7 @@ void FeedDownloader::finalizeUpdate() {
|
||||||
|
|
||||||
if (!m_results.erroredFeeds().isEmpty()) {
|
if (!m_results.erroredFeeds().isEmpty()) {
|
||||||
qApp->showGuiMessage(Notification::Event::ArticlesFetchingError,
|
qApp->showGuiMessage(Notification::Event::ArticlesFetchingError,
|
||||||
{QObject::tr("Some feed have error"),
|
{QObject::tr("Some feeds have error"),
|
||||||
QObject::tr("Some feeds threw an error when fetching articles."),
|
QObject::tr("Some feeds threw an error when fetching articles."),
|
||||||
QSystemTrayIcon::MessageIcon::Critical});
|
QSystemTrayIcon::MessageIcon::Critical});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ SingleNotificationEditor::SingleNotificationEditor(const Notification& notificat
|
||||||
connect(m_ui.m_btnBrowseSound, &QPushButton::clicked, this, &SingleNotificationEditor::selectSoundFile);
|
connect(m_ui.m_btnBrowseSound, &QPushButton::clicked, this, &SingleNotificationEditor::selectSoundFile);
|
||||||
connect(m_ui.m_txtSound, &QLineEdit::textChanged, this, &SingleNotificationEditor::notificationChanged);
|
connect(m_ui.m_txtSound, &QLineEdit::textChanged, this, &SingleNotificationEditor::notificationChanged);
|
||||||
connect(m_ui.m_cbBalloon, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
connect(m_ui.m_cbBalloon, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
||||||
|
connect(m_ui.m_cbDialogs, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
||||||
connect(m_ui.m_cbPlaySound, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
connect(m_ui.m_cbPlaySound, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
||||||
connect(m_ui.m_slidVolume, &QSlider::valueChanged, this, &SingleNotificationEditor::notificationChanged);
|
connect(m_ui.m_slidVolume, &QSlider::valueChanged, this, &SingleNotificationEditor::notificationChanged);
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ SingleNotificationEditor::SingleNotificationEditor(const Notification& notificat
|
||||||
Notification SingleNotificationEditor::notification() const {
|
Notification SingleNotificationEditor::notification() const {
|
||||||
return Notification(m_notificationEvent,
|
return Notification(m_notificationEvent,
|
||||||
m_ui.m_cbBalloon->isChecked(),
|
m_ui.m_cbBalloon->isChecked(),
|
||||||
|
m_ui.m_cbDialogs->isChecked(),
|
||||||
m_ui.m_cbPlaySound->isChecked(),
|
m_ui.m_cbPlaySound->isChecked(),
|
||||||
m_ui.m_txtSound->text(),
|
m_ui.m_txtSound->text(),
|
||||||
m_ui.m_slidVolume->value());
|
m_ui.m_slidVolume->value());
|
||||||
|
@ -64,6 +66,7 @@ void SingleNotificationEditor::loadNotification(const Notification& notification
|
||||||
m_ui.m_txtSound->setText(notification.soundPath());
|
m_ui.m_txtSound->setText(notification.soundPath());
|
||||||
m_ui.m_slidVolume->setValue(notification.volume());
|
m_ui.m_slidVolume->setValue(notification.volume());
|
||||||
m_ui.m_cbBalloon->setChecked(notification.balloonEnabled());
|
m_ui.m_cbBalloon->setChecked(notification.balloonEnabled());
|
||||||
|
m_ui.m_cbDialogs->setChecked(notification.dialogEnabled());
|
||||||
m_ui.m_cbPlaySound->setChecked(notification.soundEnabled());
|
m_ui.m_cbPlaySound->setChecked(notification.soundEnabled());
|
||||||
m_notificationEvent = notification.event();
|
m_notificationEvent = notification.event();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>423</width>
|
<width>423</width>
|
||||||
<height>128</height>
|
<height>152</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -24,6 +24,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_cbDialogs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="m_cbPlaySound">
|
<widget class="QCheckBox" name="m_cbPlaySound">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -121,6 +128,7 @@
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>m_cbBalloon</tabstop>
|
<tabstop>m_cbBalloon</tabstop>
|
||||||
|
<tabstop>m_cbDialogs</tabstop>
|
||||||
<tabstop>m_cbPlaySound</tabstop>
|
<tabstop>m_cbPlaySound</tabstop>
|
||||||
<tabstop>m_txtSound</tabstop>
|
<tabstop>m_txtSound</tabstop>
|
||||||
<tabstop>m_btnBrowseSound</tabstop>
|
<tabstop>m_btnBrowseSound</tabstop>
|
||||||
|
|
|
@ -272,6 +272,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
|
||||||
m_notifications->save({Notification(Notification::Event::GeneralEvent, true),
|
m_notifications->save({Notification(Notification::Event::GeneralEvent, true),
|
||||||
Notification(Notification::Event::NewUnreadArticlesFetched,
|
Notification(Notification::Event::NewUnreadArticlesFetched,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
true,
|
true,
|
||||||
QSL("%1/notify.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
|
QSL("%1/notify.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
|
||||||
Notification(Notification::Event::NewAppVersionAvailable, true),
|
Notification(Notification::Event::NewAppVersionAvailable, true),
|
||||||
|
@ -773,9 +774,13 @@ void Application::showGuiMessageCore(Notification::Event event,
|
||||||
GuiMessageDestination dest,
|
GuiMessageDestination dest,
|
||||||
const GuiAction& action,
|
const GuiAction& action,
|
||||||
QWidget* parent) {
|
QWidget* parent) {
|
||||||
|
bool show_dialog = true;
|
||||||
|
|
||||||
if (m_notifications->areNotificationsEnabled()) {
|
if (m_notifications->areNotificationsEnabled()) {
|
||||||
auto notification = m_notifications->notificationForEvent(event);
|
auto notification = m_notifications->notificationForEvent(event);
|
||||||
|
|
||||||
|
show_dialog = notification.dialogEnabled();
|
||||||
|
|
||||||
if (notification.soundEnabled()) {
|
if (notification.soundEnabled()) {
|
||||||
notification.playSound(this);
|
notification.playSound(this);
|
||||||
}
|
}
|
||||||
|
@ -807,7 +812,7 @@ void Application::showGuiMessageCore(Notification::Event event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.m_messageBox || msg.m_type == QSystemTrayIcon::MessageIcon::Critical) {
|
if (show_dialog && (dest.m_messageBox || msg.m_type == QSystemTrayIcon::MessageIcon::Critical)) {
|
||||||
// Tray icon or OSD is not available, display simple text box.
|
// Tray icon or OSD is not available, display simple text box.
|
||||||
MsgBox::show(parent == nullptr ? mainFormWidget() : parent,
|
MsgBox::show(parent == nullptr ? mainFormWidget() : parent,
|
||||||
QMessageBox::Icon(msg.m_type),
|
QMessageBox::Icon(msg.m_type),
|
||||||
|
|
|
@ -17,10 +17,12 @@
|
||||||
|
|
||||||
Notification::Notification(Notification::Event event,
|
Notification::Notification(Notification::Event event,
|
||||||
bool balloon,
|
bool balloon,
|
||||||
|
bool dialog,
|
||||||
bool play_sound,
|
bool play_sound,
|
||||||
const QString& sound_path,
|
const QString& sound_path,
|
||||||
int volume)
|
int volume)
|
||||||
: m_event(event), m_balloonEnabled(balloon), m_soundEnabled(play_sound), m_soundPath(sound_path), m_volume(volume) {}
|
: m_event(event), m_balloonEnabled(balloon), m_dialogEnabled(dialog), m_soundEnabled(play_sound),
|
||||||
|
m_soundPath(sound_path), m_volume(volume) {}
|
||||||
|
|
||||||
Notification::Event Notification::event() const {
|
Notification::Event Notification::event() const {
|
||||||
return m_event;
|
return m_event;
|
||||||
|
@ -161,6 +163,10 @@ QString Notification::nameForEvent(Notification::Event event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notification::dialogEnabled() const {
|
||||||
|
return m_dialogEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
void Notification::setSoundEnabled(bool play_sound) {
|
void Notification::setSoundEnabled(bool play_sound) {
|
||||||
m_soundEnabled = play_sound;
|
m_soundEnabled = play_sound;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,14 @@ class Notification {
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Notification(Event event = Event::NoEvent,
|
explicit Notification(Event event = Event::NoEvent,
|
||||||
bool balloon = {},
|
bool balloon = false,
|
||||||
|
bool dialog = true,
|
||||||
bool play_sound = true,
|
bool play_sound = true,
|
||||||
const QString& sound_path = {},
|
const QString& sound_path = {},
|
||||||
int volume = DEFAULT_NOTIFICATION_VOLUME);
|
int volume = DEFAULT_NOTIFICATION_VOLUME);
|
||||||
|
|
||||||
bool balloonEnabled() const;
|
bool balloonEnabled() const;
|
||||||
|
bool dialogEnabled() const;
|
||||||
|
|
||||||
Event event() const;
|
Event event() const;
|
||||||
void setEvent(Event event);
|
void setEvent(Event event);
|
||||||
|
@ -78,6 +80,7 @@ class Notification {
|
||||||
private:
|
private:
|
||||||
Event m_event;
|
Event m_event;
|
||||||
bool m_balloonEnabled;
|
bool m_balloonEnabled;
|
||||||
|
bool m_dialogEnabled;
|
||||||
bool m_soundEnabled;
|
bool m_soundEnabled;
|
||||||
QString m_soundPath;
|
QString m_soundPath;
|
||||||
qreal m_volume;
|
qreal m_volume;
|
||||||
|
|
|
@ -50,12 +50,13 @@ 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 data = settings->value(GROUP(Notifications), key).toStringList();
|
auto data = settings->value(GROUP(Notifications), key).toStringList();
|
||||||
auto enabled = data.at(0).toInt() != 0;
|
auto balloon = data.at(0).toInt() != 0;
|
||||||
auto sound_path = data.at(1);
|
auto sound_path = data.at(1);
|
||||||
auto volume = data.size() > 2 ? data.at(2).toInt() : DEFAULT_NOTIFICATION_VOLUME;
|
auto volume = data.size() > 2 ? data.at(2).toInt() : DEFAULT_NOTIFICATION_VOLUME;
|
||||||
auto play_sound = data.size() > 3 ? data.at(3).toInt() != 0 : true;
|
auto play_sound = data.size() > 3 ? data.at(3).toInt() != 0 : true;
|
||||||
|
auto dialog = data.size() > 4 ? data.at(4).toInt() != 0 : false;
|
||||||
|
|
||||||
m_notifications.append(Notification(event, enabled, play_sound, sound_path, volume));
|
m_notifications.append(Notification(event, balloon, dialog, play_sound, sound_path, volume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ void NotificationFactory::save(const QList<Notification>& new_notifications, Set
|
||||||
QStringList{n.balloonEnabled() ? QSL("1") : QSL("0"),
|
QStringList{n.balloonEnabled() ? QSL("1") : QSL("0"),
|
||||||
n.soundPath(),
|
n.soundPath(),
|
||||||
QString::number(n.volume()),
|
QString::number(n.volume()),
|
||||||
n.soundEnabled() ? QSL("1") : QSL("0")});
|
n.soundEnabled() ? QSL("1") : QSL("0"),
|
||||||
|
n.dialogEnabled() ? QSL("1") : QSL("0")});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue