annotate main/PreferencesDialog.cpp @ 1415:13eb1d55f129 3.0-integration

Avoid overflowing vector if number of devices becomes smaller
author Chris Cannam
date Mon, 12 Dec 2016 17:01:16 +0000
parents a89ca5ccb958
children 8bff263578ae
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@906 356
Chris@180 357 // General tab
Chris@180 358
Chris@180 359 QFrame *frame = new QFrame;
Chris@180 360
Chris@180 361 QGridLayout *subgrid = new QGridLayout;
Chris@180 362 frame->setLayout(subgrid);
Chris@180 363
Chris@0 364 int row = 0;
Chris@0 365
Chris@658 366 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("User interface language"))),
Chris@658 367 row, 0);
Chris@658 368 subgrid->addWidget(locale, row++, 1, 1, 1);
Chris@658 369
Chris@686 370 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("Allow network usage"))),
Chris@686 371 row, 0);
Chris@686 372 subgrid->addWidget(networkPermish, row++, 1, 1, 1);
Chris@686 373
Chris@0 374 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@263 375 ("Temporary Directory Root"))),
Chris@263 376 row, 0);
Chris@263 377 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
Chris@263 378 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
Chris@263 379 row++;
Chris@263 380
Chris@263 381 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@263 382 ("Resample On Load"))),
Chris@263 383 row, 0);
Chris@263 384 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
Chris@263 385
Chris@1379 386 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@1379 387 ("Use Gapless Mode"))),
Chris@1379 388 row, 0);
Chris@1379 389 subgrid->addWidget(gaplessMode, row++, 1, 1, 1);
Chris@1379 390
Chris@1397 391 subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0);
Chris@1397 392 subgrid->addWidget(audioImplementation, row++, 1, 1, 2);
Chris@1397 393
Chris@1397 394 subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0);
Chris@1397 395 subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2);
Chris@1397 396
Chris@1397 397 subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0);
Chris@1397 398 subgrid->addWidget(m_audioRecordDeviceCombo, row++, 1, 1, 2);
Chris@263 399
Chris@263 400 subgrid->setRowStretch(row, 10);
Chris@263 401
Chris@436 402 m_tabOrdering[GeneralTab] = m_tabs->count();
Chris@436 403 m_tabs->addTab(frame, tr("&General"));
Chris@263 404
Chris@263 405 // Appearance tab
Chris@263 406
Chris@263 407 frame = new QFrame;
Chris@263 408 subgrid = new QGridLayout;
Chris@263 409 frame->setLayout(subgrid);
Chris@263 410 row = 0;
Chris@263 411
Chris@263 412 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@906 413 ("Show Splash Screen"))),
Chris@906 414 row, 0);
Chris@906 415 subgrid->addWidget(showSplash, row++, 1, 1, 1);
Chris@906 416
Chris@950 417 #ifdef Q_OS_MAC
Chris@950 418 if (devicePixelRatio() > 1) {
Chris@950 419 subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0);
Chris@950 420 subgrid->addWidget(retina, row++, 1, 1, 1);
Chris@950 421 }
Chris@950 422 #endif
Chris@950 423
Chris@906 424 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 425 ("Property Box Layout"))),
Chris@0 426 row, 0);
Chris@0 427 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
Chris@0 428
Chris@1098 429 subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")),
Chris@1096 430 row, 0);
Chris@1096 431 subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2);
Chris@1096 432
Chris@1098 433 subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")),
Chris@1096 434 row, 0);
Chris@1096 435 subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2);
Chris@1096 436
Chris@1098 437 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")),
Chris@1097 438 row, 0);
Chris@1097 439 subgrid->addWidget(colour3DColour, row++, 1, 1, 2);
Chris@1097 440
Chris@1092 441 #ifdef NOT_DEFINED // see earlier
Chris@0 442 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 443 ("Background Mode"))),
Chris@0 444 row, 0);
Chris@180 445 subgrid->addWidget(bgMode, row++, 1, 1, 2);
Chris@242 446 #endif
Chris@180 447
Chris@180 448 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@225 449 ("View Font Size"))),
Chris@225 450 row, 0);
Chris@225 451 subgrid->addWidget(fontSize, row++, 1, 1, 2);
Chris@225 452
Chris@225 453 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@337 454 ("Time To Text Mode"))),
Chris@337 455 row, 0);
Chris@337 456 subgrid->addWidget(ttMode, row++, 1, 1, 2);
Chris@337 457
Chris@337 458 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@906 459 ("Show Hours And Minutes"))),
Chris@237 460 row, 0);
Chris@906 461 subgrid->addWidget(hms, row++, 1, 1, 1);
Chris@237 462
Chris@180 463 subgrid->setRowStretch(row, 10);
Chris@180 464
Chris@436 465 m_tabOrdering[AppearanceTab] = m_tabs->count();
Chris@436 466 m_tabs->addTab(frame, tr("&Appearance"));
Chris@180 467
Chris@180 468 // Analysis tab
Chris@180 469
Chris@180 470 frame = new QFrame;
Chris@180 471 subgrid = new QGridLayout;
Chris@180 472 frame->setLayout(subgrid);
Chris@180 473 row = 0;
Chris@180 474
Chris@180 475 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 476 ("Tuning Frequency"))),
Chris@180 477 row, 0);
Chris@180 478 subgrid->addWidget(frequency, row++, 1, 1, 2);
Chris@180 479
Chris@702 480 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@702 481 ("Octave Numbering System"))),
Chris@702 482 row, 0);
Chris@702 483 subgrid->addWidget(octaveSystem, row++, 1, 1, 2);
Chris@702 484
Chris@0 485 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 486 ("Spectrogram Y Smoothing")),
Chris@115 487 row, 0);
Chris@115 488 subgrid->addWidget(smoothing, row++, 1, 1, 2);
Chris@0 489
Chris@299 490 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 491 ("Spectrogram X Smoothing")),
Chris@299 492 row, 0);
Chris@299 493 subgrid->addWidget(xsmoothing, row++, 1, 1, 2);
Chris@299 494
Chris@0 495 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 496 ("Window Type"))),
Chris@0 497 row, 0);
Chris@9 498 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
Chris@1275 499
Chris@9 500 subgrid->setRowStretch(row, 10);
Chris@9 501 row++;
Chris@1275 502
Chris@1275 503 subgrid->addWidget(new QLabel(tr("Run Vamp plugins in separate process:")),
Chris@1275 504 row, 0);
Chris@1275 505 subgrid->addWidget(vampProcessSeparation, row++, 1, 1, 1);
Chris@0 506
Chris@180 507 subgrid->setRowStretch(row, 10);
Chris@180 508
Chris@436 509 m_tabOrdering[AnalysisTab] = m_tabs->count();
Chris@436 510 m_tabs->addTab(frame, tr("Anal&ysis"));
Chris@436 511
Chris@436 512 // Template tab
Chris@436 513
Chris@436 514 frame = new QFrame;
Chris@436 515 subgrid = new QGridLayout;
Chris@436 516 frame->setLayout(subgrid);
Chris@436 517 row = 0;
Chris@436 518
Chris@436 519 subgrid->addWidget(new QLabel(tr("Default session template for audio files:")), row++, 0);
Chris@436 520
Chris@436 521 QListWidget *lw = new QListWidget();
Chris@436 522 subgrid->addWidget(lw, row, 0);
Chris@436 523 subgrid->setRowStretch(row, 10);
Chris@436 524 row++;
Chris@436 525
Chris@436 526 settings.beginGroup("MainWindow");
Chris@436 527 m_currentTemplate = settings.value("sessiontemplate", "").toString();
Chris@436 528 settings.endGroup();
Chris@436 529
Chris@455 530 lw->addItem(tr("Standard Waveform"));
Chris@436 531 if (m_currentTemplate == "" || m_currentTemplate == "default") {
Chris@436 532 lw->setCurrentRow(lw->count()-1);
Chris@436 533 }
Chris@436 534 m_templates.push_back("");
Chris@436 535
Chris@436 536 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
Chris@436 537
Chris@1397 538 set<QString> byName;
Chris@436 539 foreach (QString t, templates) {
Chris@436 540 byName.insert(QFileInfo(t).baseName());
Chris@436 541 }
Chris@436 542
Chris@436 543 foreach (QString t, byName) {
Chris@436 544 if (t.toLower() == "default") continue;
Chris@436 545 m_templates.push_back(t);
Chris@436 546 lw->addItem(t);
Chris@436 547 if (m_currentTemplate == t) {
Chris@436 548 lw->setCurrentRow(lw->count()-1);
Chris@436 549 }
Chris@436 550 }
Chris@436 551
Chris@436 552 connect(lw, SIGNAL(currentRowChanged(int)), this, SLOT(defaultTemplateChanged(int)));
Chris@436 553
Chris@436 554 m_tabOrdering[TemplateTab] = m_tabs->count();
Chris@436 555 m_tabs->addTab(frame, tr("Session &Template"));
Chris@180 556
Chris@163 557 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
Chris@163 558 grid->addWidget(bb, 1, 0);
Chris@0 559
Chris@0 560 QPushButton *ok = new QPushButton(tr("OK"));
Chris@0 561 QPushButton *cancel = new QPushButton(tr("Cancel"));
Chris@163 562 bb->addButton(ok, QDialogButtonBox::AcceptRole);
Chris@163 563 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
Chris@163 564 bb->addButton(cancel, QDialogButtonBox::RejectRole);
Chris@0 565 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
Chris@0 566 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
Chris@0 567 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
Chris@0 568
Chris@0 569 m_applyButton->setEnabled(false);
Chris@0 570 }
Chris@0 571
Chris@0 572 PreferencesDialog::~PreferencesDialog()
Chris@0 573 {
Chris@438 574 SVDEBUG << "PreferencesDialog::~PreferencesDialog()" << endl;
Chris@0 575 }
Chris@0 576
Chris@0 577 void
Chris@1397 578 PreferencesDialog::rebuildDeviceCombos()
Chris@1397 579 {
Chris@1397 580 QSettings settings;
Chris@1397 581 settings.beginGroup("Preferences");
Chris@1397 582
Chris@1397 583 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
Chris@1397 584 string implementationName;
Chris@1397 585 if (in_range_for(names, m_audioImplementation-1)) {
Chris@1397 586 implementationName = names[m_audioImplementation-1];
Chris@1397 587 }
Chris@1397 588
Chris@1397 589 m_audioPlaybackDeviceCombo->clear();
Chris@1397 590 m_audioRecordDeviceCombo->clear();
Chris@1397 591
Chris@1397 592 QString suffix;
Chris@1397 593 if (implementationName != "") {
Chris@1397 594 suffix = "-" + QString(implementationName.c_str());
Chris@1397 595 }
Chris@1397 596
Chris@1397 597 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
Chris@1397 598 QString playbackDeviceName = settings.value
Chris@1397 599 ("audio-playback-device" + suffix, "").toString();
Chris@1397 600 m_audioPlaybackDeviceCombo->addItem(tr("(auto)"));
Chris@1397 601 m_audioPlaybackDeviceCombo->setCurrentIndex(0);
Chris@1397 602 m_audioPlaybackDevice = 0;
Chris@1397 603 for (int i = 0; in_range_for(names, i); ++i) {
Chris@1397 604 m_audioPlaybackDeviceCombo->addItem(names[i].c_str());
Chris@1397 605 if (playbackDeviceName.toStdString() == names[i]) {
Chris@1397 606 m_audioPlaybackDeviceCombo->setCurrentIndex(i+1);
Chris@1397 607 m_audioPlaybackDevice = i+1;
Chris@1397 608 }
Chris@1397 609 }
Chris@1397 610
Chris@1397 611 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
Chris@1397 612 QString recordDeviceName = settings.value
Chris@1397 613 ("audio-record-device" + suffix, "").toString();
Chris@1397 614 m_audioRecordDeviceCombo->addItem(tr("(auto)"));
Chris@1397 615 m_audioRecordDeviceCombo->setCurrentIndex(0);
Chris@1397 616 m_audioRecordDevice = 0;
Chris@1397 617 for (int i = 0; in_range_for(names, i); ++i) {
Chris@1397 618 m_audioRecordDeviceCombo->addItem(names[i].c_str());
Chris@1397 619 if (recordDeviceName.toStdString() == names[i]) {
Chris@1397 620 m_audioRecordDeviceCombo->setCurrentIndex(i+1);
Chris@1397 621 m_audioRecordDevice = i+1;
Chris@1397 622 }
Chris@1397 623 }
Chris@1397 624
Chris@1397 625 settings.endGroup();
Chris@1397 626 }
Chris@1397 627
Chris@1397 628 void
Chris@436 629 PreferencesDialog::switchToTab(Tab t)
Chris@436 630 {
Chris@436 631 if (m_tabOrdering.contains(t)) {
Chris@436 632 m_tabs->setCurrentIndex(m_tabOrdering[t]);
Chris@436 633 }
Chris@436 634 }
Chris@436 635
Chris@436 636 void
Chris@9 637 PreferencesDialog::windowTypeChanged(WindowType type)
Chris@0 638 {
Chris@0 639 m_windowType = type;
Chris@0 640 m_applyButton->setEnabled(true);
Chris@0 641 }
Chris@0 642
Chris@0 643 void
Chris@115 644 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
Chris@0 645 {
Chris@115 646 m_spectrogramSmoothing = smoothing;
Chris@0 647 m_applyButton->setEnabled(true);
Chris@0 648 }
Chris@0 649
Chris@0 650 void
Chris@299 651 PreferencesDialog::spectrogramXSmoothingChanged(int smoothing)
Chris@299 652 {
Chris@299 653 m_spectrogramXSmoothing = smoothing;
Chris@299 654 m_applyButton->setEnabled(true);
Chris@299 655 }
Chris@299 656
Chris@299 657 void
Chris@1096 658 PreferencesDialog::spectrogramGColourChanged(int colour)
Chris@1096 659 {
Chris@1096 660 m_spectrogramGColour = colour;
Chris@1096 661 m_applyButton->setEnabled(true);
Chris@1096 662 }
Chris@1096 663
Chris@1096 664 void
Chris@1096 665 PreferencesDialog::spectrogramMColourChanged(int colour)
Chris@1096 666 {
Chris@1096 667 m_spectrogramMColour = colour;
Chris@1096 668 m_applyButton->setEnabled(true);
Chris@1096 669 }
Chris@1096 670
Chris@1096 671 void
Chris@1097 672 PreferencesDialog::colour3DColourChanged(int colour)
Chris@1097 673 {
Chris@1097 674 m_colour3DColour = colour;
Chris@1097 675 m_applyButton->setEnabled(true);
Chris@1097 676 }
Chris@1097 677
Chris@1097 678 void
Chris@0 679 PreferencesDialog::propertyLayoutChanged(int layout)
Chris@0 680 {
Chris@0 681 m_propertyLayout = layout;
Chris@0 682 m_applyButton->setEnabled(true);
Chris@0 683 }
Chris@0 684
Chris@0 685 void
Chris@0 686 PreferencesDialog::tuningFrequencyChanged(double freq)
Chris@0 687 {
Chris@0 688 m_tuningFrequency = freq;
Chris@0 689 m_applyButton->setEnabled(true);
Chris@0 690 }
Chris@0 691
Chris@0 692 void
Chris@1397 693 PreferencesDialog::audioImplementationChanged(int s)
Chris@263 694 {
Chris@1397 695 if (m_audioImplementation != s) {
Chris@1397 696 m_audioImplementation = s;
Chris@1397 697 rebuildDeviceCombos();
Chris@1397 698 m_applyButton->setEnabled(true);
Chris@1413 699 m_audioDeviceChanged = true;
Chris@1397 700 }
Chris@1397 701 }
Chris@1397 702
Chris@1397 703 void
Chris@1397 704 PreferencesDialog::audioPlaybackDeviceChanged(int s)
Chris@1397 705 {
Chris@1397 706 if (m_audioPlaybackDevice != s) {
Chris@1397 707 m_audioPlaybackDevice = s;
Chris@1397 708 m_applyButton->setEnabled(true);
Chris@1413 709 m_audioDeviceChanged = true;
Chris@1397 710 }
Chris@1397 711 }
Chris@1397 712
Chris@1397 713 void
Chris@1397 714 PreferencesDialog::audioRecordDeviceChanged(int s)
Chris@1397 715 {
Chris@1397 716 if (m_audioRecordDevice != s) {
Chris@1397 717 m_audioRecordDevice = s;
Chris@1397 718 m_applyButton->setEnabled(true);
Chris@1413 719 m_audioDeviceChanged = true;
Chris@1397 720 }
Chris@263 721 }
Chris@263 722
Chris@263 723 void
Chris@180 724 PreferencesDialog::resampleOnLoadChanged(int state)
Chris@180 725 {
Chris@180 726 m_resampleOnLoad = (state == Qt::Checked);
Chris@180 727 m_applyButton->setEnabled(true);
Chris@180 728 m_changesOnRestart = true;
Chris@180 729 }
Chris@180 730
Chris@180 731 void
Chris@1379 732 PreferencesDialog::gaplessModeChanged(int state)
Chris@1379 733 {
Chris@1379 734 m_gapless = (state == Qt::Checked);
Chris@1379 735 m_applyButton->setEnabled(true);
Chris@1379 736 }
Chris@1379 737
Chris@1379 738 void
Chris@1275 739 PreferencesDialog::vampProcessSeparationChanged(int state)
Chris@1275 740 {
Chris@1275 741 m_runPluginsInProcess = (state == Qt::Unchecked);
Chris@1275 742 m_applyButton->setEnabled(true);
Chris@1275 743 m_changesOnRestart = true;
Chris@1275 744 }
Chris@1275 745
Chris@1275 746 void
Chris@686 747 PreferencesDialog::networkPermissionChanged(int state)
Chris@686 748 {
Chris@686 749 m_networkPermission = (state == Qt::Checked);
Chris@686 750 m_applyButton->setEnabled(true);
Chris@686 751 m_changesOnRestart = true;
Chris@686 752 }
Chris@686 753
Chris@686 754 void
Chris@950 755 PreferencesDialog::retinaChanged(int state)
Chris@950 756 {
Chris@950 757 m_retina = (state == Qt::Checked);
Chris@950 758 m_applyButton->setEnabled(true);
Chris@950 759 // Does not require a restart
Chris@950 760 }
Chris@950 761
Chris@950 762 void
Chris@237 763 PreferencesDialog::showSplashChanged(int state)
Chris@237 764 {
Chris@237 765 m_showSplash = (state == Qt::Checked);
Chris@237 766 m_applyButton->setEnabled(true);
Chris@237 767 m_changesOnRestart = true;
Chris@237 768 }
Chris@237 769
Chris@237 770 void
Chris@436 771 PreferencesDialog::defaultTemplateChanged(int i)
Chris@436 772 {
Chris@436 773 m_currentTemplate = m_templates[i];
Chris@436 774 m_applyButton->setEnabled(true);
Chris@436 775 }
Chris@436 776
Chris@436 777 void
Chris@658 778 PreferencesDialog::localeChanged(int i)
Chris@658 779 {
Chris@658 780 m_currentLocale = m_locales[i];
Chris@658 781 m_applyButton->setEnabled(true);
Chris@658 782 m_changesOnRestart = true;
Chris@658 783 }
Chris@658 784
Chris@658 785 void
Chris@180 786 PreferencesDialog::tempDirRootChanged(QString r)
Chris@180 787 {
Chris@180 788 m_tempDirRoot = r;
Chris@180 789 m_applyButton->setEnabled(true);
Chris@180 790 }
Chris@180 791
Chris@180 792 void
Chris@180 793 PreferencesDialog::tempDirButtonClicked()
Chris@180 794 {
Chris@180 795 QString dir = QFileDialog::getExistingDirectory
Chris@180 796 (this, tr("Select a directory to create cache subdirectory in"),
Chris@180 797 m_tempDirRoot);
Chris@180 798 if (dir == "") return;
Chris@180 799 m_tempDirRootEdit->setText(dir);
Chris@180 800 tempDirRootChanged(dir);
Chris@180 801 m_changesOnRestart = true;
Chris@180 802 }
Chris@180 803
Chris@180 804 void
Chris@180 805 PreferencesDialog::backgroundModeChanged(int mode)
Chris@180 806 {
Chris@180 807 m_backgroundMode = mode;
Chris@180 808 m_applyButton->setEnabled(true);
Chris@180 809 m_changesOnRestart = true;
Chris@180 810 }
Chris@180 811
Chris@180 812 void
Chris@337 813 PreferencesDialog::timeToTextModeChanged(int mode)
Chris@337 814 {
Chris@337 815 m_timeToTextMode = mode;
Chris@337 816 m_applyButton->setEnabled(true);
Chris@337 817 }
Chris@337 818
Chris@337 819 void
Chris@906 820 PreferencesDialog::showHMSChanged(int state)
Chris@906 821 {
Chris@906 822 m_showHMS = (state == Qt::Checked);
Chris@906 823 m_applyButton->setEnabled(true);
Chris@906 824 }
Chris@906 825
Chris@906 826 void
Chris@702 827 PreferencesDialog::octaveSystemChanged(int system)
Chris@702 828 {
Chris@702 829 m_octaveSystem = system;
Chris@702 830 m_applyButton->setEnabled(true);
Chris@702 831 }
Chris@702 832
Chris@702 833 void
Chris@225 834 PreferencesDialog::viewFontSizeChanged(int sz)
Chris@225 835 {
Chris@225 836 m_viewFontSize = sz;
Chris@225 837 m_applyButton->setEnabled(true);
Chris@225 838 }
Chris@225 839
Chris@225 840 void
Chris@0 841 PreferencesDialog::okClicked()
Chris@0 842 {
Chris@0 843 applyClicked();
Chris@0 844 accept();
Chris@0 845 }
Chris@0 846
Chris@0 847 void
Chris@0 848 PreferencesDialog::applyClicked()
Chris@0 849 {
Chris@0 850 Preferences *prefs = Preferences::getInstance();
Chris@0 851 prefs->setWindowType(WindowType(m_windowType));
Chris@115 852 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
Chris@115 853 (m_spectrogramSmoothing));
Chris@299 854 prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing
Chris@299 855 (m_spectrogramXSmoothing));
Chris@0 856 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
Chris@0 857 (m_propertyLayout));
Chris@0 858 prefs->setTuningFrequency(m_tuningFrequency);
Chris@180 859 prefs->setResampleOnLoad(m_resampleOnLoad);
Chris@1379 860 prefs->setUseGaplessMode(m_gapless);
Chris@1276 861 prefs->setRunPluginsInProcess(m_runPluginsInProcess);
Chris@237 862 prefs->setShowSplash(m_showSplash);
Chris@180 863 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
Chris@180 864 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
Chris@337 865 prefs->setTimeToTextMode(Preferences::TimeToTextMode(m_timeToTextMode));
Chris@906 866 prefs->setShowHMS(m_showHMS);
Chris@225 867 prefs->setViewFontSize(m_viewFontSize);
Chris@263 868
Chris@702 869 prefs->setProperty("Octave Numbering System", m_octaveSystem);
Chris@702 870
Chris@263 871 QSettings settings;
Chris@263 872 settings.beginGroup("Preferences");
Chris@686 873 QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
Chris@686 874 settings.setValue(permishTag, m_networkPermission);
Chris@1397 875
Chris@1397 876 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
Chris@1397 877 string implementationName;
Chris@1415 878 if (m_audioImplementation > int(names.size())) {
Chris@1415 879 m_audioImplementation = 0;
Chris@1415 880 }
Chris@1397 881 if (m_audioImplementation > 0) {
Chris@1397 882 implementationName = names[m_audioImplementation-1];
Chris@1397 883 }
Chris@1397 884 settings.setValue("audio-target", implementationName.c_str());
Chris@1397 885
Chris@1397 886 QString suffix;
Chris@1397 887 if (implementationName != "") {
Chris@1397 888 suffix = "-" + QString(implementationName.c_str());
Chris@1397 889 }
Chris@1397 890
Chris@1397 891 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
Chris@1397 892 string deviceName;
Chris@1415 893 if (m_audioPlaybackDevice > int(names.size())) {
Chris@1415 894 m_audioPlaybackDevice = 0;
Chris@1415 895 }
Chris@1397 896 if (m_audioPlaybackDevice > 0) {
Chris@1397 897 deviceName = names[m_audioPlaybackDevice-1];
Chris@1397 898 }
Chris@1397 899 settings.setValue("audio-playback-device" + suffix, deviceName.c_str());
Chris@1397 900
Chris@1397 901 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
Chris@1397 902 deviceName = "";
Chris@1415 903 if (m_audioRecordDevice > int(names.size())) {
Chris@1415 904 m_audioRecordDevice = 0;
Chris@1415 905 }
Chris@1397 906 if (m_audioRecordDevice > 0) {
Chris@1397 907 deviceName = names[m_audioRecordDevice-1];
Chris@1397 908 }
Chris@1397 909 settings.setValue("audio-record-device" + suffix, deviceName.c_str());
Chris@1397 910
Chris@686 911 settings.setValue("locale", m_currentLocale);
Chris@950 912 #ifdef Q_OS_MAC
Chris@950 913 settings.setValue("scaledHiDpi", m_retina);
Chris@950 914 #endif
Chris@1096 915 settings.setValue("spectrogram-colour", m_spectrogramGColour);
Chris@1096 916 settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
Chris@1097 917 settings.setValue("colour-3d-plot-colour", m_colour3DColour);
Chris@263 918 settings.endGroup();
Chris@180 919
Chris@436 920 settings.beginGroup("MainWindow");
Chris@436 921 settings.setValue("sessiontemplate", m_currentTemplate);
Chris@436 922 settings.endGroup();
Chris@436 923
Chris@0 924 m_applyButton->setEnabled(false);
Chris@180 925
Chris@180 926 if (m_changesOnRestart) {
Chris@180 927 QMessageBox::information(this, tr("Preferences"),
Chris@255 928 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 929 m_changesOnRestart = false;
Chris@180 930 }
Chris@1413 931
Chris@1413 932 if (m_audioDeviceChanged) {
Chris@1413 933 emit audioDeviceChanged();
Chris@1415 934 m_audioDeviceChanged = false;
Chris@1413 935 }
Chris@0 936 }
Chris@0 937
Chris@0 938 void
Chris@0 939 PreferencesDialog::cancelClicked()
Chris@0 940 {
Chris@0 941 reject();
Chris@0 942 }
Chris@0 943
Chris@163 944 void
Chris@163 945 PreferencesDialog::applicationClosing(bool quickly)
Chris@163 946 {
Chris@163 947 if (quickly) {
Chris@163 948 reject();
Chris@163 949 return;
Chris@163 950 }
Chris@163 951
Chris@163 952 if (m_applyButton->isEnabled()) {
Chris@163 953 int rv = QMessageBox::warning
Chris@163 954 (this, tr("Preferences Changed"),
Chris@163 955 tr("Some preferences have been changed but not applied.\n"
Chris@163 956 "Apply them before closing?"),
Chris@163 957 QMessageBox::Apply | QMessageBox::Discard,
Chris@163 958 QMessageBox::Discard);
Chris@163 959 if (rv == QMessageBox::Apply) {
Chris@163 960 applyClicked();
Chris@163 961 accept();
Chris@163 962 } else {
Chris@163 963 reject();
Chris@163 964 }
Chris@163 965 } else {
Chris@163 966 accept();
Chris@163 967 }
Chris@163 968 }
Chris@163 969