Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/disable talk chat notifications #5433

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/generalsettings.cpp

File src/gui/generalsettings.cpp does not conform to Custom style guidelines. (lines 167)
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -164,6 +164,10 @@
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 @@

_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,10 +518,17 @@
{
ConfigFile cfgFile;
cfgFile.setOptionalServerNotifications(enable);
_ui->chatNotificationsCheckBox->setEnabled(enable);
_ui->callNotificationsCheckBox->setEnabled(enable);
}

void GeneralSettings::slotToggleChatNotifications(bool enable)

Check warning on line 525 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:525:23 [readability-convert-member-functions-to-static]

method 'slotToggleChatNotifications' can be made static
{
ConfigFile cfgFile;

Check warning on line 527 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:527:16 [cppcoreguidelines-init-variables]

variable 'cfgFile' is not initialized
cfgFile.setShowChatNotifications(enable);
}

void GeneralSettings::slotToggleCallNotifications(bool enable)

Check warning on line 531 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:531:23 [readability-convert-member-functions-to-static]

method 'slotToggleCallNotifications' can be made static
{
ConfigFile cfgFile;
cfgFile.setShowCallNotifications(enable);
Expand Down
1 change: 1 addition & 0 deletions src/gui/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef MIRALL_GENERALSETTINGS_H
#define MIRALL_GENERALSETTINGS_H

#include "config.h"

Check failure on line 18 in src/gui/generalsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.h:18:10 [clang-diagnostic-error]

'config.h' file not found

#include <QWidget>
#include <QPointer>
Expand Down Expand Up @@ -52,6 +52,7 @@
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 @@ -12,7 +12,7 @@
* for more details.
*/

#include "config.h"

Check failure on line 15 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:15:10 [clang-diagnostic-error]

'config.h' file not found

#include "configfile.h"
#include "theme.h"
Expand Down Expand Up @@ -58,7 +58,8 @@
static constexpr char crashReporterC[] = "crashReporter";
static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications";
static constexpr char showCallNotificationsC[] = "showCallNotifications";
static constexpr char showChatNotificationsC[] = "showChatNotifications";

Check warning on line 61 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:61:23 [readability-static-definition-in-anonymous-namespace]

'showChatNotificationsC' is a static definition in anonymous namespace; static is redundant here
static constexpr char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";

Check warning on line 62 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:62:23 [readability-static-definition-in-anonymous-namespace]

'showInExplorerNavigationPaneC' is a static definition in anonymous namespace; static is redundant here
static constexpr char skipUpdateCheckC[] = "skipUpdateCheck";
static constexpr char autoUpdateCheckC[] = "autoUpdateCheck";
static constexpr char updateCheckIntervalC[] = "updateCheckInterval";
Expand Down Expand Up @@ -205,6 +206,19 @@
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 @@ -15,7 +15,7 @@
#ifndef CONFIGFILE_H
#define CONFIGFILE_H

#include "owncloudlib.h"

Check failure on line 18 in src/libsync/configfile.h

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.h:18:10 [clang-diagnostic-error]

'owncloudlib.h' file not found
#include <memory>
#include <QSharedPointer>
#include <QSettings>
Expand Down Expand Up @@ -167,6 +167,9 @@
[[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
Loading