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@263
|
42 #include "audioio/AudioTargetFactory.h"
|
Chris@436
|
43 #include "base/ResourceFinder.h"
|
Chris@0
|
44
|
Chris@0
|
45 PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WFlags flags) :
|
Chris@180
|
46 QDialog(parent, flags),
|
Chris@263
|
47 m_audioDevice(0),
|
Chris@180
|
48 m_changesOnRestart(false)
|
Chris@0
|
49 {
|
Chris@163
|
50 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
|
Chris@0
|
51
|
Chris@0
|
52 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
53
|
Chris@0
|
54 QGridLayout *grid = new QGridLayout;
|
Chris@0
|
55 setLayout(grid);
|
Chris@180
|
56
|
Chris@436
|
57 m_tabs = new QTabWidget;
|
Chris@436
|
58 grid->addWidget(m_tabs, 0, 0);
|
Chris@0
|
59
|
Chris@436
|
60 m_tabs->setTabPosition(QTabWidget::North);
|
Chris@0
|
61
|
Chris@0
|
62 // Create this first, as slots that get called from the ctor will
|
Chris@0
|
63 // refer to it
|
Chris@0
|
64 m_applyButton = new QPushButton(tr("Apply"));
|
Chris@0
|
65
|
Chris@180
|
66 // Create all the preference widgets first, then create the
|
Chris@180
|
67 // individual tab widgets and place the preferences in their
|
Chris@180
|
68 // appropriate places in one go afterwards
|
Chris@180
|
69
|
Chris@114
|
70 int min, max, deflt, i;
|
Chris@0
|
71
|
Chris@9
|
72 m_windowType = WindowType(prefs->getPropertyRangeAndValue
|
Chris@114
|
73 ("Window Type", &min, &max, &deflt));
|
Chris@9
|
74 m_windowTypeSelector = new WindowTypeSelector(m_windowType);
|
Chris@0
|
75
|
Chris@9
|
76 connect(m_windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@9
|
77 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@0
|
78
|
Chris@115
|
79 QComboBox *smoothing = new QComboBox;
|
Chris@115
|
80
|
Chris@299
|
81 int sm = prefs->getPropertyRangeAndValue("Spectrogram Y Smoothing", &min, &max,
|
Chris@115
|
82 &deflt);
|
Chris@115
|
83 m_spectrogramSmoothing = sm;
|
Chris@0
|
84
|
Chris@115
|
85 for (i = min; i <= max; ++i) {
|
Chris@299
|
86 smoothing->addItem(prefs->getPropertyValueLabel("Spectrogram Y Smoothing", i));
|
Chris@115
|
87 }
|
Chris@115
|
88
|
Chris@115
|
89 smoothing->setCurrentIndex(sm);
|
Chris@115
|
90
|
Chris@115
|
91 connect(smoothing, SIGNAL(currentIndexChanged(int)),
|
Chris@115
|
92 this, SLOT(spectrogramSmoothingChanged(int)));
|
Chris@0
|
93
|
Chris@299
|
94 QComboBox *xsmoothing = new QComboBox;
|
Chris@299
|
95
|
Chris@299
|
96 int xsm = prefs->getPropertyRangeAndValue("Spectrogram X Smoothing", &min, &max,
|
Chris@299
|
97 &deflt);
|
Chris@299
|
98 m_spectrogramXSmoothing = xsm;
|
Chris@299
|
99
|
Chris@299
|
100 for (i = min; i <= max; ++i) {
|
Chris@299
|
101 xsmoothing->addItem(prefs->getPropertyValueLabel("Spectrogram X Smoothing", i));
|
Chris@299
|
102 }
|
Chris@299
|
103
|
Chris@299
|
104 xsmoothing->setCurrentIndex(xsm);
|
Chris@299
|
105
|
Chris@299
|
106 connect(xsmoothing, SIGNAL(currentIndexChanged(int)),
|
Chris@299
|
107 this, SLOT(spectrogramXSmoothingChanged(int)));
|
Chris@299
|
108
|
Chris@0
|
109 QComboBox *propertyLayout = new QComboBox;
|
Chris@114
|
110 int pl = prefs->getPropertyRangeAndValue("Property Box Layout", &min, &max,
|
Chris@115
|
111 &deflt);
|
Chris@0
|
112 m_propertyLayout = pl;
|
Chris@0
|
113
|
Chris@0
|
114 for (i = min; i <= max; ++i) {
|
Chris@0
|
115 propertyLayout->addItem(prefs->getPropertyValueLabel("Property Box Layout", i));
|
Chris@0
|
116 }
|
Chris@0
|
117
|
Chris@0
|
118 propertyLayout->setCurrentIndex(pl);
|
Chris@0
|
119
|
Chris@0
|
120 connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
|
Chris@0
|
121 this, SLOT(propertyLayoutChanged(int)));
|
Chris@0
|
122
|
Chris@0
|
123 m_tuningFrequency = prefs->getTuningFrequency();
|
Chris@0
|
124
|
Chris@0
|
125 QDoubleSpinBox *frequency = new QDoubleSpinBox;
|
Chris@0
|
126 frequency->setMinimum(100.0);
|
Chris@0
|
127 frequency->setMaximum(5000.0);
|
Chris@0
|
128 frequency->setSuffix(" Hz");
|
Chris@0
|
129 frequency->setSingleStep(1);
|
Chris@0
|
130 frequency->setValue(m_tuningFrequency);
|
Chris@0
|
131 frequency->setDecimals(2);
|
Chris@0
|
132
|
Chris@0
|
133 connect(frequency, SIGNAL(valueChanged(double)),
|
Chris@0
|
134 this, SLOT(tuningFrequencyChanged(double)));
|
Chris@0
|
135
|
Chris@263
|
136 QComboBox *audioDevice = new QComboBox;
|
Chris@263
|
137 std::vector<QString> devices =
|
Chris@263
|
138 AudioTargetFactory::getInstance()->getCallbackTargetNames();
|
Chris@263
|
139
|
Chris@263
|
140 QSettings settings;
|
Chris@263
|
141 settings.beginGroup("Preferences");
|
Chris@263
|
142 QString targetName = settings.value("audio-target", "").toString();
|
Chris@263
|
143 settings.endGroup();
|
Chris@263
|
144
|
Chris@263
|
145 for (int i = 0; i < devices.size(); ++i) {
|
Chris@263
|
146 audioDevice->addItem(AudioTargetFactory::getInstance()
|
Chris@263
|
147 ->getCallbackTargetDescription(devices[i]));
|
Chris@263
|
148 if (targetName == devices[i]) audioDevice->setCurrentIndex(i);
|
Chris@263
|
149 }
|
Chris@263
|
150
|
Chris@263
|
151 connect(audioDevice, SIGNAL(currentIndexChanged(int)),
|
Chris@263
|
152 this, SLOT(audioDeviceChanged(int)));
|
Chris@263
|
153
|
Chris@32
|
154 QComboBox *resampleQuality = new QComboBox;
|
Chris@32
|
155
|
Chris@114
|
156 int rsq = prefs->getPropertyRangeAndValue("Resample Quality", &min, &max,
|
Chris@114
|
157 &deflt);
|
Chris@32
|
158 m_resampleQuality = rsq;
|
Chris@32
|
159
|
Chris@32
|
160 for (i = min; i <= max; ++i) {
|
Chris@32
|
161 resampleQuality->addItem(prefs->getPropertyValueLabel("Resample Quality", i));
|
Chris@32
|
162 }
|
Chris@32
|
163
|
Chris@32
|
164 resampleQuality->setCurrentIndex(rsq);
|
Chris@32
|
165
|
Chris@32
|
166 connect(resampleQuality, SIGNAL(currentIndexChanged(int)),
|
Chris@32
|
167 this, SLOT(resampleQualityChanged(int)));
|
Chris@32
|
168
|
Chris@180
|
169 QCheckBox *resampleOnLoad = new QCheckBox;
|
Chris@180
|
170 m_resampleOnLoad = prefs->getResampleOnLoad();
|
Chris@180
|
171 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
|
Chris@180
|
172 Qt::Unchecked);
|
Chris@180
|
173 connect(resampleOnLoad, SIGNAL(stateChanged(int)),
|
Chris@180
|
174 this, SLOT(resampleOnLoadChanged(int)));
|
Chris@180
|
175
|
Chris@180
|
176 m_tempDirRootEdit = new QLineEdit;
|
Chris@180
|
177 QString dir = prefs->getTemporaryDirectoryRoot();
|
Chris@180
|
178 m_tempDirRoot = dir;
|
Chris@180
|
179 dir.replace("$HOME", tr("<home directory>"));
|
Chris@180
|
180 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
181 m_tempDirRootEdit->setReadOnly(true);
|
Chris@180
|
182 QPushButton *tempDirButton = new QPushButton;
|
Chris@180
|
183 tempDirButton->setIcon(IconLoader().load("fileopen"));
|
Chris@180
|
184 connect(tempDirButton, SIGNAL(clicked()),
|
Chris@180
|
185 this, SLOT(tempDirButtonClicked()));
|
Chris@180
|
186 tempDirButton->setFixedSize(QSize(24, 24));
|
Chris@180
|
187
|
Chris@237
|
188 QCheckBox *showSplash = new QCheckBox;
|
Chris@237
|
189 m_showSplash = prefs->getShowSplash();
|
Chris@237
|
190 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked);
|
Chris@237
|
191 connect(showSplash, SIGNAL(stateChanged(int)),
|
Chris@237
|
192 this, SLOT(showSplashChanged(int)));
|
Chris@237
|
193
|
mathieu@459
|
194 QCheckBox *startInMiniMode = new QCheckBox;
|
mathieu@459
|
195 m_startInMiniMode = prefs->getStartInMiniMode();
|
mathieu@459
|
196 startInMiniMode->setCheckState(m_startInMiniMode ? Qt::Checked : Qt::Unchecked);
|
mathieu@459
|
197 connect(startInMiniMode, SIGNAL(stateChanged(int)),
|
mathieu@459
|
198 this, SLOT(startInMiniModeChanged(int)));
|
mathieu@459
|
199
|
Chris@237
|
200 #ifndef Q_WS_MAC
|
Chris@180
|
201 QComboBox *bgMode = new QComboBox;
|
Chris@180
|
202 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
|
Chris@180
|
203 &deflt);
|
Chris@180
|
204 m_backgroundMode = bg;
|
Chris@180
|
205 for (i = min; i <= max; ++i) {
|
Chris@180
|
206 bgMode->addItem(prefs->getPropertyValueLabel("Background Mode", i));
|
Chris@180
|
207 }
|
Chris@180
|
208 bgMode->setCurrentIndex(bg);
|
Chris@180
|
209
|
Chris@180
|
210 connect(bgMode, SIGNAL(currentIndexChanged(int)),
|
Chris@180
|
211 this, SLOT(backgroundModeChanged(int)));
|
Chris@237
|
212 #endif
|
Chris@180
|
213
|
Chris@225
|
214 QSpinBox *fontSize = new QSpinBox;
|
Chris@225
|
215 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
|
Chris@225
|
216 &deflt);
|
Chris@234
|
217 m_viewFontSize = fs;
|
Chris@225
|
218 fontSize->setMinimum(min);
|
Chris@225
|
219 fontSize->setMaximum(max);
|
Chris@225
|
220 fontSize->setSuffix(" pt");
|
Chris@225
|
221 fontSize->setSingleStep(1);
|
Chris@225
|
222 fontSize->setValue(fs);
|
Chris@225
|
223
|
Chris@225
|
224 connect(fontSize, SIGNAL(valueChanged(int)),
|
Chris@225
|
225 this, SLOT(viewFontSizeChanged(int)));
|
Chris@225
|
226
|
Chris@337
|
227 QComboBox *ttMode = new QComboBox;
|
Chris@337
|
228 int tt = prefs->getPropertyRangeAndValue("Time To Text Mode", &min, &max,
|
Chris@337
|
229 &deflt);
|
Chris@337
|
230 m_timeToTextMode = tt;
|
Chris@337
|
231 for (i = min; i <= max; ++i) {
|
Chris@337
|
232 ttMode->addItem(prefs->getPropertyValueLabel("Time To Text Mode", i));
|
Chris@337
|
233 }
|
Chris@337
|
234 ttMode->setCurrentIndex(tt);
|
Chris@337
|
235
|
Chris@337
|
236 connect(ttMode, SIGNAL(currentIndexChanged(int)),
|
Chris@337
|
237 this, SLOT(timeToTextModeChanged(int)));
|
Chris@337
|
238
|
Chris@180
|
239 // General tab
|
Chris@180
|
240
|
Chris@180
|
241 QFrame *frame = new QFrame;
|
Chris@180
|
242
|
Chris@180
|
243 QGridLayout *subgrid = new QGridLayout;
|
Chris@180
|
244 frame->setLayout(subgrid);
|
Chris@180
|
245
|
Chris@0
|
246 int row = 0;
|
Chris@0
|
247
|
Chris@0
|
248 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
249 ("Temporary Directory Root"))),
|
Chris@263
|
250 row, 0);
|
Chris@263
|
251 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
|
Chris@263
|
252 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
|
Chris@263
|
253 row++;
|
Chris@263
|
254
|
Chris@263
|
255 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
256 ("Resample On Load"))),
|
Chris@263
|
257 row, 0);
|
Chris@263
|
258 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
|
Chris@263
|
259
|
Chris@263
|
260 subgrid->addWidget(new QLabel(tr("Playback audio device:")), row, 0);
|
Chris@263
|
261 subgrid->addWidget(audioDevice, row++, 1, 1, 2);
|
Chris@263
|
262
|
Chris@263
|
263 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
264 ("Resample Quality"))),
|
Chris@263
|
265 row, 0);
|
Chris@263
|
266 subgrid->addWidget(resampleQuality, row++, 1, 1, 2);
|
Chris@263
|
267
|
Chris@263
|
268 subgrid->setRowStretch(row, 10);
|
Chris@263
|
269
|
Chris@436
|
270 m_tabOrdering[GeneralTab] = m_tabs->count();
|
Chris@436
|
271 m_tabs->addTab(frame, tr("&General"));
|
Chris@263
|
272
|
Chris@263
|
273 // Appearance tab
|
Chris@263
|
274
|
Chris@263
|
275 frame = new QFrame;
|
Chris@263
|
276 subgrid = new QGridLayout;
|
Chris@263
|
277 frame->setLayout(subgrid);
|
Chris@263
|
278 row = 0;
|
Chris@263
|
279
|
Chris@263
|
280 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
281 ("Property Box Layout"))),
|
Chris@0
|
282 row, 0);
|
Chris@0
|
283 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
|
Chris@0
|
284
|
Chris@242
|
285 #ifndef Q_WS_MAC
|
Chris@0
|
286 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
287 ("Background Mode"))),
|
Chris@0
|
288 row, 0);
|
Chris@180
|
289 subgrid->addWidget(bgMode, row++, 1, 1, 2);
|
Chris@242
|
290 #endif
|
Chris@180
|
291
|
Chris@180
|
292 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@225
|
293 ("View Font Size"))),
|
Chris@225
|
294 row, 0);
|
Chris@225
|
295 subgrid->addWidget(fontSize, row++, 1, 1, 2);
|
Chris@225
|
296
|
Chris@225
|
297 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@337
|
298 ("Time To Text Mode"))),
|
Chris@337
|
299 row, 0);
|
Chris@337
|
300 subgrid->addWidget(ttMode, row++, 1, 1, 2);
|
Chris@337
|
301
|
Chris@337
|
302 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@237
|
303 ("Show Splash Screen"))),
|
Chris@237
|
304 row, 0);
|
Chris@237
|
305 subgrid->addWidget(showSplash, row++, 1, 1, 1);
|
Chris@237
|
306
|
Chris@180
|
307 subgrid->setRowStretch(row, 10);
|
mathieu@466
|
308
|
mathieu@459
|
309 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
mathieu@466
|
310 ("Start In Minimal Mode"))), row, 0);
|
mathieu@459
|
311 subgrid->addWidget(startInMiniMode, row++, 1, 1, 1);
|
mathieu@459
|
312
|
mathieu@459
|
313 subgrid->setRowStretch(row, 10);
|
Chris@180
|
314
|
Chris@436
|
315 m_tabOrdering[AppearanceTab] = m_tabs->count();
|
mathieu@466
|
316
|
Chris@436
|
317 m_tabs->addTab(frame, tr("&Appearance"));
|
mathieu@466
|
318
|
Chris@180
|
319
|
Chris@180
|
320 // Analysis tab
|
Chris@180
|
321
|
Chris@180
|
322 frame = new QFrame;
|
Chris@180
|
323 subgrid = new QGridLayout;
|
Chris@180
|
324 frame->setLayout(subgrid);
|
Chris@180
|
325 row = 0;
|
Chris@180
|
326
|
Chris@180
|
327 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
328 ("Tuning Frequency"))),
|
Chris@180
|
329 row, 0);
|
Chris@180
|
330 subgrid->addWidget(frequency, row++, 1, 1, 2);
|
Chris@180
|
331
|
Chris@0
|
332 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
|
Chris@299
|
333 ("Spectrogram Y Smoothing")),
|
Chris@115
|
334 row, 0);
|
Chris@115
|
335 subgrid->addWidget(smoothing, row++, 1, 1, 2);
|
Chris@0
|
336
|
Chris@299
|
337 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
|
Chris@299
|
338 ("Spectrogram X Smoothing")),
|
Chris@299
|
339 row, 0);
|
Chris@299
|
340 subgrid->addWidget(xsmoothing, row++, 1, 1, 2);
|
Chris@299
|
341
|
Chris@0
|
342 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
343 ("Window Type"))),
|
Chris@0
|
344 row, 0);
|
Chris@9
|
345 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
|
Chris@9
|
346 subgrid->setRowStretch(row, 10);
|
Chris@9
|
347 row++;
|
Chris@0
|
348
|
Chris@180
|
349 subgrid->setRowStretch(row, 10);
|
Chris@180
|
350
|
Chris@436
|
351 m_tabOrdering[AnalysisTab] = m_tabs->count();
|
Chris@436
|
352 m_tabs->addTab(frame, tr("Anal&ysis"));
|
Chris@436
|
353
|
Chris@436
|
354 // Template tab
|
Chris@436
|
355
|
Chris@436
|
356 frame = new QFrame;
|
Chris@436
|
357 subgrid = new QGridLayout;
|
Chris@436
|
358 frame->setLayout(subgrid);
|
Chris@436
|
359 row = 0;
|
Chris@436
|
360
|
Chris@436
|
361 subgrid->addWidget(new QLabel(tr("Default session template for audio files:")), row++, 0);
|
Chris@436
|
362
|
Chris@436
|
363 QListWidget *lw = new QListWidget();
|
Chris@436
|
364 subgrid->addWidget(lw, row, 0);
|
Chris@436
|
365 subgrid->setRowStretch(row, 10);
|
Chris@436
|
366 row++;
|
Chris@436
|
367
|
Chris@436
|
368 settings.beginGroup("MainWindow");
|
Chris@436
|
369 m_currentTemplate = settings.value("sessiontemplate", "").toString();
|
Chris@436
|
370 settings.endGroup();
|
Chris@436
|
371
|
Chris@455
|
372 lw->addItem(tr("Standard Waveform"));
|
Chris@436
|
373 if (m_currentTemplate == "" || m_currentTemplate == "default") {
|
Chris@436
|
374 lw->setCurrentRow(lw->count()-1);
|
Chris@436
|
375 }
|
Chris@436
|
376 m_templates.push_back("");
|
Chris@436
|
377
|
Chris@436
|
378 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
|
Chris@436
|
379
|
Chris@436
|
380 std::set<QString> byName;
|
Chris@436
|
381 foreach (QString t, templates) {
|
Chris@436
|
382 byName.insert(QFileInfo(t).baseName());
|
Chris@436
|
383 }
|
Chris@436
|
384
|
Chris@436
|
385 foreach (QString t, byName) {
|
Chris@436
|
386 if (t.toLower() == "default") continue;
|
Chris@436
|
387 m_templates.push_back(t);
|
Chris@436
|
388 lw->addItem(t);
|
Chris@436
|
389 if (m_currentTemplate == t) {
|
Chris@436
|
390 lw->setCurrentRow(lw->count()-1);
|
Chris@436
|
391 }
|
Chris@436
|
392 }
|
Chris@436
|
393
|
Chris@436
|
394 connect(lw, SIGNAL(currentRowChanged(int)), this, SLOT(defaultTemplateChanged(int)));
|
Chris@436
|
395
|
Chris@436
|
396 m_tabOrdering[TemplateTab] = m_tabs->count();
|
Chris@436
|
397 m_tabs->addTab(frame, tr("Session &Template"));
|
Chris@180
|
398
|
Chris@163
|
399 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
|
Chris@163
|
400 grid->addWidget(bb, 1, 0);
|
Chris@0
|
401
|
Chris@0
|
402 QPushButton *ok = new QPushButton(tr("OK"));
|
Chris@0
|
403 QPushButton *cancel = new QPushButton(tr("Cancel"));
|
Chris@163
|
404 bb->addButton(ok, QDialogButtonBox::AcceptRole);
|
Chris@163
|
405 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
|
Chris@163
|
406 bb->addButton(cancel, QDialogButtonBox::RejectRole);
|
Chris@0
|
407 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
|
Chris@0
|
408 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
|
Chris@0
|
409 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
Chris@0
|
410
|
Chris@0
|
411 m_applyButton->setEnabled(false);
|
Chris@0
|
412 }
|
Chris@0
|
413
|
Chris@0
|
414 PreferencesDialog::~PreferencesDialog()
|
Chris@0
|
415 {
|
Chris@438
|
416 SVDEBUG << "PreferencesDialog::~PreferencesDialog()" << endl;
|
Chris@0
|
417 }
|
Chris@0
|
418
|
Chris@0
|
419 void
|
Chris@436
|
420 PreferencesDialog::switchToTab(Tab t)
|
Chris@436
|
421 {
|
Chris@436
|
422 if (m_tabOrdering.contains(t)) {
|
Chris@436
|
423 m_tabs->setCurrentIndex(m_tabOrdering[t]);
|
Chris@436
|
424 }
|
Chris@436
|
425 }
|
Chris@436
|
426
|
Chris@436
|
427 void
|
Chris@9
|
428 PreferencesDialog::windowTypeChanged(WindowType type)
|
Chris@0
|
429 {
|
Chris@0
|
430 m_windowType = type;
|
Chris@0
|
431 m_applyButton->setEnabled(true);
|
Chris@0
|
432 }
|
Chris@0
|
433
|
Chris@0
|
434 void
|
Chris@115
|
435 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
|
Chris@0
|
436 {
|
Chris@115
|
437 m_spectrogramSmoothing = smoothing;
|
Chris@0
|
438 m_applyButton->setEnabled(true);
|
Chris@0
|
439 }
|
Chris@0
|
440
|
Chris@0
|
441 void
|
Chris@299
|
442 PreferencesDialog::spectrogramXSmoothingChanged(int smoothing)
|
Chris@299
|
443 {
|
Chris@299
|
444 m_spectrogramXSmoothing = smoothing;
|
Chris@299
|
445 m_applyButton->setEnabled(true);
|
Chris@299
|
446 }
|
Chris@299
|
447
|
Chris@299
|
448 void
|
Chris@0
|
449 PreferencesDialog::propertyLayoutChanged(int layout)
|
Chris@0
|
450 {
|
Chris@0
|
451 m_propertyLayout = layout;
|
Chris@0
|
452 m_applyButton->setEnabled(true);
|
Chris@0
|
453 }
|
Chris@0
|
454
|
Chris@0
|
455 void
|
Chris@0
|
456 PreferencesDialog::tuningFrequencyChanged(double freq)
|
Chris@0
|
457 {
|
Chris@0
|
458 m_tuningFrequency = freq;
|
Chris@0
|
459 m_applyButton->setEnabled(true);
|
Chris@0
|
460 }
|
Chris@0
|
461
|
Chris@0
|
462 void
|
Chris@263
|
463 PreferencesDialog::audioDeviceChanged(int s)
|
Chris@263
|
464 {
|
Chris@263
|
465 m_audioDevice = s;
|
Chris@263
|
466 m_applyButton->setEnabled(true);
|
Chris@263
|
467 m_changesOnRestart = true;
|
Chris@263
|
468 }
|
Chris@263
|
469
|
Chris@263
|
470 void
|
Chris@32
|
471 PreferencesDialog::resampleQualityChanged(int q)
|
Chris@32
|
472 {
|
Chris@32
|
473 m_resampleQuality = q;
|
Chris@32
|
474 m_applyButton->setEnabled(true);
|
Chris@32
|
475 }
|
Chris@32
|
476
|
Chris@32
|
477 void
|
Chris@180
|
478 PreferencesDialog::resampleOnLoadChanged(int state)
|
Chris@180
|
479 {
|
Chris@180
|
480 m_resampleOnLoad = (state == Qt::Checked);
|
Chris@180
|
481 m_applyButton->setEnabled(true);
|
Chris@180
|
482 m_changesOnRestart = true;
|
Chris@180
|
483 }
|
Chris@180
|
484
|
Chris@180
|
485 void
|
Chris@237
|
486 PreferencesDialog::showSplashChanged(int state)
|
Chris@237
|
487 {
|
Chris@237
|
488 m_showSplash = (state == Qt::Checked);
|
Chris@237
|
489 m_applyButton->setEnabled(true);
|
Chris@237
|
490 m_changesOnRestart = true;
|
Chris@237
|
491 }
|
Chris@237
|
492
|
Chris@237
|
493 void
|
Chris@436
|
494 PreferencesDialog::defaultTemplateChanged(int i)
|
Chris@436
|
495 {
|
Chris@436
|
496 m_currentTemplate = m_templates[i];
|
Chris@436
|
497 m_applyButton->setEnabled(true);
|
Chris@436
|
498 }
|
Chris@436
|
499
|
mathieu@466
|
500
|
mathieu@466
|
501 void
|
mathieu@459
|
502 PreferencesDialog::startInMiniModeChanged(int state)
|
mathieu@459
|
503 {
|
mathieu@459
|
504 m_startInMiniMode = (state == Qt::Checked);
|
mathieu@459
|
505 m_applyButton->setEnabled(true);
|
mathieu@459
|
506 m_changesOnRestart = true;
|
mathieu@459
|
507 }
|
mathieu@459
|
508
|
mathieu@459
|
509 void
|
Chris@180
|
510 PreferencesDialog::tempDirRootChanged(QString r)
|
Chris@180
|
511 {
|
Chris@180
|
512 m_tempDirRoot = r;
|
Chris@180
|
513 m_applyButton->setEnabled(true);
|
Chris@180
|
514 }
|
Chris@180
|
515
|
Chris@180
|
516 void
|
Chris@180
|
517 PreferencesDialog::tempDirButtonClicked()
|
Chris@180
|
518 {
|
Chris@180
|
519 QString dir = QFileDialog::getExistingDirectory
|
Chris@180
|
520 (this, tr("Select a directory to create cache subdirectory in"),
|
Chris@180
|
521 m_tempDirRoot);
|
Chris@180
|
522 if (dir == "") return;
|
Chris@180
|
523 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
524 tempDirRootChanged(dir);
|
Chris@180
|
525 m_changesOnRestart = true;
|
Chris@180
|
526 }
|
Chris@180
|
527
|
Chris@180
|
528 void
|
Chris@180
|
529 PreferencesDialog::backgroundModeChanged(int mode)
|
Chris@180
|
530 {
|
Chris@180
|
531 m_backgroundMode = mode;
|
Chris@180
|
532 m_applyButton->setEnabled(true);
|
Chris@180
|
533 m_changesOnRestart = true;
|
Chris@180
|
534 }
|
Chris@180
|
535
|
Chris@180
|
536 void
|
Chris@337
|
537 PreferencesDialog::timeToTextModeChanged(int mode)
|
Chris@337
|
538 {
|
Chris@337
|
539 m_timeToTextMode = mode;
|
Chris@337
|
540 m_applyButton->setEnabled(true);
|
Chris@337
|
541 }
|
Chris@337
|
542
|
Chris@337
|
543 void
|
Chris@225
|
544 PreferencesDialog::viewFontSizeChanged(int sz)
|
Chris@225
|
545 {
|
Chris@225
|
546 m_viewFontSize = sz;
|
Chris@225
|
547 m_applyButton->setEnabled(true);
|
Chris@225
|
548 }
|
Chris@225
|
549
|
Chris@225
|
550 void
|
Chris@0
|
551 PreferencesDialog::okClicked()
|
Chris@0
|
552 {
|
Chris@0
|
553 applyClicked();
|
Chris@0
|
554 accept();
|
Chris@0
|
555 }
|
Chris@0
|
556
|
Chris@0
|
557 void
|
Chris@0
|
558 PreferencesDialog::applyClicked()
|
Chris@0
|
559 {
|
Chris@0
|
560 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
561 prefs->setWindowType(WindowType(m_windowType));
|
Chris@115
|
562 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
|
Chris@115
|
563 (m_spectrogramSmoothing));
|
Chris@299
|
564 prefs->setSpectrogramXSmoothing(Preferences::SpectrogramXSmoothing
|
Chris@299
|
565 (m_spectrogramXSmoothing));
|
Chris@0
|
566 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
|
Chris@0
|
567 (m_propertyLayout));
|
Chris@0
|
568 prefs->setTuningFrequency(m_tuningFrequency);
|
Chris@32
|
569 prefs->setResampleQuality(m_resampleQuality);
|
Chris@180
|
570 prefs->setResampleOnLoad(m_resampleOnLoad);
|
Chris@237
|
571 prefs->setShowSplash(m_showSplash);
|
mathieu@459
|
572 prefs->setStartInMiniMode(m_startInMiniMode);
|
Chris@180
|
573 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
|
Chris@180
|
574 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
|
Chris@337
|
575 prefs->setTimeToTextMode(Preferences::TimeToTextMode(m_timeToTextMode));
|
Chris@225
|
576 prefs->setViewFontSize(m_viewFontSize);
|
Chris@263
|
577
|
Chris@263
|
578 std::vector<QString> devices =
|
Chris@263
|
579 AudioTargetFactory::getInstance()->getCallbackTargetNames();
|
Chris@263
|
580
|
Chris@263
|
581 QSettings settings;
|
Chris@436
|
582
|
Chris@263
|
583 settings.beginGroup("Preferences");
|
Chris@263
|
584 settings.setValue("audio-target", devices[m_audioDevice]);
|
Chris@263
|
585 settings.endGroup();
|
Chris@180
|
586
|
Chris@436
|
587 settings.beginGroup("MainWindow");
|
Chris@436
|
588 settings.setValue("sessiontemplate", m_currentTemplate);
|
Chris@436
|
589 settings.endGroup();
|
Chris@436
|
590
|
Chris@0
|
591 m_applyButton->setEnabled(false);
|
Chris@180
|
592
|
Chris@180
|
593 if (m_changesOnRestart) {
|
Chris@180
|
594 QMessageBox::information(this, tr("Preferences"),
|
Chris@255
|
595 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
|
596 m_changesOnRestart = false;
|
Chris@180
|
597 }
|
Chris@0
|
598 }
|
Chris@0
|
599
|
Chris@0
|
600 void
|
Chris@0
|
601 PreferencesDialog::cancelClicked()
|
Chris@0
|
602 {
|
Chris@0
|
603 reject();
|
Chris@0
|
604 }
|
Chris@0
|
605
|
Chris@163
|
606 void
|
Chris@163
|
607 PreferencesDialog::applicationClosing(bool quickly)
|
Chris@163
|
608 {
|
Chris@163
|
609 if (quickly) {
|
Chris@163
|
610 reject();
|
Chris@163
|
611 return;
|
Chris@163
|
612 }
|
Chris@163
|
613
|
Chris@163
|
614 if (m_applyButton->isEnabled()) {
|
Chris@163
|
615 int rv = QMessageBox::warning
|
Chris@163
|
616 (this, tr("Preferences Changed"),
|
Chris@163
|
617 tr("Some preferences have been changed but not applied.\n"
|
Chris@163
|
618 "Apply them before closing?"),
|
Chris@163
|
619 QMessageBox::Apply | QMessageBox::Discard,
|
Chris@163
|
620 QMessageBox::Discard);
|
Chris@163
|
621 if (rv == QMessageBox::Apply) {
|
Chris@163
|
622 applyClicked();
|
Chris@163
|
623 accept();
|
Chris@163
|
624 } else {
|
Chris@163
|
625 reject();
|
Chris@163
|
626 }
|
Chris@163
|
627 } else {
|
Chris@163
|
628 accept();
|
Chris@163
|
629 }
|
Chris@163
|
630 }
|
Chris@163
|
631
|