annotate main/PreferencesDialog.cpp @ 316:2c8b64e72830

* various minor bits
author Chris Cannam
date Mon, 16 Mar 2009 16:36:23 +0000
parents 15ce557e1bf8
children a3b2cba73143
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@263 34 #include <QSettings>
Chris@0 35
Chris@9 36 #include "widgets/WindowTypeSelector.h"
Chris@180 37 #include "widgets/IconLoader.h"
Chris@0 38 #include "base/Preferences.h"
Chris@263 39 #include "audioio/AudioTargetFactory.h"
Chris@0 40
Chris@0 41 PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WFlags flags) :
Chris@180 42 QDialog(parent, flags),
Chris@263 43 m_audioDevice(0),
Chris@180 44 m_changesOnRestart(false)
Chris@0 45 {
Chris@163 46 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
Chris@0 47
Chris@0 48 Preferences *prefs = Preferences::getInstance();
Chris@0 49
Chris@0 50 QGridLayout *grid = new QGridLayout;
Chris@0 51 setLayout(grid);
Chris@180 52
Chris@180 53 QTabWidget *tab = new QTabWidget;
Chris@180 54 grid->addWidget(tab, 0, 0);
Chris@0 55
Chris@180 56 tab->setTabPosition(QTabWidget::North);
Chris@0 57
Chris@0 58 // Create this first, as slots that get called from the ctor will
Chris@0 59 // refer to it
Chris@0 60 m_applyButton = new QPushButton(tr("Apply"));
Chris@0 61
Chris@180 62 // Create all the preference widgets first, then create the
Chris@180 63 // individual tab widgets and place the preferences in their
Chris@180 64 // appropriate places in one go afterwards
Chris@180 65
Chris@114 66 int min, max, deflt, i;
Chris@0 67
Chris@9 68 m_windowType = WindowType(prefs->getPropertyRangeAndValue
Chris@114 69 ("Window Type", &min, &max, &deflt));
Chris@9 70 m_windowTypeSelector = new WindowTypeSelector(m_windowType);
Chris@0 71
Chris@9 72 connect(m_windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
Chris@9 73 this, SLOT(windowTypeChanged(WindowType)));
Chris@0 74
Chris@115 75 QComboBox *smoothing = new QComboBox;
Chris@115 76
Chris@299 77 int sm = prefs->getPropertyRangeAndValue("Spectrogram Y Smoothing", &min, &max,
Chris@115 78 &deflt);
Chris@115 79 m_spectrogramSmoothing = sm;
Chris@0 80
Chris@115 81 for (i = min; i <= max; ++i) {
Chris@299 82 smoothing->addItem(prefs->getPropertyValueLabel("Spectrogram Y Smoothing", i));
Chris@115 83 }
Chris@115 84
Chris@115 85 smoothing->setCurrentIndex(sm);
Chris@115 86
Chris@115 87 connect(smoothing, SIGNAL(currentIndexChanged(int)),
Chris@115 88 this, SLOT(spectrogramSmoothingChanged(int)));
Chris@0 89
Chris@299 90 QComboBox *xsmoothing = new QComboBox;
Chris@299 91
Chris@299 92 int xsm = prefs->getPropertyRangeAndValue("Spectrogram X Smoothing", &min, &max,
Chris@299 93 &deflt);
Chris@299 94 m_spectrogramXSmoothing = xsm;
Chris@299 95
Chris@299 96 for (i = min; i <= max; ++i) {
Chris@299 97 xsmoothing->addItem(prefs->getPropertyValueLabel("Spectrogram X Smoothing", i));
Chris@299 98 }
Chris@299 99
Chris@299 100 xsmoothing->setCurrentIndex(xsm);
Chris@299 101
Chris@299 102 connect(xsmoothing, SIGNAL(currentIndexChanged(int)),
Chris@299 103 this, SLOT(spectrogramXSmoothingChanged(int)));
Chris@299 104
Chris@0 105 QComboBox *propertyLayout = new QComboBox;
Chris@114 106 int pl = prefs->getPropertyRangeAndValue("Property Box Layout", &min, &max,
Chris@115 107 &deflt);
Chris@0 108 m_propertyLayout = pl;
Chris@0 109
Chris@0 110 for (i = min; i <= max; ++i) {
Chris@0 111 propertyLayout->addItem(prefs->getPropertyValueLabel("Property Box Layout", i));
Chris@0 112 }
Chris@0 113
Chris@0 114 propertyLayout->setCurrentIndex(pl);
Chris@0 115
Chris@0 116 connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
Chris@0 117 this, SLOT(propertyLayoutChanged(int)));
Chris@0 118
Chris@0 119 m_tuningFrequency = prefs->getTuningFrequency();
Chris@0 120
Chris@0 121 QDoubleSpinBox *frequency = new QDoubleSpinBox;
Chris@0 122 frequency->setMinimum(100.0);
Chris@0 123 frequency->setMaximum(5000.0);
Chris@0 124 frequency->setSuffix(" Hz");
Chris@0 125 frequency->setSingleStep(1);
Chris@0 126 frequency->setValue(m_tuningFrequency);
Chris@0 127 frequency->setDecimals(2);
Chris@0 128
Chris@0 129 connect(frequency, SIGNAL(valueChanged(double)),
Chris@0 130 this, SLOT(tuningFrequencyChanged(double)));
Chris@0 131
Chris@263 132 QComboBox *audioDevice = new QComboBox;
Chris@263 133 std::vector<QString> devices =
Chris@263 134 AudioTargetFactory::getInstance()->getCallbackTargetNames();
Chris@263 135
Chris@263 136 QSettings settings;
Chris@263 137 settings.beginGroup("Preferences");
Chris@263 138 QString targetName = settings.value("audio-target", "").toString();
Chris@263 139 settings.endGroup();
Chris@263 140
Chris@263 141 for (int i = 0; i < devices.size(); ++i) {
Chris@263 142 audioDevice->addItem(AudioTargetFactory::getInstance()
Chris@263 143 ->getCallbackTargetDescription(devices[i]));
Chris@263 144 if (targetName == devices[i]) audioDevice->setCurrentIndex(i);
Chris@263 145 }
Chris@263 146
Chris@263 147 connect(audioDevice, SIGNAL(currentIndexChanged(int)),
Chris@263 148 this, SLOT(audioDeviceChanged(int)));
Chris@263 149
Chris@32 150 QComboBox *resampleQuality = new QComboBox;
Chris@32 151
Chris@114 152 int rsq = prefs->getPropertyRangeAndValue("Resample Quality", &min, &max,
Chris@114 153 &deflt);
Chris@32 154 m_resampleQuality = rsq;
Chris@32 155
Chris@32 156 for (i = min; i <= max; ++i) {
Chris@32 157 resampleQuality->addItem(prefs->getPropertyValueLabel("Resample Quality", i));
Chris@32 158 }
Chris@32 159
Chris@32 160 resampleQuality->setCurrentIndex(rsq);
Chris@32 161
Chris@32 162 connect(resampleQuality, SIGNAL(currentIndexChanged(int)),
Chris@32 163 this, SLOT(resampleQualityChanged(int)));
Chris@32 164
Chris@180 165 QCheckBox *resampleOnLoad = new QCheckBox;
Chris@180 166 m_resampleOnLoad = prefs->getResampleOnLoad();
Chris@180 167 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
Chris@180 168 Qt::Unchecked);
Chris@180 169 connect(resampleOnLoad, SIGNAL(stateChanged(int)),
Chris@180 170 this, SLOT(resampleOnLoadChanged(int)));
Chris@180 171
Chris@180 172 m_tempDirRootEdit = new QLineEdit;
Chris@180 173 QString dir = prefs->getTemporaryDirectoryRoot();
Chris@180 174 m_tempDirRoot = dir;
Chris@180 175 dir.replace("$HOME", tr("<home directory>"));
Chris@180 176 m_tempDirRootEdit->setText(dir);
Chris@180 177 m_tempDirRootEdit->setReadOnly(true);
Chris@180 178 QPushButton *tempDirButton = new QPushButton;
Chris@180 179 tempDirButton->setIcon(IconLoader().load("fileopen"));
Chris@180 180 connect(tempDirButton, SIGNAL(clicked()),
Chris@180 181 this, SLOT(tempDirButtonClicked()));
Chris@180 182 tempDirButton->setFixedSize(QSize(24, 24));
Chris@180 183
Chris@237 184 QCheckBox *showSplash = new QCheckBox;
Chris@237 185 m_showSplash = prefs->getShowSplash();
Chris@237 186 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked);
Chris@237 187 connect(showSplash, SIGNAL(stateChanged(int)),
Chris@237 188 this, SLOT(showSplashChanged(int)));
Chris@237 189
Chris@237 190 #ifndef Q_WS_MAC
Chris@180 191 QComboBox *bgMode = new QComboBox;
Chris@180 192 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
Chris@180 193 &deflt);
Chris@180 194 m_backgroundMode = bg;
Chris@180 195 for (i = min; i <= max; ++i) {
Chris@180 196 bgMode->addItem(prefs->getPropertyValueLabel("Background Mode", i));
Chris@180 197 }
Chris@180 198 bgMode->setCurrentIndex(bg);
Chris@180 199
Chris@180 200 connect(bgMode, SIGNAL(currentIndexChanged(int)),
Chris@180 201 this, SLOT(backgroundModeChanged(int)));
Chris@237 202 #endif
Chris@180 203
Chris@225 204 QSpinBox *fontSize = new QSpinBox;
Chris@225 205 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
Chris@225 206 &deflt);
Chris@234 207 m_viewFontSize = fs;
Chris@225 208 fontSize->setMinimum(min);
Chris@225 209 fontSize->setMaximum(max);
Chris@225 210 fontSize->setSuffix(" pt");
Chris@225 211 fontSize->setSingleStep(1);
Chris@225 212 fontSize->setValue(fs);
Chris@225 213
Chris@225 214 connect(fontSize, SIGNAL(valueChanged(int)),
Chris@225 215 this, SLOT(viewFontSizeChanged(int)));
Chris@225 216
Chris@180 217 // General tab
Chris@180 218
Chris@180 219 QFrame *frame = new QFrame;
Chris@180 220
Chris@180 221 QGridLayout *subgrid = new QGridLayout;
Chris@180 222 frame->setLayout(subgrid);
Chris@180 223
Chris@0 224 int row = 0;
Chris@0 225
Chris@0 226 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@263 227 ("Temporary Directory Root"))),
Chris@263 228 row, 0);
Chris@263 229 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
Chris@263 230 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
Chris@263 231 row++;
Chris@263 232
Chris@263 233 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@263 234 ("Resample On Load"))),
Chris@263 235 row, 0);
Chris@263 236 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
Chris@263 237
Chris@263 238 subgrid->addWidget(new QLabel(tr("Playback audio device:")), row, 0);
Chris@263 239 subgrid->addWidget(audioDevice, row++, 1, 1, 2);
Chris@263 240
Chris@263 241 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@263 242 ("Resample Quality"))),
Chris@263 243 row, 0);
Chris@263 244 subgrid->addWidget(resampleQuality, row++, 1, 1, 2);
Chris@263 245
Chris@263 246 subgrid->setRowStretch(row, 10);
Chris@263 247
Chris@263 248 tab->addTab(frame, tr("&General"));
Chris@263 249
Chris@263 250 // Appearance tab
Chris@263 251
Chris@263 252 frame = new QFrame;
Chris@263 253 subgrid = new QGridLayout;
Chris@263 254 frame->setLayout(subgrid);
Chris@263 255 row = 0;
Chris@263 256
Chris@263 257 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 258 ("Property Box Layout"))),
Chris@0 259 row, 0);
Chris@0 260 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
Chris@0 261
Chris@242 262 #ifndef Q_WS_MAC
Chris@0 263 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 264 ("Background Mode"))),
Chris@0 265 row, 0);
Chris@180 266 subgrid->addWidget(bgMode, row++, 1, 1, 2);
Chris@242 267 #endif
Chris@180 268
Chris@180 269 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@225 270 ("View Font Size"))),
Chris@225 271 row, 0);
Chris@225 272 subgrid->addWidget(fontSize, row++, 1, 1, 2);
Chris@225 273
Chris@225 274 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@237 275 ("Show Splash Screen"))),
Chris@237 276 row, 0);
Chris@237 277 subgrid->addWidget(showSplash, row++, 1, 1, 1);
Chris@237 278
Chris@180 279 subgrid->setRowStretch(row, 10);
Chris@180 280
Chris@263 281 tab->addTab(frame, tr("&Appearance"));
Chris@180 282
Chris@180 283 // Analysis tab
Chris@180 284
Chris@180 285 frame = new QFrame;
Chris@180 286 subgrid = new QGridLayout;
Chris@180 287 frame->setLayout(subgrid);
Chris@180 288 row = 0;
Chris@180 289
Chris@180 290 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@180 291 ("Tuning Frequency"))),
Chris@180 292 row, 0);
Chris@180 293 subgrid->addWidget(frequency, row++, 1, 1, 2);
Chris@180 294
Chris@0 295 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 296 ("Spectrogram Y Smoothing")),
Chris@115 297 row, 0);
Chris@115 298 subgrid->addWidget(smoothing, row++, 1, 1, 2);
Chris@0 299
Chris@299 300 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
Chris@299 301 ("Spectrogram X Smoothing")),
Chris@299 302 row, 0);
Chris@299 303 subgrid->addWidget(xsmoothing, row++, 1, 1, 2);
Chris@299 304
Chris@0 305 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
Chris@0 306 ("Window Type"))),
Chris@0 307 row, 0);
Chris@9 308 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
Chris@9 309 subgrid->setRowStretch(row, 10);
Chris@9 310 row++;
Chris@0 311
Chris@180 312 subgrid->setRowStretch(row, 10);
Chris@180 313
Chris@263 314 tab->addTab(frame, tr("Anal&ysis"));
Chris@180 315
Chris@163 316 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
Chris@163 317 grid->addWidget(bb, 1, 0);
Chris@0 318
Chris@0 319 QPushButton *ok = new QPushButton(tr("OK"));
Chris@0 320 QPushButton *cancel = new QPushButton(tr("Cancel"));
Chris@163 321 bb->addButton(ok, QDialogButtonBox::AcceptRole);
Chris@163 322 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
Chris@163 323 bb->addButton(cancel, QDialogButtonBox::RejectRole);
Chris@0 324 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
Chris@0 325 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
Chris@0 326 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
Chris@0 327
Chris@0 328 m_applyButton->setEnabled(false);
Chris@0 329 }
Chris@0 330
Chris@0 331 PreferencesDialog::~PreferencesDialog()
Chris@0 332 {
Chris@0 333 std::cerr << "PreferencesDialog::~PreferencesDialog()" << std::endl;
Chris@0 334 }
Chris@0 335
Chris@0 336 void
Chris@9 337 PreferencesDialog::windowTypeChanged(WindowType type)
Chris@0 338 {
Chris@0 339 m_windowType = type;
Chris@0 340 m_applyButton->setEnabled(true);
Chris@0 341 }
Chris@0 342
Chris@0 343 void
Chris@115 344 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
Chris@0 345 {
Chris@115 346 m_spectrogramSmoothing = smoothing;
Chris@0 347 m_applyButton->setEnabled(true);
Chris@0 348 }
Chris@0 349
Chris@0 350 void
Chris@299 351 PreferencesDialog::spectrogramXSmoothingChanged(int smoothing)
Chris@299 352 {
Chris@299 353 m_spectrogramXSmoothing = smoothing;
Chris@299 354 m_applyButton->setEnabled(true);
Chris@299 355 }
Chris@299 356
Chris@299 357 void
Chris@0 358 PreferencesDialog::propertyLayoutChanged(int layout)
Chris@0 359 {
Chris@0 360 m_propertyLayout = layout;
Chris@0 361 m_applyButton->setEnabled(true);
Chris@0 362 }
Chris@0 363
Chris@0 364 void
Chris@0 365 PreferencesDialog::tuningFrequencyChanged(double freq)
Chris@0 366 {
Chris@0 367 m_tuningFrequency = freq;
Chris@0 368 m_applyButton->setEnabled(true);
Chris@0 369 }
Chris@0 370
Chris@0 371 void
Chris@263 372 PreferencesDialog::audioDeviceChanged(int s)
Chris@263 373 {
Chris@263 374 m_audioDevice = s;
Chris@263 375 m_applyButton->setEnabled(true);
Chris@263 376 m_changesOnRestart = true;
Chris@263 377 }
Chris@263 378
Chris@263 379 void
Chris@32 380 PreferencesDialog::resampleQualityChanged(int q)
Chris@32 381 {
Chris@32 382 m_resampleQuality = q;
Chris@32 383 m_applyButton->setEnabled(true);
Chris@32 384 }
Chris@32 385
Chris@32 386 void
Chris@180 387 PreferencesDialog::resampleOnLoadChanged(int state)
Chris@180 388 {
Chris@180 389 m_resampleOnLoad = (state == Qt::Checked);
Chris@180 390 m_applyButton->setEnabled(true);
Chris@180 391 m_changesOnRestart = true;
Chris@180 392 }
Chris@180 393
Chris@180 394 void
Chris@237 395 PreferencesDialog::showSplashChanged(int state)
Chris@237 396 {
Chris@237 397 m_showSplash = (state == Qt::Checked);
Chris@237 398 m_applyButton->setEnabled(true);
Chris@237 399 m_changesOnRestart = true;
Chris@237 400 }
Chris@237 401
Chris@237 402 void
Chris@180 403 PreferencesDialog::tempDirRootChanged(QString r)
Chris@180 404 {
Chris@180 405 m_tempDirRoot = r;
Chris@180 406 m_applyButton->setEnabled(true);
Chris@180 407 }
Chris@180 408
Chris@180 409 void
Chris@180 410 PreferencesDialog::tempDirButtonClicked()
Chris@180 411 {
Chris@180 412 QString dir = QFileDialog::getExistingDirectory
Chris@180 413 (this, tr("Select a directory to create cache subdirectory in"),
Chris@180 414 m_tempDirRoot);
Chris@180 415 if (dir == "") return;
Chris@180 416 m_tempDirRootEdit->setText(dir);
Chris@180 417 tempDirRootChanged(dir);
Chris@180 418 m_changesOnRestart = true;
Chris@180 419 }
Chris@180 420
Chris@180 421 void
Chris@180 422 PreferencesDialog::backgroundModeChanged(int mode)
Chris@180 423 {
Chris@180 424 m_backgroundMode = mode;
Chris@180 425 m_applyButton->setEnabled(true);
Chris@180 426 m_changesOnRestart = true;
Chris@180 427 }
Chris@180 428
Chris@180 429 void
Chris@225 430 PreferencesDialog::viewFontSizeChanged(int sz)
Chris@225 431 {
Chris@225 432 m_viewFontSize = sz;
Chris@225 433 m_applyButton->setEnabled(true);
Chris@225 434 }
Chris@225 435
Chris@225 436 void
Chris@0 437 PreferencesDialog::okClicked()
Chris@0 438 {
Chris@0 439 applyClicked();
Chris@0 440 accept();
Chris@0 441 }
Chris@0 442
Chris@0 443 void
Chris@0 444 PreferencesDialog::applyClicked()
Chris@0 445 {
Chris@0 446 Preferences *prefs = Preferences::getInstance();
Chris@0 447 prefs->setWindowType(WindowType(m_windowType));
Chris@115 448 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
Chris@115 449 (m_spectrogramSmoothing));
Chris@299 450 prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing
Chris@299 451 (m_spectrogramXSmoothing));
Chris@0 452 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
Chris@0 453 (m_propertyLayout));
Chris@0 454 prefs->setTuningFrequency(m_tuningFrequency);
Chris@32 455 prefs->setResampleQuality(m_resampleQuality);
Chris@180 456 prefs->setResampleOnLoad(m_resampleOnLoad);
Chris@237 457 prefs->setShowSplash(m_showSplash);
Chris@180 458 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
Chris@180 459 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
Chris@225 460 prefs->setViewFontSize(m_viewFontSize);
Chris@263 461
Chris@263 462 std::vector<QString> devices =
Chris@263 463 AudioTargetFactory::getInstance()->getCallbackTargetNames();
Chris@263 464
Chris@263 465 QSettings settings;
Chris@263 466 settings.beginGroup("Preferences");
Chris@263 467 settings.setValue("audio-target", devices[m_audioDevice]);
Chris@263 468 settings.endGroup();
Chris@180 469
Chris@0 470 m_applyButton->setEnabled(false);
Chris@180 471
Chris@180 472 if (m_changesOnRestart) {
Chris@180 473 QMessageBox::information(this, tr("Preferences"),
Chris@255 474 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 475 m_changesOnRestart = false;
Chris@180 476 }
Chris@0 477 }
Chris@0 478
Chris@0 479 void
Chris@0 480 PreferencesDialog::cancelClicked()
Chris@0 481 {
Chris@0 482 reject();
Chris@0 483 }
Chris@0 484
Chris@163 485 void
Chris@163 486 PreferencesDialog::applicationClosing(bool quickly)
Chris@163 487 {
Chris@163 488 if (quickly) {
Chris@163 489 reject();
Chris@163 490 return;
Chris@163 491 }
Chris@163 492
Chris@163 493 if (m_applyButton->isEnabled()) {
Chris@163 494 int rv = QMessageBox::warning
Chris@163 495 (this, tr("Preferences Changed"),
Chris@163 496 tr("Some preferences have been changed but not applied.\n"
Chris@163 497 "Apply them before closing?"),
Chris@163 498 QMessageBox::Apply | QMessageBox::Discard,
Chris@163 499 QMessageBox::Discard);
Chris@163 500 if (rv == QMessageBox::Apply) {
Chris@163 501 applyClicked();
Chris@163 502 accept();
Chris@163 503 } else {
Chris@163 504 reject();
Chris@163 505 }
Chris@163 506 } else {
Chris@163 507 accept();
Chris@163 508 }
Chris@163 509 }
Chris@163 510