~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/lib/audiosettingsmodel.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2013-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
5
 *   This library is free software; you can redistribute it and/or          *
 
6
 *   modify it under the terms of the GNU Lesser General Public             *
 
7
 *   License as published by the Free Software Foundation; either           *
 
8
 *   version 2.1 of the License, or (at your option) any later version.     *
 
9
 *                                                                          *
 
10
 *   This library is distributed in the hope that it will be useful,        *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
13
 *   Lesser General Public License for more details.                        *
 
14
 *                                                                          *
 
15
 *   You should have received a copy of the GNU General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
#ifndef AUDIOSETTINGSMODEL_H
 
19
#define AUDIOSETTINGSMODEL_H
 
20
 
 
21
#include <QtCore/QObject>
 
22
#include <QtCore/QStringList>
 
23
#include <QtCore/QAbstractListModel>
 
24
 
 
25
#include "typedefs.h"
 
26
 
 
27
class AlsaPluginModel    ;
 
28
class InputDeviceModel   ;
 
29
class OutputDeviceModel  ;
 
30
class AudioManagerModel   ;
 
31
class RingtoneDeviceModel;
 
32
 
 
33
/**
 
34
 * This class group all ComboBox models used by audio settings dialogs
 
35
 */
 
36
class LIB_EXPORT AudioSettingsModel : public QObject {
 
37
   Q_OBJECT
 
38
public:
 
39
 
 
40
   enum DeviceIndex {
 
41
      OUTPUT   = 0,
 
42
      INPUT    = 1,
 
43
      RINGTONE = 2,
 
44
   };
 
45
 
 
46
   virtual ~AudioSettingsModel();
 
47
   static AudioSettingsModel* instance();
 
48
 
 
49
   //Getters
 
50
   AlsaPluginModel*     alsaPluginModel    ();
 
51
   InputDeviceModel*    inputDeviceModel   ();
 
52
   OutputDeviceModel*   outputDeviceModel  ();
 
53
   AudioManagerModel*   audioManagerModel  ();
 
54
   RingtoneDeviceModel* ringtoneDeviceModel();
 
55
   bool                 isRoomToneEnabled  ();
 
56
   bool                 isNoiseSuppressEnabled () const;
 
57
   bool                 isPlaybackMuted() const;
 
58
   bool                 isCaptureMuted () const;
 
59
   bool                 areDTMFMuted   () const;
 
60
   int                  playbackVolume () const;
 
61
   int                  captureVolume  () const;
 
62
 
 
63
   //Setters
 
64
   void setEnableRoomTone    ( bool enable  );
 
65
   void setNoiseSuppressState( bool enabled );
 
66
 
 
67
   //Room tone type
 
68
   enum class ToneType {
 
69
      WITHOUT_MESSAGE = 0,
 
70
      WITH_MESSAGE    = 1,
 
71
   };
 
72
 
 
73
   class DeviceKey {
 
74
   public:
 
75
      constexpr static const char* CAPTURE  = "mic"    ;
 
76
      constexpr static const char* PLAYBACK = "speaker";
 
77
   };
 
78
 
 
79
   //Mutator
 
80
   ToneType playRoomTone() const;
 
81
   void     stopRoomTone() const;
 
82
 
 
83
public Q_SLOTS:
 
84
   void reload           (              );
 
85
   void mutePlayback     ( bool m       );
 
86
   void muteCapture      ( bool m       );
 
87
   void setPlaybackVolume( int  volume  );
 
88
   void setCaptureVolume ( int  volume  );
 
89
   void setDTMFMuted     ( bool muted   );
 
90
 
 
91
Q_SIGNALS:
 
92
   void captureMuted(bool);
 
93
   void playbackMuted(bool);
 
94
   void playbackVolumeChanged(int);
 
95
   void captureVolumeChanged(int);
 
96
   void DTMFMutedChanged(bool);
 
97
 
 
98
private:
 
99
   //Constructor
 
100
   explicit AudioSettingsModel();
 
101
 
 
102
   //Attributes
 
103
   AlsaPluginModel*     m_pAlsaPluginModel    ;
 
104
   InputDeviceModel*    m_pInputDeviceModel   ;
 
105
   OutputDeviceModel*   m_pOutputDeviceModel  ;
 
106
   AudioManagerModel*   m_pAudioManagerModel  ;
 
107
   RingtoneDeviceModel* m_pRingtoneDeviceModel;
 
108
   bool                 m_EnableRoomTone      ;
 
109
 
 
110
   //Singleton
 
111
   static AudioSettingsModel* m_spInstance;
 
112
};
 
113
 
 
114
class LIB_EXPORT AlsaPluginModel    : public QAbstractListModel {
 
115
   Q_OBJECT
 
116
public:
 
117
   explicit AlsaPluginModel(QObject* parent);
 
118
   virtual ~AlsaPluginModel();
 
119
 
 
120
   //Models function
 
121
   virtual QVariant      data    ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
122
   virtual int           rowCount( const QModelIndex& parent = QModelIndex()            ) const;
 
123
   virtual Qt::ItemFlags flags   ( const QModelIndex& index                             ) const;
 
124
   virtual bool          setData ( const QModelIndex& index, const QVariant &value, int role);
 
125
 
 
126
   //Getters
 
127
   QModelIndex currentPlugin() const;
 
128
 
 
129
   //Setters
 
130
   void setCurrentPlugin(const QModelIndex& idx);
 
131
   void setCurrentPlugin(int idx);
 
132
 
 
133
   //Mutator
 
134
   void reload();
 
135
 
 
136
private:
 
137
   QStringList m_lDeviceList;
 
138
};
 
