annotate main/PreferencesDialog.cpp @ 1408:35c374cadfc4 3.0-integration

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