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