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