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