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@0
|
37 #include "widgets/Fader.h"
|
Chris@0
|
38 #include "view/Overview.h"
|
Chris@0
|
39 #include "widgets/AudioDial.h"
|
Chris@0
|
40 #include "widgets/IconLoader.h"
|
Chris@0
|
41 #include "widgets/KeyReference.h"
|
Chris@0
|
42 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
43 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
44 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@0
|
45 #include "base/Profiler.h"
|
Chris@0
|
46 #include "base/UnitDatabase.h"
|
Chris@0
|
47 #include "layer/ColourDatabase.h"
|
Chris@139
|
48 #include "base/Selection.h"
|
Chris@0
|
49
|
Chris@174
|
50 #include "rdf/RDFImporter.h"
|
Chris@174
|
51 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@174
|
52 #include "data/fileio/CSVFormat.h"
|
matthiasm@26
|
53 #include "data/fileio/CSVFileWriter.h"
|
matthiasm@26
|
54 #include "data/fileio/MIDIFileWriter.h"
|
matthiasm@26
|
55 #include "rdf/RDFExporter.h"
|
matthiasm@26
|
56
|
Chris@0
|
57 // For version information
|
Chris@0
|
58 #include "vamp/vamp.h"
|
Chris@0
|
59 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
60 #include "plugin/api/ladspa.h"
|
Chris@0
|
61 #include "plugin/api/dssi.h"
|
Chris@0
|
62
|
Chris@0
|
63 #include <QApplication>
|
Chris@0
|
64 #include <QMessageBox>
|
Chris@0
|
65 #include <QGridLayout>
|
Chris@0
|
66 #include <QLabel>
|
Chris@0
|
67 #include <QMenuBar>
|
Chris@0
|
68 #include <QToolBar>
|
Chris@0
|
69 #include <QToolButton>
|
Chris@0
|
70 #include <QInputDialog>
|
Chris@0
|
71 #include <QStatusBar>
|
Chris@0
|
72 #include <QFileInfo>
|
Chris@0
|
73 #include <QDir>
|
Chris@0
|
74 #include <QProcess>
|
Chris@2
|
75 #include <QPushButton>
|
Chris@0
|
76 #include <QSettings>
|
Chris@0
|
77 #include <QScrollArea>
|
Chris@128
|
78 #include <QPainter>
|
Chris@0
|
79
|
Chris@0
|
80 #include <iostream>
|
Chris@0
|
81 #include <cstdio>
|
Chris@0
|
82 #include <errno.h>
|
Chris@0
|
83
|
Chris@0
|
84 using std::vector;
|
Chris@0
|
85
|
Chris@0
|
86
|
Chris@0
|
87 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@0
|
88 MainWindowBase(withAudioOutput, withOSCSupport, false),
|
Chris@0
|
89 m_overview(0),
|
Chris@0
|
90 m_mainMenusCreated(false),
|
Chris@0
|
91 m_playbackMenu(0),
|
gyorgyf@45
|
92 m_recentFilesMenu(0),
|
Chris@0
|
93 m_rightButtonMenu(0),
|
Chris@0
|
94 m_rightButtonPlaybackMenu(0),
|
Chris@0
|
95 m_deleteSelectedAction(0),
|
Chris@0
|
96 m_ffwdAction(0),
|
Chris@0
|
97 m_rwdAction(0),
|
Chris@168
|
98 m_intelligentActionOn(true), //GF: !!! temporary
|
Chris@0
|
99 m_keyReference(new KeyReference())
|
Chris@0
|
100 {
|
Chris@0
|
101 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
102
|
Chris@0
|
103 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@0
|
104 udb->registerUnit("Hz");
|
Chris@0
|
105 udb->registerUnit("dB");
|
Chris@0
|
106 udb->registerUnit("s");
|
Chris@0
|
107
|
Chris@0
|
108 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@0
|
109 cdb->addColour(Qt::black, tr("Black"));
|
Chris@0
|
110 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@0
|
111 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@0
|
112 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@0
|
113 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@0
|
114 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@120
|
115 cdb->addColour(QColor(180, 180, 180), tr("Grey"));
|
Chris@0
|
116 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@0
|
117 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@0
|
118 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@0
|
119 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@0
|
120 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@0
|
121 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
122
|
Chris@0
|
123 Preferences::getInstance()->setResampleOnLoad(true);
|
Chris@0
|
124 Preferences::getInstance()->setSpectrogramSmoothing
|
Chris@0
|
125 (Preferences::SpectrogramInterpolated);
|
Chris@0
|
126
|
Chris@0
|
127 QSettings settings;
|
Chris@0
|
128
|
Chris@0
|
129 settings.beginGroup("MainWindow");
|
Chris@0
|
130 settings.setValue("showstatusbar", false);
|
Chris@0
|
131 settings.endGroup();
|
Chris@0
|
132
|
Chris@96
|
133 settings.beginGroup("Transformer");
|
Chris@96
|
134 settings.setValue("use-flexi-note-model", true);
|
Chris@96
|
135 settings.endGroup();
|
Chris@96
|
136
|
Chris@73
|
137 settings.beginGroup("LayerDefaults");
|
Chris@73
|
138 settings.setValue("waveform",
|
Chris@73
|
139 QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
Chris@73
|
140 .arg(int(WaveformLayer::LinearScale))
|
Chris@73
|
141 .arg(int(WaveformLayer::MixChannels)));
|
Chris@73
|
142 settings.endGroup();
|
Chris@73
|
143
|
Chris@6
|
144 m_viewManager->setAlignMode(false);
|
Chris@6
|
145 m_viewManager->setPlaySoloMode(false);
|
Chris@0
|
146 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
147 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@6
|
148 m_viewManager->setIlluminateLocalFeatures(true);
|
Chris@0
|
149 m_viewManager->setShowWorkTitle(true);
|
Chris@6
|
150 m_viewManager->setShowCentreLine(false);
|
Chris@91
|
151 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@0
|
152
|
Chris@164
|
153 connect(m_viewManager, SIGNAL(selectionChanged()),
|
Chris@164
|
154 this, SLOT(selectionChanged()));
|
Chris@164
|
155
|
Chris@0
|
156 QFrame *frame = new QFrame;
|
Chris@0
|
157 setCentralWidget(frame);
|
Chris@0
|
158
|
Chris@0
|
159 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
160
|
Chris@0
|
161 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@0
|
162 scroll->setWidgetResizable(true);
|
Chris@0
|
163 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@0
|
164 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@0
|
165
|
Chris@6
|
166 // We have a pane stack: it comes with the territory. However, we
|
Chris@120
|
167 // have a fixed and known number of panes in it -- it isn't
|
Chris@120
|
168 // variable
|
Chris@0
|
169 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@137
|
170 m_paneStack->setShowPaneAccessories(false);
|
Chris@139
|
171 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(size_t)),
|
Chris@139
|
172 this, SLOT(doubleClickSelectInvoked(size_t)));
|
Chris@0
|
173 scroll->setWidget(m_paneStack);
|
Chris@6
|
174
|
Chris@0
|
175 m_overview = new Overview(frame);
|
Chris@0
|
176 m_overview->setViewManager(m_viewManager);
|
Chris@0
|
177 m_overview->setFixedHeight(40);
|
Chris@0
|
178 #ifndef _WIN32
|
Chris@0
|
179 // For some reason, the contents of the overview never appear if we
|
Chris@0
|
180 // make this setting on Windows. I have no inclination at the moment
|
Chris@0
|
181 // to track down the reason why.
|
Chris@0
|
182 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@0
|
183 #endif
|
Chris@0
|
184 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
185 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
186
|
Chris@0
|
187 m_panLayer = new WaveformLayer;
|
Chris@0
|
188 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
189 m_panLayer->setAggressiveCacheing(true);
|
Chris@0
|
190 m_overview->addLayer(m_panLayer);
|
Chris@0
|
191
|
Chris@0
|
192 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@0
|
193 m_panLayer->setBaseColour
|
Chris@0
|
194 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@0
|
195 } else {
|
Chris@0
|
196 m_panLayer->setBaseColour
|
matthiasm@13
|
197 (ColourDatabase::getInstance()->getColourIndex(tr("Blue")));
|
Chris@0
|
198 }
|
Chris@0
|
199
|
Chris@0
|
200 m_fader = new Fader(frame, false);
|
Chris@0
|
201 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
202 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
203
|
Chris@0
|
204 m_playSpeed = new AudioDial(frame);
|
Chris@0
|
205 m_playSpeed->setMinimum(0);
|
Chris@0
|
206 m_playSpeed->setMaximum(200);
|
Chris@0
|
207 m_playSpeed->setValue(100);
|
Chris@0
|
208 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
209 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
210 m_playSpeed->setNotchesVisible(true);
|
Chris@0
|
211 m_playSpeed->setPageStep(10);
|
Chris@0
|
212 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@0
|
213 m_playSpeed->setDefaultValue(100);
|
Chris@0
|
214 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@0
|
215 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
216 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
gyorgyf@27
|
217 this, SLOT(playSpeedChanged(int)));
|
Chris@0
|
218 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
219 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
220
|
justin@159
|
221 // Gain controls
|
justin@159
|
222 m_gainAudio = new AudioDial(frame);
|
justin@159
|
223 m_gainAudio->setMinimum(-50);
|
justin@159
|
224 m_gainAudio->setMaximum(50);
|
justin@159
|
225 m_gainAudio->setValue(0);
|
justin@159
|
226 m_gainAudio->setDefaultValue(0);
|
justin@159
|
227 m_gainAudio->setFixedWidth(24);
|
justin@159
|
228 m_gainAudio->setFixedHeight(24);
|
justin@159
|
229 m_gainAudio->setNotchesVisible(true);
|
justin@159
|
230 m_gainAudio->setPageStep(10);
|
justin@159
|
231 m_gainAudio->setObjectName(tr("Audio Track Gain"));
|
justin@159
|
232 m_gainAudio->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
233 m_gainAudio->setShowToolTip(true);
|
justin@159
|
234 connect(m_gainAudio, SIGNAL(valueChanged(int)),
|
justin@159
|
235 this, SLOT(audioGainChanged(int)));
|
justin@159
|
236 connect(m_gainAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
237 connect(m_gainAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
238
|
justin@157
|
239 m_gainPitch = new AudioDial(frame);
|
Chris@158
|
240 m_gainPitch->setMinimum(-50);
|
Chris@158
|
241 m_gainPitch->setMaximum(50);
|
Chris@158
|
242 m_gainPitch->setValue(0);
|
Chris@158
|
243 m_gainPitch->setDefaultValue(0);
|
justin@157
|
244 m_gainPitch->setFixedWidth(24);
|
justin@157
|
245 m_gainPitch->setFixedHeight(24);
|
justin@157
|
246 m_gainPitch->setNotchesVisible(true);
|
justin@157
|
247 m_gainPitch->setPageStep(10);
|
Chris@158
|
248 m_gainPitch->setObjectName(tr("Pitch Track Gain"));
|
Chris@158
|
249 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@157
|
250 m_gainPitch->setShowToolTip(true);
|
justin@157
|
251 connect(m_gainPitch, SIGNAL(valueChanged(int)),
|
Chris@158
|
252 this, SLOT(pitchGainChanged(int)));
|
justin@157
|
253 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@157
|
254 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@157
|
255
|
justin@159
|
256 m_gainNotes = new AudioDial(frame);
|
justin@159
|
257 m_gainNotes->setMinimum(-50);
|
justin@159
|
258 m_gainNotes->setMaximum(50);
|
justin@159
|
259 m_gainNotes->setValue(0);
|
justin@159
|
260 m_gainNotes->setDefaultValue(0);
|
justin@159
|
261 m_gainNotes->setFixedWidth(24);
|
justin@159
|
262 m_gainNotes->setFixedHeight(24);
|
justin@159
|
263 m_gainNotes->setNotchesVisible(true);
|
justin@159
|
264 m_gainNotes->setPageStep(10);
|
justin@159
|
265 m_gainNotes->setObjectName(tr("Pitch Track Gain"));
|
justin@159
|
266 m_gainNotes->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
267 m_gainNotes->setShowToolTip(true);
|
justin@159
|
268 connect(m_gainNotes, SIGNAL(valueChanged(int)),
|
justin@159
|
269 this, SLOT(notesGainChanged(int)));
|
justin@159
|
270 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
271 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
272 // End of Gain controls
|
justin@159
|
273
|
justin@160
|
274 // Pan controls
|
justin@160
|
275 m_panAudio = new AudioDial(frame);
|
justin@160
|
276 m_panAudio->setMinimum(-100);
|
justin@160
|
277 m_panAudio->setMaximum(100);
|
justin@160
|
278 m_panAudio->setValue(-100);
|
justin@160
|
279 m_panAudio->setDefaultValue(-100);
|
justin@160
|
280 m_panAudio->setFixedWidth(24);
|
justin@160
|
281 m_panAudio->setFixedHeight(24);
|
justin@160
|
282 m_panAudio->setNotchesVisible(true);
|
justin@160
|
283 m_panAudio->setPageStep(10);
|
justin@160
|
284 m_panAudio->setObjectName(tr("Audio Track Pan"));
|
justin@160
|
285 m_panAudio->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
286 m_panAudio->setShowToolTip(true);
|
justin@160
|
287 connect(m_panAudio, SIGNAL(valueChanged(int)),
|
justin@160
|
288 this, SLOT(audioPanChanged(int)));
|
justin@160
|
289 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
290 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
291
|
justin@160
|
292 m_panPitch = new AudioDial(frame);
|
justin@160
|
293 m_panPitch->setMinimum(-100);
|
justin@160
|
294 m_panPitch->setMaximum(100);
|
justin@160
|
295 m_panPitch->setValue(100);
|
justin@160
|
296 m_panPitch->setDefaultValue(100);
|
justin@160
|
297 m_panPitch->setFixedWidth(24);
|
justin@160
|
298 m_panPitch->setFixedHeight(24);
|
justin@160
|
299 m_panPitch->setNotchesVisible(true);
|
justin@160
|
300 m_panPitch->setPageStep(10);
|
justin@160
|
301 m_panPitch->setObjectName(tr("Pitch Track Pan"));
|
justin@160
|
302 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
303 m_panPitch->setShowToolTip(true);
|
justin@160
|
304 connect(m_panPitch, SIGNAL(valueChanged(int)),
|
justin@160
|
305 this, SLOT(pitchPanChanged(int)));
|
justin@160
|
306 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
307 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
308
|
justin@160
|
309 m_panNotes = new AudioDial(frame);
|
justin@160
|
310 m_panNotes->setMinimum(-100);
|
justin@160
|
311 m_panNotes->setMaximum(100);
|
justin@160
|
312 m_panNotes->setValue(100);
|
justin@160
|
313 m_panNotes->setDefaultValue(100);
|
justin@160
|
314 m_panNotes->setFixedWidth(24);
|
justin@160
|
315 m_panNotes->setFixedHeight(24);
|
justin@160
|
316 m_panNotes->setNotchesVisible(true);
|
justin@160
|
317 m_panNotes->setPageStep(10);
|
justin@160
|
318 m_panNotes->setObjectName(tr("Notes Track Pan"));
|
justin@160
|
319 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
320 m_panNotes->setShowToolTip(true);
|
justin@160
|
321 connect(m_panNotes, SIGNAL(valueChanged(int)),
|
justin@160
|
322 this, SLOT(notesPanChanged(int)));
|
justin@160
|
323 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
324 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
325 // End of Pan controls
|
justin@160
|
326
|
Chris@0
|
327 layout->setSpacing(4);
|
Chris@6
|
328 layout->addWidget(m_overview, 0, 1);
|
Chris@6
|
329 layout->addWidget(scroll, 1, 1);
|
Chris@0
|
330
|
Chris@0
|
331 layout->setColumnStretch(1, 10);
|
Chris@0
|
332
|
Chris@0
|
333 frame->setLayout(layout);
|
Chris@0
|
334
|
gyorgyf@21
|
335 m_analyser = new Analyser();
|
Chris@128
|
336 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@128
|
337 this, SLOT(updateLayerStatuses()));
|
gyorgyf@21
|
338
|
Chris@0
|
339 setupMenus();
|
Chris@0
|
340 setupToolbars();
|
Chris@0
|
341 setupHelpMenu();
|
Chris@0
|
342
|
Chris@0
|
343 statusBar();
|
Chris@0
|
344
|
Chris@95
|
345 newSession();
|
Chris@6
|
346
|
Chris@95
|
347 settings.beginGroup("MainWindow");
|
Chris@95
|
348 settings.setValue("zoom-default", 512);
|
Chris@95
|
349 settings.endGroup();
|
Chris@95
|
350 zoomDefault();
|
Chris@95
|
351
|
Chris@95
|
352 NetworkPermissionTester tester;
|
Chris@95
|
353 bool networkPermission = tester.havePermission();
|
Chris@95
|
354 if (networkPermission) {
|
Chris@95
|
355 m_versionTester = new VersionTester
|
Chris@95
|
356 ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
|
Chris@95
|
357 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@95
|
358 this, SLOT(newerVersionAvailable(QString)));
|
Chris@95
|
359 } else {
|
Chris@95
|
360 m_versionTester = 0;
|
Chris@95
|
361 }
|
Chris@0
|
362 }
|
Chris@0
|
363
|
Chris@0
|
364 MainWindow::~MainWindow()
|
Chris@0
|
365 {
|
Chris@6
|
366 delete m_analyser;
|
Chris@0
|
367 delete m_keyReference;
|
Chris@0
|
368 Profiles::getInstance()->dump();
|
Chris@0
|
369 }
|
Chris@0
|
370
|
Chris@0
|
371 void
|
Chris@0
|
372 MainWindow::setupMenus()
|
Chris@0
|
373 {
|
Chris@0
|
374 if (!m_mainMenusCreated) {
|
Chris@0
|
375 m_rightButtonMenu = new QMenu();
|
Chris@0
|
376 }
|
Chris@0
|
377
|
Chris@0
|
378 if (!m_mainMenusCreated) {
|
Chris@0
|
379 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
380 m_rightButtonMenu->addSeparator();
|
Chris@0
|
381 }
|
Chris@0
|
382
|
Chris@0
|
383 setupFileMenu();
|
Chris@0
|
384 setupEditMenu();
|
Chris@0
|
385 setupViewMenu();
|
Chris@0
|
386
|
Chris@0
|
387 m_mainMenusCreated = true;
|
Chris@0
|
388 }
|
Chris@0
|
389
|
Chris@0
|
390 void
|
Chris@0
|
391 MainWindow::setupFileMenu()
|
Chris@0
|
392 {
|
Chris@0
|
393 if (m_mainMenusCreated) return;
|
Chris@0
|
394
|
Chris@0
|
395 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@0
|
396 menu->setTearOffEnabled(true);
|
Chris@0
|
397 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@0
|
398
|
Chris@0
|
399 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@0
|
400
|
Chris@0
|
401 IconLoader il;
|
Chris@1
|
402 QIcon icon;
|
Chris@1
|
403 QAction *action;
|
Chris@0
|
404
|
Chris@0
|
405 icon = il.load("fileopen");
|
Chris@0
|
406 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@1
|
407 action = new QAction(icon, tr("&Open..."), this);
|
Chris@0
|
408 action->setShortcut(tr("Ctrl+O"));
|
Chris@1
|
409 action->setStatusTip(tr("Open a file"));
|
Chris@0
|
410 connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
|
Chris@0
|
411 m_keyReference->registerShortcut(action);
|
Chris@0
|
412 menu->addAction(action);
|
Chris@0
|
413 toolbar->addAction(action);
|
Chris@0
|
414
|
Chris@1
|
415 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@0
|
416 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@1
|
417 action->setStatusTip(tr("Open a file from a remote URL"));
|
Chris@0
|
418 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@0
|
419 m_keyReference->registerShortcut(action);
|
Chris@0
|
420 menu->addAction(action);
|
Chris@0
|
421
|
Chris@1
|
422 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@0
|
423 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@0
|
424 setupRecentFilesMenu();
|
Chris@0
|
425 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@0
|
426 this, SLOT(setupRecentFilesMenu()));
|
Chris@0
|
427
|
Chris@0
|
428 menu->addSeparator();
|
Chris@174
|
429 action = new QAction(tr("Import Pitch Track Data..."), this);
|
Chris@174
|
430 action->setStatusTip(tr("Import pitch-track data from a file"));
|
Chris@174
|
431 connect(action, SIGNAL(triggered()), this, SLOT(importPitchLayer()));
|
Chris@174
|
432 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@174
|
433 menu->addAction(action);
|
Chris@174
|
434
|
Chris@85
|
435 action = new QAction(tr("Export Pitch Track Data..."), this);
|
Chris@85
|
436 action->setStatusTip(tr("Export pitch-track data to a file"));
|
Chris@85
|
437 connect(action, SIGNAL(triggered()), this, SLOT(exportPitchLayer()));
|
Chris@85
|
438 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@85
|
439 menu->addAction(action);
|
Chris@85
|
440
|
Chris@85
|
441 action = new QAction(tr("Export Note Data..."), this);
|
Chris@85
|
442 action->setStatusTip(tr("Export note data to a file"));
|
Chris@85
|
443 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
|
matthiasm@26
|
444 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@26
|
445 menu->addAction(action);
|
matthiasm@26
|
446
|
matthiasm@26
|
447 menu->addSeparator();
|
Chris@0
|
448 action = new QAction(il.load("exit"), tr("&Quit"), this);
|
Chris@0
|
449 action->setShortcut(tr("Ctrl+Q"));
|
Chris@0
|
450 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@0
|
451 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@0
|
452 m_keyReference->registerShortcut(action);
|
Chris@0
|
453 menu->addAction(action);
|
Chris@0
|
454 }
|
Chris@0
|
455
|
Chris@0
|
456 void
|
Chris@0
|
457 MainWindow::setupEditMenu()
|
Chris@0
|
458 {
|
Chris@0
|
459 if (m_mainMenusCreated) return;
|
Chris@0
|
460
|
Chris@0
|
461 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@0
|
462 menu->setTearOffEnabled(true);
|
Chris@0
|
463 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@126
|
464 menu->addSeparator();
|
Chris@126
|
465
|
Chris@126
|
466 QToolBar *toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@126
|
467
|
Chris@126
|
468 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@126
|
469
|
Chris@126
|
470 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
471
|
Chris@126
|
472 QActionGroup *group = new QActionGroup(this);
|
Chris@126
|
473
|
Chris@126
|
474 IconLoader il;
|
Chris@126
|
475
|
Chris@126
|
476 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@126
|
477 tr("Navigate"));
|
Chris@126
|
478 action->setCheckable(true);
|
Chris@126
|
479 action->setChecked(true);
|
Chris@126
|
480 action->setShortcut(tr("1"));
|
Chris@126
|
481 action->setStatusTip(tr("Navigate"));
|
Chris@126
|
482 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@126
|
483 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@126
|
484 group->addAction(action);
|
Chris@126
|
485 menu->addAction(action);
|
Chris@126
|
486 m_keyReference->registerShortcut(action);
|
Chris@126
|
487
|
Chris@126
|
488 action = toolbar->addAction(il.load("move"),
|
Chris@126
|
489 tr("Edit"));
|
Chris@126
|
490 action->setCheckable(true);
|
Chris@126
|
491 action->setShortcut(tr("2"));
|
Chris@126
|
492 action->setStatusTip(tr("Edit with Note Intelligence"));
|
Chris@126
|
493 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@126
|
494 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
495 group->addAction(action);
|
Chris@126
|
496 menu->addAction(action);
|
Chris@126
|
497 m_keyReference->registerShortcut(action);
|
Chris@126
|
498
|
Chris@126
|
499 /* Remove for now...
|
Chris@126
|
500
|
Chris@126
|
501 action = toolbar->addAction(il.load("notes"),
|
Chris@126
|
502 tr("Free Edit"));
|
Chris@126
|
503 action->setCheckable(true);
|
Chris@126
|
504 action->setShortcut(tr("3"));
|
Chris@126
|
505 action->setStatusTip(tr("Free Edit"));
|
Chris@126
|
506 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
|
Chris@126
|
507 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
508 group->addAction(action);
|
Chris@126
|
509 m_keyReference->registerShortcut(action);
|
Chris@126
|
510 */
|
Chris@142
|
511
|
Chris@142
|
512 menu->addSeparator();
|
Chris@142
|
513
|
Chris@143
|
514 m_keyReference->setCategory(tr("Selection"));
|
Chris@143
|
515
|
Chris@143
|
516 action = new QAction(tr("Select &All"), this);
|
Chris@143
|
517 action->setShortcut(tr("Ctrl+A"));
|
Chris@143
|
518 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@143
|
519 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@143
|
520 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
521 m_keyReference->registerShortcut(action);
|
Chris@143
|
522 menu->addAction(action);
|
Chris@143
|
523 m_rightButtonMenu->addAction(action);
|
Chris@143
|
524
|
Chris@143
|
525 action = new QAction(tr("C&lear Selection"), this);
|
Chris@143
|
526 action->setShortcut(tr("Esc"));
|
Chris@143
|
527 action->setStatusTip(tr("Clear the selection"));
|
Chris@143
|
528 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
Chris@143
|
529 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
530 m_keyReference->registerShortcut(action);
|
Chris@143
|
531 menu->addAction(action);
|
Chris@143
|
532 m_rightButtonMenu->addAction(action);
|
Chris@143
|
533
|
Chris@143
|
534 menu->addSeparator();
|
Chris@143
|
535
|
Chris@143
|
536 //!!! shortcuts, status tip, key reference etc
|
Chris@168
|
537 action = new QAction(tr("Clear Pitches"), this);
|
Chris@168
|
538 action->setShortcut(tr("Backspace"));
|
Chris@168
|
539 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
|
Chris@168
|
540 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@168
|
541 menu->addAction(action);
|
Chris@168
|
542
|
Chris@168
|
543 //!!! shortcuts, status tip, key reference etc
|
Chris@142
|
544 action = new QAction(tr("Octave Shift Up"), this);
|
Chris@142
|
545 action->setShortcut(tr("PgUp"));
|
Chris@142
|
546 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftUp()));
|
Chris@142
|
547 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@142
|
548 menu->addAction(action);
|
Chris@142
|
549
|
Chris@142
|
550 action = new QAction(tr("Octave Shift Down"), this);
|
Chris@142
|
551 action->setShortcut(tr("PgDown"));
|
Chris@142
|
552 connect(action, SIGNAL(triggered()), this, SLOT(octaveShiftDown()));
|
Chris@142
|
553 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@142
|
554 menu->addAction(action);
|
Chris@167
|
555
|
Chris@167
|
556 //!!! shortcuts, status tip, key reference etc
|
Chris@167
|
557 action = new QAction(tr("Switch Pitch Candidate"), this);
|
Chris@167
|
558 action->setShortcut(tr("Return"));
|
Chris@168
|
559 connect(action, SIGNAL(triggered()), this, SLOT(switchPitch()));
|
Chris@167
|
560 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@167
|
561 menu->addAction(action);
|
Chris@0
|
562 }
|
Chris@0
|
563
|
Chris@0
|
564 void
|
Chris@0
|
565 MainWindow::setupViewMenu()
|
Chris@0
|
566 {
|
Chris@0
|
567 if (m_mainMenusCreated) return;
|
Chris@0
|
568
|
Chris@0
|
569 IconLoader il;
|
Chris@0
|
570
|
Chris@0
|
571 QAction *action = 0;
|
Chris@0
|
572
|
Chris@0
|
573 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@0
|
574
|
Chris@0
|
575 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@0
|
576 menu->setTearOffEnabled(true);
|
Chris@0
|
577 action = new QAction(tr("Scroll &Left"), this);
|
Chris@0
|
578 action->setShortcut(tr("Left"));
|
Chris@0
|
579 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@0
|
580 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@0
|
581 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
582 m_keyReference->registerShortcut(action);
|
Chris@0
|
583 menu->addAction(action);
|
gyorgyf@27
|
584
|
Chris@0
|
585 action = new QAction(tr("Scroll &Right"), this);
|
Chris@0
|
586 action->setShortcut(tr("Right"));
|
Chris@0
|
587 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@0
|
588 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@0
|
589 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
590 m_keyReference->registerShortcut(action);
|
Chris@0
|
591 menu->addAction(action);
|
gyorgyf@27
|
592
|
Chris@0
|
593 action = new QAction(tr("&Jump Left"), this);
|
Chris@0
|
594 action->setShortcut(tr("Ctrl+Left"));
|
Chris@0
|
595 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@0
|
596 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@0
|
597 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
598 m_keyReference->registerShortcut(action);
|
Chris@0
|
599 menu->addAction(action);
|
gyorgyf@27
|
600
|
Chris@0
|
601 action = new QAction(tr("J&ump Right"), this);
|
Chris@0
|
602 action->setShortcut(tr("Ctrl+Right"));
|
Chris@0
|
603 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@0
|
604 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@0
|
605 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
606 m_keyReference->registerShortcut(action);
|
Chris@0
|
607 menu->addAction(action);
|
Chris@0
|
608
|
Chris@0
|
609 menu->addSeparator();
|
Chris@0
|
610
|
Chris@0
|
611 m_keyReference->setCategory(tr("Zoom"));
|
Chris@0
|
612
|
Chris@0
|
613 action = new QAction(il.load("zoom-in"),
|
Chris@0
|
614 tr("Zoom &In"), this);
|
Chris@0
|
615 action->setShortcut(tr("Up"));
|
Chris@0
|
616 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@0
|
617 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@0
|
618 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
619 m_keyReference->registerShortcut(action);
|
Chris@0
|
620 menu->addAction(action);
|
gyorgyf@27
|
621
|
Chris@0
|
622 action = new QAction(il.load("zoom-out"),
|
Chris@0
|
623 tr("Zoom &Out"), this);
|
Chris@0
|
624 action->setShortcut(tr("Down"));
|
Chris@0
|
625 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@0
|
626 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@0
|
627 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
628 m_keyReference->registerShortcut(action);
|
Chris@0
|
629 menu->addAction(action);
|
gyorgyf@27
|
630
|
Chris@0
|
631 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@0
|
632 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@0
|
633 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@0
|
634 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
635 menu->addAction(action);
|
Chris@0
|
636
|
Chris@0
|
637 action = new QAction(il.load("zoom-fit"),
|
Chris@0
|
638 tr("Zoom to &Fit"), this);
|
Chris@0
|
639 action->setShortcut(tr("F"));
|
Chris@0
|
640 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@0
|
641 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@0
|
642 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
643 m_keyReference->registerShortcut(action);
|
Chris@0
|
644 menu->addAction(action);
|
Chris@0
|
645 }
|
Chris@0
|
646
|
Chris@0
|
647 void
|
Chris@0
|
648 MainWindow::setupHelpMenu()
|
Chris@0
|
649 {
|
Chris@0
|
650 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@0
|
651 menu->setTearOffEnabled(true);
|
Chris@0
|
652
|
Chris@0
|
653 m_keyReference->setCategory(tr("Help"));
|
Chris@0
|
654
|
Chris@0
|
655 IconLoader il;
|
Chris@0
|
656
|
Chris@1
|
657 QString name = QApplication::applicationName();
|
Chris@1
|
658
|
Chris@0
|
659 QAction *action = new QAction(il.load("help"),
|
Chris@0
|
660 tr("&Help Reference"), this);
|
Chris@0
|
661 action->setShortcut(tr("F1"));
|
Chris@1
|
662 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
Chris@0
|
663 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
664 m_keyReference->registerShortcut(action);
|
Chris@0
|
665 menu->addAction(action);
|
Chris@0
|
666
|
Chris@0
|
667 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@0
|
668 action->setShortcut(tr("F2"));
|
Chris@1
|
669 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@0
|
670 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@0
|
671 m_keyReference->registerShortcut(action);
|
Chris@0
|
672 menu->addAction(action);
|
Chris@0
|
673
|
Chris@1
|
674 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@1
|
675 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@0
|
676 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
677 menu->addAction(action);
|
Chris@0
|
678
|
Chris@1
|
679 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@1
|
680 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@0
|
681 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
682 menu->addAction(action);
|
Chris@0
|
683 }
|
Chris@0
|
684
|
Chris@0
|
685 void
|
Chris@0
|
686 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
687 {
|
Chris@0
|
688 m_recentFilesMenu->clear();
|
Chris@0
|
689 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
690 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@50
|
691 QAction *action = new QAction(files[i], this);
|
Chris@50
|
692 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
693 if (i == 0) {
|
Chris@0
|
694 action->setShortcut(tr("Ctrl+R"));
|
Chris@0
|
695 m_keyReference->registerShortcut
|
Chris@0
|
696 (tr("Re-open"),
|
Chris@50
|
697 action->shortcut().toString(),
|
Chris@0
|
698 tr("Re-open the current or most recently opened file"));
|
Chris@0
|
699 }
|
Chris@50
|
700 m_recentFilesMenu->addAction(action);
|
Chris@0
|
701 }
|
Chris@0
|
702 }
|
Chris@0
|
703
|
Chris@0
|
704 void
|
Chris@0
|
705 MainWindow::setupToolbars()
|
Chris@0
|
706 {
|
Chris@0
|
707 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@0
|
708
|
Chris@0
|
709 IconLoader il;
|
Chris@0
|
710
|
Chris@0
|
711 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@0
|
712 menu->setTearOffEnabled(true);
|
Chris@0
|
713 m_rightButtonMenu->addSeparator();
|
Chris@0
|
714 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@0
|
715
|
Chris@0
|
716 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@0
|
717
|
Chris@0
|
718 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@0
|
719 tr("Rewind to Start"));
|
Chris@0
|
720 rwdStartAction->setShortcut(tr("Home"));
|
Chris@0
|
721 rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
722 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
723 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@0
|
724
|
Chris@0
|
725 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
|
Chris@0
|
726 tr("Rewind"));
|
Chris@0
|
727 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@0
|
728 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
729 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
730
|
Chris@0
|
731 QAction *playAction = toolbar->addAction(il.load("playpause"),
|
Chris@0
|
732 tr("Play / Pause"));
|
Chris@0
|
733 playAction->setCheckable(true);
|
Chris@0
|
734 playAction->setShortcut(tr("Space"));
|
Chris@0
|
735 playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
736 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
737 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
gyorgyf@27
|
738 playAction, SLOT(setChecked(bool)));
|
Chris@0
|
739 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
|
Chris@0
|
740
|
Chris@0
|
741 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@0
|
742 tr("Fast Forward"));
|
Chris@0
|
743 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@0
|
744 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
745 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
746
|
Chris@0
|
747 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@0
|
748 tr("Fast Forward to End"));
|
Chris@0
|
749 ffwdEndAction->setShortcut(tr("End"));
|
Chris@0
|
750 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
751 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
752 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@6
|
753
|
Chris@0
|
754 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
755
|
Chris@0
|
756 QAction *psAction = toolbar->addAction(il.load("playselection"),
|
Chris@0
|
757 tr("Constrain Playback to Selection"));
|
Chris@0
|
758 psAction->setCheckable(true);
|
Chris@0
|
759 psAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
760 psAction->setShortcut(tr("s"));
|
Chris@0
|
761 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@0
|
762 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@0
|
763 psAction, SLOT(setChecked(bool)));
|
Chris@0
|
764 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
765 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
|
Chris@0
|
766
|
Chris@0
|
767 QAction *plAction = toolbar->addAction(il.load("playloop"),
|
Chris@0
|
768 tr("Loop Playback"));
|
Chris@0
|
769 plAction->setCheckable(true);
|
Chris@0
|
770 plAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
771 plAction->setShortcut(tr("l"));
|
Chris@0
|
772 plAction->setStatusTip(tr("Loop playback"));
|
Chris@0
|
773 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@0
|
774 plAction, SLOT(setChecked(bool)));
|
Chris@0
|
775 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
776 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
|
Chris@0
|
777
|
Chris@0
|
778 m_keyReference->registerShortcut(psAction);
|
Chris@0
|
779 m_keyReference->registerShortcut(plAction);
|
Chris@0
|
780 m_keyReference->registerShortcut(playAction);
|
Chris@0
|
781 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@0
|
782 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@0
|
783 m_keyReference->registerShortcut(rwdStartAction);
|
Chris@0
|
784 m_keyReference->registerShortcut(ffwdEndAction);
|
Chris@0
|
785
|
Chris@6
|
786 menu->addAction(playAction);
|
Chris@0
|
787 menu->addAction(psAction);
|
Chris@0
|
788 menu->addAction(plAction);
|
Chris@0
|
789 menu->addSeparator();
|
Chris@0
|
790 menu->addAction(m_rwdAction);
|
Chris@0
|
791 menu->addAction(m_ffwdAction);
|
Chris@0
|
792 menu->addSeparator();
|
Chris@0
|
793 menu->addAction(rwdStartAction);
|
Chris@0
|
794 menu->addAction(ffwdEndAction);
|
Chris@0
|
795 menu->addSeparator();
|
Chris@0
|
796
|
Chris@0
|
797 m_rightButtonPlaybackMenu->addAction(playAction);
|
Chris@0
|
798 m_rightButtonPlaybackMenu->addAction(psAction);
|
Chris@0
|
799 m_rightButtonPlaybackMenu->addAction(plAction);
|
Chris@0
|
800 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
801 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@0
|
802 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@0
|
803 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
804 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
|
Chris@0
|
805 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
|
Chris@0
|
806 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
807
|
Chris@0
|
808 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@0
|
809 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@0
|
810 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@0
|
811 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@0
|
812 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@0
|
813
|
Chris@0
|
814 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@0
|
815 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@0
|
816 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@0
|
817 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@0
|
818 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@0
|
819
|
Chris@0
|
820 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@0
|
821 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@0
|
822 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@0
|
823 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@0
|
824 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@0
|
825
|
Chris@0
|
826 m_keyReference->registerShortcut(fastAction);
|
Chris@0
|
827 m_keyReference->registerShortcut(slowAction);
|
Chris@0
|
828 m_keyReference->registerShortcut(normalAction);
|
Chris@0
|
829
|
Chris@0
|
830 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@0
|
831 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@0
|
832 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@6
|
833
|
Chris@6
|
834 toolbar = addToolBar(tr("Playback Controls"));
|
Chris@6
|
835 toolbar->addWidget(m_playSpeed);
|
Chris@6
|
836 toolbar->addWidget(m_fader);
|
Chris@0
|
837
|
Chris@128
|
838 toolbar = addToolBar(tr("Show and Play"));
|
Chris@144
|
839
|
justin@156
|
840 /* ORIGINAL DESIGN
|
Chris@144
|
841 QLabel *eye = new QLabel;
|
Chris@144
|
842 eye->setFixedWidth(40);
|
Chris@144
|
843 eye->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
844 eye->setPixmap(il.loadPixmap("eye"));
|
Chris@144
|
845 toolbar->addWidget(eye);
|
Chris@144
|
846
|
Chris@144
|
847 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
|
Chris@144
|
848 m_showAudio->setCheckable(true);
|
Chris@144
|
849 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
Chris@144
|
850 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
Chris@144
|
851
|
Chris@145
|
852 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
|
Chris@145
|
853 m_showSpect->setCheckable(true);
|
Chris@145
|
854 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
Chris@145
|
855 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@145
|
856
|
Chris@144
|
857 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
|
Chris@144
|
858 m_showPitch->setCheckable(true);
|
Chris@144
|
859 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
Chris@144
|
860 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
Chris@144
|
861
|
Chris@144
|
862 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
|
Chris@144
|
863 m_showNotes->setCheckable(true);
|
Chris@144
|
864 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
Chris@144
|
865 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
Chris@144
|
866
|
Chris@144
|
867 QLabel *speaker = new QLabel;
|
Chris@144
|
868 speaker->setFixedWidth(40);
|
Chris@144
|
869 speaker->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
870 speaker->setPixmap(il.loadPixmap("speaker"));
|
Chris@144
|
871 toolbar->addWidget(speaker);
|
Chris@128
|
872
|
Chris@144
|
873 m_playAudio = toolbar->addAction(il.load("waveform"), tr("Play Audio"));
|
Chris@144
|
874 m_playAudio->setCheckable(true);
|
Chris@144
|
875 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
Chris@144
|
876 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
Chris@128
|
877
|
Chris@144
|
878 m_playPitch = toolbar->addAction(il.load("values"), tr("Play Pitch Track"));
|
Chris@144
|
879 m_playPitch->setCheckable(true);
|
Chris@144
|
880 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
Chris@144
|
881 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
|
Chris@128
|
882
|
Chris@144
|
883 m_playNotes = toolbar->addAction(il.load("notes"), tr("Play Notes"));
|
Chris@144
|
884 m_playNotes->setCheckable(true);
|
Chris@144
|
885 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
Chris@144
|
886 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
887 */
|
justin@156
|
888
|
justin@156
|
889 // Audio
|
justin@156
|
890 QLabel *icon_audio = new QLabel;
|
justin@156
|
891 icon_audio->setFixedWidth(40);
|
justin@156
|
892 icon_audio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
893 icon_audio->setPixmap(il.loadPixmap("waveform"));
|
justin@156
|
894 toolbar->addWidget(icon_audio);
|
justin@156
|
895
|
justin@156
|
896 m_showAudio = toolbar->addAction(il.load("eye"), tr("Show Audio"));
|
justin@156
|
897 m_showAudio->setCheckable(true);
|
justin@156
|
898 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
justin@156
|
899 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
justin@156
|
900
|
justin@156
|
901 m_playAudio = toolbar->addAction(il.load("speaker"), tr("Play Audio"));
|
justin@156
|
902 m_playAudio->setCheckable(true);
|
justin@156
|
903 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
justin@156
|
904 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
justin@156
|
905
|
justin@159
|
906 toolbar->addWidget(m_gainAudio);
|
justin@160
|
907 toolbar->addWidget(m_panAudio);
|
justin@159
|
908
|
justin@156
|
909 // Pitch (f0)
|
justin@156
|
910 QLabel *icon_pitch = new QLabel;
|
justin@156
|
911 icon_pitch->setFixedWidth(40);
|
justin@156
|
912 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
913 icon_pitch->setPixmap(il.loadPixmap("values"));
|
justin@156
|
914 toolbar->addWidget(icon_pitch);
|
justin@156
|
915
|
justin@156
|
916 m_showPitch = toolbar->addAction(il.load("eye"), tr("Show Pitch Track"));
|
justin@156
|
917 m_showPitch->setCheckable(true);
|
justin@156
|
918 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
justin@156
|
919 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
justin@156
|
920
|
justin@156
|
921 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
|
justin@156
|
922 m_playPitch->setCheckable(true);
|
justin@156
|
923 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
justin@156
|
924 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
|
justin@156
|
925
|
Chris@158
|
926 toolbar->addWidget(m_gainPitch);
|
justin@160
|
927 toolbar->addWidget(m_panPitch);
|
justin@156
|
928
|
justin@156
|
929 // Notes
|
justin@156
|
930 QLabel *icon_notes = new QLabel;
|
justin@156
|
931 icon_notes->setFixedWidth(40);
|
justin@156
|
932 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
933 icon_notes->setPixmap(il.loadPixmap("notes"));
|
justin@156
|
934 toolbar->addWidget(icon_notes);
|
justin@156
|
935
|
justin@156
|
936 m_showNotes = toolbar->addAction(il.load("eye"), tr("Show Notes"));
|
justin@156
|
937 m_showNotes->setCheckable(true);
|
justin@156
|
938 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
justin@156
|
939 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
justin@156
|
940
|
justin@156
|
941 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes"));
|
justin@156
|
942 m_playNotes->setCheckable(true);
|
justin@156
|
943 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
justin@156
|
944 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
945
|
justin@159
|
946 toolbar->addWidget(m_gainNotes);
|
justin@160
|
947 toolbar->addWidget(m_panNotes);
|
justin@159
|
948
|
justin@156
|
949 // Spectrogram
|
justin@156
|
950 QLabel *icon_spectrogram = new QLabel;
|
justin@156
|
951 icon_spectrogram->setFixedWidth(40);
|
justin@156
|
952 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
953 icon_spectrogram->setPixmap(il.loadPixmap("spectrogram"));
|
justin@156
|
954 toolbar->addWidget(icon_spectrogram);
|
justin@156
|
955
|
justin@156
|
956 m_showSpect = toolbar->addAction(il.load("eye"), tr("Show Spectrogram"));
|
justin@156
|
957 m_showSpect->setCheckable(true);
|
justin@156
|
958 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
justin@156
|
959 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@128
|
960
|
Chris@0
|
961 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
962 }
|
Chris@0
|
963
|
Chris@0
|
964 void
|
Chris@70
|
965 MainWindow::toolNavigateSelected()
|
Chris@70
|
966 {
|
Chris@70
|
967 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@70
|
968 m_intelligentActionOn = true;
|
Chris@70
|
969 }
|
Chris@70
|
970
|
Chris@70
|
971 void
|
Chris@70
|
972 MainWindow::toolEditSelected()
|
Chris@70
|
973 {
|
Chris@77
|
974 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
975 m_intelligentActionOn = true;
|
Chris@70
|
976 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
977 }
|
Chris@70
|
978
|
Chris@70
|
979 void
|
Chris@70
|
980 MainWindow::toolFreeEditSelected()
|
Chris@70
|
981 {
|
Chris@77
|
982 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
983 m_intelligentActionOn = false;
|
Chris@70
|
984 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
985 }
|
Chris@70
|
986
|
gyorgyf@21
|
987 void
|
Chris@0
|
988 MainWindow::updateMenuStates()
|
Chris@0
|
989 {
|
Chris@0
|
990 MainWindowBase::updateMenuStates();
|
Chris@0
|
991
|
Chris@0
|
992 Pane *currentPane = 0;
|
Chris@0
|
993 Layer *currentLayer = 0;
|
Chris@0
|
994
|
Chris@0
|
995 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
996 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@0
|
997
|
Chris@0
|
998 bool haveCurrentPane =
|
Chris@0
|
999 (currentPane != 0);
|
Chris@0
|
1000 bool haveCurrentLayer =
|
Chris@0
|
1001 (haveCurrentPane &&
|
Chris@0
|
1002 (currentLayer != 0));
|
Chris@0
|
1003 bool haveSelection =
|
gyorgyf@27
|
1004 (m_viewManager &&
|
gyorgyf@27
|
1005 !m_viewManager->getSelections().empty());
|
Chris@0
|
1006 bool haveCurrentEditableLayer =
|
gyorgyf@27
|
1007 (haveCurrentLayer &&
|
gyorgyf@27
|
1008 currentLayer->isLayerEditable());
|
Chris@0
|
1009 bool haveCurrentTimeInstantsLayer =
|
gyorgyf@27
|
1010 (haveCurrentLayer &&
|
gyorgyf@27
|
1011 qobject_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
1012 bool haveCurrentTimeValueLayer =
|
gyorgyf@27
|
1013 (haveCurrentLayer &&
|
gyorgyf@27
|
1014 qobject_cast<TimeValueLayer *>(currentLayer));
|
Chris@0
|
1015
|
Chris@0
|
1016 emit canChangePlaybackSpeed(true);
|
Chris@0
|
1017 int v = m_playSpeed->value();
|
Chris@0
|
1018 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@0
|
1019 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@0
|
1020
|
Chris@0
|
1021 if (m_ffwdAction && m_rwdAction) {
|
Chris@0
|
1022 if (haveCurrentTimeInstantsLayer) {
|
Chris@0
|
1023 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@0
|
1024 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1025 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@0
|
1026 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1027 } else if (haveCurrentTimeValueLayer) {
|
Chris@0
|
1028 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@0
|
1029 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@0
|
1030 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@0
|
1031 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@0
|
1032 } else {
|
Chris@0
|
1033 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@0
|
1034 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@0
|
1035 m_rwdAction->setText(tr("Rewind"));
|
Chris@0
|
1036 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@0
|
1037 }
|
Chris@0
|
1038 }
|
Chris@0
|
1039 }
|
Chris@0
|
1040
|
Chris@0
|
1041 void
|
Chris@144
|
1042 MainWindow::showAudioToggled()
|
Chris@128
|
1043 {
|
Chris@144
|
1044 m_analyser->toggleVisible(Analyser::Audio);
|
Chris@128
|
1045 }
|
Chris@128
|
1046
|
Chris@128
|
1047 void
|
Chris@144
|
1048 MainWindow::showPitchToggled()
|
Chris@128
|
1049 {
|
Chris@144
|
1050 m_analyser->toggleVisible(Analyser::PitchTrack);
|
Chris@128
|
1051 }
|
Chris@128
|
1052
|
Chris@128
|
1053 void
|
Chris@145
|
1054 MainWindow::showSpectToggled()
|
Chris@145
|
1055 {
|
Chris@145
|
1056 m_analyser->toggleVisible(Analyser::Spectrogram);
|
Chris@145
|
1057 }
|
Chris@145
|
1058
|
Chris@145
|
1059 void
|
Chris@144
|
1060 MainWindow::showNotesToggled()
|
Chris@128
|
1061 {
|
Chris@144
|
1062 m_analyser->toggleVisible(Analyser::Notes);
|
Chris@144
|
1063 }
|
Chris@144
|
1064
|
Chris@144
|
1065 void
|
Chris@144
|
1066 MainWindow::playAudioToggled()
|
Chris@144
|
1067 {
|
Chris@144
|
1068 m_analyser->toggleAudible(Analyser::Audio);
|
Chris@144
|
1069 }
|
Chris@144
|
1070
|
Chris@144
|
1071 void
|
Chris@144
|
1072 MainWindow::playPitchToggled()
|
Chris@144
|
1073 {
|
Chris@144
|
1074 m_analyser->toggleAudible(Analyser::PitchTrack);
|
Chris@144
|
1075 }
|
Chris@144
|
1076
|
Chris@144
|
1077 void
|
Chris@144
|
1078 MainWindow::playNotesToggled()
|
Chris@144
|
1079 {
|
Chris@144
|
1080 m_analyser->toggleAudible(Analyser::Notes);
|
Chris@144
|
1081 }
|
Chris@144
|
1082
|
Chris@144
|
1083 void
|
Chris@144
|
1084 MainWindow::updateLayerStatuses()
|
Chris@144
|
1085 {
|
Chris@144
|
1086 m_showAudio->setChecked(m_analyser->isVisible(Analyser::Audio));
|
Chris@145
|
1087 m_showSpect->setChecked(m_analyser->isVisible(Analyser::Spectrogram));
|
Chris@144
|
1088 m_showPitch->setChecked(m_analyser->isVisible(Analyser::PitchTrack));
|
Chris@144
|
1089 m_showNotes->setChecked(m_analyser->isVisible(Analyser::Notes));
|
Chris@144
|
1090 m_playAudio->setChecked(m_analyser->isAudible(Analyser::Audio));
|
Chris@144
|
1091 m_playPitch->setChecked(m_analyser->isAudible(Analyser::PitchTrack));
|
Chris@144
|
1092 m_playNotes->setChecked(m_analyser->isAudible(Analyser::Notes));
|
Chris@128
|
1093 }
|
Chris@128
|
1094
|
Chris@128
|
1095 void
|
Chris@0
|
1096 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1097 {
|
Chris@6
|
1098 // Nothing, we don't have one
|
Chris@0
|
1099 }
|
Chris@0
|
1100
|
Chris@0
|
1101 void
|
Chris@0
|
1102 MainWindow::documentModified()
|
Chris@0
|
1103 {
|
Chris@0
|
1104 MainWindowBase::documentModified();
|
Chris@0
|
1105 }
|
Chris@0
|
1106
|
Chris@0
|
1107 void
|
Chris@0
|
1108 MainWindow::documentRestored()
|
Chris@0
|
1109 {
|
Chris@0
|
1110 MainWindowBase::documentRestored();
|
Chris@0
|
1111 }
|
Chris@0
|
1112
|
Chris@0
|
1113 void
|
Chris@0
|
1114 MainWindow::newSession()
|
Chris@0
|
1115 {
|
Chris@0
|
1116 if (!checkSaveModified()) return;
|
Chris@0
|
1117
|
Chris@0
|
1118 closeSession();
|
Chris@0
|
1119 createDocument();
|
Chris@0
|
1120 m_document->setAutoAlignment(true);
|
Chris@0
|
1121
|
Chris@0
|
1122 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
1123
|
Chris@0
|
1124 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
1125 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
1126
|
Chris@6
|
1127 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@6
|
1128 // m_document->addLayerToView(pane, waveform);
|
Chris@0
|
1129
|
Chris@0
|
1130 m_overview->registerView(pane);
|
Chris@0
|
1131
|
Chris@0
|
1132 CommandHistory::getInstance()->clear();
|
Chris@0
|
1133 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1134 documentRestored();
|
Chris@0
|
1135 updateMenuStates();
|
Chris@0
|
1136 }
|
Chris@0
|
1137
|
Chris@0
|
1138 void
|
Chris@0
|
1139 MainWindow::closeSession()
|
Chris@0
|
1140 {
|
Chris@0
|
1141 if (!checkSaveModified()) return;
|
Chris@0
|
1142
|
Chris@0
|
1143 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
1144
|
Chris@167
|
1145 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
1146
|
Chris@167
|
1147 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1148 m_document->removeLayerFromView
|
Chris@167
|
1149 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1150 }
|
Chris@167
|
1151
|
Chris@167
|
1152 m_overview->unregisterView(pane);
|
Chris@167
|
1153 m_paneStack->deletePane(pane);
|
Chris@0
|
1154 }
|
Chris@0
|
1155
|
Chris@0
|
1156 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
1157
|
Chris@167
|
1158 Pane *pane = m_paneStack->getHiddenPane
|
Chris@167
|
1159 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@167
|
1160
|
Chris@167
|
1161 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1162 m_document->removeLayerFromView
|
Chris@167
|
1163 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1164 }
|
Chris@167
|
1165
|
Chris@167
|
1166 m_overview->unregisterView(pane);
|
Chris@167
|
1167 m_paneStack->deletePane(pane);
|
Chris@0
|
1168 }
|
Chris@0
|
1169
|
Chris@0
|
1170 delete m_document;
|
Chris@0
|
1171 m_document = 0;
|
Chris@0
|
1172 m_viewManager->clearSelections();
|
Chris@0
|
1173 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
1174
|
Chris@0
|
1175 m_sessionFile = "";
|
Chris@0
|
1176
|
Chris@0
|
1177 CommandHistory::getInstance()->clear();
|
Chris@0
|
1178 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1179 documentRestored();
|
Chris@0
|
1180 }
|
Chris@0
|
1181
|
Chris@0
|
1182 void
|
Chris@0
|
1183 MainWindow::openFile()
|
Chris@0
|
1184 {
|
Chris@0
|
1185 QString orig = m_audioFile;
|
Chris@0
|
1186 if (orig == "") orig = ".";
|
Chris@0
|
1187 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1188
|
Chris@0
|
1189 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
1190
|
Chris@0
|
1191 if (path.isEmpty()) return;
|
Chris@0
|
1192
|
Chris@1
|
1193 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1194
|
Chris@0
|
1195 if (status == FileOpenFailed) {
|
Chris@0
|
1196 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1197 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@0
|
1198 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1199 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1200 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1201 }
|
Chris@0
|
1202 }
|
Chris@0
|
1203
|
Chris@0
|
1204 void
|
Chris@0
|
1205 MainWindow::openLocation()
|
Chris@0
|
1206 {
|
Chris@0
|
1207 QSettings settings;
|
Chris@0
|
1208 settings.beginGroup("MainWindow");
|
Chris@0
|
1209 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@0
|
1210
|
Chris@0
|
1211 bool ok = false;
|
Chris@0
|
1212 QString text = QInputDialog::getText
|
Chris@0
|
1213 (this, tr("Open Location"),
|
Chris@0
|
1214 tr("Please enter the URL of the location to open:"),
|
Chris@0
|
1215 QLineEdit::Normal, lastLocation, &ok);
|
Chris@0
|
1216
|
Chris@0
|
1217 if (!ok) return;
|
Chris@0
|
1218
|
Chris@0
|
1219 settings.setValue("lastremote", text);
|
Chris@0
|
1220
|
Chris@0
|
1221 if (text.isEmpty()) return;
|
Chris@0
|
1222
|
Chris@1
|
1223 FileOpenStatus status = open(text, ReplaceSession);
|
Chris@0
|
1224
|
Chris@0
|
1225 if (status == FileOpenFailed) {
|
Chris@0
|
1226 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1227 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@0
|
1228 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1229 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1230 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1231 }
|
Chris@0
|
1232 }
|
Chris@0
|
1233
|
Chris@0
|
1234 void
|
Chris@0
|
1235 MainWindow::openRecentFile()
|
Chris@0
|
1236 {
|
Chris@0
|
1237 QObject *obj = sender();
|
Chris@3
|
1238 QAction *action = qobject_cast<QAction *>(obj);
|
Chris@0
|
1239
|
Chris@0
|
1240 if (!action) {
|
Chris@70
|
1241 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@70
|
1242 << endl;
|
gyorgyf@27
|
1243 return;
|
Chris@0
|
1244 }
|
Chris@0
|
1245
|
Chris@0
|
1246 QString path = action->text();
|
Chris@0
|
1247 if (path == "") return;
|
Chris@0
|
1248
|
Chris@1
|
1249 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1250
|
Chris@0
|
1251 if (status == FileOpenFailed) {
|
Chris@0
|
1252 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1253 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@0
|
1254 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1255 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1256 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1257 }
|
Chris@0
|
1258 }
|
Chris@0
|
1259
|
Chris@0
|
1260 void
|
Chris@0
|
1261 MainWindow::paneAdded(Pane *pane)
|
Chris@0
|
1262 {
|
Chris@6
|
1263 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
1264 m_paneStack->sizePanesEqually();
|
Chris@0
|
1265 if (m_overview) m_overview->registerView(pane);
|
Chris@0
|
1266 }
|
Chris@0
|
1267
|
Chris@0
|
1268 void
|
Chris@0
|
1269 MainWindow::paneHidden(Pane *pane)
|
Chris@0
|
1270 {
|
Chris@0
|
1271 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1272 }
|
Chris@0
|
1273
|
Chris@0
|
1274 void
|
Chris@0
|
1275 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@0
|
1276 {
|
Chris@0
|
1277 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1278 }
|
Chris@0
|
1279
|
Chris@0
|
1280 void
|
Chris@0
|
1281 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@0
|
1282 {
|
Chris@4
|
1283 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1284
|
Chris@0
|
1285 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@0
|
1286
|
Chris@1
|
1287 FileOpenStatus status = open(*i, ReplaceSession);
|
Chris@0
|
1288
|
Chris@0
|
1289 if (status == FileOpenFailed) {
|
Chris@0
|
1290 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1291 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@0
|
1292 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1293 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1294 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1295 }
|
Chris@0
|
1296 }
|
Chris@0
|
1297 }
|
Chris@0
|
1298
|
Chris@0
|
1299 void
|
Chris@0
|
1300 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@0
|
1301 {
|
Chris@0
|
1302 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1303
|
Chris@0
|
1304 QUrl testUrl(text);
|
Chris@0
|
1305 if (testUrl.scheme() == "file" ||
|
Chris@0
|
1306 testUrl.scheme() == "http" ||
|
Chris@0
|
1307 testUrl.scheme() == "ftp") {
|
Chris@0
|
1308 QStringList list;
|
Chris@0
|
1309 list.push_back(text);
|
Chris@0
|
1310 paneDropAccepted(pane, list);
|
Chris@0
|
1311 return;
|
Chris@0
|
1312 }
|
Chris@0
|
1313
|
Chris@0
|
1314 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@0
|
1315 //to a text layer?
|
Chris@0
|
1316 }
|
Chris@0
|
1317
|
Chris@0
|
1318 void
|
Chris@0
|
1319 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
1320 {
|
Chris@70
|
1321 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@0
|
1322
|
Chris@0
|
1323 if (m_openingAudioFile) {
|
Chris@70
|
1324 // cerr << "Busy - ignoring close event" << endl;
|
gyorgyf@27
|
1325 e->ignore();
|
gyorgyf@27
|
1326 return;
|
Chris@0
|
1327 }
|
Chris@0
|
1328
|
Chris@0
|
1329 if (!m_abandoning && !checkSaveModified()) {
|
Chris@70
|
1330 // cerr << "Ignoring close event" << endl;
|
gyorgyf@27
|
1331 e->ignore();
|
gyorgyf@27
|
1332 return;
|
Chris@0
|
1333 }
|
Chris@0
|
1334
|
Chris@0
|
1335 QSettings settings;
|
Chris@0
|
1336 settings.beginGroup("MainWindow");
|
Chris@0
|
1337 settings.setValue("size", size());
|
Chris@0
|
1338 settings.setValue("position", pos());
|
Chris@0
|
1339 settings.endGroup();
|
Chris@0
|
1340
|
Chris@0
|
1341 delete m_keyReference;
|
Chris@0
|
1342 m_keyReference = 0;
|
Chris@0
|
1343
|
Chris@0
|
1344 closeSession();
|
Chris@0
|
1345
|
Chris@0
|
1346 e->accept();
|
Chris@0
|
1347 return;
|
Chris@0
|
1348 }
|
Chris@0
|
1349
|
Chris@0
|
1350 bool
|
Chris@0
|
1351 MainWindow::commitData(bool mayAskUser)
|
Chris@0
|
1352 {
|
Chris@0
|
1353 if (mayAskUser) {
|
Chris@0
|
1354 bool rv = checkSaveModified();
|
Chris@0
|
1355 return rv;
|
Chris@0
|
1356 } else {
|
Chris@0
|
1357 if (!m_documentModified) return true;
|
Chris@0
|
1358
|
Chris@0
|
1359 // If we can't check with the user first, then we can't save
|
Chris@0
|
1360 // to the original session file (even if we have it) -- have
|
Chris@0
|
1361 // to use a temporary file
|
Chris@0
|
1362
|
Chris@0
|
1363 QString svDirBase = ".sv1";
|
Chris@0
|
1364 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@0
|
1365
|
Chris@0
|
1366 if (!QFileInfo(svDir).exists()) {
|
Chris@0
|
1367 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@0
|
1368 } else {
|
Chris@0
|
1369 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@0
|
1370 }
|
Chris@0
|
1371
|
Chris@0
|
1372 // This name doesn't have to be unguessable
|
Chris@0
|
1373 #ifndef _WIN32
|
Chris@0
|
1374 QString fname = QString("tmp-%1-%2.sv")
|
Chris@0
|
1375 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@0
|
1376 .arg(QProcess().pid());
|
Chris@0
|
1377 #else
|
Chris@0
|
1378 QString fname = QString("tmp-%1.sv")
|
Chris@0
|
1379 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@0
|
1380 #endif
|
Chris@0
|
1381 QString fpath = QDir(svDir).filePath(fname);
|
Chris@0
|
1382 if (saveSessionFile(fpath)) {
|
Chris@0
|
1383 m_recentFiles.addFile(fpath);
|
Chris@0
|
1384 return true;
|
Chris@0
|
1385 } else {
|
Chris@0
|
1386 return false;
|
Chris@0
|
1387 }
|
Chris@0
|
1388 }
|
Chris@0
|
1389 }
|
Chris@0
|
1390
|
Chris@0
|
1391 bool
|
Chris@0
|
1392 MainWindow::checkSaveModified()
|
Chris@0
|
1393 {
|
Chris@0
|
1394 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
1395 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
1396 // cancel.
|
Chris@0
|
1397
|
Chris@0
|
1398 if (!m_documentModified) return true;
|
Chris@0
|
1399
|
Chris@0
|
1400 int button =
|
gyorgyf@27
|
1401 QMessageBox::warning(this,
|
gyorgyf@27
|
1402 tr("Session modified"),
|
gyorgyf@27
|
1403 tr("The current session has been modified.\nDo you want to save it?"),
|
gyorgyf@27
|
1404 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@0
|
1405 QMessageBox::Yes);
|
Chris@0
|
1406
|
Chris@0
|
1407 if (button == QMessageBox::Yes) {
|
gyorgyf@27
|
1408 saveSession();
|
gyorgyf@27
|
1409 if (m_documentModified) { // save failed -- don't proceed!
|
gyorgyf@27
|
1410 return false;
|
gyorgyf@27
|
1411 } else {
|
Chris@0
|
1412 return true; // saved, so it's safe to continue now
|
Chris@0
|
1413 }
|
Chris@0
|
1414 } else if (button == QMessageBox::No) {
|
gyorgyf@27
|
1415 m_documentModified = false; // so we know to abandon it
|
gyorgyf@27
|
1416 return true;
|
Chris@0
|
1417 }
|
Chris@0
|
1418
|
Chris@0
|
1419 // else cancel
|
Chris@0
|
1420 return false;
|
Chris@0
|
1421 }
|
Chris@0
|
1422
|
Chris@0
|
1423 void
|
Chris@0
|
1424 MainWindow::saveSession()
|
Chris@0
|
1425 {
|
Chris@0
|
1426 if (m_sessionFile != "") {
|
gyorgyf@27
|
1427 if (!saveSessionFile(m_sessionFile)) {
|
gyorgyf@27
|
1428 QMessageBox::critical(this, tr("Failed to save file"),
|
gyorgyf@27
|
1429 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
1430 } else {
|
gyorgyf@27
|
1431 CommandHistory::getInstance()->documentSaved();
|
gyorgyf@27
|
1432 documentRestored();
|
gyorgyf@27
|
1433 }
|
gyorgyf@27
|
1434 } else {
|
gyorgyf@27
|
1435 saveSessionAs();
|
Chris@0
|
1436 }
|
Chris@0
|
1437 }
|
Chris@0
|
1438
|
Chris@0
|
1439 void
|
Chris@0
|
1440 MainWindow::saveSessionAs()
|
Chris@0
|
1441 {
|
Chris@0
|
1442 QString orig = m_audioFile;
|
Chris@0
|
1443 if (orig == "") orig = ".";
|
Chris@0
|
1444 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1445
|
Chris@0
|
1446 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@0
|
1447
|
Chris@0
|
1448 if (path == "") return;
|
Chris@0
|
1449
|
Chris@0
|
1450 if (!saveSessionFile(path)) {
|
Chris@85
|
1451 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@85
|
1452 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
1453 } else {
|
Chris@85
|
1454 setWindowTitle(tr("%1: %2")
|
Chris@0
|
1455 .arg(QApplication::applicationName())
|
Chris@85
|
1456 .arg(QFileInfo(path).fileName()));
|
Chris@85
|
1457 m_sessionFile = path;
|
Chris@85
|
1458 CommandHistory::getInstance()->documentSaved();
|
Chris@85
|
1459 documentRestored();
|
Chris@0
|
1460 m_recentFiles.addFile(path);
|
Chris@0
|
1461 }
|
Chris@0
|
1462 }
|
Chris@0
|
1463
|
Chris@85
|
1464 QString
|
Chris@85
|
1465 MainWindow::exportToSVL(QString path, Layer *layer)
|
Chris@85
|
1466 {
|
Chris@85
|
1467 Model *model = layer->getModel();
|
Chris@85
|
1468
|
Chris@85
|
1469 QFile file(path);
|
Chris@85
|
1470 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@85
|
1471 return tr("Failed to open file %1 for writing").arg(path);
|
Chris@85
|
1472 } else {
|
Chris@85
|
1473 QTextStream out(&file);
|
Chris@85
|
1474 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@85
|
1475 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@85
|
1476 << "<sv>\n"
|
Chris@85
|
1477 << " <data>\n";
|
Chris@85
|
1478
|
Chris@85
|
1479 model->toXml(out, " ");
|
Chris@85
|
1480
|
Chris@85
|
1481 out << " </data>\n"
|
Chris@85
|
1482 << " <display>\n";
|
Chris@85
|
1483
|
Chris@85
|
1484 layer->toXml(out, " ");
|
Chris@85
|
1485
|
Chris@85
|
1486 out << " </display>\n"
|
Chris@85
|
1487 << "</sv>\n";
|
Chris@85
|
1488
|
Chris@85
|
1489 return "";
|
Chris@85
|
1490 }
|
Chris@85
|
1491 }
|
Chris@85
|
1492
|
Chris@0
|
1493 void
|
Chris@174
|
1494 MainWindow::importPitchLayer()
|
Chris@174
|
1495 {
|
Chris@174
|
1496 QString path = getOpenFileName(FileFinder::LayerFileNoMidiNonSV);
|
Chris@174
|
1497 if (path == "") return;
|
Chris@174
|
1498
|
Chris@174
|
1499 FileOpenStatus status = importPitchLayer(path);
|
Chris@174
|
1500
|
Chris@174
|
1501 if (status == FileOpenFailed) {
|
Chris@174
|
1502 emit hideSplash();
|
Chris@174
|
1503 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1504 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@174
|
1505 return;
|
Chris@174
|
1506 } else if (status == FileOpenWrongMode) {
|
Chris@174
|
1507 emit hideSplash();
|
Chris@174
|
1508 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1509 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
|
1510 }
|
Chris@174
|
1511 }
|
Chris@174
|
1512
|
Chris@174
|
1513 MainWindow::FileOpenStatus
|
Chris@174
|
1514 MainWindow::importPitchLayer(FileSource source)
|
Chris@174
|
1515 {
|
Chris@174
|
1516 if (!source.isAvailable()) return FileOpenFailed;
|
Chris@174
|
1517 source.waitForData();
|
Chris@174
|
1518
|
Chris@174
|
1519 QString path = source.getLocalFilename();
|
Chris@174
|
1520
|
Chris@174
|
1521 RDFImporter::RDFDocumentType rdfType =
|
Chris@174
|
1522 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString());
|
Chris@174
|
1523
|
Chris@174
|
1524 if (rdfType != RDFImporter::NotRDF) {
|
Chris@174
|
1525
|
Chris@174
|
1526 //!!!
|
Chris@174
|
1527 return FileOpenFailed;
|
Chris@174
|
1528
|
Chris@174
|
1529 } else if (source.getExtension().toLower() == "svl" ||
|
Chris@174
|
1530 (source.getExtension().toLower() == "xml" &&
|
Chris@174
|
1531 (SVFileReader::identifyXmlFile(source.getLocalFilename())
|
Chris@174
|
1532 == SVFileReader::SVLayerFile))) {
|
Chris@174
|
1533
|
Chris@174
|
1534 //!!!
|
Chris@174
|
1535 return FileOpenFailed;
|
Chris@174
|
1536
|
Chris@174
|
1537 } else {
|
Chris@174
|
1538
|
Chris@174
|
1539 try {
|
Chris@174
|
1540
|
Chris@174
|
1541 CSVFormat format(path);
|
Chris@174
|
1542 format.setSampleRate(getMainModel()->getSampleRate());
|
Chris@174
|
1543
|
Chris@174
|
1544 if (format.getModelType() != CSVFormat::TwoDimensionalModel) {
|
Chris@174
|
1545 //!!! error report
|
Chris@174
|
1546 return FileOpenFailed;
|
Chris@174
|
1547 }
|
Chris@174
|
1548
|
Chris@174
|
1549 Model *model = DataFileReaderFactory::loadCSV
|
Chris@174
|
1550 (path, format, getMainModel()->getSampleRate());
|
Chris@174
|
1551
|
Chris@174
|
1552 if (model) {
|
Chris@174
|
1553
|
Chris@174
|
1554 SVDEBUG << "MainWindow::importPitchLayer: Have model" << endl;
|
Chris@174
|
1555
|
Chris@174
|
1556 CommandHistory::getInstance()->startCompoundOperation
|
Chris@174
|
1557 (tr("Import Pitch Track"), true);
|
Chris@174
|
1558
|
Chris@174
|
1559 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@174
|
1560
|
Chris@174
|
1561 m_analyser->takePitchTrackFrom(newLayer);
|
Chris@174
|
1562
|
Chris@174
|
1563 m_document->deleteLayer(newLayer);
|
Chris@174
|
1564
|
Chris@174
|
1565 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@174
|
1566
|
Chris@174
|
1567 //!!! swap all data in to existing layer instead of this
|
Chris@174
|
1568
|
Chris@174
|
1569 m_recentFiles.addFile(source.getLocation());
|
Chris@174
|
1570
|
Chris@174
|
1571 if (!source.isRemote()) {
|
Chris@174
|
1572 registerLastOpenedFilePath
|
Chris@174
|
1573 (FileFinder::LayerFile,
|
Chris@174
|
1574 path); // for file dialog
|
Chris@174
|
1575 }
|
Chris@174
|
1576
|
Chris@174
|
1577 return FileOpenSucceeded;
|
Chris@174
|
1578 }
|
Chris@174
|
1579 } catch (DataFileReaderFactory::Exception e) {
|
Chris@174
|
1580 if (e == DataFileReaderFactory::ImportCancelled) {
|
Chris@174
|
1581 return FileOpenCancelled;
|
Chris@174
|
1582 }
|
Chris@174
|
1583 }
|
Chris@174
|
1584 }
|
Chris@174
|
1585
|
Chris@174
|
1586 return FileOpenFailed;
|
Chris@174
|
1587 }
|
Chris@174
|
1588
|
Chris@174
|
1589 void
|
Chris@85
|
1590 MainWindow::exportPitchLayer()
|
matthiasm@26
|
1591 {
|
Chris@174
|
1592 Layer *layer = m_analyser->getLayer(Analyser::PitchTrack);
|
matthiasm@26
|
1593 if (!layer) return;
|
matthiasm@26
|
1594
|
Chris@85
|
1595 SparseTimeValueModel *model =
|
Chris@85
|
1596 qobject_cast<SparseTimeValueModel *>(layer->getModel());
|
matthiasm@26
|
1597 if (!model) return;
|
matthiasm@26
|
1598
|
Chris@96
|
1599 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
|
matthiasm@26
|
1600
|
matthiasm@26
|
1601 QString path = getSaveFileName(type);
|
matthiasm@26
|
1602
|
matthiasm@26
|
1603 if (path == "") return;
|
matthiasm@26
|
1604
|
matthiasm@26
|
1605 if (QFileInfo(path).suffix() == "") path += ".svl";
|
matthiasm@26
|
1606
|
matthiasm@26
|
1607 QString suffix = QFileInfo(path).suffix().toLower();
|
matthiasm@26
|
1608
|
matthiasm@26
|
1609 QString error;
|
matthiasm@26
|
1610
|
matthiasm@26
|
1611 if (suffix == "xml" || suffix == "svl") {
|
matthiasm@26
|
1612
|
Chris@85
|
1613 error = exportToSVL(path, layer);
|
matthiasm@26
|
1614
|
matthiasm@26
|
1615 } else if (suffix == "ttl" || suffix == "n3") {
|
matthiasm@26
|
1616
|
Chris@85
|
1617 RDFExporter exporter(path, model);
|
Chris@85
|
1618 exporter.write();
|
Chris@85
|
1619 if (!exporter.isOK()) {
|
Chris@85
|
1620 error = exporter.getError();
|
Chris@85
|
1621 }
|
Chris@85
|
1622
|
Chris@85
|
1623 } else {
|
Chris@85
|
1624
|
Chris@85
|
1625 CSVFileWriter writer(path, model,
|
Chris@85
|
1626 ((suffix == "csv") ? "," : "\t"));
|
Chris@85
|
1627 writer.write();
|
Chris@85
|
1628
|
Chris@85
|
1629 if (!writer.isOK()) {
|
Chris@85
|
1630 error = writer.getError();
|
Chris@85
|
1631 }
|
Chris@85
|
1632 }
|
Chris@85
|
1633
|
Chris@85
|
1634 if (error != "") {
|
Chris@85
|
1635 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@85
|
1636 } else {
|
Chris@85
|
1637 m_recentFiles.addFile(path);
|
Chris@85
|
1638 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@85
|
1639 }
|
Chris@85
|
1640 }
|
Chris@85
|
1641
|
Chris@85
|
1642 void
|
Chris@85
|
1643 MainWindow::exportNoteLayer()
|
Chris@85
|
1644 {
|
Chris@174
|
1645 Layer *layer = m_analyser->getLayer(Analyser::Notes);
|
Chris@85
|
1646 if (!layer) return;
|
Chris@85
|
1647
|
Chris@85
|
1648 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
Chris@85
|
1649 if (!model) return;
|
Chris@85
|
1650
|
Chris@96
|
1651 FileFinder::FileType type = FileFinder::LayerFileNonSV;
|
Chris@85
|
1652
|
Chris@85
|
1653 QString path = getSaveFileName(type);
|
Chris@85
|
1654
|
Chris@85
|
1655 if (path == "") return;
|
Chris@85
|
1656
|
Chris@85
|
1657 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@85
|
1658
|
Chris@85
|
1659 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@85
|
1660
|
Chris@85
|
1661 QString error;
|
Chris@85
|
1662
|
Chris@85
|
1663 if (suffix == "xml" || suffix == "svl") {
|
Chris@85
|
1664
|
Chris@85
|
1665 error = exportToSVL(path, layer);
|
Chris@85
|
1666
|
Chris@85
|
1667 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@85
|
1668
|
Chris@85
|
1669 MIDIFileWriter writer(path, model, model->getSampleRate());
|
Chris@85
|
1670 writer.write();
|
Chris@85
|
1671 if (!writer.isOK()) {
|
Chris@85
|
1672 error = writer.getError();
|
Chris@85
|
1673 }
|
Chris@85
|
1674
|
Chris@85
|
1675 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@85
|
1676
|
Chris@85
|
1677 RDFExporter exporter(path, model);
|
Chris@85
|
1678 exporter.write();
|
Chris@85
|
1679 if (!exporter.isOK()) {
|
Chris@85
|
1680 error = exporter.getError();
|
matthiasm@26
|
1681 }
|
matthiasm@26
|
1682
|
matthiasm@26
|
1683 } else {
|
matthiasm@26
|
1684
|
matthiasm@26
|
1685 CSVFileWriter writer(path, model,
|
matthiasm@26
|
1686 ((suffix == "csv") ? "," : "\t"));
|
matthiasm@26
|
1687 writer.write();
|
matthiasm@26
|
1688
|
matthiasm@26
|
1689 if (!writer.isOK()) {
|
matthiasm@26
|
1690 error = writer.getError();
|
matthiasm@26
|
1691 }
|
matthiasm@26
|
1692 }
|
matthiasm@26
|
1693
|
matthiasm@26
|
1694 if (error != "") {
|
matthiasm@26
|
1695 QMessageBox::critical(this, tr("Failed to write file"), error);
|
matthiasm@26
|
1696 } else {
|
matthiasm@26
|
1697 m_recentFiles.addFile(path);
|
matthiasm@26
|
1698 emit activity(tr("Export layer to \"%1\"").arg(path));
|
matthiasm@26
|
1699 }
|
matthiasm@26
|
1700 }
|
matthiasm@26
|
1701
|
Chris@139
|
1702 void
|
Chris@139
|
1703 MainWindow::doubleClickSelectInvoked(size_t frame)
|
Chris@139
|
1704 {
|
Chris@139
|
1705 size_t f0, f1;
|
Chris@139
|
1706 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
|
Chris@139
|
1707
|
Chris@139
|
1708 cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl;
|
Chris@139
|
1709
|
Chris@164
|
1710 Selection sel(f0, f1);
|
Chris@164
|
1711 m_viewManager->setSelection(sel);
|
Chris@164
|
1712 }
|
Chris@164
|
1713
|
Chris@164
|
1714 void
|
Chris@167
|
1715 MainWindow::clearSelection()
|
Chris@167
|
1716 {
|
Chris@167
|
1717 cerr << "MainWindow::clearSelection()" << endl;
|
Chris@167
|
1718
|
Chris@168
|
1719 CommandHistory::getInstance()->startCompoundOperation(tr("Clear Selection"), true);
|
Chris@168
|
1720
|
Chris@167
|
1721 m_analyser->clearReAnalysis();
|
Chris@167
|
1722 MainWindowBase::clearSelection();
|
Chris@168
|
1723
|
Chris@168
|
1724 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
1725 }
|
Chris@167
|
1726
|
Chris@167
|
1727 void
|
Chris@164
|
1728 MainWindow::selectionChanged()
|
Chris@164
|
1729 {
|
Chris@164
|
1730 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@164
|
1731
|
Chris@164
|
1732 cerr << "MainWindow::selectionChanged" << endl;
|
Chris@164
|
1733
|
Chris@164
|
1734 if (!selections.empty()) {
|
Chris@164
|
1735 Selection sel = *selections.begin();
|
Chris@164
|
1736 cerr << "MainWindow::selectionChanged: have selection" << endl;
|
Chris@164
|
1737 QString error = m_analyser->reAnalyseSelection(sel);
|
Chris@164
|
1738 if (error != "") {
|
Chris@164
|
1739 QMessageBox::critical
|
Chris@164
|
1740 (this, tr("Failed to analyse selection"),
|
Chris@164
|
1741 tr("<b>Analysis failed</b><p>%2</p>").arg(error));
|
Chris@164
|
1742 }
|
Chris@164
|
1743 }
|
Chris@0
|
1744 }
|
Chris@0
|
1745
|
Chris@0
|
1746 void
|
Chris@168
|
1747 MainWindow::clearPitches()
|
Chris@168
|
1748 {
|
Chris@168
|
1749 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@168
|
1750
|
Chris@168
|
1751 CommandHistory::getInstance()->startCompoundOperation(tr("Clear Pitches"), true);
|
Chris@168
|
1752
|
Chris@168
|
1753 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
1754 k != selections.end(); ++k) {
|
Chris@168
|
1755 m_analyser->clearPitches(*k);
|
Chris@168
|
1756 }
|
Chris@168
|
1757
|
Chris@168
|
1758 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@168
|
1759 }
|
Chris@168
|
1760
|
Chris@168
|
1761 void
|
Chris@142
|
1762 MainWindow::octaveShiftUp()
|
Chris@142
|
1763 {
|
Chris@142
|
1764 octaveShift(true);
|
Chris@142
|
1765 }
|
Chris@142
|
1766
|
Chris@142
|
1767 void
|
Chris@142
|
1768 MainWindow::octaveShiftDown()
|
Chris@142
|
1769 {
|
Chris@142
|
1770 octaveShift(false);
|
Chris@142
|
1771 }
|
Chris@142
|
1772
|
Chris@142
|
1773 void
|
Chris@142
|
1774 MainWindow::octaveShift(bool up)
|
Chris@142
|
1775 {
|
Chris@142
|
1776 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@142
|
1777
|
Chris@142
|
1778 CommandHistory::getInstance()->startCompoundOperation(tr("Octave Shift"), true);
|
Chris@142
|
1779
|
Chris@168
|
1780 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
1781 k != selections.end(); ++k) {
|
Chris@142
|
1782
|
Chris@168
|
1783 m_analyser->shiftOctave(*k, up);
|
Chris@142
|
1784 }
|
Chris@142
|
1785
|
Chris@142
|
1786 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@142
|
1787 }
|
Chris@142
|
1788
|
Chris@142
|
1789 void
|
Chris@168
|
1790 MainWindow::switchPitch()
|
Chris@167
|
1791 {
|
Chris@168
|
1792 CommandHistory::getInstance()->startCompoundOperation
|
Chris@168
|
1793 (tr("Switch Pitch Candidate"), true);
|
Chris@168
|
1794
|
Chris@167
|
1795 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@167
|
1796
|
Chris@167
|
1797 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@167
|
1798 k != selections.end(); ++k) {
|
Chris@167
|
1799 m_analyser->switchPitchCandidate(*k, true);
|
Chris@167
|
1800 }
|
Chris@167
|
1801
|
Chris@168
|
1802 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
1803 }
|
Chris@167
|
1804
|
Chris@167
|
1805 void
|
Chris@0
|
1806 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
1807 {
|
Chris@0
|
1808 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@0
|
1809
|
Chris@0
|
1810 float percent = m_playSpeed->mappedValue();
|
Chris@0
|
1811 float factor = mapper.getFactorForValue(percent);
|
Chris@0
|
1812
|
Chris@70
|
1813 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
|
Chris@0
|
1814
|
Chris@0
|
1815 bool something = (position != 100);
|
Chris@0
|
1816
|
Chris@0
|
1817 int pc = lrintf(percent);
|
Chris@0
|
1818
|
Chris@0
|
1819 if (!something) {
|
Chris@0
|
1820 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@0
|
1821 } else {
|
Chris@0
|
1822 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@0
|
1823 .arg(position > 100 ? "+" : "")
|
Chris@0
|
1824 .arg(pc));
|
Chris@0
|
1825 }
|
Chris@0
|
1826
|
Chris@0
|
1827 m_playSource->setTimeStretch(factor);
|
Chris@0
|
1828
|
Chris@0
|
1829 updateMenuStates();
|
Chris@0
|
1830 }
|
Chris@0
|
1831
|
Chris@0
|
1832 void
|
Chris@0
|
1833 MainWindow::playSharpenToggled()
|
Chris@0
|
1834 {
|
Chris@0
|
1835 QSettings settings;
|
Chris@0
|
1836 settings.beginGroup("MainWindow");
|
Chris@0
|
1837 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@0
|
1838 settings.endGroup();
|
Chris@0
|
1839
|
Chris@0
|
1840 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
1841 // TODO: pitch gain?
|
Chris@0
|
1842 }
|
Chris@0
|
1843
|
Chris@0
|
1844 void
|
Chris@0
|
1845 MainWindow::playMonoToggled()
|
Chris@0
|
1846 {
|
Chris@0
|
1847 QSettings settings;
|
Chris@0
|
1848 settings.beginGroup("MainWindow");
|
Chris@0
|
1849 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@0
|
1850 settings.endGroup();
|
Chris@0
|
1851
|
Chris@0
|
1852 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
1853 // TODO: pitch gain?
|
Chris@0
|
1854 }
|
Chris@0
|
1855
|
Chris@0
|
1856 void
|
Chris@0
|
1857 MainWindow::speedUpPlayback()
|
Chris@0
|
1858 {
|
Chris@0
|
1859 int value = m_playSpeed->value();
|
Chris@0
|
1860 value = value + m_playSpeed->pageStep();
|
Chris@0
|
1861 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@0
|
1862 m_playSpeed->setValue(value);
|
Chris@0
|
1863 }
|
Chris@0
|
1864
|
Chris@0
|
1865 void
|
Chris@0
|
1866 MainWindow::slowDownPlayback()
|
Chris@0
|
1867 {
|
Chris@0
|
1868 int value = m_playSpeed->value();
|
Chris@0
|
1869 value = value - m_playSpeed->pageStep();
|
Chris@0
|
1870 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@0
|
1871 m_playSpeed->setValue(value);
|
Chris@0
|
1872 }
|
Chris@0
|
1873
|
Chris@0
|
1874 void
|
Chris@0
|
1875 MainWindow::restoreNormalPlayback()
|
Chris@0
|
1876 {
|
Chris@0
|
1877 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@0
|
1878 }
|
Chris@0
|
1879
|
justin@157
|
1880 void
|
justin@159
|
1881 MainWindow::audioGainChanged(int position)
|
justin@159
|
1882 {
|
justin@159
|
1883 float level = m_gainAudio->mappedValue();
|
justin@159
|
1884 float gain = powf(10, level / 20.0);
|
justin@159
|
1885
|
justin@159
|
1886 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
1887
|
justin@159
|
1888 contextHelpChanged(tr("Audio Gain: %1 dB").arg(position));
|
justin@159
|
1889
|
justin@159
|
1890 m_analyser->setGain(Analyser::Audio, gain);
|
justin@159
|
1891
|
justin@159
|
1892 updateMenuStates();
|
justin@159
|
1893 }
|
justin@159
|
1894
|
justin@159
|
1895 void
|
justin@159
|
1896 MainWindow::increaseAudioGain()
|
justin@159
|
1897 {
|
justin@159
|
1898 int value = m_gainAudio->value();
|
justin@159
|
1899 value = value + m_gainAudio->pageStep();
|
justin@159
|
1900 if (value > m_gainAudio->maximum()) value = m_gainAudio->maximum();
|
justin@159
|
1901 m_gainAudio->setValue(value);
|
justin@159
|
1902 }
|
justin@159
|
1903
|
justin@159
|
1904 void
|
justin@159
|
1905 MainWindow::decreaseAudioGain()
|
justin@159
|
1906 {
|
justin@159
|
1907 int value = m_gainAudio->value();
|
justin@159
|
1908 value = value - m_gainAudio->pageStep();
|
justin@159
|
1909 if (value < m_gainAudio->minimum()) value = m_gainAudio->minimum();
|
justin@159
|
1910 m_gainAudio->setValue(value);
|
justin@159
|
1911 }
|
justin@159
|
1912
|
justin@159
|
1913 void
|
justin@159
|
1914 MainWindow::restoreNormalAudioGain()
|
justin@159
|
1915 {
|
justin@159
|
1916 m_gainAudio->setValue(m_gainAudio->defaultValue());
|
justin@159
|
1917 }
|
justin@159
|
1918
|
justin@159
|
1919 void
|
justin@157
|
1920 MainWindow::pitchGainChanged(int position)
|
justin@157
|
1921 {
|
Chris@158
|
1922 float level = m_gainPitch->mappedValue();
|
Chris@158
|
1923 float gain = powf(10, level / 20.0);
|
justin@157
|
1924
|
Chris@158
|
1925 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@157
|
1926
|
Chris@158
|
1927 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position));
|
justin@157
|
1928
|
Chris@158
|
1929 m_analyser->setGain(Analyser::PitchTrack, gain);
|
justin@157
|
1930
|
justin@157
|
1931 updateMenuStates();
|
justin@157
|
1932 }
|
justin@157
|
1933
|
justin@157
|
1934 void
|
justin@157
|
1935 MainWindow::increasePitchGain()
|
justin@157
|
1936 {
|
justin@157
|
1937 int value = m_gainPitch->value();
|
justin@157
|
1938 value = value + m_gainPitch->pageStep();
|
justin@157
|
1939 if (value > m_gainPitch->maximum()) value = m_gainPitch->maximum();
|
justin@157
|
1940 m_gainPitch->setValue(value);
|
justin@157
|
1941 }
|
justin@157
|
1942
|
justin@157
|
1943 void
|
justin@157
|
1944 MainWindow::decreasePitchGain()
|
justin@157
|
1945 {
|
justin@157
|
1946 int value = m_gainPitch->value();
|
justin@157
|
1947 value = value - m_gainPitch->pageStep();
|
justin@157
|
1948 if (value < m_gainPitch->minimum()) value = m_gainPitch->minimum();
|
justin@157
|
1949 m_gainPitch->setValue(value);
|
justin@157
|
1950 }
|
justin@157
|
1951
|
justin@157
|
1952 void
|
justin@157
|
1953 MainWindow::restoreNormalPitchGain()
|
justin@157
|
1954 {
|
justin@157
|
1955 m_gainPitch->setValue(m_gainPitch->defaultValue());
|
justin@157
|
1956 }
|
justin@157
|
1957
|
Chris@0
|
1958 void
|
justin@159
|
1959 MainWindow::notesGainChanged(int position)
|
justin@159
|
1960 {
|
justin@159
|
1961 float level = m_gainNotes->mappedValue();
|
justin@159
|
1962 float gain = powf(10, level / 20.0);
|
justin@159
|
1963
|
justin@159
|
1964 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
1965
|
justin@159
|
1966 contextHelpChanged(tr("Notes Gain: %1 dB").arg(position));
|
justin@159
|
1967
|
justin@159
|
1968 m_analyser->setGain(Analyser::Notes, gain);
|
justin@159
|
1969
|
justin@159
|
1970 updateMenuStates();
|
justin@159
|
1971 }
|
justin@159
|
1972
|
justin@159
|
1973 void
|
justin@159
|
1974 MainWindow::increaseNotesGain()
|
justin@159
|
1975 {
|
justin@159
|
1976 int value = m_gainNotes->value();
|
justin@159
|
1977 value = value + m_gainNotes->pageStep();
|
justin@159
|
1978 if (value > m_gainNotes->maximum()) value = m_gainNotes->maximum();
|
justin@159
|
1979 m_gainNotes->setValue(value);
|
justin@159
|
1980 }
|
justin@159
|
1981
|
justin@159
|
1982 void
|
justin@159
|
1983 MainWindow::decreaseNotesGain()
|
justin@159
|
1984 {
|
justin@159
|
1985 int value = m_gainNotes->value();
|
justin@159
|
1986 value = value - m_gainNotes->pageStep();
|
justin@159
|
1987 if (value < m_gainNotes->minimum()) value = m_gainNotes->minimum();
|
justin@159
|
1988 m_gainNotes->setValue(value);
|
justin@159
|
1989 }
|
justin@159
|
1990
|
justin@159
|
1991 void
|
justin@159
|
1992 MainWindow::restoreNormalNotesGain()
|
justin@159
|
1993 {
|
justin@159
|
1994 m_gainNotes->setValue(m_gainNotes->defaultValue());
|
justin@159
|
1995 }
|
justin@159
|
1996
|
justin@159
|
1997 void
|
justin@160
|
1998 MainWindow::audioPanChanged(int position)
|
justin@160
|
1999 {
|
justin@160
|
2000 float level = m_panAudio->mappedValue();
|
justin@160
|
2001 float pan = level/100.f;
|
justin@160
|
2002
|
justin@160
|
2003 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2004
|
justin@160
|
2005 contextHelpChanged(tr("Audio Pan: %1").arg(position));
|
justin@160
|
2006
|
justin@160
|
2007 m_analyser->setPan(Analyser::Audio, pan);
|
justin@160
|
2008
|
justin@160
|
2009 updateMenuStates();
|
justin@160
|
2010 }
|
justin@160
|
2011
|
justin@160
|
2012 void
|
justin@160
|
2013 MainWindow::increaseAudioPan()
|
justin@160
|
2014 {
|
justin@160
|
2015 int value = m_panAudio->value();
|
justin@160
|
2016 value = value + m_panAudio->pageStep();
|
justin@160
|
2017 if (value > m_panAudio->maximum()) value = m_panAudio->maximum();
|
justin@160
|
2018 m_panAudio->setValue(value);
|
justin@160
|
2019 }
|
justin@160
|
2020
|
justin@160
|
2021 void
|
justin@160
|
2022 MainWindow::decreaseAudioPan()
|
justin@160
|
2023 {
|
justin@160
|
2024 int value = m_panAudio->value();
|
justin@160
|
2025 value = value - m_panAudio->pageStep();
|
justin@160
|
2026 if (value < m_panAudio->minimum()) value = m_panAudio->minimum();
|
justin@160
|
2027 m_panAudio->setValue(value);
|
justin@160
|
2028 }
|
justin@160
|
2029
|
justin@160
|
2030 void
|
justin@160
|
2031 MainWindow::restoreNormalAudioPan()
|
justin@160
|
2032 {
|
justin@160
|
2033 m_panAudio->setValue(m_panAudio->defaultValue());
|
justin@160
|
2034 }
|
justin@160
|
2035
|
justin@160
|
2036 void
|
justin@160
|
2037 MainWindow::pitchPanChanged(int position)
|
justin@160
|
2038 {
|
justin@160
|
2039 float level = m_panPitch->mappedValue();
|
justin@160
|
2040 float pan = level/100.f;
|
justin@160
|
2041
|
justin@160
|
2042 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2043
|
justin@160
|
2044 contextHelpChanged(tr("Pitch Pan: %1").arg(position));
|
justin@160
|
2045
|
justin@160
|
2046 m_analyser->setPan(Analyser::PitchTrack, pan);
|
justin@160
|
2047
|
justin@160
|
2048 updateMenuStates();
|
justin@160
|
2049 }
|
justin@160
|
2050
|
justin@160
|
2051 void
|
justin@160
|
2052 MainWindow::increasePitchPan()
|
justin@160
|
2053 {
|
justin@160
|
2054 int value = m_panPitch->value();
|
justin@160
|
2055 value = value + m_panPitch->pageStep();
|
justin@160
|
2056 if (value > m_panPitch->maximum()) value = m_panPitch->maximum();
|
justin@160
|
2057 m_panPitch->setValue(value);
|
justin@160
|
2058 }
|
justin@160
|
2059
|
justin@160
|
2060 void
|
justin@160
|
2061 MainWindow::decreasePitchPan()
|
justin@160
|
2062 {
|
justin@160
|
2063 int value = m_panPitch->value();
|
justin@160
|
2064 value = value - m_panPitch->pageStep();
|
justin@160
|
2065 if (value < m_panPitch->minimum()) value = m_panPitch->minimum();
|
justin@160
|
2066 m_panPitch->setValue(value);
|
justin@160
|
2067 }
|
justin@160
|
2068
|
justin@160
|
2069 void
|
justin@160
|
2070 MainWindow::restoreNormalPitchPan()
|
justin@160
|
2071 {
|
justin@160
|
2072 m_panPitch->setValue(m_panPitch->defaultValue());
|
justin@160
|
2073 }
|
justin@160
|
2074
|
justin@160
|
2075 void
|
justin@160
|
2076 MainWindow::notesPanChanged(int position)
|
justin@160
|
2077 {
|
justin@160
|
2078 float level = m_panNotes->mappedValue();
|
justin@160
|
2079 float pan = level/100.f;
|
justin@160
|
2080
|
justin@160
|
2081 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2082
|
justin@160
|
2083 contextHelpChanged(tr("Notes Pan: %1").arg(position));
|
justin@160
|
2084
|
justin@160
|
2085 m_analyser->setPan(Analyser::Notes, pan);
|
justin@160
|
2086
|
justin@160
|
2087 updateMenuStates();
|
justin@160
|
2088 }
|
justin@160
|
2089
|
justin@160
|
2090 void
|
justin@160
|
2091 MainWindow::increaseNotesPan()
|
justin@160
|
2092 {
|
justin@160
|
2093 int value = m_panNotes->value();
|
justin@160
|
2094 value = value + m_panNotes->pageStep();
|
justin@160
|
2095 if (value > m_panNotes->maximum()) value = m_panNotes->maximum();
|
justin@160
|
2096 m_panNotes->setValue(value);
|
justin@160
|
2097 }
|
justin@160
|
2098
|
justin@160
|
2099 void
|
justin@160
|
2100 MainWindow::decreaseNotesPan()
|
justin@160
|
2101 {
|
justin@160
|
2102 int value = m_panNotes->value();
|
justin@160
|
2103 value = value - m_panNotes->pageStep();
|
justin@160
|
2104 if (value < m_panNotes->minimum()) value = m_panNotes->minimum();
|
justin@160
|
2105 m_panNotes->setValue(value);
|
justin@160
|
2106 }
|
justin@160
|
2107
|
justin@160
|
2108 void
|
justin@160
|
2109 MainWindow::restoreNormalNotesPan()
|
justin@160
|
2110 {
|
justin@160
|
2111 m_panNotes->setValue(m_panNotes->defaultValue());
|
justin@160
|
2112 }
|
justin@160
|
2113
|
justin@160
|
2114 void
|
Chris@0
|
2115 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@0
|
2116 {
|
Chris@0
|
2117 if (!getMainModel() || !p) {
|
Chris@0
|
2118 return;
|
Chris@0
|
2119 }
|
Chris@0
|
2120
|
Chris@0
|
2121 bool haveSelection = false;
|
Chris@0
|
2122 size_t startFrame = 0, endFrame = 0;
|
Chris@0
|
2123
|
Chris@0
|
2124 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@0
|
2125
|
Chris@0
|
2126 bool exclusive = false;
|
Chris@0
|
2127 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@0
|
2128
|
Chris@0
|
2129 if (!s.isEmpty()) {
|
Chris@0
|
2130 haveSelection = true;
|
Chris@0
|
2131 startFrame = s.getStartFrame();
|
Chris@0
|
2132 endFrame = s.getEndFrame();
|
Chris@0
|
2133 }
|
Chris@0
|
2134 }
|
Chris@0
|
2135
|
Chris@0
|
2136 if (!haveSelection) {
|
Chris@0
|
2137 startFrame = p->getFirstVisibleFrame();
|
Chris@0
|
2138 endFrame = p->getLastVisibleFrame();
|
Chris@0
|
2139 }
|
Chris@0
|
2140
|
Chris@0
|
2141 RealTime start = RealTime::frame2RealTime
|
Chris@0
|
2142 (startFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2143
|
Chris@0
|
2144 RealTime end = RealTime::frame2RealTime
|
Chris@0
|
2145 (endFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2146
|
Chris@0
|
2147 RealTime duration = end - start;
|
Chris@0
|
2148
|
Chris@0
|
2149 QString startStr, endStr, durationStr;
|
Chris@0
|
2150 startStr = start.toText(true).c_str();
|
Chris@0
|
2151 endStr = end.toText(true).c_str();
|
Chris@0
|
2152 durationStr = duration.toText(true).c_str();
|
Chris@0
|
2153
|
Chris@0
|
2154 if (haveSelection) {
|
Chris@0
|
2155 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@0
|
2156 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2157 } else {
|
Chris@0
|
2158 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@0
|
2159 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2160 }
|
matthiasm@42
|
2161
|
matthiasm@42
|
2162 // scale Y axis
|
matthiasm@42
|
2163 FlexiNoteLayer *fnl = dynamic_cast<FlexiNoteLayer *>(p->getLayer(2));
|
matthiasm@42
|
2164 if (fnl) {
|
matthiasm@42
|
2165 fnl->setVerticalRangeToNoteRange(p);
|
matthiasm@42
|
2166 }
|
matthiasm@42
|
2167
|
Chris@0
|
2168 statusBar()->showMessage(m_myStatusMessage);
|
Chris@0
|
2169 }
|
Chris@0
|
2170
|
Chris@0
|
2171 void
|
Chris@0
|
2172 MainWindow::updatePositionStatusDisplays() const
|
Chris@0
|
2173 {
|
Chris@0
|
2174 if (!statusBar()->isVisible()) return;
|
Chris@0
|
2175
|
Chris@0
|
2176 }
|
Chris@0
|
2177
|
Chris@0
|
2178 void
|
Chris@0
|
2179 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
2180 {
|
Chris@0
|
2181 m_fader->setPeakLeft(left);
|
Chris@0
|
2182 m_fader->setPeakRight(right);
|
Chris@0
|
2183 }
|
Chris@0
|
2184
|
Chris@0
|
2185 void
|
Chris@0
|
2186 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
2187 bool willResample)
|
Chris@0
|
2188 {
|
Chris@0
|
2189 updateDescriptionLabel();
|
Chris@0
|
2190 }
|
Chris@0
|
2191
|
Chris@0
|
2192 void
|
Chris@0
|
2193 MainWindow::audioOverloadPluginDisabled()
|
Chris@0
|
2194 {
|
Chris@0
|
2195 QMessageBox::information
|
Chris@0
|
2196 (this, tr("Audio processing overload"),
|
Chris@0
|
2197 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@0
|
2198 }
|
Chris@0
|
2199
|
Chris@0
|
2200 void
|
Chris@0
|
2201 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@0
|
2202 {
|
Chris@0
|
2203 static bool shownOnce = false;
|
Chris@0
|
2204 if (shownOnce) return;
|
Chris@0
|
2205 QMessageBox::information
|
Chris@0
|
2206 (this, tr("Audio processing overload"),
|
Chris@0
|
2207 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@0
|
2208 shownOnce = true;
|
Chris@0
|
2209 }
|
Chris@0
|
2210
|
Chris@0
|
2211 void
|
Chris@0
|
2212 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
2213 {
|
Chris@0
|
2214 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
2215 }
|
Chris@0
|
2216
|
Chris@0
|
2217 void
|
Chris@0
|
2218 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
2219 {
|
Chris@0
|
2220 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
2221 }
|
Chris@0
|
2222
|
Chris@0
|
2223 void
|
Chris@0
|
2224 MainWindow::modelAdded(Model *model)
|
Chris@0
|
2225 {
|
Chris@0
|
2226 MainWindowBase::modelAdded(model);
|
Chris@3
|
2227 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
|
Chris@0
|
2228 if (dtvm) {
|
Chris@70
|
2229 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
|
Chris@0
|
2230 }
|
Chris@0
|
2231 }
|
Chris@0
|
2232
|
Chris@0
|
2233 void
|
Chris@0
|
2234 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
2235 {
|
Chris@0
|
2236 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@0
|
2237 }
|
Chris@0
|
2238
|
Chris@0
|
2239 void
|
Chris@0
|
2240 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
2241 {
|
Chris@0
|
2242 m_panLayer->setModel(model);
|
Chris@0
|
2243
|
Chris@0
|
2244 MainWindowBase::mainModelChanged(model);
|
Chris@0
|
2245
|
Chris@0
|
2246 if (m_playTarget) {
|
Chris@0
|
2247 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2248 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2249 }
|
Chris@72
|
2250
|
Chris@72
|
2251 if (model) {
|
Chris@72
|
2252 if (m_paneStack) {
|
Chris@174
|
2253
|
Chris@174
|
2254 int pc = m_paneStack->getPaneCount();
|
Chris@174
|
2255 Pane *pane = 0;
|
Chris@174
|
2256
|
Chris@174
|
2257 if (pc < 1) {
|
Chris@72
|
2258 pane = m_paneStack->addPane();
|
Chris@131
|
2259
|
Chris@131
|
2260 Pane *selectionStrip = m_paneStack->addPane();
|
Chris@131
|
2261 selectionStrip->setFixedHeight(26);
|
Chris@131
|
2262 m_document->addLayerToView
|
Chris@131
|
2263 (selectionStrip,
|
Chris@131
|
2264 m_document->createMainModelLayer(LayerFactory::TimeRuler));
|
Chris@131
|
2265 m_paneStack->sizePanesEqually();
|
Chris@131
|
2266
|
Chris@131
|
2267 m_viewManager->clearToolModeOverrides();
|
Chris@131
|
2268 m_viewManager->setToolModeFor(selectionStrip,
|
Chris@131
|
2269 ViewManager::SelectMode);
|
Chris@174
|
2270 } else {
|
Chris@174
|
2271 pane = m_paneStack->getPane(0);
|
Chris@72
|
2272 }
|
Chris@174
|
2273
|
Chris@72
|
2274 if (pane) {
|
Chris@140
|
2275 QString error = m_analyser->newFileLoaded
|
Chris@72
|
2276 (m_document, getMainModel(), m_paneStack, pane);
|
Chris@140
|
2277 if (error != "") {
|
Chris@140
|
2278 QMessageBox::warning
|
Chris@140
|
2279 (this,
|
Chris@140
|
2280 tr("Failed to analyse audio"),
|
Chris@140
|
2281 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
|
Chris@140
|
2282 QMessageBox::Ok);
|
Chris@140
|
2283 }
|
Chris@72
|
2284 }
|
Chris@72
|
2285 }
|
Chris@72
|
2286 }
|
Chris@0
|
2287 }
|
Chris@0
|
2288
|
Chris@0
|
2289 void
|
Chris@0
|
2290 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@0
|
2291 {
|
Chris@0
|
2292 if (message != "") {
|
Chris@0
|
2293
|
Chris@0
|
2294 QMessageBox::warning
|
Chris@0
|
2295 (this,
|
Chris@0
|
2296 tr("Failed to generate layer"),
|
Chris@0
|
2297 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@0
|
2298 .arg(transformName).arg(message),
|
Chris@0
|
2299 QMessageBox::Ok);
|
Chris@0
|
2300 } else {
|
Chris@0
|
2301 QMessageBox::warning
|
Chris@0
|
2302 (this,
|
Chris@0
|
2303 tr("Failed to generate layer"),
|
Chris@0
|
2304 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
|
2305 .arg(transformName),
|
Chris@0
|
2306 QMessageBox::Ok);
|
Chris@0
|
2307 }
|
Chris@0
|
2308 }
|
Chris@0
|
2309
|
Chris@0
|
2310 void
|
Chris@0
|
2311 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@0
|
2312 {
|
Chris@0
|
2313 QMessageBox::warning
|
Chris@0
|
2314 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@0
|
2315 }
|
Chris@0
|
2316
|
Chris@0
|
2317 void
|
Chris@0
|
2318 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@0
|
2319 QString transformName, QString message)
|
Chris@0
|
2320 {
|
Chris@0
|
2321 if (message != "") {
|
Chris@0
|
2322
|
Chris@0
|
2323 QMessageBox::warning
|
Chris@0
|
2324 (this,
|
Chris@0
|
2325 tr("Failed to regenerate layer"),
|
Chris@0
|
2326 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
|
2327 .arg(layerName).arg(transformName).arg(message),
|
Chris@0
|
2328 QMessageBox::Ok);
|
Chris@0
|
2329 } else {
|
Chris@0
|
2330 QMessageBox::warning
|
Chris@0
|
2331 (this,
|
Chris@0
|
2332 tr("Failed to regenerate layer"),
|
Chris@0
|
2333 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
|
2334 .arg(layerName).arg(transformName),
|
Chris@0
|
2335 QMessageBox::Ok);
|
Chris@0
|
2336 }
|
Chris@0
|
2337 }
|
Chris@0
|
2338
|
Chris@0
|
2339 void
|
Chris@0
|
2340 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@0
|
2341 QString transformName, QString message)
|
Chris@0
|
2342 {
|
Chris@0
|
2343 QMessageBox::warning
|
Chris@0
|
2344 (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
|
2345 }
|
Chris@0
|
2346
|
Chris@0
|
2347 void
|
Chris@0
|
2348 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
2349 {
|
Chris@0
|
2350 QMessageBox::warning
|
Chris@0
|
2351 (this,
|
Chris@0
|
2352 tr("Failed to calculate alignment"),
|
Chris@0
|
2353 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@0
|
2354 .arg(transformName).arg(message),
|
Chris@0
|
2355 QMessageBox::Ok);
|
Chris@0
|
2356 }
|
Chris@0
|
2357
|
Chris@0
|
2358 void
|
Chris@0
|
2359 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
2360 {
|
Chris@70
|
2361 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
2362 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
2363 m_rightButtonMenu->popup(position);
|
Chris@0
|
2364 }
|
Chris@0
|
2365
|
Chris@0
|
2366 void
|
Chris@0
|
2367 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@0
|
2368 {
|
Chris@70
|
2369 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
|
Chris@0
|
2370 }
|
Chris@0
|
2371
|
Chris@0
|
2372 void
|
Chris@0
|
2373 MainWindow::mouseEnteredWidget()
|
Chris@0
|
2374 {
|
Chris@3
|
2375 QWidget *w = qobject_cast<QWidget *>(sender());
|
Chris@0
|
2376 if (!w) return;
|
Chris@0
|
2377
|
Chris@0
|
2378 if (w == m_fader) {
|
Chris@0
|
2379 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@0
|
2380 } else if (w == m_playSpeed) {
|
Chris@0
|
2381 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@0
|
2382 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@0
|
2383 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@0
|
2384 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@0
|
2385 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
|
Chris@0
|
2386 }
|
Chris@0
|
2387 }
|
Chris@0
|
2388
|
Chris@0
|
2389 void
|
Chris@0
|
2390 MainWindow::mouseLeftWidget()
|
Chris@0
|
2391 {
|
Chris@0
|
2392 contextHelpChanged("");
|
Chris@0
|
2393 }
|
Chris@0
|
2394
|
Chris@0
|
2395 void
|
Chris@0
|
2396 MainWindow::website()
|
Chris@0
|
2397 {
|
Chris@4
|
2398 //!!! todo: URL!
|
Chris@4
|
2399 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2400 }
|
Chris@0
|
2401
|
Chris@0
|
2402 void
|
Chris@0
|
2403 MainWindow::help()
|
Chris@0
|
2404 {
|
Chris@4
|
2405 //!!! todo: help URL!
|
Chris@4
|
2406 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2407 }
|
Chris@0
|
2408
|
Chris@0
|
2409 void
|
Chris@0
|
2410 MainWindow::about()
|
Chris@0
|
2411 {
|
Chris@0
|
2412 bool debug = false;
|
Chris@0
|
2413 QString version = "(unknown version)";
|
Chris@0
|
2414
|
Chris@0
|
2415 #ifdef BUILD_DEBUG
|
Chris@0
|
2416 debug = true;
|
Chris@0
|
2417 #endif
|
Chris@0
|
2418 version = tr("Release %1").arg(TONY_VERSION);
|
Chris@0
|
2419
|
Chris@0
|
2420 QString aboutText;
|
Chris@0
|
2421
|
Chris@0
|
2422 aboutText += tr("<h3>About Tony</h3>");
|
Chris@0
|
2423 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
|
Chris@0
|
2424 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
2425 .arg(version)
|
Chris@0
|
2426 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
2427
|
Chris@0
|
2428 aboutText +=
|
Chris@90
|
2429 "<p>Copyright © 2005–2013 Chris Cannam, Matthias Mauch, George Fazekas, and Queen Mary University of London.</p>"
|
Chris@90
|
2430 "<p>This program is free software; you can redistribute it and/or "
|
Chris@90
|
2431 "modify it under the terms of the GNU General Public License as "
|
Chris@90
|
2432 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
2433 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
2434 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
2435
|
Chris@0
|
2436 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
|
Chris@0
|
2437 }
|
Chris@0
|
2438
|
Chris@0
|
2439 void
|
Chris@0
|
2440 MainWindow::keyReference()
|
Chris@0
|
2441 {
|
Chris@0
|
2442 m_keyReference->show();
|
Chris@0
|
2443 }
|
Chris@0
|
2444
|
Chris@0
|
2445
|