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 Tony
|
Chris@0
|
5 An intonation analysis and annotation tool
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7 This file copyright 2006-2012 Chris Cannam and QMUL.
|
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 "../version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@95
|
19 #include "NetworkPermissionTester.h"
|
Chris@6
|
20 #include "Analyser.h"
|
Chris@6
|
21
|
Chris@0
|
22 #include "framework/Document.h"
|
Chris@95
|
23 #include "framework/VersionTester.h"
|
Chris@0
|
24
|
Chris@0
|
25 #include "view/Pane.h"
|
Chris@0
|
26 #include "view/PaneStack.h"
|
Chris@0
|
27 #include "data/model/WaveFileModel.h"
|
matthiasm@26
|
28 #include "data/model/NoteModel.h"
|
matthiasm@26
|
29 #include "data/model/FlexiNoteModel.h"
|
matthiasm@42
|
30 #include "layer/FlexiNoteLayer.h"
|
matthiasm@26
|
31 #include "data/model/NoteModel.h"
|
Chris@0
|
32 #include "view/ViewManager.h"
|
Chris@0
|
33 #include "base/Preferences.h"
|
Chris@0
|
34 #include "layer/WaveformLayer.h"
|
Chris@0
|
35 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
36 #include "layer/TimeValueLayer.h"
|
Chris@192
|
37 #include "layer/SpectrogramLayer.h"
|
Chris@0
|
38 #include "widgets/Fader.h"
|
Chris@0
|
39 #include "view/Overview.h"
|
Chris@0
|
40 #include "widgets/AudioDial.h"
|
Chris@0
|
41 #include "widgets/IconLoader.h"
|
Chris@0
|
42 #include "widgets/KeyReference.h"
|
Chris@0
|
43 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
44 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
45 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@0
|
46 #include "base/Profiler.h"
|
Chris@0
|
47 #include "base/UnitDatabase.h"
|
Chris@0
|
48 #include "layer/ColourDatabase.h"
|
Chris@139
|
49 #include "base/Selection.h"
|
Chris@0
|
50
|
Chris@174
|
51 #include "rdf/RDFImporter.h"
|
Chris@174
|
52 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@174
|
53 #include "data/fileio/CSVFormat.h"
|
matthiasm@26
|
54 #include "data/fileio/CSVFileWriter.h"
|
matthiasm@26
|
55 #include "data/fileio/MIDIFileWriter.h"
|
matthiasm@26
|
56 #include "rdf/RDFExporter.h"
|
matthiasm@26
|
57
|
Chris@0
|
58 // For version information
|
Chris@0
|
59 #include "vamp/vamp.h"
|
Chris@0
|
60 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
61 #include "plugin/api/ladspa.h"
|
Chris@0
|
62 #include "plugin/api/dssi.h"
|
Chris@0
|
63
|
Chris@0
|
64 #include <QApplication>
|
Chris@0
|
65 #include <QMessageBox>
|
Chris@0
|
66 #include <QGridLayout>
|
Chris@0
|
67 #include <QLabel>
|
Chris@0
|
68 #include <QMenuBar>
|
Chris@0
|
69 #include <QToolBar>
|
Chris@0
|
70 #include <QToolButton>
|
Chris@0
|
71 #include <QInputDialog>
|
Chris@0
|
72 #include <QStatusBar>
|
Chris@0
|
73 #include <QFileInfo>
|
Chris@0
|
74 #include <QDir>
|
Chris@0
|
75 #include <QProcess>
|
Chris@2
|
76 #include <QPushButton>
|
Chris@0
|
77 #include <QSettings>
|
Chris@0
|
78 #include <QScrollArea>
|
Chris@128
|
79 #include <QPainter>
|
Chris@0
|
80
|
Chris@0
|
81 #include <iostream>
|
Chris@0
|
82 #include <cstdio>
|
Chris@0
|
83 #include <errno.h>
|
Chris@0
|
84
|
Chris@0
|
85 using std::vector;
|
Chris@0
|
86
|
Chris@0
|
87
|
Chris@0
|
88 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@0
|
89 MainWindowBase(withAudioOutput, withOSCSupport, false),
|
Chris@0
|
90 m_overview(0),
|
Chris@0
|
91 m_mainMenusCreated(false),
|
Chris@0
|
92 m_playbackMenu(0),
|
gyorgyf@45
|
93 m_recentFilesMenu(0),
|
Chris@0
|
94 m_rightButtonMenu(0),
|
Chris@0
|
95 m_rightButtonPlaybackMenu(0),
|
Chris@0
|
96 m_deleteSelectedAction(0),
|
Chris@0
|
97 m_ffwdAction(0),
|
Chris@0
|
98 m_rwdAction(0),
|
Chris@168
|
99 m_intelligentActionOn(true), //GF: !!! temporary
|
Chris@0
|
100 m_keyReference(new KeyReference())
|
Chris@0
|
101 {
|
Chris@0
|
102 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
103
|
Chris@206
|
104 #ifdef Q_OS_MAC
|
Chris@206
|
105 #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
|
Chris@206
|
106 setUnifiedTitleAndToolBarOnMac(true);
|
Chris@206
|
107 #endif
|
Chris@206
|
108 #endif
|
Chris@206
|
109
|
Chris@0
|
110 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@0
|
111 udb->registerUnit("Hz");
|
Chris@0
|
112 udb->registerUnit("dB");
|
Chris@0
|
113 udb->registerUnit("s");
|
Chris@0
|
114
|
Chris@0
|
115 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@0
|
116 cdb->addColour(Qt::black, tr("Black"));
|
Chris@0
|
117 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@0
|
118 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@0
|
119 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@0
|
120 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@0
|
121 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@120
|
122 cdb->addColour(QColor(180, 180, 180), tr("Grey"));
|
Chris@0
|
123 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@0
|
124 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@0
|
125 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@0
|
126 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@0
|
127 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@0
|
128 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
129
|
Chris@0
|
130 Preferences::getInstance()->setResampleOnLoad(true);
|
Chris@0
|
131 Preferences::getInstance()->setSpectrogramSmoothing
|
Chris@0
|
132 (Preferences::SpectrogramInterpolated);
|
Chris@0
|
133
|
Chris@0
|
134 QSettings settings;
|
Chris@0
|
135
|
Chris@0
|
136 settings.beginGroup("MainWindow");
|
Chris@0
|
137 settings.setValue("showstatusbar", false);
|
Chris@0
|
138 settings.endGroup();
|
Chris@0
|
139
|
Chris@96
|
140 settings.beginGroup("Transformer");
|
Chris@96
|
141 settings.setValue("use-flexi-note-model", true);
|
Chris@96
|
142 settings.endGroup();
|
Chris@96
|
143
|
Chris@73
|
144 settings.beginGroup("LayerDefaults");
|
Chris@73
|
145 settings.setValue("waveform",
|
Chris@73
|
146 QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
Chris@73
|
147 .arg(int(WaveformLayer::LinearScale))
|
Chris@73
|
148 .arg(int(WaveformLayer::MixChannels)));
|
Chris@73
|
149 settings.endGroup();
|
Chris@73
|
150
|
Chris@6
|
151 m_viewManager->setAlignMode(false);
|
Chris@6
|
152 m_viewManager->setPlaySoloMode(false);
|
Chris@0
|
153 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
154 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@6
|
155 m_viewManager->setIlluminateLocalFeatures(true);
|
Chris@0
|
156 m_viewManager->setShowWorkTitle(true);
|
Chris@6
|
157 m_viewManager->setShowCentreLine(false);
|
Chris@91
|
158 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@0
|
159
|
Chris@192
|
160 connect(m_viewManager, SIGNAL(selectionChangedByUser()),
|
Chris@192
|
161 this, SLOT(selectionChangedByUser()));
|
Chris@164
|
162
|
Chris@0
|
163 QFrame *frame = new QFrame;
|
Chris@0
|
164 setCentralWidget(frame);
|
Chris@0
|
165
|
Chris@0
|
166 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
167
|
Chris@0
|
168 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@0
|
169 scroll->setWidgetResizable(true);
|
Chris@0
|
170 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@0
|
171 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@0
|
172
|
Chris@6
|
173 // We have a pane stack: it comes with the territory. However, we
|
Chris@120
|
174 // have a fixed and known number of panes in it -- it isn't
|
Chris@120
|
175 // variable
|
Chris@0
|
176 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@137
|
177 m_paneStack->setShowPaneAccessories(false);
|
Chris@139
|
178 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(size_t)),
|
Chris@139
|
179 this, SLOT(doubleClickSelectInvoked(size_t)));
|
Chris@0
|
180 scroll->setWidget(m_paneStack);
|
Chris@6
|
181
|
Chris@0
|
182 m_overview = new Overview(frame);
|
Chris@0
|
183 m_overview->setViewManager(m_viewManager);
|
Chris@0
|
184 m_overview->setFixedHeight(40);
|
Chris@0
|
185 #ifndef _WIN32
|
Chris@0
|
186 // For some reason, the contents of the overview never appear if we
|
Chris@0
|
187 // make this setting on Windows. I have no inclination at the moment
|
Chris@0
|
188 // to track down the reason why.
|
Chris@0
|
189 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@0
|
190 #endif
|
Chris@0
|
191 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
192 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
193
|
Chris@0
|
194 m_panLayer = new WaveformLayer;
|
Chris@0
|
195 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
196 m_panLayer->setAggressiveCacheing(true);
|
Chris@0
|
197 m_overview->addLayer(m_panLayer);
|
Chris@0
|
198
|
Chris@0
|
199 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@0
|
200 m_panLayer->setBaseColour
|
Chris@0
|
201 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@0
|
202 } else {
|
Chris@0
|
203 m_panLayer->setBaseColour
|
matthiasm@13
|
204 (ColourDatabase::getInstance()->getColourIndex(tr("Blue")));
|
Chris@0
|
205 }
|
Chris@0
|
206
|
Chris@0
|
207 m_fader = new Fader(frame, false);
|
Chris@0
|
208 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
209 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
210
|
Chris@0
|
211 m_playSpeed = new AudioDial(frame);
|
Chris@0
|
212 m_playSpeed->setMinimum(0);
|
Chris@0
|
213 m_playSpeed->setMaximum(200);
|
Chris@0
|
214 m_playSpeed->setValue(100);
|
Chris@0
|
215 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
216 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
217 m_playSpeed->setNotchesVisible(true);
|
Chris@0
|
218 m_playSpeed->setPageStep(10);
|
Chris@0
|
219 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@0
|
220 m_playSpeed->setDefaultValue(100);
|
Chris@0
|
221 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@0
|
222 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
223 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
gyorgyf@27
|
224 this, SLOT(playSpeedChanged(int)));
|
Chris@0
|
225 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
226 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
227
|
justin@159
|
228 // Gain controls
|
justin@159
|
229 m_gainAudio = new AudioDial(frame);
|
justin@159
|
230 m_gainAudio->setMinimum(-50);
|
justin@159
|
231 m_gainAudio->setMaximum(50);
|
justin@159
|
232 m_gainAudio->setValue(0);
|
justin@159
|
233 m_gainAudio->setDefaultValue(0);
|
justin@159
|
234 m_gainAudio->setFixedWidth(24);
|
justin@159
|
235 m_gainAudio->setFixedHeight(24);
|
justin@159
|
236 m_gainAudio->setNotchesVisible(true);
|
justin@159
|
237 m_gainAudio->setPageStep(10);
|
justin@159
|
238 m_gainAudio->setObjectName(tr("Audio Track Gain"));
|
justin@159
|
239 m_gainAudio->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
240 m_gainAudio->setShowToolTip(true);
|
justin@159
|
241 connect(m_gainAudio, SIGNAL(valueChanged(int)),
|
justin@159
|
242 this, SLOT(audioGainChanged(int)));
|
justin@159
|
243 connect(m_gainAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
244 connect(m_gainAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
245
|
justin@157
|
246 m_gainPitch = new AudioDial(frame);
|
Chris@158
|
247 m_gainPitch->setMinimum(-50);
|
Chris@158
|
248 m_gainPitch->setMaximum(50);
|
Chris@158
|
249 m_gainPitch->setValue(0);
|
Chris@158
|
250 m_gainPitch->setDefaultValue(0);
|
justin@157
|
251 m_gainPitch->setFixedWidth(24);
|
justin@157
|
252 m_gainPitch->setFixedHeight(24);
|
justin@157
|
253 m_gainPitch->setNotchesVisible(true);
|
justin@157
|
254 m_gainPitch->setPageStep(10);
|
Chris@158
|
255 m_gainPitch->setObjectName(tr("Pitch Track Gain"));
|
Chris@158
|
256 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@157
|
257 m_gainPitch->setShowToolTip(true);
|
justin@157
|
258 connect(m_gainPitch, SIGNAL(valueChanged(int)),
|
Chris@158
|
259 this, SLOT(pitchGainChanged(int)));
|
justin@157
|
260 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@157
|
261 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@157
|
262
|
justin@159
|
263 m_gainNotes = new AudioDial(frame);
|
justin@159
|
264 m_gainNotes->setMinimum(-50);
|
justin@159
|
265 m_gainNotes->setMaximum(50);
|
justin@159
|
266 m_gainNotes->setValue(0);
|
justin@159
|
267 m_gainNotes->setDefaultValue(0);
|
justin@159
|
268 m_gainNotes->setFixedWidth(24);
|
justin@159
|
269 m_gainNotes->setFixedHeight(24);
|
justin@159
|
270 m_gainNotes->setNotchesVisible(true);
|
justin@159
|
271 m_gainNotes->setPageStep(10);
|
justin@159
|
272 m_gainNotes->setObjectName(tr("Pitch Track Gain"));
|
justin@159
|
273 m_gainNotes->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
274 m_gainNotes->setShowToolTip(true);
|
justin@159
|
275 connect(m_gainNotes, SIGNAL(valueChanged(int)),
|
justin@159
|
276 this, SLOT(notesGainChanged(int)));
|
justin@159
|
277 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
278 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
279 // End of Gain controls
|
justin@159
|
280
|
justin@160
|
281 // Pan controls
|
justin@160
|
282 m_panAudio = new AudioDial(frame);
|
justin@160
|
283 m_panAudio->setMinimum(-100);
|
justin@160
|
284 m_panAudio->setMaximum(100);
|
justin@160
|
285 m_panAudio->setValue(-100);
|
justin@160
|
286 m_panAudio->setDefaultValue(-100);
|
justin@160
|
287 m_panAudio->setFixedWidth(24);
|
justin@160
|
288 m_panAudio->setFixedHeight(24);
|
justin@160
|
289 m_panAudio->setNotchesVisible(true);
|
justin@160
|
290 m_panAudio->setPageStep(10);
|
justin@160
|
291 m_panAudio->setObjectName(tr("Audio Track Pan"));
|
justin@160
|
292 m_panAudio->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
293 m_panAudio->setShowToolTip(true);
|
justin@160
|
294 connect(m_panAudio, SIGNAL(valueChanged(int)),
|
justin@160
|
295 this, SLOT(audioPanChanged(int)));
|
justin@160
|
296 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
297 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
298
|
justin@160
|
299 m_panPitch = new AudioDial(frame);
|
justin@160
|
300 m_panPitch->setMinimum(-100);
|
justin@160
|
301 m_panPitch->setMaximum(100);
|
justin@160
|
302 m_panPitch->setValue(100);
|
justin@160
|
303 m_panPitch->setDefaultValue(100);
|
justin@160
|
304 m_panPitch->setFixedWidth(24);
|
justin@160
|
305 m_panPitch->setFixedHeight(24);
|
justin@160
|
306 m_panPitch->setNotchesVisible(true);
|
justin@160
|
307 m_panPitch->setPageStep(10);
|
justin@160
|
308 m_panPitch->setObjectName(tr("Pitch Track Pan"));
|
justin@160
|
309 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
310 m_panPitch->setShowToolTip(true);
|
justin@160
|
311 connect(m_panPitch, SIGNAL(valueChanged(int)),
|
justin@160
|
312 this, SLOT(pitchPanChanged(int)));
|
justin@160
|
313 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
314 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
315
|
justin@160
|
316 m_panNotes = new AudioDial(frame);
|
justin@160
|
317 m_panNotes->setMinimum(-100);
|
justin@160
|
318 m_panNotes->setMaximum(100);
|
justin@160
|
319 m_panNotes->setValue(100);
|
justin@160
|
320 m_panNotes->setDefaultValue(100);
|
justin@160
|
321 m_panNotes->setFixedWidth(24);
|
justin@160
|
322 m_panNotes->setFixedHeight(24);
|
justin@160
|
323 m_panNotes->setNotchesVisible(true);
|
justin@160
|
324 m_panNotes->setPageStep(10);
|
justin@160
|
325 m_panNotes->setObjectName(tr("Notes Track Pan"));
|
justin@160
|
326 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
327 m_panNotes->setShowToolTip(true);
|
justin@160
|
328 connect(m_panNotes, SIGNAL(valueChanged(int)),
|
justin@160
|
329 this, SLOT(notesPanChanged(int)));
|
justin@160
|
330 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
331 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
332 // End of Pan controls
|
justin@160
|
333
|
Chris@0
|
334 layout->setSpacing(4);
|
Chris@6
|
335 layout->addWidget(m_overview, 0, 1);
|
Chris@6
|
336 layout->addWidget(scroll, 1, 1);
|
Chris@0
|
337
|
Chris@0
|
338 layout->setColumnStretch(1, 10);
|
Chris@0
|
339
|
Chris@0
|
340 frame->setLayout(layout);
|
Chris@0
|
341
|
gyorgyf@21
|
342 m_analyser = new Analyser();
|
Chris@128
|
343 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@128
|
344 this, SLOT(updateLayerStatuses()));
|
Chris@187
|
345 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@187
|
346 this, SLOT(updateMenuStates()));
|
gyorgyf@21
|
347
|
Chris@0
|
348 setupMenus();
|
Chris@0
|
349 setupToolbars();
|
Chris@0
|
350 setupHelpMenu();
|
Chris@0
|
351
|
Chris@0
|
352 statusBar();
|
Chris@0
|
353
|
Chris@95
|
354 newSession();
|
Chris@6
|
355
|
Chris@95
|
356 settings.beginGroup("MainWindow");
|
Chris@95
|
357 settings.setValue("zoom-default", 512);
|
Chris@95
|
358 settings.endGroup();
|
Chris@95
|
359 zoomDefault();
|
Chris@95
|
360
|
Chris@95
|
361 NetworkPermissionTester tester;
|
Chris@95
|
362 bool networkPermission = tester.havePermission();
|
Chris@95
|
363 if (networkPermission) {
|
Chris@95
|
364 m_versionTester = new VersionTester
|
Chris@95
|
365 ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
|
Chris@95
|
366 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@95
|
367 this, SLOT(newerVersionAvailable(QString)));
|
Chris@95
|
368 } else {
|
Chris@95
|
369 m_versionTester = 0;
|
Chris@95
|
370 }
|
Chris@0
|
371 }
|
Chris@0
|
372
|
Chris@0
|
373 MainWindow::~MainWindow()
|
Chris@0
|
374 {
|
Chris@6
|
375 delete m_analyser;
|
Chris@0
|
376 delete m_keyReference;
|
Chris@0
|
377 Profiles::getInstance()->dump();
|
Chris@0
|
378 }
|
Chris@0
|
379
|
Chris@0
|
380 void
|
Chris@0
|
381 MainWindow::setupMenus()
|
Chris@0
|
382 {
|
Chris@0
|
383 if (!m_mainMenusCreated) {
|
Chris@0
|
384 m_rightButtonMenu = new QMenu();
|
Chris@0
|
385 }
|
Chris@0
|
386
|
Chris@0
|
387 if (!m_mainMenusCreated) {
|
Chris@0
|
388 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
389 m_rightButtonMenu->addSeparator();
|
Chris@0
|
390 }
|
Chris@0
|
391
|
Chris@0
|
392 setupFileMenu();
|
Chris@0
|
393 setupEditMenu();
|
Chris@0
|
394 setupViewMenu();
|
Chris@0
|
395
|
Chris@0
|
396 m_mainMenusCreated = true;
|
Chris@0
|
397 }
|
Chris@0
|
398
|
Chris@0
|
399 void
|
Chris@0
|
400 MainWindow::setupFileMenu()
|
Chris@0
|
401 {
|
Chris@0
|
402 if (m_mainMenusCreated) return;
|
Chris@0
|
403
|
Chris@0
|
404 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@0
|
405 menu->setTearOffEnabled(true);
|
Chris@0
|
406 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@0
|
407
|
Chris@0
|
408 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@0
|
409
|
Chris@0
|
410 IconLoader il;
|
Chris@1
|
411 QIcon icon;
|
Chris@1
|
412 QAction *action;
|
Chris@0
|
413
|
Chris@0
|
414 icon = il.load("fileopen");
|
Chris@0
|
415 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@1
|
416 action = new QAction(icon, tr("&Open..."), this);
|
Chris@0
|
417 action->setShortcut(tr("Ctrl+O"));
|
Chris@1
|
418 action->setStatusTip(tr("Open a file"));
|
Chris@0
|
419 connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
|
Chris@0
|
420 m_keyReference->registerShortcut(action);
|
Chris@0
|
421 menu->addAction(action);
|
Chris@0
|
422 toolbar->addAction(action);
|
Chris@0
|
423
|
Chris@1
|
424 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@0
|
425 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@1
|
426 action->setStatusTip(tr("Open a file from a remote URL"));
|
Chris@0
|
427 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@0
|
428 m_keyReference->registerShortcut(action);
|
Chris@0
|
429 menu->addAction(action);
|
Chris@0
|
430
|
Chris@1
|
431 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@0
|
432 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@0
|
433 setupRecentFilesMenu();
|
Chris@0
|
434 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@0
|
435 this, SLOT(setupRecentFilesMenu()));
|
Chris@0
|
436
|
Chris@0
|
437 menu->addSeparator();
|
Chris@174
|
438 action = new QAction(tr("Import Pitch Track Data..."), this);
|
Chris@174
|
439 action->setStatusTip(tr("Import pitch-track data from a file"));
|
Chris@174
|
440 connect(action, SIGNAL(triggered()), this, SLOT(importPitchLayer()));
|
Chris@174
|
441 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@174
|
442 menu->addAction(action);
|
Chris@174
|
443
|
Chris@85
|
444 action = new QAction(tr("Export Pitch Track Data..."), this);
|
Chris@85
|
445 action->setStatusTip(tr("Export pitch-track data to a file"));
|
Chris@85
|
446 connect(action, SIGNAL(triggered()), this, SLOT(exportPitchLayer()));
|
Chris@85
|
447 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@85
|
448 menu->addAction(action);
|
Chris@85
|
449
|
Chris@85
|
450 action = new QAction(tr("Export Note Data..."), this);
|
Chris@85
|
451 action->setStatusTip(tr("Export note data to a file"));
|
Chris@85
|
452 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
|
matthiasm@26
|
453 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@26
|
454 menu->addAction(action);
|
matthiasm@26
|
455
|
matthiasm@26
|
456 menu->addSeparator();
|
Chris@0
|
457 action = new QAction(il.load("exit"), tr("&Quit"), this);
|
Chris@0
|
458 action->setShortcut(tr("Ctrl+Q"));
|
Chris@0
|
459 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@0
|
460 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@0
|
461 m_keyReference->registerShortcut(action);
|
Chris@0
|
462 menu->addAction(action);
|
Chris@0
|
463 }
|
Chris@0
|
464
|
Chris@0
|
465 void
|
Chris@0
|
466 MainWindow::setupEditMenu()
|
Chris@0
|
467 {
|
Chris@0
|
468 if (m_mainMenusCreated) return;
|
Chris@0
|
469
|
Chris@0
|
470 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@0
|
471 menu->setTearOffEnabled(true);
|
Chris@0
|
472 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@126
|
473 menu->addSeparator();
|
Chris@126
|
474
|
Chris@126
|
475 QToolBar *toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@126
|
476
|
Chris@126
|
477 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@126
|
478
|
Chris@126
|
479 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
480
|
Chris@126
|
481 QActionGroup *group = new QActionGroup(this);
|
Chris@126
|
482
|
Chris@126
|
483 IconLoader il;
|
Chris@126
|
484
|
Chris@126
|
485 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@126
|
486 tr("Navigate"));
|
Chris@126
|
487 action->setCheckable(true);
|
Chris@126
|
488 action->setChecked(true);
|
Chris@126
|
489 action->setShortcut(tr("1"));
|
Chris@126
|
490 action->setStatusTip(tr("Navigate"));
|
Chris@126
|
491 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@126
|
492 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@126
|
493 group->addAction(action);
|
Chris@126
|
494 menu->addAction(action);
|
Chris@126
|
495 m_keyReference->registerShortcut(action);
|
Chris@126
|
496
|
Chris@126
|
497 action = toolbar->addAction(il.load("move"),
|
Chris@126
|
498 tr("Edit"));
|
Chris@126
|
499 action->setCheckable(true);
|
Chris@126
|
500 action->setShortcut(tr("2"));
|
Chris@126
|
501 action->setStatusTip(tr("Edit with Note Intelligence"));
|
Chris@126
|
502 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@126
|
503 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
504 group->addAction(action);
|
Chris@126
|
505 menu->addAction(action);
|
Chris@126
|
506 m_keyReference->registerShortcut(action);
|
Chris@126
|
507
|
Chris@126
|
508 /* Remove for now...
|
Chris@126
|
509
|
Chris@126
|
510 action = toolbar->addAction(il.load("notes"),
|
Chris@126
|
511 tr("Free Edit"));
|
Chris@126
|
512 action->setCheckable(true);
|
Chris@126
|
513 action->setShortcut(tr("3"));
|
Chris@126
|
514 action->setStatusTip(tr("Free Edit"));
|
Chris@126
|
515 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
|
Chris@126
|
516 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
517 group->addAction(action);
|
Chris@126
|
518 m_keyReference->registerShortcut(action);
|
Chris@126
|
519 */
|
Chris@142
|
520
|
Chris@142
|
521 menu->addSeparator();
|
Chris@142
|
522
|
Chris@143
|
523 m_keyReference->setCategory(tr("Selection"));
|
Chris@143
|
524
|
Chris@143
|
525 action = new QAction(tr("Select &All"), this);
|
Chris@143
|
526 action->setShortcut(tr("Ctrl+A"));
|
Chris@143
|
527 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@143
|
528 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@143
|
529 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
530 m_keyReference->registerShortcut(action);
|
Chris@143
|
531 menu->addAction(action);
|
Chris@143
|
532 m_rightButtonMenu->addAction(action);
|
Chris@143
|
533
|
Chris@143
|
534 action = new QAction(tr("C&lear Selection"), this);
|
Chris@143
|
535 action->setShortcut(tr("Esc"));
|
Chris@143
|
536 action->setStatusTip(tr("Clear the selection"));
|
Chris@194
|
537 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection()));
|
Chris@143
|
538 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
539 m_keyReference->registerShortcut(action);
|
Chris@143
|
540 menu->addAction(action);
|
Chris@143
|
541 m_rightButtonMenu->addAction(action);
|
Chris@143
|
542
|
Chris@143
|
543 menu->addSeparator();
|
Chris@189
|
544 m_rightButtonMenu->addSeparator();
|
Chris@143
|
545
|
Chris@189
|
546 m_keyReference->setCategory(tr("Pitch Track"));
|
Chris@189
|
547
|
Chris@187
|
548 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this);
|
Chris@187
|
549 m_showCandidatesAction->setShortcut(tr("Ctrl+Return"));
|
Chris@189
|
550 m_showCandidatesAction->setStatusTip(tr("Toggle the display of alternative pitch candidates for the selected region"));
|
Chris@189
|
551 m_keyReference->registerShortcut(m_showCandidatesAction);
|
Chris@187
|
552 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates()));
|
Chris@187
|
553 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
|
Chris@187
|
554 menu->addAction(m_showCandidatesAction);
|
Chris@189
|
555 m_rightButtonMenu->addAction(m_showCandidatesAction);
|
Chris@187
|
556
|
Chris@187
|
557 action = new QAction(tr("Pick Higher Pitch Candidate"), this);
|
Chris@187
|
558 action->setShortcut(tr("Ctrl+Up"));
|
Chris@189
|
559 action->setStatusTip(tr("Switch to the next higher pitch candidate in the selected region"));
|
Chris@189
|
560 m_keyReference->registerShortcut(action);
|
Chris@187
|
561 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
|
Chris@198
|
562 connect(this, SIGNAL(canChangeToHigherCandidate(bool)), action, SLOT(setEnabled(bool)));
|
Chris@168
|
563 menu->addAction(action);
|
Chris@189
|
564 m_rightButtonMenu->addAction(action);
|
Chris@187
|
565
|
Chris@187
|
566 action = new QAction(tr("Pick Lower Pitch Candidate"), this);
|
Chris@187
|
567 action->setShortcut(tr("Ctrl+Down"));
|
Chris@189
|
568 action->setStatusTip(tr("Switch to the next lower pitch candidate in the selected region"));
|
Chris@189
|
569 m_keyReference->registerShortcut(action);
|
Chris@187
|
570 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown()));
|
Chris@198
|
571 connect(this, SIGNAL(canChangeToLowerCandidate(bool)), action, SLOT(setEnabled(bool)));
|
Chris@187
|
572 menu->addAction(action);
|
Chris@189
|
573 m_rightButtonMenu->addAction(action);
|
Chris@187
|
574
|
Chris@187
|
575 menu->addSeparator();
|
Chris@189
|
576 m_rightButtonMenu->addSeparator();
|
Chris@187
|
577
|
Chris@142
|
578 action = new QAction(tr("Octave Shift Up"), this);
|
Chris@142
|
579 action->setShortcut(tr("PgUp"));
|
Chris@189
|
580 action->setStatusTip(tr("Move all pitches up an octave in the selected region"));
|
Chris@189
|
581 m_keyReference->registerShortcut(action);
|
Chris@142
|
582 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp()));
|
Chris@142
|
583 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@142
|
584 menu->addAction(action);
|
Chris@189
|
585 m_rightButtonMenu->addAction(action);
|
Chris@142
|
586
|
Chris@142
|
587 action = new QAction(tr("Octave Shift Down"), this);
|
Chris@142
|
588 action->setShortcut(tr("PgDown"));
|
Chris@189
|
589 action->setStatusTip(tr("Move all pitches down an octave in the selected region"));
|
Chris@189
|
590 m_keyReference->registerShortcut(action);
|
Chris@142
|
591 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown()));
|
Chris@142
|
592 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@142
|
593 menu->addAction(action);
|
Chris@189
|
594 m_rightButtonMenu->addAction(action);
|
Chris@187
|
595
|
Chris@187
|
596 menu->addSeparator();
|
Chris@189
|
597 m_rightButtonMenu->addSeparator();
|
Chris@167
|
598
|
Chris@187
|
599 action = new QAction(tr("Remove Pitches"), this);
|
Chris@187
|
600 action->setShortcut(tr("Ctrl+Backspace"));
|
Chris@189
|
601 action->setStatusTip(tr("Remove all pitch estimates within the selected region (converting it to unvoiced)"));
|
Chris@189
|
602 m_keyReference->registerShortcut(action);
|
Chris@187
|
603 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
|
Chris@167
|
604 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@167
|
605 menu->addAction(action);
|
Chris@189
|
606 m_rightButtonMenu->addAction(action);
|
Chris@0
|
607 }
|
Chris@0
|
608
|
Chris@0
|
609 void
|
Chris@0
|
610 MainWindow::setupViewMenu()
|
Chris@0
|
611 {
|
Chris@0
|
612 if (m_mainMenusCreated) return;
|
Chris@0
|
613
|
Chris@0
|
614 IconLoader il;
|
Chris@0
|
615
|
Chris@0
|
616 QAction *action = 0;
|
Chris@0
|
617
|
Chris@0
|
618 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@0
|
619
|
Chris@0
|
620 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@0
|
621 menu->setTearOffEnabled(true);
|
Chris@0
|
622 action = new QAction(tr("Scroll &Left"), this);
|
Chris@0
|
623 action->setShortcut(tr("Left"));
|
Chris@0
|
624 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@0
|
625 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@0
|
626 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
627 m_keyReference->registerShortcut(action);
|
Chris@0
|
628 menu->addAction(action);
|
gyorgyf@27
|
629
|
Chris@0
|
630 action = new QAction(tr("Scroll &Right"), this);
|
Chris@0
|
631 action->setShortcut(tr("Right"));
|
Chris@0
|
632 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@0
|
633 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@0
|
634 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
635 m_keyReference->registerShortcut(action);
|
Chris@0
|
636 menu->addAction(action);
|
gyorgyf@27
|
637
|
Chris@0
|
638 action = new QAction(tr("&Jump Left"), this);
|
Chris@0
|
639 action->setShortcut(tr("Ctrl+Left"));
|
Chris@0
|
640 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@0
|
641 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@0
|
642 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
643 m_keyReference->registerShortcut(action);
|
Chris@0
|
644 menu->addAction(action);
|
gyorgyf@27
|
645
|
Chris@0
|
646 action = new QAction(tr("J&ump Right"), this);
|
Chris@0
|
647 action->setShortcut(tr("Ctrl+Right"));
|
Chris@0
|
648 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@0
|
649 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@0
|
650 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
651 m_keyReference->registerShortcut(action);
|
Chris@0
|
652 menu->addAction(action);
|
Chris@0
|
653
|
Chris@0
|
654 menu->addSeparator();
|
Chris@0
|
655
|
Chris@0
|
656 m_keyReference->setCategory(tr("Zoom"));
|
Chris@0
|
657
|
Chris@0
|
658 action = new QAction(il.load("zoom-in"),
|
Chris@0
|
659 tr("Zoom &In"), this);
|
Chris@0
|
660 action->setShortcut(tr("Up"));
|
Chris@0
|
661 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@0
|
662 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@0
|
663 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
664 m_keyReference->registerShortcut(action);
|
Chris@0
|
665 menu->addAction(action);
|
gyorgyf@27
|
666
|
Chris@0
|
667 action = new QAction(il.load("zoom-out"),
|
Chris@0
|
668 tr("Zoom &Out"), this);
|
Chris@0
|
669 action->setShortcut(tr("Down"));
|
Chris@0
|
670 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@0
|
671 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@0
|
672 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
673 m_keyReference->registerShortcut(action);
|
Chris@0
|
674 menu->addAction(action);
|
gyorgyf@27
|
675
|
Chris@0
|
676 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@0
|
677 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@0
|
678 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@0
|
679 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
680 menu->addAction(action);
|
Chris@0
|
681
|
Chris@0
|
682 action = new QAction(il.load("zoom-fit"),
|
Chris@0
|
683 tr("Zoom to &Fit"), this);
|
Chris@0
|
684 action->setShortcut(tr("F"));
|
Chris@0
|
685 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@0
|
686 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@0
|
687 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
688 m_keyReference->registerShortcut(action);
|
Chris@0
|
689 menu->addAction(action);
|
Chris@0
|
690 }
|
Chris@0
|
691
|
Chris@0
|
692 void
|
Chris@0
|
693 MainWindow::setupHelpMenu()
|
Chris@0
|
694 {
|
Chris@0
|
695 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@0
|
696 menu->setTearOffEnabled(true);
|
Chris@0
|
697
|
Chris@0
|
698 m_keyReference->setCategory(tr("Help"));
|
Chris@0
|
699
|
Chris@0
|
700 IconLoader il;
|
Chris@0
|
701
|
Chris@1
|
702 QString name = QApplication::applicationName();
|
Chris@1
|
703
|
Chris@0
|
704 QAction *action = new QAction(il.load("help"),
|
Chris@0
|
705 tr("&Help Reference"), this);
|
Chris@0
|
706 action->setShortcut(tr("F1"));
|
Chris@1
|
707 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
Chris@0
|
708 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
709 m_keyReference->registerShortcut(action);
|
Chris@0
|
710 menu->addAction(action);
|
Chris@0
|
711
|
Chris@0
|
712 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@0
|
713 action->setShortcut(tr("F2"));
|
Chris@1
|
714 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@0
|
715 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@0
|
716 m_keyReference->registerShortcut(action);
|
Chris@0
|
717 menu->addAction(action);
|
Chris@0
|
718
|
Chris@1
|
719 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@1
|
720 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@0
|
721 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
722 menu->addAction(action);
|
Chris@0
|
723
|
Chris@1
|
724 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@1
|
725 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@0
|
726 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
727 menu->addAction(action);
|
Chris@0
|
728 }
|
Chris@0
|
729
|
Chris@0
|
730 void
|
Chris@0
|
731 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
732 {
|
Chris@0
|
733 m_recentFilesMenu->clear();
|
Chris@0
|
734 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
735 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@50
|
736 QAction *action = new QAction(files[i], this);
|
Chris@50
|
737 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
738 if (i == 0) {
|
Chris@0
|
739 action->setShortcut(tr("Ctrl+R"));
|
Chris@0
|
740 m_keyReference->registerShortcut
|
Chris@0
|
741 (tr("Re-open"),
|
Chris@50
|
742 action->shortcut().toString(),
|
Chris@0
|
743 tr("Re-open the current or most recently opened file"));
|
Chris@0
|
744 }
|
Chris@50
|
745 m_recentFilesMenu->addAction(action);
|
Chris@0
|
746 }
|
Chris@0
|
747 }
|
Chris@0
|
748
|
Chris@0
|
749 void
|
Chris@0
|
750 MainWindow::setupToolbars()
|
Chris@0
|
751 {
|
Chris@0
|
752 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@0
|
753
|
Chris@0
|
754 IconLoader il;
|
Chris@0
|
755
|
Chris@0
|
756 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@0
|
757 menu->setTearOffEnabled(true);
|
Chris@0
|
758 m_rightButtonMenu->addSeparator();
|
Chris@0
|
759 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@0
|
760
|
Chris@0
|
761 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@0
|
762
|
Chris@0
|
763 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@0
|
764 tr("Rewind to Start"));
|
Chris@0
|
765 rwdStartAction->setShortcut(tr("Home"));
|
Chris@0
|
766 rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
767 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
768 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@0
|
769
|
Chris@0
|
770 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
|
Chris@0
|
771 tr("Rewind"));
|
Chris@0
|
772 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@0
|
773 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
774 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
775
|
Chris@0
|
776 QAction *playAction = toolbar->addAction(il.load("playpause"),
|
Chris@0
|
777 tr("Play / Pause"));
|
Chris@0
|
778 playAction->setCheckable(true);
|
Chris@0
|
779 playAction->setShortcut(tr("Space"));
|
Chris@0
|
780 playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
781 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
782 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
gyorgyf@27
|
783 playAction, SLOT(setChecked(bool)));
|
Chris@0
|
784 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
|
Chris@0
|
785
|
Chris@0
|
786 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@0
|
787 tr("Fast Forward"));
|
Chris@0
|
788 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@0
|
789 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
790 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
791
|
Chris@0
|
792 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@0
|
793 tr("Fast Forward to End"));
|
Chris@0
|
794 ffwdEndAction->setShortcut(tr("End"));
|
Chris@0
|
795 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
796 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
797 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@6
|
798
|
Chris@0
|
799 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
800
|
Chris@0
|
801 QAction *psAction = toolbar->addAction(il.load("playselection"),
|
Chris@0
|
802 tr("Constrain Playback to Selection"));
|
Chris@0
|
803 psAction->setCheckable(true);
|
Chris@0
|
804 psAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
805 psAction->setShortcut(tr("s"));
|
Chris@0
|
806 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@0
|
807 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@0
|
808 psAction, SLOT(setChecked(bool)));
|
Chris@0
|
809 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
810 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
|
Chris@0
|
811
|
Chris@0
|
812 QAction *plAction = toolbar->addAction(il.load("playloop"),
|
Chris@0
|
813 tr("Loop Playback"));
|
Chris@0
|
814 plAction->setCheckable(true);
|
Chris@0
|
815 plAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
816 plAction->setShortcut(tr("l"));
|
Chris@0
|
817 plAction->setStatusTip(tr("Loop playback"));
|
Chris@0
|
818 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@0
|
819 plAction, SLOT(setChecked(bool)));
|
Chris@0
|
820 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
821 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
|
Chris@0
|
822
|
Chris@0
|
823 m_keyReference->registerShortcut(psAction);
|
Chris@0
|
824 m_keyReference->registerShortcut(plAction);
|
Chris@0
|
825 m_keyReference->registerShortcut(playAction);
|
Chris@0
|
826 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@0
|
827 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@0
|
828 m_keyReference->registerShortcut(rwdStartAction);
|
Chris@0
|
829 m_keyReference->registerShortcut(ffwdEndAction);
|
Chris@0
|
830
|
Chris@6
|
831 menu->addAction(playAction);
|
Chris@0
|
832 menu->addAction(psAction);
|
Chris@0
|
833 menu->addAction(plAction);
|
Chris@0
|
834 menu->addSeparator();
|
Chris@0
|
835 menu->addAction(m_rwdAction);
|
Chris@0
|
836 menu->addAction(m_ffwdAction);
|
Chris@0
|
837 menu->addSeparator();
|
Chris@0
|
838 menu->addAction(rwdStartAction);
|
Chris@0
|
839 menu->addAction(ffwdEndAction);
|
Chris@0
|
840 menu->addSeparator();
|
Chris@0
|
841
|
Chris@0
|
842 m_rightButtonPlaybackMenu->addAction(playAction);
|
Chris@0
|
843 m_rightButtonPlaybackMenu->addAction(psAction);
|
Chris@0
|
844 m_rightButtonPlaybackMenu->addAction(plAction);
|
Chris@0
|
845 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
846 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@0
|
847 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@0
|
848 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
849 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
|
Chris@0
|
850 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
|
Chris@0
|
851 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
852
|
Chris@0
|
853 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@0
|
854 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@0
|
855 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@0
|
856 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@0
|
857 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@0
|
858
|
Chris@0
|
859 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@0
|
860 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@0
|
861 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@0
|
862 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@0
|
863 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@0
|
864
|
Chris@0
|
865 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@0
|
866 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@0
|
867 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@0
|
868 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@0
|
869 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@0
|
870
|
Chris@0
|
871 m_keyReference->registerShortcut(fastAction);
|
Chris@0
|
872 m_keyReference->registerShortcut(slowAction);
|
Chris@0
|
873 m_keyReference->registerShortcut(normalAction);
|
Chris@0
|
874
|
Chris@0
|
875 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@0
|
876 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@0
|
877 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@6
|
878
|
Chris@195
|
879 toolbar = new QToolBar(tr("Playback Controls"));
|
Chris@195
|
880 addToolBar(Qt::BottomToolBarArea, toolbar);
|
Chris@195
|
881
|
Chris@6
|
882 toolbar->addWidget(m_playSpeed);
|
Chris@6
|
883 toolbar->addWidget(m_fader);
|
Chris@0
|
884
|
Chris@128
|
885 toolbar = addToolBar(tr("Show and Play"));
|
Chris@144
|
886
|
justin@156
|
887 /* ORIGINAL DESIGN
|
Chris@144
|
888 QLabel *eye = new QLabel;
|
Chris@144
|
889 eye->setFixedWidth(40);
|
Chris@144
|
890 eye->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
891 eye->setPixmap(il.loadPixmap("eye"));
|
Chris@144
|
892 toolbar->addWidget(eye);
|
Chris@144
|
893
|
Chris@144
|
894 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
|
Chris@144
|
895 m_showAudio->setCheckable(true);
|
Chris@144
|
896 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
Chris@144
|
897 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
Chris@144
|
898
|
Chris@145
|
899 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
|
Chris@145
|
900 m_showSpect->setCheckable(true);
|
Chris@145
|
901 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
Chris@145
|
902 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@145
|
903
|
Chris@144
|
904 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
|
Chris@144
|
905 m_showPitch->setCheckable(true);
|
Chris@144
|
906 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
Chris@144
|
907 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
Chris@144
|
908
|
Chris@144
|
909 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
|
Chris@144
|
910 m_showNotes->setCheckable(true);
|
Chris@144
|
911 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
Chris@144
|
912 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
Chris@144
|
913
|
Chris@144
|
914 QLabel *speaker = new QLabel;
|
Chris@144
|
915 speaker->setFixedWidth(40);
|
Chris@144
|
916 speaker->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
917 speaker->setPixmap(il.loadPixmap("speaker"));
|
Chris@144
|
918 toolbar->addWidget(speaker);
|
Chris@128
|
919
|
Chris@144
|
920 m_playAudio = toolbar->addAction(il.load("waveform"), tr("Play Audio"));
|
Chris@144
|
921 m_playAudio->setCheckable(true);
|
Chris@144
|
922 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
Chris@144
|
923 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
Chris@128
|
924
|
Chris@144
|
925 m_playPitch = toolbar->addAction(il.load("values"), tr("Play Pitch Track"));
|
Chris@144
|
926 m_playPitch->setCheckable(true);
|
Chris@144
|
927 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
Chris@144
|
928 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
|
Chris@128
|
929
|
Chris@144
|
930 m_playNotes = toolbar->addAction(il.load("notes"), tr("Play Notes"));
|
Chris@144
|
931 m_playNotes->setCheckable(true);
|
Chris@144
|
932 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
Chris@144
|
933 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
934 */
|
justin@156
|
935
|
justin@156
|
936 // Audio
|
justin@156
|
937 QLabel *icon_audio = new QLabel;
|
justin@156
|
938 icon_audio->setFixedWidth(40);
|
justin@156
|
939 icon_audio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
940 icon_audio->setPixmap(il.loadPixmap("waveform"));
|
justin@156
|
941 toolbar->addWidget(icon_audio);
|
justin@156
|
942
|
justin@156
|
943 m_showAudio = toolbar->addAction(il.load("eye"), tr("Show Audio"));
|
justin@156
|
944 m_showAudio->setCheckable(true);
|
justin@156
|
945 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
justin@156
|
946 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
justin@156
|
947
|
justin@156
|
948 m_playAudio = toolbar->addAction(il.load("speaker"), tr("Play Audio"));
|
justin@156
|
949 m_playAudio->setCheckable(true);
|
justin@156
|
950 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
justin@156
|
951 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
justin@156
|
952
|
justin@159
|
953 toolbar->addWidget(m_gainAudio);
|
justin@160
|
954 toolbar->addWidget(m_panAudio);
|
justin@159
|
955
|
justin@156
|
956 // Pitch (f0)
|
justin@156
|
957 QLabel *icon_pitch = new QLabel;
|
justin@156
|
958 icon_pitch->setFixedWidth(40);
|
justin@156
|
959 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
960 icon_pitch->setPixmap(il.loadPixmap("values"));
|
justin@156
|
961 toolbar->addWidget(icon_pitch);
|
justin@156
|
962
|
justin@156
|
963 m_showPitch = toolbar->addAction(il.load("eye"), tr("Show Pitch Track"));
|
justin@156
|
964 m_showPitch->setCheckable(true);
|
justin@156
|
965 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
justin@156
|
966 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
justin@156
|
967
|
justin@156
|
968 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
|
justin@156
|
969 m_playPitch->setCheckable(true);
|
justin@156
|
970 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
justin@186
|
971 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); // JTEST: this resets the enabled state of m_playPitch.
|
justin@156
|
972
|
Chris@158
|
973 toolbar->addWidget(m_gainPitch);
|
justin@160
|
974 toolbar->addWidget(m_panPitch);
|
justin@156
|
975
|
justin@156
|
976 // Notes
|
justin@156
|
977 QLabel *icon_notes = new QLabel;
|
justin@156
|
978 icon_notes->setFixedWidth(40);
|
justin@156
|
979 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
980 icon_notes->setPixmap(il.loadPixmap("notes"));
|
justin@156
|
981 toolbar->addWidget(icon_notes);
|
justin@156
|
982
|
justin@156
|
983 m_showNotes = toolbar->addAction(il.load("eye"), tr("Show Notes"));
|
justin@156
|
984 m_showNotes->setCheckable(true);
|
justin@156
|
985 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
justin@156
|
986 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
justin@156
|
987
|
justin@156
|
988 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes"));
|
justin@156
|
989 m_playNotes->setCheckable(true);
|
justin@156
|
990 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
justin@156
|
991 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
992
|
justin@159
|
993 toolbar->addWidget(m_gainNotes);
|
justin@160
|
994 toolbar->addWidget(m_panNotes);
|
justin@159
|
995
|
justin@156
|
996 // Spectrogram
|
justin@156
|
997 QLabel *icon_spectrogram = new QLabel;
|
justin@156
|
998 icon_spectrogram->setFixedWidth(40);
|
justin@156
|
999 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
1000 icon_spectrogram->setPixmap(il.loadPixmap("spectrogram"));
|
justin@156
|
1001 toolbar->addWidget(icon_spectrogram);
|
justin@156
|
1002
|
justin@156
|
1003 m_showSpect = toolbar->addAction(il.load("eye"), tr("Show Spectrogram"));
|
justin@156
|
1004 m_showSpect->setCheckable(true);
|
justin@156
|
1005 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
justin@156
|
1006 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@128
|
1007
|
Chris@0
|
1008 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
1009 }
|
Chris@0
|
1010
|
Chris@0
|
1011 void
|
Chris@70
|
1012 MainWindow::toolNavigateSelected()
|
Chris@70
|
1013 {
|
Chris@70
|
1014 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@70
|
1015 m_intelligentActionOn = true;
|
Chris@70
|
1016 }
|
Chris@70
|
1017
|
Chris@70
|
1018 void
|
Chris@70
|
1019 MainWindow::toolEditSelected()
|
Chris@70
|
1020 {
|
Chris@77
|
1021 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1022 m_intelligentActionOn = true;
|
Chris@70
|
1023 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1024 }
|
Chris@70
|
1025
|
Chris@70
|
1026 void
|
Chris@70
|
1027 MainWindow::toolFreeEditSelected()
|
Chris@70
|
1028 {
|
Chris@77
|
1029 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1030 m_intelligentActionOn = false;
|
Chris@70
|
1031 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1032 }
|
Chris@70
|
1033
|
gyorgyf@21
|
1034 void
|
Chris@0
|
1035 MainWindow::updateMenuStates()
|
Chris@0
|
1036 {
|
Chris@0
|
1037 MainWindowBase::updateMenuStates();
|
Chris@0
|
1038
|
Chris@0
|
1039 Pane *currentPane = 0;
|
Chris@0
|
1040 Layer *currentLayer = 0;
|
Chris@0
|
1041
|
Chris@0
|
1042 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1043 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@0
|
1044
|
Chris@0
|
1045 bool haveCurrentPane =
|
Chris@0
|
1046 (currentPane != 0);
|
Chris@0
|
1047 bool haveCurrentLayer =
|
Chris@0
|
1048 (haveCurrentPane &&
|
Chris@0
|
1049 (currentLayer != 0));
|
Chris@0
|
1050 bool haveSelection =
|
Chris@187
|
1051 (m_viewManager &&
|
Chris@187
|
1052 !m_viewManager->getSelections().empty());
|
Chris@0
|
1053 bool haveCurrentEditableLayer =
|
Chris@187
|
1054 (haveCurrentLayer &&
|
Chris@187
|
1055 currentLayer->isLayerEditable());
|
Chris@0
|
1056 bool haveCurrentTimeInstantsLayer =
|
Chris@187
|
1057 (haveCurrentLayer &&
|
Chris@187
|
1058 qobject_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
1059 bool haveCurrentTimeValueLayer =
|
Chris@187
|
1060 (haveCurrentLayer &&
|
Chris@187
|
1061 qobject_cast<TimeValueLayer *>(currentLayer));
|
Chris@187
|
1062 bool pitchCandidatesVisible =
|
Chris@187
|
1063 m_analyser->arePitchCandidatesShown();
|
Chris@198
|
1064 bool haveHigher =
|
Chris@198
|
1065 m_analyser->haveHigherPitchCandidate();
|
Chris@198
|
1066 bool haveLower =
|
Chris@198
|
1067 m_analyser->haveLowerPitchCandidate();
|
Chris@0
|
1068
|
Chris@0
|
1069 emit canChangePlaybackSpeed(true);
|
Chris@0
|
1070 int v = m_playSpeed->value();
|
Chris@0
|
1071 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@0
|
1072 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@0
|
1073
|
Chris@187
|
1074 emit canChangePitchCandidate(pitchCandidatesVisible && haveSelection);
|
Chris@198
|
1075 emit canChangeToHigherCandidate(pitchCandidatesVisible && haveSelection && haveHigher);
|
Chris@198
|
1076 emit canChangeToLowerCandidate(pitchCandidatesVisible && haveSelection && haveLower);
|
Chris@187
|
1077
|
Chris@187
|
1078 if (pitchCandidatesVisible) {
|
Chris@187
|
1079 m_showCandidatesAction->setText(tr("Hide Pitch Candidates"));
|
Chris@187
|
1080 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region"));
|
Chris@187
|
1081 } else {
|
Chris@187
|
1082 m_showCandidatesAction->setText(tr("Show Pitch Candidates"));
|
Chris@187
|
1083 m_showCandidatesAction->setStatusTip(tr("Show alternate pitch candidates for the selected region"));
|
Chris@187
|
1084 }
|
Chris@187
|
1085
|
Chris@0
|
1086 if (m_ffwdAction && m_rwdAction) {
|
Chris@0
|
1087 if (haveCurrentTimeInstantsLayer) {
|
Chris@0
|
1088 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@0
|
1089 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1090 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@0
|
1091 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1092 } else if (haveCurrentTimeValueLayer) {
|
Chris@0
|
1093 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@0
|
1094 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@0
|
1095 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@0
|
1096 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@0
|
1097 } else {
|
Chris@0
|
1098 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@0
|
1099 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@0
|
1100 m_rwdAction->setText(tr("Rewind"));
|
Chris@0
|
1101 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@0
|
1102 }
|
Chris@0
|
1103 }
|
Chris@0
|
1104 }
|
Chris@0
|
1105
|
Chris@0
|
1106 void
|
Chris@144
|
1107 MainWindow::showAudioToggled()
|
Chris@128
|
1108 {
|
Chris@144
|
1109 m_analyser->toggleVisible(Analyser::Audio);
|
Chris@128
|
1110 }
|
Chris@128
|
1111
|
Chris@128
|
1112 void
|
Chris@144
|
1113 MainWindow::showPitchToggled()
|
Chris@128
|
1114 {
|
Chris@144
|
1115 m_analyser->toggleVisible(Analyser::PitchTrack);
|
justin@185
|
1116
|
justin@186
|
1117 // JTEST
|
justin@185
|
1118 if (!m_analyser->isVisible(Analyser::PitchTrack))
|
justin@185
|
1119 {
|
justin@185
|
1120 m_analyser->setAudible(Analyser::PitchTrack,false);
|
justin@185
|
1121 m_playPitch->setChecked(false);
|
justin@185
|
1122 m_playPitch->setEnabled(false);
|
justin@185
|
1123 }
|
justin@185
|
1124 else
|
justin@185
|
1125 {
|
justin@185
|
1126 m_playPitch->setEnabled(true);
|
justin@185
|
1127 }
|
Chris@128
|
1128 }
|
Chris@128
|
1129
|
Chris@128
|
1130 void
|
Chris@145
|
1131 MainWindow::showSpectToggled()
|
Chris@145
|
1132 {
|
Chris@145
|
1133 m_analyser->toggleVisible(Analyser::Spectrogram);
|
Chris@145
|
1134 }
|
Chris@145
|
1135
|
Chris@145
|
1136 void
|
Chris@144
|
1137 MainWindow::showNotesToggled()
|
Chris@128
|
1138 {
|
Chris@144
|
1139 m_analyser->toggleVisible(Analyser::Notes);
|
Chris@144
|
1140 }
|
Chris@144
|
1141
|
Chris@144
|
1142 void
|
Chris@144
|
1143 MainWindow::playAudioToggled()
|
Chris@144
|
1144 {
|
Chris@144
|
1145 m_analyser->toggleAudible(Analyser::Audio);
|
Chris@144
|
1146 }
|
Chris@144
|
1147
|
Chris@144
|
1148 void
|
Chris@144
|
1149 MainWindow::playPitchToggled()
|
Chris@144
|
1150 {
|
Chris@144
|
1151 m_analyser->toggleAudible(Analyser::PitchTrack);
|
Chris@144
|
1152 }
|
Chris@144
|
1153
|
Chris@144
|
1154 void
|
Chris@144
|
1155 MainWindow::playNotesToggled()
|
Chris@144
|
1156 {
|
Chris@144
|
1157 m_analyser->toggleAudible(Analyser::Notes);
|
Chris@144
|
1158 }
|
Chris@144
|
1159
|
Chris@144
|
1160 void
|
Chris@144
|
1161 MainWindow::updateLayerStatuses()
|
Chris@144
|
1162 {
|
Chris@144
|
1163 m_showAudio->setChecked(m_analyser->isVisible(Analyser::Audio));
|
Chris@145
|
1164 m_showSpect->setChecked(m_analyser->isVisible(Analyser::Spectrogram));
|
Chris@144
|
1165 m_showPitch->setChecked(m_analyser->isVisible(Analyser::PitchTrack));
|
Chris@144
|
1166 m_showNotes->setChecked(m_analyser->isVisible(Analyser::Notes));
|
Chris@144
|
1167 m_playAudio->setChecked(m_analyser->isAudible(Analyser::Audio));
|
Chris@144
|
1168 m_playPitch->setChecked(m_analyser->isAudible(Analyser::PitchTrack));
|
Chris@144
|
1169 m_playNotes->setChecked(m_analyser->isAudible(Analyser::Notes));
|
Chris@128
|
1170 }
|
Chris@128
|
1171
|
Chris@128
|
1172 void
|
Chris@0
|
1173 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1174 {
|
Chris@6
|
1175 // Nothing, we don't have one
|
Chris@0
|
1176 }
|
Chris@0
|
1177
|
Chris@0
|
1178 void
|
Chris@0
|
1179 MainWindow::documentModified()
|
Chris@0
|
1180 {
|
Chris@0
|
1181 MainWindowBase::documentModified();
|
Chris@0
|
1182 }
|
Chris@0
|
1183
|
Chris@0
|
1184 void
|
Chris@0
|
1185 MainWindow::documentRestored()
|
Chris@0
|
1186 {
|
Chris@0
|
1187 MainWindowBase::documentRestored();
|
Chris@0
|
1188 }
|
Chris@0
|
1189
|
Chris@0
|
1190 void
|
Chris@0
|
1191 MainWindow::newSession()
|
Chris@0
|
1192 {
|
Chris@0
|
1193 if (!checkSaveModified()) return;
|
Chris@0
|
1194
|
Chris@0
|
1195 closeSession();
|
Chris@0
|
1196 createDocument();
|
Chris@0
|
1197 m_document->setAutoAlignment(true);
|
Chris@0
|
1198
|
Chris@0
|
1199 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
1200
|
Chris@0
|
1201 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
1202 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
1203
|
Chris@6
|
1204 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@6
|
1205 // m_document->addLayerToView(pane, waveform);
|
Chris@0
|
1206
|
Chris@0
|
1207 m_overview->registerView(pane);
|
Chris@0
|
1208
|
Chris@0
|
1209 CommandHistory::getInstance()->clear();
|
Chris@0
|
1210 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1211 documentRestored();
|
Chris@0
|
1212 updateMenuStates();
|
Chris@0
|
1213 }
|
Chris@0
|
1214
|
Chris@0
|
1215 void
|
Chris@0
|
1216 MainWindow::closeSession()
|
Chris@0
|
1217 {
|
Chris@0
|
1218 if (!checkSaveModified()) return;
|
Chris@0
|
1219
|
Chris@0
|
1220 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
1221
|
Chris@167
|
1222 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
1223
|
Chris@167
|
1224 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1225 m_document->removeLayerFromView
|
Chris@167
|
1226 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1227 }
|
Chris@167
|
1228
|
Chris@167
|
1229 m_overview->unregisterView(pane);
|
Chris@167
|
1230 m_paneStack->deletePane(pane);
|
Chris@0
|
1231 }
|
Chris@0
|
1232
|
Chris@0
|
1233 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
1234
|
Chris@167
|
1235 Pane *pane = m_paneStack->getHiddenPane
|
Chris@167
|
1236 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@167
|
1237
|
Chris@167
|
1238 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1239 m_document->removeLayerFromView
|
Chris@167
|
1240 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1241 }
|
Chris@167
|
1242
|
Chris@167
|
1243 m_overview->unregisterView(pane);
|
Chris@167
|
1244 m_paneStack->deletePane(pane);
|
Chris@0
|
1245 }
|
Chris@0
|
1246
|
Chris@0
|
1247 delete m_document;
|
Chris@0
|
1248 m_document = 0;
|
Chris@0
|
1249 m_viewManager->clearSelections();
|
Chris@0
|
1250 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
1251
|
Chris@0
|
1252 m_sessionFile = "";
|
Chris@0
|
1253
|
Chris@0
|
1254 CommandHistory::getInstance()->clear();
|
Chris@0
|
1255 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1256 documentRestored();
|
Chris@0
|
1257 }
|
Chris@0
|
1258
|
Chris@0
|
1259 void
|
Chris@0
|
1260 MainWindow::openFile()
|
Chris@0
|
1261 {
|
Chris@0
|
1262 QString orig = m_audioFile;
|
Chris@0
|
1263 if (orig == "") orig = ".";
|
Chris@0
|
1264 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1265
|
Chris@0
|
1266 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
1267
|
Chris@0
|
1268 if (path.isEmpty()) return;
|
Chris@0
|
1269
|
Chris@1
|
1270 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1271
|
Chris@0
|
1272 if (status == FileOpenFailed) {
|
Chris@0
|
1273 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1274 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@0
|
1275 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1276 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1277 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1278 }
|
Chris@0
|
1279 }
|
Chris@0
|
1280
|
Chris@0
|
1281 void
|
Chris@0
|
1282 MainWindow::openLocation()
|
Chris@0
|
1283 {
|
Chris@0
|
1284 QSettings settings;
|
Chris@0
|
1285 settings.beginGroup("MainWindow");
|
Chris@0
|
1286 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@0
|
1287
|
Chris@0
|
1288 bool ok = false;
|
Chris@0
|
1289 QString text = QInputDialog::getText
|
Chris@0
|
1290 (this, tr("Open Location"),
|
Chris@0
|
1291 tr("Please enter the URL of the location to open:"),
|
Chris@0
|
1292 QLineEdit::Normal, lastLocation, &ok);
|
Chris@0
|
1293
|
Chris@0
|
1294 if (!ok) return;
|
Chris@0
|
1295
|
Chris@0
|
1296 settings.setValue("lastremote", text);
|
Chris@0
|
1297
|
Chris@0
|
1298 if (text.isEmpty()) return;
|
Chris@0
|
1299
|
Chris@1
|
1300 FileOpenStatus status = open(text, ReplaceSession);
|
Chris@0
|
1301
|
Chris@0
|
1302 if (status == FileOpenFailed) {
|
Chris@0
|
1303 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1304 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@0
|
1305 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1306 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1307 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1308 }
|
Chris@0
|
1309 }
|
Chris@0
|
1310
|
Chris@0
|
1311 void
|
Chris@0
|
1312 MainWindow::openRecentFile()
|
Chris@0
|
1313 {
|
Chris@0
|
1314 QObject *obj = sender();
|
Chris@3
|
1315 QAction *action = qobject_cast<QAction *>(obj);
|
Chris@0
|
1316
|
Chris@0
|
1317 if (!action) {
|
Chris@188
|
1318 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@188
|
1319 << endl;
|
Chris@188
|
1320 return;
|
Chris@0
|
1321 }
|
Chris@0
|
1322
|
Chris@0
|
1323 QString path = action->text();
|
Chris@0
|
1324 if (path == "") return;
|
Chris@0
|
1325
|
Chris@1
|
1326 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1327
|
Chris@0
|
1328 if (status == FileOpenFailed) {
|
Chris@0
|
1329 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1330 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@0
|
1331 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1332 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1333 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1334 }
|
Chris@0
|
1335 }
|
Chris@0
|
1336
|
Chris@0
|
1337 void
|
Chris@0
|
1338 MainWindow::paneAdded(Pane *pane)
|
Chris@0
|
1339 {
|
Chris@6
|
1340 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
1341 m_paneStack->sizePanesEqually();
|
Chris@0
|
1342 if (m_overview) m_overview->registerView(pane);
|
Chris@0
|
1343 }
|
Chris@0
|
1344
|
Chris@0
|
1345 void
|
Chris@0
|
1346 MainWindow::paneHidden(Pane *pane)
|
Chris@0
|
1347 {
|
Chris@0
|
1348 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1349 }
|
Chris@0
|
1350
|
Chris@0
|
1351 void
|
Chris@0
|
1352 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@0
|
1353 {
|
Chris@0
|
1354 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1355 }
|
Chris@0
|
1356
|
Chris@0
|
1357 void
|
Chris@0
|
1358 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@0
|
1359 {
|
Chris@4
|
1360 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1361
|
Chris@0
|
1362 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@0
|
1363
|
Chris@1
|
1364 FileOpenStatus status = open(*i, ReplaceSession);
|
Chris@0
|
1365
|
Chris@0
|
1366 if (status == FileOpenFailed) {
|
Chris@0
|
1367 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1368 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@0
|
1369 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1370 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1371 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1372 }
|
Chris@0
|
1373 }
|
Chris@0
|
1374 }
|
Chris@0
|
1375
|
Chris@0
|
1376 void
|
Chris@0
|
1377 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@0
|
1378 {
|
Chris@0
|
1379 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1380
|
Chris@0
|
1381 QUrl testUrl(text);
|
Chris@0
|
1382 if (testUrl.scheme() == "file" ||
|
Chris@0
|
1383 testUrl.scheme() == "http" ||
|
Chris@0
|
1384 testUrl.scheme() == "ftp") {
|
Chris@0
|
1385 QStringList list;
|
Chris@0
|
1386 list.push_back(text);
|
Chris@0
|
1387 paneDropAccepted(pane, list);
|
Chris@0
|
1388 return;
|
Chris@0
|
1389 }
|
Chris@0
|
1390
|
Chris@0
|
1391 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@0
|
1392 //to a text layer?
|
Chris@0
|
1393 }
|
Chris@0
|
1394
|
Chris@0
|
1395 void
|
Chris@0
|
1396 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
1397 {
|
Chris@70
|
1398 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@0
|
1399
|
Chris@0
|
1400 if (m_openingAudioFile) {
|
Chris@70
|
1401 // cerr << "Busy - ignoring close event" << endl;
|
gyorgyf@27
|
1402 e->ignore();
|
gyorgyf@27
|
1403 return;
|
Chris@0
|
1404 }
|
Chris@0
|
1405
|
Chris@0
|
1406 if (!m_abandoning && !checkSaveModified()) {
|
Chris@70
|
1407 // cerr << "Ignoring close event" << endl;
|
gyorgyf@27
|
1408 e->ignore();
|
gyorgyf@27
|
1409 return;
|
Chris@0
|
1410 }
|
Chris@0
|
1411
|
Chris@0
|
1412 QSettings settings;
|
Chris@0
|
1413 settings.beginGroup("MainWindow");
|
Chris@0
|
1414 settings.setValue("size", size());
|
Chris@0
|
1415 settings.setValue("position", pos());
|
Chris@0
|
1416 settings.endGroup();
|
Chris@0
|
1417
|
Chris@0
|
1418 delete m_keyReference;
|
Chris@0
|
1419 m_keyReference = 0;
|
Chris@0
|
1420
|
Chris@0
|
1421 closeSession();
|
Chris@0
|
1422
|
Chris@0
|
1423 e->accept();
|
Chris@0
|
1424 return;
|
Chris@0
|
1425 }
|
Chris@0
|
1426
|
Chris@0
|
1427 bool
|
Chris@0
|
1428 MainWindow::commitData(bool mayAskUser)
|
Chris@0
|
1429 {
|
Chris@0
|
1430 if (mayAskUser) {
|
Chris@0
|
1431 bool rv = checkSaveModified();
|
Chris@0
|
1432 return rv;
|
Chris@0
|
1433 } else {
|
Chris@0
|
1434 if (!m_documentModified) return true;
|
Chris@0
|
1435
|
Chris@0
|
1436 // If we can't check with the user first, then we can't save
|
Chris@0
|
1437 // to the original session file (even if we have it) -- have
|
Chris@0
|
1438 // to use a temporary file
|
Chris@0
|
1439
|
Chris@0
|
1440 QString svDirBase = ".sv1";
|
Chris@0
|
1441 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@0
|
1442
|
Chris@0
|
1443 if (!QFileInfo(svDir).exists()) {
|
Chris@0
|
1444 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@0
|
1445 } else {
|
Chris@0
|
1446 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@0
|
1447 }
|
Chris@0
|
1448
|
Chris@0
|
1449 // This name doesn't have to be unguessable
|
Chris@0
|
1450 #ifndef _WIN32
|
Chris@0
|
1451 QString fname = QString("tmp-%1-%2.sv")
|
Chris@0
|
1452 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@0
|
1453 .arg(QProcess().pid());
|
Chris@0
|
1454 #else
|
Chris@0
|
1455 QString fname = QString("tmp-%1.sv")
|
Chris@0
|
1456 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@0
|
1457 #endif
|
Chris@0
|
1458 QString fpath = QDir(svDir).filePath(fname);
|
Chris@0
|
1459 if (saveSessionFile(fpath)) {
|
Chris@0
|
1460 m_recentFiles.addFile(fpath);
|
Chris@0
|
1461 return true;
|
Chris@0
|
1462 } else {
|
Chris@0
|
1463 return false;
|
Chris@0
|
1464 }
|
Chris@0
|
1465 }
|
Chris@0
|
1466 }
|
Chris@0
|
1467
|
Chris@0
|
1468 bool
|
Chris@0
|
1469 MainWindow::checkSaveModified()
|
Chris@0
|
1470 {
|
Chris@0
|
1471 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
1472 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
1473 // cancel.
|
Chris@0
|
1474
|
Chris@0
|
1475 if (!m_documentModified) return true;
|
Chris@0
|
1476
|
Chris@0
|
1477 int button =
|
gyorgyf@27
|
1478 QMessageBox::warning(this,
|
gyorgyf@27
|
1479 tr("Session modified"),
|
gyorgyf@27
|
1480 tr("The current session has been modified.\nDo you want to save it?"),
|
gyorgyf@27
|
1481 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@0
|
1482 QMessageBox::Yes);
|
Chris@0
|
1483
|
Chris@0
|
1484 if (button == QMessageBox::Yes) {
|
gyorgyf@27
|
1485 saveSession();
|
gyorgyf@27
|
1486 if (m_documentModified) { // save failed -- don't proceed!
|
gyorgyf@27
|
1487 return false;
|
gyorgyf@27
|
1488 } else {
|
Chris@0
|
1489 return true; // saved, so it's safe to continue now
|
Chris@0
|
1490 }
|
Chris@0
|
1491 } else if (button == QMessageBox::No) {
|
gyorgyf@27
|
1492 m_documentModified = false; // so we know to abandon it
|
gyorgyf@27
|
1493 return true;
|
Chris@0
|
1494 }
|
Chris@0
|
1495
|
Chris@0
|
1496 // else cancel
|
Chris@0
|
1497 return false;
|
Chris@0
|
1498 }
|
Chris@0
|
1499
|
Chris@0
|
1500 void
|
Chris@0
|
1501 MainWindow::saveSession()
|
Chris@0
|
1502 {
|
Chris@0
|
1503 if (m_sessionFile != "") {
|
gyorgyf@27
|
1504 if (!saveSessionFile(m_sessionFile)) {
|
gyorgyf@27
|
1505 QMessageBox::critical(this, tr("Failed to save file"),
|
gyorgyf@27
|
1506 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
1507 } else {
|
gyorgyf@27
|
1508 CommandHistory::getInstance()->documentSaved();
|
gyorgyf@27
|
1509 documentRestored();
|
gyorgyf@27
|
1510 }
|
gyorgyf@27
|
1511 } else {
|
gyorgyf@27
|
1512 saveSessionAs();
|
Chris@0
|
1513 }
|
Chris@0
|
1514 }
|
Chris@0
|
1515
|
Chris@0
|
1516 void
|
Chris@0
|
1517 MainWindow::saveSessionAs()
|
Chris@0
|
1518 {
|
Chris@0
|
1519 QString orig = m_audioFile;
|
Chris@0
|
1520 if (orig == "") orig = ".";
|
Chris@0
|
1521 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1522
|
Chris@0
|
1523 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@0
|
1524
|
Chris@0
|
1525 if (path == "") return;
|
Chris@0
|
1526
|
Chris@0
|
1527 if (!saveSessionFile(path)) {
|
Chris@85
|
1528 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@85
|
1529 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
1530 } else {
|
Chris@85
|
1531 setWindowTitle(tr("%1: %2")
|
Chris@0
|
1532 .arg(QApplication::applicationName())
|
Chris@85
|
1533 .arg(QFileInfo(path).fileName()));
|
Chris@85
|
1534 m_sessionFile = path;
|
Chris@85
|
1535 CommandHistory::getInstance()->documentSaved();
|
Chris@85
|
1536 documentRestored();
|
Chris@0
|
1537 m_recentFiles.addFile(path);
|
Chris@0
|
1538 }
|
Chris@0
|
1539 }
|
Chris@0
|
1540
|
Chris@85
|
1541 QString
|
Chris@85
|
1542 MainWindow::exportToSVL(QString path, Layer *layer)
|
Chris@85
|
1543 {
|
Chris@85
|
1544 Model *model = layer->getModel();
|
Chris@85
|
1545
|
Chris@85
|
1546 QFile file(path);
|
Chris@85
|
1547 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@85
|
1548 return tr("Failed to open file %1 for writing").arg(path);
|
Chris@85
|
1549 } else {
|
Chris@85
|
1550 QTextStream out(&file);
|
Chris@85
|
1551 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@85
|
1552 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@85
|
1553 << "<sv>\n"
|
Chris@85
|
1554 << " <data>\n";
|
Chris@85
|
1555
|
Chris@85
|
1556 model->toXml(out, " ");
|
Chris@85
|
1557
|
Chris@85
|
1558 out << " </data>\n"
|
Chris@85
|
1559 << " <display>\n";
|
Chris@85
|
1560
|
Chris@85
|
1561 layer->toXml(out, " ");
|
Chris@85
|
1562
|
Chris@85
|
1563 out << " </display>\n"
|
Chris@85
|
1564 << "</sv>\n";
|
Chris@85
|
1565
|
Chris@85
|
1566 return "";
|
Chris@85
|
1567 }
|
Chris@85
|
1568 }
|
Chris@85
|
1569
|
Chris@0
|
1570 void
|
Chris@174
|
1571 MainWindow::importPitchLayer()
|
Chris@174
|
1572 {
|
Chris@174
|
1573 QString path = getOpenFileName(FileFinder::LayerFileNoMidiNonSV);
|
Chris@174
|
1574 if (path == "") return;
|
Chris@174
|
1575
|
Chris@174
|
1576 FileOpenStatus status = importPitchLayer(path);
|
Chris@174
|
1577
|
Chris@174
|
1578 if (status == FileOpenFailed) {
|
Chris@174
|
1579 emit hideSplash();
|
Chris@174
|
1580 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1581 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@174
|
1582 return;
|
Chris@174
|
1583 } else if (status == FileOpenWrongMode) {
|
Chris@174
|
1584 emit hideSplash();
|
Chris@174
|
1585 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1586 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
|
Chris@174
|
1587 }
|
Chris@174
|
1588 }
|
Chris@174
|
1589
|
Chris@174
|
1590 MainWindow::FileOpenStatus
|
Chris@174
|
1591 MainWindow::importPitchLayer(FileSource source)
|
Chris@174
|
1592 {
|
Chris@174
|
1593 if (!source.isAvailable()) return FileOpenFailed;
|
Chris@174
|
1594 source.waitForData();
|
Chris@174
|
1595
|
Chris@174
|
1596 QString path = source.getLocalFilename();
|
Chris@174
|
1597
|
Chris@174
|
1598 RDFImporter::RDFDocumentType rdfType =
|
Chris@174
|
1599 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString());
|
Chris@174
|
1600
|
Chris@174
|
1601 if (rdfType != RDFImporter::NotRDF) {
|
Chris@174
|
1602
|
Chris@174
|
1603 //!!!
|
Chris@174
|
1604 return FileOpenFailed;
|
Chris@174
|
1605
|
Chris@174
|
1606 } else if (source.getExtension().toLower() == "svl" ||
|
Chris@174
|
1607 (source.getExtension().toLower() == "xml" &&
|
Chris@174
|
1608 (SVFileReader::identifyXmlFile(source.getLocalFilename())
|
Chris@174
|
1609 == SVFileReader::SVLayerFile))) {
|
Chris@174
|
1610
|
Chris@174
|
1611 //!!!
|
Chris@174
|
1612 return FileOpenFailed;
|
Chris@174
|
1613
|
Chris@174
|
1614 } else {
|
Chris@174
|
1615
|
Chris@174
|
1616 try {
|
Chris@174
|
1617
|
Chris@174
|
1618 CSVFormat format(path);
|
Chris@174
|
1619 format.setSampleRate(getMainModel()->getSampleRate());
|
Chris@174
|
1620
|
Chris@174
|
1621 if (format.getModelType() != CSVFormat::TwoDimensionalModel) {
|
Chris@174
|
1622 //!!! error report
|
Chris@174
|
1623 return FileOpenFailed;
|
Chris@174
|
1624 }
|
Chris@174
|
1625
|
Chris@174
|
1626 Model *model = DataFileReaderFactory::loadCSV
|
Chris@174
|
1627 (path, format, getMainModel()->getSampleRate());
|
Chris@174
|
1628
|
Chris@174
|
1629 if (model) {
|
Chris@174
|
1630
|
Chris@174
|
1631 SVDEBUG << "MainWindow::importPitchLayer: Have model" << endl;
|
Chris@174
|
1632
|
Chris@174
|
1633 CommandHistory::getInstance()->startCompoundOperation
|
Chris@174
|
1634 (tr("Import Pitch Track"), true);
|
Chris@174
|
1635
|
Chris@174
|
1636 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@174
|
1637
|
Chris@174
|
1638 m_analyser->takePitchTrackFrom(newLayer);
|
Chris@174
|
1639
|
Chris@174
|
1640 m_document->deleteLayer(newLayer);
|
Chris@174
|
1641
|
Chris@174
|
1642 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@174
|
1643
|
Chris@174
|
1644 //!!! swap all data in to existing layer instead of this
|
Chris@174
|
1645
|
Chris@174
|
1646 if (!source.isRemote()) {
|
Chris@174
|
1647 registerLastOpenedFilePath
|
Chris@174
|
1648 (FileFinder::LayerFile,
|
Chris@174
|
1649 path); // for file dialog
|
Chris@174
|
1650 }
|
Chris@174
|
1651
|
Chris@174
|
1652 return FileOpenSucceeded;
|
Chris@174
|
1653 }
|
Chris@174
|
1654 } catch (DataFileReaderFactory::Exception e) {
|
Chris@174
|
1655 if (e == DataFileReaderFactory::ImportCancelled) {
|
Chris@174
|
1656 return FileOpenCancelled;
|
Chris@174
|
1657 }
|
Chris@174
|
1658 }
|
Chris@174
|
1659 }
|
Chris@174
|
1660
|
Chris@174
|
1661 return FileOpenFailed;
|
Chris@174
|
1662 }
|
Chris@174
|
1663
|
Chris@174
|
1664 void
|
Chris@85
|
1665 MainWindow::exportPitchLayer()
|
matthiasm@26
|
1666 {
|
Chris@174
|
1667 Layer *layer = m_analyser->getLayer(Analyser::PitchTrack);
|
matthiasm@26
|
1668 if (!layer) return;
|
matthiasm@26
|
1669
|
Chris@85
|
1670 SparseTimeValueModel *model =
|
Chris@85
|
1671 qobject_cast<SparseTimeValueModel *>(layer->getModel());
|
matthiasm@26
|
1672 if (!model) return;
|
matthiasm@26
|
1673
|
Chris@96
|
1674 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
|
matthiasm@26
|
1675
|
matthiasm@26
|
1676 QString path = getSaveFileName(type);
|
matthiasm@26
|
1677
|
matthiasm@26
|
1678 if (path == "") return;
|
matthiasm@26
|
1679
|
matthiasm@26
|
1680 if (QFileInfo(path).suffix() == "") path += ".svl";
|
matthiasm@26
|
1681
|
matthiasm@26
|
1682 QString suffix = QFileInfo(path).suffix().toLower();
|
matthiasm@26
|
1683
|
matthiasm@26
|
1684 QString error;
|
matthiasm@26
|
1685
|
matthiasm@26
|
1686 if (suffix == "xml" || suffix == "svl") {
|
matthiasm@26
|
1687
|
Chris@85
|
1688 error = exportToSVL(path, layer);
|
matthiasm@26
|
1689
|
matthiasm@26
|
1690 } else if (suffix == "ttl" || suffix == "n3") {
|
matthiasm@26
|
1691
|
Chris@85
|
1692 RDFExporter exporter(path, model);
|
Chris@85
|
1693 exporter.write();
|
Chris@85
|
1694 if (!exporter.isOK()) {
|
Chris@85
|
1695 error = exporter.getError();
|
Chris@85
|
1696 }
|
Chris@85
|
1697
|
Chris@85
|
1698 } else {
|
Chris@85
|
1699
|
Chris@85
|
1700 CSVFileWriter writer(path, model,
|
Chris@85
|
1701 ((suffix == "csv") ? "," : "\t"));
|
Chris@85
|
1702 writer.write();
|
Chris@85
|
1703
|
Chris@85
|
1704 if (!writer.isOK()) {
|
Chris@85
|
1705 error = writer.getError();
|
Chris@85
|
1706 }
|
Chris@85
|
1707 }
|
Chris@85
|
1708
|
Chris@85
|
1709 if (error != "") {
|
Chris@85
|
1710 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@85
|
1711 } else {
|
Chris@85
|
1712 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@85
|
1713 }
|
Chris@85
|
1714 }
|
Chris@85
|
1715
|
Chris@85
|
1716 void
|
Chris@85
|
1717 MainWindow::exportNoteLayer()
|
Chris@85
|
1718 {
|
Chris@174
|
1719 Layer *layer = m_analyser->getLayer(Analyser::Notes);
|
Chris@85
|
1720 if (!layer) return;
|
Chris@85
|
1721
|
Chris@85
|
1722 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
Chris@85
|
1723 if (!model) return;
|
Chris@85
|
1724
|
Chris@96
|
1725 FileFinder::FileType type = FileFinder::LayerFileNonSV;
|
Chris@85
|
1726
|
Chris@85
|
1727 QString path = getSaveFileName(type);
|
Chris@85
|
1728
|
Chris@85
|
1729 if (path == "") return;
|
Chris@85
|
1730
|
Chris@85
|
1731 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@85
|
1732
|
Chris@85
|
1733 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@85
|
1734
|
Chris@85
|
1735 QString error;
|
Chris@85
|
1736
|
Chris@85
|
1737 if (suffix == "xml" || suffix == "svl") {
|
Chris@85
|
1738
|
Chris@85
|
1739 error = exportToSVL(path, layer);
|
Chris@85
|
1740
|
Chris@85
|
1741 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@85
|
1742
|
Chris@85
|
1743 MIDIFileWriter writer(path, model, model->getSampleRate());
|
Chris@85
|
1744 writer.write();
|
Chris@85
|
1745 if (!writer.isOK()) {
|
Chris@85
|
1746 error = writer.getError();
|
Chris@85
|
1747 }
|
Chris@85
|
1748
|
Chris@85
|
1749 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@85
|
1750
|
Chris@85
|
1751 RDFExporter exporter(path, model);
|
Chris@85
|
1752 exporter.write();
|
Chris@85
|
1753 if (!exporter.isOK()) {
|
Chris@85
|
1754 error = exporter.getError();
|
matthiasm@26
|
1755 }
|
matthiasm@26
|
1756
|
matthiasm@26
|
1757 } else {
|
matthiasm@26
|
1758
|
matthiasm@26
|
1759 CSVFileWriter writer(path, model,
|
matthiasm@26
|
1760 ((suffix == "csv") ? "," : "\t"));
|
matthiasm@26
|
1761 writer.write();
|
matthiasm@26
|
1762
|
matthiasm@26
|
1763 if (!writer.isOK()) {
|
matthiasm@26
|
1764 error = writer.getError();
|
matthiasm@26
|
1765 }
|
matthiasm@26
|
1766 }
|
matthiasm@26
|
1767
|
matthiasm@26
|
1768 if (error != "") {
|
matthiasm@26
|
1769 QMessageBox::critical(this, tr("Failed to write file"), error);
|
matthiasm@26
|
1770 } else {
|
matthiasm@26
|
1771 emit activity(tr("Export layer to \"%1\"").arg(path));
|
matthiasm@26
|
1772 }
|
matthiasm@26
|
1773 }
|
matthiasm@26
|
1774
|
Chris@139
|
1775 void
|
Chris@139
|
1776 MainWindow::doubleClickSelectInvoked(size_t frame)
|
Chris@139
|
1777 {
|
Chris@139
|
1778 size_t f0, f1;
|
Chris@139
|
1779 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
|
Chris@139
|
1780
|
Chris@139
|
1781 cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl;
|
Chris@139
|
1782
|
Chris@164
|
1783 Selection sel(f0, f1);
|
Chris@164
|
1784 m_viewManager->setSelection(sel);
|
Chris@164
|
1785 }
|
Chris@164
|
1786
|
Chris@164
|
1787 void
|
Chris@194
|
1788 MainWindow::abandonSelection()
|
Chris@167
|
1789 {
|
Chris@194
|
1790 // Named abandonSelection rather than clearSelection to indicate
|
Chris@194
|
1791 // that this is an active operation -- it restores the original
|
Chris@194
|
1792 // content of the pitch track in the selected region rather than
|
Chris@194
|
1793 // simply un-selecting.
|
Chris@194
|
1794
|
Chris@194
|
1795 cerr << "MainWindow::abandonSelection()" << endl;
|
Chris@167
|
1796
|
Chris@199
|
1797 CommandHistory::getInstance()->startCompoundOperation(tr("Abandon Selection"), true);
|
Chris@168
|
1798
|
Chris@194
|
1799 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@194
|
1800 if (!selections.empty()) {
|
Chris@194
|
1801 Selection sel = *selections.begin();
|
Chris@199
|
1802 m_analyser->abandonReAnalysis(sel);
|
Chris@194
|
1803 }
|
Chris@194
|
1804
|
Chris@167
|
1805 MainWindowBase::clearSelection();
|
Chris@168
|
1806
|
Chris@168
|
1807 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
1808 }
|
Chris@167
|
1809
|
Chris@167
|
1810 void
|
Chris@192
|
1811 MainWindow::selectionChangedByUser()
|
Chris@164
|
1812 {
|
Chris@164
|
1813 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@164
|
1814
|
Chris@192
|
1815 cerr << "MainWindow::selectionChangedByUser" << endl;
|
Chris@192
|
1816
|
Chris@192
|
1817 m_analyser->showPitchCandidates(m_pendingConstraint.isConstrained());
|
Chris@190
|
1818
|
Chris@164
|
1819 if (!selections.empty()) {
|
Chris@164
|
1820 Selection sel = *selections.begin();
|
Chris@192
|
1821 cerr << "MainWindow::selectionChangedByUser: have selection" << endl;
|
Chris@192
|
1822 QString error = m_analyser->reAnalyseSelection
|
Chris@192
|
1823 (sel, m_pendingConstraint);
|
Chris@164
|
1824 if (error != "") {
|
Chris@164
|
1825 QMessageBox::critical
|
Chris@164
|
1826 (this, tr("Failed to analyse selection"),
|
Chris@164
|
1827 tr("<b>Analysis failed</b><p>%2</p>").arg(error));
|
Chris@164
|
1828 }
|
Chris@164
|
1829 }
|
Chris@192
|
1830
|
Chris@192
|
1831 m_pendingConstraint = Analyser::FrequencyRange();
|
Chris@192
|
1832 }
|
Chris@192
|
1833
|
Chris@192
|
1834 void
|
Chris@192
|
1835 MainWindow::regionOutlined(QRect r)
|
Chris@192
|
1836 {
|
Chris@192
|
1837 cerr << "MainWindow::regionOutlined(" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ")" << endl;
|
Chris@192
|
1838
|
Chris@192
|
1839 Pane *pane = qobject_cast<Pane *>(sender());
|
Chris@192
|
1840 if (!pane) {
|
Chris@192
|
1841 cerr << "MainWindow::regionOutlined: not sent by pane, ignoring" << endl;
|
Chris@192
|
1842 return;
|
Chris@192
|
1843 }
|
Chris@192
|
1844
|
Chris@192
|
1845 if (!m_analyser) {
|
Chris@192
|
1846 cerr << "MainWindow::regionOutlined: no analyser, ignoring" << endl;
|
Chris@192
|
1847 return;
|
Chris@192
|
1848 }
|
Chris@192
|
1849
|
Chris@192
|
1850 SpectrogramLayer *spectrogram = qobject_cast<SpectrogramLayer *>
|
Chris@192
|
1851 (m_analyser->getLayer(Analyser::Spectrogram));
|
Chris@192
|
1852 if (!spectrogram) {
|
Chris@192
|
1853 cerr << "MainWindow::regionOutlined: no spectrogram layer, ignoring" << endl;
|
Chris@192
|
1854 return;
|
Chris@192
|
1855 }
|
Chris@192
|
1856
|
Chris@192
|
1857 int f0 = pane->getFrameForX(r.x());
|
Chris@192
|
1858 int f1 = pane->getFrameForX(r.x() + r.width());
|
Chris@192
|
1859
|
Chris@192
|
1860 float v0 = spectrogram->getFrequencyForY(pane, r.y() + r.height());
|
Chris@192
|
1861 float v1 = spectrogram->getFrequencyForY(pane, r.y());
|
Chris@192
|
1862
|
Chris@192
|
1863 cerr << "MainWindow::regionOutlined: frame " << f0 << " -> " << f1
|
Chris@192
|
1864 << ", frequency " << v0 << " -> " << v1 << endl;
|
Chris@192
|
1865
|
Chris@192
|
1866 m_pendingConstraint = Analyser::FrequencyRange(v0, v1);
|
Chris@192
|
1867
|
Chris@192
|
1868 Selection sel(f0, f1);
|
Chris@192
|
1869 m_viewManager->setSelection(sel);
|
Chris@0
|
1870 }
|
Chris@0
|
1871
|
Chris@0
|
1872 void
|
Chris@168
|
1873 MainWindow::clearPitches()
|
Chris@168
|
1874 {
|
Chris@168
|
1875 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@168
|
1876
|
Chris@168
|
1877 CommandHistory::getInstance()->startCompoundOperation(tr("Clear Pitches"), true);
|
Chris@168
|
1878
|
Chris@168
|
1879 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
1880 k != selections.end(); ++k) {
|
Chris@184
|
1881 m_analyser->deletePitches(*k);
|
Chris@168
|
1882 }
|
Chris@168
|
1883
|
Chris@168
|
1884 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@168
|
1885 }
|
Chris@168
|
1886
|
Chris@168
|
1887 void
|
Chris@142
|
1888 MainWindow::octaveShiftUp()
|
Chris@142
|
1889 {
|
Chris@142
|
1890 octaveShift(true);
|
Chris@142
|
1891 }
|
Chris@142
|
1892
|
Chris@142
|
1893 void
|
Chris@142
|
1894 MainWindow::octaveShiftDown()
|
Chris@142
|
1895 {
|
Chris@142
|
1896 octaveShift(false);
|
Chris@142
|
1897 }
|
Chris@142
|
1898
|
Chris@142
|
1899 void
|
Chris@142
|
1900 MainWindow::octaveShift(bool up)
|
Chris@142
|
1901 {
|
Chris@142
|
1902 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@142
|
1903
|
Chris@142
|
1904 CommandHistory::getInstance()->startCompoundOperation(tr("Octave Shift"), true);
|
Chris@142
|
1905
|
Chris@168
|
1906 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
1907 k != selections.end(); ++k) {
|
Chris@142
|
1908
|
Chris@168
|
1909 m_analyser->shiftOctave(*k, up);
|
Chris@142
|
1910 }
|
Chris@142
|
1911
|
Chris@142
|
1912 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@142
|
1913 }
|
Chris@142
|
1914
|
Chris@142
|
1915 void
|
Chris@184
|
1916 MainWindow::togglePitchCandidates()
|
Chris@184
|
1917 {
|
Chris@199
|
1918 CommandHistory::getInstance()->startCompoundOperation(tr("Toggle Pitch Candidates"), true);
|
Chris@199
|
1919
|
Chris@184
|
1920 m_analyser->showPitchCandidates(!m_analyser->arePitchCandidatesShown());
|
Chris@199
|
1921
|
Chris@199
|
1922 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@199
|
1923
|
Chris@187
|
1924 updateMenuStates();
|
Chris@184
|
1925 }
|
Chris@184
|
1926
|
Chris@184
|
1927 void
|
Chris@184
|
1928 MainWindow::switchPitchUp()
|
Chris@167
|
1929 {
|
Chris@168
|
1930 CommandHistory::getInstance()->startCompoundOperation
|
Chris@168
|
1931 (tr("Switch Pitch Candidate"), true);
|
Chris@168
|
1932
|
Chris@167
|
1933 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@167
|
1934
|
Chris@167
|
1935 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@167
|
1936 k != selections.end(); ++k) {
|
Chris@167
|
1937 m_analyser->switchPitchCandidate(*k, true);
|
Chris@167
|
1938 }
|
Chris@167
|
1939
|
Chris@168
|
1940 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
1941 }
|
Chris@167
|
1942
|
Chris@167
|
1943 void
|
Chris@184
|
1944 MainWindow::switchPitchDown()
|
Chris@184
|
1945 {
|
Chris@184
|
1946 CommandHistory::getInstance()->startCompoundOperation
|
Chris@184
|
1947 (tr("Switch Pitch Candidate"), true);
|
Chris@184
|
1948
|
Chris@184
|
1949 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@184
|
1950
|
Chris@184
|
1951 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@184
|
1952 k != selections.end(); ++k) {
|
Chris@184
|
1953 m_analyser->switchPitchCandidate(*k, false);
|
Chris@184
|
1954 }
|
Chris@184
|
1955
|
Chris@184
|
1956 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@184
|
1957 }
|
Chris@184
|
1958
|
Chris@184
|
1959 void
|
Chris@0
|
1960 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
1961 {
|
Chris@0
|
1962 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@0
|
1963
|
Chris@0
|
1964 float percent = m_playSpeed->mappedValue();
|
Chris@0
|
1965 float factor = mapper.getFactorForValue(percent);
|
Chris@0
|
1966
|
Chris@70
|
1967 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
|
Chris@0
|
1968
|
Chris@0
|
1969 bool something = (position != 100);
|
Chris@0
|
1970
|
Chris@0
|
1971 int pc = lrintf(percent);
|
Chris@0
|
1972
|
Chris@0
|
1973 if (!something) {
|
Chris@0
|
1974 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@0
|
1975 } else {
|
Chris@0
|
1976 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@0
|
1977 .arg(position > 100 ? "+" : "")
|
Chris@0
|
1978 .arg(pc));
|
Chris@0
|
1979 }
|
Chris@0
|
1980
|
Chris@0
|
1981 m_playSource->setTimeStretch(factor);
|
Chris@0
|
1982
|
Chris@0
|
1983 updateMenuStates();
|
Chris@0
|
1984 }
|
Chris@0
|
1985
|
Chris@0
|
1986 void
|
Chris@0
|
1987 MainWindow::playSharpenToggled()
|
Chris@0
|
1988 {
|
Chris@0
|
1989 QSettings settings;
|
Chris@0
|
1990 settings.beginGroup("MainWindow");
|
Chris@0
|
1991 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@0
|
1992 settings.endGroup();
|
Chris@0
|
1993
|
Chris@0
|
1994 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
1995 // TODO: pitch gain?
|
Chris@0
|
1996 }
|
Chris@0
|
1997
|
Chris@0
|
1998 void
|
Chris@0
|
1999 MainWindow::playMonoToggled()
|
Chris@0
|
2000 {
|
Chris@0
|
2001 QSettings settings;
|
Chris@0
|
2002 settings.beginGroup("MainWindow");
|
Chris@0
|
2003 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@0
|
2004 settings.endGroup();
|
Chris@0
|
2005
|
Chris@0
|
2006 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
2007 // TODO: pitch gain?
|
Chris@0
|
2008 }
|
Chris@0
|
2009
|
Chris@0
|
2010 void
|
Chris@0
|
2011 MainWindow::speedUpPlayback()
|
Chris@0
|
2012 {
|
Chris@0
|
2013 int value = m_playSpeed->value();
|
Chris@0
|
2014 value = value + m_playSpeed->pageStep();
|
Chris@0
|
2015 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@0
|
2016 m_playSpeed->setValue(value);
|
Chris@0
|
2017 }
|
Chris@0
|
2018
|
Chris@0
|
2019 void
|
Chris@0
|
2020 MainWindow::slowDownPlayback()
|
Chris@0
|
2021 {
|
Chris@0
|
2022 int value = m_playSpeed->value();
|
Chris@0
|
2023 value = value - m_playSpeed->pageStep();
|
Chris@0
|
2024 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@0
|
2025 m_playSpeed->setValue(value);
|
Chris@0
|
2026 }
|
Chris@0
|
2027
|
Chris@0
|
2028 void
|
Chris@0
|
2029 MainWindow::restoreNormalPlayback()
|
Chris@0
|
2030 {
|
Chris@0
|
2031 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@0
|
2032 }
|
Chris@0
|
2033
|
justin@157
|
2034 void
|
justin@159
|
2035 MainWindow::audioGainChanged(int position)
|
justin@159
|
2036 {
|
justin@159
|
2037 float level = m_gainAudio->mappedValue();
|
justin@159
|
2038 float gain = powf(10, level / 20.0);
|
justin@159
|
2039
|
justin@159
|
2040 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
2041
|
justin@159
|
2042 contextHelpChanged(tr("Audio Gain: %1 dB").arg(position));
|
justin@159
|
2043
|
justin@159
|
2044 m_analyser->setGain(Analyser::Audio, gain);
|
justin@159
|
2045
|
justin@159
|
2046 updateMenuStates();
|
justin@159
|
2047 }
|
justin@159
|
2048
|
justin@159
|
2049 void
|
justin@159
|
2050 MainWindow::increaseAudioGain()
|
justin@159
|
2051 {
|
justin@159
|
2052 int value = m_gainAudio->value();
|
justin@159
|
2053 value = value + m_gainAudio->pageStep();
|
justin@159
|
2054 if (value > m_gainAudio->maximum()) value = m_gainAudio->maximum();
|
justin@159
|
2055 m_gainAudio->setValue(value);
|
justin@159
|
2056 }
|
justin@159
|
2057
|
justin@159
|
2058 void
|
justin@159
|
2059 MainWindow::decreaseAudioGain()
|
justin@159
|
2060 {
|
justin@159
|
2061 int value = m_gainAudio->value();
|
justin@159
|
2062 value = value - m_gainAudio->pageStep();
|
justin@159
|
2063 if (value < m_gainAudio->minimum()) value = m_gainAudio->minimum();
|
justin@159
|
2064 m_gainAudio->setValue(value);
|
justin@159
|
2065 }
|
justin@159
|
2066
|
justin@159
|
2067 void
|
justin@159
|
2068 MainWindow::restoreNormalAudioGain()
|
justin@159
|
2069 {
|
justin@159
|
2070 m_gainAudio->setValue(m_gainAudio->defaultValue());
|
justin@159
|
2071 }
|
justin@159
|
2072
|
justin@159
|
2073 void
|
justin@157
|
2074 MainWindow::pitchGainChanged(int position)
|
justin@157
|
2075 {
|
Chris@158
|
2076 float level = m_gainPitch->mappedValue();
|
Chris@158
|
2077 float gain = powf(10, level / 20.0);
|
justin@157
|
2078
|
Chris@158
|
2079 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@157
|
2080
|
Chris@158
|
2081 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position));
|
justin@157
|
2082
|
Chris@158
|
2083 m_analyser->setGain(Analyser::PitchTrack, gain);
|
justin@157
|
2084
|
justin@157
|
2085 updateMenuStates();
|
justin@157
|
2086 }
|
justin@157
|
2087
|
justin@157
|
2088 void
|
justin@157
|
2089 MainWindow::increasePitchGain()
|
justin@157
|
2090 {
|
justin@157
|
2091 int value = m_gainPitch->value();
|
justin@157
|
2092 value = value + m_gainPitch->pageStep();
|
justin@157
|
2093 if (value > m_gainPitch->maximum()) value = m_gainPitch->maximum();
|
justin@157
|
2094 m_gainPitch->setValue(value);
|
justin@157
|
2095 }
|
justin@157
|
2096
|
justin@157
|
2097 void
|
justin@157
|
2098 MainWindow::decreasePitchGain()
|
justin@157
|
2099 {
|
justin@157
|
2100 int value = m_gainPitch->value();
|
justin@157
|
2101 value = value - m_gainPitch->pageStep();
|
justin@157
|
2102 if (value < m_gainPitch->minimum()) value = m_gainPitch->minimum();
|
justin@157
|
2103 m_gainPitch->setValue(value);
|
justin@157
|
2104 }
|
justin@157
|
2105
|
justin@157
|
2106 void
|
justin@157
|
2107 MainWindow::restoreNormalPitchGain()
|
justin@157
|
2108 {
|
justin@157
|
2109 m_gainPitch->setValue(m_gainPitch->defaultValue());
|
justin@157
|
2110 }
|
justin@157
|
2111
|
Chris@0
|
2112 void
|
justin@159
|
2113 MainWindow::notesGainChanged(int position)
|
justin@159
|
2114 {
|
justin@159
|
2115 float level = m_gainNotes->mappedValue();
|
justin@159
|
2116 float gain = powf(10, level / 20.0);
|
justin@159
|
2117
|
justin@159
|
2118 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
2119
|
justin@159
|
2120 contextHelpChanged(tr("Notes Gain: %1 dB").arg(position));
|
justin@159
|
2121
|
justin@159
|
2122 m_analyser->setGain(Analyser::Notes, gain);
|
justin@159
|
2123
|
justin@159
|
2124 updateMenuStates();
|
justin@159
|
2125 }
|
justin@159
|
2126
|
justin@159
|
2127 void
|
justin@159
|
2128 MainWindow::increaseNotesGain()
|
justin@159
|
2129 {
|
justin@159
|
2130 int value = m_gainNotes->value();
|
justin@159
|
2131 value = value + m_gainNotes->pageStep();
|
justin@159
|
2132 if (value > m_gainNotes->maximum()) value = m_gainNotes->maximum();
|
justin@159
|
2133 m_gainNotes->setValue(value);
|
justin@159
|
2134 }
|
justin@159
|
2135
|
justin@159
|
2136 void
|
justin@159
|
2137 MainWindow::decreaseNotesGain()
|
justin@159
|
2138 {
|
justin@159
|
2139 int value = m_gainNotes->value();
|
justin@159
|
2140 value = value - m_gainNotes->pageStep();
|
justin@159
|
2141 if (value < m_gainNotes->minimum()) value = m_gainNotes->minimum();
|
justin@159
|
2142 m_gainNotes->setValue(value);
|
justin@159
|
2143 }
|
justin@159
|
2144
|
justin@159
|
2145 void
|
justin@159
|
2146 MainWindow::restoreNormalNotesGain()
|
justin@159
|
2147 {
|
justin@159
|
2148 m_gainNotes->setValue(m_gainNotes->defaultValue());
|
justin@159
|
2149 }
|
justin@159
|
2150
|
justin@159
|
2151 void
|
justin@160
|
2152 MainWindow::audioPanChanged(int position)
|
justin@160
|
2153 {
|
justin@160
|
2154 float level = m_panAudio->mappedValue();
|
justin@160
|
2155 float pan = level/100.f;
|
justin@160
|
2156
|
justin@160
|
2157 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2158
|
justin@160
|
2159 contextHelpChanged(tr("Audio Pan: %1").arg(position));
|
justin@160
|
2160
|
justin@160
|
2161 m_analyser->setPan(Analyser::Audio, pan);
|
justin@160
|
2162
|
justin@160
|
2163 updateMenuStates();
|
justin@160
|
2164 }
|
justin@160
|
2165
|
justin@160
|
2166 void
|
justin@160
|
2167 MainWindow::increaseAudioPan()
|
justin@160
|
2168 {
|
justin@160
|
2169 int value = m_panAudio->value();
|
justin@160
|
2170 value = value + m_panAudio->pageStep();
|
justin@160
|
2171 if (value > m_panAudio->maximum()) value = m_panAudio->maximum();
|
justin@160
|
2172 m_panAudio->setValue(value);
|
justin@160
|
2173 }
|
justin@160
|
2174
|
justin@160
|
2175 void
|
justin@160
|
2176 MainWindow::decreaseAudioPan()
|
justin@160
|
2177 {
|
justin@160
|
2178 int value = m_panAudio->value();
|
justin@160
|
2179 value = value - m_panAudio->pageStep();
|
justin@160
|
2180 if (value < m_panAudio->minimum()) value = m_panAudio->minimum();
|
justin@160
|
2181 m_panAudio->setValue(value);
|
justin@160
|
2182 }
|
justin@160
|
2183
|
justin@160
|
2184 void
|
justin@160
|
2185 MainWindow::restoreNormalAudioPan()
|
justin@160
|
2186 {
|
justin@160
|
2187 m_panAudio->setValue(m_panAudio->defaultValue());
|
justin@160
|
2188 }
|
justin@160
|
2189
|
justin@160
|
2190 void
|
justin@160
|
2191 MainWindow::pitchPanChanged(int position)
|
justin@160
|
2192 {
|
justin@160
|
2193 float level = m_panPitch->mappedValue();
|
justin@160
|
2194 float pan = level/100.f;
|
justin@160
|
2195
|
justin@160
|
2196 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2197
|
justin@160
|
2198 contextHelpChanged(tr("Pitch Pan: %1").arg(position));
|
justin@160
|
2199
|
justin@160
|
2200 m_analyser->setPan(Analyser::PitchTrack, pan);
|
justin@160
|
2201
|
justin@160
|
2202 updateMenuStates();
|
justin@160
|
2203 }
|
justin@160
|
2204
|
justin@160
|
2205 void
|
justin@160
|
2206 MainWindow::increasePitchPan()
|
justin@160
|
2207 {
|
justin@160
|
2208 int value = m_panPitch->value();
|
justin@160
|
2209 value = value + m_panPitch->pageStep();
|
justin@160
|
2210 if (value > m_panPitch->maximum()) value = m_panPitch->maximum();
|
justin@160
|
2211 m_panPitch->setValue(value);
|
justin@160
|
2212 }
|
justin@160
|
2213
|
justin@160
|
2214 void
|
justin@160
|
2215 MainWindow::decreasePitchPan()
|
justin@160
|
2216 {
|
justin@160
|
2217 int value = m_panPitch->value();
|
justin@160
|
2218 value = value - m_panPitch->pageStep();
|
justin@160
|
2219 if (value < m_panPitch->minimum()) value = m_panPitch->minimum();
|
justin@160
|
2220 m_panPitch->setValue(value);
|
justin@160
|
2221 }
|
justin@160
|
2222
|
justin@160
|
2223 void
|
justin@160
|
2224 MainWindow::restoreNormalPitchPan()
|
justin@160
|
2225 {
|
justin@160
|
2226 m_panPitch->setValue(m_panPitch->defaultValue());
|
justin@160
|
2227 }
|
justin@160
|
2228
|
justin@160
|
2229 void
|
justin@160
|
2230 MainWindow::notesPanChanged(int position)
|
justin@160
|
2231 {
|
justin@160
|
2232 float level = m_panNotes->mappedValue();
|
justin@160
|
2233 float pan = level/100.f;
|
justin@160
|
2234
|
justin@160
|
2235 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2236
|
justin@160
|
2237 contextHelpChanged(tr("Notes Pan: %1").arg(position));
|
justin@160
|
2238
|
justin@160
|
2239 m_analyser->setPan(Analyser::Notes, pan);
|
justin@160
|
2240
|
justin@160
|
2241 updateMenuStates();
|
justin@160
|
2242 }
|
justin@160
|
2243
|
justin@160
|
2244 void
|
justin@160
|
2245 MainWindow::increaseNotesPan()
|
justin@160
|
2246 {
|
justin@160
|
2247 int value = m_panNotes->value();
|
justin@160
|
2248 value = value + m_panNotes->pageStep();
|
justin@160
|
2249 if (value > m_panNotes->maximum()) value = m_panNotes->maximum();
|
justin@160
|
2250 m_panNotes->setValue(value);
|
justin@160
|
2251 }
|
justin@160
|
2252
|
justin@160
|
2253 void
|
justin@160
|
2254 MainWindow::decreaseNotesPan()
|
justin@160
|
2255 {
|
justin@160
|
2256 int value = m_panNotes->value();
|
justin@160
|
2257 value = value - m_panNotes->pageStep();
|
justin@160
|
2258 if (value < m_panNotes->minimum()) value = m_panNotes->minimum();
|
justin@160
|
2259 m_panNotes->setValue(value);
|
justin@160
|
2260 }
|
justin@160
|
2261
|
justin@160
|
2262 void
|
justin@160
|
2263 MainWindow::restoreNormalNotesPan()
|
justin@160
|
2264 {
|
justin@160
|
2265 m_panNotes->setValue(m_panNotes->defaultValue());
|
justin@160
|
2266 }
|
justin@160
|
2267
|
justin@160
|
2268 void
|
Chris@0
|
2269 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@0
|
2270 {
|
Chris@0
|
2271 if (!getMainModel() || !p) {
|
Chris@0
|
2272 return;
|
Chris@0
|
2273 }
|
Chris@0
|
2274
|
Chris@0
|
2275 bool haveSelection = false;
|
Chris@0
|
2276 size_t startFrame = 0, endFrame = 0;
|
Chris@0
|
2277
|
Chris@0
|
2278 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@0
|
2279
|
Chris@0
|
2280 bool exclusive = false;
|
Chris@0
|
2281 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@0
|
2282
|
Chris@0
|
2283 if (!s.isEmpty()) {
|
Chris@0
|
2284 haveSelection = true;
|
Chris@0
|
2285 startFrame = s.getStartFrame();
|
Chris@0
|
2286 endFrame = s.getEndFrame();
|
Chris@0
|
2287 }
|
Chris@0
|
2288 }
|
Chris@0
|
2289
|
Chris@0
|
2290 if (!haveSelection) {
|
Chris@0
|
2291 startFrame = p->getFirstVisibleFrame();
|
Chris@0
|
2292 endFrame = p->getLastVisibleFrame();
|
Chris@0
|
2293 }
|
Chris@0
|
2294
|
Chris@0
|
2295 RealTime start = RealTime::frame2RealTime
|
Chris@0
|
2296 (startFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2297
|
Chris@0
|
2298 RealTime end = RealTime::frame2RealTime
|
Chris@0
|
2299 (endFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2300
|
Chris@0
|
2301 RealTime duration = end - start;
|
Chris@0
|
2302
|
Chris@0
|
2303 QString startStr, endStr, durationStr;
|
Chris@0
|
2304 startStr = start.toText(true).c_str();
|
Chris@0
|
2305 endStr = end.toText(true).c_str();
|
Chris@0
|
2306 durationStr = duration.toText(true).c_str();
|
Chris@0
|
2307
|
Chris@0
|
2308 if (haveSelection) {
|
Chris@0
|
2309 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@0
|
2310 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2311 } else {
|
Chris@0
|
2312 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@0
|
2313 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2314 }
|
matthiasm@42
|
2315
|
matthiasm@42
|
2316 // scale Y axis
|
matthiasm@42
|
2317 FlexiNoteLayer *fnl = dynamic_cast<FlexiNoteLayer *>(p->getLayer(2));
|
matthiasm@42
|
2318 if (fnl) {
|
matthiasm@42
|
2319 fnl->setVerticalRangeToNoteRange(p);
|
matthiasm@42
|
2320 }
|
matthiasm@42
|
2321
|
Chris@0
|
2322 statusBar()->showMessage(m_myStatusMessage);
|
Chris@0
|
2323 }
|
Chris@0
|
2324
|
Chris@0
|
2325 void
|
Chris@0
|
2326 MainWindow::updatePositionStatusDisplays() const
|
Chris@0
|
2327 {
|
Chris@0
|
2328 if (!statusBar()->isVisible()) return;
|
Chris@0
|
2329
|
Chris@0
|
2330 }
|
Chris@0
|
2331
|
Chris@0
|
2332 void
|
Chris@0
|
2333 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
2334 {
|
Chris@0
|
2335 m_fader->setPeakLeft(left);
|
Chris@0
|
2336 m_fader->setPeakRight(right);
|
Chris@0
|
2337 }
|
Chris@0
|
2338
|
Chris@0
|
2339 void
|
Chris@0
|
2340 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
2341 bool willResample)
|
Chris@0
|
2342 {
|
Chris@0
|
2343 updateDescriptionLabel();
|
Chris@0
|
2344 }
|
Chris@0
|
2345
|
Chris@0
|
2346 void
|
Chris@0
|
2347 MainWindow::audioOverloadPluginDisabled()
|
Chris@0
|
2348 {
|
Chris@0
|
2349 QMessageBox::information
|
Chris@0
|
2350 (this, tr("Audio processing overload"),
|
Chris@0
|
2351 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@0
|
2352 }
|
Chris@0
|
2353
|
Chris@0
|
2354 void
|
Chris@0
|
2355 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@0
|
2356 {
|
Chris@0
|
2357 static bool shownOnce = false;
|
Chris@0
|
2358 if (shownOnce) return;
|
Chris@0
|
2359 QMessageBox::information
|
Chris@0
|
2360 (this, tr("Audio processing overload"),
|
Chris@0
|
2361 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@0
|
2362 shownOnce = true;
|
Chris@0
|
2363 }
|
Chris@0
|
2364
|
Chris@0
|
2365 void
|
Chris@0
|
2366 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
2367 {
|
Chris@0
|
2368 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
2369 }
|
Chris@0
|
2370
|
Chris@0
|
2371 void
|
Chris@0
|
2372 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
2373 {
|
Chris@0
|
2374 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
2375 }
|
Chris@0
|
2376
|
Chris@0
|
2377 void
|
Chris@0
|
2378 MainWindow::modelAdded(Model *model)
|
Chris@0
|
2379 {
|
Chris@0
|
2380 MainWindowBase::modelAdded(model);
|
Chris@3
|
2381 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
|
Chris@0
|
2382 if (dtvm) {
|
Chris@70
|
2383 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
|
Chris@0
|
2384 }
|
Chris@0
|
2385 }
|
Chris@0
|
2386
|
Chris@0
|
2387 void
|
Chris@0
|
2388 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
2389 {
|
Chris@0
|
2390 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@0
|
2391 }
|
Chris@0
|
2392
|
Chris@0
|
2393 void
|
Chris@0
|
2394 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
2395 {
|
Chris@0
|
2396 m_panLayer->setModel(model);
|
Chris@0
|
2397
|
Chris@0
|
2398 MainWindowBase::mainModelChanged(model);
|
Chris@0
|
2399
|
Chris@0
|
2400 if (m_playTarget) {
|
Chris@0
|
2401 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2402 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2403 }
|
Chris@72
|
2404
|
Chris@72
|
2405 if (model) {
|
Chris@72
|
2406 if (m_paneStack) {
|
Chris@174
|
2407
|
Chris@174
|
2408 int pc = m_paneStack->getPaneCount();
|
Chris@174
|
2409 Pane *pane = 0;
|
Chris@174
|
2410
|
Chris@174
|
2411 if (pc < 1) {
|
Chris@72
|
2412 pane = m_paneStack->addPane();
|
Chris@131
|
2413
|
Chris@131
|
2414 Pane *selectionStrip = m_paneStack->addPane();
|
Chris@131
|
2415 selectionStrip->setFixedHeight(26);
|
Chris@131
|
2416 m_document->addLayerToView
|
Chris@131
|
2417 (selectionStrip,
|
Chris@131
|
2418 m_document->createMainModelLayer(LayerFactory::TimeRuler));
|
Chris@131
|
2419 m_paneStack->sizePanesEqually();
|
Chris@131
|
2420
|
Chris@131
|
2421 m_viewManager->clearToolModeOverrides();
|
Chris@131
|
2422 m_viewManager->setToolModeFor(selectionStrip,
|
Chris@131
|
2423 ViewManager::SelectMode);
|
Chris@174
|
2424 } else {
|
Chris@174
|
2425 pane = m_paneStack->getPane(0);
|
Chris@72
|
2426 }
|
Chris@174
|
2427
|
Chris@72
|
2428 if (pane) {
|
Chris@192
|
2429
|
Chris@192
|
2430 disconnect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@192
|
2431 pane, SLOT(zoomToRegion(QRect)));
|
Chris@192
|
2432 connect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@192
|
2433 this, SLOT(regionOutlined(QRect)));
|
Chris@192
|
2434
|
Chris@140
|
2435 QString error = m_analyser->newFileLoaded
|
Chris@72
|
2436 (m_document, getMainModel(), m_paneStack, pane);
|
Chris@140
|
2437 if (error != "") {
|
Chris@140
|
2438 QMessageBox::warning
|
Chris@140
|
2439 (this,
|
Chris@140
|
2440 tr("Failed to analyse audio"),
|
Chris@140
|
2441 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
|
Chris@140
|
2442 QMessageBox::Ok);
|
Chris@140
|
2443 }
|
Chris@72
|
2444 }
|
Chris@72
|
2445 }
|
Chris@72
|
2446 }
|
Chris@0
|
2447 }
|
Chris@0
|
2448
|
Chris@0
|
2449 void
|
Chris@0
|
2450 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@0
|
2451 {
|
Chris@0
|
2452 if (message != "") {
|
Chris@0
|
2453
|
Chris@0
|
2454 QMessageBox::warning
|
Chris@0
|
2455 (this,
|
Chris@0
|
2456 tr("Failed to generate layer"),
|
Chris@0
|
2457 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@0
|
2458 .arg(transformName).arg(message),
|
Chris@0
|
2459 QMessageBox::Ok);
|
Chris@0
|
2460 } else {
|
Chris@0
|
2461 QMessageBox::warning
|
Chris@0
|
2462 (this,
|
Chris@0
|
2463 tr("Failed to generate layer"),
|
Chris@0
|
2464 tr("<b>Layer generation failed</b><p>Failed to generate a derived layer.<p>The layer transform \"%1\" failed.<p>No error information is available.")
|
Chris@0
|
2465 .arg(transformName),
|
Chris@0
|
2466 QMessageBox::Ok);
|
Chris@0
|
2467 }
|
Chris@0
|
2468 }
|
Chris@0
|
2469
|
Chris@0
|
2470 void
|
Chris@0
|
2471 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@0
|
2472 {
|
Chris@0
|
2473 QMessageBox::warning
|
Chris@0
|
2474 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@0
|
2475 }
|
Chris@0
|
2476
|
Chris@0
|
2477 void
|
Chris@0
|
2478 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@0
|
2479 QString transformName, QString message)
|
Chris@0
|
2480 {
|
Chris@0
|
2481 if (message != "") {
|
Chris@0
|
2482
|
Chris@0
|
2483 QMessageBox::warning
|
Chris@0
|
2484 (this,
|
Chris@0
|
2485 tr("Failed to regenerate layer"),
|
Chris@0
|
2486 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed:<p>%3")
|
Chris@0
|
2487 .arg(layerName).arg(transformName).arg(message),
|
Chris@0
|
2488 QMessageBox::Ok);
|
Chris@0
|
2489 } else {
|
Chris@0
|
2490 QMessageBox::warning
|
Chris@0
|
2491 (this,
|
Chris@0
|
2492 tr("Failed to regenerate layer"),
|
Chris@0
|
2493 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed.<p>No error information is available.")
|
Chris@0
|
2494 .arg(layerName).arg(transformName),
|
Chris@0
|
2495 QMessageBox::Ok);
|
Chris@0
|
2496 }
|
Chris@0
|
2497 }
|
Chris@0
|
2498
|
Chris@0
|
2499 void
|
Chris@0
|
2500 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@0
|
2501 QString transformName, QString message)
|
Chris@0
|
2502 {
|
Chris@0
|
2503 QMessageBox::warning
|
Chris@0
|
2504 (this, tr("Warning"), tr("<b>Warning when regenerating layer</b><p>When regenerating the derived layer \"%1\" using new data model as input:<p>%2").arg(layerName).arg(message), QMessageBox::Ok);
|
Chris@0
|
2505 }
|
Chris@0
|
2506
|
Chris@0
|
2507 void
|
Chris@0
|
2508 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
2509 {
|
Chris@0
|
2510 QMessageBox::warning
|
Chris@0
|
2511 (this,
|
Chris@0
|
2512 tr("Failed to calculate alignment"),
|
Chris@0
|
2513 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@0
|
2514 .arg(transformName).arg(message),
|
Chris@0
|
2515 QMessageBox::Ok);
|
Chris@0
|
2516 }
|
Chris@0
|
2517
|
Chris@0
|
2518 void
|
Chris@0
|
2519 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
2520 {
|
Chris@70
|
2521 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
2522 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
2523 m_rightButtonMenu->popup(position);
|
Chris@0
|
2524 }
|
Chris@0
|
2525
|
Chris@0
|
2526 void
|
Chris@0
|
2527 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@0
|
2528 {
|
Chris@70
|
2529 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
|
Chris@0
|
2530 }
|
Chris@0
|
2531
|
Chris@0
|
2532 void
|
Chris@0
|
2533 MainWindow::mouseEnteredWidget()
|
Chris@0
|
2534 {
|
Chris@3
|
2535 QWidget *w = qobject_cast<QWidget *>(sender());
|
Chris@0
|
2536 if (!w) return;
|
Chris@0
|
2537
|
Chris@0
|
2538 if (w == m_fader) {
|
Chris@0
|
2539 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@0
|
2540 } else if (w == m_playSpeed) {
|
Chris@0
|
2541 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@0
|
2542 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@0
|
2543 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@0
|
2544 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@0
|
2545 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
|
Chris@0
|
2546 }
|
Chris@0
|
2547 }
|
Chris@0
|
2548
|
Chris@0
|
2549 void
|
Chris@0
|
2550 MainWindow::mouseLeftWidget()
|
Chris@0
|
2551 {
|
Chris@0
|
2552 contextHelpChanged("");
|
Chris@0
|
2553 }
|
Chris@0
|
2554
|
Chris@0
|
2555 void
|
Chris@0
|
2556 MainWindow::website()
|
Chris@0
|
2557 {
|
Chris@4
|
2558 //!!! todo: URL!
|
Chris@4
|
2559 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2560 }
|
Chris@0
|
2561
|
Chris@0
|
2562 void
|
Chris@0
|
2563 MainWindow::help()
|
Chris@0
|
2564 {
|
Chris@4
|
2565 //!!! todo: help URL!
|
Chris@4
|
2566 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2567 }
|
Chris@0
|
2568
|
Chris@0
|
2569 void
|
Chris@0
|
2570 MainWindow::about()
|
Chris@0
|
2571 {
|
Chris@0
|
2572 bool debug = false;
|
Chris@0
|
2573 QString version = "(unknown version)";
|
Chris@0
|
2574
|
Chris@0
|
2575 #ifdef BUILD_DEBUG
|
Chris@0
|
2576 debug = true;
|
Chris@0
|
2577 #endif
|
Chris@0
|
2578 version = tr("Release %1").arg(TONY_VERSION);
|
Chris@0
|
2579
|
Chris@0
|
2580 QString aboutText;
|
Chris@0
|
2581
|
Chris@0
|
2582 aboutText += tr("<h3>About Tony</h3>");
|
Chris@0
|
2583 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
|
Chris@0
|
2584 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
2585 .arg(version)
|
Chris@0
|
2586 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@206
|
2587 aboutText += tr("<p>Using Qt version %1</p>")
|
Chris@206
|
2588 .arg(QT_VERSION_STR);
|
Chris@0
|
2589
|
Chris@0
|
2590 aboutText +=
|
Chris@90
|
2591 "<p>Copyright © 2005–2013 Chris Cannam, Matthias Mauch, George Fazekas, and Queen Mary University of London.</p>"
|
Chris@90
|
2592 "<p>This program is free software; you can redistribute it and/or "
|
Chris@90
|
2593 "modify it under the terms of the GNU General Public License as "
|
Chris@90
|
2594 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
2595 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
2596 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
2597
|
Chris@0
|
2598 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
|
Chris@0
|
2599 }
|
Chris@0
|
2600
|
Chris@0
|
2601 void
|
Chris@0
|
2602 MainWindow::keyReference()
|
Chris@0
|
2603 {
|
Chris@0
|
2604 m_keyReference->show();
|
Chris@0
|
2605 }
|
Chris@0
|
2606
|
Chris@0
|
2607
|