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