1 /*
2  * Cantata
3  *
4  * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com>
5  *
6  * ----
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; see the file COPYING.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #include "audiocdsettings.h"
25 #include "gui/settings.h"
26 
27 #define REMOVE(w) \
28     w->setVisible(false); \
29     w->deleteLater(); \
30     w=0;
31 
AudioCdSettings(QWidget * p)32 AudioCdSettings::AudioCdSettings(QWidget *p)
33     : QWidget(p)
34 {
35     setupUi(this);
36     #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
37     cdLookup->addItem(tr("CDDB"), true);
38     cdLookup->addItem(tr("MusicBrainz"), false);
39     #else
40     REMOVE(cdLookup)
41     REMOVE(cdLookupLabel)
42     #endif
43 
44     #if !defined CDDB_FOUND
45     REMOVE(cddbHost)
46     REMOVE(cddbHostLabel)
47     REMOVE(cddbPort)
48     REMOVE(cddbPortLabel)
49     #endif
50 }
51 
load()52 void AudioCdSettings::load()
53 {
54     cdAuto->setChecked(Settings::self()->cdAuto());
55     #if defined CDDB_FOUND
56     cddbHost->setText(Settings::self()->cddbHost());
57     cddbPort->setValue(Settings::self()->cddbPort());
58     #endif
59     paranoiaFull->setChecked(Settings::self()->paranoiaFull());
60     paranoiaNeverSkip->setChecked(Settings::self()->paranoiaNeverSkip());
61     #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
62     for (int i=0; i<cdLookup->count(); ++i) {
63         if (cdLookup->itemData(i).toBool()==Settings::self()->useCddb()) {
64             cdLookup->setCurrentIndex(i);
65             break;
66         }
67     }
68     #endif
69     paranoiaOffset->setValue(Settings::self()->paranoiaOffset());
70 }
71 
save()72 void AudioCdSettings::save()
73 {
74     Settings::self()->saveCdAuto(cdAuto->isChecked());
75     #if defined CDDB_FOUND
76     Settings::self()->saveCddbHost(cddbHost->text().trimmed());
77     Settings::self()->saveCddbPort(cddbPort->value());
78     #endif
79     Settings::self()->saveParanoiaFull(paranoiaFull->isChecked());
80     Settings::self()->saveParanoiaNeverSkip(paranoiaNeverSkip->isChecked());
81     #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
82     Settings::self()->saveUseCddb(cdLookup->itemData(cdLookup->currentIndex()).toBool());
83     #endif
84     Settings::self()->saveParanoiaOffset(paranoiaOffset->value());
85 }
86 
87 #include "moc_audiocdsettings.cpp"
88