annotate main/PreferencesDialog.cpp @ 1474:8007556e7764 3.0-integration

Add record update timer (very crude this)
author Chris Cannam
date Wed, 04 Jan 2017 13:23:18 +0000
parents f5c828d1f3e2
children 06f061c54b66
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 Sonic Visualiser
Chris@0 5 An audio file viewer and annotation editor.
Chris@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@0 9 This program is free software; you can redistribute it and/or
Chris@0 10 modify it under the terms of the GNU General Public License as
Chris@0 11 published by the Free Software Foundation; either version 2 of the
Chris@0 12 License, or (at your option) any later version. See the file
Chris@0 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #include "PreferencesDialog.h"
Chris@0 17
Chris@0 18 #include <QGridLayout>
Chris@0 19 #include <QComboBox>
Chris@0 20 #include <QCheckBox>
Chris@0 21 #include <QGroupBox>
Chris@0 22 #include <QDoubleSpinBox>
Chris@0 23 #include <QLabel>
Chris@0 24 #include <QPushButton>
Chris@0 25 #include <QHBoxLayout>
Chris@0 26 #include <QString>
Chris@163 27 #include <QDialogButtonBox>
Chris@163 28 #include <QMessageBox>
Chris@180 29 #include <QTabWidget>
Chris@180 30 #include <QLineEdit>
Chris@180 31 #include <QFileDialog>
Chris@180 32 #include <QMessageBox>
Chris@225 33 #include <QSpinBox>
Chris@436 34 #include <QListWidget>
Chris@263 35 #include <QSettings>
Chris@0 36
Chris@436 37 #include <set>
Chris@436 38
Chris@9 39 #include "widgets/WindowTypeSelector.h"
Chris@180 40 #include "widgets/IconLoader.h"
Chris@1445 41 #include "widgets/ColourMapComboBox.h"
Chris@1448 42 #include "widgets/ColourComboBox.h"
Chris@0 43 #include "base/Preferences.h"
Chris@436 44 #include "base/ResourceFinder.h"
Chris@1096 45 #include "layer/ColourMapper.h"
Chris@1448 46 #include "layer/ColourDatabase.h"
Chris@0 47
Chris@1397 48 #include "bqaudioio/AudioFactory.h"
Chris@1035 49
Chris@686 50 #include "version.h"
Chris@686 51
Chris@1397 52 using namespace std;
Chris@1397 53
Chris@528 54 PreferencesDialog::PreferencesDialog(QWidget *parent) :
Chris@528 55 QDialog(parent),
Chris@1397 56 m_audioImplementation(0),
Chris@1397 57 m_audioPlaybackDevice(0),
Chris@1397 58 m_audioRecordDevice(0),
Chris@1413 59 m_audioDeviceChanged(false),
Chris@1448 60 m_coloursChanged(false),
Chris@180 61 m_changesOnRestart(false)
Chris@0 62 {
Chris@163 63 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
Chris@0 64
Chris@0 65 Preferences *prefs = Preferences::getInstance();
Chris@0 66
Chris@0 67 QGridLayout *grid = new QGridLayout;
Chris@0 68 setLayout(grid);
Chris@180 69
Chris@436 70 m_tabs = new QTabWidget;
Chris@436 71 grid->addWidget(m_tabs, 0, 0);
Chris@0 72
Chris@436 73 m_tabs->setTabPosition(QTabWidget::North);
Chris@0 74
Chris@0 75 // Create this first, as slots that get called from the ctor will
Chris@0 76 // refer to it
Chris@0 77 m_applyButton = new QPushButton(tr("Apply"));
Chris@0 78
Chris@180 79 // Create all the preference widgets first, then create the
Chris@180 80 // individual tab widgets and place the preferences in their
Chris@180 81 // appropriate places in one go afterwards
Chris@180 82
Chris@114 83 int min, max, deflt, i;
Chris@0 84
Chris@9 85 m_windowType = WindowType(prefs->getPropertyRangeAndValue
Chris@114 86 ("Window Type", &min, &max, &deflt));
Chris@9 87 m_windowTypeSelector = new WindowTypeSelector(m_windowType);
Chris@0 88
Chris@9 89 connect(m_windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
Chris@9 90 this, SLOT(windowTypeChanged(WindowType)));
Chris@0 91
Chris@1275 92 QCheckBox *vampProcessSeparation = new QCheckBox;
Chris@1275 93 m_runPluginsInProcess = prefs->getRunPluginsInProcess();
Chris@1275 94 vampProcessSeparation->setCheckState(m_runPluginsInProcess ? Qt::Unchecked :
Chris@1275 95 Qt::Checked);
Chris@1275 96 connect(vampProcessSeparation, SIGNAL(stateChanged(int)),
Chris@1275 97 this, SLOT(vampProcessSeparationChanged(int)));
Chris@1275 98
Chris@115 99 QComboBox *smoothing = new QComboBox;
Chris@115 100
Chris@299 101 int sm = prefs->getPropertyRangeAndValue("Spectrogram Y Smoothing", &min, &max,
Chris@115 102 &deflt);
Chris@115 103 m_spectrogramSmoothing = sm;
Chris@0 104
Chris@115 105 for (i = min; i <= max; ++i) {
Chris@299 106 smoothing->addItem(prefs->getPropertyValueLabel("Spectrogram Y Smoothing", i));
Chris@115 107 }
Chris@115 108
Chris@115 109 smoothing->setCurrentIndex(sm);
Chris@115 110
Chris@115 111 connect(smoothing, SIGNAL(currentIndexChanged(int)),
Chris@115 112 this, SLOT(spectrogramSmoothingChanged(int)));
Chris@0 113
Chris@299 114 QComboBox *xsmoothing = new QComboBox;
Chris@299 115
Chris@299 116 int xsm = prefs->getPropertyRangeAndValue("Spectrogram X Smoothing", &min, &max,
Chris@299 117 &deflt);
Chris@299 118 m_spectrogramXSmoothing = xsm;
Chris@299 119
Chris@299 120 for (i = min; i <= max; ++i) {
Chris@299 121 xsmoothing->addItem(prefs->getPropertyValueLabel("Spectrogram X Smoothing", i));
Chris@299 122 }
Chris@299 123
Chris@299 124 xsmoothing->setCurrentIndex(xsm);
Chris@299 125
Chris@299 126 connect(xsmoothing, SIGNAL(currentIndexChanged(int)),
Chris@299 127 this, SLOT(spectrogramXSmoothingChanged(int)));
Chris@299 128
Chris@0 129 QComboBox *propertyLayout = new QComboBox;
Chris@114 130 int pl = prefs->getPropertyRangeAndValue("Property Box Layout", &min, &max,
Chris@115 131 &deflt);
Chris@0 132 m_propertyLayout = pl;
Chris@0 133
Chris@0 134 for (i = min; i <= max; ++i) {
Chris@0 135 propertyLayout->addItem(prefs->getPropertyValueLabel("Property Box Layout", i));
Chris@0 136 }
Chris@0 137
Chris@0 138 propertyLayout->setCurrentIndex(pl);
Chris@0 139
Chris@0 140 connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
Chris@0 141 this, SLOT(propertyLayoutChanged(int)));
Chris@0 142
Chris@1096 143 QSettings settings;
Chris@1096 144 settings.beginGroup("Preferences");
Chris@1096 145 m_spectrogramGColour = (settings.value("spectrogram-colour",
Chris@1096 146 int(ColourMapper::Green)).toInt());
Chris@1096 147 m_spectrogramMColour = (settings.value("spectrogram-melodic-colour",
Chris@1096 148 int(ColourMapper::Sunset)).toInt());
Chris@1097 149 m_colour3DColour = (settings.value("colour-3d-plot-colour",
Chris@1097 150 int(ColourMapper::Green)).toInt());
cannam@1463 151 m_overviewColour = ColourDatabase::getInstance()->getColour(tr("Green"));
cannam@1463 152 if (settings.contains("overview-colour")) {
cannam@1463 153 QString qcolorName =
cannam@1463 154 settings.value("overview-colour", m_overviewColour.name())
cannam@1463 155 .toString();
cannam@1463 156 m_overviewColour.setNamedColor(qcolorName);
cannam@1463 157 cerr << "loaded colour " << m_overviewColour.name() << " from settings" << endl;
cannam@1463 158 }
Chris@1096 159 settings.endGroup();
Chris@1445 160
Chris@1445 161 ColourMapComboBox *spectrogramGColour = new ColourMapComboBox(true);
Chris@1445 162 spectrogramGColour->setCurrentIndex(m_spectrogramGColour);
Chris@1445 163
Chris@1445 164 ColourMapComboBox *spectrogramMColour = new ColourMapComboBox(true);
Chris@1445 165 spectrogramMColour->setCurrentIndex(m_spectrogramMColour);
Chris@1445 166
Chris@1445 167 ColourMapComboBox *colour3DColour = new ColourMapComboBox(true);
Chris@1445 168 colour3DColour->setCurrentIndex(m_colour3DColour);
Chris@1445 169
Chris@1448 170 // can't have "add new colour", as it gets saved in the session not in prefs
Chris@1448 171 ColourComboBox *overviewColour = new ColourComboBox(false);
Chris@1448 172 int overviewColourIndex =
Chris@1448 173 ColourDatabase::getInstance()->getColourIndex(m_overviewColour);
cannam@1463 174 cerr << "index = " << overviewColourIndex << " for colour " << m_overviewColour.name() << endl;
Chris@1448 175 if (overviewColourIndex >= 0) {
Chris@1448 176 overviewColour->setCurrentIndex(overviewColourIndex);
Chris@1448 177 }
Chris@1448 178
Chris@1445 179 connect(spectrogramGColour, SIGNAL(colourMapChanged(int)),
Chris@1096 180 this, SLOT(spectrogramGColourChanged(int)));
Chris@1445 181 connect(spectrogramMColour, SIGNAL(colourMapChanged(int)),
Chris@1096 182 this, SLOT(spectrogramMColourChanged(int)));
Chris@1445 183 connect(colour3DColour, SIGNAL(colourMapChanged(int)),
Chris@1097 184 this, SLOT(colour3DColourChanged(int)));
Chris@1448 185 connect(overviewColour, SIGNAL(colourChanged(int)),
Chris@1448 186 this, SLOT(overviewColourChanged(int)));
Chris@702 187
Chris@0 188 m_tuningFrequency = prefs->getTuningFrequency();
Chris@0 189
Chris@0 190 QDoubleSpinBox *frequency = new QDoubleSpinBox;
Chris@0 191 frequency->setMinimum(100.0);
Chris@0 192 frequency->setMaximum(5000.0);
Chris@0 193 frequency->setSuffix(" Hz");
Chris@0 194 frequency->setSingleStep(1);
Chris@0 195 frequency->setValue(m_tuningFrequency);
Chris@0 196 frequency->setDecimals(2);
Chris@0 197
Chris@0 198 connect(frequency, SIGNAL(valueChanged(double)),
Chris@0 199 this, SLOT(tuningFrequencyChanged(double)));
Chris@0 200
Chris@702 201 QComboBox *octaveSystem = new QComboBox;
Chris@702 202 int oct = prefs->getPropertyRangeAndValue
Chris@702 203 ("Octave Numbering System", &min, &max, &deflt);
Chris@702 204 m_octaveSystem = oct;
Chris@702 205 for (i = min; i <= max; ++i) {
Chris@702 206 octaveSystem->addItem(prefs->getPropertyValueLabel
Chris@702 207 ("Octave Numbering System", i));
Chris@702 208 }
Chris@702 209 octaveSystem->setCurrentIndex(oct);
Chris@702 210
Chris@702 211 connect(octaveSystem, SIGNAL(currentIndexChanged(int)),
Chris@702 212 this, SLOT(octaveSystemChanged(int)));
Chris@702 213
Chris@263 214 settings.beginGroup("Preferences");
Chris@1397 215
Chris@1397 216 QComboBox *audioImplementation = new QComboBox;
Chris@1397 217 connect(audioImplementation, SIGNAL(currentIndexChanged(int)),
Chris@1397 218 this, SLOT(audioImplementationChanged(int)));
Chris@1397 219
Chris@1397 220 m_audioPlaybackDeviceCombo = new QComboBox;
Chris@1397 221 connect(m_audioPlaybackDeviceCombo, SIGNAL(currentIndexChanged(int)),
Chris@1397 222 this, SLOT(audioPlaybackDeviceChanged(int)));
Chris@1397 223
Chris@1397 224 m_audioRecordDeviceCombo = new QComboBox;
Chris@1397 225 connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)),
Chris@1397 226 this, SLOT(audioRecordDeviceChanged(int)));
Chris@1397 227
Chris@1459 228 vector<string> implementationNames =
Chris@1459 229 breakfastquay::AudioFactory::getImplementationNames();
Chris@1459 230
Chris@1397 231 QString implementationName = settings.value("audio-target", "").toString();
Chris@1397 232 if (implementationName == "auto") implementationName = "";
Chris@1459 233 if (implementationName == "" && implementationNames.size() == 1) {
Chris@1459 234 // We won't be showing the implementations menu in this case
Chris@1459 235 implementationName = implementationNames[0].c_str();
Chris@1459 236 }
Chris@1459 237
Chris@1397 238 audioImplementation->addItem(tr("(auto)"));
Chris@1397 239 m_audioImplementation = 0;
Chris@1459 240
Chris@1459 241 for (int i = 0; in_range_for(implementationNames, i); ++i) {
Chris@1397 242 audioImplementation->addItem
Chris@1459 243 (breakfastquay::AudioFactory::getImplementationDescription
Chris@1459 244 (implementationNames[i]).c_str());
Chris@1459 245 if (implementationName.toStdString() == implementationNames[i]) {
Chris@1397 246 audioImplementation->setCurrentIndex(i+1);
Chris@1397 247 m_audioImplementation = i+1;
Chris@1397 248 }
Chris@1397 249 }
Chris@1459 250
Chris@263 251 settings.endGroup();
Chris@263 252
Chris@1397 253 rebuildDeviceCombos();
Chris@1413 254 m_audioDeviceChanged = false; // the rebuild will have changed this
Chris@32 255
Chris@180 256 QCheckBox *resampleOnLoad = new QCheckBox;
Chris@180 257 m_resampleOnLoad = prefs->getResampleOnLoad();
Chris@180 258 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
Chris@180 259 Qt::Unchecked);
Chris@180 260 connect(resampleOnLoad, SIGNAL(stateChanged(int)),
Chris@180 261 this, SLOT(resampleOnLoadChanged(int)));
Chris@180 262
Chris@1379 263 QCheckBox *gaplessMode = new QCheckBox;
Chris@1379 264 m_gapless = prefs->getUseGaplessMode();
Chris@1379 265 gaplessMode->setCheckState(m_gapless ? Qt::Checked : Qt::Unchecked);
Chris@1379 266 connect(gaplessMode, SIGNAL(stateChanged(int)),
Chris@1379 267 this, SLOT(gaplessModeChanged(int)));
Chris@1379 268
Chris@180 269 m_tempDirRootEdit = new QLineEdit;
Chris@180 270 QString dir = prefs->getTemporaryDirectoryRoot();
Chris@180 271 m_tempDirRoot = dir;
Chris@180 272 dir.replace("$HOME", tr("<home directory>"));
Chris@180 273 m_tempDirRootEdit->setText(dir);
Chris@180 274 m_tempDirRootEdit->setReadOnly(true);
Chris@180 275 QPushButton *tempDirButton = new QPushButton;
Chris@180 276 tempDirButton->setIcon(IconLoader().load("fileopen"));
Chris@180 277 connect(tempDirButton, SIGNAL(clicked()),
Chris@180 278 this, SLOT(tempDirButtonClicked()));
Chris@180 279 tempDirButton->setFixedSize(QSize(24, 24));
Chris@180 280
Chris@237 281 QCheckBox *showSplash = new QCheckBox;
Chris@237 282 m_showSplash = prefs->getShowSplash();
Chris@237 283 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked);
Chris@237 284 connect(showSplash, SIGNAL(stateChanged(int)),
Chris@237 285 this, SLOT(showSplashChanged(int)));
Chris@237 286
Chris@1092 287 #ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS
Chris@180 288 QComboBox *bgMode = new QComboBox;
Chris@180 289 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
Chris@180 290 &deflt);
Chris@180 291 m_backgroundMode = bg;
Chris@180 292 for (i = min; i <= max; ++i) {
Chris@180 293 bgMode->addItem(prefs->getPropertyValueLabel("Background Mode", i));
Chris@180 294 }
Chris@180 295 bgMode->setCurrentIndex(bg);
Chris@180 296
Chris@180 297 connect(bgMode, SIGNAL(currentIndexChanged(int)),
Chris@180 298 this, SLOT(backgroundModeChanged(int)));
Chris@237 299 #endif
Chris@180 300
Chris@658 301 settings.beginGroup("Preferences");
Chris@686 302
Chris@950 303 #ifdef Q_OS_MAC
Chris@950 304 m_retina = settings.value("scaledHiDpi", true).toBool();
Chris@950 305 QCheckBox *retina = new QCheckBox;
Chris@950 306 retina->setCheckState(m_retina ? Qt::Checked : Qt::Unchecked);
Chris@950 307 connect(retina, SIGNAL(stateChanged(int)), this, SLOT(retinaChanged(int)));
Chris@950 308 #else
Chris@950 309 m_retina = false;
Chris@950 310 #endif
Chris@950 311
Chris@658 312 QString userLocale = settings.value("locale", "").toString();
Chris@658 313 m_currentLocale = userLocale;
Chris@686 314
Chris@686 315 QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
Chris@686 316 m_networkPermission = settings.value(permishTag, false).toBool();
Chris@686 317
Chris@658 318 settings.endGroup();
Chris@658 319
Chris@658 320 QComboBox *locale = new QComboBox;
Chris@658 321 QStringList localeFiles = QDir(":i18n").entryList(QStringList() << "*.qm");
Chris@658 322 locale->addItem(tr("Follow system locale"));
Chris@658 323 m_locales.push_back("");
Chris@658 324 if (userLocale == "") {
Chris@658 325 locale->setCurrentIndex(0);
Chris@658 326 }
Chris@658 327 foreach (QString f, localeFiles) {
Chris@658 328 QString f0 = f;
Chris@658 329 f.replace("sonic-visualiser_", "").replace(".qm", "");
Chris@658 330 if (f == f0) { // our expectations about filename format were not met
Chris@665 331 cerr << "INFO: Unexpected filename " << f << " in i18n resource directory" << endl;
Chris@658 332 } else {
Chris@658 333 m_locales.push_back(f);
Chris@658 334 QString displayText;
Chris@658 335 // Add new translations here
Chris@658 336 if (f == "ru") displayText = tr("Russian");
Chris@658 337 else if (f == "en_GB") displayText = tr("British English");
Chris@658 338 else if (f == "en_US") displayText = tr("American English");
Chris@658 339 else if (f == "cs_CZ") displayText = tr("Czech");
Chris@658 340 else displayText = f;
Chris@658 341 locale->addItem(QString("%1 [%2]").arg(displayText).arg(f));
Chris@658 342 if (userLocale == f) {
Chris@658 343 locale->setCurrentIndex(locale->count() - 1);
Chris@658 344 }
Chris@658 345 }
Chris@658 346 }
Chris@658 347 connect(locale, SIGNAL(currentIndexChanged(int)),
Chris@658 348 this, SLOT(localeChanged(int)));
Chris@658 349
Chris@686 350 QCheckBox *networkPermish = new QCheckBox;
Chris@686 351 networkPermish->setCheckState(m_networkPermission ? Qt::Checked : Qt::Unchecked);
Chris@686 352 connect(networkPermish, SIGNAL(stateChanged(int)),
Chris@686 353 this, SLOT(networkPermissionChanged(int)));
Chris@686 354
Chris@225 355 QSpinBox *fontSize = new QSpinBox;
Chris@225 356 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
Chris@225 357 &deflt);
Chris@234 358 m_viewFontSize = fs;
Chris@225 359 fontSize->setMinimum(min);
Chris@225 360 fontSize->setMaximum(max);
Chris@225 361 fontSize->setSuffix(" pt");
Chris@225 362 fontSize->setSingleStep(1);
Chris@225 363 fontSize->setValue(fs);
Chris@225 364
Chris@225 365 connect(fontSize, SIGNAL(valueChanged(int)),
Chris@225 366 this, SLOT(viewFontSizeChanged(int)));
Chris@225 367
Chris@337 368 QComboBox *ttMode = new QComboBox;
Chris@337 369 int tt = prefs->getPropertyRangeAndValue("Time To Text Mode", &min, &max,
Chris@337 370 &deflt);
Chris@337 371 m_timeToTextMode = tt;
Chris@337 372 for (i = min; i <= max; ++i) {
Chris@337 373 ttMode->addItem(prefs->getPropertyValueLabel("Time To Text Mode", i));
Chris@337 374 }
Chris@337 375 ttMode->setCurrentIndex(tt);
Chris@337 376
Chris@337 377 connect(ttMode, SIGNAL(currentIndexChanged(int)),
Chris@337 378 this, SLOT(timeToTextModeChanged(int)));
Chris@337 379
Chris@906 380 QCheckBox *hms = new QCheckBox;
Chris@906 381 int showHMS = prefs->getPropertyRangeAndValue
Chris@906 382 ("Show Hours And Minutes", &min, &max, &deflt);
Chris@906 383 m_showHMS = (showHMS != 0);
Chris@906 384 hms->setCheckState(m_showHMS ? Qt::Checked : Qt::Unchecked);
Chris@906 385 connect(hms, SIGNAL(stateChanged(int)),
Chris@906 386 this, SLOT(showHMSChanged(int)));
Chris@180 387
Chris@1436 388 QFrame *frame = 0;
Chris@1436 389 QGridLayout *subgrid = 0;
Chris@0 390 int row = 0;
Chris@0 391
Chris@263 392 // Appearance tab
Chris@263 393
Chris@263 394 frame = new QFrame;
Chris@263 395 subgrid = new QGridLayout;
Chris@263 396 frame->setLayout(subgrid);
Chris@263 397 row = 0;
Chris@263 398
Chris@950 399 #ifdef Q_OS_MAC
Chris@950 400 if (devicePixelRatio() > 1) {
Chris@950 401 subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0);
Chris@950 402 subgrid->addWidget(retina, row++, 1, 1, 1);
Chris@950 403 }
Chris@950 404 #endif
Chris@950 405
Chris@906 406 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 407 ("Property Box Layout"))),
Chris@0 408 row, 0);
Chris@0 409 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
Chris@0 410
Chris@1098 411 subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")),
Chris@1096 412 row, 0);
Chris@1096 413 subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2);
Chris@1096 414
Chris@1098 415 subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")),
Chris@1096 416 row, 0);
Chris@1096 417 subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2);
Chris@1096 418
Chris@1098 419 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")),
Chris@1097 420 row, 0);
Chris@1097 421 subgrid->addWidget(colour3DColour, row++, 1, 1, 2);
Chris@1097 422
Chris@1448 423 subgrid->addWidget(new QLabel(tr("Overview waveform colour:")),
Chris@1448 424 row, 0);
Chris@1448 425 subgrid->addWidget(overviewColour, row++, 1, 1, 2);
Chris@1448 426
Chris@1092 427 #ifdef NOT_DEFINED // see earlier
Chris@0 428 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 429 ("Background Mode"))),
Chris@0 430 row, 0);
Chris@180 431 subgrid->addWidget(bgMode, row++, 1, 1, 2);
Chris@242 432 #endif
Chris@180 433
Chris@180 434 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@225 435 ("View Font Size"))),
Chris@225 436 row, 0);
Chris@225 437 subgrid->addWidget(fontSize, row++, 1, 1, 2);
Chris@225 438
Chris@225 439 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@337 440 ("Time To Text Mode"))),
Chris@337 441 row, 0);
Chris@337 442 subgrid->addWidget(ttMode, row++, 1, 1, 2);
Chris@337 443
Chris@337 444 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@906 445 ("Show Hours And Minutes"))),
Chris@237 446 row, 0);
Chris@906 447 subgrid->addWidget(hms, row++, 1, 1, 1);
Chris@237 448
Chris@180 449 subgrid->setRowStretch(row, 10);
Chris@180 450
Chris@436 451 m_tabOrdering[AppearanceTab] = m_tabs->count();
Chris@436 452 m_tabs->addTab(frame, tr("&Appearance"));
Chris@180 453
Chris@180 454 // Analysis tab
Chris@180 455
Chris@180 456 frame = new QFrame;
Chris@180 457 subgrid = new QGridLayout;
Chris@180 458 frame->setLayout(subgrid);
Chris@180 459 row = 0;
Chris@180 460
Chris@180 461 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 462 ("Tuning Frequency"))),
Chris@180 463 row, 0);
Chris@180 464 subgrid->addWidget(frequency, row++, 1, 1, 2);
Chris@180 465
Chris@702 466 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@702 467 ("Octave Numbering System"))),
Chris@702 468 row, 0);
Chris@702 469 subgrid->addWidget(octaveSystem, row++, 1, 1, 2);
Chris@702 470
Chris@0 471 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 472 ("Spectrogram Y Smoothing")),
Chris@115 473 row, 0);
Chris@115 474 subgrid->addWidget(smoothing, row++, 1, 1, 2);
Chris@0 475
Chris@299 476 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 477 ("Spectrogram X Smoothing")),
Chris@299 478 row, 0);
Chris@299 479 subgrid->addWidget(xsmoothing, row++, 1, 1, 2);
Chris@299 480
Chris@0 481 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 482 ("Window Type"))),
Chris@0 483 row, 0);
Chris@9 484 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
Chris@1275 485
Chris@9 486 subgrid->setRowStretch(row, 10);
Chris@9 487 row++;
Chris@1275 488
Chris@1275 489 subgrid->addWidget(new QLabel(tr("Run Vamp plugins in separate process:")),
Chris@1275 490 row, 0);
Chris@1275 491 subgrid->addWidget(vampProcessSeparation, row++, 1, 1, 1);
Chris@0 492
Chris@180 493 subgrid->setRowStretch(row, 10);
Chris@180 494
Chris@436 495 m_tabOrdering[AnalysisTab] = m_tabs->count();
Chris@436 496 m_tabs->addTab(frame, tr("Anal&ysis"));
Chris@436 497
Chris@436 498 // Template tab
Chris@436 499
Chris@436 500 frame = new QFrame;
Chris@436 501 subgrid = new QGridLayout;
Chris@436 502 frame->setLayout(subgrid);
Chris@436 503 row = 0;
Chris@436 504
Chris@1436 505 subgrid->addWidget(new QLabel(tr("Default session template when loading audio files:")), row++, 0);
Chris@436 506
Chris@436 507 QListWidget *lw = new QListWidget();
Chris@436 508 subgrid->addWidget(lw, row, 0);
Chris@436 509 subgrid->setRowStretch(row, 10);
Chris@436 510 row++;
Chris@436 511
Chris@1425 512 subgrid->addWidget(new QLabel(tr("(Use \"%1\" in the File menu to add to these.)")
Chris@1425 513 .arg(tr("Export Session as Template..."))),
Chris@1425 514 row++, 0);
Chris@1425 515
Chris@436 516 settings.beginGroup("MainWindow");
Chris@436 517 m_currentTemplate = settings.value("sessiontemplate", "").toString();
Chris@436 518 settings.endGroup();
Chris@436 519
Chris@455 520 lw->addItem(tr("Standard Waveform"));
Chris@436 521 if (m_currentTemplate == "" || m_currentTemplate == "default") {
Chris@436 522 lw->setCurrentRow(lw->count()-1);
Chris@436 523 }
Chris@436 524 m_templates.push_back("");
Chris@436 525
Chris@436 526 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
Chris@436 527
Chris@1397 528 set<QString> byName;
Chris@436 529 foreach (QString t, templates) {
Chris@436 530 byName.insert(QFileInfo(t).baseName());
Chris@436 531 }
Chris@436 532
Chris@436 533 foreach (QString t, byName) {
Chris@436 534 if (t.toLower() == "default") continue;
Chris@436 535 m_templates.push_back(t);
Chris@436 536 lw->addItem(t);
Chris@436 537 if (m_currentTemplate == t) {
Chris@436 538 lw->setCurrentRow(lw->count()-1);
Chris@436 539 }
Chris@436 540 }
Chris@436 541
Chris@436 542 connect(lw, SIGNAL(currentRowChanged(int)), this, SLOT(defaultTemplateChanged(int)));
Chris@436 543
Chris@436 544 m_tabOrdering[TemplateTab] = m_tabs->count();
Chris@436 545 m_tabs->addTab(frame, tr("Session &Template"));
Chris@180 546
Chris@1436 547 // Audio IO tab
Chris@1436 548
Chris@1436 549 frame = new QFrame;
Chris@1436 550 subgrid = new QGridLayout;
Chris@1436 551 frame->setLayout(subgrid);
Chris@1436 552 row = 0;
Chris@1436 553
Chris@1459 554 if (implementationNames.size() > 1) {
Chris@1459 555 subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0);
Chris@1459 556 subgrid->addWidget(audioImplementation, row++, 1, 1, 2);
Chris@1459 557 }
Chris@1436 558
Chris@1436 559 subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0);
Chris@1436 560 subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2);
Chris@1436 561
Chris@1436 562 subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0);
Chris@1436 563 subgrid->addWidget(m_audioRecordDeviceCombo, row++, 1, 1, 2);
Chris@1436 564
Chris@1436 565 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@1436 566 ("Use Gapless Mode"))),
Chris@1436 567 row, 0);
Chris@1436 568 subgrid->addWidget(gaplessMode, row++, 1, 1, 1);
Chris@1436 569
Chris@1436 570 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@1436 571 ("Resample On Load"))),
Chris@1436 572 row, 0);
Chris@1436 573 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
Chris@1436 574
Chris@1436 575 subgrid->setRowStretch(row, 10);
Chris@1436 576
Chris@1436 577 m_tabOrdering[AudioIOTab] = m_tabs->count();
Chris@1436 578 m_tabs->addTab(frame, tr("A&udio I/O"));
Chris@1436 579
Chris@1436 580 // General tab
Chris@1436 581
Chris@1436 582 frame = new QFrame;
Chris@1436 583 subgrid = new QGridLayout;
Chris@1436 584 frame->setLayout(subgrid);
Chris@1436 585 row = 0;
Chris@1436 586
Chris@1436 587 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("User interface language"))),
Chris@1436 588 row, 0);
Chris@1436 589 subgrid->addWidget(locale, row++, 1, 1, 1);
Chris@1436 590
Chris@1436 591 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("Allow network usage"))),
Chris@1436 592 row, 0);
Chris@1436 593 subgrid->addWidget(networkPermish, row++, 1, 1, 1);
Chris@1436 594
Chris@1436 595 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@1436 596 ("Show Splash Screen"))),
Chris@1436 597 row, 0);
Chris@1436 598 subgrid->addWidget(showSplash, row++, 1, 1, 1);
Chris@1436 599
Chris@1436 600 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@1436 601 ("Temporary Directory Root"))),
Chris@1436 602 row, 0);
Chris@1436 603 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
Chris@1436 604 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
Chris@1436 605 row++;
Chris@1436 606
Chris@1436 607 subgrid->setRowStretch(row, 10);
Chris@1436 608
Chris@1436 609 m_tabOrdering[GeneralTab] = m_tabs->count();
Chris@1436 610 m_tabs->addTab(frame, tr("&Other"));
Chris@1436 611
Chris@163 612 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
Chris@163 613 grid->addWidget(bb, 1, 0);
Chris@0 614
Chris@0 615 QPushButton *ok = new QPushButton(tr("OK"));
Chris@0 616 QPushButton *cancel = new QPushButton(tr("Cancel"));
Chris@163 617 bb->addButton(ok, QDialogButtonBox::AcceptRole);
Chris@163 618 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
Chris@163 619 bb->addButton(cancel, QDialogButtonBox::RejectRole);
Chris@0 620 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
Chris@0 621 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
Chris@0 622 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
Chris@0 623
Chris@0 624 m_applyButton->setEnabled(false);
Chris@0 625 }
Chris@0 626
Chris@0 627 PreferencesDialog::~PreferencesDialog()
Chris@0 628 {
Chris@438 629 SVDEBUG << "PreferencesDialog::~PreferencesDialog()" << endl;
Chris@0 630 }
Chris@0 631
Chris@0 632 void
Chris@1397 633 PreferencesDialog::rebuildDeviceCombos()
Chris@1397 634 {
Chris@1397 635 QSettings settings;
Chris@1397 636 settings.beginGroup("Preferences");
Chris@1397 637
Chris@1397 638 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
Chris@1397 639 string implementationName;
Chris@1459 640
Chris@1397 641 if (in_range_for(names, m_audioImplementation-1)) {
Chris@1397 642 implementationName = names[m_audioImplementation-1];
Chris@1397 643 }
Chris@1397 644
Chris@1397 645 QString suffix;
Chris@1397 646 if (implementationName != "") {
Chris@1397 647 suffix = "-" + QString(implementationName.c_str());
Chris@1397 648 }
Chris@1397 649
Chris@1397 650 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
Chris@1397 651 QString playbackDeviceName = settings.value
Chris@1397 652 ("audio-playback-device" + suffix, "").toString();
Chris@1417 653 m_audioPlaybackDeviceCombo->clear();
Chris@1397 654 m_audioPlaybackDeviceCombo->addItem(tr("(auto)"));
Chris@1397 655 m_audioPlaybackDeviceCombo->setCurrentIndex(0);
Chris@1397 656 m_audioPlaybackDevice = 0;
Chris@1397 657 for (int i = 0; in_range_for(names, i); ++i) {
Chris@1397 658 m_audioPlaybackDeviceCombo->addItem(names[i].c_str());
Chris@1397 659 if (playbackDeviceName.toStdString() == names[i]) {
Chris@1397 660 m_audioPlaybackDeviceCombo->setCurrentIndex(i+1);
Chris@1397 661 m_audioPlaybackDevice = i+1;
Chris@1397 662 }
Chris@1397 663 }
Chris@1397 664
Chris@1397 665 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
Chris@1397 666 QString recordDeviceName = settings.value
Chris@1397 667 ("audio-record-device" + suffix, "").toString();
Chris@1417 668 m_audioRecordDeviceCombo->clear();
Chris@1397 669 m_audioRecordDeviceCombo->addItem(tr("(auto)"));
Chris@1397 670 m_audioRecordDeviceCombo->setCurrentIndex(0);
Chris@1397 671 m_audioRecordDevice = 0;
Chris@1397 672 for (int i = 0; in_range_for(names, i); ++i) {
Chris@1397 673 m_audioRecordDeviceCombo->addItem(names[i].c_str());
Chris@1397 674 if (recordDeviceName.toStdString() == names[i]) {
Chris@1397 675 m_audioRecordDeviceCombo->setCurrentIndex(i+1);
Chris@1397 676 m_audioRecordDevice = i+1;
Chris@1397 677 }
Chris@1397 678 }
Chris@1397 679
Chris@1397 680 settings.endGroup();
Chris@1397 681 }
Chris@1397 682
Chris@1397 683 void
Chris@436 684 PreferencesDialog::switchToTab(Tab t)
Chris@436 685 {
Chris@436 686 if (m_tabOrdering.contains(t)) {
Chris@436 687 m_tabs->setCurrentIndex(m_tabOrdering[t]);
Chris@436 688 }
Chris@436 689 }
Chris@436 690
Chris@436 691 void
Chris@9 692 PreferencesDialog::windowTypeChanged(WindowType type)
Chris@0 693 {
Chris@0 694 m_windowType = type;
Chris@0 695 m_applyButton->setEnabled(true);
Chris@0 696 }
Chris@0 697
Chris@0 698 void
Chris@115 699 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
Chris@0 700 {
Chris@115 701 m_spectrogramSmoothing = smoothing;
Chris@0 702 m_applyButton->setEnabled(true);
Chris@0 703 }
Chris@0 704
Chris@0 705 void
Chris@299 706 PreferencesDialog::spectrogramXSmoothingChanged(int smoothing)
Chris@299 707 {
Chris@299 708 m_spectrogramXSmoothing = smoothing;
Chris@299 709 m_applyButton->setEnabled(true);
Chris@299 710 }
Chris@299 711
Chris@299 712 void
Chris@1096 713 PreferencesDialog::spectrogramGColourChanged(int colour)
Chris@1096 714 {
Chris@1096 715 m_spectrogramGColour = colour;
Chris@1448 716 m_coloursChanged = true;
Chris@1096 717 m_applyButton->setEnabled(true);
Chris@1096 718 }
Chris@1096 719
Chris@1096 720 void
Chris@1096 721 PreferencesDialog::spectrogramMColourChanged(int colour)
Chris@1096 722 {
Chris@1096 723 m_spectrogramMColour = colour;
Chris@1448 724 m_coloursChanged = true;
Chris@1096 725 m_applyButton->setEnabled(true);
Chris@1096 726 }
Chris@1096 727
Chris@1096 728 void
Chris@1097 729 PreferencesDialog::colour3DColourChanged(int colour)
Chris@1097 730 {
Chris@1097 731 m_colour3DColour = colour;
Chris@1448 732 m_coloursChanged = true;
Chris@1448 733 m_applyButton->setEnabled(true);
Chris@1448 734 }
Chris@1448 735
Chris@1448 736 void
Chris@1448 737 PreferencesDialog::overviewColourChanged(int colour)
Chris@1448 738 {
Chris@1448 739 m_overviewColour = ColourDatabase::getInstance()->getColour(colour);
Chris@1448 740 m_coloursChanged = true;
Chris@1097 741 m_applyButton->setEnabled(true);
Chris@1097 742 }
Chris@1097 743
Chris@1097 744 void
Chris@0 745 PreferencesDialog::propertyLayoutChanged(int layout)
Chris@0 746 {
Chris@0 747 m_propertyLayout = layout;
Chris@0 748 m_applyButton->setEnabled(true);
Chris@0 749 }
Chris@0 750
Chris@0 751 void
Chris@0 752 PreferencesDialog::tuningFrequencyChanged(double freq)
Chris@0 753 {
Chris@0 754 m_tuningFrequency = freq;
Chris@0 755 m_applyButton->setEnabled(true);
Chris@0 756 }
Chris@0 757
Chris@0 758 void
Chris@1397 759 PreferencesDialog::audioImplementationChanged(int s)
Chris@263 760 {
Chris@1397 761 if (m_audioImplementation != s) {
Chris@1397 762 m_audioImplementation = s;
Chris@1397 763 rebuildDeviceCombos();
Chris@1397 764 m_applyButton->setEnabled(true);
Chris@1413 765 m_audioDeviceChanged = true;
Chris@1397 766 }
Chris@1397 767 }
Chris@1397 768
Chris@1397 769 void
Chris@1397 770 PreferencesDialog::audioPlaybackDeviceChanged(int s)
Chris@1397 771 {
Chris@1397 772 if (m_audioPlaybackDevice != s) {
Chris@1397 773 m_audioPlaybackDevice = s;
Chris@1397 774 m_applyButton->setEnabled(true);
Chris@1413 775 m_audioDeviceChanged = true;
Chris@1397 776 }
Chris@1397 777 }
Chris@1397 778
Chris@1397 779 void
Chris@1397 780 PreferencesDialog::audioRecordDeviceChanged(int s)
Chris@1397 781 {
Chris@1397 782 if (m_audioRecordDevice != s) {
Chris@1397 783 m_audioRecordDevice = s;
Chris@1397 784 m_applyButton->setEnabled(true);
Chris@1413 785 m_audioDeviceChanged = true;
Chris@1397 786 }
Chris@263 787 }
Chris@263 788
Chris@263 789 void
Chris@180 790 PreferencesDialog::resampleOnLoadChanged(int state)
Chris@180 791 {
Chris@180 792 m_resampleOnLoad = (state == Qt::Checked);
Chris@180 793 m_applyButton->setEnabled(true);
Chris@180 794 m_changesOnRestart = true;
Chris@180 795 }
Chris@180 796
Chris@180 797 void
Chris@1379 798 PreferencesDialog::gaplessModeChanged(int state)
Chris@1379 799 {
Chris@1379 800 m_gapless = (state == Qt::Checked);
Chris@1379 801 m_applyButton->setEnabled(true);
Chris@1379 802 }
Chris@1379 803
Chris@1379 804 void
Chris@1275 805 PreferencesDialog::vampProcessSeparationChanged(int state)
Chris@1275 806 {
Chris@1275 807 m_runPluginsInProcess = (state == Qt::Unchecked);
Chris@1275 808 m_applyButton->setEnabled(true);
Chris@1275 809 m_changesOnRestart = true;
Chris@1275 810 }
Chris@1275 811
Chris@1275 812 void
Chris@686 813 PreferencesDialog::networkPermissionChanged(int state)
Chris@686 814 {
Chris@686 815 m_networkPermission = (state == Qt::Checked);
Chris@686 816 m_applyButton->setEnabled(true);
Chris@686 817 m_changesOnRestart = true;
Chris@686 818 }
Chris@686 819
Chris@686 820 void
Chris@950 821 PreferencesDialog::retinaChanged(int state)
Chris@950 822 {
Chris@950 823 m_retina = (state == Qt::Checked);
Chris@950 824 m_applyButton->setEnabled(true);
Chris@950 825 // Does not require a restart
Chris@950 826 }
Chris@950 827
Chris@950 828 void
Chris@237 829 PreferencesDialog::showSplashChanged(int state)
Chris@237 830 {
Chris@237 831 m_showSplash = (state == Qt::Checked);
Chris@237 832 m_applyButton->setEnabled(true);
Chris@237 833 m_changesOnRestart = true;
Chris@237 834 }
Chris@237 835
Chris@237 836 void
Chris@436 837 PreferencesDialog::defaultTemplateChanged(int i)
Chris@436 838 {
Chris@436 839 m_currentTemplate = m_templates[i];
Chris@436 840 m_applyButton->setEnabled(true);
Chris@436 841 }
Chris@436 842
Chris@436 843 void
Chris@658 844 PreferencesDialog::localeChanged(int i)
Chris@658 845 {
Chris@658 846 m_currentLocale = m_locales[i];
Chris@658 847 m_applyButton->setEnabled(true);
Chris@658 848 m_changesOnRestart = true;
Chris@658 849 }
Chris@658 850
Chris@658 851 void
Chris@180 852 PreferencesDialog::tempDirRootChanged(QString r)
Chris@180 853 {
Chris@180 854 m_tempDirRoot = r;
Chris@180 855 m_applyButton->setEnabled(true);
Chris@180 856 }
Chris@180 857
Chris@180 858 void
Chris@180 859 PreferencesDialog::tempDirButtonClicked()
Chris@180 860 {
Chris@180 861 QString dir = QFileDialog::getExistingDirectory
Chris@180 862 (this, tr("Select a directory to create cache subdirectory in"),
Chris@180 863 m_tempDirRoot);
Chris@180 864 if (dir == "") return;
Chris@180 865 m_tempDirRootEdit->setText(dir);
Chris@180 866 tempDirRootChanged(dir);
Chris@180 867 m_changesOnRestart = true;
Chris@180 868 }
Chris@180 869
Chris@180 870 void
Chris@180 871 PreferencesDialog::backgroundModeChanged(int mode)
Chris@180 872 {
Chris@180 873 m_backgroundMode = mode;
Chris@180 874 m_applyButton->setEnabled(true);
Chris@180 875 m_changesOnRestart = true;
Chris@180 876 }
Chris@180 877
Chris@180 878 void
Chris@337 879 PreferencesDialog::timeToTextModeChanged(int mode)
Chris@337 880 {
Chris@337 881 m_timeToTextMode = mode;
Chris@337 882 m_applyButton->setEnabled(true);
Chris@337 883 }
Chris@337 884
Chris@337 885 void
Chris@906 886 PreferencesDialog::showHMSChanged(int state)
Chris@906 887 {
Chris@906 888 m_showHMS = (state == Qt::Checked);
Chris@906 889 m_applyButton->setEnabled(true);
Chris@906 890 }
Chris@906 891
Chris@906 892 void
Chris@702 893 PreferencesDialog::octaveSystemChanged(int system)
Chris@702 894 {
Chris@702 895 m_octaveSystem = system;
Chris@702 896 m_applyButton->setEnabled(true);
Chris@702 897 }
Chris@702 898
Chris@702 899 void
Chris@225 900 PreferencesDialog::viewFontSizeChanged(int sz)
Chris@225 901 {
Chris@225 902 m_viewFontSize = sz;
Chris@225 903 m_applyButton->setEnabled(true);
Chris@225 904 }
Chris@225 905
Chris@225 906 void
Chris@0 907 PreferencesDialog::okClicked()
Chris@0 908 {
Chris@0 909 applyClicked();
Chris@0 910 accept();
Chris@0 911 }
Chris@0 912
Chris@0 913 void
Chris@0 914 PreferencesDialog::applyClicked()
Chris@0 915 {
Chris@0 916 Preferences *prefs = Preferences::getInstance();
Chris@0 917 prefs->setWindowType(WindowType(m_windowType));
Chris@115 918 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
Chris@115 919 (m_spectrogramSmoothing));
Chris@299 920 prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing
Chris@299 921 (m_spectrogramXSmoothing));
Chris@0 922 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
Chris@0 923 (m_propertyLayout));
Chris@0 924 prefs->setTuningFrequency(m_tuningFrequency);
Chris@180 925 prefs->setResampleOnLoad(m_resampleOnLoad);
Chris@1379 926 prefs->setUseGaplessMode(m_gapless);
Chris@1276 927 prefs->setRunPluginsInProcess(m_runPluginsInProcess);
Chris@237 928 prefs->setShowSplash(m_showSplash);
Chris@180 929 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
Chris@180 930 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
Chris@337 931 prefs->setTimeToTextMode(Preferences::TimeToTextMode(m_timeToTextMode));
Chris@906 932 prefs->setShowHMS(m_showHMS);
Chris@225 933 prefs->setViewFontSize(m_viewFontSize);
Chris@263 934
Chris@702 935 prefs->setProperty("Octave Numbering System", m_octaveSystem);
Chris@702 936
Chris@263 937 QSettings settings;
Chris@263 938 settings.beginGroup("Preferences");
Chris@686 939 QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
Chris@686 940 settings.setValue(permishTag, m_networkPermission);
Chris@1397 941
Chris@1397 942 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
Chris@1397 943 string implementationName;
Chris@1415 944 if (m_audioImplementation > int(names.size())) {
Chris@1415 945 m_audioImplementation = 0;
Chris@1415 946 }
Chris@1397 947 if (m_audioImplementation > 0) {
Chris@1397 948 implementationName = names[m_audioImplementation-1];
Chris@1397 949 }
Chris@1397 950 settings.setValue("audio-target", implementationName.c_str());
Chris@1397 951
Chris@1397 952 QString suffix;
Chris@1397 953 if (implementationName != "") {
Chris@1397 954 suffix = "-" + QString(implementationName.c_str());
Chris@1397 955 }
Chris@1397 956
Chris@1397 957 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
Chris@1397 958 string deviceName;
Chris@1415 959 if (m_audioPlaybackDevice > int(names.size())) {
Chris@1415 960 m_audioPlaybackDevice = 0;
Chris@1415 961 }
Chris@1397 962 if (m_audioPlaybackDevice > 0) {
Chris@1397 963 deviceName = names[m_audioPlaybackDevice-1];
Chris@1397 964 }
Chris@1397 965 settings.setValue("audio-playback-device" + suffix, deviceName.c_str());
Chris@1397 966
Chris@1397 967 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
Chris@1397 968 deviceName = "";
Chris@1415 969 if (m_audioRecordDevice > int(names.size())) {
Chris@1415 970 m_audioRecordDevice = 0;
Chris@1415 971 }
Chris@1397 972 if (m_audioRecordDevice > 0) {
Chris@1397 973 deviceName = names[m_audioRecordDevice-1];
Chris@1397 974 }
Chris@1397 975 settings.setValue("audio-record-device" + suffix, deviceName.c_str());
Chris@1397 976
Chris@686 977 settings.setValue("locale", m_currentLocale);
Chris@950 978 #ifdef Q_OS_MAC
Chris@950 979 settings.setValue("scaledHiDpi", m_retina);
Chris@950 980 #endif
Chris@1096 981 settings.setValue("spectrogram-colour", m_spectrogramGColour);
Chris@1096 982 settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
Chris@1097 983 settings.setValue("colour-3d-plot-colour", m_colour3DColour);
cannam@1463 984 settings.setValue("overview-colour", m_overviewColour.name());
Chris@263 985 settings.endGroup();
Chris@180 986
Chris@436 987 settings.beginGroup("MainWindow");
Chris@436 988 settings.setValue("sessiontemplate", m_currentTemplate);
Chris@436 989 settings.endGroup();
Chris@436 990
Chris@0 991 m_applyButton->setEnabled(false);
Chris@180 992
Chris@180 993 if (m_changesOnRestart) {
Chris@180 994 QMessageBox::information(this, tr("Preferences"),
Chris@255 995 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>"));
Chris@180 996 m_changesOnRestart = false;
Chris@180 997 }
Chris@1413 998
Chris@1413 999 if (m_audioDeviceChanged) {
Chris@1413 1000 emit audioDeviceChanged();
Chris@1415 1001 m_audioDeviceChanged = false;
Chris@1413 1002 }
Chris@1448 1003
Chris@1448 1004 if (m_coloursChanged) {
Chris@1448 1005 emit coloursChanged();
Chris@1448 1006 m_coloursChanged = false;
Chris@1448 1007 }
Chris@0 1008 }
Chris@0 1009
Chris@0 1010 void
Chris@0 1011 PreferencesDialog::cancelClicked()
Chris@0 1012 {
Chris@0 1013 reject();
Chris@0 1014 }
Chris@0 1015
Chris@163 1016 void
Chris@163 1017 PreferencesDialog::applicationClosing(bool quickly)
Chris@163 1018 {
Chris@163 1019 if (quickly) {
Chris@163 1020 reject();
Chris@163 1021 return;
Chris@163 1022 }
Chris@163 1023
Chris@163 1024 if (m_applyButton->isEnabled()) {
Chris@163 1025 int rv = QMessageBox::warning
Chris@163 1026 (this, tr("Preferences Changed"),
Chris@163 1027 tr("Some preferences have been changed but not applied.\n"
Chris@163 1028 "Apply them before closing?"),
Chris@163 1029 QMessageBox::Apply | QMessageBox::Discard,
Chris@163 1030 QMessageBox::Discard);
Chris@163 1031 if (rv == QMessageBox::Apply) {
Chris@163 1032 applyClicked();
Chris@163 1033 accept();
Chris@163 1034 } else {
Chris@163 1035 reject();
Chris@163 1036 }
Chris@163 1037 } else {
Chris@163 1038 accept();
Chris@163 1039 }
Chris@163 1040 }
Chris@163 1041