Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 Sonic Visualiser
|
Chris@0
|
5 An audio file viewer and annotation editor.
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7 This file copyright 2006 Chris Cannam.
|
Chris@0
|
8
|
Chris@0
|
9 This program is free software; you can redistribute it and/or
|
Chris@0
|
10 modify it under the terms of the GNU General Public License as
|
Chris@0
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
12 License, or (at your option) any later version. See the file
|
Chris@0
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "PreferencesDialog.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include <QGridLayout>
|
Chris@0
|
19 #include <QComboBox>
|
Chris@0
|
20 #include <QCheckBox>
|
Chris@0
|
21 #include <QGroupBox>
|
Chris@0
|
22 #include <QDoubleSpinBox>
|
Chris@0
|
23 #include <QLabel>
|
Chris@0
|
24 #include <QPushButton>
|
Chris@0
|
25 #include <QHBoxLayout>
|
Chris@0
|
26 #include <QString>
|
Chris@163
|
27 #include <QDialogButtonBox>
|
Chris@163
|
28 #include <QMessageBox>
|
Chris@180
|
29 #include <QTabWidget>
|
Chris@180
|
30 #include <QLineEdit>
|
Chris@180
|
31 #include <QFileDialog>
|
Chris@180
|
32 #include <QMessageBox>
|
Chris@225
|
33 #include <QSpinBox>
|
Chris@436
|
34 #include <QListWidget>
|
Chris@263
|
35 #include <QSettings>
|
Chris@0
|
36
|
Chris@436
|
37 #include <set>
|
Chris@436
|
38
|
Chris@9
|
39 #include "widgets/WindowTypeSelector.h"
|
Chris@180
|
40 #include "widgets/IconLoader.h"
|
Chris@0
|
41 #include "base/Preferences.h"
|
Chris@436
|
42 #include "base/ResourceFinder.h"
|
Chris@1096
|
43 #include "layer/ColourMapper.h"
|
Chris@0
|
44
|
Chris@1397
|
45 #include "bqaudioio/AudioFactory.h"
|
Chris@1035
|
46
|
Chris@686
|
47 #include "version.h"
|
Chris@686
|
48
|
Chris@1397
|
49 using namespace std;
|
Chris@1397
|
50
|
Chris@528
|
51 PreferencesDialog::PreferencesDialog(QWidget *parent) :
|
Chris@528
|
52 QDialog(parent),
|
Chris@1397
|
53 m_audioImplementation(0),
|
Chris@1397
|
54 m_audioPlaybackDevice(0),
|
Chris@1397
|
55 m_audioRecordDevice(0),
|
Chris@1413
|
56 m_audioDeviceChanged(false),
|
Chris@180
|
57 m_changesOnRestart(false)
|
Chris@0
|
58 {
|
Chris@163
|
59 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
|
Chris@0
|
60
|
Chris@0
|
61 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
62
|
Chris@0
|
63 QGridLayout *grid = new QGridLayout;
|
Chris@0
|
64 setLayout(grid);
|
Chris@180
|
65
|
Chris@436
|
66 m_tabs = new QTabWidget;
|
Chris@436
|
67 grid->addWidget(m_tabs, 0, 0);
|
Chris@0
|
68
|
Chris@436
|
69 m_tabs->setTabPosition(QTabWidget::North);
|
Chris@0
|
70
|
Chris@0
|
71 // Create this first, as slots that get called from the ctor will
|
Chris@0
|
72 // refer to it
|
Chris@0
|
73 m_applyButton = new QPushButton(tr("Apply"));
|
Chris@0
|
74
|
Chris@180
|
75 // Create all the preference widgets first, then create the
|
Chris@180
|
76 // individual tab widgets and place the preferences in their
|
Chris@180
|
77 // appropriate places in one go afterwards
|
Chris@180
|
78
|
Chris@114
|
79 int min, max, deflt, i;
|
Chris@0
|
80
|
Chris@9
|
81 m_windowType = WindowType(prefs->getPropertyRangeAndValue
|
Chris@114
|
82 ("Window Type", &min, &max, &deflt));
|
Chris@9
|
83 m_windowTypeSelector = new WindowTypeSelector(m_windowType);
|
Chris@0
|
84
|
Chris@9
|
85 connect(m_windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@9
|
86 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@0
|
87
|
Chris@1275
|
88 QCheckBox *vampProcessSeparation = new QCheckBox;
|
Chris@1275
|
89 m_runPluginsInProcess = prefs->getRunPluginsInProcess();
|
Chris@1275
|
90 vampProcessSeparation->setCheckState(m_runPluginsInProcess ? Qt::Unchecked :
|
Chris@1275
|
91 Qt::Checked);
|
Chris@1275
|
92 connect(vampProcessSeparation, SIGNAL(stateChanged(int)),
|
Chris@1275
|
93 this, SLOT(vampProcessSeparationChanged(int)));
|
Chris@1275
|
94
|
Chris@115
|
95 QComboBox *smoothing = new QComboBox;
|
Chris@115
|
96
|
Chris@299
|
97 int sm = prefs->getPropertyRangeAndValue("Spectrogram Y Smoothing", &min, &max,
|
Chris@115
|
98 &deflt);
|
Chris@115
|
99 m_spectrogramSmoothing = sm;
|
Chris@0
|
100
|
Chris@115
|
101 for (i = min; i <= max; ++i) {
|
Chris@299
|
102 smoothing->addItem(prefs->getPropertyValueLabel("Spectrogram Y Smoothing", i));
|
Chris@115
|
103 }
|
Chris@115
|
104
|
Chris@115
|
105 smoothing->setCurrentIndex(sm);
|
Chris@115
|
106
|
Chris@115
|
107 connect(smoothing, SIGNAL(currentIndexChanged(int)),
|
Chris@115
|
108 this, SLOT(spectrogramSmoothingChanged(int)));
|
Chris@0
|
109
|
Chris@299
|
110 QComboBox *xsmoothing = new QComboBox;
|
Chris@299
|
111
|
Chris@299
|
112 int xsm = prefs->getPropertyRangeAndValue("Spectrogram X Smoothing", &min, &max,
|
Chris@299
|
113 &deflt);
|
Chris@299
|
114 m_spectrogramXSmoothing = xsm;
|
Chris@299
|
115
|
Chris@299
|
116 for (i = min; i <= max; ++i) {
|
Chris@299
|
117 xsmoothing->addItem(prefs->getPropertyValueLabel("Spectrogram X Smoothing", i));
|
Chris@299
|
118 }
|
Chris@299
|
119
|
Chris@299
|
120 xsmoothing->setCurrentIndex(xsm);
|
Chris@299
|
121
|
Chris@299
|
122 connect(xsmoothing, SIGNAL(currentIndexChanged(int)),
|
Chris@299
|
123 this, SLOT(spectrogramXSmoothingChanged(int)));
|
Chris@299
|
124
|
Chris@0
|
125 QComboBox *propertyLayout = new QComboBox;
|
Chris@114
|
126 int pl = prefs->getPropertyRangeAndValue("Property Box Layout", &min, &max,
|
Chris@115
|
127 &deflt);
|
Chris@0
|
128 m_propertyLayout = pl;
|
Chris@0
|
129
|
Chris@0
|
130 for (i = min; i <= max; ++i) {
|
Chris@0
|
131 propertyLayout->addItem(prefs->getPropertyValueLabel("Property Box Layout", i));
|
Chris@0
|
132 }
|
Chris@0
|
133
|
Chris@0
|
134 propertyLayout->setCurrentIndex(pl);
|
Chris@0
|
135
|
Chris@0
|
136 connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
|
Chris@0
|
137 this, SLOT(propertyLayoutChanged(int)));
|
Chris@0
|
138
|
Chris@1096
|
139 QSettings settings;
|
Chris@1096
|
140 settings.beginGroup("Preferences");
|
Chris@1096
|
141 m_spectrogramGColour = (settings.value("spectrogram-colour",
|
Chris@1096
|
142 int(ColourMapper::Green)).toInt());
|
Chris@1096
|
143 m_spectrogramMColour = (settings.value("spectrogram-melodic-colour",
|
Chris@1096
|
144 int(ColourMapper::Sunset)).toInt());
|
Chris@1097
|
145 m_colour3DColour = (settings.value("colour-3d-plot-colour",
|
Chris@1097
|
146 int(ColourMapper::Green)).toInt());
|
Chris@1096
|
147 settings.endGroup();
|
Chris@1096
|
148 QComboBox *spectrogramGColour = new QComboBox;
|
Chris@1096
|
149 QComboBox *spectrogramMColour = new QComboBox;
|
Chris@1097
|
150 QComboBox *colour3DColour = new QComboBox;
|
Chris@1096
|
151 for (i = 0; i < ColourMapper::getColourMapCount(); ++i) {
|
Chris@1096
|
152 spectrogramGColour->addItem(ColourMapper::getColourMapName(i));
|
Chris@1096
|
153 spectrogramMColour->addItem(ColourMapper::getColourMapName(i));
|
Chris@1097
|
154 colour3DColour->addItem(ColourMapper::getColourMapName(i));
|
Chris@1096
|
155 if (i == m_spectrogramGColour) spectrogramGColour->setCurrentIndex(i);
|
Chris@1096
|
156 if (i == m_spectrogramMColour) spectrogramMColour->setCurrentIndex(i);
|
Chris@1097
|
157 if (i == m_colour3DColour) colour3DColour->setCurrentIndex(i);
|
Chris@1096
|
158 }
|
Chris@1096
|
159 connect(spectrogramGColour, SIGNAL(currentIndexChanged(int)),
|
Chris@1096
|
160 this, SLOT(spectrogramGColourChanged(int)));
|
Chris@1096
|
161 connect(spectrogramMColour, SIGNAL(currentIndexChanged(int)),
|
Chris@1096
|
162 this, SLOT(spectrogramMColourChanged(int)));
|
Chris@1097
|
163 connect(colour3DColour, SIGNAL(currentIndexChanged(int)),
|
Chris@1097
|
164 this, SLOT(colour3DColourChanged(int)));
|
Chris@702
|
165
|
Chris@0
|
166 m_tuningFrequency = prefs->getTuningFrequency();
|
Chris@0
|
167
|
Chris@0
|
168 QDoubleSpinBox *frequency = new QDoubleSpinBox;
|
Chris@0
|
169 frequency->setMinimum(100.0);
|
Chris@0
|
170 frequency->setMaximum(5000.0);
|
Chris@0
|
171 frequency->setSuffix(" Hz");
|
Chris@0
|
172 frequency->setSingleStep(1);
|
Chris@0
|
173 frequency->setValue(m_tuningFrequency);
|
Chris@0
|
174 frequency->setDecimals(2);
|
Chris@0
|
175
|
Chris@0
|
176 connect(frequency, SIGNAL(valueChanged(double)),
|
Chris@0
|
177 this, SLOT(tuningFrequencyChanged(double)));
|
Chris@0
|
178
|
Chris@702
|
179 QComboBox *octaveSystem = new QComboBox;
|
Chris@702
|
180 int oct = prefs->getPropertyRangeAndValue
|
Chris@702
|
181 ("Octave Numbering System", &min, &max, &deflt);
|
Chris@702
|
182 m_octaveSystem = oct;
|
Chris@702
|
183 for (i = min; i <= max; ++i) {
|
Chris@702
|
184 octaveSystem->addItem(prefs->getPropertyValueLabel
|
Chris@702
|
185 ("Octave Numbering System", i));
|
Chris@702
|
186 }
|
Chris@702
|
187 octaveSystem->setCurrentIndex(oct);
|
Chris@702
|
188
|
Chris@702
|
189 connect(octaveSystem, SIGNAL(currentIndexChanged(int)),
|
Chris@702
|
190 this, SLOT(octaveSystemChanged(int)));
|
Chris@702
|
191
|
Chris@263
|
192 settings.beginGroup("Preferences");
|
Chris@1397
|
193
|
Chris@1397
|
194 QComboBox *audioImplementation = new QComboBox;
|
Chris@1397
|
195 connect(audioImplementation, SIGNAL(currentIndexChanged(int)),
|
Chris@1397
|
196 this, SLOT(audioImplementationChanged(int)));
|
Chris@1397
|
197
|
Chris@1397
|
198 m_audioPlaybackDeviceCombo = new QComboBox;
|
Chris@1397
|
199 connect(m_audioPlaybackDeviceCombo, SIGNAL(currentIndexChanged(int)),
|
Chris@1397
|
200 this, SLOT(audioPlaybackDeviceChanged(int)));
|
Chris@1397
|
201
|
Chris@1397
|
202 m_audioRecordDeviceCombo = new QComboBox;
|
Chris@1397
|
203 connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)),
|
Chris@1397
|
204 this, SLOT(audioRecordDeviceChanged(int)));
|
Chris@1397
|
205
|
Chris@1397
|
206 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
|
Chris@1397
|
207 QString implementationName = settings.value("audio-target", "").toString();
|
Chris@1397
|
208 if (implementationName == "auto") implementationName = "";
|
Chris@1397
|
209 audioImplementation->addItem(tr("(auto)"));
|
Chris@1397
|
210 m_audioImplementation = 0;
|
Chris@1397
|
211 for (int i = 0; in_range_for(names, i); ++i) {
|
Chris@1397
|
212 audioImplementation->addItem
|
Chris@1397
|
213 (breakfastquay::AudioFactory::getImplementationDescription(names[i]).
|
Chris@1397
|
214 c_str());
|
Chris@1397
|
215 if (implementationName.toStdString() == names[i]) {
|
Chris@1397
|
216 audioImplementation->setCurrentIndex(i+1);
|
Chris@1397
|
217 m_audioImplementation = i+1;
|
Chris@1397
|
218 }
|
Chris@1397
|
219 }
|
Chris@263
|
220 settings.endGroup();
|
Chris@263
|
221
|
Chris@1397
|
222 rebuildDeviceCombos();
|
Chris@1413
|
223 m_audioDeviceChanged = false; // the rebuild will have changed this
|
Chris@32
|
224
|
Chris@180
|
225 QCheckBox *resampleOnLoad = new QCheckBox;
|
Chris@180
|
226 m_resampleOnLoad = prefs->getResampleOnLoad();
|
Chris@180
|
227 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
|
Chris@180
|
228 Qt::Unchecked);
|
Chris@180
|
229 connect(resampleOnLoad, SIGNAL(stateChanged(int)),
|
Chris@180
|
230 this, SLOT(resampleOnLoadChanged(int)));
|
Chris@180
|
231
|
Chris@1379
|
232 QCheckBox *gaplessMode = new QCheckBox;
|
Chris@1379
|
233 m_gapless = prefs->getUseGaplessMode();
|
Chris@1379
|
234 gaplessMode->setCheckState(m_gapless ? Qt::Checked : Qt::Unchecked);
|
Chris@1379
|
235 connect(gaplessMode, SIGNAL(stateChanged(int)),
|
Chris@1379
|
236 this, SLOT(gaplessModeChanged(int)));
|
Chris@1379
|
237
|
Chris@180
|
238 m_tempDirRootEdit = new QLineEdit;
|
Chris@180
|
239 QString dir = prefs->getTemporaryDirectoryRoot();
|
Chris@180
|
240 m_tempDirRoot = dir;
|
Chris@180
|
241 dir.replace("$HOME", tr("<home directory>"));
|
Chris@180
|
242 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
243 m_tempDirRootEdit->setReadOnly(true);
|
Chris@180
|
244 QPushButton *tempDirButton = new QPushButton;
|
Chris@180
|
245 tempDirButton->setIcon(IconLoader().load("fileopen"));
|
Chris@180
|
246 connect(tempDirButton, SIGNAL(clicked()),
|
Chris@180
|
247 this, SLOT(tempDirButtonClicked()));
|
Chris@180
|
248 tempDirButton->setFixedSize(QSize(24, 24));
|
Chris@180
|
249
|
Chris@237
|
250 QCheckBox *showSplash = new QCheckBox;
|
Chris@237
|
251 m_showSplash = prefs->getShowSplash();
|
Chris@237
|
252 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked);
|
Chris@237
|
253 connect(showSplash, SIGNAL(stateChanged(int)),
|
Chris@237
|
254 this, SLOT(showSplashChanged(int)));
|
Chris@237
|
255
|
Chris@1092
|
256 #ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS
|
Chris@180
|
257 QComboBox *bgMode = new QComboBox;
|
Chris@180
|
258 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
|
Chris@180
|
259 &deflt);
|
Chris@180
|
260 m_backgroundMode = bg;
|
Chris@180
|
261 for (i = min; i <= max; ++i) {
|
Chris@180
|
262 bgMode->addItem(prefs->getPropertyValueLabel("Background Mode", i));
|
Chris@180
|
263 }
|
Chris@180
|
264 bgMode->setCurrentIndex(bg);
|
Chris@180
|
265
|
Chris@180
|
266 connect(bgMode, SIGNAL(currentIndexChanged(int)),
|
Chris@180
|
267 this, SLOT(backgroundModeChanged(int)));
|
Chris@237
|
268 #endif
|
Chris@180
|
269
|
Chris@658
|
270 settings.beginGroup("Preferences");
|
Chris@686
|
271
|
Chris@950
|
272 #ifdef Q_OS_MAC
|
Chris@950
|
273 m_retina = settings.value("scaledHiDpi", true).toBool();
|
Chris@950
|
274 QCheckBox *retina = new QCheckBox;
|
Chris@950
|
275 retina->setCheckState(m_retina ? Qt::Checked : Qt::Unchecked);
|
Chris@950
|
276 connect(retina, SIGNAL(stateChanged(int)), this, SLOT(retinaChanged(int)));
|
Chris@950
|
277 #else
|
Chris@950
|
278 m_retina = false;
|
Chris@950
|
279 #endif
|
Chris@950
|
280
|
Chris@658
|
281 QString userLocale = settings.value("locale", "").toString();
|
Chris@658
|
282 m_currentLocale = userLocale;
|
Chris@686
|
283
|
Chris@686
|
284 QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
|
Chris@686
|
285 m_networkPermission = settings.value(permishTag, false).toBool();
|
Chris@686
|
286
|
Chris@658
|
287 settings.endGroup();
|
Chris@658
|
288
|
Chris@658
|
289 QComboBox *locale = new QComboBox;
|
Chris@658
|
290 QStringList localeFiles = QDir(":i18n").entryList(QStringList() << "*.qm");
|
Chris@658
|
291 locale->addItem(tr("Follow system locale"));
|
Chris@658
|
292 m_locales.push_back("");
|
Chris@658
|
293 if (userLocale == "") {
|
Chris@658
|
294 locale->setCurrentIndex(0);
|
Chris@658
|
295 }
|
Chris@658
|
296 foreach (QString f, localeFiles) {
|
Chris@658
|
297 QString f0 = f;
|
Chris@658
|
298 f.replace("sonic-visualiser_", "").replace(".qm", "");
|
Chris@658
|
299 if (f == f0) { // our expectations about filename format were not met
|
Chris@665
|
300 cerr << "INFO: Unexpected filename " << f << " in i18n resource directory" << endl;
|
Chris@658
|
301 } else {
|
Chris@658
|
302 m_locales.push_back(f);
|
Chris@658
|
303 QString displayText;
|
Chris@658
|
304 // Add new translations here
|
Chris@658
|
305 if (f == "ru") displayText = tr("Russian");
|
Chris@658
|
306 else if (f == "en_GB") displayText = tr("British English");
|
Chris@658
|
307 else if (f == "en_US") displayText = tr("American English");
|
Chris@658
|
308 else if (f == "cs_CZ") displayText = tr("Czech");
|
Chris@658
|
309 else displayText = f;
|
Chris@658
|
310 locale->addItem(QString("%1 [%2]").arg(displayText).arg(f));
|
Chris@658
|
311 if (userLocale == f) {
|
Chris@658
|
312 locale->setCurrentIndex(locale->count() - 1);
|
Chris@658
|
313 }
|
Chris@658
|
314 }
|
Chris@658
|
315 }
|
Chris@658
|
316 connect(locale, SIGNAL(currentIndexChanged(int)),
|
Chris@658
|
317 this, SLOT(localeChanged(int)));
|
Chris@658
|
318
|
Chris@686
|
319 QCheckBox *networkPermish = new QCheckBox;
|
Chris@686
|
320 networkPermish->setCheckState(m_networkPermission ? Qt::Checked : Qt::Unchecked);
|
Chris@686
|
321 connect(networkPermish, SIGNAL(stateChanged(int)),
|
Chris@686
|
322 this, SLOT(networkPermissionChanged(int)));
|
Chris@686
|
323
|
Chris@225
|
324 QSpinBox *fontSize = new QSpinBox;
|
Chris@225
|
325 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
|
Chris@225
|
326 &deflt);
|
Chris@234
|
327 m_viewFontSize = fs;
|
Chris@225
|
328 fontSize->setMinimum(min);
|
Chris@225
|
329 fontSize->setMaximum(max);
|
Chris@225
|
330 fontSize->setSuffix(" pt");
|
Chris@225
|
331 fontSize->setSingleStep(1);
|
Chris@225
|
332 fontSize->setValue(fs);
|
Chris@225
|
333
|
Chris@225
|
334 connect(fontSize, SIGNAL(valueChanged(int)),
|
Chris@225
|
335 this, SLOT(viewFontSizeChanged(int)));
|
Chris@225
|
336
|
Chris@337
|
337 QComboBox *ttMode = new QComboBox;
|
Chris@337
|
338 int tt = prefs->getPropertyRangeAndValue("Time To Text Mode", &min, &max,
|
Chris@337
|
339 &deflt);
|
Chris@337
|
340 m_timeToTextMode = tt;
|
Chris@337
|
341 for (i = min; i <= max; ++i) {
|
Chris@337
|
342 ttMode->addItem(prefs->getPropertyValueLabel("Time To Text Mode", i));
|
Chris@337
|
343 }
|
Chris@337
|
344 ttMode->setCurrentIndex(tt);
|
Chris@337
|
345
|
Chris@337
|
346 connect(ttMode, SIGNAL(currentIndexChanged(int)),
|
Chris@337
|
347 this, SLOT(timeToTextModeChanged(int)));
|
Chris@337
|
348
|
Chris@906
|
349 QCheckBox *hms = new QCheckBox;
|
Chris@906
|
350 int showHMS = prefs->getPropertyRangeAndValue
|
Chris@906
|
351 ("Show Hours And Minutes", &min, &max, &deflt);
|
Chris@906
|
352 m_showHMS = (showHMS != 0);
|
Chris@906
|
353 hms->setCheckState(m_showHMS ? Qt::Checked : Qt::Unchecked);
|
Chris@906
|
354 connect(hms, SIGNAL(stateChanged(int)),
|
Chris@906
|
355 this, SLOT(showHMSChanged(int)));
|
Chris@906
|
356
|
Chris@180
|
357 // General tab
|
Chris@180
|
358
|
Chris@180
|
359 QFrame *frame = new QFrame;
|
Chris@180
|
360
|
Chris@180
|
361 QGridLayout *subgrid = new QGridLayout;
|
Chris@180
|
362 frame->setLayout(subgrid);
|
Chris@180
|
363
|
Chris@0
|
364 int row = 0;
|
Chris@0
|
365
|
Chris@658
|
366 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("User interface language"))),
|
Chris@658
|
367 row, 0);
|
Chris@658
|
368 subgrid->addWidget(locale, row++, 1, 1, 1);
|
Chris@658
|
369
|
Chris@686
|
370 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("Allow network usage"))),
|
Chris@686
|
371 row, 0);
|
Chris@686
|
372 subgrid->addWidget(networkPermish, row++, 1, 1, 1);
|
Chris@686
|
373
|
Chris@0
|
374 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
375 ("Temporary Directory Root"))),
|
Chris@263
|
376 row, 0);
|
Chris@263
|
377 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
|
Chris@263
|
378 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
|
Chris@263
|
379 row++;
|
Chris@263
|
380
|
Chris@263
|
381 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
382 ("Resample On Load"))),
|
Chris@263
|
383 row, 0);
|
Chris@263
|
384 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
|
Chris@263
|
385
|
Chris@1379
|
386 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@1379
|
387 ("Use Gapless Mode"))),
|
Chris@1379
|
388 row, 0);
|
Chris@1379
|
389 subgrid->addWidget(gaplessMode, row++, 1, 1, 1);
|
Chris@1379
|
390
|
Chris@1397
|
391 subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0);
|
Chris@1397
|
392 subgrid->addWidget(audioImplementation, row++, 1, 1, 2);
|
Chris@1397
|
393
|
Chris@1397
|
394 subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0);
|
Chris@1397
|
395 subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2);
|
Chris@1397
|
396
|
Chris@1397
|
397 subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0);
|
Chris@1397
|
398 subgrid->addWidget(m_audioRecordDeviceCombo, row++, 1, 1, 2);
|
Chris@263
|
399
|
Chris@263
|
400 subgrid->setRowStretch(row, 10);
|
Chris@263
|
401
|
Chris@436
|
402 m_tabOrdering[GeneralTab] = m_tabs->count();
|
Chris@436
|
403 m_tabs->addTab(frame, tr("&General"));
|
Chris@263
|
404
|
Chris@263
|
405 // Appearance tab
|
Chris@263
|
406
|
Chris@263
|
407 frame = new QFrame;
|
Chris@263
|
408 subgrid = new QGridLayout;
|
Chris@263
|
409 frame->setLayout(subgrid);
|
Chris@263
|
410 row = 0;
|
Chris@263
|
411
|
Chris@263
|
412 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@906
|
413 ("Show Splash Screen"))),
|
Chris@906
|
414 row, 0);
|
Chris@906
|
415 subgrid->addWidget(showSplash, row++, 1, 1, 1);
|
Chris@906
|
416
|
Chris@950
|
417 #ifdef Q_OS_MAC
|
Chris@950
|
418 if (devicePixelRatio() > 1) {
|
Chris@950
|
419 subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0);
|
Chris@950
|
420 subgrid->addWidget(retina, row++, 1, 1, 1);
|
Chris@950
|
421 }
|
Chris@950
|
422 #endif
|
Chris@950
|
423
|
Chris@906
|
424 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
425 ("Property Box Layout"))),
|
Chris@0
|
426 row, 0);
|
Chris@0
|
427 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
|
Chris@0
|
428
|
Chris@1098
|
429 subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")),
|
Chris@1096
|
430 row, 0);
|
Chris@1096
|
431 subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2);
|
Chris@1096
|
432
|
Chris@1098
|
433 subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")),
|
Chris@1096
|
434 row, 0);
|
Chris@1096
|
435 subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2);
|
Chris@1096
|
436
|
Chris@1098
|
437 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")),
|
Chris@1097
|
438 row, 0);
|
Chris@1097
|
439 subgrid->addWidget(colour3DColour, row++, 1, 1, 2);
|
Chris@1097
|
440
|
Chris@1092
|
441 #ifdef NOT_DEFINED // see earlier
|
Chris@0
|
442 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
443 ("Background Mode"))),
|
Chris@0
|
444 row, 0);
|
Chris@180
|
445 subgrid->addWidget(bgMode, row++, 1, 1, 2);
|
Chris@242
|
446 #endif
|
Chris@180
|
447
|
Chris@180
|
448 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@225
|
449 ("View Font Size"))),
|
Chris@225
|
450 row, 0);
|
Chris@225
|
451 subgrid->addWidget(fontSize, row++, 1, 1, 2);
|
Chris@225
|
452
|
Chris@225
|
453 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@337
|
454 ("Time To Text Mode"))),
|
Chris@337
|
455 row, 0);
|
Chris@337
|
456 subgrid->addWidget(ttMode, row++, 1, 1, 2);
|
Chris@337
|
457
|
Chris@337
|
458 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@906
|
459 ("Show Hours And Minutes"))),
|
Chris@237
|
460 row, 0);
|
Chris@906
|
461 subgrid->addWidget(hms, row++, 1, 1, 1);
|
Chris@237
|
462
|
Chris@180
|
463 subgrid->setRowStretch(row, 10);
|
Chris@180
|
464
|
Chris@436
|
465 m_tabOrdering[AppearanceTab] = m_tabs->count();
|
Chris@436
|
466 m_tabs->addTab(frame, tr("&Appearance"));
|
Chris@180
|
467
|
Chris@180
|
468 // Analysis tab
|
Chris@180
|
469
|
Chris@180
|
470 frame = new QFrame;
|
Chris@180
|
471 subgrid = new QGridLayout;
|
Chris@180
|
472 frame->setLayout(subgrid);
|
Chris@180
|
473 row = 0;
|
Chris@180
|
474
|
Chris@180
|
475 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
476 ("Tuning Frequency"))),
|
Chris@180
|
477 row, 0);
|
Chris@180
|
478 subgrid->addWidget(frequency, row++, 1, 1, 2);
|
Chris@180
|
479
|
Chris@702
|
480 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@702
|
481 ("Octave Numbering System"))),
|
Chris@702
|
482 row, 0);
|
Chris@702
|
483 subgrid->addWidget(octaveSystem, row++, 1, 1, 2);
|
Chris@702
|
484
|
Chris@0
|
485 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
|
Chris@299
|
486 ("Spectrogram Y Smoothing")),
|
Chris@115
|
487 row, 0);
|
Chris@115
|
488 subgrid->addWidget(smoothing, row++, 1, 1, 2);
|
Chris@0
|
489
|
Chris@299
|
490 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
|
Chris@299
|
491 ("Spectrogram X Smoothing")),
|
Chris@299
|
492 row, 0);
|
Chris@299
|
493 subgrid->addWidget(xsmoothing, row++, 1, 1, 2);
|
Chris@299
|
494
|
Chris@0
|
495 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
496 ("Window Type"))),
|
Chris@0
|
497 row, 0);
|
Chris@9
|
498 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
|
Chris@1275
|
499
|
Chris@9
|
500 subgrid->setRowStretch(row, 10);
|
Chris@9
|
501 row++;
|
Chris@1275
|
502
|
Chris@1275
|
503 subgrid->addWidget(new QLabel(tr("Run Vamp plugins in separate process:")),
|
Chris@1275
|
504 row, 0);
|
Chris@1275
|
505 subgrid->addWidget(vampProcessSeparation, row++, 1, 1, 1);
|
Chris@0
|
506
|
Chris@180
|
507 subgrid->setRowStretch(row, 10);
|
Chris@180
|
508
|
Chris@436
|
509 m_tabOrdering[AnalysisTab] = m_tabs->count();
|
Chris@436
|
510 m_tabs->addTab(frame, tr("Anal&ysis"));
|
Chris@436
|
511
|
Chris@436
|
512 // Template tab
|
Chris@436
|
513
|
Chris@436
|
514 frame = new QFrame;
|
Chris@436
|
515 subgrid = new QGridLayout;
|
Chris@436
|
516 frame->setLayout(subgrid);
|
Chris@436
|
517 row = 0;
|
Chris@436
|
518
|
Chris@436
|
519 subgrid->addWidget(new QLabel(tr("Default session template for audio files:")), row++, 0);
|
Chris@436
|
520
|
Chris@436
|
521 QListWidget *lw = new QListWidget();
|
Chris@436
|
522 subgrid->addWidget(lw, row, 0);
|
Chris@436
|
523 subgrid->setRowStretch(row, 10);
|
Chris@436
|
524 row++;
|
Chris@436
|
525
|
Chris@1425
|
526 subgrid->addWidget(new QLabel(tr("(Use \"%1\" in the File menu to add to these.)")
|
Chris@1425
|
527 .arg(tr("Export Session as Template..."))),
|
Chris@1425
|
528 row++, 0);
|
Chris@1425
|
529
|
Chris@436
|
530 settings.beginGroup("MainWindow");
|
Chris@436
|
531 m_currentTemplate = settings.value("sessiontemplate", "").toString();
|
Chris@436
|
532 settings.endGroup();
|
Chris@436
|
533
|
Chris@455
|
534 lw->addItem(tr("Standard Waveform"));
|
Chris@436
|
535 if (m_currentTemplate == "" || m_currentTemplate == "default") {
|
Chris@436
|
536 lw->setCurrentRow(lw->count()-1);
|
Chris@436
|
537 }
|
Chris@436
|
538 m_templates.push_back("");
|
Chris@436
|
539
|
Chris@436
|
540 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
|
Chris@436
|
541
|
Chris@1397
|
542 set<QString> byName;
|
Chris@436
|
543 foreach (QString t, templates) {
|
Chris@436
|
544 byName.insert(QFileInfo(t).baseName());
|
Chris@436
|
545 }
|
Chris@436
|
546
|
Chris@436
|
547 foreach (QString t, byName) {
|
Chris@436
|
548 if (t.toLower() == "default") continue;
|
Chris@436
|
549 m_templates.push_back(t);
|
Chris@436
|
550 lw->addItem(t);
|
Chris@436
|
551 if (m_currentTemplate == t) {
|
Chris@436
|
552 lw->setCurrentRow(lw->count()-1);
|
Chris@436
|
553 }
|
Chris@436
|
554 }
|
Chris@436
|
555
|
Chris@436
|
556 connect(lw, SIGNAL(currentRowChanged(int)), this, SLOT(defaultTemplateChanged(int)));
|
Chris@436
|
557
|
Chris@436
|
558 m_tabOrdering[TemplateTab] = m_tabs->count();
|
Chris@436
|
559 m_tabs->addTab(frame, tr("Session &Template"));
|
Chris@180
|
560
|
Chris@163
|
561 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
|
Chris@163
|
562 grid->addWidget(bb, 1, 0);
|
Chris@0
|
563
|
Chris@0
|
564 QPushButton *ok = new QPushButton(tr("OK"));
|
Chris@0
|
565 QPushButton *cancel = new QPushButton(tr("Cancel"));
|
Chris@163
|
566 bb->addButton(ok, QDialogButtonBox::AcceptRole);
|
Chris@163
|
567 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
|
Chris@163
|
568 bb->addButton(cancel, QDialogButtonBox::RejectRole);
|
Chris@0
|
569 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
|
Chris@0
|
570 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
|
Chris@0
|
571 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
Chris@0
|
572
|
Chris@0
|
573 m_applyButton->setEnabled(false);
|
Chris@0
|
574 }
|
Chris@0
|
575
|
Chris@0
|
576 PreferencesDialog::~PreferencesDialog()
|
Chris@0
|
577 {
|
Chris@438
|
578 SVDEBUG << "PreferencesDialog::~PreferencesDialog()" << endl;
|
Chris@0
|
579 }
|
Chris@0
|
580
|
Chris@0
|
581 void
|
Chris@1397
|
582 PreferencesDialog::rebuildDeviceCombos()
|
Chris@1397
|
583 {
|
Chris@1397
|
584 QSettings settings;
|
Chris@1397
|
585 settings.beginGroup("Preferences");
|
Chris@1397
|
586
|
Chris@1397
|
587 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
|
Chris@1397
|
588 string implementationName;
|
Chris@1397
|
589 if (in_range_for(names, m_audioImplementation-1)) {
|
Chris@1397
|
590 implementationName = names[m_audioImplementation-1];
|
Chris@1397
|
591 }
|
Chris@1397
|
592
|
Chris@1397
|
593 QString suffix;
|
Chris@1397
|
594 if (implementationName != "") {
|
Chris@1397
|
595 suffix = "-" + QString(implementationName.c_str());
|
Chris@1397
|
596 }
|
Chris@1397
|
597
|
Chris@1397
|
598 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
|
Chris@1397
|
599 QString playbackDeviceName = settings.value
|
Chris@1397
|
600 ("audio-playback-device" + suffix, "").toString();
|
Chris@1417
|
601 m_audioPlaybackDeviceCombo->clear();
|
Chris@1397
|
602 m_audioPlaybackDeviceCombo->addItem(tr("(auto)"));
|
Chris@1397
|
603 m_audioPlaybackDeviceCombo->setCurrentIndex(0);
|
Chris@1397
|
604 m_audioPlaybackDevice = 0;
|
Chris@1397
|
605 for (int i = 0; in_range_for(names, i); ++i) {
|
Chris@1397
|
606 m_audioPlaybackDeviceCombo->addItem(names[i].c_str());
|
Chris@1397
|
607 if (playbackDeviceName.toStdString() == names[i]) {
|
Chris@1397
|
608 m_audioPlaybackDeviceCombo->setCurrentIndex(i+1);
|
Chris@1397
|
609 m_audioPlaybackDevice = i+1;
|
Chris@1397
|
610 }
|
Chris@1397
|
611 }
|
Chris@1397
|
612
|
Chris@1397
|
613 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
|
Chris@1397
|
614 QString recordDeviceName = settings.value
|
Chris@1397
|
615 ("audio-record-device" + suffix, "").toString();
|
Chris@1417
|
616 m_audioRecordDeviceCombo->clear();
|
Chris@1397
|
617 m_audioRecordDeviceCombo->addItem(tr("(auto)"));
|
Chris@1397
|
618 m_audioRecordDeviceCombo->setCurrentIndex(0);
|
Chris@1397
|
619 m_audioRecordDevice = 0;
|
Chris@1397
|
620 for (int i = 0; in_range_for(names, i); ++i) {
|
Chris@1397
|
621 m_audioRecordDeviceCombo->addItem(names[i].c_str());
|
Chris@1397
|
622 if (recordDeviceName.toStdString() == names[i]) {
|
Chris@1397
|
623 m_audioRecordDeviceCombo->setCurrentIndex(i+1);
|
Chris@1397
|
624 m_audioRecordDevice = i+1;
|
Chris@1397
|
625 }
|
Chris@1397
|
626 }
|
Chris@1397
|
627
|
Chris@1397
|
628 settings.endGroup();
|
Chris@1397
|
629 }
|
Chris@1397
|
630
|
Chris@1397
|
631 void
|
Chris@436
|
632 PreferencesDialog::switchToTab(Tab t)
|
Chris@436
|
633 {
|
Chris@436
|
634 if (m_tabOrdering.contains(t)) {
|
Chris@436
|
635 m_tabs->setCurrentIndex(m_tabOrdering[t]);
|
Chris@436
|
636 }
|
Chris@436
|
637 }
|
Chris@436
|
638
|
Chris@436
|
639 void
|
Chris@9
|
640 PreferencesDialog::windowTypeChanged(WindowType type)
|
Chris@0
|
641 {
|
Chris@0
|
642 m_windowType = type;
|
Chris@0
|
643 m_applyButton->setEnabled(true);
|
Chris@0
|
644 }
|
Chris@0
|
645
|
Chris@0
|
646 void
|
Chris@115
|
647 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
|
Chris@0
|
648 {
|
Chris@115
|
649 m_spectrogramSmoothing = smoothing;
|
Chris@0
|
650 m_applyButton->setEnabled(true);
|
Chris@0
|
651 }
|
Chris@0
|
652
|
Chris@0
|
653 void
|
Chris@299
|
654 PreferencesDialog::spectrogramXSmoothingChanged(int smoothing)
|
Chris@299
|
655 {
|
Chris@299
|
656 m_spectrogramXSmoothing = smoothing;
|
Chris@299
|
657 m_applyButton->setEnabled(true);
|
Chris@299
|
658 }
|
Chris@299
|
659
|
Chris@299
|
660 void
|
Chris@1096
|
661 PreferencesDialog::spectrogramGColourChanged(int colour)
|
Chris@1096
|
662 {
|
Chris@1096
|
663 m_spectrogramGColour = colour;
|
Chris@1096
|
664 m_applyButton->setEnabled(true);
|
Chris@1096
|
665 }
|
Chris@1096
|
666
|
Chris@1096
|
667 void
|
Chris@1096
|
668 PreferencesDialog::spectrogramMColourChanged(int colour)
|
Chris@1096
|
669 {
|
Chris@1096
|
670 m_spectrogramMColour = colour;
|
Chris@1096
|
671 m_applyButton->setEnabled(true);
|
Chris@1096
|
672 }
|
Chris@1096
|
673
|
Chris@1096
|
674 void
|
Chris@1097
|
675 PreferencesDialog::colour3DColourChanged(int colour)
|
Chris@1097
|
676 {
|
Chris@1097
|
677 m_colour3DColour = colour;
|
Chris@1097
|
678 m_applyButton->setEnabled(true);
|
Chris@1097
|
679 }
|
Chris@1097
|
680
|
Chris@1097
|
681 void
|
Chris@0
|
682 PreferencesDialog::propertyLayoutChanged(int layout)
|
Chris@0
|
683 {
|
Chris@0
|
684 m_propertyLayout = layout;
|
Chris@0
|
685 m_applyButton->setEnabled(true);
|
Chris@0
|
686 }
|
Chris@0
|
687
|
Chris@0
|
688 void
|
Chris@0
|
689 PreferencesDialog::tuningFrequencyChanged(double freq)
|
Chris@0
|
690 {
|
Chris@0
|
691 m_tuningFrequency = freq;
|
Chris@0
|
692 m_applyButton->setEnabled(true);
|
Chris@0
|
693 }
|
Chris@0
|
694
|
Chris@0
|
695 void
|
Chris@1397
|
696 PreferencesDialog::audioImplementationChanged(int s)
|
Chris@263
|
697 {
|
Chris@1397
|
698 if (m_audioImplementation != s) {
|
Chris@1397
|
699 m_audioImplementation = s;
|
Chris@1397
|
700 rebuildDeviceCombos();
|
Chris@1397
|
701 m_applyButton->setEnabled(true);
|
Chris@1413
|
702 m_audioDeviceChanged = true;
|
Chris@1397
|
703 }
|
Chris@1397
|
704 }
|
Chris@1397
|
705
|
Chris@1397
|
706 void
|
Chris@1397
|
707 PreferencesDialog::audioPlaybackDeviceChanged(int s)
|
Chris@1397
|
708 {
|
Chris@1397
|
709 if (m_audioPlaybackDevice != s) {
|
Chris@1397
|
710 m_audioPlaybackDevice = s;
|
Chris@1397
|
711 m_applyButton->setEnabled(true);
|
Chris@1413
|
712 m_audioDeviceChanged = true;
|
Chris@1397
|
713 }
|
Chris@1397
|
714 }
|
Chris@1397
|
715
|
Chris@1397
|
716 void
|
Chris@1397
|
717 PreferencesDialog::audioRecordDeviceChanged(int s)
|
Chris@1397
|
718 {
|
Chris@1397
|
719 if (m_audioRecordDevice != s) {
|
Chris@1397
|
720 m_audioRecordDevice = s;
|
Chris@1397
|
721 m_applyButton->setEnabled(true);
|
Chris@1413
|
722 m_audioDeviceChanged = true;
|
Chris@1397
|
723 }
|
Chris@263
|
724 }
|
Chris@263
|
725
|
Chris@263
|
726 void
|
Chris@180
|
727 PreferencesDialog::resampleOnLoadChanged(int state)
|
Chris@180
|
728 {
|
Chris@180
|
729 m_resampleOnLoad = (state == Qt::Checked);
|
Chris@180
|
730 m_applyButton->setEnabled(true);
|
Chris@180
|
731 m_changesOnRestart = true;
|
Chris@180
|
732 }
|
Chris@180
|
733
|
Chris@180
|
734 void
|
Chris@1379
|
735 PreferencesDialog::gaplessModeChanged(int state)
|
Chris@1379
|
736 {
|
Chris@1379
|
737 m_gapless = (state == Qt::Checked);
|
Chris@1379
|
738 m_applyButton->setEnabled(true);
|
Chris@1379
|
739 }
|
Chris@1379
|
740
|
Chris@1379
|
741 void
|
Chris@1275
|
742 PreferencesDialog::vampProcessSeparationChanged(int state)
|
Chris@1275
|
743 {
|
Chris@1275
|
744 m_runPluginsInProcess = (state == Qt::Unchecked);
|
Chris@1275
|
745 m_applyButton->setEnabled(true);
|
Chris@1275
|
746 m_changesOnRestart = true;
|
Chris@1275
|
747 }
|
Chris@1275
|
748
|
Chris@1275
|
749 void
|
Chris@686
|
750 PreferencesDialog::networkPermissionChanged(int state)
|
Chris@686
|
751 {
|
Chris@686
|
752 m_networkPermission = (state == Qt::Checked);
|
Chris@686
|
753 m_applyButton->setEnabled(true);
|
Chris@686
|
754 m_changesOnRestart = true;
|
Chris@686
|
755 }
|
Chris@686
|
756
|
Chris@686
|
757 void
|
Chris@950
|
758 PreferencesDialog::retinaChanged(int state)
|
Chris@950
|
759 {
|
Chris@950
|
760 m_retina = (state == Qt::Checked);
|
Chris@950
|
761 m_applyButton->setEnabled(true);
|
Chris@950
|
762 // Does not require a restart
|
Chris@950
|
763 }
|
Chris@950
|
764
|
Chris@950
|
765 void
|
Chris@237
|
766 PreferencesDialog::showSplashChanged(int state)
|
Chris@237
|
767 {
|
Chris@237
|
768 m_showSplash = (state == Qt::Checked);
|
Chris@237
|
769 m_applyButton->setEnabled(true);
|
Chris@237
|
770 m_changesOnRestart = true;
|
Chris@237
|
771 }
|
Chris@237
|
772
|
Chris@237
|
773 void
|
Chris@436
|
774 PreferencesDialog::defaultTemplateChanged(int i)
|
Chris@436
|
775 {
|
Chris@436
|
776 m_currentTemplate = m_templates[i];
|
Chris@436
|
777 m_applyButton->setEnabled(true);
|
Chris@436
|
778 }
|
Chris@436
|
779
|
Chris@436
|
780 void
|
Chris@658
|
781 PreferencesDialog::localeChanged(int i)
|
Chris@658
|
782 {
|
Chris@658
|
783 m_currentLocale = m_locales[i];
|
Chris@658
|
784 m_applyButton->setEnabled(true);
|
Chris@658
|
785 m_changesOnRestart = true;
|
Chris@658
|
786 }
|
Chris@658
|
787
|
Chris@658
|
788 void
|
Chris@180
|
789 PreferencesDialog::tempDirRootChanged(QString r)
|
Chris@180
|
790 {
|
Chris@180
|
791 m_tempDirRoot = r;
|
Chris@180
|
792 m_applyButton->setEnabled(true);
|
Chris@180
|
793 }
|
Chris@180
|
794
|
Chris@180
|
795 void
|
Chris@180
|
796 PreferencesDialog::tempDirButtonClicked()
|
Chris@180
|
797 {
|
Chris@180
|
798 QString dir = QFileDialog::getExistingDirectory
|
Chris@180
|
799 (this, tr("Select a directory to create cache subdirectory in"),
|
Chris@180
|
800 m_tempDirRoot);
|
Chris@180
|
801 if (dir == "") return;
|
Chris@180
|
802 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
803 tempDirRootChanged(dir);
|
Chris@180
|
804 m_changesOnRestart = true;
|
Chris@180
|
805 }
|
Chris@180
|
806
|
Chris@180
|
807 void
|
Chris@180
|
808 PreferencesDialog::backgroundModeChanged(int mode)
|
Chris@180
|
809 {
|
Chris@180
|
810 m_backgroundMode = mode;
|
Chris@180
|
811 m_applyButton->setEnabled(true);
|
Chris@180
|
812 m_changesOnRestart = true;
|
Chris@180
|
813 }
|
Chris@180
|
814
|
Chris@180
|
815 void
|
Chris@337
|
816 PreferencesDialog::timeToTextModeChanged(int mode)
|
Chris@337
|
817 {
|
Chris@337
|
818 m_timeToTextMode = mode;
|
Chris@337
|
819 m_applyButton->setEnabled(true);
|
Chris@337
|
820 }
|
Chris@337
|
821
|
Chris@337
|
822 void
|
Chris@906
|
823 PreferencesDialog::showHMSChanged(int state)
|
Chris@906
|
824 {
|
Chris@906
|
825 m_showHMS = (state == Qt::Checked);
|
Chris@906
|
826 m_applyButton->setEnabled(true);
|
Chris@906
|
827 }
|
Chris@906
|
828
|
Chris@906
|
829 void
|
Chris@702
|
830 PreferencesDialog::octaveSystemChanged(int system)
|
Chris@702
|
831 {
|
Chris@702
|
832 m_octaveSystem = system;
|
Chris@702
|
833 m_applyButton->setEnabled(true);
|
Chris@702
|
834 }
|
Chris@702
|
835
|
Chris@702
|
836 void
|
Chris@225
|
837 PreferencesDialog::viewFontSizeChanged(int sz)
|
Chris@225
|
838 {
|
Chris@225
|
839 m_viewFontSize = sz;
|
Chris@225
|
840 m_applyButton->setEnabled(true);
|
Chris@225
|
841 }
|
Chris@225
|
842
|
Chris@225
|
843 void
|
Chris@0
|
844 PreferencesDialog::okClicked()
|
Chris@0
|
845 {
|
Chris@0
|
846 applyClicked();
|
Chris@0
|
847 accept();
|
Chris@0
|
848 }
|
Chris@0
|
849
|
Chris@0
|
850 void
|
Chris@0
|
851 PreferencesDialog::applyClicked()
|
Chris@0
|
852 {
|
Chris@0
|
853 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
854 prefs->setWindowType(WindowType(m_windowType));
|
Chris@115
|
855 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
|
Chris@115
|
856 (m_spectrogramSmoothing));
|
Chris@299
|
857 prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing
|
Chris@299
|
858 (m_spectrogramXSmoothing));
|
Chris@0
|
859 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
|
Chris@0
|
860 (m_propertyLayout));
|
Chris@0
|
861 prefs->setTuningFrequency(m_tuningFrequency);
|
Chris@180
|
862 prefs->setResampleOnLoad(m_resampleOnLoad);
|
Chris@1379
|
863 prefs->setUseGaplessMode(m_gapless);
|
Chris@1276
|
864 prefs->setRunPluginsInProcess(m_runPluginsInProcess);
|
Chris@237
|
865 prefs->setShowSplash(m_showSplash);
|
Chris@180
|
866 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
|
Chris@180
|
867 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
|
Chris@337
|
868 prefs->setTimeToTextMode(Preferences::TimeToTextMode(m_timeToTextMode));
|
Chris@906
|
869 prefs->setShowHMS(m_showHMS);
|
Chris@225
|
870 prefs->setViewFontSize(m_viewFontSize);
|
Chris@263
|
871
|
Chris@702
|
872 prefs->setProperty("Octave Numbering System", m_octaveSystem);
|
Chris@702
|
873
|
Chris@263
|
874 QSettings settings;
|
Chris@263
|
875 settings.beginGroup("Preferences");
|
Chris@686
|
876 QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
|
Chris@686
|
877 settings.setValue(permishTag, m_networkPermission);
|
Chris@1397
|
878
|
Chris@1397
|
879 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
|
Chris@1397
|
880 string implementationName;
|
Chris@1415
|
881 if (m_audioImplementation > int(names.size())) {
|
Chris@1415
|
882 m_audioImplementation = 0;
|
Chris@1415
|
883 }
|
Chris@1397
|
884 if (m_audioImplementation > 0) {
|
Chris@1397
|
885 implementationName = names[m_audioImplementation-1];
|
Chris@1397
|
886 }
|
Chris@1397
|
887 settings.setValue("audio-target", implementationName.c_str());
|
Chris@1397
|
888
|
Chris@1397
|
889 QString suffix;
|
Chris@1397
|
890 if (implementationName != "") {
|
Chris@1397
|
891 suffix = "-" + QString(implementationName.c_str());
|
Chris@1397
|
892 }
|
Chris@1397
|
893
|
Chris@1397
|
894 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
|
Chris@1397
|
895 string deviceName;
|
Chris@1415
|
896 if (m_audioPlaybackDevice > int(names.size())) {
|
Chris@1415
|
897 m_audioPlaybackDevice = 0;
|
Chris@1415
|
898 }
|
Chris@1397
|
899 if (m_audioPlaybackDevice > 0) {
|
Chris@1397
|
900 deviceName = names[m_audioPlaybackDevice-1];
|
Chris@1397
|
901 }
|
Chris@1397
|
902 settings.setValue("audio-playback-device" + suffix, deviceName.c_str());
|
Chris@1397
|
903
|
Chris@1397
|
904 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
|
Chris@1397
|
905 deviceName = "";
|
Chris@1415
|
906 if (m_audioRecordDevice > int(names.size())) {
|
Chris@1415
|
907 m_audioRecordDevice = 0;
|
Chris@1415
|
908 }
|
Chris@1397
|
909 if (m_audioRecordDevice > 0) {
|
Chris@1397
|
910 deviceName = names[m_audioRecordDevice-1];
|
Chris@1397
|
911 }
|
Chris@1397
|
912 settings.setValue("audio-record-device" + suffix, deviceName.c_str());
|
Chris@1397
|
913
|
Chris@686
|
914 settings.setValue("locale", m_currentLocale);
|
Chris@950
|
915 #ifdef Q_OS_MAC
|
Chris@950
|
916 settings.setValue("scaledHiDpi", m_retina);
|
Chris@950
|
917 #endif
|
Chris@1096
|
918 settings.setValue("spectrogram-colour", m_spectrogramGColour);
|
Chris@1096
|
919 settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
|
Chris@1097
|
920 settings.setValue("colour-3d-plot-colour", m_colour3DColour);
|
Chris@263
|
921 settings.endGroup();
|
Chris@180
|
922
|
Chris@436
|
923 settings.beginGroup("MainWindow");
|
Chris@436
|
924 settings.setValue("sessiontemplate", m_currentTemplate);
|
Chris@436
|
925 settings.endGroup();
|
Chris@436
|
926
|
Chris@0
|
927 m_applyButton->setEnabled(false);
|
Chris@180
|
928
|
Chris@180
|
929 if (m_changesOnRestart) {
|
Chris@180
|
930 QMessageBox::information(this, tr("Preferences"),
|
Chris@255
|
931 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>"));
|
Chris@180
|
932 m_changesOnRestart = false;
|
Chris@180
|
933 }
|
Chris@1413
|
934
|
Chris@1413
|
935 if (m_audioDeviceChanged) {
|
Chris@1413
|
936 emit audioDeviceChanged();
|
Chris@1415
|
937 m_audioDeviceChanged = false;
|
Chris@1413
|
938 }
|
Chris@0
|
939 }
|
Chris@0
|
940
|
Chris@0
|
941 void
|
Chris@0
|
942 PreferencesDialog::cancelClicked()
|
Chris@0
|
943 {
|
Chris@0
|
944 reject();
|
Chris@0
|
945 }
|
Chris@0
|
946
|
Chris@163
|
947 void
|
Chris@163
|
948 PreferencesDialog::applicationClosing(bool quickly)
|
Chris@163
|
949 {
|
Chris@163
|
950 if (quickly) {
|
Chris@163
|
951 reject();
|
Chris@163
|
952 return;
|
Chris@163
|
953 }
|
Chris@163
|
954
|
Chris@163
|
955 if (m_applyButton->isEnabled()) {
|
Chris@163
|
956 int rv = QMessageBox::warning
|
Chris@163
|
957 (this, tr("Preferences Changed"),
|
Chris@163
|
958 tr("Some preferences have been changed but not applied.\n"
|
Chris@163
|
959 "Apply them before closing?"),
|
Chris@163
|
960 QMessageBox::Apply | QMessageBox::Discard,
|
Chris@163
|
961 QMessageBox::Discard);
|
Chris@163
|
962 if (rv == QMessageBox::Apply) {
|
Chris@163
|
963 applyClicked();
|
Chris@163
|
964 accept();
|
Chris@163
|
965 } else {
|
Chris@163
|
966 reject();
|
Chris@163
|
967 }
|
Chris@163
|
968 } else {
|
Chris@163
|
969 accept();
|
Chris@163
|
970 }
|
Chris@163
|
971 }
|
Chris@163
|
972
|