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