139
 
 
140
class LIB_EXPORT InputDeviceModel   : public QAbstractListModel {
 
141
   Q_OBJECT
 
142
public:
 
143
   explicit InputDeviceModel(QObject* parent);
 
144
   virtual ~InputDeviceModel();
 
145
 
 
146
   //Models function
 
147
   virtual QVariant      data    ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
148
   virtual int           rowCount( const QModelIndex& parent = QModelIndex()            ) const;
 
149
   virtual Qt::ItemFlags flags   ( const QModelIndex& index                             ) const;
 
150
   virtual bool          setData ( const QModelIndex& index, const QVariant &value, int role);
 
151
 
 
152
   //Getters
 
153
   QModelIndex currentDevice() const;
 
154
 
 
155
   //Setters
 
156
   void setCurrentDevice(const QModelIndex& index);
 
157
   void setCurrentDevice(int idx);
 
158
 
 
159
   //Mutator
 
160
   void reload();
 
161
 
 
162
private:
 
163
   QStringList m_lDeviceList;
 
164
};
 
165
 
 
166
class LIB_EXPORT OutputDeviceModel  : public QAbstractListModel {
 
167
   Q_OBJECT
 
168
public:
 
169
   explicit OutputDeviceModel(QObject* parent);
 
170
   virtual ~OutputDeviceModel();
 
171
 
 
172
   //Models function
 
173
   virtual QVariant      data    ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
174
   virtual int           rowCount( const QModelIndex& parent = QModelIndex()            ) const;
 
175
   virtual Qt::ItemFlags flags   ( const QModelIndex& index                             ) const;
 
176
   virtual bool          setData ( const QModelIndex& index, const QVariant &value, int role);
 
177
 
 
178
   //Getters
 
179
   QModelIndex currentDevice() const;
 
180
 
 
181
   //Setters
 
182
   void setCurrentDevice(const QModelIndex& index);
 
183
   void setCurrentDevice(int idx);
 
184
 
 
185
   //Mutator
 
186
   void reload();
 
187
 
 
188
private:
 
189
   QStringList m_lDeviceList;
 
190
};
 
191
 
 
192
class LIB_EXPORT AudioManagerModel   : public QAbstractListModel {
 
193
   Q_OBJECT
 
194
public:
 
195
   explicit AudioManagerModel(QObject* parent);
 
196
   virtual ~AudioManagerModel();
 
197
 
 
198
   //Models function
 
199
   virtual QVariant      data    ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
200
   virtual int           rowCount( const QModelIndex& parent = QModelIndex()            ) const;
 
201
   virtual Qt::ItemFlags flags   ( const QModelIndex& index                             ) const;
 
202
   virtual bool          setData ( const QModelIndex& index, const QVariant &value, int role);
 
203
 
 
204
   //Getters
 
205
   QModelIndex currentManager() const;
 
206
 
 
207
   //Setters
 
208
   void setCurrentManager(const QModelIndex& index);
 
209
 
 
210
public Q_SLOTS:
 
211
   void setCurrentManager(int idx);
 
212
 
 
213
 
 
214
private:
 
215
   QStringList m_lDeviceList;
 
216
   class ManagerName {
 
217
   public:
 
218
      constexpr static const char* PULSEAUDIO = "pulseaudio";
 
219
      constexpr static const char* ALSA       = "alsa";
 
220
   };
 
221
 
 
222
   enum class Manager {
 
223
      ALSA =0,
 
224
      PULSE=1,
 
225
   };
 
226
};
 
227
 
 
228
class LIB_EXPORT RingtoneDeviceModel: public QAbstractListModel {
 
229
   Q_OBJECT
 
230
public:
 
231
   explicit RingtoneDeviceModel(QObject* parent);
 
232
   virtual ~RingtoneDeviceModel();
 
233
 
 
234
   //Models function
 
235
   virtual QVariant      data    ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
236
   virtual int           rowCount( const QModelIndex& parent = QModelIndex()            ) const;
 
237
   virtual Qt::ItemFlags flags   ( const QModelIndex& index                             ) const;
 
238
   virtual bool          setData ( const QModelIndex& index, const QVariant &value, int role);
 
239
 
 
240
   //Getters
 
241
   QModelIndex currentDevice() const;
 
242
 
 
243
   //Setters
 
244
   void setCurrentDevice(const QModelIndex& index);
 
245
   void setCurrentDevice(int idx);
 
246
 
 
247
   //Mutator
 
248
   void reload();
 
249
 
 
250
private:
 
251
   QStringList m_lDeviceList;
 
252
};
 
253
 
 
254
#endif //AUDIOSETTINGSMODEL_H