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