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