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