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