Chris@136
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@136
|
2
|
Chris@136
|
3 /*
|
Chris@136
|
4 Sonic Visualiser
|
Chris@136
|
5 An audio file viewer and annotation editor.
|
Chris@136
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@202
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@136
|
8
|
Chris@136
|
9 This program is free software; you can redistribute it and/or
|
Chris@136
|
10 modify it under the terms of the GNU General Public License as
|
Chris@136
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@136
|
12 License, or (at your option) any later version. See the file
|
Chris@136
|
13 COPYING included with this distribution for more information.
|
Chris@136
|
14 */
|
Chris@136
|
15
|
Chris@136
|
16 #include "Preferences.h"
|
Chris@136
|
17
|
Chris@145
|
18 #include "Exceptions.h"
|
Chris@145
|
19
|
Chris@145
|
20 #include "TempDirectory.h"
|
Chris@145
|
21
|
Chris@145
|
22 #include <QDir>
|
Chris@145
|
23 #include <QFileInfo>
|
Chris@156
|
24 #include <QMutex>
|
Chris@156
|
25 #include <QSettings>
|
Chris@145
|
26
|
Chris@136
|
27 Preferences *
|
Chris@1582
|
28 Preferences::m_instance = nullptr;
|
Chris@156
|
29
|
Chris@156
|
30 Preferences *
|
Chris@156
|
31 Preferences::getInstance()
|
Chris@156
|
32 {
|
Chris@156
|
33 if (!m_instance) m_instance = new Preferences();
|
Chris@156
|
34 return m_instance;
|
Chris@156
|
35 }
|
Chris@136
|
36
|
Chris@136
|
37 Preferences::Preferences() :
|
Chris@553
|
38 m_spectrogramSmoothing(SpectrogramInterpolated),
|
Chris@553
|
39 m_spectrogramXSmoothing(SpectrogramXInterpolated),
|
Chris@140
|
40 m_tuningFrequency(440),
|
Chris@140
|
41 m_propertyBoxLayout(VerticallyStacked),
|
Chris@164
|
42 m_windowType(HanningWindow),
|
Chris@1225
|
43 m_runPluginsInProcess(true),
|
Chris@297
|
44 m_omitRecentTemps(true),
|
Chris@297
|
45 m_tempDirRoot(""),
|
Chris@919
|
46 m_fixedSampleRate(0),
|
Chris@1868
|
47 m_recordMono(false),
|
Chris@354
|
48 m_resampleOnLoad(false),
|
Chris@1313
|
49 m_gapless(true),
|
Chris@921
|
50 m_normaliseAudio(false),
|
Chris@354
|
51 m_viewFontSize(10),
|
Chris@372
|
52 m_backgroundMode(BackgroundFromTheme),
|
Chris@612
|
53 m_timeToTextMode(TimeToTextMs),
|
Chris@1031
|
54 m_showHMS(true),
|
Chris@892
|
55 m_octave(4),
|
Chris@372
|
56 m_showSplash(true)
|
Chris@136
|
57 {
|
Chris@156
|
58 QSettings settings;
|
Chris@156
|
59 settings.beginGroup("Preferences");
|
Chris@246
|
60 m_spectrogramSmoothing = SpectrogramSmoothing
|
Chris@553
|
61 (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
|
Chris@553
|
62 m_spectrogramXSmoothing = SpectrogramXSmoothing
|
Chris@553
|
63 (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
|
Chris@1038
|
64 m_tuningFrequency = settings.value("tuning-frequency", 440.).toDouble();
|
Chris@145
|
65 m_propertyBoxLayout = PropertyBoxLayout
|
Chris@156
|
66 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
|
Chris@145
|
67 m_windowType = WindowType
|
Chris@156
|
68 (settings.value("window-type", int(HanningWindow)).toInt());
|
Chris@1225
|
69 m_runPluginsInProcess = settings.value("run-vamp-plugins-in-process", true).toBool();
|
Chris@1047
|
70 m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toDouble();
|
Chris@1868
|
71 m_recordMono = settings.value("record-mono", false).toBool();
|
Chris@304
|
72 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
|
Chris@1313
|
73 m_gapless = settings.value("gapless", true).toBool();
|
Chris@921
|
74 m_normaliseAudio = settings.value("normalise-audio", false).toBool();
|
Chris@297
|
75 m_backgroundMode = BackgroundMode
|
Chris@297
|
76 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
|
Chris@612
|
77 m_timeToTextMode = TimeToTextMode
|
Chris@612
|
78 (settings.value("time-to-text-mode", int(TimeToTextMs)).toInt());
|
Chris@1031
|
79 m_showHMS = (settings.value("show-hours-minutes-seconds", true)).toBool();
|
Chris@892
|
80 m_octave = (settings.value("octave-of-middle-c", 4)).toInt();
|
Chris@387
|
81 m_viewFontSize = settings.value("view-font-size", 10).toInt();
|
Chris@372
|
82 m_showSplash = settings.value("show-splash", true).toBool();
|
Chris@297
|
83 settings.endGroup();
|
Chris@297
|
84
|
Chris@297
|
85 settings.beginGroup("TempDirectory");
|
Chris@297
|
86 m_tempDirRoot = settings.value("create-in", "$HOME").toString();
|
Chris@156
|
87 settings.endGroup();
|
Chris@145
|
88 }
|
Chris@145
|
89
|
Chris@145
|
90 Preferences::~Preferences()
|
Chris@145
|
91 {
|
Chris@136
|
92 }
|
Chris@136
|
93
|
Chris@136
|
94 Preferences::PropertyList
|
Chris@136
|
95 Preferences::getProperties() const
|
Chris@136
|
96 {
|
Chris@136
|
97 PropertyList props;
|
Chris@553
|
98 props.push_back("Spectrogram Y Smoothing");
|
Chris@553
|
99 props.push_back("Spectrogram X Smoothing");
|
Chris@136
|
100 props.push_back("Tuning Frequency");
|
Chris@138
|
101 props.push_back("Property Box Layout");
|
Chris@140
|
102 props.push_back("Window Type");
|
Chris@164
|
103 props.push_back("Resample Quality");
|
Chris@277
|
104 props.push_back("Omit Temporaries from Recent Files");
|
Chris@1868
|
105 props.push_back("Record Mono");
|
Chris@297
|
106 props.push_back("Resample On Load");
|
Chris@1313
|
107 props.push_back("Use Gapless Mode");
|
Chris@921
|
108 props.push_back("Normalise Audio");
|
Chris@919
|
109 props.push_back("Fixed Sample Rate");
|
Chris@297
|
110 props.push_back("Temporary Directory Root");
|
Chris@297
|
111 props.push_back("Background Mode");
|
Chris@612
|
112 props.push_back("Time To Text Mode");
|
Chris@1031
|
113 props.push_back("Show Hours And Minutes");
|
Chris@892
|
114 props.push_back("Octave Numbering System");
|
Chris@354
|
115 props.push_back("View Font Size");
|
Chris@372
|
116 props.push_back("Show Splash Screen");
|
Chris@136
|
117 return props;
|
Chris@136
|
118 }
|
Chris@136
|
119
|
Chris@136
|
120 QString
|
Chris@136
|
121 Preferences::getPropertyLabel(const PropertyName &name) const
|
Chris@136
|
122 {
|
Chris@553
|
123 if (name == "Spectrogram Y Smoothing") {
|
Chris@372
|
124 return tr("Spectrogram y-axis interpolation:");
|
Chris@136
|
125 }
|
Chris@553
|
126 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
127 return tr("Spectrogram x-axis interpolation:");
|
Chris@553
|
128 }
|
Chris@136
|
129 if (name == "Tuning Frequency") {
|
Chris@141
|
130 return tr("Frequency of concert A");
|
Chris@136
|
131 }
|
Chris@138
|
132 if (name == "Property Box Layout") {
|
Chris@141
|
133 return tr("Property box layout");
|
Chris@138
|
134 }
|
Chris@140
|
135 if (name == "Window Type") {
|
Chris@141
|
136 return tr("Spectral analysis window shape");
|
Chris@140
|
137 }
|
Chris@164
|
138 if (name == "Resample Quality") {
|
Chris@165
|
139 return tr("Playback resampler type");
|
Chris@164
|
140 }
|
Chris@921
|
141 if (name == "Normalise Audio") {
|
Chris@921
|
142 return tr("Normalise audio signal when reading from audio file");
|
Chris@921
|
143 }
|
Chris@277
|
144 if (name == "Omit Temporaries from Recent Files") {
|
Chris@297
|
145 return tr("Omit temporaries from Recent Files menu");
|
Chris@297
|
146 }
|
Chris@1868
|
147 if (name == "Record Mono") {
|
Chris@1868
|
148 return tr("Mix recorded channels to mono");
|
Chris@1868
|
149 }
|
Chris@297
|
150 if (name == "Resample On Load") {
|
Chris@297
|
151 return tr("Resample mismatching files on import");
|
Chris@297
|
152 }
|
Chris@1313
|
153 if (name == "Use Gapless Mode") {
|
Chris@1313
|
154 return tr("Load mp3 files in gapless mode");
|
Chris@1313
|
155 }
|
Chris@919
|
156 if (name == "Fixed Sample Rate") {
|
Chris@919
|
157 return tr("Single fixed sample rate to resample all files to");
|
Chris@919
|
158 }
|
Chris@297
|
159 if (name == "Temporary Directory Root") {
|
Chris@297
|
160 return tr("Location for cache file directory");
|
Chris@297
|
161 }
|
Chris@297
|
162 if (name == "Background Mode") {
|
Chris@297
|
163 return tr("Background colour preference");
|
Chris@277
|
164 }
|
Chris@612
|
165 if (name == "Time To Text Mode") {
|
Chris@1031
|
166 return tr("Time display precision");
|
Chris@1031
|
167 }
|
Chris@1031
|
168 if (name == "Show Hours And Minutes") {
|
Chris@1031
|
169 return tr("Use hours:minutes:seconds format");
|
Chris@612
|
170 }
|
Chris@892
|
171 if (name == "Octave Numbering System") {
|
Chris@892
|
172 return tr("Label middle C as");
|
Chris@892
|
173 }
|
Chris@354
|
174 if (name == "View Font Size") {
|
Chris@354
|
175 return tr("Font size for text overlays");
|
Chris@354
|
176 }
|
Chris@372
|
177 if (name == "Show Splash Screen") {
|
Chris@372
|
178 return tr("Show splash screen on startup");
|
Chris@372
|
179 }
|
Chris@136
|
180 return name;
|
Chris@136
|
181 }
|
Chris@136
|
182
|
Chris@136
|
183 Preferences::PropertyType
|
Chris@136
|
184 Preferences::getPropertyType(const PropertyName &name) const
|
Chris@136
|
185 {
|
Chris@553
|
186 if (name == "Spectrogram Y Smoothing") {
|
Chris@553
|
187 return ValueProperty;
|
Chris@553
|
188 }
|
Chris@553
|
189 if (name == "Spectrogram X Smoothing") {
|
Chris@246
|
190 return ValueProperty;
|
Chris@136
|
191 }
|
Chris@136
|
192 if (name == "Tuning Frequency") {
|
Chris@136
|
193 return RangeProperty;
|
Chris@136
|
194 }
|
Chris@138
|
195 if (name == "Property Box Layout") {
|
Chris@138
|
196 return ValueProperty;
|
Chris@138
|
197 }
|
Chris@140
|
198 if (name == "Window Type") {
|
Chris@140
|
199 return ValueProperty;
|
Chris@140
|
200 }
|
Chris@164
|
201 if (name == "Resample Quality") {
|
Chris@164
|
202 return ValueProperty;
|
Chris@164
|
203 }
|
Chris@921
|
204 if (name == "Normalise Audio") {
|
Chris@921
|
205 return ToggleProperty;
|
Chris@921
|
206 }
|
Chris@277
|
207 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
208 return ToggleProperty;
|
Chris@277
|
209 }
|
Chris@1868
|
210 if (name == "Record Mono") {
|
Chris@1868
|
211 return ToggleProperty;
|
Chris@1868
|
212 }
|
Chris@297
|
213 if (name == "Resample On Load") {
|
Chris@297
|
214 return ToggleProperty;
|
Chris@297
|
215 }
|
Chris@1313
|
216 if (name == "Use Gapless Mode") {
|
Chris@1313
|
217 return ToggleProperty;
|
Chris@1313
|
218 }
|
Chris@919
|
219 if (name == "Fixed Sample Rate") {
|
Chris@919
|
220 return ValueProperty;
|
Chris@919
|
221 }
|
Chris@297
|
222 if (name == "Temporary Directory Root") {
|
Chris@297
|
223 // It's an arbitrary string, we don't have a set of values for this
|
Chris@297
|
224 return InvalidProperty;
|
Chris@297
|
225 }
|
Chris@297
|
226 if (name == "Background Mode") {
|
Chris@297
|
227 return ValueProperty;
|
Chris@297
|
228 }
|
Chris@612
|
229 if (name == "Time To Text Mode") {
|
Chris@612
|
230 return ValueProperty;
|
Chris@612
|
231 }
|
Chris@1031
|
232 if (name == "Show Hours And Minutes") {
|
Chris@1031
|
233 return ToggleProperty;
|
Chris@1031
|
234 }
|
Chris@892
|
235 if (name == "Octave Numbering System") {
|
Chris@892
|
236 return ValueProperty;
|
Chris@892
|
237 }
|
Chris@354
|
238 if (name == "View Font Size") {
|
Chris@354
|
239 return RangeProperty;
|
Chris@354
|
240 }
|
Chris@372
|
241 if (name == "Show Splash Screen") {
|
Chris@372
|
242 return ToggleProperty;
|
Chris@372
|
243 }
|
Chris@136
|
244 return InvalidProperty;
|
Chris@136
|
245 }
|
Chris@136
|
246
|
Chris@136
|
247 int
|
Chris@136
|
248 Preferences::getPropertyRangeAndValue(const PropertyName &name,
|
Chris@245
|
249 int *min, int *max, int *deflt) const
|
Chris@136
|
250 {
|
Chris@553
|
251 if (name == "Spectrogram Y Smoothing") {
|
Chris@136
|
252 if (min) *min = 0;
|
Chris@1578
|
253 if (max) *max = 1;
|
Chris@553
|
254 if (deflt) *deflt = int(SpectrogramInterpolated);
|
Chris@246
|
255 return int(m_spectrogramSmoothing);
|
Chris@136
|
256 }
|
Chris@553
|
257 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
258 if (min) *min = 0;
|
Chris@553
|
259 if (max) *max = 1;
|
Chris@553
|
260 if (deflt) *deflt = int(SpectrogramXInterpolated);
|
Chris@553
|
261 return int(m_spectrogramXSmoothing);
|
Chris@553
|
262 }
|
Chris@136
|
263
|
Chris@136
|
264 //!!! freq mapping
|
Chris@136
|
265
|
Chris@138
|
266 if (name == "Property Box Layout") {
|
Chris@138
|
267 if (min) *min = 0;
|
Chris@138
|
268 if (max) *max = 1;
|
Chris@245
|
269 if (deflt) *deflt = 0;
|
Chris@138
|
270 return m_propertyBoxLayout == Layered ? 1 : 0;
|
Chris@138
|
271 }
|
Chris@138
|
272
|
Chris@140
|
273 if (name == "Window Type") {
|
Chris@140
|
274 if (min) *min = int(RectangularWindow);
|
Chris@142
|
275 if (max) *max = int(BlackmanHarrisWindow);
|
Chris@245
|
276 if (deflt) *deflt = int(HanningWindow);
|
Chris@140
|
277 return int(m_windowType);
|
Chris@140
|
278 }
|
Chris@140
|
279
|
Chris@1225
|
280 if (name == "Run Vamp Plugins In Process") {
|
Chris@1225
|
281 return m_runPluginsInProcess;
|
Chris@1225
|
282 }
|
Chris@1225
|
283
|
Chris@277
|
284 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
285 if (deflt) *deflt = 1;
|
Chris@1031
|
286 return m_omitRecentTemps ? 1 : 0;
|
Chris@277
|
287 }
|
Chris@277
|
288
|
Chris@297
|
289 if (name == "Background Mode") {
|
Chris@297
|
290 if (min) *min = 0;
|
Chris@297
|
291 if (max) *max = 2;
|
Chris@297
|
292 if (deflt) *deflt = 0;
|
Chris@297
|
293 return int(m_backgroundMode);
|
Chris@297
|
294 }
|
Chris@297
|
295
|
Chris@612
|
296 if (name == "Time To Text Mode") {
|
Chris@612
|
297 if (min) *min = 0;
|
Chris@612
|
298 if (max) *max = 6;
|
Chris@612
|
299 if (deflt) *deflt = 0;
|
Chris@612
|
300 return int(m_timeToTextMode);
|
Chris@612
|
301 }
|
Chris@612
|
302
|
Chris@1031
|
303 if (name == "Show Hours And Minutes") {
|
Chris@1031
|
304 if (deflt) *deflt = 1;
|
Chris@1031
|
305 return m_showHMS ? 1 : 0;
|
Chris@1031
|
306 }
|
Chris@1031
|
307
|
Chris@892
|
308 if (name == "Octave Numbering System") {
|
Chris@892
|
309 // we don't support arbitrary octaves in the gui, because we
|
Chris@892
|
310 // want to be able to label what the octave system comes
|
Chris@892
|
311 // from. so we support 0, 3, 4 and 5.
|
Chris@892
|
312 if (min) *min = 0;
|
Chris@892
|
313 if (max) *max = 3;
|
Chris@892
|
314 if (deflt) *deflt = 2;
|
Chris@892
|
315 return int(getSystemWithMiddleCInOctave(m_octave));
|
Chris@892
|
316 }
|
Chris@892
|
317
|
Chris@354
|
318 if (name == "View Font Size") {
|
Chris@354
|
319 if (min) *min = 3;
|
Chris@354
|
320 if (max) *max = 48;
|
Chris@387
|
321 if (deflt) *deflt = 10;
|
Chris@354
|
322 return int(m_viewFontSize);
|
Chris@354
|
323 }
|
Chris@354
|
324
|
Chris@372
|
325 if (name == "Show Splash Screen") {
|
Chris@372
|
326 if (deflt) *deflt = 1;
|
Chris@1031
|
327 return m_showSplash ? 1 : 0;
|
Chris@372
|
328 }
|
Chris@372
|
329
|
Chris@136
|
330 return 0;
|
Chris@136
|
331 }
|
Chris@136
|
332
|
Chris@136
|
333 QString
|
Chris@136
|
334 Preferences::getPropertyValueLabel(const PropertyName &name,
|
Chris@136
|
335 int value) const
|
Chris@136
|
336 {
|
Chris@138
|
337 if (name == "Property Box Layout") {
|
Chris@141
|
338 if (value == 0) return tr("Show boxes for all panes");
|
Chris@141
|
339 else return tr("Show box for current pane only");
|
Chris@138
|
340 }
|
Chris@140
|
341 if (name == "Window Type") {
|
Chris@140
|
342 switch (WindowType(value)) {
|
Chris@140
|
343 case RectangularWindow: return tr("Rectangular");
|
Chris@141
|
344 case BartlettWindow: return tr("Triangular");
|
Chris@140
|
345 case HammingWindow: return tr("Hamming");
|
Chris@381
|
346 case HanningWindow: return tr("Hann");
|
Chris@140
|
347 case BlackmanWindow: return tr("Blackman");
|
Chris@140
|
348 case GaussianWindow: return tr("Gaussian");
|
Chris@140
|
349 case ParzenWindow: return tr("Parzen");
|
Chris@142
|
350 case NuttallWindow: return tr("Nuttall");
|
Chris@142
|
351 case BlackmanHarrisWindow: return tr("Blackman-Harris");
|
Chris@140
|
352 }
|
Chris@140
|
353 }
|
Chris@164
|
354 if (name == "Resample Quality") {
|
Chris@164
|
355 switch (value) {
|
Chris@164
|
356 case 0: return tr("Fastest");
|
Chris@165
|
357 case 1: return tr("Standard");
|
Chris@164
|
358 case 2: return tr("Highest quality");
|
Chris@164
|
359 }
|
Chris@164
|
360 }
|
Chris@553
|
361 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
362 switch (value) {
|
Chris@553
|
363 case NoSpectrogramSmoothing: return tr("None");
|
Chris@553
|
364 case SpectrogramInterpolated: return tr("Linear interpolation");
|
Chris@553
|
365 }
|
Chris@553
|
366 }
|
Chris@553
|
367 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
368 switch (value) {
|
Chris@553
|
369 case NoSpectrogramXSmoothing: return tr("None");
|
Chris@553
|
370 case SpectrogramXInterpolated: return tr("Linear interpolation");
|
Chris@246
|
371 }
|
Chris@246
|
372 }
|
Chris@297
|
373 if (name == "Background Mode") {
|
Chris@297
|
374 switch (value) {
|
Chris@297
|
375 case BackgroundFromTheme: return tr("Follow desktop theme");
|
Chris@297
|
376 case DarkBackground: return tr("Dark background");
|
Chris@297
|
377 case LightBackground: return tr("Light background");
|
Chris@297
|
378 }
|
Chris@297
|
379 }
|
Chris@612
|
380 if (name == "Time To Text Mode") {
|
Chris@612
|
381 switch (value) {
|
Chris@612
|
382 case TimeToTextMs: return tr("Standard (to millisecond)");
|
Chris@612
|
383 case TimeToTextUs: return tr("High resolution (to microsecond)");
|
Chris@612
|
384 case TimeToText24Frame: return tr("24 FPS");
|
Chris@612
|
385 case TimeToText25Frame: return tr("25 FPS");
|
Chris@612
|
386 case TimeToText30Frame: return tr("30 FPS");
|
Chris@612
|
387 case TimeToText50Frame: return tr("50 FPS");
|
Chris@612
|
388 case TimeToText60Frame: return tr("60 FPS");
|
Chris@612
|
389 }
|
Chris@612
|
390 }
|
Chris@892
|
391 if (name == "Octave Numbering System") {
|
Chris@892
|
392 switch (value) {
|
Chris@892
|
393 case C0_Centre: return tr("C0 - middle of octave scale");
|
Chris@892
|
394 case C3_Logic: return tr("C3 - common MIDI sequencer convention");
|
Chris@892
|
395 case C4_ASA: return tr("C4 - ASA American standard");
|
Chris@892
|
396 case C5_Sonar: return tr("C5 - used in Cakewalk and others");
|
Chris@892
|
397 }
|
Chris@892
|
398 }
|
Chris@246
|
399
|
Chris@136
|
400 return "";
|
Chris@136
|
401 }
|
Chris@136
|
402
|
Chris@136
|
403 QString
|
Chris@136
|
404 Preferences::getPropertyContainerName() const
|
Chris@136
|
405 {
|
Chris@136
|
406 return tr("Preferences");
|
Chris@136
|
407 }
|
Chris@136
|
408
|
Chris@136
|
409 QString
|
Chris@136
|
410 Preferences::getPropertyContainerIconName() const
|
Chris@136
|
411 {
|
Chris@136
|
412 return "preferences";
|
Chris@136
|
413 }
|
Chris@136
|
414
|
Chris@136
|
415 void
|
Chris@136
|
416 Preferences::setProperty(const PropertyName &name, int value)
|
Chris@136
|
417 {
|
Chris@553
|
418 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
419 setSpectrogramSmoothing(SpectrogramSmoothing(value));
|
Chris@553
|
420 } else if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
421 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
|
Chris@136
|
422 } else if (name == "Tuning Frequency") {
|
Chris@136
|
423 //!!!
|
Chris@138
|
424 } else if (name == "Property Box Layout") {
|
Chris@138
|
425 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
|
Chris@140
|
426 } else if (name == "Window Type") {
|
Chris@140
|
427 setWindowType(WindowType(value));
|
Chris@1225
|
428 } else if (name == "Run Vamp Plugins In Process") {
|
Chris@1225
|
429 setRunPluginsInProcess(value ? true : false);
|
Chris@277
|
430 } else if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
431 setOmitTempsFromRecentFiles(value ? true : false);
|
Chris@297
|
432 } else if (name == "Background Mode") {
|
Chris@297
|
433 setBackgroundMode(BackgroundMode(value));
|
Chris@612
|
434 } else if (name == "Time To Text Mode") {
|
Chris@612
|
435 setTimeToTextMode(TimeToTextMode(value));
|
Chris@1031
|
436 } else if (name == "Show Hours And Minutes") {
|
Chris@1031
|
437 setShowHMS(value ? true : false);
|
Chris@892
|
438 } else if (name == "Octave Numbering System") {
|
Chris@892
|
439 setOctaveOfMiddleC(getOctaveOfMiddleCInSystem
|
Chris@892
|
440 (OctaveNumberingSystem(value)));
|
Chris@354
|
441 } else if (name == "View Font Size") {
|
Chris@354
|
442 setViewFontSize(value);
|
Chris@372
|
443 } else if (name == "Show Splash Screen") {
|
Chris@372
|
444 setShowSplash(value ? true : false);
|
Chris@136
|
445 }
|
Chris@136
|
446 }
|
Chris@136
|
447
|
Chris@136
|
448 void
|
Chris@246
|
449 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
|
Chris@136
|
450 {
|
Chris@246
|
451 if (m_spectrogramSmoothing != smoothing) {
|
Chris@246
|
452
|
Chris@246
|
453 // "smoothing" is one of those words that looks increasingly
|
Chris@246
|
454 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@246
|
455 m_spectrogramSmoothing = smoothing;
|
Chris@246
|
456
|
Chris@156
|
457 QSettings settings;
|
Chris@156
|
458 settings.beginGroup("Preferences");
|
Chris@553
|
459 settings.setValue("spectrogram-y-smoothing", int(smoothing));
|
Chris@156
|
460 settings.endGroup();
|
Chris@553
|
461 emit propertyChanged("Spectrogram Y Smoothing");
|
Chris@553
|
462 }
|
Chris@553
|
463 }
|
Chris@553
|
464
|
Chris@553
|
465 void
|
Chris@553
|
466 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
|
Chris@553
|
467 {
|
Chris@553
|
468 if (m_spectrogramXSmoothing != smoothing) {
|
Chris@553
|
469
|
Chris@553
|
470 // "smoothing" is one of those words that looks increasingly
|
Chris@553
|
471 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@553
|
472 m_spectrogramXSmoothing = smoothing;
|
Chris@553
|
473
|
Chris@553
|
474 QSettings settings;
|
Chris@553
|
475 settings.beginGroup("Preferences");
|
Chris@553
|
476 settings.setValue("spectrogram-x-smoothing", int(smoothing));
|
Chris@553
|
477 settings.endGroup();
|
Chris@553
|
478 emit propertyChanged("Spectrogram X Smoothing");
|
Chris@138
|
479 }
|
Chris@136
|
480 }
|
Chris@136
|
481
|
Chris@136
|
482 void
|
Chris@1038
|
483 Preferences::setTuningFrequency(double freq)
|
Chris@136
|
484 {
|
Chris@138
|
485 if (m_tuningFrequency != freq) {
|
Chris@138
|
486 m_tuningFrequency = freq;
|
Chris@156
|
487 QSettings settings;
|
Chris@156
|
488 settings.beginGroup("Preferences");
|
Chris@156
|
489 settings.setValue("tuning-frequency", freq);
|
Chris@156
|
490 settings.endGroup();
|
Chris@141
|
491 emit propertyChanged("Tuning Frequency");
|
Chris@138
|
492 }
|
Chris@136
|
493 }
|
Chris@136
|
494
|
Chris@138
|
495 void
|
Chris@138
|
496 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
|
Chris@138
|
497 {
|
Chris@138
|
498 if (m_propertyBoxLayout != layout) {
|
Chris@138
|
499 m_propertyBoxLayout = layout;
|
Chris@156
|
500 QSettings settings;
|
Chris@156
|
501 settings.beginGroup("Preferences");
|
Chris@156
|
502 settings.setValue("property-box-layout", int(layout));
|
Chris@156
|
503 settings.endGroup();
|
Chris@141
|
504 emit propertyChanged("Property Box Layout");
|
Chris@138
|
505 }
|
Chris@138
|
506 }
|
Chris@138
|
507
|
Chris@140
|
508 void
|
Chris@140
|
509 Preferences::setWindowType(WindowType type)
|
Chris@140
|
510 {
|
Chris@140
|
511 if (m_windowType != type) {
|
Chris@140
|
512 m_windowType = type;
|
Chris@156
|
513 QSettings settings;
|
Chris@156
|
514 settings.beginGroup("Preferences");
|
Chris@156
|
515 settings.setValue("window-type", int(type));
|
Chris@156
|
516 settings.endGroup();
|
Chris@141
|
517 emit propertyChanged("Window Type");
|
Chris@140
|
518 }
|
Chris@140
|
519 }
|
Chris@140
|
520
|
Chris@164
|
521 void
|
Chris@1225
|
522 Preferences::setRunPluginsInProcess(bool run)
|
Chris@1225
|
523 {
|
Chris@1225
|
524 if (m_runPluginsInProcess != run) {
|
Chris@1225
|
525 m_runPluginsInProcess = run;
|
Chris@1225
|
526 QSettings settings;
|
Chris@1225
|
527 settings.beginGroup("Preferences");
|
Chris@1225
|
528 settings.setValue("run-vamp-plugins-in-process", run);
|
Chris@1225
|
529 settings.endGroup();
|
Chris@1225
|
530 emit propertyChanged("Run Vamp Plugins In Process");
|
Chris@1225
|
531 }
|
Chris@1225
|
532 }
|
Chris@1225
|
533
|
Chris@1225
|
534 void
|
Chris@277
|
535 Preferences::setOmitTempsFromRecentFiles(bool omit)
|
Chris@277
|
536 {
|
Chris@277
|
537 if (m_omitRecentTemps != omit) {
|
Chris@277
|
538 m_omitRecentTemps = omit;
|
Chris@277
|
539 QSettings settings;
|
Chris@277
|
540 settings.beginGroup("Preferences");
|
Chris@277
|
541 settings.setValue("omit-recent-temporaries", omit);
|
Chris@277
|
542 settings.endGroup();
|
Chris@277
|
543 emit propertyChanged("Omit Temporaries from Recent Files");
|
Chris@277
|
544 }
|
Chris@277
|
545 }
|
Chris@297
|
546
|
Chris@297
|
547 void
|
Chris@297
|
548 Preferences::setTemporaryDirectoryRoot(QString root)
|
Chris@297
|
549 {
|
Chris@297
|
550 if (root == QDir::home().absolutePath()) {
|
Chris@297
|
551 root = "$HOME";
|
Chris@297
|
552 }
|
Chris@297
|
553 if (m_tempDirRoot != root) {
|
Chris@297
|
554 m_tempDirRoot = root;
|
Chris@297
|
555 QSettings settings;
|
Chris@297
|
556 settings.beginGroup("TempDirectory");
|
Chris@297
|
557 settings.setValue("create-in", root);
|
Chris@297
|
558 settings.endGroup();
|
Chris@297
|
559 emit propertyChanged("Temporary Directory Root");
|
Chris@297
|
560 }
|
Chris@297
|
561 }
|
Chris@297
|
562
|
Chris@297
|
563 void
|
Chris@1868
|
564 Preferences::setRecordMono(bool mono)
|
Chris@1868
|
565 {
|
Chris@1868
|
566 if (m_recordMono != mono) {
|
Chris@1868
|
567 m_recordMono = mono;
|
Chris@1868
|
568 QSettings settings;
|
Chris@1868
|
569 settings.beginGroup("Preferences");
|
Chris@1868
|
570 settings.setValue("record-mono", mono);
|
Chris@1868
|
571 settings.endGroup();
|
Chris@1868
|
572 emit propertyChanged("Record Mono");
|
Chris@1868
|
573 }
|
Chris@1868
|
574 }
|
Chris@1868
|
575
|
Chris@1868
|
576 void
|
Chris@297
|
577 Preferences::setResampleOnLoad(bool resample)
|
Chris@297
|
578 {
|
Chris@297
|
579 if (m_resampleOnLoad != resample) {
|
Chris@297
|
580 m_resampleOnLoad = resample;
|
Chris@297
|
581 QSettings settings;
|
Chris@297
|
582 settings.beginGroup("Preferences");
|
Chris@297
|
583 settings.setValue("resample-on-load", resample);
|
Chris@297
|
584 settings.endGroup();
|
Chris@297
|
585 emit propertyChanged("Resample On Load");
|
Chris@297
|
586 }
|
Chris@297
|
587 }
|
Chris@297
|
588
|
Chris@297
|
589 void
|
Chris@1313
|
590 Preferences::setUseGaplessMode(bool gapless)
|
Chris@1313
|
591 {
|
Chris@1313
|
592 if (m_gapless != gapless) {
|
Chris@1313
|
593 m_gapless = gapless;
|
Chris@1313
|
594 QSettings settings;
|
Chris@1313
|
595 settings.beginGroup("Preferences");
|
Chris@1313
|
596 settings.setValue("gapless", gapless);
|
Chris@1313
|
597 settings.endGroup();
|
Chris@1313
|
598 emit propertyChanged("Use Gapless Mode");
|
Chris@1313
|
599 }
|
Chris@1313
|
600 }
|
Chris@1313
|
601
|
Chris@1313
|
602 void
|
Chris@1047
|
603 Preferences::setFixedSampleRate(sv_samplerate_t rate)
|
Chris@919
|
604 {
|
Chris@919
|
605 if (m_fixedSampleRate != rate) {
|
Chris@919
|
606 m_fixedSampleRate = rate;
|
Chris@919
|
607 QSettings settings;
|
Chris@919
|
608 settings.beginGroup("Preferences");
|
Chris@919
|
609 settings.setValue("fixed-sample-rate", rate);
|
Chris@919
|
610 settings.endGroup();
|
Chris@919
|
611 emit propertyChanged("Fixed Sample Rate");
|
Chris@919
|
612 }
|
Chris@919
|
613 }
|
Chris@919
|
614
|
Chris@919
|
615 void
|
Chris@921
|
616 Preferences::setNormaliseAudio(bool norm)
|
Chris@921
|
617 {
|
Chris@921
|
618 if (m_normaliseAudio != norm) {
|
Chris@921
|
619 m_normaliseAudio = norm;
|
Chris@921
|
620 QSettings settings;
|
Chris@921
|
621 settings.beginGroup("Preferences");
|
Chris@921
|
622 settings.setValue("normalise-audio", norm);
|
Chris@921
|
623 settings.endGroup();
|
Chris@921
|
624 emit propertyChanged("Normalise Audio");
|
Chris@921
|
625 }
|
Chris@921
|
626 }
|
Chris@921
|
627
|
Chris@921
|
628 void
|
Chris@297
|
629 Preferences::setBackgroundMode(BackgroundMode mode)
|
Chris@297
|
630 {
|
Chris@297
|
631 if (m_backgroundMode != mode) {
|
Chris@297
|
632
|
Chris@297
|
633 m_backgroundMode = mode;
|
Chris@297
|
634
|
Chris@297
|
635 QSettings settings;
|
Chris@297
|
636 settings.beginGroup("Preferences");
|
Chris@297
|
637 settings.setValue("background-mode", int(mode));
|
Chris@297
|
638 settings.endGroup();
|
Chris@297
|
639 emit propertyChanged("Background Mode");
|
Chris@297
|
640 }
|
Chris@297
|
641 }
|
Chris@297
|
642
|
Chris@354
|
643 void
|
Chris@612
|
644 Preferences::setTimeToTextMode(TimeToTextMode mode)
|
Chris@612
|
645 {
|
Chris@612
|
646 if (m_timeToTextMode != mode) {
|
Chris@612
|
647
|
Chris@612
|
648 m_timeToTextMode = mode;
|
Chris@612
|
649
|
Chris@612
|
650 QSettings settings;
|
Chris@612
|
651 settings.beginGroup("Preferences");
|
Chris@612
|
652 settings.setValue("time-to-text-mode", int(mode));
|
Chris@612
|
653 settings.endGroup();
|
Chris@612
|
654 emit propertyChanged("Time To Text Mode");
|
Chris@612
|
655 }
|
Chris@612
|
656 }
|
Chris@612
|
657
|
Chris@612
|
658 void
|
Chris@1031
|
659 Preferences::setShowHMS(bool show)
|
Chris@1031
|
660 {
|
Chris@1031
|
661 if (m_showHMS != show) {
|
Chris@1031
|
662
|
Chris@1031
|
663 m_showHMS = show;
|
Chris@1031
|
664
|
Chris@1031
|
665 QSettings settings;
|
Chris@1031
|
666 settings.beginGroup("Preferences");
|
Chris@1031
|
667 settings.setValue("show-hours-minutes-seconds", show);
|
Chris@1031
|
668 settings.endGroup();
|
Chris@1031
|
669 emit propertyChanged("Show Hours And Minutes");
|
Chris@1031
|
670 }
|
Chris@1031
|
671 }
|
Chris@1031
|
672
|
Chris@1031
|
673 void
|
Chris@892
|
674 Preferences::setOctaveOfMiddleC(int oct)
|
Chris@892
|
675 {
|
Chris@892
|
676 if (m_octave != oct) {
|
Chris@892
|
677
|
Chris@892
|
678 m_octave = oct;
|
Chris@892
|
679
|
Chris@892
|
680 QSettings settings;
|
Chris@892
|
681 settings.beginGroup("Preferences");
|
Chris@892
|
682 settings.setValue("octave-of-middle-c", int(oct));
|
Chris@892
|
683 settings.endGroup();
|
Chris@892
|
684 emit propertyChanged("Octave Numbering System");
|
Chris@892
|
685 }
|
Chris@892
|
686 }
|
Chris@892
|
687
|
Chris@892
|
688 int
|
Chris@892
|
689 Preferences::getOctaveOfMiddleCInSystem(OctaveNumberingSystem s)
|
Chris@892
|
690 {
|
Chris@892
|
691 switch (s) {
|
Chris@892
|
692 case C0_Centre: return 0;
|
Chris@892
|
693 case C3_Logic: return 3;
|
Chris@892
|
694 case C4_ASA: return 4;
|
Chris@892
|
695 case C5_Sonar: return 5;
|
Chris@892
|
696 default: return 4;
|
Chris@892
|
697 }
|
Chris@892
|
698 }
|
Chris@892
|
699
|
Chris@892
|
700 Preferences::OctaveNumberingSystem
|
Chris@892
|
701 Preferences::getSystemWithMiddleCInOctave(int o)
|
Chris@892
|
702 {
|
Chris@892
|
703 switch (o) {
|
Chris@892
|
704 case 0: return C0_Centre;
|
Chris@892
|
705 case 3: return C3_Logic;
|
Chris@892
|
706 case 4: return C4_ASA;
|
Chris@892
|
707 case 5: return C5_Sonar;
|
Chris@892
|
708 default: return C4_ASA;
|
Chris@892
|
709 }
|
Chris@892
|
710 }
|
Chris@892
|
711
|
Chris@892
|
712 void
|
Chris@354
|
713 Preferences::setViewFontSize(int size)
|
Chris@354
|
714 {
|
Chris@354
|
715 if (m_viewFontSize != size) {
|
Chris@297
|
716
|
Chris@354
|
717 m_viewFontSize = size;
|
Chris@354
|
718
|
Chris@354
|
719 QSettings settings;
|
Chris@354
|
720 settings.beginGroup("Preferences");
|
Chris@354
|
721 settings.setValue("view-font-size", size);
|
Chris@354
|
722 settings.endGroup();
|
Chris@354
|
723 emit propertyChanged("View Font Size");
|
Chris@354
|
724 }
|
Chris@354
|
725 }
|
Chris@354
|
726
|
Chris@372
|
727 void
|
Chris@372
|
728 Preferences::setShowSplash(bool show)
|
Chris@372
|
729 {
|
Chris@372
|
730 if (m_showSplash != show) {
|
Chris@372
|
731
|
Chris@372
|
732 m_showSplash = show;
|
Chris@372
|
733
|
Chris@372
|
734 QSettings settings;
|
Chris@372
|
735 settings.beginGroup("Preferences");
|
Chris@372
|
736 settings.setValue("show-splash", show);
|
Chris@372
|
737 settings.endGroup();
|
Chris@372
|
738 emit propertyChanged("Show Splash Screen");
|
Chris@372
|
739 }
|
Chris@372
|
740 }
|
Chris@372
|
741
|