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