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@0
|
48
|
matthiasm@26
|
49 #include "data/fileio/CSVFileWriter.h"
|
matthiasm@26
|
50 #include "data/fileio/MIDIFileWriter.h"
|
matthiasm@26
|
51 #include "rdf/RDFExporter.h"
|
matthiasm@26
|
52
|
Chris@0
|
53 // For version information
|
Chris@0
|
54 #include "vamp/vamp.h"
|
Chris@0
|
55 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
56 #include "plugin/api/ladspa.h"
|
Chris@0
|
57 #include "plugin/api/dssi.h"
|
Chris@0
|
58
|
Chris@0
|
59 #include <QApplication>
|
Chris@0
|
60 #include <QMessageBox>
|
Chris@0
|
61 #include <QGridLayout>
|
Chris@0
|
62 #include <QLabel>
|
Chris@0
|
63 #include <QMenuBar>
|
Chris@0
|
64 #include <QToolBar>
|
Chris@0
|
65 #include <QToolButton>
|
Chris@0
|
66 #include <QInputDialog>
|
Chris@0
|
67 #include <QStatusBar>
|
Chris@0
|
68 #include <QFileInfo>
|
Chris@0
|
69 #include <QDir>
|
Chris@0
|
70 #include <QProcess>
|
Chris@2
|
71 #include <QPushButton>
|
Chris@0
|
72 #include <QSettings>
|
Chris@0
|
73 #include <QScrollArea>
|
Chris@128
|
74 #include <QPainter>
|
Chris@0
|
75
|
Chris@0
|
76 #include <iostream>
|
Chris@0
|
77 #include <cstdio>
|
Chris@0
|
78 #include <errno.h>
|
Chris@0
|
79
|
Chris@0
|
80 using std::vector;
|
Chris@0
|
81
|
Chris@0
|
82
|
Chris@0
|
83 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@0
|
84 MainWindowBase(withAudioOutput, withOSCSupport, false),
|
Chris@0
|
85 m_overview(0),
|
Chris@0
|
86 m_mainMenusCreated(false),
|
gyorgyf@45
|
87 m_intelligentActionOn(true), //GF: !!! temporary
|
Chris@0
|
88 m_playbackMenu(0),
|
gyorgyf@45
|
89 m_recentFilesMenu(0),
|
Chris@0
|
90 m_rightButtonMenu(0),
|
Chris@0
|
91 m_rightButtonPlaybackMenu(0),
|
Chris@0
|
92 m_deleteSelectedAction(0),
|
Chris@0
|
93 m_ffwdAction(0),
|
Chris@0
|
94 m_rwdAction(0),
|
Chris@0
|
95 m_keyReference(new KeyReference())
|
Chris@0
|
96 {
|
Chris@0
|
97 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
98
|
Chris@0
|
99 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@0
|
100 udb->registerUnit("Hz");
|
Chris@0
|
101 udb->registerUnit("dB");
|
Chris@0
|
102 udb->registerUnit("s");
|
Chris@0
|
103
|
Chris@0
|
104 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@0
|
105 cdb->addColour(Qt::black, tr("Black"));
|
Chris@0
|
106 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@0
|
107 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@0
|
108 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@0
|
109 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@0
|
110 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@120
|
111 cdb->addColour(QColor(180, 180, 180), tr("Grey"));
|
Chris@0
|
112 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@0
|
113 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@0
|
114 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@0
|
115 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@0
|
116 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@0
|
117 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
118
|
Chris@0
|
119 Preferences::getInstance()->setResampleOnLoad(true);
|
Chris@0
|
120 Preferences::getInstance()->setSpectrogramSmoothing
|
Chris@0
|
121 (Preferences::SpectrogramInterpolated);
|
Chris@0
|
122
|
Chris@0
|
123 QSettings settings;
|
Chris@0
|
124
|
Chris@0
|
125 settings.beginGroup("MainWindow");
|
Chris@0
|
126 settings.setValue("showstatusbar", false);
|
Chris@0
|
127 settings.endGroup();
|
Chris@0
|
128
|
Chris@96
|
129 settings.beginGroup("Transformer");
|
Chris@96
|
130 settings.setValue("use-flexi-note-model", true);
|
Chris@96
|
131 settings.endGroup();
|
Chris@96
|
132
|
Chris@73
|
133 settings.beginGroup("LayerDefaults");
|
Chris@73
|
134 settings.setValue("waveform",
|
Chris@73
|
135 QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
Chris@73
|
136 .arg(int(WaveformLayer::LinearScale))
|
Chris@73
|
137 .arg(int(WaveformLayer::MixChannels)));
|
Chris@73
|
138 settings.endGroup();
|
Chris@73
|
139
|
Chris@6
|
140 m_viewManager->setAlignMode(false);
|
Chris@6
|
141 m_viewManager->setPlaySoloMode(false);
|
Chris@0
|
142 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
143 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@6
|
144 m_viewManager->setIlluminateLocalFeatures(true);
|
Chris@0
|
145 m_viewManager->setShowWorkTitle(true);
|
Chris@6
|
146 m_viewManager->setShowCentreLine(false);
|
Chris@91
|
147 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@0
|
148
|
Chris@0
|
149 QFrame *frame = new QFrame;
|
Chris@0
|
150 setCentralWidget(frame);
|
Chris@0
|
151
|
Chris@0
|
152 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
153
|
Chris@0
|
154 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@0
|
155 scroll->setWidgetResizable(true);
|
Chris@0
|
156 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@0
|
157 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@0
|
158
|
Chris@6
|
159 // We have a pane stack: it comes with the territory. However, we
|
Chris@120
|
160 // have a fixed and known number of panes in it -- it isn't
|
Chris@120
|
161 // variable
|
Chris@0
|
162 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@0
|
163 scroll->setWidget(m_paneStack);
|
Chris@6
|
164
|
Chris@0
|
165 m_overview = new Overview(frame);
|
Chris@0
|
166 m_overview->setViewManager(m_viewManager);
|
Chris@0
|
167 m_overview->setFixedHeight(40);
|
Chris@0
|
168 #ifndef _WIN32
|
Chris@0
|
169 // For some reason, the contents of the overview never appear if we
|
Chris@0
|
170 // make this setting on Windows. I have no inclination at the moment
|
Chris@0
|
171 // to track down the reason why.
|
Chris@0
|
172 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@0
|
173 #endif
|
Chris@0
|
174 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
175 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
176
|
Chris@0
|
177 m_panLayer = new WaveformLayer;
|
Chris@0
|
178 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
179 m_panLayer->setAggressiveCacheing(true);
|
Chris@0
|
180 m_overview->addLayer(m_panLayer);
|
Chris@0
|
181
|
Chris@0
|
182 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@0
|
183 m_panLayer->setBaseColour
|
Chris@0
|
184 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@0
|
185 } else {
|
Chris@0
|
186 m_panLayer->setBaseColour
|
matthiasm@13
|
187 (ColourDatabase::getInstance()->getColourIndex(tr("Blue")));
|
Chris@0
|
188 }
|
Chris@0
|
189
|
Chris@0
|
190 m_fader = new Fader(frame, false);
|
Chris@0
|
191 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
192 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
193
|
Chris@0
|
194 m_playSpeed = new AudioDial(frame);
|
Chris@0
|
195 m_playSpeed->setMinimum(0);
|
Chris@0
|
196 m_playSpeed->setMaximum(200);
|
Chris@0
|
197 m_playSpeed->setValue(100);
|
Chris@0
|
198 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
199 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
200 m_playSpeed->setNotchesVisible(true);
|
Chris@0
|
201 m_playSpeed->setPageStep(10);
|
Chris@0
|
202 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@0
|
203 m_playSpeed->setDefaultValue(100);
|
Chris@0
|
204 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@0
|
205 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
206 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
gyorgyf@27
|
207 this, SLOT(playSpeedChanged(int)));
|
Chris@0
|
208 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
209 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
210
|
Chris@0
|
211 layout->setSpacing(4);
|
Chris@6
|
212 layout->addWidget(m_overview, 0, 1);
|
Chris@6
|
213 layout->addWidget(scroll, 1, 1);
|
Chris@0
|
214
|
Chris@0
|
215 layout->setColumnStretch(1, 10);
|
Chris@0
|
216
|
Chris@0
|
217 frame->setLayout(layout);
|
Chris@0
|
218
|
gyorgyf@21
|
219 m_analyser = new Analyser();
|
Chris@128
|
220 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@128
|
221 this, SLOT(updateLayerStatuses()));
|
gyorgyf@21
|
222
|
Chris@0
|
223 setupMenus();
|
Chris@0
|
224 setupToolbars();
|
Chris@0
|
225 setupHelpMenu();
|
Chris@0
|
226
|
Chris@0
|
227 statusBar();
|
Chris@0
|
228
|
Chris@95
|
229 newSession();
|
Chris@6
|
230
|
Chris@95
|
231 settings.beginGroup("MainWindow");
|
Chris@95
|
232 settings.setValue("zoom-default", 512);
|
Chris@95
|
233 settings.endGroup();
|
Chris@95
|
234 zoomDefault();
|
Chris@95
|
235
|
Chris@95
|
236 NetworkPermissionTester tester;
|
Chris@95
|
237 bool networkPermission = tester.havePermission();
|
Chris@95
|
238 if (networkPermission) {
|
Chris@95
|
239 m_versionTester = new VersionTester
|
Chris@95
|
240 ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
|
Chris@95
|
241 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@95
|
242 this, SLOT(newerVersionAvailable(QString)));
|
Chris@95
|
243 } else {
|
Chris@95
|
244 m_versionTester = 0;
|
Chris@95
|
245 }
|
Chris@0
|
246 }
|
Chris@0
|
247
|
Chris@0
|
248 MainWindow::~MainWindow()
|
Chris@0
|
249 {
|
Chris@6
|
250 delete m_analyser;
|
Chris@0
|
251 delete m_keyReference;
|
Chris@0
|
252 Profiles::getInstance()->dump();
|
Chris@0
|
253 }
|
Chris@0
|
254
|
Chris@0
|
255 void
|
Chris@0
|
256 MainWindow::setupMenus()
|
Chris@0
|
257 {
|
Chris@0
|
258 if (!m_mainMenusCreated) {
|
Chris@0
|
259 m_rightButtonMenu = new QMenu();
|
Chris@0
|
260 }
|
Chris@0
|
261
|
Chris@0
|
262 if (!m_mainMenusCreated) {
|
Chris@0
|
263 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
264 m_rightButtonMenu->addSeparator();
|
Chris@0
|
265 }
|
Chris@0
|
266
|
Chris@0
|
267 setupFileMenu();
|
Chris@0
|
268 setupEditMenu();
|
Chris@0
|
269 setupViewMenu();
|
Chris@0
|
270
|
Chris@0
|
271 m_mainMenusCreated = true;
|
Chris@0
|
272 }
|
Chris@0
|
273
|
Chris@0
|
274 void
|
Chris@0
|
275 MainWindow::setupFileMenu()
|
Chris@0
|
276 {
|
Chris@0
|
277 if (m_mainMenusCreated) return;
|
Chris@0
|
278
|
Chris@0
|
279 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@0
|
280 menu->setTearOffEnabled(true);
|
Chris@0
|
281 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@0
|
282
|
Chris@0
|
283 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@0
|
284
|
Chris@0
|
285 IconLoader il;
|
Chris@1
|
286 QIcon icon;
|
Chris@1
|
287 QAction *action;
|
Chris@0
|
288
|
Chris@0
|
289 icon = il.load("fileopen");
|
Chris@0
|
290 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@1
|
291 action = new QAction(icon, tr("&Open..."), this);
|
Chris@0
|
292 action->setShortcut(tr("Ctrl+O"));
|
Chris@1
|
293 action->setStatusTip(tr("Open a file"));
|
Chris@0
|
294 connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
|
Chris@0
|
295 m_keyReference->registerShortcut(action);
|
Chris@0
|
296 menu->addAction(action);
|
Chris@0
|
297 toolbar->addAction(action);
|
Chris@0
|
298
|
Chris@1
|
299 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@0
|
300 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@1
|
301 action->setStatusTip(tr("Open a file from a remote URL"));
|
Chris@0
|
302 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@0
|
303 m_keyReference->registerShortcut(action);
|
Chris@0
|
304 menu->addAction(action);
|
Chris@0
|
305
|
Chris@1
|
306 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@0
|
307 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@0
|
308 setupRecentFilesMenu();
|
Chris@0
|
309 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@0
|
310 this, SLOT(setupRecentFilesMenu()));
|
Chris@0
|
311
|
Chris@0
|
312 menu->addSeparator();
|
Chris@85
|
313 action = new QAction(tr("Export Pitch Track Data..."), this);
|
Chris@85
|
314 action->setStatusTip(tr("Export pitch-track data to a file"));
|
Chris@85
|
315 connect(action, SIGNAL(triggered()), this, SLOT(exportPitchLayer()));
|
Chris@85
|
316 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@85
|
317 menu->addAction(action);
|
Chris@85
|
318
|
Chris@85
|
319 action = new QAction(tr("Export Note Data..."), this);
|
Chris@85
|
320 action->setStatusTip(tr("Export note data to a file"));
|
Chris@85
|
321 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
|
matthiasm@26
|
322 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@26
|
323 menu->addAction(action);
|
matthiasm@26
|
324
|
matthiasm@26
|
325 menu->addSeparator();
|
Chris@0
|
326 action = new QAction(il.load("exit"), tr("&Quit"), this);
|
Chris@0
|
327 action->setShortcut(tr("Ctrl+Q"));
|
Chris@0
|
328 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@0
|
329 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@0
|
330 m_keyReference->registerShortcut(action);
|
Chris@0
|
331 menu->addAction(action);
|
Chris@0
|
332 }
|
Chris@0
|
333
|
Chris@0
|
334 void
|
Chris@0
|
335 MainWindow::setupEditMenu()
|
Chris@0
|
336 {
|
Chris@0
|
337 if (m_mainMenusCreated) return;
|
Chris@0
|
338
|
Chris@0
|
339 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@0
|
340 menu->setTearOffEnabled(true);
|
Chris@0
|
341 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@126
|
342 menu->addSeparator();
|
Chris@126
|
343
|
Chris@126
|
344 QToolBar *toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@126
|
345
|
Chris@126
|
346 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@126
|
347
|
Chris@126
|
348 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
349
|
Chris@126
|
350 QActionGroup *group = new QActionGroup(this);
|
Chris@126
|
351
|
Chris@126
|
352 IconLoader il;
|
Chris@126
|
353
|
Chris@126
|
354 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@126
|
355 tr("Navigate"));
|
Chris@126
|
356 action->setCheckable(true);
|
Chris@126
|
357 action->setChecked(true);
|
Chris@126
|
358 action->setShortcut(tr("1"));
|
Chris@126
|
359 action->setStatusTip(tr("Navigate"));
|
Chris@126
|
360 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@126
|
361 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@126
|
362 group->addAction(action);
|
Chris@126
|
363 menu->addAction(action);
|
Chris@126
|
364 m_keyReference->registerShortcut(action);
|
Chris@126
|
365
|
Chris@126
|
366 action = toolbar->addAction(il.load("move"),
|
Chris@126
|
367 tr("Edit"));
|
Chris@126
|
368 action->setCheckable(true);
|
Chris@126
|
369 action->setShortcut(tr("2"));
|
Chris@126
|
370 action->setStatusTip(tr("Edit with Note Intelligence"));
|
Chris@126
|
371 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@126
|
372 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
373 group->addAction(action);
|
Chris@126
|
374 menu->addAction(action);
|
Chris@126
|
375 m_keyReference->registerShortcut(action);
|
Chris@126
|
376
|
Chris@126
|
377 /* Remove for now...
|
Chris@126
|
378
|
Chris@126
|
379 action = toolbar->addAction(il.load("notes"),
|
Chris@126
|
380 tr("Free Edit"));
|
Chris@126
|
381 action->setCheckable(true);
|
Chris@126
|
382 action->setShortcut(tr("3"));
|
Chris@126
|
383 action->setStatusTip(tr("Free Edit"));
|
Chris@126
|
384 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
|
Chris@126
|
385 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@126
|
386 group->addAction(action);
|
Chris@126
|
387 m_keyReference->registerShortcut(action);
|
Chris@126
|
388 */
|
Chris@0
|
389 }
|
Chris@0
|
390
|
Chris@0
|
391 void
|
Chris@0
|
392 MainWindow::setupViewMenu()
|
Chris@0
|
393 {
|
Chris@0
|
394 if (m_mainMenusCreated) return;
|
Chris@0
|
395
|
Chris@0
|
396 IconLoader il;
|
Chris@0
|
397
|
Chris@0
|
398 QAction *action = 0;
|
Chris@0
|
399
|
Chris@0
|
400 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@0
|
401
|
Chris@0
|
402 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@0
|
403 menu->setTearOffEnabled(true);
|
Chris@0
|
404 action = new QAction(tr("Scroll &Left"), this);
|
Chris@0
|
405 action->setShortcut(tr("Left"));
|
Chris@0
|
406 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@0
|
407 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@0
|
408 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
409 m_keyReference->registerShortcut(action);
|
Chris@0
|
410 menu->addAction(action);
|
gyorgyf@27
|
411
|
Chris@0
|
412 action = new QAction(tr("Scroll &Right"), this);
|
Chris@0
|
413 action->setShortcut(tr("Right"));
|
Chris@0
|
414 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@0
|
415 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@0
|
416 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
417 m_keyReference->registerShortcut(action);
|
Chris@0
|
418 menu->addAction(action);
|
gyorgyf@27
|
419
|
Chris@0
|
420 action = new QAction(tr("&Jump Left"), this);
|
Chris@0
|
421 action->setShortcut(tr("Ctrl+Left"));
|
Chris@0
|
422 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@0
|
423 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@0
|
424 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
425 m_keyReference->registerShortcut(action);
|
Chris@0
|
426 menu->addAction(action);
|
gyorgyf@27
|
427
|
Chris@0
|
428 action = new QAction(tr("J&ump Right"), this);
|
Chris@0
|
429 action->setShortcut(tr("Ctrl+Right"));
|
Chris@0
|
430 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@0
|
431 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@0
|
432 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
433 m_keyReference->registerShortcut(action);
|
Chris@0
|
434 menu->addAction(action);
|
Chris@0
|
435
|
Chris@0
|
436 menu->addSeparator();
|
Chris@0
|
437
|
Chris@0
|
438 m_keyReference->setCategory(tr("Zoom"));
|
Chris@0
|
439
|
Chris@0
|
440 action = new QAction(il.load("zoom-in"),
|
Chris@0
|
441 tr("Zoom &In"), this);
|
Chris@0
|
442 action->setShortcut(tr("Up"));
|
Chris@0
|
443 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@0
|
444 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@0
|
445 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
446 m_keyReference->registerShortcut(action);
|
Chris@0
|
447 menu->addAction(action);
|
gyorgyf@27
|
448
|
Chris@0
|
449 action = new QAction(il.load("zoom-out"),
|
Chris@0
|
450 tr("Zoom &Out"), this);
|
Chris@0
|
451 action->setShortcut(tr("Down"));
|
Chris@0
|
452 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@0
|
453 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@0
|
454 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
455 m_keyReference->registerShortcut(action);
|
Chris@0
|
456 menu->addAction(action);
|
gyorgyf@27
|
457
|
Chris@0
|
458 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@0
|
459 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@0
|
460 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@0
|
461 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
462 menu->addAction(action);
|
Chris@0
|
463
|
Chris@0
|
464 action = new QAction(il.load("zoom-fit"),
|
Chris@0
|
465 tr("Zoom to &Fit"), this);
|
Chris@0
|
466 action->setShortcut(tr("F"));
|
Chris@0
|
467 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@0
|
468 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@0
|
469 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
470 m_keyReference->registerShortcut(action);
|
Chris@0
|
471 menu->addAction(action);
|
Chris@0
|
472 }
|
Chris@0
|
473
|
Chris@0
|
474 void
|
Chris@0
|
475 MainWindow::setupHelpMenu()
|
Chris@0
|
476 {
|
Chris@0
|
477 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@0
|
478 menu->setTearOffEnabled(true);
|
Chris@0
|
479
|
Chris@0
|
480 m_keyReference->setCategory(tr("Help"));
|
Chris@0
|
481
|
Chris@0
|
482 IconLoader il;
|
Chris@0
|
483
|
Chris@1
|
484 QString name = QApplication::applicationName();
|
Chris@1
|
485
|
Chris@0
|
486 QAction *action = new QAction(il.load("help"),
|
Chris@0
|
487 tr("&Help Reference"), this);
|
Chris@0
|
488 action->setShortcut(tr("F1"));
|
Chris@1
|
489 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
Chris@0
|
490 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
491 m_keyReference->registerShortcut(action);
|
Chris@0
|
492 menu->addAction(action);
|
Chris@0
|
493
|
Chris@0
|
494 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@0
|
495 action->setShortcut(tr("F2"));
|
Chris@1
|
496 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@0
|
497 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@0
|
498 m_keyReference->registerShortcut(action);
|
Chris@0
|
499 menu->addAction(action);
|
Chris@0
|
500
|
Chris@1
|
501 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@1
|
502 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@0
|
503 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
504 menu->addAction(action);
|
Chris@0
|
505
|
Chris@1
|
506 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@1
|
507 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@0
|
508 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
509 menu->addAction(action);
|
Chris@0
|
510 }
|
Chris@0
|
511
|
Chris@0
|
512 void
|
Chris@0
|
513 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
514 {
|
Chris@0
|
515 m_recentFilesMenu->clear();
|
Chris@0
|
516 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
517 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@50
|
518 QAction *action = new QAction(files[i], this);
|
Chris@50
|
519 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
520 if (i == 0) {
|
Chris@0
|
521 action->setShortcut(tr("Ctrl+R"));
|
Chris@0
|
522 m_keyReference->registerShortcut
|
Chris@0
|
523 (tr("Re-open"),
|
Chris@50
|
524 action->shortcut().toString(),
|
Chris@0
|
525 tr("Re-open the current or most recently opened file"));
|
Chris@0
|
526 }
|
Chris@50
|
527 m_recentFilesMenu->addAction(action);
|
Chris@0
|
528 }
|
Chris@0
|
529 }
|
Chris@0
|
530
|
Chris@0
|
531 void
|
Chris@0
|
532 MainWindow::setupToolbars()
|
Chris@0
|
533 {
|
Chris@0
|
534 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@0
|
535
|
Chris@0
|
536 IconLoader il;
|
Chris@0
|
537
|
Chris@0
|
538 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@0
|
539 menu->setTearOffEnabled(true);
|
Chris@0
|
540 m_rightButtonMenu->addSeparator();
|
Chris@0
|
541 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@0
|
542
|
Chris@0
|
543 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@0
|
544
|
Chris@0
|
545 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@0
|
546 tr("Rewind to Start"));
|
Chris@0
|
547 rwdStartAction->setShortcut(tr("Home"));
|
Chris@0
|
548 rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
549 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
550 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@0
|
551
|
Chris@0
|
552 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
|
Chris@0
|
553 tr("Rewind"));
|
Chris@0
|
554 m_rwdAction->setShortcut(tr("PgUp"));
|
Chris@0
|
555 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@0
|
556 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
557 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
558
|
Chris@0
|
559 QAction *playAction = toolbar->addAction(il.load("playpause"),
|
Chris@0
|
560 tr("Play / Pause"));
|
Chris@0
|
561 playAction->setCheckable(true);
|
Chris@0
|
562 playAction->setShortcut(tr("Space"));
|
Chris@0
|
563 playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
564 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
565 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
gyorgyf@27
|
566 playAction, SLOT(setChecked(bool)));
|
Chris@0
|
567 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
|
Chris@0
|
568
|
Chris@0
|
569 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@0
|
570 tr("Fast Forward"));
|
Chris@0
|
571 m_ffwdAction->setShortcut(tr("PgDown"));
|
Chris@0
|
572 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@0
|
573 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
574 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
575
|
Chris@0
|
576 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@0
|
577 tr("Fast Forward to End"));
|
Chris@0
|
578 ffwdEndAction->setShortcut(tr("End"));
|
Chris@0
|
579 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
580 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
581 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@6
|
582
|
Chris@0
|
583 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
584
|
Chris@0
|
585 QAction *psAction = toolbar->addAction(il.load("playselection"),
|
Chris@0
|
586 tr("Constrain Playback to Selection"));
|
Chris@0
|
587 psAction->setCheckable(true);
|
Chris@0
|
588 psAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
589 psAction->setShortcut(tr("s"));
|
Chris@0
|
590 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@0
|
591 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@0
|
592 psAction, SLOT(setChecked(bool)));
|
Chris@0
|
593 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
594 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
|
Chris@0
|
595
|
Chris@0
|
596 QAction *plAction = toolbar->addAction(il.load("playloop"),
|
Chris@0
|
597 tr("Loop Playback"));
|
Chris@0
|
598 plAction->setCheckable(true);
|
Chris@0
|
599 plAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
600 plAction->setShortcut(tr("l"));
|
Chris@0
|
601 plAction->setStatusTip(tr("Loop playback"));
|
Chris@0
|
602 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@0
|
603 plAction, SLOT(setChecked(bool)));
|
Chris@0
|
604 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
605 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
|
Chris@0
|
606
|
Chris@0
|
607 m_keyReference->registerShortcut(psAction);
|
Chris@0
|
608 m_keyReference->registerShortcut(plAction);
|
Chris@0
|
609 m_keyReference->registerShortcut(playAction);
|
Chris@0
|
610 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@0
|
611 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@0
|
612 m_keyReference->registerShortcut(rwdStartAction);
|
Chris@0
|
613 m_keyReference->registerShortcut(ffwdEndAction);
|
Chris@0
|
614
|
Chris@6
|
615 menu->addAction(playAction);
|
Chris@0
|
616 menu->addAction(psAction);
|
Chris@0
|
617 menu->addAction(plAction);
|
Chris@0
|
618 menu->addSeparator();
|
Chris@0
|
619 menu->addAction(m_rwdAction);
|
Chris@0
|
620 menu->addAction(m_ffwdAction);
|
Chris@0
|
621 menu->addSeparator();
|
Chris@0
|
622 menu->addAction(rwdStartAction);
|
Chris@0
|
623 menu->addAction(ffwdEndAction);
|
Chris@0
|
624 menu->addSeparator();
|
Chris@0
|
625
|
Chris@0
|
626 m_rightButtonPlaybackMenu->addAction(playAction);
|
Chris@0
|
627 m_rightButtonPlaybackMenu->addAction(psAction);
|
Chris@0
|
628 m_rightButtonPlaybackMenu->addAction(plAction);
|
Chris@0
|
629 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
630 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@0
|
631 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@0
|
632 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
633 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
|
Chris@0
|
634 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
|
Chris@0
|
635 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
636
|
Chris@0
|
637 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@0
|
638 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@0
|
639 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@0
|
640 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@0
|
641 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@0
|
642
|
Chris@0
|
643 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@0
|
644 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@0
|
645 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@0
|
646 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@0
|
647 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@0
|
648
|
Chris@0
|
649 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@0
|
650 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@0
|
651 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@0
|
652 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@0
|
653 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@0
|
654
|
Chris@0
|
655 m_keyReference->registerShortcut(fastAction);
|
Chris@0
|
656 m_keyReference->registerShortcut(slowAction);
|
Chris@0
|
657 m_keyReference->registerShortcut(normalAction);
|
Chris@0
|
658
|
Chris@0
|
659 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@0
|
660 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@0
|
661 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@6
|
662
|
Chris@6
|
663 toolbar = addToolBar(tr("Playback Controls"));
|
Chris@6
|
664 toolbar->addWidget(m_playSpeed);
|
Chris@6
|
665 toolbar->addWidget(m_fader);
|
Chris@0
|
666
|
Chris@128
|
667 toolbar = addToolBar(tr("Show and Play"));
|
Chris@128
|
668
|
Chris@128
|
669 QAction *cycleWaveformAction = toolbar->addAction(tr("Audio"));
|
Chris@128
|
670 //!!! shortcut etc
|
Chris@128
|
671 connect(cycleWaveformAction, SIGNAL(triggered()), this, SLOT(cycleWaveform()));
|
Chris@128
|
672
|
Chris@128
|
673 m_waveformStatus = new QLabel();
|
Chris@128
|
674 toolbar->addWidget(m_waveformStatus);
|
Chris@128
|
675
|
Chris@128
|
676 QAction *cyclePitchAction = toolbar->addAction(tr("Pitch"));
|
Chris@128
|
677 //!!! shortcut etc
|
Chris@128
|
678 connect(cyclePitchAction, SIGNAL(triggered()), this, SLOT(cyclePitch()));
|
Chris@128
|
679
|
Chris@128
|
680 m_pitchStatus = new QLabel();
|
Chris@128
|
681 toolbar->addWidget(m_pitchStatus);
|
Chris@128
|
682
|
Chris@128
|
683 QAction *cycleNotesAction = toolbar->addAction(tr("Notes"));
|
Chris@128
|
684 //!!! shortcut etc
|
Chris@128
|
685 connect(cycleNotesAction, SIGNAL(triggered()), this, SLOT(cycleNotes()));
|
Chris@128
|
686
|
Chris@128
|
687 m_notesStatus = new QLabel();
|
Chris@128
|
688 toolbar->addWidget(m_notesStatus);
|
Chris@128
|
689
|
Chris@128
|
690 updateLayerStatuses();
|
Chris@128
|
691
|
Chris@0
|
692 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
693 }
|
Chris@0
|
694
|
Chris@0
|
695 void
|
Chris@70
|
696 MainWindow::toolNavigateSelected()
|
Chris@70
|
697 {
|
Chris@70
|
698 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@70
|
699 m_intelligentActionOn = true;
|
Chris@70
|
700 }
|
Chris@70
|
701
|
Chris@70
|
702 void
|
Chris@70
|
703 MainWindow::toolEditSelected()
|
Chris@70
|
704 {
|
Chris@77
|
705 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
706 m_intelligentActionOn = true;
|
Chris@70
|
707 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
708 }
|
Chris@70
|
709
|
Chris@70
|
710 void
|
Chris@70
|
711 MainWindow::toolFreeEditSelected()
|
Chris@70
|
712 {
|
Chris@77
|
713 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
714 m_intelligentActionOn = false;
|
Chris@70
|
715 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
716 }
|
Chris@70
|
717
|
gyorgyf@21
|
718 void
|
Chris@0
|
719 MainWindow::updateMenuStates()
|
Chris@0
|
720 {
|
Chris@0
|
721 MainWindowBase::updateMenuStates();
|
Chris@0
|
722
|
Chris@0
|
723 Pane *currentPane = 0;
|
Chris@0
|
724 Layer *currentLayer = 0;
|
Chris@0
|
725
|
Chris@0
|
726 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
727 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@0
|
728
|
Chris@0
|
729 bool haveCurrentPane =
|
Chris@0
|
730 (currentPane != 0);
|
Chris@0
|
731 bool haveCurrentLayer =
|
Chris@0
|
732 (haveCurrentPane &&
|
Chris@0
|
733 (currentLayer != 0));
|
Chris@0
|
734 bool haveSelection =
|
gyorgyf@27
|
735 (m_viewManager &&
|
gyorgyf@27
|
736 !m_viewManager->getSelections().empty());
|
Chris@0
|
737 bool haveCurrentEditableLayer =
|
gyorgyf@27
|
738 (haveCurrentLayer &&
|
gyorgyf@27
|
739 currentLayer->isLayerEditable());
|
Chris@0
|
740 bool haveCurrentTimeInstantsLayer =
|
gyorgyf@27
|
741 (haveCurrentLayer &&
|
gyorgyf@27
|
742 qobject_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
743 bool haveCurrentTimeValueLayer =
|
gyorgyf@27
|
744 (haveCurrentLayer &&
|
gyorgyf@27
|
745 qobject_cast<TimeValueLayer *>(currentLayer));
|
Chris@0
|
746
|
Chris@0
|
747 emit canChangePlaybackSpeed(true);
|
Chris@0
|
748 int v = m_playSpeed->value();
|
Chris@0
|
749 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@0
|
750 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@0
|
751
|
Chris@0
|
752 if (m_ffwdAction && m_rwdAction) {
|
Chris@0
|
753 if (haveCurrentTimeInstantsLayer) {
|
Chris@0
|
754 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@0
|
755 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
756 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@0
|
757 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
758 } else if (haveCurrentTimeValueLayer) {
|
Chris@0
|
759 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@0
|
760 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@0
|
761 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@0
|
762 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@0
|
763 } else {
|
Chris@0
|
764 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@0
|
765 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@0
|
766 m_rwdAction->setText(tr("Rewind"));
|
Chris@0
|
767 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@0
|
768 }
|
Chris@0
|
769 }
|
Chris@0
|
770 }
|
Chris@0
|
771
|
Chris@0
|
772 void
|
Chris@128
|
773 MainWindow::updateLayerStatuses()
|
Chris@128
|
774 {
|
Chris@128
|
775 IconLoader il;
|
Chris@128
|
776 QPixmap eye = il.loadPixmap("eye");
|
Chris@128
|
777 QPixmap speaker = il.loadPixmap("speaker");
|
Chris@128
|
778
|
Chris@128
|
779 // NB these need to be in the same order as the Analyser::Component enum
|
Chris@128
|
780 QLabel *statuses[] = { m_waveformStatus, m_pitchStatus, m_notesStatus };
|
Chris@128
|
781
|
Chris@128
|
782 for (int i = 0; i < sizeof(statuses)/sizeof(statuses[0]); ++i) {
|
Chris@128
|
783 QPixmap p(40, 16);
|
Chris@128
|
784 p.fill(QColor(0, 0, 0, 0));
|
Chris@128
|
785 QPainter paint(&p);
|
Chris@128
|
786 if (m_analyser->isVisible((Analyser::Component)i)) {
|
Chris@128
|
787 paint.drawPixmap(0, 0, eye);
|
Chris@128
|
788 }
|
Chris@128
|
789 if (m_analyser->isAudible((Analyser::Component)i)) {
|
Chris@128
|
790 paint.drawPixmap(20, 0, speaker);
|
Chris@128
|
791 }
|
Chris@128
|
792 statuses[i]->setPixmap(p);
|
Chris@128
|
793 }
|
Chris@128
|
794 }
|
Chris@128
|
795
|
Chris@128
|
796 void
|
Chris@128
|
797 MainWindow::cycleWaveform()
|
Chris@128
|
798 {
|
Chris@128
|
799 cerr << "cycleWaveform" << endl;
|
Chris@128
|
800 m_analyser->cycleStatus(Analyser::Audio);
|
Chris@128
|
801 updateLayerStatuses();
|
Chris@128
|
802 }
|
Chris@128
|
803
|
Chris@128
|
804 void
|
Chris@128
|
805 MainWindow::cyclePitch()
|
Chris@128
|
806 {
|
Chris@128
|
807 cerr << "cyclePitch" << endl;
|
Chris@128
|
808 m_analyser->cycleStatus(Analyser::PitchTrack);
|
Chris@128
|
809 updateLayerStatuses();
|
Chris@128
|
810 }
|
Chris@128
|
811
|
Chris@128
|
812 void
|
Chris@128
|
813 MainWindow::cycleNotes()
|
Chris@128
|
814 {
|
Chris@128
|
815 cerr << "cycleNotes" << endl;
|
Chris@128
|
816 m_analyser->cycleStatus(Analyser::Notes);
|
Chris@128
|
817 updateLayerStatuses();
|
Chris@128
|
818 }
|
Chris@128
|
819
|
Chris@128
|
820 void
|
Chris@0
|
821 MainWindow::updateDescriptionLabel()
|
Chris@0
|
822 {
|
Chris@6
|
823 // Nothing, we don't have one
|
Chris@0
|
824 }
|
Chris@0
|
825
|
Chris@0
|
826 void
|
Chris@0
|
827 MainWindow::documentModified()
|
Chris@0
|
828 {
|
Chris@0
|
829 MainWindowBase::documentModified();
|
Chris@0
|
830 }
|
Chris@0
|
831
|
Chris@0
|
832 void
|
Chris@0
|
833 MainWindow::documentRestored()
|
Chris@0
|
834 {
|
Chris@0
|
835 MainWindowBase::documentRestored();
|
Chris@0
|
836 }
|
Chris@0
|
837
|
Chris@0
|
838 void
|
Chris@0
|
839 MainWindow::newSession()
|
Chris@0
|
840 {
|
Chris@0
|
841 if (!checkSaveModified()) return;
|
Chris@0
|
842
|
Chris@0
|
843 closeSession();
|
Chris@0
|
844 createDocument();
|
Chris@0
|
845 m_document->setAutoAlignment(true);
|
Chris@0
|
846
|
Chris@0
|
847 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
848
|
Chris@0
|
849 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
850 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
851
|
Chris@6
|
852 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@6
|
853 // m_document->addLayerToView(pane, waveform);
|
Chris@0
|
854
|
Chris@0
|
855 m_overview->registerView(pane);
|
Chris@0
|
856
|
Chris@0
|
857 CommandHistory::getInstance()->clear();
|
Chris@0
|
858 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
859 documentRestored();
|
Chris@0
|
860 updateMenuStates();
|
Chris@0
|
861 }
|
Chris@0
|
862
|
Chris@0
|
863 void
|
Chris@0
|
864 MainWindow::closeSession()
|
Chris@0
|
865 {
|
Chris@0
|
866 if (!checkSaveModified()) return;
|
Chris@0
|
867
|
Chris@0
|
868 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
869
|
gyorgyf@27
|
870 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
871
|
gyorgyf@27
|
872 while (pane->getLayerCount() > 0) {
|
gyorgyf@27
|
873 m_document->removeLayerFromView
|
gyorgyf@27
|
874 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
gyorgyf@27
|
875 }
|
Chris@0
|
876
|
gyorgyf@27
|
877 m_overview->unregisterView(pane);
|
gyorgyf@27
|
878 m_paneStack->deletePane(pane);
|
Chris@0
|
879 }
|
Chris@0
|
880
|
Chris@0
|
881 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
882
|
gyorgyf@27
|
883 Pane *pane = m_paneStack->getHiddenPane
|
gyorgyf@27
|
884 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
885
|
gyorgyf@27
|
886 while (pane->getLayerCount() > 0) {
|
gyorgyf@27
|
887 m_document->removeLayerFromView
|
gyorgyf@27
|
888 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
gyorgyf@27
|
889 }
|
Chris@0
|
890
|
gyorgyf@27
|
891 m_overview->unregisterView(pane);
|
gyorgyf@27
|
892 m_paneStack->deletePane(pane);
|
Chris@0
|
893 }
|
Chris@0
|
894
|
Chris@0
|
895 delete m_document;
|
Chris@0
|
896 m_document = 0;
|
Chris@0
|
897 m_viewManager->clearSelections();
|
Chris@0
|
898 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
899
|
Chris@0
|
900 m_sessionFile = "";
|
Chris@0
|
901
|
Chris@0
|
902 CommandHistory::getInstance()->clear();
|
Chris@0
|
903 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
904 documentRestored();
|
Chris@0
|
905 }
|
Chris@0
|
906
|
Chris@0
|
907 void
|
Chris@0
|
908 MainWindow::openFile()
|
Chris@0
|
909 {
|
Chris@0
|
910 QString orig = m_audioFile;
|
Chris@0
|
911 if (orig == "") orig = ".";
|
Chris@0
|
912 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
913
|
Chris@0
|
914 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
915
|
Chris@0
|
916 if (path.isEmpty()) return;
|
Chris@0
|
917
|
Chris@1
|
918 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
919
|
Chris@0
|
920 if (status == FileOpenFailed) {
|
Chris@0
|
921 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
922 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@0
|
923 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
924 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
925 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
926 }
|
Chris@0
|
927 }
|
Chris@0
|
928
|
Chris@0
|
929 void
|
Chris@0
|
930 MainWindow::openLocation()
|
Chris@0
|
931 {
|
Chris@0
|
932 QSettings settings;
|
Chris@0
|
933 settings.beginGroup("MainWindow");
|
Chris@0
|
934 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@0
|
935
|
Chris@0
|
936 bool ok = false;
|
Chris@0
|
937 QString text = QInputDialog::getText
|
Chris@0
|
938 (this, tr("Open Location"),
|
Chris@0
|
939 tr("Please enter the URL of the location to open:"),
|
Chris@0
|
940 QLineEdit::Normal, lastLocation, &ok);
|
Chris@0
|
941
|
Chris@0
|
942 if (!ok) return;
|
Chris@0
|
943
|
Chris@0
|
944 settings.setValue("lastremote", text);
|
Chris@0
|
945
|
Chris@0
|
946 if (text.isEmpty()) return;
|
Chris@0
|
947
|
Chris@1
|
948 FileOpenStatus status = open(text, ReplaceSession);
|
Chris@0
|
949
|
Chris@0
|
950 if (status == FileOpenFailed) {
|
Chris@0
|
951 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
952 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@0
|
953 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
954 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
955 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
956 }
|
Chris@0
|
957 }
|
Chris@0
|
958
|
Chris@0
|
959 void
|
Chris@0
|
960 MainWindow::openRecentFile()
|
Chris@0
|
961 {
|
Chris@0
|
962 QObject *obj = sender();
|
Chris@3
|
963 QAction *action = qobject_cast<QAction *>(obj);
|
Chris@0
|
964
|
Chris@0
|
965 if (!action) {
|
Chris@70
|
966 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@70
|
967 << endl;
|
gyorgyf@27
|
968 return;
|
Chris@0
|
969 }
|
Chris@0
|
970
|
Chris@0
|
971 QString path = action->text();
|
Chris@0
|
972 if (path == "") return;
|
Chris@0
|
973
|
Chris@1
|
974 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
975
|
Chris@0
|
976 if (status == FileOpenFailed) {
|
Chris@0
|
977 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
978 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@0
|
979 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
980 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
981 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
982 }
|
Chris@0
|
983 }
|
Chris@0
|
984
|
Chris@0
|
985 void
|
Chris@0
|
986 MainWindow::paneAdded(Pane *pane)
|
Chris@0
|
987 {
|
Chris@6
|
988 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
989 m_paneStack->sizePanesEqually();
|
Chris@0
|
990 if (m_overview) m_overview->registerView(pane);
|
Chris@0
|
991 }
|
Chris@0
|
992
|
Chris@0
|
993 void
|
Chris@0
|
994 MainWindow::paneHidden(Pane *pane)
|
Chris@0
|
995 {
|
Chris@0
|
996 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
997 }
|
Chris@0
|
998
|
Chris@0
|
999 void
|
Chris@0
|
1000 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@0
|
1001 {
|
Chris@0
|
1002 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1003 }
|
Chris@0
|
1004
|
Chris@0
|
1005 void
|
Chris@0
|
1006 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@0
|
1007 {
|
Chris@4
|
1008 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1009
|
Chris@0
|
1010 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@0
|
1011
|
Chris@1
|
1012 FileOpenStatus status = open(*i, ReplaceSession);
|
Chris@0
|
1013
|
Chris@0
|
1014 if (status == FileOpenFailed) {
|
Chris@0
|
1015 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1016 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@0
|
1017 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1018 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1019 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1020 }
|
Chris@0
|
1021 }
|
Chris@0
|
1022 }
|
Chris@0
|
1023
|
Chris@0
|
1024 void
|
Chris@0
|
1025 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@0
|
1026 {
|
Chris@0
|
1027 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1028
|
Chris@0
|
1029 QUrl testUrl(text);
|
Chris@0
|
1030 if (testUrl.scheme() == "file" ||
|
Chris@0
|
1031 testUrl.scheme() == "http" ||
|
Chris@0
|
1032 testUrl.scheme() == "ftp") {
|
Chris@0
|
1033 QStringList list;
|
Chris@0
|
1034 list.push_back(text);
|
Chris@0
|
1035 paneDropAccepted(pane, list);
|
Chris@0
|
1036 return;
|
Chris@0
|
1037 }
|
Chris@0
|
1038
|
Chris@0
|
1039 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@0
|
1040 //to a text layer?
|
Chris@0
|
1041 }
|
Chris@0
|
1042
|
Chris@0
|
1043 void
|
Chris@0
|
1044 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
1045 {
|
Chris@70
|
1046 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@0
|
1047
|
Chris@0
|
1048 if (m_openingAudioFile) {
|
Chris@70
|
1049 // cerr << "Busy - ignoring close event" << endl;
|
gyorgyf@27
|
1050 e->ignore();
|
gyorgyf@27
|
1051 return;
|
Chris@0
|
1052 }
|
Chris@0
|
1053
|
Chris@0
|
1054 if (!m_abandoning && !checkSaveModified()) {
|
Chris@70
|
1055 // cerr << "Ignoring close event" << endl;
|
gyorgyf@27
|
1056 e->ignore();
|
gyorgyf@27
|
1057 return;
|
Chris@0
|
1058 }
|
Chris@0
|
1059
|
Chris@0
|
1060 QSettings settings;
|
Chris@0
|
1061 settings.beginGroup("MainWindow");
|
Chris@0
|
1062 settings.setValue("size", size());
|
Chris@0
|
1063 settings.setValue("position", pos());
|
Chris@0
|
1064 settings.endGroup();
|
Chris@0
|
1065
|
Chris@0
|
1066 delete m_keyReference;
|
Chris@0
|
1067 m_keyReference = 0;
|
Chris@0
|
1068
|
Chris@0
|
1069 closeSession();
|
Chris@0
|
1070
|
Chris@0
|
1071 e->accept();
|
Chris@0
|
1072 return;
|
Chris@0
|
1073 }
|
Chris@0
|
1074
|
Chris@0
|
1075 bool
|
Chris@0
|
1076 MainWindow::commitData(bool mayAskUser)
|
Chris@0
|
1077 {
|
Chris@0
|
1078 if (mayAskUser) {
|
Chris@0
|
1079 bool rv = checkSaveModified();
|
Chris@0
|
1080 return rv;
|
Chris@0
|
1081 } else {
|
Chris@0
|
1082 if (!m_documentModified) return true;
|
Chris@0
|
1083
|
Chris@0
|
1084 // If we can't check with the user first, then we can't save
|
Chris@0
|
1085 // to the original session file (even if we have it) -- have
|
Chris@0
|
1086 // to use a temporary file
|
Chris@0
|
1087
|
Chris@0
|
1088 QString svDirBase = ".sv1";
|
Chris@0
|
1089 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@0
|
1090
|
Chris@0
|
1091 if (!QFileInfo(svDir).exists()) {
|
Chris@0
|
1092 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@0
|
1093 } else {
|
Chris@0
|
1094 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@0
|
1095 }
|
Chris@0
|
1096
|
Chris@0
|
1097 // This name doesn't have to be unguessable
|
Chris@0
|
1098 #ifndef _WIN32
|
Chris@0
|
1099 QString fname = QString("tmp-%1-%2.sv")
|
Chris@0
|
1100 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@0
|
1101 .arg(QProcess().pid());
|
Chris@0
|
1102 #else
|
Chris@0
|
1103 QString fname = QString("tmp-%1.sv")
|
Chris@0
|
1104 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@0
|
1105 #endif
|
Chris@0
|
1106 QString fpath = QDir(svDir).filePath(fname);
|
Chris@0
|
1107 if (saveSessionFile(fpath)) {
|
Chris@0
|
1108 m_recentFiles.addFile(fpath);
|
Chris@0
|
1109 return true;
|
Chris@0
|
1110 } else {
|
Chris@0
|
1111 return false;
|
Chris@0
|
1112 }
|
Chris@0
|
1113 }
|
Chris@0
|
1114 }
|
Chris@0
|
1115
|
Chris@0
|
1116 bool
|
Chris@0
|
1117 MainWindow::checkSaveModified()
|
Chris@0
|
1118 {
|
Chris@0
|
1119 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
1120 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
1121 // cancel.
|
Chris@0
|
1122
|
Chris@0
|
1123 if (!m_documentModified) return true;
|
Chris@0
|
1124
|
Chris@0
|
1125 int button =
|
gyorgyf@27
|
1126 QMessageBox::warning(this,
|
gyorgyf@27
|
1127 tr("Session modified"),
|
gyorgyf@27
|
1128 tr("The current session has been modified.\nDo you want to save it?"),
|
gyorgyf@27
|
1129 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@0
|
1130 QMessageBox::Yes);
|
Chris@0
|
1131
|
Chris@0
|
1132 if (button == QMessageBox::Yes) {
|
gyorgyf@27
|
1133 saveSession();
|
gyorgyf@27
|
1134 if (m_documentModified) { // save failed -- don't proceed!
|
gyorgyf@27
|
1135 return false;
|
gyorgyf@27
|
1136 } else {
|
Chris@0
|
1137 return true; // saved, so it's safe to continue now
|
Chris@0
|
1138 }
|
Chris@0
|
1139 } else if (button == QMessageBox::No) {
|
gyorgyf@27
|
1140 m_documentModified = false; // so we know to abandon it
|
gyorgyf@27
|
1141 return true;
|
Chris@0
|
1142 }
|
Chris@0
|
1143
|
Chris@0
|
1144 // else cancel
|
Chris@0
|
1145 return false;
|
Chris@0
|
1146 }
|
Chris@0
|
1147
|
Chris@0
|
1148 void
|
Chris@0
|
1149 MainWindow::saveSession()
|
Chris@0
|
1150 {
|
Chris@0
|
1151 if (m_sessionFile != "") {
|
gyorgyf@27
|
1152 if (!saveSessionFile(m_sessionFile)) {
|
gyorgyf@27
|
1153 QMessageBox::critical(this, tr("Failed to save file"),
|
gyorgyf@27
|
1154 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
1155 } else {
|
gyorgyf@27
|
1156 CommandHistory::getInstance()->documentSaved();
|
gyorgyf@27
|
1157 documentRestored();
|
gyorgyf@27
|
1158 }
|
gyorgyf@27
|
1159 } else {
|
gyorgyf@27
|
1160 saveSessionAs();
|
Chris@0
|
1161 }
|
Chris@0
|
1162 }
|
Chris@0
|
1163
|
Chris@0
|
1164 void
|
Chris@0
|
1165 MainWindow::saveSessionAs()
|
Chris@0
|
1166 {
|
Chris@0
|
1167 QString orig = m_audioFile;
|
Chris@0
|
1168 if (orig == "") orig = ".";
|
Chris@0
|
1169 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1170
|
Chris@0
|
1171 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@0
|
1172
|
Chris@0
|
1173 if (path == "") return;
|
Chris@0
|
1174
|
Chris@0
|
1175 if (!saveSessionFile(path)) {
|
Chris@85
|
1176 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@85
|
1177 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
1178 } else {
|
Chris@85
|
1179 setWindowTitle(tr("%1: %2")
|
Chris@0
|
1180 .arg(QApplication::applicationName())
|
Chris@85
|
1181 .arg(QFileInfo(path).fileName()));
|
Chris@85
|
1182 m_sessionFile = path;
|
Chris@85
|
1183 CommandHistory::getInstance()->documentSaved();
|
Chris@85
|
1184 documentRestored();
|
Chris@0
|
1185 m_recentFiles.addFile(path);
|
Chris@0
|
1186 }
|
Chris@0
|
1187 }
|
Chris@0
|
1188
|
Chris@85
|
1189 QString
|
Chris@85
|
1190 MainWindow::exportToSVL(QString path, Layer *layer)
|
Chris@85
|
1191 {
|
Chris@85
|
1192 Model *model = layer->getModel();
|
Chris@85
|
1193
|
Chris@85
|
1194 QFile file(path);
|
Chris@85
|
1195 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@85
|
1196 return tr("Failed to open file %1 for writing").arg(path);
|
Chris@85
|
1197 } else {
|
Chris@85
|
1198 QTextStream out(&file);
|
Chris@85
|
1199 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@85
|
1200 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@85
|
1201 << "<sv>\n"
|
Chris@85
|
1202 << " <data>\n";
|
Chris@85
|
1203
|
Chris@85
|
1204 model->toXml(out, " ");
|
Chris@85
|
1205
|
Chris@85
|
1206 out << " </data>\n"
|
Chris@85
|
1207 << " <display>\n";
|
Chris@85
|
1208
|
Chris@85
|
1209 layer->toXml(out, " ");
|
Chris@85
|
1210
|
Chris@85
|
1211 out << " </display>\n"
|
Chris@85
|
1212 << "</sv>\n";
|
Chris@85
|
1213
|
Chris@85
|
1214 return "";
|
Chris@85
|
1215 }
|
Chris@85
|
1216 }
|
Chris@85
|
1217
|
Chris@0
|
1218 void
|
Chris@85
|
1219 MainWindow::exportPitchLayer()
|
matthiasm@26
|
1220 {
|
Chris@85
|
1221 Layer *layer = 0;
|
Chris@85
|
1222 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@85
|
1223 Pane *pane = m_paneStack->getPane(i);
|
Chris@85
|
1224 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@85
|
1225 layer = qobject_cast<TimeValueLayer *>(pane->getLayer(j));
|
Chris@85
|
1226 if (layer) break;
|
Chris@85
|
1227 }
|
Chris@85
|
1228 if (layer) break;
|
Chris@85
|
1229 }
|
matthiasm@26
|
1230
|
matthiasm@26
|
1231 if (!layer) return;
|
matthiasm@26
|
1232
|
Chris@85
|
1233 SparseTimeValueModel *model =
|
Chris@85
|
1234 qobject_cast<SparseTimeValueModel *>(layer->getModel());
|
matthiasm@26
|
1235 if (!model) return;
|
matthiasm@26
|
1236
|
Chris@96
|
1237 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
|
matthiasm@26
|
1238
|
matthiasm@26
|
1239 QString path = getSaveFileName(type);
|
matthiasm@26
|
1240
|
matthiasm@26
|
1241 if (path == "") return;
|
matthiasm@26
|
1242
|
matthiasm@26
|
1243 if (QFileInfo(path).suffix() == "") path += ".svl";
|
matthiasm@26
|
1244
|
matthiasm@26
|
1245 QString suffix = QFileInfo(path).suffix().toLower();
|
matthiasm@26
|
1246
|
matthiasm@26
|
1247 QString error;
|
matthiasm@26
|
1248
|
matthiasm@26
|
1249 if (suffix == "xml" || suffix == "svl") {
|
matthiasm@26
|
1250
|
Chris@85
|
1251 error = exportToSVL(path, layer);
|
matthiasm@26
|
1252
|
matthiasm@26
|
1253 } else if (suffix == "ttl" || suffix == "n3") {
|
matthiasm@26
|
1254
|
Chris@85
|
1255 RDFExporter exporter(path, model);
|
Chris@85
|
1256 exporter.write();
|
Chris@85
|
1257 if (!exporter.isOK()) {
|
Chris@85
|
1258 error = exporter.getError();
|
Chris@85
|
1259 }
|
Chris@85
|
1260
|
Chris@85
|
1261 } else {
|
Chris@85
|
1262
|
Chris@85
|
1263 CSVFileWriter writer(path, model,
|
Chris@85
|
1264 ((suffix == "csv") ? "," : "\t"));
|
Chris@85
|
1265 writer.write();
|
Chris@85
|
1266
|
Chris@85
|
1267 if (!writer.isOK()) {
|
Chris@85
|
1268 error = writer.getError();
|
Chris@85
|
1269 }
|
Chris@85
|
1270 }
|
Chris@85
|
1271
|
Chris@85
|
1272 if (error != "") {
|
Chris@85
|
1273 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@85
|
1274 } else {
|
Chris@85
|
1275 m_recentFiles.addFile(path);
|
Chris@85
|
1276 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@85
|
1277 }
|
Chris@85
|
1278 }
|
Chris@85
|
1279
|
Chris@85
|
1280 void
|
Chris@85
|
1281 MainWindow::exportNoteLayer()
|
Chris@85
|
1282 {
|
Chris@85
|
1283 Layer *layer = 0;
|
Chris@85
|
1284 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@85
|
1285 Pane *pane = m_paneStack->getPane(i);
|
Chris@85
|
1286 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@85
|
1287 layer = qobject_cast<FlexiNoteLayer *>(pane->getLayer(j));
|
Chris@85
|
1288 if (layer) break;
|
Chris@85
|
1289 }
|
Chris@85
|
1290 if (layer) break;
|
Chris@85
|
1291 }
|
Chris@85
|
1292
|
Chris@85
|
1293 if (!layer) return;
|
Chris@85
|
1294
|
Chris@85
|
1295 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
Chris@85
|
1296 if (!model) return;
|
Chris@85
|
1297
|
Chris@96
|
1298 FileFinder::FileType type = FileFinder::LayerFileNonSV;
|
Chris@85
|
1299
|
Chris@85
|
1300 QString path = getSaveFileName(type);
|
Chris@85
|
1301
|
Chris@85
|
1302 if (path == "") return;
|
Chris@85
|
1303
|
Chris@85
|
1304 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@85
|
1305
|
Chris@85
|
1306 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@85
|
1307
|
Chris@85
|
1308 QString error;
|
Chris@85
|
1309
|
Chris@85
|
1310 if (suffix == "xml" || suffix == "svl") {
|
Chris@85
|
1311
|
Chris@85
|
1312 error = exportToSVL(path, layer);
|
Chris@85
|
1313
|
Chris@85
|
1314 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@85
|
1315
|
Chris@85
|
1316 MIDIFileWriter writer(path, model, model->getSampleRate());
|
Chris@85
|
1317 writer.write();
|
Chris@85
|
1318 if (!writer.isOK()) {
|
Chris@85
|
1319 error = writer.getError();
|
Chris@85
|
1320 }
|
Chris@85
|
1321
|
Chris@85
|
1322 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@85
|
1323
|
Chris@85
|
1324 RDFExporter exporter(path, model);
|
Chris@85
|
1325 exporter.write();
|
Chris@85
|
1326 if (!exporter.isOK()) {
|
Chris@85
|
1327 error = exporter.getError();
|
matthiasm@26
|
1328 }
|
matthiasm@26
|
1329
|
matthiasm@26
|
1330 } else {
|
matthiasm@26
|
1331
|
matthiasm@26
|
1332 CSVFileWriter writer(path, model,
|
matthiasm@26
|
1333 ((suffix == "csv") ? "," : "\t"));
|
matthiasm@26
|
1334 writer.write();
|
matthiasm@26
|
1335
|
matthiasm@26
|
1336 if (!writer.isOK()) {
|
matthiasm@26
|
1337 error = writer.getError();
|
matthiasm@26
|
1338 }
|
matthiasm@26
|
1339 }
|
matthiasm@26
|
1340
|
matthiasm@26
|
1341 if (error != "") {
|
matthiasm@26
|
1342 QMessageBox::critical(this, tr("Failed to write file"), error);
|
matthiasm@26
|
1343 } else {
|
matthiasm@26
|
1344 m_recentFiles.addFile(path);
|
matthiasm@26
|
1345 emit activity(tr("Export layer to \"%1\"").arg(path));
|
matthiasm@26
|
1346 }
|
matthiasm@26
|
1347 }
|
matthiasm@26
|
1348
|
matthiasm@26
|
1349
|
matthiasm@26
|
1350 void
|
Chris@0
|
1351 MainWindow::renameCurrentLayer()
|
Chris@0
|
1352 {
|
Chris@0
|
1353 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
1354 if (pane) {
|
gyorgyf@27
|
1355 Layer *layer = pane->getSelectedLayer();
|
gyorgyf@27
|
1356 if (layer) {
|
gyorgyf@27
|
1357 bool ok = false;
|
gyorgyf@27
|
1358 QString newName = QInputDialog::getText
|
gyorgyf@27
|
1359 (this, tr("Rename Layer"),
|
gyorgyf@27
|
1360 tr("New name for this layer:"),
|
gyorgyf@27
|
1361 QLineEdit::Normal, layer->objectName(), &ok);
|
gyorgyf@27
|
1362 if (ok) {
|
gyorgyf@27
|
1363 layer->setObjectName(newName);
|
gyorgyf@27
|
1364 }
|
gyorgyf@27
|
1365 }
|
Chris@0
|
1366 }
|
Chris@0
|
1367 }
|
Chris@0
|
1368
|
Chris@0
|
1369 void
|
Chris@0
|
1370 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
1371 {
|
Chris@0
|
1372 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@0
|
1373
|
Chris@0
|
1374 float percent = m_playSpeed->mappedValue();
|
Chris@0
|
1375 float factor = mapper.getFactorForValue(percent);
|
Chris@0
|
1376
|
Chris@70
|
1377 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
|
Chris@0
|
1378
|
Chris@0
|
1379 bool something = (position != 100);
|
Chris@0
|
1380
|
Chris@0
|
1381 int pc = lrintf(percent);
|
Chris@0
|
1382
|
Chris@0
|
1383 if (!something) {
|
Chris@0
|
1384 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@0
|
1385 } else {
|
Chris@0
|
1386 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@0
|
1387 .arg(position > 100 ? "+" : "")
|
Chris@0
|
1388 .arg(pc));
|
Chris@0
|
1389 }
|
Chris@0
|
1390
|
Chris@0
|
1391 m_playSource->setTimeStretch(factor);
|
Chris@0
|
1392
|
Chris@0
|
1393 updateMenuStates();
|
Chris@0
|
1394 }
|
Chris@0
|
1395
|
Chris@0
|
1396 void
|
Chris@0
|
1397 MainWindow::playSharpenToggled()
|
Chris@0
|
1398 {
|
Chris@0
|
1399 QSettings settings;
|
Chris@0
|
1400 settings.beginGroup("MainWindow");
|
Chris@0
|
1401 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@0
|
1402 settings.endGroup();
|
Chris@0
|
1403
|
Chris@0
|
1404 playSpeedChanged(m_playSpeed->value());
|
Chris@0
|
1405 }
|
Chris@0
|
1406
|
Chris@0
|
1407 void
|
Chris@0
|
1408 MainWindow::playMonoToggled()
|
Chris@0
|
1409 {
|
Chris@0
|
1410 QSettings settings;
|
Chris@0
|
1411 settings.beginGroup("MainWindow");
|
Chris@0
|
1412 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@0
|
1413 settings.endGroup();
|
Chris@0
|
1414
|
Chris@0
|
1415 playSpeedChanged(m_playSpeed->value());
|
Chris@0
|
1416 }
|
Chris@0
|
1417
|
Chris@0
|
1418 void
|
Chris@0
|
1419 MainWindow::speedUpPlayback()
|
Chris@0
|
1420 {
|
Chris@0
|
1421 int value = m_playSpeed->value();
|
Chris@0
|
1422 value = value + m_playSpeed->pageStep();
|
Chris@0
|
1423 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@0
|
1424 m_playSpeed->setValue(value);
|
Chris@0
|
1425 }
|
Chris@0
|
1426
|
Chris@0
|
1427 void
|
Chris@0
|
1428 MainWindow::slowDownPlayback()
|
Chris@0
|
1429 {
|
Chris@0
|
1430 int value = m_playSpeed->value();
|
Chris@0
|
1431 value = value - m_playSpeed->pageStep();
|
Chris@0
|
1432 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@0
|
1433 m_playSpeed->setValue(value);
|
Chris@0
|
1434 }
|
Chris@0
|
1435
|
Chris@0
|
1436 void
|
Chris@0
|
1437 MainWindow::restoreNormalPlayback()
|
Chris@0
|
1438 {
|
Chris@0
|
1439 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@0
|
1440 }
|
Chris@0
|
1441
|
Chris@0
|
1442 void
|
Chris@0
|
1443 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@0
|
1444 {
|
Chris@0
|
1445 if (!getMainModel() || !p) {
|
Chris@0
|
1446 return;
|
Chris@0
|
1447 }
|
Chris@0
|
1448
|
Chris@0
|
1449 bool haveSelection = false;
|
Chris@0
|
1450 size_t startFrame = 0, endFrame = 0;
|
Chris@0
|
1451
|
Chris@0
|
1452 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@0
|
1453
|
Chris@0
|
1454 bool exclusive = false;
|
Chris@0
|
1455 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@0
|
1456
|
Chris@0
|
1457 if (!s.isEmpty()) {
|
Chris@0
|
1458 haveSelection = true;
|
Chris@0
|
1459 startFrame = s.getStartFrame();
|
Chris@0
|
1460 endFrame = s.getEndFrame();
|
Chris@0
|
1461 }
|
Chris@0
|
1462 }
|
Chris@0
|
1463
|
Chris@0
|
1464 if (!haveSelection) {
|
Chris@0
|
1465 startFrame = p->getFirstVisibleFrame();
|
Chris@0
|
1466 endFrame = p->getLastVisibleFrame();
|
Chris@0
|
1467 }
|
Chris@0
|
1468
|
Chris@0
|
1469 RealTime start = RealTime::frame2RealTime
|
Chris@0
|
1470 (startFrame, getMainModel()->getSampleRate());
|
Chris@0
|
1471
|
Chris@0
|
1472 RealTime end = RealTime::frame2RealTime
|
Chris@0
|
1473 (endFrame, getMainModel()->getSampleRate());
|
Chris@0
|
1474
|
Chris@0
|
1475 RealTime duration = end - start;
|
Chris@0
|
1476
|
Chris@0
|
1477 QString startStr, endStr, durationStr;
|
Chris@0
|
1478 startStr = start.toText(true).c_str();
|
Chris@0
|
1479 endStr = end.toText(true).c_str();
|
Chris@0
|
1480 durationStr = duration.toText(true).c_str();
|
Chris@0
|
1481
|
Chris@0
|
1482 if (haveSelection) {
|
Chris@0
|
1483 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@0
|
1484 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
1485 } else {
|
Chris@0
|
1486 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@0
|
1487 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
1488 }
|
matthiasm@42
|
1489
|
matthiasm@42
|
1490 // scale Y axis
|
matthiasm@42
|
1491 FlexiNoteLayer *fnl = dynamic_cast<FlexiNoteLayer *>(p->getLayer(2));
|
matthiasm@42
|
1492 if (fnl) {
|
matthiasm@42
|
1493 fnl->setVerticalRangeToNoteRange(p);
|
matthiasm@42
|
1494 }
|
matthiasm@42
|
1495
|
Chris@0
|
1496 statusBar()->showMessage(m_myStatusMessage);
|
Chris@0
|
1497 }
|
Chris@0
|
1498
|
Chris@0
|
1499 void
|
Chris@0
|
1500 MainWindow::updatePositionStatusDisplays() const
|
Chris@0
|
1501 {
|
Chris@0
|
1502 if (!statusBar()->isVisible()) return;
|
Chris@0
|
1503
|
Chris@0
|
1504 }
|
Chris@0
|
1505
|
Chris@0
|
1506 void
|
Chris@0
|
1507 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
1508 {
|
Chris@0
|
1509 m_fader->setPeakLeft(left);
|
Chris@0
|
1510 m_fader->setPeakRight(right);
|
Chris@0
|
1511 }
|
Chris@0
|
1512
|
Chris@0
|
1513 void
|
Chris@0
|
1514 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
1515 bool willResample)
|
Chris@0
|
1516 {
|
Chris@0
|
1517 updateDescriptionLabel();
|
Chris@0
|
1518 }
|
Chris@0
|
1519
|
Chris@0
|
1520 void
|
Chris@0
|
1521 MainWindow::audioOverloadPluginDisabled()
|
Chris@0
|
1522 {
|
Chris@0
|
1523 QMessageBox::information
|
Chris@0
|
1524 (this, tr("Audio processing overload"),
|
Chris@0
|
1525 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@0
|
1526 }
|
Chris@0
|
1527
|
Chris@0
|
1528 void
|
Chris@0
|
1529 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@0
|
1530 {
|
Chris@0
|
1531 static bool shownOnce = false;
|
Chris@0
|
1532 if (shownOnce) return;
|
Chris@0
|
1533 QMessageBox::information
|
Chris@0
|
1534 (this, tr("Audio processing overload"),
|
Chris@0
|
1535 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@0
|
1536 shownOnce = true;
|
Chris@0
|
1537 }
|
Chris@0
|
1538
|
Chris@0
|
1539 void
|
Chris@0
|
1540 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
1541 {
|
Chris@0
|
1542 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
1543 }
|
Chris@0
|
1544
|
Chris@0
|
1545 void
|
Chris@0
|
1546 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
1547 {
|
Chris@0
|
1548 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
1549 }
|
Chris@0
|
1550
|
Chris@0
|
1551 void
|
Chris@0
|
1552 MainWindow::modelAdded(Model *model)
|
Chris@0
|
1553 {
|
Chris@0
|
1554 MainWindowBase::modelAdded(model);
|
Chris@3
|
1555 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
|
Chris@0
|
1556 if (dtvm) {
|
Chris@70
|
1557 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
|
Chris@0
|
1558 }
|
Chris@0
|
1559 }
|
Chris@0
|
1560
|
Chris@0
|
1561 void
|
Chris@0
|
1562 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
1563 {
|
Chris@0
|
1564 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@0
|
1565 }
|
Chris@0
|
1566
|
Chris@0
|
1567 void
|
Chris@0
|
1568 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
1569 {
|
Chris@0
|
1570 m_panLayer->setModel(model);
|
Chris@0
|
1571
|
Chris@0
|
1572 MainWindowBase::mainModelChanged(model);
|
Chris@0
|
1573
|
Chris@0
|
1574 if (m_playTarget) {
|
Chris@0
|
1575 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
1576 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
1577 }
|
Chris@72
|
1578
|
Chris@72
|
1579 if (model) {
|
Chris@72
|
1580 if (m_paneStack) {
|
Chris@72
|
1581 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@72
|
1582 if (!pane) {
|
Chris@72
|
1583 pane = m_paneStack->addPane();
|
Chris@72
|
1584 }
|
Chris@72
|
1585 if (pane) {
|
Chris@72
|
1586 m_analyser->newFileLoaded
|
Chris@72
|
1587 (m_document, getMainModel(), m_paneStack, pane);
|
Chris@72
|
1588 }
|
Chris@72
|
1589 }
|
Chris@72
|
1590 }
|
Chris@0
|
1591 }
|
Chris@0
|
1592
|
Chris@0
|
1593 void
|
Chris@0
|
1594 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@0
|
1595 {
|
Chris@0
|
1596 if (message != "") {
|
Chris@0
|
1597
|
Chris@0
|
1598 QMessageBox::warning
|
Chris@0
|
1599 (this,
|
Chris@0
|
1600 tr("Failed to generate layer"),
|
Chris@0
|
1601 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@0
|
1602 .arg(transformName).arg(message),
|
Chris@0
|
1603 QMessageBox::Ok);
|
Chris@0
|
1604 } else {
|
Chris@0
|
1605 QMessageBox::warning
|
Chris@0
|
1606 (this,
|
Chris@0
|
1607 tr("Failed to generate layer"),
|
Chris@0
|
1608 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
|
1609 .arg(transformName),
|
Chris@0
|
1610 QMessageBox::Ok);
|
Chris@0
|
1611 }
|
Chris@0
|
1612 }
|
Chris@0
|
1613
|
Chris@0
|
1614 void
|
Chris@0
|
1615 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@0
|
1616 {
|
Chris@0
|
1617 QMessageBox::warning
|
Chris@0
|
1618 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@0
|
1619 }
|
Chris@0
|
1620
|
Chris@0
|
1621 void
|
Chris@0
|
1622 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@0
|
1623 QString transformName, QString message)
|
Chris@0
|
1624 {
|
Chris@0
|
1625 if (message != "") {
|
Chris@0
|
1626
|
Chris@0
|
1627 QMessageBox::warning
|
Chris@0
|
1628 (this,
|
Chris@0
|
1629 tr("Failed to regenerate layer"),
|
Chris@0
|
1630 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
|
1631 .arg(layerName).arg(transformName).arg(message),
|
Chris@0
|
1632 QMessageBox::Ok);
|
Chris@0
|
1633 } else {
|
Chris@0
|
1634 QMessageBox::warning
|
Chris@0
|
1635 (this,
|
Chris@0
|
1636 tr("Failed to regenerate layer"),
|
Chris@0
|
1637 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
|
1638 .arg(layerName).arg(transformName),
|
Chris@0
|
1639 QMessageBox::Ok);
|
Chris@0
|
1640 }
|
Chris@0
|
1641 }
|
Chris@0
|
1642
|
Chris@0
|
1643 void
|
Chris@0
|
1644 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@0
|
1645 QString transformName, QString message)
|
Chris@0
|
1646 {
|
Chris@0
|
1647 QMessageBox::warning
|
Chris@0
|
1648 (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
|
1649 }
|
Chris@0
|
1650
|
Chris@0
|
1651 void
|
Chris@0
|
1652 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
1653 {
|
Chris@0
|
1654 QMessageBox::warning
|
Chris@0
|
1655 (this,
|
Chris@0
|
1656 tr("Failed to calculate alignment"),
|
Chris@0
|
1657 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@0
|
1658 .arg(transformName).arg(message),
|
Chris@0
|
1659 QMessageBox::Ok);
|
Chris@0
|
1660 }
|
Chris@0
|
1661
|
Chris@0
|
1662 void
|
Chris@0
|
1663 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
1664 {
|
Chris@70
|
1665 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
1666 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1667 m_rightButtonMenu->popup(position);
|
Chris@0
|
1668 }
|
Chris@0
|
1669
|
Chris@0
|
1670 void
|
Chris@0
|
1671 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@0
|
1672 {
|
Chris@70
|
1673 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
|
Chris@0
|
1674 }
|
Chris@0
|
1675
|
Chris@0
|
1676 void
|
Chris@0
|
1677 MainWindow::mouseEnteredWidget()
|
Chris@0
|
1678 {
|
Chris@3
|
1679 QWidget *w = qobject_cast<QWidget *>(sender());
|
Chris@0
|
1680 if (!w) return;
|
Chris@0
|
1681
|
Chris@0
|
1682 if (w == m_fader) {
|
Chris@0
|
1683 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@0
|
1684 } else if (w == m_playSpeed) {
|
Chris@0
|
1685 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@0
|
1686 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@0
|
1687 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@0
|
1688 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@0
|
1689 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
|
Chris@0
|
1690 }
|
Chris@0
|
1691 }
|
Chris@0
|
1692
|
Chris@0
|
1693 void
|
Chris@0
|
1694 MainWindow::mouseLeftWidget()
|
Chris@0
|
1695 {
|
Chris@0
|
1696 contextHelpChanged("");
|
Chris@0
|
1697 }
|
Chris@0
|
1698
|
Chris@0
|
1699 void
|
Chris@0
|
1700 MainWindow::website()
|
Chris@0
|
1701 {
|
Chris@4
|
1702 //!!! todo: URL!
|
Chris@4
|
1703 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
1704 }
|
Chris@0
|
1705
|
Chris@0
|
1706 void
|
Chris@0
|
1707 MainWindow::help()
|
Chris@0
|
1708 {
|
Chris@4
|
1709 //!!! todo: help URL!
|
Chris@4
|
1710 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
1711 }
|
Chris@0
|
1712
|
Chris@0
|
1713 void
|
Chris@0
|
1714 MainWindow::about()
|
Chris@0
|
1715 {
|
Chris@0
|
1716 bool debug = false;
|
Chris@0
|
1717 QString version = "(unknown version)";
|
Chris@0
|
1718
|
Chris@0
|
1719 #ifdef BUILD_DEBUG
|
Chris@0
|
1720 debug = true;
|
Chris@0
|
1721 #endif
|
Chris@0
|
1722 version = tr("Release %1").arg(TONY_VERSION);
|
Chris@0
|
1723
|
Chris@0
|
1724 QString aboutText;
|
Chris@0
|
1725
|
Chris@0
|
1726 aboutText += tr("<h3>About Tony</h3>");
|
Chris@0
|
1727 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
|
Chris@0
|
1728 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
1729 .arg(version)
|
Chris@0
|
1730 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
1731
|
Chris@0
|
1732 aboutText +=
|
Chris@90
|
1733 "<p>Copyright © 2005–2013 Chris Cannam, Matthias Mauch, George Fazekas, and Queen Mary University of London.</p>"
|
Chris@90
|
1734 "<p>This program is free software; you can redistribute it and/or "
|
Chris@90
|
1735 "modify it under the terms of the GNU General Public License as "
|
Chris@90
|
1736 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
1737 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
1738 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
1739
|
Chris@0
|
1740 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
|
Chris@0
|
1741 }
|
Chris@0
|
1742
|
Chris@0
|
1743 void
|
Chris@0
|
1744 MainWindow::keyReference()
|
Chris@0
|
1745 {
|
Chris@0
|
1746 m_keyReference->show();
|
Chris@0
|
1747 }
|
Chris@0
|
1748
|
Chris@0
|
1749
|