annotate base/Preferences.cpp @ 714:eb741b4e8d21 library_integration

Remove the qutomatic updating of Vamp plugin RDF description files using netwoek access for the library edition
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Mon, 17 Oct 2011 14:07:54 +0100
parents 2c4aca969c24
children
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),
mathieu@694 50 m_showSplash(true),
mathieu@694 51 m_startInMiniMode(false)
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@387 70 m_viewFontSize = settings.value("view-font-size", 10).toInt();
Chris@372 71 m_showSplash = settings.value("show-splash", true).toBool();
mathieu@694 72 m_startInMiniMode = settings.value("start-in-mini-mode", false).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@354 99 props.push_back("View Font Size");
Chris@372 100 props.push_back("Show Splash Screen");
mathieu@694 101 props.push_back("Start In Minimal Mode");
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@354 141 if (name == "View Font Size") {
Chris@354 142 return tr("Font size for text overlays");
Chris@354 143 }
Chris@372 144 if (name == "Show Splash Screen") {
Chris@372 145 return tr("Show splash screen on startup");
Chris@372 146 }
mathieu@694 147 if (name == "Start In Minimal Mode") {
mathieu@694 148 return tr("Start Sonic Visualiser in minimal mode");
mathieu@694 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@354 190 if (name == "View Font Size") {
Chris@354 191 return RangeProperty;
Chris@354 192 }
Chris@372 193 if (name == "Show Splash Screen") {
Chris@372 194 return ToggleProperty;
Chris@372 195 }
mathieu@694 196 if (name == "Start In Minimal Mode") {
mathieu@694 197 return ToggleProperty;
mathieu@694 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@354 260 if (name == "View Font Size") {
Chris@354 261 if (min) *min = 3;
Chris@354 262 if (max) *max = 48;
Chris@387 263 if (deflt) *deflt = 10;
Chris@354 264 return int(m_viewFontSize);
Chris@354 265 }
Chris@354 266
Chris@372 267 if (name == "Show Splash Screen") {
Chris@372 268 if (deflt) *deflt = 1;
Chris@372 269 }
Chris@372 270
mathieu@694 271 if (name == "Start In Minimal Mode") {
mathieu@694 272 if (deflt) *deflt = 0;
mathieu@694 273 }
mathieu@694 274
Chris@136 275 return 0;
Chris@136 276 }
Chris@136 277
Chris@136 278 QString
Chris@136 279 Preferences::getPropertyValueLabel(const PropertyName &name,
Chris@136 280 int value) const
Chris@136 281 {
Chris@138 282 if (name == "Property Box Layout") {
Chris@141 283 if (value == 0) return tr("Show boxes for all panes");
Chris@141 284 else return tr("Show box for current pane only");
Chris@138 285 }
Chris@140 286 if (name == "Window Type") {
Chris@140 287 switch (WindowType(value)) {
Chris@140 288 case RectangularWindow: return tr("Rectangular");
Chris@141 289 case BartlettWindow: return tr("Triangular");
Chris@140 290 case HammingWindow: return tr("Hamming");
Chris@381 291 case HanningWindow: return tr("Hann");
Chris@140 292 case BlackmanWindow: return tr("Blackman");
Chris@140 293 case GaussianWindow: return tr("Gaussian");
Chris@140 294 case ParzenWindow: return tr("Parzen");
Chris@142 295 case NuttallWindow: return tr("Nuttall");
Chris@142 296 case BlackmanHarrisWindow: return tr("Blackman-Harris");
Chris@140 297 }
Chris@140 298 }
Chris@164 299 if (name == "Resample Quality") {
Chris@164 300 switch (value) {
Chris@164 301 case 0: return tr("Fastest");
Chris@165 302 case 1: return tr("Standard");
Chris@164 303 case 2: return tr("Highest quality");
Chris@164 304 }
Chris@164 305 }
Chris@553 306 if (name == "Spectrogram Y Smoothing") {
Chris@246 307 switch (value) {
Chris@553 308 case NoSpectrogramSmoothing: return tr("None");
Chris@553 309 case SpectrogramInterpolated: return tr("Linear interpolation");
Chris@553 310 case SpectrogramZeroPadded: return tr("4 x Oversampling");
Chris@553 311 case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
Chris@553 312 }
Chris@553 313 }
Chris@553 314 if (name == "Spectrogram X Smoothing") {
Chris@553 315 switch (value) {
Chris@553 316 case NoSpectrogramXSmoothing: return tr("None");
Chris@553 317 case SpectrogramXInterpolated: return tr("Linear interpolation");
Chris@246 318 }
Chris@246 319 }
Chris@297 320 if (name == "Background Mode") {
Chris@297 321 switch (value) {
Chris@297 322 case BackgroundFromTheme: return tr("Follow desktop theme");
Chris@297 323 case DarkBackground: return tr("Dark background");
Chris@297 324 case LightBackground: return tr("Light background");
Chris@297 325 }
Chris@297 326 }
Chris@612 327 if (name == "Time To Text Mode") {
Chris@612 328 switch (value) {
Chris@612 329 case TimeToTextMs: return tr("Standard (to millisecond)");
Chris@612 330 case TimeToTextUs: return tr("High resolution (to microsecond)");
Chris@612 331 case TimeToText24Frame: return tr("24 FPS");
Chris@612 332 case TimeToText25Frame: return tr("25 FPS");
Chris@612 333 case TimeToText30Frame: return tr("30 FPS");
Chris@612 334 case TimeToText50Frame: return tr("50 FPS");
Chris@612 335 case TimeToText60Frame: return tr("60 FPS");
Chris@612 336 }
Chris@612 337 }
Chris@246 338
Chris@136 339 return "";
Chris@136 340 }
Chris@136 341
Chris@136 342 QString
Chris@136 343 Preferences::getPropertyContainerName() const
Chris@136 344 {
Chris@136 345 return tr("Preferences");
Chris@136 346 }
Chris@136 347
Chris@136 348 QString
Chris@136 349 Preferences::getPropertyContainerIconName() const
Chris@136 350 {
Chris@136 351 return "preferences";
Chris@136 352 }
Chris@136 353
Chris@136 354 void
Chris@136 355 Preferences::setProperty(const PropertyName &name, int value)
Chris@136 356 {
Chris@553 357 if (name == "Spectrogram Y Smoothing") {
Chris@246 358 setSpectrogramSmoothing(SpectrogramSmoothing(value));
Chris@553 359 } else if (name == "Spectrogram X Smoothing") {
Chris@553 360 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
Chris@136 361 } else if (name == "Tuning Frequency") {
Chris@136 362 //!!!
Chris@138 363 } else if (name == "Property Box Layout") {
Chris@138 364 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
Chris@140 365 } else if (name == "Window Type") {
Chris@140 366 setWindowType(WindowType(value));
Chris@164 367 } else if (name == "Resample Quality") {
Chris@164 368 setResampleQuality(value);
Chris@277 369 } else if (name == "Omit Temporaries from Recent Files") {
Chris@277 370 setOmitTempsFromRecentFiles(value ? true : false);
Chris@297 371 } else if (name == "Background Mode") {
Chris@297 372 setBackgroundMode(BackgroundMode(value));
Chris@612 373 } else if (name == "Time To Text Mode") {
Chris@612 374 setTimeToTextMode(TimeToTextMode(value));
Chris@354 375 } else if (name == "View Font Size") {
Chris@354 376 setViewFontSize(value);
Chris@372 377 } else if (name == "Show Splash Screen") {
Chris@372 378 setShowSplash(value ? true : false);
mathieu@694 379 } else if (name == "Start In Minimal Mode") {
mathieu@694 380 setStartInMiniMode(value ? true : false);
Chris@136 381 }
Chris@136 382 }
Chris@136 383
Chris@136 384 void
Chris@246 385 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
Chris@136 386 {
Chris@246 387 if (m_spectrogramSmoothing != smoothing) {
Chris@246 388
Chris@246 389 // "smoothing" is one of those words that looks increasingly
Chris@246 390 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@246 391 m_spectrogramSmoothing = smoothing;
Chris@246 392
Chris@156 393 QSettings settings;
Chris@156 394 settings.beginGroup("Preferences");
Chris@553 395 settings.setValue("spectrogram-y-smoothing", int(smoothing));
Chris@156 396 settings.endGroup();
Chris@553 397 emit propertyChanged("Spectrogram Y Smoothing");
Chris@553 398 }
Chris@553 399 }
Chris@553 400
Chris@553 401 void
Chris@553 402 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
Chris@553 403 {
Chris@553 404 if (m_spectrogramXSmoothing != smoothing) {
Chris@553 405
Chris@553 406 // "smoothing" is one of those words that looks increasingly
Chris@553 407 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@553 408 m_spectrogramXSmoothing = smoothing;
Chris@553 409
Chris@553 410 QSettings settings;
Chris@553 411 settings.beginGroup("Preferences");
Chris@553 412 settings.setValue("spectrogram-x-smoothing", int(smoothing));
Chris@553 413 settings.endGroup();
Chris@553 414 emit propertyChanged("Spectrogram X Smoothing");
Chris@138 415 }
Chris@136 416 }
Chris@136 417
Chris@136 418 void
Chris@136 419 Preferences::setTuningFrequency(float freq)
Chris@136 420 {
Chris@138 421 if (m_tuningFrequency != freq) {
Chris@138 422 m_tuningFrequency = freq;
Chris@156 423 QSettings settings;
Chris@156 424 settings.beginGroup("Preferences");
Chris@156 425 settings.setValue("tuning-frequency", freq);
Chris@156 426 settings.endGroup();
Chris@141 427 emit propertyChanged("Tuning Frequency");
Chris@138 428 }
Chris@136 429 }
Chris@136 430
Chris@138 431 void
Chris@138 432 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
Chris@138 433 {
Chris@138 434 if (m_propertyBoxLayout != layout) {
Chris@138 435 m_propertyBoxLayout = layout;
Chris@156 436 QSettings settings;
Chris@156 437 settings.beginGroup("Preferences");
Chris@156 438 settings.setValue("property-box-layout", int(layout));
Chris@156 439 settings.endGroup();
Chris@141 440 emit propertyChanged("Property Box Layout");
Chris@138 441 }
Chris@138 442 }
Chris@138 443
Chris@140 444 void
Chris@140 445 Preferences::setWindowType(WindowType type)
Chris@140 446 {
Chris@140 447 if (m_windowType != type) {
Chris@140 448 m_windowType = type;
Chris@156 449 QSettings settings;
Chris@156 450 settings.beginGroup("Preferences");
Chris@156 451 settings.setValue("window-type", int(type));
Chris@156 452 settings.endGroup();
Chris@141 453 emit propertyChanged("Window Type");
Chris@140 454 }
Chris@140 455 }
Chris@140 456
Chris@164 457 void
Chris@164 458 Preferences::setResampleQuality(int q)
Chris@164 459 {
Chris@164 460 if (m_resampleQuality != q) {
Chris@164 461 m_resampleQuality = q;
Chris@164 462 QSettings settings;
Chris@164 463 settings.beginGroup("Preferences");
Chris@164 464 settings.setValue("resample-quality", q);
Chris@164 465 settings.endGroup();
Chris@164 466 emit propertyChanged("Resample Quality");
Chris@164 467 }
Chris@164 468 }
Chris@277 469
Chris@277 470 void
Chris@277 471 Preferences::setOmitTempsFromRecentFiles(bool omit)
Chris@277 472 {
Chris@277 473 if (m_omitRecentTemps != omit) {
Chris@277 474 m_omitRecentTemps = omit;
Chris@277 475 QSettings settings;
Chris@277 476 settings.beginGroup("Preferences");
Chris@277 477 settings.setValue("omit-recent-temporaries", omit);
Chris@277 478 settings.endGroup();
Chris@277 479 emit propertyChanged("Omit Temporaries from Recent Files");
Chris@277 480 }
Chris@277 481 }
Chris@297 482
Chris@297 483 void
Chris@297 484 Preferences::setTemporaryDirectoryRoot(QString root)
Chris@297 485 {
Chris@297 486 if (root == QDir::home().absolutePath()) {
Chris@297 487 root = "$HOME";
Chris@297 488 }
Chris@297 489 if (m_tempDirRoot != root) {
Chris@297 490 m_tempDirRoot = root;
Chris@297 491 QSettings settings;
Chris@297 492 settings.beginGroup("TempDirectory");
Chris@297 493 settings.setValue("create-in", root);
Chris@297 494 settings.endGroup();
Chris@297 495 emit propertyChanged("Temporary Directory Root");
Chris@297 496 }
Chris@297 497 }
Chris@297 498
Chris@297 499 void
Chris@297 500 Preferences::setResampleOnLoad(bool resample)
Chris@297 501 {
Chris@297 502 if (m_resampleOnLoad != resample) {
Chris@297 503 m_resampleOnLoad = resample;
Chris@297 504 QSettings settings;
Chris@297 505 settings.beginGroup("Preferences");
Chris@297 506 settings.setValue("resample-on-load", resample);
Chris@297 507 settings.endGroup();
Chris@297 508 emit propertyChanged("Resample On Load");
Chris@297 509 }
Chris@297 510 }
Chris@297 511
Chris@297 512 void
Chris@297 513 Preferences::setBackgroundMode(BackgroundMode mode)
Chris@297 514 {
Chris@297 515 if (m_backgroundMode != mode) {
Chris@297 516
Chris@297 517 m_backgroundMode = mode;
Chris@297 518
Chris@297 519 QSettings settings;
Chris@297 520 settings.beginGroup("Preferences");
Chris@297 521 settings.setValue("background-mode", int(mode));
Chris@297 522 settings.endGroup();
Chris@297 523 emit propertyChanged("Background Mode");
Chris@297 524 }
Chris@297 525 }
Chris@297 526
Chris@354 527 void
Chris@612 528 Preferences::setTimeToTextMode(TimeToTextMode mode)
Chris@612 529 {
Chris@612 530 if (m_timeToTextMode != mode) {
Chris@612 531
Chris@612 532 m_timeToTextMode = mode;
Chris@612 533
Chris@612 534 QSettings settings;
Chris@612 535 settings.beginGroup("Preferences");
Chris@612 536 settings.setValue("time-to-text-mode", int(mode));
Chris@612 537 settings.endGroup();
Chris@612 538 emit propertyChanged("Time To Text Mode");
Chris@612 539 }
Chris@612 540 }
Chris@612 541
Chris@612 542 void
Chris@354 543 Preferences::setViewFontSize(int size)
Chris@354 544 {
Chris@354 545 if (m_viewFontSize != size) {
Chris@297 546
Chris@354 547 m_viewFontSize = size;
Chris@354 548
Chris@354 549 QSettings settings;
Chris@354 550 settings.beginGroup("Preferences");
Chris@354 551 settings.setValue("view-font-size", size);
Chris@354 552 settings.endGroup();
Chris@354 553 emit propertyChanged("View Font Size");
Chris@354 554 }
Chris@354 555 }
Chris@354 556
Chris@372 557 void
Chris@372 558 Preferences::setShowSplash(bool show)
Chris@372 559 {
Chris@372 560 if (m_showSplash != show) {
Chris@372 561
Chris@372 562 m_showSplash = show;
Chris@372 563
Chris@372 564 QSettings settings;
Chris@372 565 settings.beginGroup("Preferences");
Chris@372 566 settings.setValue("show-splash", show);
Chris@372 567 settings.endGroup();
Chris@372 568 emit propertyChanged("Show Splash Screen");
Chris@372 569 }
Chris@372 570 }
mathieu@694 571
mathieu@694 572 void
mathieu@694 573 Preferences::setStartInMiniMode(bool show)
mathieu@694 574 {
mathieu@694 575 if (m_startInMiniMode != show) {
mathieu@694 576
mathieu@694 577 m_startInMiniMode = show;
mathieu@694 578
mathieu@694 579 QSettings settings;
mathieu@694 580 settings.beginGroup("Preferences");
mathieu@694 581 settings.setValue("start-in-mini-mode", show);
mathieu@694 582 settings.endGroup();
mathieu@694 583 emit propertyChanged("Start Sonic Visualiser in minimal mode");
mathieu@694 584 }
mathieu@694 585 }
Chris@372 586