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