annotate main/PreferencesDialog.cpp @ 1451:e4f223fc9099 svg

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