| 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@2457 | 172     m_overviewColourCombo = 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@2457 | 177         m_overviewColourCombo->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@2457 | 186     connect(m_overviewColourCombo, 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@2457 | 288 #ifndef Q_OS_MAC | 
| 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@2126 | 389     QFrame *frame = nullptr; | 
| Chris@2126 | 390     QGridLayout *subgrid = nullptr; | 
| 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@2457 | 407 #ifndef Q_OS_MAC | 
| Chris@2457 | 408     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 
| Chris@2457 | 409                                                 ("Background Mode"))), | 
| Chris@2457 | 410                        row, 0); | 
| Chris@2457 | 411     subgrid->addWidget(bgMode, row++, 1, 1, 2); | 
| Chris@2457 | 412 #endif | 
| Chris@2457 | 413 | 
| Chris@906 | 414     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 
| Chris@0 | 415                                                 ("Property Box Layout"))), | 
| Chris@0 | 416                        row, 0); | 
| Chris@0 | 417     subgrid->addWidget(propertyLayout, row++, 1, 1, 2); | 
| Chris@0 | 418 | 
| Chris@1098 | 419     subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")), | 
| Chris@1096 | 420                        row, 0); | 
| Chris@1096 | 421     subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2); | 
| Chris@1096 | 422 | 
| Chris@1098 | 423     subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")), | 
| Chris@1096 | 424                        row, 0); | 
| Chris@1096 | 425     subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2); | 
| Chris@1096 | 426 | 
| Chris@1098 | 427     subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")), | 
| Chris@1097 | 428                        row, 0); | 
| Chris@1097 | 429     subgrid->addWidget(colour3DColour, row++, 1, 1, 2); | 
| Chris@1097 | 430 | 
| Chris@1448 | 431     subgrid->addWidget(new QLabel(tr("Overview waveform colour:")), | 
| Chris@1448 | 432                        row, 0); | 
| Chris@2457 | 433     subgrid->addWidget(m_overviewColourCombo, row++, 1, 1, 2); | 
| 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@2457 | 887 | 
| Chris@2457 | 888     // When switching to one of the explicit background choices | 
| Chris@2457 | 889     // (dark/light), also default the overview colour preference to | 
| Chris@2457 | 890     // something sensible | 
| Chris@2457 | 891 | 
| Chris@2457 | 892     int overviewColour = m_overviewColourCombo->currentIndex(); | 
| Chris@2457 | 893     int plainColours = 6; // we happen to know there are 6 "light" and 6 "dark" | 
| Chris@2457 | 894 | 
| Chris@2457 | 895     if (mode == Preferences::DarkBackground && overviewColour < plainColours) { | 
| Chris@2457 | 896         overviewColour += plainColours; | 
| Chris@2457 | 897     } | 
| Chris@2457 | 898     if (mode == Preferences::LightBackground && overviewColour >= plainColours) { | 
| Chris@2457 | 899         overviewColour -= plainColours; | 
| Chris@2457 | 900     } | 
| Chris@2457 | 901 | 
| Chris@2457 | 902     m_overviewColourCombo->setCurrentIndex(overviewColour); | 
| Chris@2457 | 903     overviewColourChanged(overviewColour); | 
| Chris@180 | 904 } | 
| Chris@180 | 905 | 
| Chris@180 | 906 void | 
| Chris@337 | 907 PreferencesDialog::timeToTextModeChanged(int mode) | 
| Chris@337 | 908 { | 
| Chris@337 | 909     m_timeToTextMode = mode; | 
| Chris@337 | 910     m_applyButton->setEnabled(true); | 
| Chris@337 | 911 } | 
| Chris@337 | 912 | 
| Chris@337 | 913 void | 
| Chris@906 | 914 PreferencesDialog::showHMSChanged(int state) | 
| Chris@906 | 915 { | 
| Chris@906 | 916     m_showHMS = (state == Qt::Checked); | 
| Chris@906 | 917     m_applyButton->setEnabled(true); | 
| Chris@906 | 918 } | 
| Chris@906 | 919 | 
| Chris@906 | 920 void | 
| Chris@702 | 921 PreferencesDialog::octaveSystemChanged(int system) | 
| Chris@702 | 922 { | 
| Chris@702 | 923     m_octaveSystem = system; | 
| Chris@702 | 924     m_applyButton->setEnabled(true); | 
| Chris@702 | 925 } | 
| Chris@702 | 926 | 
| Chris@702 | 927 void | 
| Chris@225 | 928 PreferencesDialog::viewFontSizeChanged(int sz) | 
| Chris@225 | 929 { | 
| Chris@225 | 930     m_viewFontSize = sz; | 
| Chris@225 | 931     m_applyButton->setEnabled(true); | 
| Chris@225 | 932 } | 
| Chris@225 | 933 | 
| Chris@225 | 934 void | 
| Chris@1837 | 935 PreferencesDialog::pluginPathsChanged() | 
| Chris@1837 | 936 { | 
| Chris@1837 | 937     m_applyButton->setEnabled(true); | 
| Chris@1837 | 938     m_changesOnRestart = true; | 
| Chris@1837 | 939 } | 
| Chris@1837 | 940 | 
| Chris@1837 | 941 void | 
| Chris@0 | 942 PreferencesDialog::okClicked() | 
| Chris@0 | 943 { | 
| Chris@0 | 944     applyClicked(); | 
| Chris@0 | 945     accept(); | 
| Chris@0 | 946 } | 
| Chris@0 | 947 | 
| Chris@0 | 948 void | 
| Chris@0 | 949 PreferencesDialog::applyClicked() | 
| Chris@0 | 950 { | 
| Chris@0 | 951     Preferences *prefs = Preferences::getInstance(); | 
| Chris@0 | 952     prefs->setWindowType(WindowType(m_windowType)); | 
| Chris@115 | 953     prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing | 
| Chris@115 | 954                                    (m_spectrogramSmoothing)); | 
| Chris@299 | 955     prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing | 
| Chris@299 | 956                                    (m_spectrogramXSmoothing)); | 
| Chris@0 | 957     prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout | 
| Chris@0 | 958                                 (m_propertyLayout)); | 
| Chris@0 | 959     prefs->setTuningFrequency(m_tuningFrequency); | 
| Chris@180 | 960     prefs->setResampleOnLoad(m_resampleOnLoad); | 
| Chris@1379 | 961     prefs->setUseGaplessMode(m_gapless); | 
| Chris@1276 | 962     prefs->setRunPluginsInProcess(m_runPluginsInProcess); | 
| Chris@237 | 963     prefs->setShowSplash(m_showSplash); | 
| Chris@180 | 964     prefs->setTemporaryDirectoryRoot(m_tempDirRoot); | 
| Chris@180 | 965     prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode)); | 
| Chris@337 | 966     prefs->setTimeToTextMode(Preferences::TimeToTextMode(m_timeToTextMode)); | 
| Chris@906 | 967     prefs->setShowHMS(m_showHMS); | 
| Chris@225 | 968     prefs->setViewFontSize(m_viewFontSize); | 
| Chris@263 | 969 | 
| Chris@702 | 970     prefs->setProperty("Octave Numbering System", m_octaveSystem); | 
| Chris@702 | 971 | 
| Chris@263 | 972     QSettings settings; | 
| Chris@263 | 973     settings.beginGroup("Preferences"); | 
| Chris@686 | 974     QString permishTag = QString("network-permission-%1").arg(SV_VERSION); | 
| Chris@686 | 975     settings.setValue(permishTag, m_networkPermission); | 
| Chris@1397 | 976 | 
| Chris@1397 | 977     vector<string> names = breakfastquay::AudioFactory::getImplementationNames(); | 
| Chris@1397 | 978     string implementationName; | 
| Chris@1415 | 979     if (m_audioImplementation > int(names.size())) { | 
| Chris@1415 | 980         m_audioImplementation = 0; | 
| Chris@1415 | 981     } | 
| Chris@1397 | 982     if (m_audioImplementation > 0) { | 
| Chris@1397 | 983         implementationName = names[m_audioImplementation-1]; | 
| Chris@1397 | 984     } | 
| Chris@1397 | 985     settings.setValue("audio-target", implementationName.c_str()); | 
| Chris@1397 | 986 | 
| Chris@1397 | 987     QString suffix; | 
| Chris@1397 | 988     if (implementationName != "") { | 
| Chris@1397 | 989         suffix = "-" + QString(implementationName.c_str()); | 
| Chris@1397 | 990     } | 
| Chris@1397 | 991 | 
| Chris@1397 | 992     names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName); | 
| Chris@1397 | 993     string deviceName; | 
| Chris@1415 | 994     if (m_audioPlaybackDevice > int(names.size())) { | 
| Chris@1415 | 995         m_audioPlaybackDevice = 0; | 
| Chris@1415 | 996     } | 
| Chris@1397 | 997     if (m_audioPlaybackDevice > 0) { | 
| Chris@1397 | 998         deviceName = names[m_audioPlaybackDevice-1]; | 
| Chris@1397 | 999     } | 
| Chris@1397 | 1000     settings.setValue("audio-playback-device" + suffix, deviceName.c_str()); | 
| Chris@1397 | 1001 | 
| Chris@1397 | 1002     names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName); | 
| Chris@1397 | 1003     deviceName = ""; | 
| Chris@1415 | 1004     if (m_audioRecordDevice > int(names.size())) { | 
| Chris@1415 | 1005         m_audioRecordDevice = 0; | 
| Chris@1415 | 1006     } | 
| Chris@1397 | 1007     if (m_audioRecordDevice > 0) { | 
| Chris@1397 | 1008         deviceName = names[m_audioRecordDevice-1]; | 
| Chris@1397 | 1009     } | 
| Chris@1397 | 1010     settings.setValue("audio-record-device" + suffix, deviceName.c_str()); | 
| Chris@1397 | 1011 | 
| Chris@686 | 1012     settings.setValue("locale", m_currentLocale); | 
| Chris@950 | 1013 #ifdef Q_OS_MAC | 
| Chris@950 | 1014     settings.setValue("scaledHiDpi", m_retina); | 
| Chris@950 | 1015 #endif | 
| Chris@1096 | 1016     settings.setValue("spectrogram-colour", m_spectrogramGColour); | 
| Chris@1096 | 1017     settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour); | 
| Chris@1097 | 1018     settings.setValue("colour-3d-plot-colour", m_colour3DColour); | 
| cannam@1463 | 1019     settings.setValue("overview-colour", m_overviewColour.name()); | 
| Chris@263 | 1020     settings.endGroup(); | 
| Chris@180 | 1021 | 
| Chris@436 | 1022     settings.beginGroup("MainWindow"); | 
| Chris@436 | 1023     settings.setValue("sessiontemplate", m_currentTemplate); | 
| Chris@436 | 1024     settings.endGroup(); | 
| Chris@436 | 1025 | 
| Chris@0 | 1026     m_applyButton->setEnabled(false); | 
| Chris@180 | 1027 | 
| Chris@180 | 1028     if (m_changesOnRestart) { | 
| Chris@180 | 1029         QMessageBox::information(this, tr("Preferences"), | 
| Chris@255 | 1030                                  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 | 1031         m_changesOnRestart = false; | 
| Chris@180 | 1032     } | 
| Chris@1413 | 1033 | 
| Chris@1413 | 1034     if (m_audioDeviceChanged) { | 
| Chris@1413 | 1035         emit audioDeviceChanged(); | 
| Chris@1415 | 1036         m_audioDeviceChanged = false; | 
| Chris@1413 | 1037     } | 
| Chris@1448 | 1038 | 
| Chris@1448 | 1039     if (m_coloursChanged) { | 
| Chris@1448 | 1040         emit coloursChanged(); | 
| Chris@1448 | 1041         m_coloursChanged = false; | 
| Chris@1448 | 1042     } | 
| Chris@1837 | 1043 | 
| Chris@1837 | 1044     PluginPathSetter::savePathSettings(m_pluginPathConfigurator->getPaths()); | 
| Chris@0 | 1045 } | 
| Chris@0 | 1046 | 
| Chris@0 | 1047 void | 
| Chris@0 | 1048 PreferencesDialog::cancelClicked() | 
| Chris@0 | 1049 { | 
| Chris@0 | 1050     reject(); | 
| Chris@0 | 1051 } | 
| Chris@0 | 1052 | 
| Chris@163 | 1053 void | 
| Chris@163 | 1054 PreferencesDialog::applicationClosing(bool quickly) | 
| Chris@163 | 1055 { | 
| Chris@163 | 1056     if (quickly) { | 
| Chris@163 | 1057         reject(); | 
| Chris@163 | 1058         return; | 
| Chris@163 | 1059     } | 
| Chris@163 | 1060 | 
| Chris@163 | 1061     if (m_applyButton->isEnabled()) { | 
| Chris@163 | 1062         int rv = QMessageBox::warning | 
| Chris@163 | 1063             (this, tr("Preferences Changed"), | 
| Chris@163 | 1064              tr("Some preferences have been changed but not applied.\n" | 
| Chris@163 | 1065                 "Apply them before closing?"), | 
| Chris@163 | 1066              QMessageBox::Apply | QMessageBox::Discard, | 
| Chris@163 | 1067              QMessageBox::Discard); | 
| Chris@163 | 1068         if (rv == QMessageBox::Apply) { | 
| Chris@163 | 1069             applyClicked(); | 
| Chris@163 | 1070             accept(); | 
| Chris@163 | 1071         } else { | 
| Chris@163 | 1072             reject(); | 
| Chris@163 | 1073         } | 
| Chris@163 | 1074     } else { | 
| Chris@163 | 1075         accept(); | 
| Chris@163 | 1076     } | 
| Chris@163 | 1077 } | 
| Chris@163 | 1078 |