Skip to content

Commit

Permalink
Merge pull request #5433 from nextcloud/feature/disable-talk-notifica…
Browse files Browse the repository at this point in the history
…tions

Feature/disable talk chat notifications
  • Loading branch information
mgallien authored Nov 21, 2024
2 parents 1e378a9 + e66135a commit 52f066d
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 44 deletions.
15 changes: 14 additions & 1 deletion src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/gui/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
251 changes: 209 additions & 42 deletions src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,221 @@
<x>0</x>
<y>0</y>
<width>667</width>
<height>663</height>
<height>796</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QGroupBox" name="aboutGroupBox">
<property name="title">
<string>About</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="aboutLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>About</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="legalNoticeButton">
<property name="text">
<string>Legal notice</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<property name="text">
<string>&amp;Launch on System Startup</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="callNotificationsCheckBox">
<property name="text">
<string>Show Call Notifications</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>Use &amp;Monochrome Icons</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chatNotificationsCheckBox">
<property name="text">
<string>Show Chat Notifications</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="serverNotificationsCheckBox">
<property name="text">
<string>Show Server &amp;Notifications</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="updatesGroupBox">
<property name="title">
<string>Updates</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QCheckBox" name="autoCheckForUpdatesCheckBox">
<property name="text">
<string>&amp;Automatically check for Updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="updateChannelLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Channel</string>
</property>
<property name="buddy">
<cstring>updateChannel</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="updateChannel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>stable</string>
</property>
</item>
<item>
<property name="text">
<string>beta</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="updateStateLabel">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="restartButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Restart &amp;&amp; Update</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="updateButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Check for Update now</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand Down Expand Up @@ -383,52 +591,11 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>Use &amp;monochrome icons</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<property name="text">
<string>&amp;Launch on system startup</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="serverNotificationsCheckBox">
<property name="text">
<string>Show server &amp;notifications</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="callNotificationsCheckBox">
<property name="text">
<string>Show call notifications</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>autostartCheckBox</tabstop>
<tabstop>serverNotificationsCheckBox</tabstop>
<tabstop>monoIconsCheckBox</tabstop>
<tabstop>ignoredFilesButton</tabstop>
<tabstop>newFolderLimitCheckBox</tabstop>
<tabstop>newFolderLimitSpinBox</tabstop>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void User::showDesktopTalkNotification(const Activity &activity)
{
const auto notificationId = activity._id;

if (!canShowNotification(notificationId)) {
if (!canShowNotification(notificationId) || !ConfigFile().showChatNotifications()) {
return;
}

Expand Down
14 changes: 14 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 52f066d

Please sign in to comment.