annotate main/PreferencesDialog.cpp @ 2059:2cad3bf55850

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