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