annotate base/Preferences.cpp @ 1251:67aee57e32c8 3.0-integration

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