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