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