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