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