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