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