annotate base/Preferences.cpp @ 909:c48b07b34cb3 tony_integration

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