annotate main/PreferencesDialog.cpp @ 1439:3e77e9ecc520 3.0-integration

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