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@156
|
28 Preferences::m_instance = 0;
|
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@277
|
43 m_resampleQuality(1),
|
Chris@297
|
44 m_omitRecentTemps(true),
|
Chris@297
|
45 m_tempDirRoot(""),
|
Chris@354
|
46 m_resampleOnLoad(false),
|
Chris@354
|
47 m_viewFontSize(10),
|
Chris@372
|
48 m_backgroundMode(BackgroundFromTheme),
|
Chris@612
|
49 m_timeToTextMode(TimeToTextMs),
|
Chris@372
|
50 m_showSplash(true)
|
Chris@136
|
51 {
|
Chris@156
|
52 QSettings settings;
|
Chris@156
|
53 settings.beginGroup("Preferences");
|
Chris@246
|
54 m_spectrogramSmoothing = SpectrogramSmoothing
|
Chris@553
|
55 (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
|
Chris@553
|
56 m_spectrogramXSmoothing = SpectrogramXSmoothing
|
Chris@553
|
57 (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
|
Chris@156
|
58 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble();
|
Chris@145
|
59 m_propertyBoxLayout = PropertyBoxLayout
|
Chris@156
|
60 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
|
Chris@145
|
61 m_windowType = WindowType
|
Chris@156
|
62 (settings.value("window-type", int(HanningWindow)).toInt());
|
Chris@164
|
63 m_resampleQuality = settings.value("resample-quality", 1).toInt();
|
Chris@304
|
64 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
|
Chris@297
|
65 m_backgroundMode = BackgroundMode
|
Chris@297
|
66 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
|
Chris@612
|
67 m_timeToTextMode = TimeToTextMode
|
Chris@612
|
68 (settings.value("time-to-text-mode", int(TimeToTextMs)).toInt());
|
Chris@387
|
69 m_viewFontSize = settings.value("view-font-size", 10).toInt();
|
Chris@372
|
70 m_showSplash = settings.value("show-splash", true).toBool();
|
Chris@297
|
71 settings.endGroup();
|
Chris@297
|
72
|
Chris@297
|
73 settings.beginGroup("TempDirectory");
|
Chris@297
|
74 m_tempDirRoot = settings.value("create-in", "$HOME").toString();
|
Chris@156
|
75 settings.endGroup();
|
Chris@145
|
76 }
|
Chris@145
|
77
|
Chris@145
|
78 Preferences::~Preferences()
|
Chris@145
|
79 {
|
Chris@136
|
80 }
|
Chris@136
|
81
|
Chris@136
|
82 Preferences::PropertyList
|
Chris@136
|
83 Preferences::getProperties() const
|
Chris@136
|
84 {
|
Chris@136
|
85 PropertyList props;
|
Chris@553
|
86 props.push_back("Spectrogram Y Smoothing");
|
Chris@553
|
87 props.push_back("Spectrogram X Smoothing");
|
Chris@136
|
88 props.push_back("Tuning Frequency");
|
Chris@138
|
89 props.push_back("Property Box Layout");
|
Chris@140
|
90 props.push_back("Window Type");
|
Chris@164
|
91 props.push_back("Resample Quality");
|
Chris@277
|
92 props.push_back("Omit Temporaries from Recent Files");
|
Chris@297
|
93 props.push_back("Resample On Load");
|
Chris@297
|
94 props.push_back("Temporary Directory Root");
|
Chris@297
|
95 props.push_back("Background Mode");
|
Chris@612
|
96 props.push_back("Time To Text Mode");
|
Chris@354
|
97 props.push_back("View Font Size");
|
Chris@372
|
98 props.push_back("Show Splash Screen");
|
Chris@136
|
99 return props;
|
Chris@136
|
100 }
|
Chris@136
|
101
|
Chris@136
|
102 QString
|
Chris@136
|
103 Preferences::getPropertyLabel(const PropertyName &name) const
|
Chris@136
|
104 {
|
Chris@553
|
105 if (name == "Spectrogram Y Smoothing") {
|
Chris@372
|
106 return tr("Spectrogram y-axis interpolation:");
|
Chris@136
|
107 }
|
Chris@553
|
108 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
109 return tr("Spectrogram x-axis interpolation:");
|
Chris@553
|
110 }
|
Chris@136
|
111 if (name == "Tuning Frequency") {
|
Chris@141
|
112 return tr("Frequency of concert A");
|
Chris@136
|
113 }
|
Chris@138
|
114 if (name == "Property Box Layout") {
|
Chris@141
|
115 return tr("Property box layout");
|
Chris@138
|
116 }
|
Chris@140
|
117 if (name == "Window Type") {
|
Chris@141
|
118 return tr("Spectral analysis window shape");
|
Chris@140
|
119 }
|
Chris@164
|
120 if (name == "Resample Quality") {
|
Chris@165
|
121 return tr("Playback resampler type");
|
Chris@164
|
122 }
|
Chris@277
|
123 if (name == "Omit Temporaries from Recent Files") {
|
Chris@297
|
124 return tr("Omit temporaries from Recent Files menu");
|
Chris@297
|
125 }
|
Chris@297
|
126 if (name == "Resample On Load") {
|
Chris@297
|
127 return tr("Resample mismatching files on import");
|
Chris@297
|
128 }
|
Chris@297
|
129 if (name == "Temporary Directory Root") {
|
Chris@297
|
130 return tr("Location for cache file directory");
|
Chris@297
|
131 }
|
Chris@297
|
132 if (name == "Background Mode") {
|
Chris@297
|
133 return tr("Background colour preference");
|
Chris@277
|
134 }
|
Chris@612
|
135 if (name == "Time To Text Mode") {
|
Chris@612
|
136 return tr("Time display format");
|
Chris@612
|
137 }
|
Chris@354
|
138 if (name == "View Font Size") {
|
Chris@354
|
139 return tr("Font size for text overlays");
|
Chris@354
|
140 }
|
Chris@372
|
141 if (name == "Show Splash Screen") {
|
Chris@372
|
142 return tr("Show splash screen on startup");
|
Chris@372
|
143 }
|
Chris@136
|
144 return name;
|
Chris@136
|
145 }
|
Chris@136
|
146
|
Chris@136
|
147 Preferences::PropertyType
|
Chris@136
|
148 Preferences::getPropertyType(const PropertyName &name) const
|
Chris@136
|
149 {
|
Chris@553
|
150 if (name == "Spectrogram Y Smoothing") {
|
Chris@553
|
151 return ValueProperty;
|
Chris@553
|
152 }
|
Chris@553
|
153 if (name == "Spectrogram X Smoothing") {
|
Chris@246
|
154 return ValueProperty;
|
Chris@136
|
155 }
|
Chris@136
|
156 if (name == "Tuning Frequency") {
|
Chris@136
|
157 return RangeProperty;
|
Chris@136
|
158 }
|
Chris@138
|
159 if (name == "Property Box Layout") {
|
Chris@138
|
160 return ValueProperty;
|
Chris@138
|
161 }
|
Chris@140
|
162 if (name == "Window Type") {
|
Chris@140
|
163 return ValueProperty;
|
Chris@140
|
164 }
|
Chris@164
|
165 if (name == "Resample Quality") {
|
Chris@164
|
166 return ValueProperty;
|
Chris@164
|
167 }
|
Chris@277
|
168 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
169 return ToggleProperty;
|
Chris@277
|
170 }
|
Chris@297
|
171 if (name == "Resample On Load") {
|
Chris@297
|
172 return ToggleProperty;
|
Chris@297
|
173 }
|
Chris@297
|
174 if (name == "Temporary Directory Root") {
|
Chris@297
|
175 // It's an arbitrary string, we don't have a set of values for this
|
Chris@297
|
176 return InvalidProperty;
|
Chris@297
|
177 }
|
Chris@297
|
178 if (name == "Background Mode") {
|
Chris@297
|
179 return ValueProperty;
|
Chris@297
|
180 }
|
Chris@612
|
181 if (name == "Time To Text Mode") {
|
Chris@612
|
182 return ValueProperty;
|
Chris@612
|
183 }
|
Chris@354
|
184 if (name == "View Font Size") {
|
Chris@354
|
185 return RangeProperty;
|
Chris@354
|
186 }
|
Chris@372
|
187 if (name == "Show Splash Screen") {
|
Chris@372
|
188 return ToggleProperty;
|
Chris@372
|
189 }
|
Chris@136
|
190 return InvalidProperty;
|
Chris@136
|
191 }
|
Chris@136
|
192
|
Chris@136
|
193 int
|
Chris@136
|
194 Preferences::getPropertyRangeAndValue(const PropertyName &name,
|
Chris@245
|
195 int *min, int *max, int *deflt) const
|
Chris@136
|
196 {
|
Chris@553
|
197 if (name == "Spectrogram Y Smoothing") {
|
Chris@136
|
198 if (min) *min = 0;
|
Chris@553
|
199 if (max) *max = 3;
|
Chris@553
|
200 if (deflt) *deflt = int(SpectrogramInterpolated);
|
Chris@246
|
201 return int(m_spectrogramSmoothing);
|
Chris@136
|
202 }
|
Chris@553
|
203 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
204 if (min) *min = 0;
|
Chris@553
|
205 if (max) *max = 1;
|
Chris@553
|
206 if (deflt) *deflt = int(SpectrogramXInterpolated);
|
Chris@553
|
207 return int(m_spectrogramXSmoothing);
|
Chris@553
|
208 }
|
Chris@136
|
209
|
Chris@136
|
210 //!!! freq mapping
|
Chris@136
|
211
|
Chris@138
|
212 if (name == "Property Box Layout") {
|
Chris@138
|
213 if (min) *min = 0;
|
Chris@138
|
214 if (max) *max = 1;
|
Chris@245
|
215 if (deflt) *deflt = 0;
|
Chris@138
|
216 return m_propertyBoxLayout == Layered ? 1 : 0;
|
Chris@138
|
217 }
|
Chris@138
|
218
|
Chris@140
|
219 if (name == "Window Type") {
|
Chris@140
|
220 if (min) *min = int(RectangularWindow);
|
Chris@142
|
221 if (max) *max = int(BlackmanHarrisWindow);
|
Chris@245
|
222 if (deflt) *deflt = int(HanningWindow);
|
Chris@140
|
223 return int(m_windowType);
|
Chris@140
|
224 }
|
Chris@140
|
225
|
Chris@164
|
226 if (name == "Resample Quality") {
|
Chris@164
|
227 if (min) *min = 0;
|
Chris@164
|
228 if (max) *max = 2;
|
Chris@245
|
229 if (deflt) *deflt = 1;
|
Chris@164
|
230 return m_resampleQuality;
|
Chris@164
|
231 }
|
Chris@164
|
232
|
Chris@277
|
233 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
234 if (deflt) *deflt = 1;
|
Chris@277
|
235 }
|
Chris@277
|
236
|
Chris@297
|
237 if (name == "Background Mode") {
|
Chris@297
|
238 if (min) *min = 0;
|
Chris@297
|
239 if (max) *max = 2;
|
Chris@297
|
240 if (deflt) *deflt = 0;
|
Chris@297
|
241 return int(m_backgroundMode);
|
Chris@297
|
242 }
|
Chris@297
|
243
|
Chris@612
|
244 if (name == "Time To Text Mode") {
|
Chris@612
|
245 if (min) *min = 0;
|
Chris@612
|
246 if (max) *max = 6;
|
Chris@612
|
247 if (deflt) *deflt = 0;
|
Chris@612
|
248 return int(m_timeToTextMode);
|
Chris@612
|
249 }
|
Chris@612
|
250
|
Chris@354
|
251 if (name == "View Font Size") {
|
Chris@354
|
252 if (min) *min = 3;
|
Chris@354
|
253 if (max) *max = 48;
|
Chris@387
|
254 if (deflt) *deflt = 10;
|
Chris@354
|
255 return int(m_viewFontSize);
|
Chris@354
|
256 }
|
Chris@354
|
257
|
Chris@372
|
258 if (name == "Show Splash Screen") {
|
Chris@372
|
259 if (deflt) *deflt = 1;
|
Chris@372
|
260 }
|
Chris@372
|
261
|
Chris@136
|
262 return 0;
|
Chris@136
|
263 }
|
Chris@136
|
264
|
Chris@136
|
265 QString
|
Chris@136
|
266 Preferences::getPropertyValueLabel(const PropertyName &name,
|
Chris@136
|
267 int value) const
|
Chris@136
|
268 {
|
Chris@138
|
269 if (name == "Property Box Layout") {
|
Chris@141
|
270 if (value == 0) return tr("Show boxes for all panes");
|
Chris@141
|
271 else return tr("Show box for current pane only");
|
Chris@138
|
272 }
|
Chris@140
|
273 if (name == "Window Type") {
|
Chris@140
|
274 switch (WindowType(value)) {
|
Chris@140
|
275 case RectangularWindow: return tr("Rectangular");
|
Chris@141
|
276 case BartlettWindow: return tr("Triangular");
|
Chris@140
|
277 case HammingWindow: return tr("Hamming");
|
Chris@381
|
278 case HanningWindow: return tr("Hann");
|
Chris@140
|
279 case BlackmanWindow: return tr("Blackman");
|
Chris@140
|
280 case GaussianWindow: return tr("Gaussian");
|
Chris@140
|
281 case ParzenWindow: return tr("Parzen");
|
Chris@142
|
282 case NuttallWindow: return tr("Nuttall");
|
Chris@142
|
283 case BlackmanHarrisWindow: return tr("Blackman-Harris");
|
Chris@140
|
284 }
|
Chris@140
|
285 }
|
Chris@164
|
286 if (name == "Resample Quality") {
|
Chris@164
|
287 switch (value) {
|
Chris@164
|
288 case 0: return tr("Fastest");
|
Chris@165
|
289 case 1: return tr("Standard");
|
Chris@164
|
290 case 2: return tr("Highest quality");
|
Chris@164
|
291 }
|
Chris@164
|
292 }
|
Chris@553
|
293 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
294 switch (value) {
|
Chris@553
|
295 case NoSpectrogramSmoothing: return tr("None");
|
Chris@553
|
296 case SpectrogramInterpolated: return tr("Linear interpolation");
|
Chris@553
|
297 case SpectrogramZeroPadded: return tr("4 x Oversampling");
|
Chris@553
|
298 case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
|
Chris@553
|
299 }
|
Chris@553
|
300 }
|
Chris@553
|
301 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
302 switch (value) {
|
Chris@553
|
303 case NoSpectrogramXSmoothing: return tr("None");
|
Chris@553
|
304 case SpectrogramXInterpolated: return tr("Linear interpolation");
|
Chris@246
|
305 }
|
Chris@246
|
306 }
|
Chris@297
|
307 if (name == "Background Mode") {
|
Chris@297
|
308 switch (value) {
|
Chris@297
|
309 case BackgroundFromTheme: return tr("Follow desktop theme");
|
Chris@297
|
310 case DarkBackground: return tr("Dark background");
|
Chris@297
|
311 case LightBackground: return tr("Light background");
|
Chris@297
|
312 }
|
Chris@297
|
313 }
|
Chris@612
|
314 if (name == "Time To Text Mode") {
|
Chris@612
|
315 switch (value) {
|
Chris@612
|
316 case TimeToTextMs: return tr("Standard (to millisecond)");
|
Chris@612
|
317 case TimeToTextUs: return tr("High resolution (to microsecond)");
|
Chris@612
|
318 case TimeToText24Frame: return tr("24 FPS");
|
Chris@612
|
319 case TimeToText25Frame: return tr("25 FPS");
|
Chris@612
|
320 case TimeToText30Frame: return tr("30 FPS");
|
Chris@612
|
321 case TimeToText50Frame: return tr("50 FPS");
|
Chris@612
|
322 case TimeToText60Frame: return tr("60 FPS");
|
Chris@612
|
323 }
|
Chris@612
|
324 }
|
Chris@246
|
325
|
Chris@136
|
326 return "";
|
Chris@136
|
327 }
|
Chris@136
|
328
|
Chris@136
|
329 QString
|
Chris@136
|
330 Preferences::getPropertyContainerName() const
|
Chris@136
|
331 {
|
Chris@136
|
332 return tr("Preferences");
|
Chris@136
|
333 }
|
Chris@136
|
334
|
Chris@136
|
335 QString
|
Chris@136
|
336 Preferences::getPropertyContainerIconName() const
|
Chris@136
|
337 {
|
Chris@136
|
338 return "preferences";
|
Chris@136
|
339 }
|
Chris@136
|
340
|
Chris@136
|
341 void
|
Chris@136
|
342 Preferences::setProperty(const PropertyName &name, int value)
|
Chris@136
|
343 {
|
Chris@553
|
344 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
345 setSpectrogramSmoothing(SpectrogramSmoothing(value));
|
Chris@553
|
346 } else if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
347 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
|
Chris@136
|
348 } else if (name == "Tuning Frequency") {
|
Chris@136
|
349 //!!!
|
Chris@138
|
350 } else if (name == "Property Box Layout") {
|
Chris@138
|
351 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
|
Chris@140
|
352 } else if (name == "Window Type") {
|
Chris@140
|
353 setWindowType(WindowType(value));
|
Chris@164
|
354 } else if (name == "Resample Quality") {
|
Chris@164
|
355 setResampleQuality(value);
|
Chris@277
|
356 } else if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
357 setOmitTempsFromRecentFiles(value ? true : false);
|
Chris@297
|
358 } else if (name == "Background Mode") {
|
Chris@297
|
359 setBackgroundMode(BackgroundMode(value));
|
Chris@612
|
360 } else if (name == "Time To Text Mode") {
|
Chris@612
|
361 setTimeToTextMode(TimeToTextMode(value));
|
Chris@354
|
362 } else if (name == "View Font Size") {
|
Chris@354
|
363 setViewFontSize(value);
|
Chris@372
|
364 } else if (name == "Show Splash Screen") {
|
Chris@372
|
365 setShowSplash(value ? true : false);
|
Chris@136
|
366 }
|
Chris@136
|
367 }
|
Chris@136
|
368
|
Chris@136
|
369 void
|
Chris@246
|
370 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
|
Chris@136
|
371 {
|
Chris@246
|
372 if (m_spectrogramSmoothing != smoothing) {
|
Chris@246
|
373
|
Chris@246
|
374 // "smoothing" is one of those words that looks increasingly
|
Chris@246
|
375 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@246
|
376 m_spectrogramSmoothing = smoothing;
|
Chris@246
|
377
|
Chris@156
|
378 QSettings settings;
|
Chris@156
|
379 settings.beginGroup("Preferences");
|
Chris@553
|
380 settings.setValue("spectrogram-y-smoothing", int(smoothing));
|
Chris@156
|
381 settings.endGroup();
|
Chris@553
|
382 emit propertyChanged("Spectrogram Y Smoothing");
|
Chris@553
|
383 }
|
Chris@553
|
384 }
|
Chris@553
|
385
|
Chris@553
|
386 void
|
Chris@553
|
387 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
|
Chris@553
|
388 {
|
Chris@553
|
389 if (m_spectrogramXSmoothing != smoothing) {
|
Chris@553
|
390
|
Chris@553
|
391 // "smoothing" is one of those words that looks increasingly
|
Chris@553
|
392 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@553
|
393 m_spectrogramXSmoothing = smoothing;
|
Chris@553
|
394
|
Chris@553
|
395 QSettings settings;
|
Chris@553
|
396 settings.beginGroup("Preferences");
|
Chris@553
|
397 settings.setValue("spectrogram-x-smoothing", int(smoothing));
|
Chris@553
|
398 settings.endGroup();
|
Chris@553
|
399 emit propertyChanged("Spectrogram X Smoothing");
|
Chris@138
|
400 }
|
Chris@136
|
401 }
|
Chris@136
|
402
|
Chris@136
|
403 void
|
Chris@136
|
404 Preferences::setTuningFrequency(float freq)
|
Chris@136
|
405 {
|
Chris@138
|
406 if (m_tuningFrequency != freq) {
|
Chris@138
|
407 m_tuningFrequency = freq;
|
Chris@156
|
408 QSettings settings;
|
Chris@156
|
409 settings.beginGroup("Preferences");
|
Chris@156
|
410 settings.setValue("tuning-frequency", freq);
|
Chris@156
|
411 settings.endGroup();
|
Chris@141
|
412 emit propertyChanged("Tuning Frequency");
|
Chris@138
|
413 }
|
Chris@136
|
414 }
|
Chris@136
|
415
|
Chris@138
|
416 void
|
Chris@138
|
417 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
|
Chris@138
|
418 {
|
Chris@138
|
419 if (m_propertyBoxLayout != layout) {
|
Chris@138
|
420 m_propertyBoxLayout = layout;
|
Chris@156
|
421 QSettings settings;
|
Chris@156
|
422 settings.beginGroup("Preferences");
|
Chris@156
|
423 settings.setValue("property-box-layout", int(layout));
|
Chris@156
|
424 settings.endGroup();
|
Chris@141
|
425 emit propertyChanged("Property Box Layout");
|
Chris@138
|
426 }
|
Chris@138
|
427 }
|
Chris@138
|
428
|
Chris@140
|
429 void
|
Chris@140
|
430 Preferences::setWindowType(WindowType type)
|
Chris@140
|
431 {
|
Chris@140
|
432 if (m_windowType != type) {
|
Chris@140
|
433 m_windowType = type;
|
Chris@156
|
434 QSettings settings;
|
Chris@156
|
435 settings.beginGroup("Preferences");
|
Chris@156
|
436 settings.setValue("window-type", int(type));
|
Chris@156
|
437 settings.endGroup();
|
Chris@141
|
438 emit propertyChanged("Window Type");
|
Chris@140
|
439 }
|
Chris@140
|
440 }
|
Chris@140
|
441
|
Chris@164
|
442 void
|
Chris@164
|
443 Preferences::setResampleQuality(int q)
|
Chris@164
|
444 {
|
Chris@164
|
445 if (m_resampleQuality != q) {
|
Chris@164
|
446 m_resampleQuality = q;
|
Chris@164
|
447 QSettings settings;
|
Chris@164
|
448 settings.beginGroup("Preferences");
|
Chris@164
|
449 settings.setValue("resample-quality", q);
|
Chris@164
|
450 settings.endGroup();
|
Chris@164
|
451 emit propertyChanged("Resample Quality");
|
Chris@164
|
452 }
|
Chris@164
|
453 }
|
Chris@277
|
454
|
Chris@277
|
455 void
|
Chris@277
|
456 Preferences::setOmitTempsFromRecentFiles(bool omit)
|
Chris@277
|
457 {
|
Chris@277
|
458 if (m_omitRecentTemps != omit) {
|
Chris@277
|
459 m_omitRecentTemps = omit;
|
Chris@277
|
460 QSettings settings;
|
Chris@277
|
461 settings.beginGroup("Preferences");
|
Chris@277
|
462 settings.setValue("omit-recent-temporaries", omit);
|
Chris@277
|
463 settings.endGroup();
|
Chris@277
|
464 emit propertyChanged("Omit Temporaries from Recent Files");
|
Chris@277
|
465 }
|
Chris@277
|
466 }
|
Chris@297
|
467
|
Chris@297
|
468 void
|
Chris@297
|
469 Preferences::setTemporaryDirectoryRoot(QString root)
|
Chris@297
|
470 {
|
Chris@297
|
471 if (root == QDir::home().absolutePath()) {
|
Chris@297
|
472 root = "$HOME";
|
Chris@297
|
473 }
|
Chris@297
|
474 if (m_tempDirRoot != root) {
|
Chris@297
|
475 m_tempDirRoot = root;
|
Chris@297
|
476 QSettings settings;
|
Chris@297
|
477 settings.beginGroup("TempDirectory");
|
Chris@297
|
478 settings.setValue("create-in", root);
|
Chris@297
|
479 settings.endGroup();
|
Chris@297
|
480 emit propertyChanged("Temporary Directory Root");
|
Chris@297
|
481 }
|
Chris@297
|
482 }
|
Chris@297
|
483
|
Chris@297
|
484 void
|
Chris@297
|
485 Preferences::setResampleOnLoad(bool resample)
|
Chris@297
|
486 {
|
Chris@297
|
487 if (m_resampleOnLoad != resample) {
|
Chris@297
|
488 m_resampleOnLoad = resample;
|
Chris@297
|
489 QSettings settings;
|
Chris@297
|
490 settings.beginGroup("Preferences");
|
Chris@297
|
491 settings.setValue("resample-on-load", resample);
|
Chris@297
|
492 settings.endGroup();
|
Chris@297
|
493 emit propertyChanged("Resample On Load");
|
Chris@297
|
494 }
|
Chris@297
|
495 }
|
Chris@297
|
496
|
Chris@297
|
497 void
|
Chris@297
|
498 Preferences::setBackgroundMode(BackgroundMode mode)
|
Chris@297
|
499 {
|
Chris@297
|
500 if (m_backgroundMode != mode) {
|
Chris@297
|
501
|
Chris@297
|
502 m_backgroundMode = mode;
|
Chris@297
|
503
|
Chris@297
|
504 QSettings settings;
|
Chris@297
|
505 settings.beginGroup("Preferences");
|
Chris@297
|
506 settings.setValue("background-mode", int(mode));
|
Chris@297
|
507 settings.endGroup();
|
Chris@297
|
508 emit propertyChanged("Background Mode");
|
Chris@297
|
509 }
|
Chris@297
|
510 }
|
Chris@297
|
511
|
Chris@354
|
512 void
|
Chris@612
|
513 Preferences::setTimeToTextMode(TimeToTextMode mode)
|
Chris@612
|
514 {
|
Chris@612
|
515 if (m_timeToTextMode != mode) {
|
Chris@612
|
516
|
Chris@612
|
517 m_timeToTextMode = mode;
|
Chris@612
|
518
|
Chris@612
|
519 QSettings settings;
|
Chris@612
|
520 settings.beginGroup("Preferences");
|
Chris@612
|
521 settings.setValue("time-to-text-mode", int(mode));
|
Chris@612
|
522 settings.endGroup();
|
Chris@612
|
523 emit propertyChanged("Time To Text Mode");
|
Chris@612
|
524 }
|
Chris@612
|
525 }
|
Chris@612
|
526
|
Chris@612
|
527 void
|
Chris@354
|
528 Preferences::setViewFontSize(int size)
|
Chris@354
|
529 {
|
Chris@354
|
530 if (m_viewFontSize != size) {
|
Chris@297
|
531
|
Chris@354
|
532 m_viewFontSize = size;
|
Chris@354
|
533
|
Chris@354
|
534 QSettings settings;
|
Chris@354
|
535 settings.beginGroup("Preferences");
|
Chris@354
|
536 settings.setValue("view-font-size", size);
|
Chris@354
|
537 settings.endGroup();
|
Chris@354
|
538 emit propertyChanged("View Font Size");
|
Chris@354
|
539 }
|
Chris@354
|
540 }
|
Chris@354
|
541
|
Chris@372
|
542 void
|
Chris@372
|
543 Preferences::setShowSplash(bool show)
|
Chris@372
|
544 {
|
Chris@372
|
545 if (m_showSplash != show) {
|
Chris@372
|
546
|
Chris@372
|
547 m_showSplash = show;
|
Chris@372
|
548
|
Chris@372
|
549 QSettings settings;
|
Chris@372
|
550 settings.beginGroup("Preferences");
|
Chris@372
|
551 settings.setValue("show-splash", show);
|
Chris@372
|
552 settings.endGroup();
|
Chris@372
|
553 emit propertyChanged("Show Splash Screen");
|
Chris@372
|
554 }
|
Chris@372
|
555 }
|
Chris@372
|
556
|