From 5f10acb331e9c5b7c68ed1fc5e2a39fc536ed848 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 13 Feb 2023 13:15:01 +0100 Subject: [PATCH 1/6] Add checkbox to disable general talk notifications in general settings Signed-off-by: Claudio Cambra --- src/gui/generalsettings.ui | 251 ++++++++++++++++++++++++++++++------- 1 file changed, 209 insertions(+), 42 deletions(-) diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index d81e83cfbf50b..4a27fe0c838b2 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -7,13 +7,221 @@ 0 0 667 - 663 + 796 Form + + + + About + + + + + + + 0 + 0 + + + + About + + + + + + + + + Legal notice + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + General Settings + + + + + + &Launch on System Startup + + + + + + + Show Call Notifications + + + + + + + For System Tray + + + Use &Monochrome Icons + + + + + + + Show Chat Notifications + + + + + + + Show Server &Notifications + + + + + + + + + + Updates + + + + + + + + &Automatically check for Updates + + + true + + + + + + + + + + + + 0 + 0 + + + + &Channel + + + updateChannel + + + + + + + + 0 + 0 + + + + + stable + + + + + beta + + + + + + + + + + + true + + + true + + + + + + + + 0 + 0 + + + + &Restart && Update + + + + + + + + + + 0 + 0 + + + + &Check for Update now + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + @@ -383,52 +591,11 @@ - - - - General Settings - - - - - - For System Tray - - - Use &monochrome icons - - - - - - - &Launch on system startup - - - - - - - Show server &notifications - - - - - - - Show call notifications - - - - - - autostartCheckBox serverNotificationsCheckBox - monoIconsCheckBox ignoredFilesButton newFolderLimitCheckBox newFolderLimitSpinBox From e7d1f5f0921d8a2d5e8da5a9f876c6ea50a0c415 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 13 Feb 2023 13:47:52 +0100 Subject: [PATCH 2/6] Add setting for showing chat notifications to configfile Signed-off-by: Claudio Cambra --- src/libsync/configfile.cpp | 14 ++++++++++++++ src/libsync/configfile.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 1f571de3c42cf..2b1cda432e597 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -58,6 +58,7 @@ static constexpr char deleteFilesThresholdC[] = "deleteFilesThreshold"; static constexpr char crashReporterC[] = "crashReporter"; static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications"; static constexpr char showCallNotificationsC[] = "showCallNotifications"; +static constexpr char showChatNotificationsC[] = "showChatNotifications"; static constexpr char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane"; static constexpr char skipUpdateCheckC[] = "skipUpdateCheck"; static constexpr char autoUpdateCheckC[] = "autoUpdateCheck"; @@ -205,6 +206,19 @@ bool ConfigFile::optionalServerNotifications() const return settings.value(QLatin1String(optionalServerNotificationsC), true).toBool(); } +bool ConfigFile::showChatNotifications() const +{ + const QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(showChatNotificationsC), true).toBool() && optionalServerNotifications(); +} + +void ConfigFile::setShowChatNotifications(const bool show) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(showChatNotificationsC), show); + settings.sync(); +} + bool ConfigFile::showCallNotifications() const { const QSettings settings(configFile(), QSettings::IniFormat); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index ff289b1fe0605..212d6e6fe0d7d 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -167,8 +167,11 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] bool optionalServerNotifications() const; void setOptionalServerNotifications(bool show); + [[nodiscard]] bool showChatNotifications() const; + void setShowChatNotifications(bool show); + [[nodiscard]] bool showCallNotifications() const; - void setShowCallNotifications(bool show); + void setShowCallNotifications(const bool show); [[nodiscard]] bool showInExplorerNavigationPane() const; void setShowInExplorerNavigationPane(bool show); From 918d79f5cd509cb4c7f90ccbc53aabbb3e4d3b8f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 13 Feb 2023 13:56:20 +0100 Subject: [PATCH 3/6] Add the chat notification toggle setting logic in generalsettings Signed-off-by: Claudio Cambra --- src/gui/generalsettings.cpp | 15 ++++++++++++++- src/gui/generalsettings.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index d9fcbefe284cd..8653f433f6c6f 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -164,6 +164,10 @@ GeneralSettings::GeneralSettings(QWidget *parent) this, &GeneralSettings::slotToggleOptionalServerNotifications); _ui->serverNotificationsCheckBox->setToolTip(tr("Server notifications that require attention.")); + connect(_ui->chatNotificationsCheckBox, &QAbstractButton::toggled, + this, &GeneralSettings::slotToggleChatNotifications); + _ui->chatNotificationsCheckBox->setToolTip(tr("Show chat notification dialogs.")); + connect(_ui->callNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleCallNotifications); _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); @@ -271,7 +275,9 @@ void GeneralSettings::loadMiscSettings() _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); _ui->serverNotificationsCheckBox->setChecked(cfgFile.optionalServerNotifications()); - _ui->callNotificationsCheckBox->setEnabled(_ui->serverNotificationsCheckBox->isEnabled()); + _ui->chatNotificationsCheckBox->setEnabled(cfgFile.optionalServerNotifications()); + _ui->chatNotificationsCheckBox->setChecked(cfgFile.showChatNotifications()); + _ui->callNotificationsCheckBox->setEnabled(cfgFile.optionalServerNotifications()); _ui->callNotificationsCheckBox->setChecked(cfgFile.showCallNotifications()); _ui->showInExplorerNavigationPaneCheckBox->setChecked(cfgFile.showInExplorerNavigationPane()); _ui->crashreporterCheckBox->setChecked(cfgFile.crashReporter()); @@ -512,9 +518,16 @@ void GeneralSettings::slotToggleOptionalServerNotifications(bool enable) { ConfigFile cfgFile; cfgFile.setOptionalServerNotifications(enable); + _ui->chatNotificationsCheckBox->setEnabled(enable); _ui->callNotificationsCheckBox->setEnabled(enable); } +void GeneralSettings::slotToggleChatNotifications(bool enable) +{ + ConfigFile cfgFile; + cfgFile.setShowChatNotifications(enable); +} + void GeneralSettings::slotToggleCallNotifications(bool enable) { ConfigFile cfgFile; diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 02a8cef3dedf2..83067799a9753 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -52,6 +52,7 @@ private slots: void saveMiscSettings(); void slotToggleLaunchOnStartup(bool); void slotToggleOptionalServerNotifications(bool); + void slotToggleChatNotifications(bool); void slotToggleCallNotifications(bool); void slotShowInExplorerNavigationPane(bool); void slotIgnoreFilesEditor(); From babdbd1e3e9b80e976c1623f144d77fc0187aace Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 13 Feb 2023 14:15:18 +0100 Subject: [PATCH 4/6] Only notify talk chat notifications if this is enabled Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 98393f4ca9406..fefbe27f46c2b 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -184,7 +184,12 @@ void User::showDesktopTalkNotification(const Activity &activity) { const auto notificationId = activity._id; - if (!canShowNotification(notificationId)) { + const ConfigFile cfg; + const auto userStatus = _account->account()->userStatusConnector()->userStatus().state(); + if (!canShowNotification(notificationId) || + userStatus == OCC::UserStatus::OnlineStatus::DoNotDisturb || + !cfg.showChatNotifications()) { + return; } From 2608016995d6c6caf8e42f56dbb35e36f422c18d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 26 Jun 2024 17:24:42 +0800 Subject: [PATCH 5/6] Do not use const for POD type in setShowCallNotifications declaration Signed-off-by: Claudio Cambra --- src/libsync/configfile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 212d6e6fe0d7d..844036336a6f9 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -171,7 +171,7 @@ class OWNCLOUDSYNC_EXPORT ConfigFile void setShowChatNotifications(bool show); [[nodiscard]] bool showCallNotifications() const; - void setShowCallNotifications(const bool show); + void setShowCallNotifications(bool show); [[nodiscard]] bool showInExplorerNavigationPane() const; void setShowInExplorerNavigationPane(bool show); From e66135a59aff90a42c2ea8906edf16fd6609f60d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Nov 2024 16:15:31 +0800 Subject: [PATCH 6/6] Remove unneeded check for DnD status when showing desktop talk notification The server will not deliver it anyway Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index fefbe27f46c2b..c39b1406e57c3 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -184,12 +184,7 @@ void User::showDesktopTalkNotification(const Activity &activity) { const auto notificationId = activity._id; - const ConfigFile cfg; - const auto userStatus = _account->account()->userStatusConnector()->userStatus().state(); - if (!canShowNotification(notificationId) || - userStatus == OCC::UserStatus::OnlineStatus::DoNotDisturb || - !cfg.showChatNotifications()) { - + if (!canShowNotification(notificationId) || !ConfigFile().showChatNotifications()) { return; }