annotate base/Preferences.cpp @ 925:3efc20c59a94 tonioni

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