annotate main/PreferencesDialog.cpp @ 1854:5ef2df5bb886 plugin-path-config

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