annotate main/PreferencesDialog.cpp @ 2560:cbde01e5c626 smoother-recording

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