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