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