swift
audiosettings.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_AUDIO_SETTINGS_H
7 #define SWIFT_MISC_AUDIO_SETTINGS_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
13 #include "misc/metaclass.h"
14 #include "misc/settingscache.h"
15 #include "misc/statusmessage.h"
16 #include "misc/swiftmiscexport.h"
17 #include "misc/valueobject.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::audio, CSettings)
20 
21 namespace swift::misc::audio
22 {
24  class SWIFT_MISC_EXPORT CSettings : public CValueObject<CSettings>
25  {
26  public:
29  static constexpr int InMax = 100;
30  static constexpr int InMin = 0;
31  static constexpr int OutMax = 100;
32  static constexpr int OutMin = 0;
34 
37  static int fixOutVolume(int v);
38  static int fixInVolume(int v);
40 
42  CSettings() = default;
43 
45  bool isNotificationFlagSet(CNotificationSounds::NotificationFlag notification) const;
46 
48  void setNotificationFlag(CNotificationSounds::NotificationFlag notification, bool value);
49 
51  CNotificationSounds::Notification getNotification() const
52  {
53  return static_cast<CNotificationSounds::Notification>(m_notification);
54  }
55 
57  void setNotification(CNotificationSounds::Notification notification)
58  {
59  m_notification = static_cast<int>(notification);
60  }
61 
64  bool textMessagePrivate() const
65  {
66  return this->isNotificationFlagSet(CNotificationSounds::NotificationTextMessagePrivate);
67  }
68  bool textMessageSupervisor() const
69  {
70  return this->isNotificationFlagSet(CNotificationSounds::NotificationTextMessageSupervisor);
71  }
72  bool textCallsignMentioned() const
73  {
74  return this->isNotificationFlagSet(CNotificationSounds::NotificationTextCallsignMentioned);
75  }
76  bool pttClickDown() const { return this->isNotificationFlagSet(CNotificationSounds::PTTClickKeyDown); }
77  bool pttClickUp() const { return this->isNotificationFlagSet(CNotificationSounds::PTTClickKeyUp); }
78 
79  bool afvClicked() const { return this->isNotificationFlagSet(CNotificationSounds::AFVClicked); }
80  bool afvBlocked() const { return this->isNotificationFlagSet(CNotificationSounds::AFVBlocked); }
82 
84  void setNotificationSoundDirectory(const QString &dir);
85 
87  const QString &getNotificationSoundDirectory() const { return m_notificationSoundDir; }
88 
90  const QString &getNotificationSoundDirectoryOrDefault() const;
91 
95  QString getNotificationFilePath(const QString &fileName) const;
96 
98  void setNotificationVolume(int volume);
99 
101  int getNotificationVolume() const { return m_notificationVolume; }
102 
104  void setOutVolume(int volume);
105 
107  int getOutVolume() const { return m_outVolume; }
108 
110  void setOutVolumeCom1(int volume);
111 
113  int getOutVolumeCom1() const { return m_outVolumeCom1; }
114 
116  void setOutVolumeCom2(int volume);
117 
119  int getOutVolumeCom2() const { return m_outVolumeCom2; }
120 
122  void setInVolume(int volume);
123 
125  int getInVolume() const { return m_inVolume; }
126 
128  bool isAudioEffectsEnabled() const { return m_audioEffects; }
129 
131  void setAudioEffectsEnabled(bool enabled) { m_audioEffects = enabled; }
132 
134  QString convertToQString(bool i18n = false) const;
135 
136  private:
137  QString m_notificationSoundDir;
138  int m_notification = static_cast<int>(
141  int m_notificationVolume = 90;
142  int m_outVolume = 40;
143  int m_outVolumeCom1 = 100;
144  int m_outVolumeCom2 = 100;
145  int m_inVolume = 50;
146  bool m_audioEffects = true;
147 
149  CSettings,
150  SWIFT_METAMEMBER(notificationSoundDir),
151  SWIFT_METAMEMBER(notification),
152  SWIFT_METAMEMBER(notificationVolume),
153  SWIFT_METAMEMBER(outVolume),
154  SWIFT_METAMEMBER(outVolumeCom1),
155  SWIFT_METAMEMBER(outVolumeCom2),
156  SWIFT_METAMEMBER(inVolume),
157  SWIFT_METAMEMBER(audioEffects));
158  };
159 
161  struct TSettings : public TSettingTrait<CSettings>
162  {
164  static const char *key() { return "audio/%Application%/setup"; }
165 
167  static const QString &humanReadable()
168  {
169  static const QString name("Audio");
170  return name;
171  }
172 
174  static bool isValid(const swift::misc::audio::CSettings &value, QString &)
175  {
176  Q_UNUSED(value)
177  return true;
178  }
179  };
180 } // namespace swift::misc::audio
181 
182 Q_DECLARE_METATYPE(swift::misc::audio::CSettings)
183 
184 #endif // SWIFT_MISC_AUDIO_SETTINGS_H
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating information of audio related settings.
Definition: audiosettings.h:25
void setAudioEffectsEnabled(bool enabled)
Audio effects.
CNotificationSounds::Notification getNotification() const
Get notification.
Definition: audiosettings.h:51
bool afvClicked() const
Simplified functions.
Definition: audiosettings.h:79
bool textMessageSupervisor() const
Simplified functions.
Definition: audiosettings.h:68
int getNotificationVolume() const
Get volume (notifications)
bool textMessagePrivate() const
Simplified functions.
Definition: audiosettings.h:64
void setNotification(CNotificationSounds::Notification notification)
Set notification.
Definition: audiosettings.h:57
CSettings()=default
Default constructor.
int getOutVolumeCom2() const
Get volume for com2 (audio) 0..100.
bool afvBlocked() const
Simplified functions.
Definition: audiosettings.h:80
int getOutVolume() const
Get volume (audio) 0..100.
bool pttClickUp() const
Simplified functions.
Definition: audiosettings.h:77
bool isAudioEffectsEnabled() const
Audio effects enabled?
int getInVolume() const
Get mic.volume (audio 0..100)
bool pttClickDown() const
Simplified functions.
Definition: audiosettings.h:76
bool textCallsignMentioned() const
Simplified functions.
Definition: audiosettings.h:72
int getOutVolumeCom1() const
Get volume for com1 (audio) 0..100.
const QString & getNotificationSoundDirectory() const
Notification directory.
Definition: audiosettings.h:87
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
Base class for traits to be used as template argument to swift::misc::CSetting.
constexpr static Notification DefaultNotifications
Default notification flags.
Audio related settings.
static bool isValid(const swift::misc::audio::CSettings &value, QString &)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
static const char * key()
Key string of the value. Reimplemented in derived class.
static const QString & humanReadable()
Optional human readable name.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65