aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/hal/halplugin.h
blob: fd00159f41fe411927ac2e62056d217cd9784c84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/***************************************************************************
 *   Copyright (C) 2009-2012 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#ifndef DEVDETECT_H
#define DEVDETECT_H


#include <qmmpui/general.h>

class HalManager;
class HalDevice;
class QActionGroup;
class QAction;

/**
    @author Ilya Kotov <forkotov02@hotmail.ru>
*/

class HalPlugin : public QObject
{
Q_OBJECT
public:
    HalPlugin(QObject *parent = 0);

    ~HalPlugin();

private slots:
    void removeDevice(const QString &udi);
    void addDevice(const QString &udi);
    void processAction(QAction *action);
    void updateActions();

private:
    QAction *findAction(const QString &dev_path);
    HalDevice *findDevice(QAction *action);
    void addPath(const QString &path);
    void removePath(const QString &path);
    HalManager *m_manager;
    QList <HalDevice *> m_devices;
    QActionGroup *m_actions;
    bool m_detectCDA;
    bool m_addTracks;
    bool m_removeTracks;
    bool m_detectRemovable;
    bool m_addFiles;
    bool m_removeFiles;
};

#endif
d96289e136ff0c4002'>2ae491146
68bb7c962

9e562efd8
68bb7c962

013ee07b5
68bb7c962

11b7655bb

0535efd70
68bb7c962
37251bf90
c4749f20a
d542ede2e

2242b02f8




68bb7c962




b917024aa
68bb7c962



























2242b02f8
68bb7c962







3ad8895ad
68bb7c962
3ad8895ad
68bb7c962

dbc9b4065




3ad8895ad
68bb7c962

3ad8895ad
dbc9b4065
2242b02f8
68bb7c962


19361d62b
68bb7c962



















cc22f5cee
2242b02f8
68bb7c962












f81e13160
68bb7c962
f81e13160
68bb7c962

0535efd70





68bb7c962


0535efd70
68bb7c962
2242b02f8
68bb7c962


f81e13160
1b1902f39






2242b02f8
1b1902f39


143ecc15a
37251bf90






736d099ca
37251bf90
f81e13160
37251bf90


c4749f20a









e9574015d









2ae491146











68bb7c962

2242b02f8
68bb7c962









3ad8895ad
dbc9b4065
e9574015d
2ae491146
68bb7c962










0535efd70
1b1902f39
37251bf90





f81e13160
c4749f20a

d542ede2e

68bb7c962







