comparison base/Preferences.cpp @ 612:75f154085a4d

* Add time display format preference
author Chris Cannam
date Fri, 25 Sep 2009 12:02:22 +0000
parents 98077b21a9e1
children 2c4aca969c24 451f7f3ab6e7
comparison
equal deleted inserted replaced
611:dd97f7b3d120 612:75f154085a4d
44 m_omitRecentTemps(true), 44 m_omitRecentTemps(true),
45 m_tempDirRoot(""), 45 m_tempDirRoot(""),
46 m_resampleOnLoad(false), 46 m_resampleOnLoad(false),
47 m_viewFontSize(10), 47 m_viewFontSize(10),
48 m_backgroundMode(BackgroundFromTheme), 48 m_backgroundMode(BackgroundFromTheme),
49 m_timeToTextMode(TimeToTextMs),
49 m_showSplash(true) 50 m_showSplash(true)
50 { 51 {
51 QSettings settings; 52 QSettings settings;
52 settings.beginGroup("Preferences"); 53 settings.beginGroup("Preferences");
53 m_spectrogramSmoothing = SpectrogramSmoothing 54 m_spectrogramSmoothing = SpectrogramSmoothing
61 (settings.value("window-type", int(HanningWindow)).toInt()); 62 (settings.value("window-type", int(HanningWindow)).toInt());
62 m_resampleQuality = settings.value("resample-quality", 1).toInt(); 63 m_resampleQuality = settings.value("resample-quality", 1).toInt();
63 m_resampleOnLoad = settings.value("resample-on-load", false).toBool(); 64 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
64 m_backgroundMode = BackgroundMode 65 m_backgroundMode = BackgroundMode
65 (settings.value("background-mode", int(BackgroundFromTheme)).toInt()); 66 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
67 m_timeToTextMode = TimeToTextMode
68 (settings.value("time-to-text-mode", int(TimeToTextMs)).toInt());
66 m_viewFontSize = settings.value("view-font-size", 10).toInt(); 69 m_viewFontSize = settings.value("view-font-size", 10).toInt();
67 m_showSplash = settings.value("show-splash", true).toBool(); 70 m_showSplash = settings.value("show-splash", true).toBool();
68 settings.endGroup(); 71 settings.endGroup();
69 72
70 settings.beginGroup("TempDirectory"); 73 settings.beginGroup("TempDirectory");
88 props.push_back("Resample Quality"); 91 props.push_back("Resample Quality");
89 props.push_back("Omit Temporaries from Recent Files"); 92 props.push_back("Omit Temporaries from Recent Files");
90 props.push_back("Resample On Load"); 93 props.push_back("Resample On Load");
91 props.push_back("Temporary Directory Root"); 94 props.push_back("Temporary Directory Root");
92 props.push_back("Background Mode"); 95 props.push_back("Background Mode");
96 props.push_back("Time To Text Mode");
93 props.push_back("View Font Size"); 97 props.push_back("View Font Size");
94 props.push_back("Show Splash Screen"); 98 props.push_back("Show Splash Screen");
95 return props; 99 return props;
96 } 100 }
97 101
126 return tr("Location for cache file directory"); 130 return tr("Location for cache file directory");
127 } 131 }
128 if (name == "Background Mode") { 132 if (name == "Background Mode") {
129 return tr("Background colour preference"); 133 return tr("Background colour preference");
130 } 134 }
135 if (name == "Time To Text Mode") {
136 return tr("Time display format");
137 }
131 if (name == "View Font Size") { 138 if (name == "View Font Size") {
132 return tr("Font size for text overlays"); 139 return tr("Font size for text overlays");
133 } 140 }
134 if (name == "Show Splash Screen") { 141 if (name == "Show Splash Screen") {
135 return tr("Show splash screen on startup"); 142 return tr("Show splash screen on startup");
167 if (name == "Temporary Directory Root") { 174 if (name == "Temporary Directory Root") {
168 // It's an arbitrary string, we don't have a set of values for this 175 // It's an arbitrary string, we don't have a set of values for this
169 return InvalidProperty; 176 return InvalidProperty;
170 } 177 }
171 if (name == "Background Mode") { 178 if (name == "Background Mode") {
179 return ValueProperty;
180 }
181 if (name == "Time To Text Mode") {
172 return ValueProperty; 182 return ValueProperty;
173 } 183 }
174 if (name == "View Font Size") { 184 if (name == "View Font Size") {
175 return RangeProperty; 185 return RangeProperty;
176 } 186 }
227 if (name == "Background Mode") { 237 if (name == "Background Mode") {
228 if (min) *min = 0; 238 if (min) *min = 0;
229 if (max) *max = 2; 239 if (max) *max = 2;
230 if (deflt) *deflt = 0; 240 if (deflt) *deflt = 0;
231 return int(m_backgroundMode); 241 return int(m_backgroundMode);
242 }
243
244 if (name == "Time To Text Mode") {
245 if (min) *min = 0;
246 if (max) *max = 6;
247 if (deflt) *deflt = 0;
248 return int(m_timeToTextMode);
232 } 249 }
233 250
234 if (name == "View Font Size") { 251 if (name == "View Font Size") {
235 if (min) *min = 3; 252 if (min) *min = 3;
236 if (max) *max = 48; 253 if (max) *max = 48;
290 if (name == "Background Mode") { 307 if (name == "Background Mode") {
291 switch (value) { 308 switch (value) {
292 case BackgroundFromTheme: return tr("Follow desktop theme"); 309 case BackgroundFromTheme: return tr("Follow desktop theme");
293 case DarkBackground: return tr("Dark background"); 310 case DarkBackground: return tr("Dark background");
294 case LightBackground: return tr("Light background"); 311 case LightBackground: return tr("Light background");
312 }
313 }
314 if (name == "Time To Text Mode") {
315 switch (value) {
316 case TimeToTextMs: return tr("Standard (to millisecond)");
317 case TimeToTextUs: return tr("High resolution (to microsecond)");
318 case TimeToText24Frame: return tr("24 FPS");
319 case TimeToText25Frame: return tr("25 FPS");
320 case TimeToText30Frame: return tr("30 FPS");
321 case TimeToText50Frame: return tr("50 FPS");
322 case TimeToText60Frame: return tr("60 FPS");
295 } 323 }
296 } 324 }
297 325
298 return ""; 326 return "";
299 } 327 }
327 setResampleQuality(value); 355 setResampleQuality(value);
328 } else if (name == "Omit Temporaries from Recent Files") { 356 } else if (name == "Omit Temporaries from Recent Files") {
329 setOmitTempsFromRecentFiles(value ? true : false); 357 setOmitTempsFromRecentFiles(value ? true : false);
330 } else if (name == "Background Mode") { 358 } else if (name == "Background Mode") {
331 setBackgroundMode(BackgroundMode(value)); 359 setBackgroundMode(BackgroundMode(value));
360 } else if (name == "Time To Text Mode") {
361 setTimeToTextMode(TimeToTextMode(value));
332 } else if (name == "View Font Size") { 362 } else if (name == "View Font Size") {
333 setViewFontSize(value); 363 setViewFontSize(value);
334 } else if (name == "Show Splash Screen") { 364 } else if (name == "Show Splash Screen") {
335 setShowSplash(value ? true : false); 365 setShowSplash(value ? true : false);
336 } 366 }
478 emit propertyChanged("Background Mode"); 508 emit propertyChanged("Background Mode");
479 } 509 }
480 } 510 }
481 511
482 void 512 void
513 Preferences::setTimeToTextMode(TimeToTextMode mode)
514 {
515 if (m_timeToTextMode != mode) {
516
517 m_timeToTextMode = mode;
518
519 QSettings settings;
520 settings.beginGroup("Preferences");
521 settings.setValue("time-to-text-mode", int(mode));
522 settings.endGroup();
523 emit propertyChanged("Time To Text Mode");
524 }
525 }
526
527 void
483 Preferences::setViewFontSize(int size) 528 Preferences::setViewFontSize(int size)
484 { 529 {
485 if (m_viewFontSize != size) { 530 if (m_viewFontSize != size) {
486 531
487 m_viewFontSize = size; 532 m_viewFontSize = size;