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