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