d542ede2e









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            



                                                                             
                 
                            


                         
                                                 


                                                             

                                                             






                                                                                     
                                                                              

                        
                                                                                     
                                                                                                            
                                                                        
                                                                    
                                                                                 

                                 
                                                                                                              

                                                                                            
                                                                   

                        

                                                                          
                                                                                                  
                                                      
            
                                                                      

                                                                                              




                                                      




                             
                         



























                                                                                                        
                     







                                        
                                                    
 
                        

 




                                       
                                                                                                   

                                        
                          
                                    
                     


                                
                                                                     



















                                                                                                
                                                   
                     












                                         
                                       
 
                       

 





                                                                                                   


                                
                        
                        
                     


                                  
                                                  






                                                            
                     


                             
                                                          






                                                                                              
                                                                        
                        
                                                                                      


                             









                                          









                                          











                                                  

                         
                              









                                                                       
                                                     
                                                           
                                                           
                                                                   










                                                            
                                                        
                        





                                                                                
                                                                         

                                                           

                                                                                







                                      









                                                              
/***************************************************************************
 *   Copyright (C) 2010-2016 by Ilya Kotov                                 *
 *   forkotov02@ya.ru                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QSettings>
#include <QApplication>
#include <QTimer>
#include "metadatamanager.h"
#include "qmmp.h"
#include "qmmpsettings.h"

QmmpSettings *QmmpSettings::m_instance = nullptr;

QmmpSettings::QmmpSettings(QObject *parent) : QObject(parent)
{
    if(m_instance)
        qFatal("QmmpSettings: only one instance is allowed");
    m_instance = this;
    QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
    //replaygain settings
    settings.beginGroup("ReplayGain");
    m_rg_mode = (ReplayGainMode) settings.value("mode", REPLAYGAIN_DISABLED).toInt();
    m_rg_preamp = settings.value("preamp", 0.0).toDouble();
    m_rg_defaut_gain = settings.value("default_gain", 0.0).toDouble();
    m_rg_prevent_clipping = settings.value("prevent_clipping", true).toBool();
    settings.endGroup();
    //audio settings
    m_aud_software_volume = settings.value("Output/software_volume", false).toBool();
    m_aud_format = static_cast<Qmmp::AudioFormat>(settings.value("Output/format", Qmmp::PCM_S16LE).toInt());
    m_aud_dithering = settings.value("Output/dithering", true).toBool();
    m_volume_step = settings.value("Output/volume_step", 5).toInt();
    m_average_bitrate = settings.value("Output/average_bitrate", false).toBool();
    //cover settings
    settings.beginGroup("Cover");
    m_cover_inc = settings.value("include", (QStringList() << "*.jpg" << "*.png" << "*.webp")).toStringList();
    m_cover_exclude = settings.value("exclude", (QStringList() << "*back*")).toStringList();
    m_cover_depth = settings.value("depth", 0).toInt();
    m_cover_use_files = settings.value("use_files", true).toBool();
    settings.endGroup();
    //network settings
    m_proxy_enabled = settings.value("Proxy/use_proxy", false).toBool();
    m_proxy_auth = settings.value("Proxy/authentication", false).toBool();
    m_proxy_type = static_cast<ProxyType>(settings.value("Proxy/proxy_type", HTTP_PROXY).toInt());
    m_proxy_url = settings.value("Proxy/url").toUrl();
    //buffer
    m_buffer_size = settings.value("Output/buffer_size", 500).toInt();
    //file type determination
    m_determine_by_content = settings.value("Misc/determine_file_by_content", false).toBool();
    //timer
    m_timer = new QTimer(this);
    m_timer->setSingleShot(true);
    m_timer->setInterval(5000);
    connect(m_timer, SIGNAL(timeout()), SLOT(sync()));
}

QmmpSettings::~QmmpSettings()
{
    sync();
    m_instance = nullptr;
}

QmmpSettings::ReplayGainMode QmmpSettings::replayGainMode() const
{
    return m_rg_mode;
}

double QmmpSettings::replayGainPreamp() const
{
    return m_rg_preamp;
}

double QmmpSettings::replayGainDefaultGain() const
{
    return m_rg_defaut_gain;
}

bool QmmpSettings::replayGainPreventClipping() const
{
    return m_rg_prevent_clipping;
}

void QmmpSettings::setReplayGainSettings(ReplayGainMode mode, double preamp, double def_gain, bool clip)
{
    m_rg_mode = mode;
    m_rg_preamp = preamp;
    m_rg_defaut_gain = def_gain;
    m_rg_prevent_clipping = clip;
    m_timer->start();
    emit replayGainSettingsChanged();
}

bool QmmpSettings::useSoftVolume() const
{
    return m_aud_software_volume;
}

Qmmp::AudioFormat QmmpSettings::outputFormat() const
{
    return m_aud_format;
}

bool QmmpSettings::useDithering() const
{
    return m_aud_dithering;
}

void QmmpSettings::setAudioSettings(bool soft_volume, Qmmp::AudioFormat format, bool use_dithering)
{
    m_aud_software_volume = soft_volume;
    m_aud_format = format;
    m_aud_dithering = use_dithering;
    m_timer->start();
    emit audioSettingsChanged();
}

const QStringList &QmmpSettings::coverNameFilters(bool include) const
{
    return include ? m_cover_inc : m_cover_exclude;
}

int QmmpSettings::coverSearchDepth() const
{
    return m_cover_depth;
}

bool QmmpSettings::useCoverFiles() const
{
    return m_cover_use_files;
}

void QmmpSettings::setCoverSettings(QStringList inc, QStringList exc, int depth, bool use_files)
{
    m_cover_inc = inc;
    m_cover_exclude = exc;
    m_cover_depth = depth;
    m_cover_use_files = use_files;
    MetaDataManager::instance()->clearCoverCache();
    m_timer->start();
    emit coverSettingsChanged();
}

bool QmmpSettings::isProxyEnabled() const
{
    return m_proxy_enabled;
}

bool QmmpSettings::useProxyAuth() const
{
    return m_proxy_auth;
}

const QUrl &QmmpSettings::proxy() const
{
    return m_proxy_url;
}

QmmpSettings::ProxyType QmmpSettings::proxyType() const
{
    return m_proxy_type;
}

void QmmpSettings::setNetworkSettings(bool use_proxy, bool auth, ProxyType type, const QUrl &proxy)
{
    m_proxy_enabled = use_proxy;
    m_proxy_auth = auth;
    m_proxy_type = type;
    m_proxy_url = proxy;
    m_timer->start();
    emit networkSettingsChanged();
}

const EqSettings &QmmpSettings::eqSettings() const
{
    return m_eq_settings;
}

void QmmpSettings::setEqSettings(const EqSettings &settings)
{
    m_eq_settings = settings;
    m_timer->start();
    emit eqSettingsChanged();
}

void QmmpSettings::readEqSettings(EqSettings::Bands bands)
{
    m_eq_settings = EqSettings(bands);
    QSettings settings (Qmmp::configFile(), QSettings::IniFormat);