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