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(); 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 diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 98393f4ca9406..c39b1406e57c3 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -184,7 +184,7 @@ void User::showDesktopTalkNotification(const Activity &activity) { const auto notificationId = activity._id; - if (!canShowNotification(notificationId)) { + if (!canShowNotification(notificationId) || !ConfigFile().showChatNotifications()) { return; } 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..844036336a6f9 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -167,6 +167,9 @@ 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);