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 Sonic Visualiser
|
Chris@0
|
5 An audio file viewer and annotation editor.
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@77
|
7 This file copyright 2006 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@1
|
16 #include "version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@1
|
19 #include "document/Document.h"
|
Chris@0
|
20 #include "PreferencesDialog.h"
|
Chris@0
|
21
|
Chris@1
|
22 #include "view/Pane.h"
|
Chris@1
|
23 #include "view/PaneStack.h"
|
Chris@1
|
24 #include "data/model/WaveFileModel.h"
|
Chris@1
|
25 #include "data/model/SparseOneDimensionalModel.h"
|
Chris@1
|
26 #include "view/ViewManager.h"
|
Chris@0
|
27 #include "base/Preferences.h"
|
Chris@0
|
28 #include "layer/WaveformLayer.h"
|
Chris@0
|
29 #include "layer/TimeRulerLayer.h"
|
Chris@0
|
30 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
31 #include "layer/TimeValueLayer.h"
|
Chris@0
|
32 #include "layer/Colour3DPlotLayer.h"
|
Chris@95
|
33 #include "layer/SliceLayer.h"
|
Chris@95
|
34 #include "layer/SliceableLayer.h"
|
Chris@0
|
35 #include "widgets/Fader.h"
|
Chris@65
|
36 #include "view/Overview.h"
|
Chris@0
|
37 #include "widgets/PropertyBox.h"
|
Chris@0
|
38 #include "widgets/PropertyStack.h"
|
Chris@0
|
39 #include "widgets/AudioDial.h"
|
Chris@0
|
40 #include "widgets/LayerTree.h"
|
Chris@0
|
41 #include "widgets/ListInputDialog.h"
|
Chris@36
|
42 #include "widgets/SubdividingMenu.h"
|
Chris@90
|
43 #include "widgets/NotifyingPushButton.h"
|
Chris@0
|
44 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
45 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
46 #include "audioio/AudioTargetFactory.h"
|
Chris@59
|
47 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@1
|
48 #include "data/fileio/AudioFileReaderFactory.h"
|
Chris@1
|
49 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@1
|
50 #include "data/fileio/WavFileWriter.h"
|
Chris@1
|
51 #include "data/fileio/CSVFileWriter.h"
|
Chris@1
|
52 #include "data/fileio/BZipFileDevice.h"
|
Chris@85
|
53 #include "data/fileio/RemoteFile.h"
|
Chris@91
|
54 #include "data/fft/FFTDataServer.h"
|
Chris@1
|
55 #include "base/RecentFiles.h"
|
Chris@0
|
56 #include "transform/TransformFactory.h"
|
Chris@0
|
57 #include "base/PlayParameterRepository.h"
|
Chris@0
|
58 #include "base/XmlExportable.h"
|
Chris@0
|
59 #include "base/CommandHistory.h"
|
Chris@0
|
60 #include "base/Profiler.h"
|
Chris@0
|
61 #include "base/Clipboard.h"
|
Chris@69
|
62 #include "osc/OSCQueue.h"
|
Chris@0
|
63
|
Chris@0
|
64 // For version information
|
Chris@0
|
65 #include "vamp/vamp.h"
|
Chris@0
|
66 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
67 #include "plugin/api/ladspa.h"
|
Chris@0
|
68 #include "plugin/api/dssi.h"
|
Chris@0
|
69
|
Chris@0
|
70 #include <QApplication>
|
Chris@0
|
71 #include <QMessageBox>
|
Chris@0
|
72 #include <QGridLayout>
|
Chris@0
|
73 #include <QLabel>
|
Chris@0
|
74 #include <QAction>
|
Chris@0
|
75 #include <QMenuBar>
|
Chris@0
|
76 #include <QToolBar>
|
Chris@0
|
77 #include <QInputDialog>
|
Chris@0
|
78 #include <QStatusBar>
|
Chris@0
|
79 #include <QTreeView>
|
Chris@0
|
80 #include <QFile>
|
Chris@88
|
81 #include <QFileInfo>
|
Chris@88
|
82 #include <QDir>
|
Chris@0
|
83 #include <QTextStream>
|
Chris@0
|
84 #include <QProcess>
|
Chris@7
|
85 #include <QShortcut>
|
Chris@5
|
86 #include <QSettings>
|
Chris@11
|
87 #include <QDateTime>
|
Chris@11
|
88 #include <QProcess>
|
Chris@16
|
89 #include <QCheckBox>
|
Chris@55
|
90 #include <QRegExp>
|
Chris@0
|
91
|
Chris@0
|
92 #include <iostream>
|
Chris@0
|
93 #include <cstdio>
|
Chris@0
|
94 #include <errno.h>
|
Chris@0
|
95
|
Chris@0
|
96 using std::cerr;
|
Chris@0
|
97 using std::endl;
|
Chris@0
|
98
|
Chris@33
|
99 using std::vector;
|
Chris@33
|
100 using std::map;
|
Chris@33
|
101 using std::set;
|
Chris@33
|
102
|
Chris@0
|
103
|
Chris@70
|
104 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@0
|
105 m_document(0),
|
Chris@0
|
106 m_paneStack(0),
|
Chris@0
|
107 m_viewManager(0),
|
Chris@65
|
108 m_overview(0),
|
Chris@0
|
109 m_timeRulerLayer(0),
|
Chris@46
|
110 m_audioOutput(withAudioOutput),
|
Chris@0
|
111 m_playSource(0),
|
Chris@0
|
112 m_playTarget(0),
|
Chris@70
|
113 m_oscQueue(withOSCSupport ? new OSCQueue() : 0),
|
Chris@81
|
114 m_recentFiles("RecentFiles", 20),
|
Chris@49
|
115 m_recentTransforms("RecentTransforms", 20),
|
Chris@0
|
116 m_mainMenusCreated(false),
|
Chris@0
|
117 m_paneMenu(0),
|
Chris@0
|
118 m_layerMenu(0),
|
Chris@34
|
119 m_transformsMenu(0),
|
Chris@0
|
120 m_existingLayersMenu(0),
|
Chris@95
|
121 m_sliceMenu(0),
|
Chris@34
|
122 m_recentFilesMenu(0),
|
Chris@34
|
123 m_recentTransformsMenu(0),
|
Chris@0
|
124 m_rightButtonMenu(0),
|
Chris@0
|
125 m_rightButtonLayerMenu(0),
|
Chris@34
|
126 m_rightButtonTransformsMenu(0),
|
Chris@0
|
127 m_documentModified(false),
|
Chris@70
|
128 m_openingAudioFile(false),
|
Chris@70
|
129 m_abandoning(false),
|
Chris@0
|
130 m_preferencesDialog(0)
|
Chris@0
|
131 {
|
Chris@0
|
132 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
133
|
Chris@0
|
134 UnitDatabase::getInstance()->registerUnit("Hz");
|
Chris@0
|
135 UnitDatabase::getInstance()->registerUnit("dB");
|
Chris@0
|
136
|
Chris@0
|
137 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
|
Chris@0
|
138 this, SLOT(documentModified()));
|
Chris@0
|
139 connect(CommandHistory::getInstance(), SIGNAL(documentRestored()),
|
Chris@0
|
140 this, SLOT(documentRestored()));
|
Chris@0
|
141
|
Chris@0
|
142 QFrame *frame = new QFrame;
|
Chris@0
|
143 setCentralWidget(frame);
|
Chris@0
|
144
|
Chris@0
|
145 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
146
|
Chris@0
|
147 m_viewManager = new ViewManager();
|
Chris@0
|
148 connect(m_viewManager, SIGNAL(selectionChanged()),
|
Chris@0
|
149 this, SLOT(updateMenuStates()));
|
Chris@0
|
150
|
Chris@0
|
151 m_descriptionLabel = new QLabel;
|
Chris@0
|
152
|
Chris@0
|
153 m_paneStack = new PaneStack(frame, m_viewManager);
|
Chris@0
|
154 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)),
|
Chris@0
|
155 this, SLOT(currentPaneChanged(Pane *)));
|
Chris@0
|
156 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)),
|
Chris@0
|
157 this, SLOT(currentLayerChanged(Pane *, Layer *)));
|
Chris@0
|
158 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)),
|
Chris@0
|
159 this, SLOT(rightButtonMenuRequested(Pane *, QPoint)));
|
Chris@73
|
160 connect(m_paneStack, SIGNAL(propertyStacksResized()),
|
Chris@73
|
161 this, SLOT(propertyStacksResized()));
|
Chris@90
|
162 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
163 statusBar(), SLOT(showMessage(const QString &)));
|
Chris@0
|
164
|
Chris@65
|
165 m_overview = new Overview(frame);
|
Chris@65
|
166 m_overview->setViewManager(m_viewManager);
|
Chris@65
|
167 m_overview->setFixedHeight(40);
|
Chris@90
|
168 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
169 statusBar(), SLOT(showMessage(const QString &)));
|
Chris@0
|
170
|
Chris@0
|
171 m_panLayer = new WaveformLayer;
|
Chris@0
|
172 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
173 // m_panLayer->setScale(WaveformLayer::MeterScale);
|
Chris@39
|
174 // m_panLayer->setAutoNormalize(true);
|
Chris@0
|
175 m_panLayer->setBaseColour(Qt::darkGreen);
|
Chris@0
|
176 m_panLayer->setAggressiveCacheing(true);
|
Chris@65
|
177 m_overview->addLayer(m_panLayer);
|
Chris@0
|
178
|
Chris@0
|
179 m_playSource = new AudioCallbackPlaySource(m_viewManager);
|
Chris@0
|
180
|
Chris@0
|
181 connect(m_playSource, SIGNAL(sampleRateMismatch(size_t, size_t, bool)),
|
Chris@0
|
182 this, SLOT(sampleRateMismatch(size_t, size_t, bool)));
|
Chris@42
|
183 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()),
|
Chris@42
|
184 this, SLOT(audioOverloadPluginDisabled()));
|
Chris@0
|
185
|
Chris@0
|
186 m_fader = new Fader(frame, false);
|
Chris@90
|
187 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
188 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
189
|
Chris@0
|
190 m_playSpeed = new AudioDial(frame);
|
Chris@12
|
191 m_playSpeed->setMinimum(0);
|
Chris@48
|
192 m_playSpeed->setMaximum(200);
|
Chris@25
|
193 m_playSpeed->setValue(100);
|
Chris@0
|
194 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
195 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
196 m_playSpeed->setNotchesVisible(true);
|
Chris@25
|
197 m_playSpeed->setPageStep(10);
|
Chris@60
|
198 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@25
|
199 m_playSpeed->setDefaultValue(100);
|
Chris@59
|
200 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@60
|
201 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
202 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
Chris@0
|
203 this, SLOT(playSpeedChanged(int)));
|
Chris@90
|
204 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
205 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
206
|
Chris@90
|
207 m_playSharpen = new NotifyingPushButton(frame);
|
Chris@17
|
208 m_playSharpen->setToolTip(tr("Sharpen percussive transients"));
|
Chris@26
|
209 m_playSharpen->setFixedSize(20, 20);
|
Chris@26
|
210 // m_playSharpen->setFlat(true);
|
Chris@16
|
211 m_playSharpen->setEnabled(false);
|
Chris@26
|
212 m_playSharpen->setCheckable(true);
|
Chris@26
|
213 m_playSharpen->setChecked(false);
|
Chris@26
|
214 m_playSharpen->setIcon(QIcon(":icons/sharpen.png"));
|
Chris@26
|
215 connect(m_playSharpen, SIGNAL(clicked()), this, SLOT(playSharpenToggled()));
|
Chris@90
|
216 connect(m_playSharpen, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
217 connect(m_playSharpen, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
218
|
Chris@90
|
219 m_playMono = new NotifyingPushButton(frame);
|
Chris@26
|
220 m_playMono->setToolTip(tr("Run time stretcher in mono only"));
|
Chris@26
|
221 m_playMono->setFixedSize(20, 20);
|
Chris@26
|
222 // m_playMono->setFlat(true);
|
Chris@26
|
223 m_playMono->setEnabled(false);
|
Chris@26
|
224 m_playMono->setCheckable(true);
|
Chris@26
|
225 m_playMono->setChecked(false);
|
Chris@26
|
226 m_playMono->setIcon(QIcon(":icons/mono.png"));
|
Chris@26
|
227 connect(m_playMono, SIGNAL(clicked()), this, SLOT(playMonoToggled()));
|
Chris@90
|
228 connect(m_playMono, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
229 connect(m_playMono, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@21
|
230
|
Chris@21
|
231 QSettings settings;
|
Chris@21
|
232 settings.beginGroup("MainWindow");
|
Chris@24
|
233 m_playSharpen->setChecked(settings.value("playsharpen", true).toBool());
|
Chris@26
|
234 m_playMono->setChecked(settings.value("playmono", false).toBool());
|
Chris@21
|
235 settings.endGroup();
|
Chris@21
|
236
|
Chris@26
|
237 layout->addWidget(m_paneStack, 0, 0, 1, 5);
|
Chris@65
|
238 layout->addWidget(m_overview, 1, 0);
|
Chris@0
|
239 layout->addWidget(m_fader, 1, 1);
|
Chris@0
|
240 layout->addWidget(m_playSpeed, 1, 2);
|
Chris@16
|
241 layout->addWidget(m_playSharpen, 1, 3);
|
Chris@26
|
242 layout->addWidget(m_playMono, 1, 4);
|
Chris@16
|
243
|
Chris@16
|
244 layout->setColumnStretch(0, 10);
|
Chris@16
|
245
|
Chris@0
|
246 frame->setLayout(layout);
|
Chris@0
|
247
|
Chris@0
|
248 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)),
|
Chris@0
|
249 this, SLOT(outputLevelsChanged(float, float)));
|
Chris@0
|
250
|
Chris@0
|
251 connect(Preferences::getInstance(),
|
Chris@0
|
252 SIGNAL(propertyChanged(PropertyContainer::PropertyName)),
|
Chris@0
|
253 this,
|
Chris@0
|
254 SLOT(preferenceChanged(PropertyContainer::PropertyName)));
|
Chris@0
|
255
|
Chris@98
|
256 // preferenceChanged("Property Box Layout");
|
Chris@98
|
257
|
Chris@70
|
258 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@69
|
259 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC()));
|
Chris@69
|
260 QTimer *oscTimer = new QTimer(this);
|
Chris@69
|
261 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC()));
|
Chris@69
|
262 oscTimer->start(1000);
|
Chris@69
|
263 }
|
Chris@69
|
264
|
Chris@0
|
265 setupMenus();
|
Chris@0
|
266 setupToolbars();
|
Chris@0
|
267
|
Chris@90
|
268 statusBar();
|
Chris@0
|
269
|
Chris@0
|
270 newSession();
|
Chris@0
|
271 }
|
Chris@0
|
272
|
Chris@0
|
273 MainWindow::~MainWindow()
|
Chris@0
|
274 {
|
Chris@70
|
275 if (!m_abandoning) {
|
Chris@70
|
276 closeSession();
|
Chris@70
|
277 }
|
Chris@0
|
278 delete m_playTarget;
|
Chris@0
|
279 delete m_playSource;
|
Chris@0
|
280 delete m_viewManager;
|
Chris@69
|
281 delete m_oscQueue;
|
Chris@0
|
282 Profiles::getInstance()->dump();
|
Chris@0
|
283 }
|
Chris@0
|
284
|
Chris@81
|
285 QString
|
Chris@88
|
286 MainWindow::getOpenFileName(FileFinder::FileType type)
|
Chris@81
|
287 {
|
Chris@88
|
288 FileFinder *ff = FileFinder::getInstance();
|
Chris@81
|
289 switch (type) {
|
Chris@88
|
290 case FileFinder::SessionFile:
|
Chris@88
|
291 return ff->getOpenFileName(type, m_sessionFile);
|
Chris@88
|
292 case FileFinder::AudioFile:
|
Chris@88
|
293 return ff->getOpenFileName(type, m_audioFile);
|
Chris@88
|
294 case FileFinder::LayerFile:
|
Chris@88
|
295 return ff->getOpenFileName(type, m_sessionFile);
|
Chris@88
|
296 case FileFinder::SessionOrAudioFile:
|
Chris@88
|
297 return ff->getOpenFileName(type, m_sessionFile);
|
Chris@88
|
298 case FileFinder::AnyFile:
|
Chris@88
|
299 if (getMainModel() != 0 &&
|
Chris@88
|
300 m_paneStack != 0 &&
|
Chris@88
|
301 m_paneStack->getCurrentPane() != 0) { // can import a layer
|
Chris@88
|
302 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile);
|
Chris@81
|
303 } else {
|
Chris@88
|
304 return ff->getOpenFileName(FileFinder::SessionOrAudioFile,
|
Chris@88
|
305 m_sessionFile);
|
Chris@81
|
306 }
|
Chris@81
|
307 }
|
Chris@88
|
308 return "";
|
Chris@88
|
309 }
|
Chris@88
|
310
|
Chris@88
|
311 QString
|
Chris@88
|
312 MainWindow::getSaveFileName(FileFinder::FileType type)
|
Chris@88
|
313 {
|
Chris@88
|
314 FileFinder *ff = FileFinder::getInstance();
|
Chris@88
|
315 switch (type) {
|
Chris@88
|
316 case FileFinder::SessionFile:
|
Chris@88
|
317 return ff->getSaveFileName(type, m_sessionFile);
|
Chris@88
|
318 case FileFinder::AudioFile:
|
Chris@88
|
319 return ff->getSaveFileName(type, m_audioFile);
|
Chris@88
|
320 case FileFinder::LayerFile:
|
Chris@88
|
321 return ff->getSaveFileName(type, m_sessionFile);
|
Chris@88
|
322 case FileFinder::SessionOrAudioFile:
|
Chris@88
|
323 return ff->getSaveFileName(type, m_sessionFile);
|
Chris@88
|
324 case FileFinder::AnyFile:
|
Chris@88
|
325 return ff->getSaveFileName(type, m_sessionFile);
|
Chris@81
|
326 }
|
Chris@88
|
327 return "";
|
Chris@81
|
328 }
|
Chris@81
|
329
|
Chris@88
|
330 void
|
Chris@88
|
331 MainWindow::registerLastOpenedFilePath(FileFinder::FileType type, QString path)
|
Chris@81
|
332 {
|
Chris@88
|
333 FileFinder *ff = FileFinder::getInstance();
|
Chris@88
|
334 ff->registerLastOpenedFilePath(type, path);
|
Chris@81
|
335 }
|
Chris@81
|
336
|
Chris@81
|
337 void
|
Chris@0
|
338 MainWindow::setupMenus()
|
Chris@0
|
339 {
|
Chris@0
|
340 if (!m_mainMenusCreated) {
|
Chris@0
|
341 m_rightButtonMenu = new QMenu();
|
Chris@104
|
342
|
Chris@104
|
343 // No -- we don't want tear-off enabled on the right-button
|
Chris@104
|
344 // menu. If it is enabled, then simply right-clicking and
|
Chris@104
|
345 // releasing will pop up the menu, activate the tear-off, and
|
Chris@104
|
346 // leave the torn-off menu window in front of the main window.
|
Chris@104
|
347 // That isn't desirable. I'm not sure it ever would be, in a
|
Chris@104
|
348 // context menu -- perhaps technically a Qt bug?
|
Chris@104
|
349 // m_rightButtonMenu->setTearOffEnabled(true);
|
Chris@0
|
350 }
|
Chris@0
|
351
|
Chris@0
|
352 if (m_rightButtonLayerMenu) {
|
Chris@0
|
353 m_rightButtonLayerMenu->clear();
|
Chris@0
|
354 } else {
|
Chris@0
|
355 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
|
Chris@97
|
356 m_rightButtonLayerMenu->setTearOffEnabled(true);
|
Chris@0
|
357 m_rightButtonMenu->addSeparator();
|
Chris@0
|
358 }
|
Chris@0
|
359
|
Chris@34
|
360 if (m_rightButtonTransformsMenu) {
|
Chris@34
|
361 m_rightButtonTransformsMenu->clear();
|
Chris@34
|
362 } else {
|
Chris@34
|
363 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform"));
|
Chris@97
|
364 m_rightButtonTransformsMenu->setTearOffEnabled(true);
|
Chris@34
|
365 m_rightButtonMenu->addSeparator();
|
Chris@34
|
366 }
|
Chris@34
|
367
|
Chris@0
|
368 if (!m_mainMenusCreated) {
|
Chris@0
|
369 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
370 m_rightButtonMenu->addSeparator();
|
Chris@66
|
371 }
|
Chris@66
|
372
|
Chris@66
|
373 setupFileMenu();
|
Chris@66
|
374 setupEditMenu();
|
Chris@66
|
375 setupViewMenu();
|
Chris@66
|
376 setupPaneAndLayerMenus();
|
Chris@66
|
377 setupTransformsMenu();
|
Chris@66
|
378 setupHelpMenu();
|
Chris@66
|
379
|
Chris@66
|
380 m_mainMenusCreated = true;
|
Chris@66
|
381 }
|
Chris@66
|
382
|
Chris@66
|
383 void
|
Chris@66
|
384 MainWindow::setupFileMenu()
|
Chris@66
|
385 {
|
Chris@66
|
386 if (m_mainMenusCreated) return;
|
Chris@66
|
387
|
Chris@66
|
388 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@97
|
389 menu->setTearOffEnabled(true);
|
Chris@66
|
390 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@66
|
391
|
Chris@66
|
392 QIcon icon(":icons/filenew.png");
|
Chris@66
|
393 icon.addFile(":icons/filenew-22.png");
|
Chris@66
|
394 QAction *action = new QAction(icon, tr("&New Session"), this);
|
Chris@66
|
395 action->setShortcut(tr("Ctrl+N"));
|
Chris@90
|
396 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one"));
|
Chris@66
|
397 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
|
Chris@66
|
398 menu->addAction(action);
|
Chris@66
|
399 toolbar->addAction(action);
|
Chris@0
|
400
|
Chris@66
|
401 icon = QIcon(":icons/fileopen.png");
|
Chris@66
|
402 icon.addFile(":icons/fileopen-22.png");
|
Chris@66
|
403
|
Chris@66
|
404 action = new QAction(icon, tr("&Open Session..."), this);
|
Chris@66
|
405 action->setShortcut(tr("Ctrl+O"));
|
Chris@66
|
406 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file"));
|
Chris@66
|
407 connect(action, SIGNAL(triggered()), this, SLOT(openSession()));
|
Chris@66
|
408 menu->addAction(action);
|
Chris@66
|
409
|
Chris@66
|
410 action = new QAction(icon, tr("&Open..."), this);
|
Chris@66
|
411 action->setStatusTip(tr("Open a session file, audio file, or layer"));
|
Chris@66
|
412 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
|
Chris@66
|
413 toolbar->addAction(action);
|
Chris@66
|
414
|
Chris@66
|
415 icon = QIcon(":icons/filesave.png");
|
Chris@66
|
416 icon.addFile(":icons/filesave-22.png");
|
Chris@66
|
417 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@66
|
418 action->setShortcut(tr("Ctrl+S"));
|
Chris@66
|
419 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file"));
|
Chris@66
|
420 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@66
|
421 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
422 menu->addAction(action);
|
Chris@66
|
423 toolbar->addAction(action);
|
Chris@0
|
424
|
Chris@66
|
425 icon = QIcon(":icons/filesaveas.png");
|
Chris@66
|
426 icon.addFile(":icons/filesaveas-22.png");
|
Chris@66
|
427 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@66
|
428 action->setStatusTip(tr("Save the current session into a new Sonic Visualiser session file"));
|
Chris@66
|
429 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@66
|
430 menu->addAction(action);
|
Chris@66
|
431 toolbar->addAction(action);
|
Chris@66
|
432
|
Chris@66
|
433 menu->addSeparator();
|
Chris@66
|
434
|
Chris@66
|
435 action = new QAction(tr("&Import Audio File..."), this);
|
Chris@66
|
436 action->setShortcut(tr("Ctrl+I"));
|
Chris@66
|
437 action->setStatusTip(tr("Import an existing audio file"));
|
Chris@66
|
438 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
|
Chris@66
|
439 menu->addAction(action);
|
Chris@66
|
440
|
Chris@66
|
441 action = new QAction(tr("Import Secondary Audio File..."), this);
|
Chris@66
|
442 action->setShortcut(tr("Ctrl+Shift+I"));
|
Chris@66
|
443 action->setStatusTip(tr("Import an extra audio file as a separate layer"));
|
Chris@66
|
444 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
|
Chris@66
|
445 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
446 menu->addAction(action);
|
Chris@66
|
447
|
Chris@66
|
448 action = new QAction(tr("&Export Audio File..."), this);
|
Chris@66
|
449 action->setStatusTip(tr("Export selection as an audio file"));
|
Chris@66
|
450 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
|
Chris@66
|
451 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
452 menu->addAction(action);
|
Chris@66
|
453
|
Chris@66
|
454 menu->addSeparator();
|
Chris@66
|
455
|
Chris@66
|
456 action = new QAction(tr("Import Annotation &Layer..."), this);
|
Chris@66
|
457 action->setShortcut(tr("Ctrl+L"));
|
Chris@66
|
458 action->setStatusTip(tr("Import layer data from an existing file"));
|
Chris@66
|
459 connect(action, SIGNAL(triggered()), this, SLOT(importLayer()));
|
Chris@66
|
460 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
461 menu->addAction(action);
|
Chris@66
|
462
|
Chris@66
|
463 action = new QAction(tr("Export Annotation Layer..."), this);
|
Chris@66
|
464 action->setStatusTip(tr("Export layer data to a file"));
|
Chris@66
|
465 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer()));
|
Chris@66
|
466 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
467 menu->addAction(action);
|
Chris@66
|
468
|
Chris@66
|
469 menu->addSeparator();
|
Chris@86
|
470
|
Chris@86
|
471 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@86
|
472 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@86
|
473 action->setStatusTip(tr("Open or import a file from a remote URL"));
|
Chris@86
|
474 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@86
|
475 menu->addAction(action);
|
Chris@86
|
476
|
Chris@86
|
477 menu->addSeparator();
|
Chris@86
|
478
|
Chris@66
|
479 m_recentFilesMenu = menu->addMenu(tr("&Recent Files"));
|
Chris@97
|
480 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@66
|
481 setupRecentFilesMenu();
|
Chris@66
|
482 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@66
|
483 this, SLOT(setupRecentFilesMenu()));
|
Chris@66
|
484
|
Chris@66
|
485 menu->addSeparator();
|
Chris@66
|
486 action = new QAction(tr("&Preferences..."), this);
|
Chris@66
|
487 action->setStatusTip(tr("Adjust the application preferences"));
|
Chris@66
|
488 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
|
Chris@66
|
489 menu->addAction(action);
|
Chris@0
|
490
|
Chris@66
|
491 /*!!!
|
Chris@66
|
492 menu->addSeparator();
|
Chris@0
|
493
|
Chris@66
|
494 action = new QAction(tr("Play / Pause"), this);
|
Chris@66
|
495 action->setShortcut(tr("Space"));
|
Chris@66
|
496 action->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@66
|
497 connect(action, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@66
|
498 menu->addAction(action);
|
Chris@66
|
499 */
|
Chris@66
|
500
|
Chris@66
|
501 menu->addSeparator();
|
Chris@66
|
502 action = new QAction(QIcon(":/icons/exit.png"),
|
Chris@66
|
503 tr("&Quit"), this);
|
Chris@66
|
504 action->setShortcut(tr("Ctrl+Q"));
|
Chris@90
|
505 action->setStatusTip(tr("Exit Sonic Visualiser"));
|
Chris@66
|
506 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@66
|
507 menu->addAction(action);
|
Chris@66
|
508 }
|
Chris@66
|
509
|
Chris@66
|
510 void
|
Chris@66
|
511 MainWindow::setupEditMenu()
|
Chris@66
|
512 {
|
Chris@66
|
513 if (m_mainMenusCreated) return;
|
Chris@66
|
514
|
Chris@66
|
515 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@97
|
516 menu->setTearOffEnabled(true);
|
Chris@66
|
517 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@66
|
518
|
Chris@66
|
519 menu->addSeparator();
|
Chris@66
|
520
|
Chris@66
|
521 QAction *action = new QAction(QIcon(":/icons/editcut.png"),
|
Chris@66
|
522 tr("Cu&t"), this);
|
Chris@66
|
523 action->setShortcut(tr("Ctrl+X"));
|
Chris@90
|
524 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard"));
|
Chris@66
|
525 connect(action, SIGNAL(triggered()), this, SLOT(cut()));
|
Chris@66
|
526 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
527 menu->addAction(action);
|
Chris@66
|
528 m_rightButtonMenu->addAction(action);
|
Chris@66
|
529
|
Chris@66
|
530 action = new QAction(QIcon(":/icons/editcopy.png"),
|
Chris@66
|
531 tr("&Copy"), this);
|
Chris@66
|
532 action->setShortcut(tr("Ctrl+C"));
|
Chris@90
|
533 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard"));
|
Chris@66
|
534 connect(action, SIGNAL(triggered()), this, SLOT(copy()));
|
Chris@66
|
535 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
536 menu->addAction(action);
|
Chris@66
|
537 m_rightButtonMenu->addAction(action);
|
Chris@66
|
538
|
Chris@66
|
539 action = new QAction(QIcon(":/icons/editpaste.png"),
|
Chris@66
|
540 tr("&Paste"), this);
|
Chris@66
|
541 action->setShortcut(tr("Ctrl+V"));
|
Chris@90
|
542 action->setStatusTip(tr("Paste from the clipboard to the current layer"));
|
Chris@66
|
543 connect(action, SIGNAL(triggered()), this, SLOT(paste()));
|
Chris@66
|
544 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
545 menu->addAction(action);
|
Chris@66
|
546 m_rightButtonMenu->addAction(action);
|
Chris@66
|
547
|
Chris@66
|
548 action = new QAction(tr("&Delete Selected Items"), this);
|
Chris@66
|
549 action->setShortcut(tr("Del"));
|
Chris@90
|
550 action->setStatusTip(tr("Delete the selection from the current layer"));
|
Chris@66
|
551 connect(action, SIGNAL(triggered()), this, SLOT(deleteSelected()));
|
Chris@66
|
552 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
553 menu->addAction(action);
|
Chris@66
|
554 m_rightButtonMenu->addAction(action);
|
Chris@66
|
555
|
Chris@66
|
556 menu->addSeparator();
|
Chris@66
|
557 m_rightButtonMenu->addSeparator();
|
Chris@0
|
558
|
Chris@66
|
559 action = new QAction(tr("Select &All"), this);
|
Chris@66
|
560 action->setShortcut(tr("Ctrl+A"));
|
Chris@90
|
561 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@66
|
562 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@66
|
563 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
564 menu->addAction(action);
|
Chris@66
|
565 m_rightButtonMenu->addAction(action);
|
Chris@0
|
566
|
Chris@66
|
567 action = new QAction(tr("Select &Visible Range"), this);
|
Chris@66
|
568 action->setShortcut(tr("Ctrl+Shift+A"));
|
Chris@90
|
569 action->setStatusTip(tr("Select the time range corresponding to the current window width"));
|
Chris@66
|
570 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible()));
|
Chris@66
|
571 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
572 menu->addAction(action);
|
Chris@0
|
573
|
Chris@66
|
574 action = new QAction(tr("Select to &Start"), this);
|
Chris@66
|
575 action->setShortcut(tr("Shift+Left"));
|
Chris@90
|
576 action->setStatusTip(tr("Select from the start of the session to the current playback position"));
|
Chris@66
|
577 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart()));
|
Chris@66
|
578 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
579 menu->addAction(action);
|
Chris@0
|
580
|
Chris@66
|
581 action = new QAction(tr("Select to &End"), this);
|
Chris@66
|
582 action->setShortcut(tr("Shift+Right"));
|
Chris@90
|
583 action->setStatusTip(tr("Select from the current playback position to the end of the session"));
|
Chris@66
|
584 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd()));
|
Chris@66
|
585 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
586 menu->addAction(action);
|
Chris@66
|
587
|
Chris@66
|
588 action = new QAction(tr("C&lear Selection"), this);
|
Chris@66
|
589 action->setShortcut(tr("Esc"));
|
Chris@90
|
590 action->setStatusTip(tr("Clear the selection"));
|
Chris@66
|
591 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
Chris@66
|
592 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
593 menu->addAction(action);
|
Chris@66
|
594 m_rightButtonMenu->addAction(action);
|
Chris@66
|
595
|
Chris@66
|
596 menu->addSeparator();
|
Chris@66
|
597
|
Chris@66
|
598 action = new QAction(tr("&Insert Instant at Playback Position"), this);
|
Chris@66
|
599 action->setShortcut(tr("Enter"));
|
Chris@90
|
600 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary"));
|
Chris@66
|
601 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
|
Chris@66
|
602 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
603 menu->addAction(action);
|
Chris@66
|
604
|
Chris@81
|
605 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
|
Chris@81
|
606 action->setShortcut(tr("Shift+Enter"));
|
Chris@90
|
607 action->setStatusTip(tr("Insert new time instants at the start and end of the current selection, in a new layer if necessary"));
|
Chris@81
|
608 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
|
Chris@81
|
609 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
|
Chris@81
|
610 menu->addAction(action);
|
Chris@81
|
611
|
Chris@66
|
612 // Laptop shortcut (no keypad Enter key)
|
Chris@66
|
613 connect(new QShortcut(tr(";"), this), SIGNAL(activated()),
|
Chris@66
|
614 this, SLOT(insertInstant()));
|
Chris@66
|
615 }
|
Chris@66
|
616
|
Chris@66
|
617 void
|
Chris@66
|
618 MainWindow::setupViewMenu()
|
Chris@66
|
619 {
|
Chris@66
|
620 if (m_mainMenusCreated) return;
|
Chris@66
|
621
|
Chris@90
|
622 QAction *action = 0;
|
Chris@90
|
623
|
Chris@66
|
624 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@97
|
625 menu->setTearOffEnabled(true);
|
Chris@66
|
626 action = new QAction(tr("Scroll &Left"), this);
|
Chris@66
|
627 action->setShortcut(tr("Left"));
|
Chris@66
|
628 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@66
|
629 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@66
|
630 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
631 menu->addAction(action);
|
Chris@0
|
632
|
Chris@66
|
633 action = new QAction(tr("Scroll &Right"), this);
|
Chris@66
|
634 action->setShortcut(tr("Right"));
|
Chris@66
|
635 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@66
|
636 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@66
|
637 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
638 menu->addAction(action);
|
Chris@0
|
639
|
Chris@90
|
640 action = new QAction(tr("&Jump Left"), this);
|
Chris@66
|
641 action->setShortcut(tr("Ctrl+Left"));
|
Chris@66
|
642 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@66
|
643 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@66
|
644 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
645 menu->addAction(action);
|
Chris@0
|
646
|
Chris@90
|
647 action = new QAction(tr("J&ump Right"), this);
|
Chris@66
|
648 action->setShortcut(tr("Ctrl+Right"));
|
Chris@66
|
649 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@66
|
650 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@66
|
651 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
652 menu->addAction(action);
|
Chris@66
|
653
|
Chris@66
|
654 menu->addSeparator();
|
Chris@66
|
655
|
Chris@66
|
656 action = new QAction(QIcon(":/icons/zoom-in.png"),
|
Chris@66
|
657 tr("Zoom &In"), this);
|
Chris@66
|
658 action->setShortcut(tr("Up"));
|
Chris@66
|
659 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@66
|
660 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@66
|
661 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
662 menu->addAction(action);
|
Chris@0
|
663
|
Chris@66
|
664 action = new QAction(QIcon(":/icons/zoom-out.png"),
|
Chris@66
|
665 tr("Zoom &Out"), this);
|
Chris@66
|
666 action->setShortcut(tr("Down"));
|
Chris@66
|
667 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@66
|
668 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@66
|
669 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
670 menu->addAction(action);
|
Chris@0
|
671
|
Chris@66
|
672 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@90
|
673 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@66
|
674 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@66
|
675 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
676 menu->addAction(action);
|
Chris@66
|
677
|
Chris@66
|
678 action = new QAction(tr("Zoom to &Fit"), this);
|
Chris@66
|
679 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@66
|
680 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@66
|
681 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
682 menu->addAction(action);
|
Chris@90
|
683
|
Chris@90
|
684 menu->addSeparator();
|
Chris@90
|
685
|
Chris@90
|
686 QActionGroup *overlayGroup = new QActionGroup(this);
|
Chris@90
|
687
|
Chris@90
|
688 action = new QAction(tr("Show &No Overlays"), this);
|
Chris@90
|
689 action->setShortcut(tr("0"));
|
Chris@90
|
690 action->setStatusTip(tr("Hide centre indicator, frame times, layer names and scale"));
|
Chris@90
|
691 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays()));
|
Chris@90
|
692 action->setCheckable(true);
|
Chris@90
|
693 action->setChecked(false);
|
Chris@90
|
694 overlayGroup->addAction(action);
|
Chris@90
|
695 menu->addAction(action);
|
Chris@90
|
696
|
Chris@90
|
697 action = new QAction(tr("Show &Minimal Overlays"), this);
|
Chris@90
|
698 action->setShortcut(tr("9"));
|
Chris@90
|
699 action->setStatusTip(tr("Show centre indicator only"));
|
Chris@90
|
700 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays()));
|
Chris@90
|
701 action->setCheckable(true);
|
Chris@90
|
702 action->setChecked(false);
|
Chris@90
|
703 overlayGroup->addAction(action);
|
Chris@90
|
704 menu->addAction(action);
|
Chris@90
|
705
|
Chris@90
|
706 action = new QAction(tr("Show &Standard Overlays"), this);
|
Chris@90
|
707 action->setShortcut(tr("8"));
|
Chris@90
|
708 action->setStatusTip(tr("Show centre indicator, frame times and scale"));
|
Chris@90
|
709 connect(action, SIGNAL(triggered()), this, SLOT(showStandardOverlays()));
|
Chris@90
|
710 action->setCheckable(true);
|
Chris@90
|
711 action->setChecked(true);
|
Chris@90
|
712 overlayGroup->addAction(action);
|
Chris@90
|
713 menu->addAction(action);
|
Chris@90
|
714
|
Chris@90
|
715 action = new QAction(tr("Show &All Overlays"), this);
|
Chris@90
|
716 action->setShortcut(tr("7"));
|
Chris@90
|
717 action->setStatusTip(tr("Show all texts and scale"));
|
Chris@90
|
718 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays()));
|
Chris@90
|
719 action->setCheckable(true);
|
Chris@90
|
720 action->setChecked(false);
|
Chris@90
|
721 overlayGroup->addAction(action);
|
Chris@90
|
722 menu->addAction(action);
|
Chris@7
|
723
|
Chris@72
|
724 menu->addSeparator();
|
Chris@72
|
725
|
Chris@66
|
726 action = new QAction(tr("Show &Zoom Wheels"), this);
|
Chris@66
|
727 action->setShortcut(tr("Z"));
|
Chris@66
|
728 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically"));
|
Chris@66
|
729 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels()));
|
Chris@66
|
730 action->setCheckable(true);
|
Chris@66
|
731 action->setChecked(m_viewManager->getZoomWheelsEnabled());
|
Chris@66
|
732 menu->addAction(action);
|
Chris@72
|
733
|
Chris@72
|
734 action = new QAction(tr("Show Property Bo&xes"), this);
|
Chris@72
|
735 action->setShortcut(tr("X"));
|
Chris@72
|
736 action->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
|
Chris@72
|
737 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
|
Chris@72
|
738 action->setCheckable(true);
|
Chris@72
|
739 action->setChecked(true);
|
Chris@72
|
740 menu->addAction(action);
|
Chris@0
|
741
|
Chris@90
|
742 action = new QAction(tr("Show Status &Bar"), this);
|
Chris@90
|
743 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
|
Chris@90
|
744 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
|
Chris@90
|
745 action->setCheckable(true);
|
Chris@90
|
746 action->setChecked(true);
|
Chris@90
|
747 menu->addAction(action);
|
Chris@90
|
748
|
Chris@90
|
749 QSettings settings;
|
Chris@90
|
750 settings.beginGroup("MainWindow");
|
Chris@90
|
751 bool sb = settings.value("showstatusbar", true).toBool();
|
Chris@90
|
752 if (!sb) {
|
Chris@90
|
753 action->setChecked(false);
|
Chris@90
|
754 statusBar()->hide();
|
Chris@90
|
755 }
|
Chris@90
|
756 settings.endGroup();
|
Chris@90
|
757
|
Chris@0
|
758 /*!!! This one doesn't work properly yet
|
Chris@90
|
759
|
Chris@66
|
760 menu->addSeparator();
|
Chris@66
|
761
|
Chris@90
|
762 action = new QAction(tr("Show La&yer Hierarchy"), this);
|
Chris@66
|
763 action->setShortcut(tr("Alt+L"));
|
Chris@90
|
764 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session"));
|
Chris@66
|
765 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree()));
|
Chris@66
|
766 menu->addAction(action);
|
Chris@90
|
767 */
|
Chris@66
|
768 }
|
Chris@66
|
769
|
Chris@66
|
770 void
|
Chris@66
|
771 MainWindow::setupPaneAndLayerMenus()
|
Chris@66
|
772 {
|
Chris@0
|
773 if (m_paneMenu) {
|
Chris@0
|
774 m_paneActions.clear();
|
Chris@0
|
775 m_paneMenu->clear();
|
Chris@0
|
776 } else {
|
Chris@0
|
777 m_paneMenu = menuBar()->addMenu(tr("&Pane"));
|
Chris@97
|
778 m_paneMenu->setTearOffEnabled(true);
|
Chris@0
|
779 }
|
Chris@0
|
780
|
Chris@0
|
781 if (m_layerMenu) {
|
Chris@0
|
782 m_layerActions.clear();
|
Chris@0
|
783 m_layerMenu->clear();
|
Chris@0
|
784 } else {
|
Chris@0
|
785 m_layerMenu = menuBar()->addMenu(tr("&Layer"));
|
Chris@97
|
786 m_layerMenu->setTearOffEnabled(true);
|
Chris@0
|
787 }
|
Chris@0
|
788
|
Chris@66
|
789 QMenu *menu = m_paneMenu;
|
Chris@66
|
790
|
Chris@66
|
791 QAction *action = new QAction(QIcon(":/icons/pane.png"), tr("Add &New Pane"), this);
|
Chris@66
|
792 action->setShortcut(tr("Alt+N"));
|
Chris@66
|
793 action->setStatusTip(tr("Add a new pane containing only a time ruler"));
|
Chris@66
|
794 connect(action, SIGNAL(triggered()), this, SLOT(addPane()));
|
Chris@66
|
795 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
796 m_paneActions[action] = PaneConfiguration(LayerFactory::TimeRuler);
|
Chris@66
|
797 menu->addAction(action);
|
Chris@66
|
798
|
Chris@66
|
799 menu->addSeparator();
|
Chris@66
|
800
|
Chris@66
|
801 menu = m_layerMenu;
|
Chris@66
|
802
|
Chris@66
|
803 // menu->addSeparator();
|
Chris@66
|
804
|
Chris@66
|
805 LayerFactory::LayerTypeSet emptyLayerTypes =
|
Chris@66
|
806 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@66
|
807
|
Chris@66
|
808 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin();
|
Chris@66
|
809 i != emptyLayerTypes.end(); ++i) {
|
Chris@66
|
810
|
Chris@66
|
811 QIcon icon;
|
Chris@66
|
812 QString mainText, tipText, channelText;
|
Chris@66
|
813 LayerFactory::LayerType type = *i;
|
Chris@66
|
814 QString name = LayerFactory::getInstance()->getLayerPresentationName(type);
|
Chris@66
|
815
|
Chris@66
|
816 icon = QIcon(QString(":/icons/%1.png")
|
Chris@66
|
817 .arg(LayerFactory::getInstance()->getLayerIconName(type)));
|
Chris@66
|
818
|
Chris@66
|
819 mainText = tr("Add New %1 Layer").arg(name);
|
Chris@66
|
820 tipText = tr("Add a new empty layer of type %1").arg(name);
|
Chris@66
|
821
|
Chris@66
|
822 action = new QAction(icon, mainText, this);
|
Chris@66
|
823 action->setStatusTip(tipText);
|
Chris@66
|
824
|
Chris@66
|
825 if (type == LayerFactory::Text) {
|
Chris@66
|
826 action->setShortcut(tr("Alt+T"));
|
Chris@66
|
827 }
|
Chris@66
|
828
|
Chris@66
|
829 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@66
|
830 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
831 m_layerActions[action] = type;
|
Chris@66
|
832 menu->addAction(action);
|
Chris@66
|
833 m_rightButtonLayerMenu->addAction(action);
|
Chris@66
|
834 }
|
Chris@66
|
835
|
Chris@66
|
836 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
837 menu->addSeparator();
|
Chris@66
|
838
|
Chris@66
|
839 LayerFactory::LayerType backgroundTypes[] = {
|
Chris@66
|
840 LayerFactory::Waveform,
|
Chris@66
|
841 LayerFactory::Spectrogram,
|
Chris@66
|
842 LayerFactory::MelodicRangeSpectrogram,
|
Chris@66
|
843 LayerFactory::PeakFrequencySpectrogram,
|
Chris@66
|
844 LayerFactory::Spectrum
|
Chris@66
|
845 };
|
Chris@66
|
846
|
Chris@66
|
847 std::vector<Model *> models;
|
Chris@66
|
848 if (m_document) models = m_document->getTransformInputModels(); //!!! not well named for this!
|
Chris@66
|
849 bool plural = (models.size() > 1);
|
Chris@66
|
850 if (models.empty()) {
|
Chris@67
|
851 models.push_back(getMainModel()); // probably 0
|
Chris@66
|
852 }
|
Chris@66
|
853
|
Chris@66
|
854 for (unsigned int i = 0;
|
Chris@66
|
855 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
|
Chris@66
|
856
|
Chris@66
|
857 for (int menuType = 0; menuType <= 1; ++menuType) { // pane, layer
|
Chris@66
|
858
|
Chris@66
|
859 if (menuType == 0) menu = m_paneMenu;
|
Chris@66
|
860 else menu = m_layerMenu;
|
Chris@66
|
861
|
Chris@66
|
862 QMenu *submenu = 0;
|
Chris@66
|
863
|
Chris@66
|
864 QIcon icon;
|
Chris@66
|
865 QString mainText, shortcutText, tipText, channelText;
|
Chris@66
|
866 LayerFactory::LayerType type = backgroundTypes[i];
|
Chris@66
|
867 bool mono = true;
|
Chris@66
|
868
|
Chris@66
|
869 switch (type) {
|
Chris@66
|
870
|
Chris@66
|
871 case LayerFactory::Waveform:
|
Chris@66
|
872 icon = QIcon(":/icons/waveform.png");
|
Chris@66
|
873 mainText = tr("Add &Waveform");
|
Chris@66
|
874 if (menuType == 0) {
|
Chris@66
|
875 shortcutText = tr("Alt+W");
|
Chris@66
|
876 tipText = tr("Add a new pane showing a waveform view");
|
Chris@66
|
877 } else {
|
Chris@66
|
878 tipText = tr("Add a new layer showing a waveform view");
|
Chris@66
|
879 }
|
Chris@66
|
880 mono = false;
|
Chris@66
|
881 break;
|
Chris@66
|
882
|
Chris@66
|
883 case LayerFactory::Spectrogram:
|
Chris@67
|
884 icon = QIcon(":/icons/spectrogram.png");
|
Chris@66
|
885 mainText = tr("Add &Spectrogram");
|
Chris@66
|
886 if (menuType == 0) {
|
Chris@66
|
887 shortcutText = tr("Alt+S");
|
Chris@90
|
888 tipText = tr("Add a new pane showing a spectrogram");
|
Chris@66
|
889 } else {
|
Chris@90
|
890 tipText = tr("Add a new layer showing a spectrogram");
|
Chris@66
|
891 }
|
Chris@66
|
892 break;
|
Chris@66
|
893
|
Chris@66
|
894 case LayerFactory::MelodicRangeSpectrogram:
|
Chris@67
|
895 icon = QIcon(":/icons/spectrogram.png");
|
Chris@66
|
896 mainText = tr("Add &Melodic Range Spectrogram");
|
Chris@66
|
897 if (menuType == 0) {
|
Chris@66
|
898 shortcutText = tr("Alt+M");
|
Chris@90
|
899 tipText = tr("Add a new pane showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
900 } else {
|
Chris@90
|
901 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
902 }
|
Chris@66
|
903 break;
|
Chris@66
|
904
|
Chris@66
|
905 case LayerFactory::PeakFrequencySpectrogram:
|
Chris@67
|
906 icon = QIcon(":/icons/spectrogram.png");
|
Chris@66
|
907 mainText = tr("Add &Peak Frequency Spectrogram");
|
Chris@66
|
908 if (menuType == 0) {
|
Chris@66
|
909 shortcutText = tr("Alt+P");
|
Chris@66
|
910 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
911 } else {
|
Chris@66
|
912 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
913 }
|
Chris@66
|
914 break;
|
Chris@66
|
915
|
Chris@66
|
916 case LayerFactory::Spectrum:
|
Chris@67
|
917 icon = QIcon(":/icons/spectrum.png");
|
Chris@66
|
918 mainText = tr("Add Spectr&um");
|
Chris@66
|
919 if (menuType == 0) {
|
Chris@66
|
920 shortcutText = tr("Alt+U");
|
Chris@66
|
921 tipText = tr("Add a new pane showing a frequency spectrum");
|
Chris@66
|
922 } else {
|
Chris@66
|
923 tipText = tr("Add a new layer showing a frequency spectrum");
|
Chris@66
|
924 }
|
Chris@66
|
925 break;
|
Chris@66
|
926
|
Chris@66
|
927 default: break;
|
Chris@66
|
928 }
|
Chris@66
|
929
|
Chris@66
|
930 std::vector<Model *> candidateModels;
|
Chris@66
|
931 if (menuType == 0) {
|
Chris@66
|
932 candidateModels = models;
|
Chris@66
|
933 } else {
|
Chris@66
|
934 candidateModels.push_back(0);
|
Chris@66
|
935 }
|
Chris@66
|
936
|
Chris@66
|
937 for (std::vector<Model *>::iterator mi =
|
Chris@66
|
938 candidateModels.begin();
|
Chris@66
|
939 mi != candidateModels.end(); ++mi) {
|
Chris@66
|
940
|
Chris@66
|
941 Model *model = *mi;
|
Chris@66
|
942
|
Chris@66
|
943 int channels = 0;
|
Chris@66
|
944 if (model) {
|
Chris@66
|
945 DenseTimeValueModel *dtvm =
|
Chris@66
|
946 dynamic_cast<DenseTimeValueModel *>(model);
|
Chris@66
|
947 if (dtvm) channels = dtvm->getChannelCount();
|
Chris@66
|
948 }
|
Chris@66
|
949 if (channels < 1 && getMainModel()) {
|
Chris@66
|
950 channels = getMainModel()->getChannelCount();
|
Chris@66
|
951 }
|
Chris@66
|
952 if (channels < 1) channels = 1;
|
Chris@66
|
953
|
Chris@66
|
954 for (int c = 0; c <= channels; ++c) {
|
Chris@66
|
955
|
Chris@66
|
956 if (c == 1 && channels == 1) continue;
|
Chris@66
|
957 bool isDefault = (c == 0);
|
Chris@66
|
958 bool isOnly = (isDefault && (channels == 1));
|
Chris@66
|
959
|
Chris@66
|
960 if (menuType == 1) {
|
Chris@66
|
961 if (isDefault) isOnly = true;
|
Chris@66
|
962 else continue;
|
Chris@66
|
963 }
|
Chris@66
|
964
|
Chris@66
|
965 if (isOnly && (!plural || menuType == 1)) {
|
Chris@66
|
966
|
Chris@67
|
967 if (type != LayerFactory::Waveform) {
|
Chris@67
|
968 action = new QAction(mainText, this);
|
Chris@67
|
969 } else {
|
Chris@67
|
970 action = new QAction(icon, mainText, this);
|
Chris@67
|
971 }
|
Chris@67
|
972
|
Chris@66
|
973 action->setShortcut(shortcutText);
|
Chris@66
|
974 action->setStatusTip(tipText);
|
Chris@66
|
975 if (menuType == 0) {
|
Chris@66
|
976 connect(action, SIGNAL(triggered()),
|
Chris@66
|
977 this, SLOT(addPane()));
|
Chris@66
|
978 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
979 action, SLOT(setEnabled(bool)));
|
Chris@66
|
980 m_paneActions[action] = PaneConfiguration(type);
|
Chris@66
|
981 } else {
|
Chris@66
|
982 connect(action, SIGNAL(triggered()),
|
Chris@66
|
983 this, SLOT(addLayer()));
|
Chris@66
|
984 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
985 action, SLOT(setEnabled(bool)));
|
Chris@66
|
986 m_layerActions[action] = type;
|
Chris@66
|
987 }
|
Chris@66
|
988 menu->addAction(action);
|
Chris@66
|
989
|
Chris@66
|
990 } else {
|
Chris@66
|
991
|
Chris@66
|
992 if (!submenu) {
|
Chris@66
|
993 submenu = menu->addMenu(mainText);
|
Chris@97
|
994 submenu->setTearOffEnabled(true);
|
Chris@67
|
995 } else if (isDefault) {
|
Chris@67
|
996 submenu->addSeparator();
|
Chris@66
|
997 }
|
Chris@66
|
998
|
Chris@66
|
999 QString actionText;
|
Chris@66
|
1000 if (c == 0) {
|
Chris@66
|
1001 if (mono) {
|
Chris@66
|
1002 actionText = tr("&All Channels Mixed");
|
Chris@66
|
1003 } else {
|
Chris@66
|
1004 actionText = tr("&All Channels");
|
Chris@66
|
1005 }
|
Chris@66
|
1006 } else {
|
Chris@66
|
1007 actionText = tr("Channel &%1").arg(c);
|
Chris@66
|
1008 }
|
Chris@66
|
1009
|
Chris@66
|
1010 if (model) {
|
Chris@66
|
1011 actionText = tr("%1: %2")
|
Chris@66
|
1012 .arg(model->objectName())
|
Chris@66
|
1013 .arg(actionText);
|
Chris@66
|
1014 }
|
Chris@67
|
1015
|
Chris@67
|
1016 if (isDefault) {
|
Chris@67
|
1017 action = new QAction(icon, actionText, this);
|
Chris@67
|
1018 if (!model || model == getMainModel()) {
|
Chris@67
|
1019 action->setShortcut(shortcutText);
|
Chris@67
|
1020 }
|
Chris@67
|
1021 } else {
|
Chris@67
|
1022 action = new QAction(actionText, this);
|
Chris@67
|
1023 }
|
Chris@67
|
1024
|
Chris@66
|
1025 action->setStatusTip(tipText);
|
Chris@66
|
1026
|
Chris@66
|
1027 if (menuType == 0) {
|
Chris@66
|
1028 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1029 this, SLOT(addPane()));
|
Chris@66
|
1030 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
1031 action, SLOT(setEnabled(bool)));
|
Chris@66
|
1032 m_paneActions[action] =
|
Chris@66
|
1033 PaneConfiguration(type, model, c - 1);
|
Chris@66
|
1034 } else {
|
Chris@66
|
1035 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1036 this, SLOT(addLayer()));
|
Chris@66
|
1037 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
1038 action, SLOT(setEnabled(bool)));
|
Chris@66
|
1039 m_layerActions[action] = type;
|
Chris@66
|
1040 }
|
Chris@66
|
1041
|
Chris@66
|
1042 submenu->addAction(action);
|
Chris@66
|
1043 }
|
Chris@66
|
1044 }
|
Chris@66
|
1045 }
|
Chris@66
|
1046 }
|
Chris@66
|
1047 }
|
Chris@66
|
1048
|
Chris@66
|
1049 menu = m_paneMenu;
|
Chris@66
|
1050
|
Chris@66
|
1051 menu->addSeparator();
|
Chris@66
|
1052
|
Chris@66
|
1053 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Pane"), this);
|
Chris@66
|
1054 action->setShortcut(tr("Alt+D"));
|
Chris@90
|
1055 action->setStatusTip(tr("Delete the currently active pane"));
|
Chris@66
|
1056 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane()));
|
Chris@66
|
1057 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
1058 menu->addAction(action);
|
Chris@66
|
1059
|
Chris@66
|
1060 menu = m_layerMenu;
|
Chris@66
|
1061
|
Chris@66
|
1062 action = new QAction(QIcon(":/icons/timeruler.png"), tr("Add &Time Ruler"), this);
|
Chris@66
|
1063 action->setStatusTip(tr("Add a new layer showing a time ruler"));
|
Chris@66
|
1064 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@66
|
1065 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
1066 m_layerActions[action] = LayerFactory::TimeRuler;
|
Chris@66
|
1067 menu->addAction(action);
|
Chris@66
|
1068
|
Chris@66
|
1069 menu->addSeparator();
|
Chris@66
|
1070
|
Chris@66
|
1071 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer"));
|
Chris@97
|
1072 m_existingLayersMenu->setTearOffEnabled(true);
|
Chris@66
|
1073 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu);
|
Chris@95
|
1074
|
Chris@95
|
1075 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer"));
|
Chris@97
|
1076 m_sliceMenu->setTearOffEnabled(true);
|
Chris@95
|
1077 m_rightButtonLayerMenu->addMenu(m_sliceMenu);
|
Chris@95
|
1078
|
Chris@95
|
1079 setupExistingLayersMenus();
|
Chris@66
|
1080
|
Chris@66
|
1081 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
1082 menu->addSeparator();
|
Chris@66
|
1083
|
Chris@66
|
1084 action = new QAction(tr("&Rename Layer..."), this);
|
Chris@66
|
1085 action->setShortcut(tr("Alt+R"));
|
Chris@66
|
1086 action->setStatusTip(tr("Rename the currently active layer"));
|
Chris@66
|
1087 connect(action, SIGNAL(triggered()), this, SLOT(renameCurrentLayer()));
|
Chris@66
|
1088 connect(this, SIGNAL(canRenameLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
1089 menu->addAction(action);
|
Chris@66
|
1090 m_rightButtonLayerMenu->addAction(action);
|
Chris@66
|
1091
|
Chris@66
|
1092 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this);
|
Chris@66
|
1093 action->setShortcut(tr("Alt+Shift+D"));
|
Chris@66
|
1094 action->setStatusTip(tr("Delete the currently active layer"));
|
Chris@66
|
1095 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer()));
|
Chris@66
|
1096 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
1097 menu->addAction(action);
|
Chris@66
|
1098 m_rightButtonLayerMenu->addAction(action);
|
Chris@66
|
1099 }
|
Chris@66
|
1100
|
Chris@66
|
1101 void
|
Chris@66
|
1102 MainWindow::setupTransformsMenu()
|
Chris@66
|
1103 {
|
Chris@34
|
1104 if (m_transformsMenu) {
|
Chris@34
|
1105 m_transformActions.clear();
|
Chris@34
|
1106 m_transformActionsReverse.clear();
|
Chris@34
|
1107 m_transformsMenu->clear();
|
Chris@34
|
1108 } else {
|
Chris@97
|
1109 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
|
Chris@97
|
1110 m_transformsMenu->setTearOffEnabled(true);
|
Chris@97
|
1111 }
|
Chris@34
|
1112
|
Chris@0
|
1113 TransformFactory::TransformList transforms =
|
Chris@0
|
1114 TransformFactory::getInstance()->getAllTransforms();
|
Chris@0
|
1115
|
Chris@33
|
1116 vector<QString> types =
|
Chris@0
|
1117 TransformFactory::getInstance()->getAllTransformTypes();
|
Chris@0
|
1118
|
Chris@37
|
1119 map<QString, map<QString, SubdividingMenu *> > categoryMenus;
|
Chris@37
|
1120 map<QString, map<QString, SubdividingMenu *> > makerMenus;
|
Chris@33
|
1121
|
Chris@36
|
1122 map<QString, SubdividingMenu *> byPluginNameMenus;
|
Chris@33
|
1123 map<QString, map<QString, QMenu *> > pluginNameMenus;
|
Chris@33
|
1124
|
Chris@37
|
1125 set<SubdividingMenu *> pendingMenus;
|
Chris@37
|
1126
|
Chris@34
|
1127 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms"));
|
Chris@97
|
1128 m_recentTransformsMenu->setTearOffEnabled(true);
|
Chris@34
|
1129 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu);
|
Chris@34
|
1130 connect(&m_recentTransforms, SIGNAL(recentChanged()),
|
Chris@34
|
1131 this, SLOT(setupRecentTransformsMenu()));
|
Chris@34
|
1132
|
Chris@34
|
1133 m_transformsMenu->addSeparator();
|
Chris@34
|
1134 m_rightButtonTransformsMenu->addSeparator();
|
Chris@34
|
1135
|
Chris@33
|
1136 for (vector<QString>::iterator i = types.begin(); i != types.end(); ++i) {
|
Chris@33
|
1137
|
Chris@33
|
1138 if (i != types.begin()) {
|
Chris@34
|
1139 m_transformsMenu->addSeparator();
|
Chris@34
|
1140 m_rightButtonTransformsMenu->addSeparator();
|
Chris@33
|
1141 }
|
Chris@33
|
1142
|
Chris@33
|
1143 QString byCategoryLabel = tr("%1 by Category").arg(*i);
|
Chris@37
|
1144 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel,
|
Chris@37
|
1145 20, 40);
|
Chris@97
|
1146 byCategoryMenu->setTearOffEnabled(true);
|
Chris@37
|
1147 m_transformsMenu->addMenu(byCategoryMenu);
|
Chris@34
|
1148 m_rightButtonTransformsMenu->addMenu(byCategoryMenu);
|
Chris@37
|
1149 pendingMenus.insert(byCategoryMenu);
|
Chris@33
|
1150
|
Chris@33
|
1151 vector<QString> categories =
|
Chris@33
|
1152 TransformFactory::getInstance()->getTransformCategories(*i);
|
Chris@33
|
1153
|
Chris@33
|
1154 for (vector<QString>::iterator j = categories.begin();
|
Chris@33
|
1155 j != categories.end(); ++j) {
|
Chris@33
|
1156
|
Chris@33
|
1157 QString category = *j;
|
Chris@33
|
1158 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1159
|
Chris@33
|
1160 if (categories.size() < 2) {
|
Chris@33
|
1161 categoryMenus[*i][category] = byCategoryMenu;
|
Chris@33
|
1162 continue;
|
Chris@33
|
1163 }
|
Chris@33
|
1164
|
Chris@33
|
1165 QStringList components = category.split(" > ");
|
Chris@33
|
1166 QString key;
|
Chris@33
|
1167
|
Chris@33
|
1168 for (QStringList::iterator k = components.begin();
|
Chris@33
|
1169 k != components.end(); ++k) {
|
Chris@33
|
1170
|
Chris@33
|
1171 QString parentKey = key;
|
Chris@33
|
1172 if (key != "") key += " > ";
|
Chris@33
|
1173 key += *k;
|
Chris@33
|
1174
|
Chris@33
|
1175 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) {
|
Chris@37
|
1176 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40);
|
Chris@97
|
1177 m->setTearOffEnabled(true);
|
Chris@37
|
1178 pendingMenus.insert(m);
|
Chris@37
|
1179 categoryMenus[*i][key] = m;
|
Chris@33
|
1180 if (parentKey == "") {
|
Chris@37
|
1181 byCategoryMenu->addMenu(m);
|
Chris@33
|
1182 } else {
|
Chris@37
|
1183 categoryMenus[*i][parentKey]->addMenu(m);
|
Chris@33
|
1184 }
|
Chris@33
|
1185 }
|
Chris@33
|
1186 }
|
Chris@33
|
1187 }
|
Chris@33
|
1188
|
Chris@34
|
1189 QString byPluginNameLabel = tr("%1 by Plugin Name").arg(*i);
|
Chris@36
|
1190 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel);
|
Chris@97
|
1191 byPluginNameMenus[*i]->setTearOffEnabled(true);
|
Chris@36
|
1192 m_transformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@34
|
1193 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@37
|
1194 pendingMenus.insert(byPluginNameMenus[*i]);
|
Chris@34
|
1195
|
Chris@33
|
1196 QString byMakerLabel = tr("%1 by Maker").arg(*i);
|
Chris@37
|
1197 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40);
|
Chris@97
|
1198 byMakerMenu->setTearOffEnabled(true);
|
Chris@37
|
1199 m_transformsMenu->addMenu(byMakerMenu);
|
Chris@34
|
1200 m_rightButtonTransformsMenu->addMenu(byMakerMenu);
|
Chris@37
|
1201 pendingMenus.insert(byMakerMenu);
|
Chris@33
|
1202
|
Chris@33
|
1203 vector<QString> makers =
|
Chris@33
|
1204 TransformFactory::getInstance()->getTransformMakers(*i);
|
Chris@37
|
1205
|
Chris@33
|
1206 for (vector<QString>::iterator j = makers.begin();
|
Chris@33
|
1207 j != makers.end(); ++j) {
|
Chris@33
|
1208
|
Chris@33
|
1209 QString maker = *j;
|
Chris@33
|
1210 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1211 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@55
|
1212
|
Chris@37
|
1213 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40);
|
Chris@97
|
1214 makerMenus[*i][maker]->setTearOffEnabled(true);
|
Chris@37
|
1215 byMakerMenu->addMenu(makerMenus[*i][maker]);
|
Chris@37
|
1216 pendingMenus.insert(makerMenus[*i][maker]);
|
Chris@33
|
1217 }
|
Chris@0
|
1218 }
|
Chris@0
|
1219
|
Chris@0
|
1220 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@0
|
1221
|
Chris@107
|
1222 QString name = transforms[i].name;
|
Chris@107
|
1223 if (name == "") name = transforms[i].identifier;
|
Chris@107
|
1224
|
Chris@107
|
1225 // std::cerr << "Plugin Name: " << name.toStdString() << std::endl;
|
Chris@80
|
1226
|
Chris@33
|
1227 QString type = transforms[i].type;
|
Chris@33
|
1228
|
Chris@33
|
1229 QString category = transforms[i].category;
|
Chris@33
|
1230 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1231
|
Chris@33
|
1232 QString maker = transforms[i].maker;
|
Chris@33
|
1233 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1234 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@33
|
1235
|
Chris@107
|
1236 QString pluginName = name.section(": ", 0, 0);
|
Chris@107
|
1237 QString output = name.section(": ", 1);
|
Chris@107
|
1238
|
Chris@107
|
1239 QAction *action = new QAction(tr("%1...").arg(name), this);
|
Chris@0
|
1240 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1241 m_transformActions[action] = transforms[i].identifier;
|
Chris@107
|
1242 m_transformActionsReverse[transforms[i].identifier] = action;
|
Chris@0
|
1243 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@33
|
1244
|
Chris@108
|
1245 action->setStatusTip(transforms[i].description);
|
Chris@90
|
1246
|
Chris@33
|
1247 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
|
Chris@33
|
1248 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1249 << "No category menu for transform \""
|
Chris@107
|
1250 << name.toStdString() << "\" (category = \""
|
Chris@33
|
1251 << category.toStdString() << "\")" << std::endl;
|
Chris@33
|
1252 } else {
|
Chris@33
|
1253 categoryMenus[type][category]->addAction(action);
|
Chris@33
|
1254 }
|
Chris@33
|
1255
|
Chris@33
|
1256 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
|
Chris@33
|
1257 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1258 << "No maker menu for transform \""
|
Chris@107
|
1259 << name.toStdString() << "\" (maker = \""
|
Chris@33
|
1260 << maker.toStdString() << "\")" << std::endl;
|
Chris@33
|
1261 } else {
|
Chris@80
|
1262 makerMenus[type][maker]->addAction(action);
|
Chris@33
|
1263 }
|
Chris@33
|
1264
|
Chris@33
|
1265 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
|
Chris@33
|
1266 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1267 m_transformActions[action] = transforms[i].identifier;
|
Chris@33
|
1268 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@108
|
1269 action->setStatusTip(transforms[i].description);
|
Chris@33
|
1270
|
Chris@34
|
1271 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl;
|
Chris@34
|
1272
|
Chris@33
|
1273 if (pluginNameMenus[type].find(pluginName) ==
|
Chris@33
|
1274 pluginNameMenus[type].end()) {
|
Chris@33
|
1275
|
Chris@36
|
1276 SubdividingMenu *parentMenu = byPluginNameMenus[type];
|
Chris@97
|
1277 parentMenu->setTearOffEnabled(true);
|
Chris@34
|
1278
|
Chris@33
|
1279 if (output == "") {
|
Chris@36
|
1280 parentMenu->addAction(pluginName, action);
|
Chris@33
|
1281 } else {
|
Chris@34
|
1282 pluginNameMenus[type][pluginName] =
|
Chris@34
|
1283 parentMenu->addMenu(pluginName);
|
Chris@33
|
1284 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@33
|
1285 pluginNameMenus[type][pluginName],
|
Chris@33
|
1286 SLOT(setEnabled(bool)));
|
Chris@33
|
1287 }
|
Chris@33
|
1288 }
|
Chris@33
|
1289
|
Chris@33
|
1290 if (pluginNameMenus[type].find(pluginName) !=
|
Chris@33
|
1291 pluginNameMenus[type].end()) {
|
Chris@33
|
1292 pluginNameMenus[type][pluginName]->addAction(action);
|
Chris@33
|
1293 }
|
Chris@0
|
1294 }
|
Chris@0
|
1295
|
Chris@37
|
1296 for (set<SubdividingMenu *>::iterator i = pendingMenus.begin();
|
Chris@37
|
1297 i != pendingMenus.end(); ++i) {
|
Chris@37
|
1298 (*i)->entriesAdded();
|
Chris@37
|
1299 }
|
Chris@37
|
1300
|
Chris@34
|
1301 setupRecentTransformsMenu();
|
Chris@66
|
1302 }
|
Chris@66
|
1303
|
Chris@66
|
1304 void
|
Chris@66
|
1305 MainWindow::setupHelpMenu()
|
Chris@66
|
1306 {
|
Chris@66
|
1307 if (m_mainMenusCreated) return;
|
Chris@66
|
1308
|
Chris@66
|
1309 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@97
|
1310 menu->setTearOffEnabled(true);
|
Chris@66
|
1311
|
Chris@66
|
1312 QAction *action = new QAction(tr("&Help Reference"), this);
|
Chris@66
|
1313 action->setStatusTip(tr("Open the Sonic Visualiser reference manual"));
|
Chris@66
|
1314 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
1315 menu->addAction(action);
|
Chris@0
|
1316
|
Chris@66
|
1317 action = new QAction(tr("Sonic Visualiser on the &Web"), this);
|
Chris@66
|
1318 action->setStatusTip(tr("Open the Sonic Visualiser website"));
|
Chris@66
|
1319 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
1320 menu->addAction(action);
|
Chris@66
|
1321
|
Chris@66
|
1322 action = new QAction(tr("&About Sonic Visualiser"), this);
|
Chris@66
|
1323 action->setStatusTip(tr("Show information about Sonic Visualiser"));
|
Chris@66
|
1324 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
1325 menu->addAction(action);
|
Chris@0
|
1326 }
|
Chris@0
|
1327
|
Chris@0
|
1328 void
|
Chris@0
|
1329 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
1330 {
|
Chris@0
|
1331 m_recentFilesMenu->clear();
|
Chris@34
|
1332 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
1333 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@0
|
1334 QAction *action = new QAction(files[i], this);
|
Chris@0
|
1335 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
1336 m_recentFilesMenu->addAction(action);
|
Chris@0
|
1337 }
|
Chris@0
|
1338 }
|
Chris@0
|
1339
|
Chris@0
|
1340 void
|
Chris@34
|
1341 MainWindow::setupRecentTransformsMenu()
|
Chris@34
|
1342 {
|
Chris@34
|
1343 m_recentTransformsMenu->clear();
|
Chris@34
|
1344 vector<QString> transforms = m_recentTransforms.getRecent();
|
Chris@34
|
1345 for (size_t i = 0; i < transforms.size(); ++i) {
|
Chris@34
|
1346 TransformActionReverseMap::iterator ti =
|
Chris@34
|
1347 m_transformActionsReverse.find(transforms[i]);
|
Chris@34
|
1348 if (ti == m_transformActionsReverse.end()) {
|
Chris@34
|
1349 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
|
Chris@34
|
1350 << "Unknown transform \"" << transforms[i].toStdString()
|
Chris@34
|
1351 << "\" in recent transforms list" << std::endl;
|
Chris@34
|
1352 continue;
|
Chris@34
|
1353 }
|
Chris@34
|
1354 m_recentTransformsMenu->addAction(ti->second);
|
Chris@34
|
1355 }
|
Chris@34
|
1356 }
|
Chris@34
|
1357
|
Chris@34
|
1358 void
|
Chris@95
|
1359 MainWindow::setupExistingLayersMenus()
|
Chris@0
|
1360 {
|
Chris@0
|
1361 if (!m_existingLayersMenu) return; // should have been created by setupMenus
|
Chris@0
|
1362
|
Chris@0
|
1363 // std::cerr << "MainWindow::setupExistingLayersMenu" << std::endl;
|
Chris@0
|
1364
|
Chris@0
|
1365 m_existingLayersMenu->clear();
|
Chris@0
|
1366 m_existingLayerActions.clear();
|
Chris@0
|
1367
|
Chris@95
|
1368 m_sliceMenu->clear();
|
Chris@95
|
1369 m_sliceActions.clear();
|
Chris@95
|
1370
|
Chris@33
|
1371 vector<Layer *> orderedLayers;
|
Chris@33
|
1372 set<Layer *> observedLayers;
|
Chris@95
|
1373 set<Layer *> sliceableLayers;
|
Chris@95
|
1374
|
Chris@95
|
1375 LayerFactory *factory = LayerFactory::getInstance();
|
Chris@0
|
1376
|
Chris@0
|
1377 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
1378
|
Chris@0
|
1379 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
1380 if (!pane) continue;
|
Chris@0
|
1381
|
Chris@0
|
1382 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
1383
|
Chris@0
|
1384 Layer *layer = pane->getLayer(j);
|
Chris@0
|
1385 if (!layer) continue;
|
Chris@0
|
1386 if (observedLayers.find(layer) != observedLayers.end()) {
|
Chris@0
|
1387 std::cerr << "found duplicate layer " << layer << std::endl;
|
Chris@0
|
1388 continue;
|
Chris@0
|
1389 }
|
Chris@0
|
1390
|
Chris@0
|
1391 // std::cerr << "found new layer " << layer << " (name = "
|
Chris@0
|
1392 // << layer->getLayerPresentationName().toStdString() << ")" << std::endl;
|
Chris@0
|
1393
|
Chris@0
|
1394 orderedLayers.push_back(layer);
|
Chris@0
|
1395 observedLayers.insert(layer);
|
Chris@95
|
1396
|
Chris@95
|
1397 if (factory->isLayerSliceable(layer)) {
|
Chris@95
|
1398 sliceableLayers.insert(layer);
|
Chris@95
|
1399 }
|
Chris@0
|
1400 }
|
Chris@0
|
1401 }
|
Chris@0
|
1402
|
Chris@33
|
1403 map<QString, int> observedNames;
|
Chris@0
|
1404
|
Chris@0
|
1405 for (int i = 0; i < orderedLayers.size(); ++i) {
|
Chris@0
|
1406
|
Chris@95
|
1407 Layer *layer = orderedLayers[i];
|
Chris@95
|
1408
|
Chris@95
|
1409 QString name = layer->getLayerPresentationName();
|
Chris@0
|
1410 int n = ++observedNames[name];
|
Chris@0
|
1411 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n);
|
Chris@0
|
1412
|
Chris@95
|
1413 QIcon icon = QIcon(QString(":/icons/%1.png")
|
Chris@95
|
1414 .arg(factory->getLayerIconName
|
Chris@95
|
1415 (factory->getLayerType(layer))));
|
Chris@95
|
1416
|
Chris@95
|
1417 QAction *action = new QAction(icon, name, this);
|
Chris@0
|
1418 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@0
|
1419 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1420 m_existingLayerActions[action] = layer;
|
Chris@0
|
1421
|
Chris@0
|
1422 m_existingLayersMenu->addAction(action);
|
Chris@95
|
1423
|
Chris@95
|
1424 if (sliceableLayers.find(layer) != sliceableLayers.end()) {
|
Chris@95
|
1425 action = new QAction(icon, name, this);
|
Chris@95
|
1426 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@95
|
1427 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1428 m_sliceActions[action] = layer;
|
Chris@95
|
1429 m_sliceMenu->addAction(action);
|
Chris@95
|
1430 }
|
Chris@0
|
1431 }
|
Chris@95
|
1432
|
Chris@95
|
1433 m_sliceMenu->setEnabled(!m_sliceActions.empty());
|
Chris@0
|
1434 }
|
Chris@0
|
1435
|
Chris@0
|
1436 void
|
Chris@0
|
1437 MainWindow::setupToolbars()
|
Chris@0
|
1438 {
|
Chris@0
|
1439 QToolBar *toolbar = addToolBar(tr("Transport Toolbar"));
|
Chris@0
|
1440
|
Chris@0
|
1441 QAction *action = toolbar->addAction(QIcon(":/icons/rewind-start.png"),
|
Chris@0
|
1442 tr("Rewind to Start"));
|
Chris@0
|
1443 action->setShortcut(tr("Home"));
|
Chris@0
|
1444 action->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
1445 connect(action, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
1446 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1447
|
Chris@0
|
1448 action = toolbar->addAction(QIcon(":/icons/rewind.png"),
|
Chris@0
|
1449 tr("Rewind"));
|
Chris@0
|
1450 action->setShortcut(tr("PageUp"));
|
Chris@0
|
1451 action->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1452 connect(action, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
1453 connect(this, SIGNAL(canRewind(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1454
|
Chris@0
|
1455 action = toolbar->addAction(QIcon(":/icons/playpause.png"),
|
Chris@0
|
1456 tr("Play / Pause"));
|
Chris@0
|
1457 action->setCheckable(true);
|
Chris@0
|
1458 action->setShortcut(tr("Space"));
|
Chris@0
|
1459 action->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
1460 connect(action, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
1461 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@0
|
1462 action, SLOT(setChecked(bool)));
|
Chris@0
|
1463 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1464
|
Chris@0
|
1465 action = toolbar->addAction(QIcon(":/icons/ffwd.png"),
|
Chris@0
|
1466 tr("Fast Forward"));
|
Chris@0
|
1467 action->setShortcut(tr("PageDown"));
|
Chris@0
|
1468 action->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1469 connect(action, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
1470 connect(this, SIGNAL(canFfwd(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1471
|
Chris@0
|
1472 action = toolbar->addAction(QIcon(":/icons/ffwd-end.png"),
|
Chris@0
|
1473 tr("Fast Forward to End"));
|
Chris@0
|
1474 action->setShortcut(tr("End"));
|
Chris@0
|
1475 action->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
1476 connect(action, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
1477 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1478
|
Chris@0
|
1479 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
1480
|
Chris@0
|
1481 action = toolbar->addAction(QIcon(":/icons/playselection.png"),
|
Chris@0
|
1482 tr("Constrain Playback to Selection"));
|
Chris@0
|
1483 action->setCheckable(true);
|
Chris@0
|
1484 action->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
1485 action->setShortcut(tr("s"));
|
Chris@0
|
1486 action->setStatusTip(tr("Constrain playback to the selected area"));
|
Chris@69
|
1487 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@69
|
1488 action, SLOT(setChecked(bool)));
|
Chris@0
|
1489 connect(action, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
1490 connect(this, SIGNAL(canPlaySelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1491
|
Chris@0
|
1492 action = toolbar->addAction(QIcon(":/icons/playloop.png"),
|
Chris@0
|
1493 tr("Loop Playback"));
|
Chris@0
|
1494 action->setCheckable(true);
|
Chris@0
|
1495 action->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
1496 action->setShortcut(tr("l"));
|
Chris@0
|
1497 action->setStatusTip(tr("Loop playback"));
|
Chris@69
|
1498 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@69
|
1499 action, SLOT(setChecked(bool)));
|
Chris@0
|
1500 connect(action, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
1501 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1502
|
Chris@0
|
1503 toolbar = addToolBar(tr("Edit Toolbar"));
|
Chris@0
|
1504 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@0
|
1505
|
Chris@0
|
1506 toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@0
|
1507 QActionGroup *group = new QActionGroup(this);
|
Chris@0
|
1508
|
Chris@0
|
1509 action = toolbar->addAction(QIcon(":/icons/navigate.png"),
|
Chris@0
|
1510 tr("Navigate"));
|
Chris@0
|
1511 action->setCheckable(true);
|
Chris@0
|
1512 action->setChecked(true);
|
Chris@0
|
1513 action->setShortcut(tr("1"));
|
Chris@90
|
1514 action->setStatusTip(tr("Navigate"));
|
Chris@0
|
1515 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@0
|
1516 group->addAction(action);
|
Chris@0
|
1517 m_toolActions[ViewManager::NavigateMode] = action;
|
Chris@0
|
1518
|
Chris@0
|
1519 action = toolbar->addAction(QIcon(":/icons/select.png"),
|
Chris@0
|
1520 tr("Select"));
|
Chris@0
|
1521 action->setCheckable(true);
|
Chris@0
|
1522 action->setShortcut(tr("2"));
|
Chris@90
|
1523 action->setStatusTip(tr("Select ranges"));
|
Chris@0
|
1524 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected()));
|
Chris@0
|
1525 group->addAction(action);
|
Chris@0
|
1526 m_toolActions[ViewManager::SelectMode] = action;
|
Chris@0
|
1527
|
Chris@0
|
1528 action = toolbar->addAction(QIcon(":/icons/move.png"),
|
Chris@0
|
1529 tr("Edit"));
|
Chris@0
|
1530 action->setCheckable(true);
|
Chris@0
|
1531 action->setShortcut(tr("3"));
|
Chris@90
|
1532 action->setStatusTip(tr("Edit items in layer"));
|
Chris@0
|
1533 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@0
|
1534 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1535 group->addAction(action);
|
Chris@0
|
1536 m_toolActions[ViewManager::EditMode] = action;
|
Chris@0
|
1537
|
Chris@0
|
1538 action = toolbar->addAction(QIcon(":/icons/draw.png"),
|
Chris@0
|
1539 tr("Draw"));
|
Chris@0
|
1540 action->setCheckable(true);
|
Chris@0
|
1541 action->setShortcut(tr("4"));
|
Chris@90
|
1542 action->setStatusTip(tr("Draw new items in layer"));
|
Chris@0
|
1543 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected()));
|
Chris@0
|
1544 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1545 group->addAction(action);
|
Chris@0
|
1546 m_toolActions[ViewManager::DrawMode] = action;
|
Chris@0
|
1547
|
Chris@0
|
1548 // action = toolbar->addAction(QIcon(":/icons/text.png"),
|
Chris@0
|
1549 // tr("Text"));
|
Chris@0
|
1550 // action->setCheckable(true);
|
Chris@0
|
1551 // action->setShortcut(tr("5"));
|
Chris@0
|
1552 // connect(action, SIGNAL(triggered()), this, SLOT(toolTextSelected()));
|
Chris@0
|
1553 // group->addAction(action);
|
Chris@0
|
1554 // m_toolActions[ViewManager::TextMode] = action;
|
Chris@0
|
1555
|
Chris@0
|
1556 toolNavigateSelected();
|
Chris@0
|
1557 }
|
Chris@0
|
1558
|
Chris@0
|
1559 void
|
Chris@0
|
1560 MainWindow::updateMenuStates()
|
Chris@0
|
1561 {
|
Chris@0
|
1562 bool haveCurrentPane =
|
Chris@0
|
1563 (m_paneStack &&
|
Chris@0
|
1564 (m_paneStack->getCurrentPane() != 0));
|
Chris@0
|
1565 bool haveCurrentLayer =
|
Chris@0
|
1566 (haveCurrentPane &&
|
Chris@0
|
1567 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1568 bool haveMainModel =
|
Chris@0
|
1569 (getMainModel() != 0);
|
Chris@0
|
1570 bool havePlayTarget =
|
Chris@0
|
1571 (m_playTarget != 0);
|
Chris@0
|
1572 bool haveSelection =
|
Chris@0
|
1573 (m_viewManager &&
|
Chris@0
|
1574 !m_viewManager->getSelections().empty());
|
Chris@0
|
1575 bool haveCurrentEditableLayer =
|
Chris@0
|
1576 (haveCurrentLayer &&
|
Chris@0
|
1577 m_paneStack->getCurrentPane()->getSelectedLayer()->
|
Chris@0
|
1578 isLayerEditable());
|
Chris@0
|
1579 bool haveCurrentTimeInstantsLayer =
|
Chris@0
|
1580 (haveCurrentLayer &&
|
Chris@0
|
1581 dynamic_cast<TimeInstantLayer *>
|
Chris@0
|
1582 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1583 bool haveCurrentTimeValueLayer =
|
Chris@0
|
1584 (haveCurrentLayer &&
|
Chris@0
|
1585 dynamic_cast<TimeValueLayer *>
|
Chris@0
|
1586 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1587 bool haveCurrentColour3DPlot =
|
Chris@0
|
1588 (haveCurrentLayer &&
|
Chris@0
|
1589 dynamic_cast<Colour3DPlotLayer *>
|
Chris@0
|
1590 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1591 bool haveClipboardContents =
|
Chris@0
|
1592 (m_viewManager &&
|
Chris@0
|
1593 !m_viewManager->getClipboard().empty());
|
Chris@0
|
1594
|
Chris@0
|
1595 emit canAddPane(haveMainModel);
|
Chris@0
|
1596 emit canDeleteCurrentPane(haveCurrentPane);
|
Chris@0
|
1597 emit canZoom(haveMainModel && haveCurrentPane);
|
Chris@0
|
1598 emit canScroll(haveMainModel && haveCurrentPane);
|
Chris@0
|
1599 emit canAddLayer(haveMainModel && haveCurrentPane);
|
Chris@0
|
1600 emit canImportMoreAudio(haveMainModel);
|
Chris@0
|
1601 emit canImportLayer(haveMainModel && haveCurrentPane);
|
Chris@0
|
1602 emit canExportAudio(haveMainModel);
|
Chris@0
|
1603 emit canExportLayer(haveMainModel &&
|
Chris@0
|
1604 (haveCurrentEditableLayer || haveCurrentColour3DPlot));
|
Chris@0
|
1605 emit canDeleteCurrentLayer(haveCurrentLayer);
|
Chris@0
|
1606 emit canRenameLayer(haveCurrentLayer);
|
Chris@0
|
1607 emit canEditLayer(haveCurrentEditableLayer);
|
Chris@0
|
1608 emit canSelect(haveMainModel && haveCurrentPane);
|
Chris@0
|
1609 emit canPlay(/*!!! haveMainModel && */ havePlayTarget);
|
Chris@0
|
1610 emit canFfwd(haveCurrentTimeInstantsLayer || haveCurrentTimeValueLayer);
|
Chris@0
|
1611 emit canRewind(haveCurrentTimeInstantsLayer || haveCurrentTimeValueLayer);
|
Chris@0
|
1612 emit canPaste(haveCurrentEditableLayer && haveClipboardContents);
|
Chris@0
|
1613 emit canInsertInstant(haveCurrentPane);
|
Chris@81
|
1614 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection);
|
Chris@0
|
1615 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
|
Chris@0
|
1616 emit canClearSelection(haveSelection);
|
Chris@0
|
1617 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
|
Chris@0
|
1618 emit canSave(m_sessionFile != "" && m_documentModified);
|
Chris@0
|
1619 }
|
Chris@0
|
1620
|
Chris@0
|
1621 void
|
Chris@0
|
1622 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1623 {
|
Chris@0
|
1624 if (!getMainModel()) {
|
Chris@0
|
1625 m_descriptionLabel->setText(tr("No audio file loaded."));
|
Chris@0
|
1626 return;
|
Chris@0
|
1627 }
|
Chris@0
|
1628
|
Chris@0
|
1629 QString description;
|
Chris@0
|
1630
|
Chris@0
|
1631 size_t ssr = getMainModel()->getSampleRate();
|
Chris@0
|
1632 size_t tsr = ssr;
|
Chris@0
|
1633 if (m_playSource) tsr = m_playSource->getTargetSampleRate();
|
Chris@0
|
1634
|
Chris@0
|
1635 if (ssr != tsr) {
|
Chris@0
|
1636 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
|
Chris@0
|
1637 } else {
|
Chris@0
|
1638 description = QString("%1Hz").arg(ssr);
|
Chris@0
|
1639 }
|
Chris@0
|
1640
|
Chris@0
|
1641 description = QString("%1 - %2")
|
Chris@0
|
1642 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr)
|
Chris@0
|
1643 .toText(false).c_str())
|
Chris@0
|
1644 .arg(description);
|
Chris@0
|
1645
|
Chris@0
|
1646 m_descriptionLabel->setText(description);
|
Chris@0
|
1647 }
|
Chris@0
|
1648
|
Chris@0
|
1649 void
|
Chris@0
|
1650 MainWindow::documentModified()
|
Chris@0
|
1651 {
|
Chris@0
|
1652 // std::cerr << "MainWindow::documentModified" << std::endl;
|
Chris@0
|
1653
|
Chris@0
|
1654 if (!m_documentModified) {
|
Chris@0
|
1655 setWindowTitle(tr("%1 (modified)").arg(windowTitle()));
|
Chris@0
|
1656 }
|
Chris@0
|
1657
|
Chris@0
|
1658 m_documentModified = true;
|
Chris@0
|
1659 updateMenuStates();
|
Chris@0
|
1660 }
|
Chris@0
|
1661
|
Chris@0
|
1662 void
|
Chris@0
|
1663 MainWindow::documentRestored()
|
Chris@0
|
1664 {
|
Chris@0
|
1665 // std::cerr << "MainWindow::documentRestored" << std::endl;
|
Chris@0
|
1666
|
Chris@0
|
1667 if (m_documentModified) {
|
Chris@0
|
1668 QString wt(windowTitle());
|
Chris@0
|
1669 wt.replace(tr(" (modified)"), "");
|
Chris@0
|
1670 setWindowTitle(wt);
|
Chris@0
|
1671 }
|
Chris@0
|
1672
|
Chris@0
|
1673 m_documentModified = false;
|
Chris@0
|
1674 updateMenuStates();
|
Chris@0
|
1675 }
|
Chris@0
|
1676
|
Chris@0
|
1677 void
|
Chris@0
|
1678 MainWindow::playLoopToggled()
|
Chris@0
|
1679 {
|
Chris@0
|
1680 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@0
|
1681
|
Chris@0
|
1682 if (action) {
|
Chris@0
|
1683 m_viewManager->setPlayLoopMode(action->isChecked());
|
Chris@0
|
1684 } else {
|
Chris@0
|
1685 m_viewManager->setPlayLoopMode(!m_viewManager->getPlayLoopMode());
|
Chris@0
|
1686 }
|
Chris@0
|
1687 }
|
Chris@0
|
1688
|
Chris@0
|
1689 void
|
Chris@0
|
1690 MainWindow::playSelectionToggled()
|
Chris@0
|
1691 {
|
Chris@0
|
1692 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@0
|
1693
|
Chris@0
|
1694 if (action) {
|
Chris@0
|
1695 m_viewManager->setPlaySelectionMode(action->isChecked());
|
Chris@0
|
1696 } else {
|
Chris@0
|
1697 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode());
|
Chris@0
|
1698 }
|
Chris@0
|
1699 }
|
Chris@0
|
1700
|
Chris@0
|
1701 void
|
Chris@0
|
1702 MainWindow::currentPaneChanged(Pane *)
|
Chris@0
|
1703 {
|
Chris@0
|
1704 updateMenuStates();
|
Chris@0
|
1705 }
|
Chris@0
|
1706
|
Chris@0
|
1707 void
|
Chris@0
|
1708 MainWindow::currentLayerChanged(Pane *, Layer *)
|
Chris@0
|
1709 {
|
Chris@0
|
1710 updateMenuStates();
|
Chris@0
|
1711 }
|
Chris@0
|
1712
|
Chris@0
|
1713 void
|
Chris@0
|
1714 MainWindow::toolNavigateSelected()
|
Chris@0
|
1715 {
|
Chris@0
|
1716 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
1717 }
|
Chris@0
|
1718
|
Chris@0
|
1719 void
|
Chris@0
|
1720 MainWindow::toolSelectSelected()
|
Chris@0
|
1721 {
|
Chris@0
|
1722 m_viewManager->setToolMode(ViewManager::SelectMode);
|
Chris@0
|
1723 }
|
Chris@0
|
1724
|
Chris@0
|
1725 void
|
Chris@0
|
1726 MainWindow::toolEditSelected()
|
Chris@0
|
1727 {
|
Chris@0
|
1728 m_viewManager->setToolMode(ViewManager::EditMode);
|
Chris@0
|
1729 }
|
Chris@0
|
1730
|
Chris@0
|
1731 void
|
Chris@0
|
1732 MainWindow::toolDrawSelected()
|
Chris@0
|
1733 {
|
Chris@0
|
1734 m_viewManager->setToolMode(ViewManager::DrawMode);
|
Chris@0
|
1735 }
|
Chris@0
|
1736
|
Chris@0
|
1737 //void
|
Chris@0
|
1738 //MainWindow::toolTextSelected()
|
Chris@0
|
1739 //{
|
Chris@0
|
1740 // m_viewManager->setToolMode(ViewManager::TextMode);
|
Chris@0
|
1741 //}
|
Chris@0
|
1742
|
Chris@0
|
1743 void
|
Chris@0
|
1744 MainWindow::selectAll()
|
Chris@0
|
1745 {
|
Chris@0
|
1746 if (!getMainModel()) return;
|
Chris@0
|
1747 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(),
|
Chris@0
|
1748 getMainModel()->getEndFrame()));
|
Chris@0
|
1749 }
|
Chris@0
|
1750
|
Chris@0
|
1751 void
|
Chris@0
|
1752 MainWindow::selectToStart()
|
Chris@0
|
1753 {
|
Chris@0
|
1754 if (!getMainModel()) return;
|
Chris@0
|
1755 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(),
|
Chris@0
|
1756 m_viewManager->getGlobalCentreFrame()));
|
Chris@0
|
1757 }
|
Chris@0
|
1758
|
Chris@0
|
1759 void
|
Chris@0
|
1760 MainWindow::selectToEnd()
|
Chris@0
|
1761 {
|
Chris@0
|
1762 if (!getMainModel()) return;
|
Chris@0
|
1763 m_viewManager->setSelection(Selection(m_viewManager->getGlobalCentreFrame(),
|
Chris@0
|
1764 getMainModel()->getEndFrame()));
|
Chris@0
|
1765 }
|
Chris@0
|
1766
|
Chris@0
|
1767 void
|
Chris@0
|
1768 MainWindow::selectVisible()
|
Chris@0
|
1769 {
|
Chris@0
|
1770 Model *model = getMainModel();
|
Chris@0
|
1771 if (!model) return;
|
Chris@0
|
1772
|
Chris@0
|
1773 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1774 if (!currentPane) return;
|
Chris@0
|
1775
|
Chris@0
|
1776 size_t startFrame, endFrame;
|
Chris@0
|
1777
|
Chris@0
|
1778 if (currentPane->getStartFrame() < 0) startFrame = 0;
|
Chris@0
|
1779 else startFrame = currentPane->getStartFrame();
|
Chris@0
|
1780
|
Chris@0
|
1781 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame();
|
Chris@0
|
1782 else endFrame = currentPane->getEndFrame();
|
Chris@0
|
1783
|
Chris@0
|
1784 m_viewManager->setSelection(Selection(startFrame, endFrame));
|
Chris@0
|
1785 }
|
Chris@0
|
1786
|
Chris@0
|
1787 void
|
Chris@0
|
1788 MainWindow::clearSelection()
|
Chris@0
|
1789 {
|
Chris@0
|
1790 m_viewManager->clearSelections();
|
Chris@0
|
1791 }
|
Chris@0
|
1792
|
Chris@0
|
1793 void
|
Chris@0
|
1794 MainWindow::cut()
|
Chris@0
|
1795 {
|
Chris@0
|
1796 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1797 if (!currentPane) return;
|
Chris@0
|
1798
|
Chris@0
|
1799 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1800 if (!layer) return;
|
Chris@0
|
1801
|
Chris@0
|
1802 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1803 clipboard.clear();
|
Chris@0
|
1804
|
Chris@0
|
1805 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
1806
|
Chris@0
|
1807 CommandHistory::getInstance()->startCompoundOperation(tr("Cut"), true);
|
Chris@0
|
1808
|
Chris@0
|
1809 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1810 i != selections.end(); ++i) {
|
Chris@0
|
1811 layer->copy(*i, clipboard);
|
Chris@0
|
1812 layer->deleteSelection(*i);
|
Chris@0
|
1813 }
|
Chris@0
|
1814
|
Chris@0
|
1815 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
1816 }
|
Chris@0
|
1817
|
Chris@0
|
1818 void
|
Chris@0
|
1819 MainWindow::copy()
|
Chris@0
|
1820 {
|
Chris@0
|
1821 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1822 if (!currentPane) return;
|
Chris@0
|
1823
|
Chris@0
|
1824 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1825 if (!layer) return;
|
Chris@0
|
1826
|
Chris@0
|
1827 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1828 clipboard.clear();
|
Chris@0
|
1829
|
Chris@0
|
1830 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
1831
|
Chris@0
|
1832 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1833 i != selections.end(); ++i) {
|
Chris@0
|
1834 layer->copy(*i, clipboard);
|
Chris@0
|
1835 }
|
Chris@0
|
1836 }
|
Chris@0
|
1837
|
Chris@0
|
1838 void
|
Chris@0
|
1839 MainWindow::paste()
|
Chris@0
|
1840 {
|
Chris@0
|
1841 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1842 if (!currentPane) return;
|
Chris@0
|
1843
|
Chris@0
|
1844 //!!! if we have no current layer, we should create one of the most
|
Chris@0
|
1845 // appropriate type
|
Chris@0
|
1846
|
Chris@0
|
1847 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1848 if (!layer) return;
|
Chris@0
|
1849
|
Chris@0
|
1850 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1851 Clipboard::PointList contents = clipboard.getPoints();
|
Chris@0
|
1852 /*
|
Chris@0
|
1853 long minFrame = 0;
|
Chris@0
|
1854 bool have = false;
|
Chris@0
|
1855 for (int i = 0; i < contents.size(); ++i) {
|
Chris@0
|
1856 if (!contents[i].haveFrame()) continue;
|
Chris@0
|
1857 if (!have || contents[i].getFrame() < minFrame) {
|
Chris@0
|
1858 minFrame = contents[i].getFrame();
|
Chris@0
|
1859 have = true;
|
Chris@0
|
1860 }
|
Chris@0
|
1861 }
|
Chris@0
|
1862
|
Chris@0
|
1863 long frameOffset = long(m_viewManager->getGlobalCentreFrame()) - minFrame;
|
Chris@0
|
1864
|
Chris@0
|
1865 layer->paste(clipboard, frameOffset);
|
Chris@0
|
1866 */
|
Chris@0
|
1867 layer->paste(clipboard, 0, true);
|
Chris@0
|
1868 }
|
Chris@0
|
1869
|
Chris@0
|
1870 void
|
Chris@0
|
1871 MainWindow::deleteSelected()
|
Chris@0
|
1872 {
|
Chris@0
|
1873 if (m_paneStack->getCurrentPane() &&
|
Chris@0
|
1874 m_paneStack->getCurrentPane()->getSelectedLayer()) {
|
Chris@0
|
1875
|
Chris@0
|
1876 MultiSelection::SelectionList selections =
|
Chris@0
|
1877 m_viewManager->getSelections();
|
Chris@0
|
1878
|
Chris@0
|
1879 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1880 i != selections.end(); ++i) {
|
Chris@0
|
1881
|
Chris@0
|
1882 m_paneStack->getCurrentPane()->getSelectedLayer()->deleteSelection(*i);
|
Chris@0
|
1883 }
|
Chris@0
|
1884 }
|
Chris@0
|
1885 }
|
Chris@0
|
1886
|
Chris@0
|
1887 void
|
Chris@0
|
1888 MainWindow::insertInstant()
|
Chris@0
|
1889 {
|
Chris@0
|
1890 int frame = m_viewManager->getPlaybackFrame();
|
Chris@81
|
1891 insertInstantAt(frame);
|
Chris@81
|
1892 }
|
Chris@81
|
1893
|
Chris@81
|
1894 void
|
Chris@81
|
1895 MainWindow::insertInstantsAtBoundaries()
|
Chris@81
|
1896 {
|
Chris@81
|
1897 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@81
|
1898 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@81
|
1899 i != selections.end(); ++i) {
|
Chris@81
|
1900 size_t start = i->getStartFrame();
|
Chris@81
|
1901 size_t end = i->getEndFrame();
|
Chris@81
|
1902 if (start != end) {
|
Chris@81
|
1903 insertInstantAt(i->getStartFrame());
|
Chris@81
|
1904 insertInstantAt(i->getEndFrame());
|
Chris@81
|
1905 }
|
Chris@81
|
1906 }
|
Chris@81
|
1907 }
|
Chris@81
|
1908
|
Chris@81
|
1909 void
|
Chris@81
|
1910 MainWindow::insertInstantAt(size_t frame)
|
Chris@81
|
1911 {
|
Chris@0
|
1912 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
1913 if (!pane) {
|
Chris@0
|
1914 return;
|
Chris@0
|
1915 }
|
Chris@0
|
1916
|
Chris@0
|
1917 Layer *layer = dynamic_cast<TimeInstantLayer *>
|
Chris@0
|
1918 (pane->getSelectedLayer());
|
Chris@0
|
1919
|
Chris@0
|
1920 if (!layer) {
|
Chris@0
|
1921 for (int i = pane->getLayerCount(); i > 0; --i) {
|
Chris@0
|
1922 layer = dynamic_cast<TimeInstantLayer *>(pane->getLayer(i - 1));
|
Chris@0
|
1923 if (layer) break;
|
Chris@0
|
1924 }
|
Chris@0
|
1925
|
Chris@0
|
1926 if (!layer) {
|
Chris@0
|
1927 CommandHistory::getInstance()->startCompoundOperation
|
Chris@0
|
1928 (tr("Add Point"), true);
|
Chris@0
|
1929 layer = m_document->createEmptyLayer(LayerFactory::TimeInstants);
|
Chris@0
|
1930 if (layer) {
|
Chris@0
|
1931 m_document->addLayerToView(pane, layer);
|
Chris@0
|
1932 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@0
|
1933 }
|
Chris@0
|
1934 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
1935 }
|
Chris@0
|
1936 }
|
Chris@0
|
1937
|
Chris@0
|
1938 if (layer) {
|
Chris@0
|
1939
|
Chris@0
|
1940 Model *model = layer->getModel();
|
Chris@0
|
1941 SparseOneDimensionalModel *sodm = dynamic_cast<SparseOneDimensionalModel *>
|
Chris@0
|
1942 (model);
|
Chris@0
|
1943
|
Chris@0
|
1944 if (sodm) {
|
Chris@0
|
1945 SparseOneDimensionalModel::Point point
|
Chris@0
|
1946 (frame, QString("%1").arg(sodm->getPointCount() + 1));
|
Chris@0
|
1947 CommandHistory::getInstance()->addCommand
|
Chris@0
|
1948 (new SparseOneDimensionalModel::AddPointCommand(sodm, point,
|
Chris@0
|
1949 tr("Add Points")),
|
Chris@0
|
1950 true, true); // bundled
|
Chris@0
|
1951 }
|
Chris@0
|
1952 }
|
Chris@0
|
1953 }
|
Chris@0
|
1954
|
Chris@0
|
1955 void
|
Chris@0
|
1956 MainWindow::importAudio()
|
Chris@0
|
1957 {
|
Chris@88
|
1958 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
1959
|
Chris@0
|
1960 if (path != "") {
|
Chris@82
|
1961 if (openAudioFile(path, ReplaceMainModel) == FileOpenFailed) {
|
Chris@0
|
1962 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1963 tr("Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1964 }
|
Chris@0
|
1965 }
|
Chris@0
|
1966 }
|
Chris@0
|
1967
|
Chris@0
|
1968 void
|
Chris@0
|
1969 MainWindow::importMoreAudio()
|
Chris@0
|
1970 {
|
Chris@88
|
1971 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
1972
|
Chris@0
|
1973 if (path != "") {
|
Chris@82
|
1974 if (openAudioFile(path, CreateAdditionalModel) == FileOpenFailed) {
|
Chris@0
|
1975 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1976 tr("Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1977 }
|
Chris@0
|
1978 }
|
Chris@0
|
1979 }
|
Chris@0
|
1980
|
Chris@0
|
1981 void
|
Chris@0
|
1982 MainWindow::exportAudio()
|
Chris@0
|
1983 {
|
Chris@0
|
1984 if (!getMainModel()) return;
|
Chris@0
|
1985
|
Chris@88
|
1986 QString path = getSaveFileName(FileFinder::AudioFile);
|
Chris@0
|
1987
|
Chris@0
|
1988 if (path == "") return;
|
Chris@0
|
1989
|
Chris@0
|
1990 bool ok = false;
|
Chris@0
|
1991 QString error;
|
Chris@0
|
1992
|
Chris@0
|
1993 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
1994 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
1995
|
Chris@0
|
1996 bool multiple = false;
|
Chris@0
|
1997
|
Chris@38
|
1998 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
1999
|
Chris@38
|
2000 if (selections.size() == 1) {
|
Chris@0
|
2001
|
Chris@0
|
2002 QStringList items;
|
Chris@0
|
2003 items << tr("Export the selected region only")
|
Chris@0
|
2004 << tr("Export the whole audio file");
|
Chris@0
|
2005
|
Chris@0
|
2006 bool ok = false;
|
Chris@0
|
2007 QString item = ListInputDialog::getItem
|
Chris@0
|
2008 (this, tr("Select region to export"),
|
Chris@0
|
2009 tr("Which region from the original audio file do you want to export?"),
|
Chris@0
|
2010 items, 0, &ok);
|
Chris@0
|
2011
|
Chris@0
|
2012 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2013
|
Chris@38
|
2014 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2015
|
Chris@38
|
2016 } else if (selections.size() > 1) {
|
Chris@0
|
2017
|
Chris@0
|
2018 QStringList items;
|
Chris@0
|
2019 items << tr("Export the selected regions into a single audio file")
|
Chris@0
|
2020 << tr("Export the selected regions into separate files")
|
Chris@0
|
2021 << tr("Export the whole audio file");
|
Chris@0
|
2022
|
Chris@0
|
2023 QString item = ListInputDialog::getItem
|
Chris@0
|
2024 (this, tr("Select region to export"),
|
Chris@0
|
2025 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@0
|
2026 items, 0, &ok);
|
Chris@0
|
2027
|
Chris@0
|
2028 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2029
|
Chris@0
|
2030 if (item == items[0]) {
|
Chris@0
|
2031
|
Chris@38
|
2032 selectionToWrite = &ms;
|
Chris@38
|
2033
|
Chris@38
|
2034 } else if (item == items[1]) {
|
Chris@0
|
2035
|
Chris@0
|
2036 multiple = true;
|
Chris@0
|
2037
|
Chris@0
|
2038 int n = 1;
|
Chris@0
|
2039 QString base = path;
|
Chris@0
|
2040 base.replace(".wav", "");
|
Chris@0
|
2041
|
Chris@0
|
2042 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
2043 i != selections.end(); ++i) {
|
Chris@0
|
2044
|
Chris@0
|
2045 MultiSelection subms;
|
Chris@0
|
2046 subms.setSelection(*i);
|
Chris@0
|
2047
|
Chris@0
|
2048 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@0
|
2049 ++n;
|
Chris@0
|
2050
|
Chris@0
|
2051 if (QFileInfo(subpath).exists()) {
|
Chris@0
|
2052 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@0
|
2053 break;
|
Chris@0
|
2054 }
|
Chris@0
|
2055
|
Chris@38
|
2056 WavFileWriter subwriter(subpath,
|
Chris@38
|
2057 getMainModel()->getSampleRate(),
|
Chris@38
|
2058 getMainModel()->getChannelCount());
|
Chris@38
|
2059 subwriter.writeModel(getMainModel(), &subms);
|
Chris@0
|
2060 ok = subwriter.isOK();
|
Chris@0
|
2061
|
Chris@0
|
2062 if (!ok) {
|
Chris@0
|
2063 error = subwriter.getError();
|
Chris@0
|
2064 break;
|
Chris@0
|
2065 }
|
Chris@0
|
2066 }
|
Chris@0
|
2067 }
|
Chris@0
|
2068 }
|
Chris@0
|
2069
|
Chris@38
|
2070 if (!multiple) {
|
Chris@38
|
2071 WavFileWriter writer(path,
|
Chris@38
|
2072 getMainModel()->getSampleRate(),
|
Chris@38
|
2073 getMainModel()->getChannelCount());
|
Chris@38
|
2074 writer.writeModel(getMainModel(), selectionToWrite);
|
Chris@38
|
2075 ok = writer.isOK();
|
Chris@38
|
2076 error = writer.getError();
|
Chris@0
|
2077 }
|
Chris@0
|
2078
|
Chris@0
|
2079 if (ok) {
|
Chris@0
|
2080 if (!multiple) {
|
Chris@34
|
2081 m_recentFiles.addFile(path);
|
Chris@0
|
2082 }
|
Chris@0
|
2083 } else {
|
Chris@0
|
2084 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2085 }
|
Chris@0
|
2086 }
|
Chris@0
|
2087
|
Chris@0
|
2088 void
|
Chris@0
|
2089 MainWindow::importLayer()
|
Chris@0
|
2090 {
|
Chris@0
|
2091 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2092
|
Chris@0
|
2093 if (!pane) {
|
Chris@0
|
2094 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2095 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
|
Chris@0
|
2096 return;
|
Chris@0
|
2097 }
|
Chris@0
|
2098
|
Chris@0
|
2099 if (!getMainModel()) {
|
Chris@0
|
2100 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2101 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
|
Chris@0
|
2102 return;
|
Chris@0
|
2103 }
|
Chris@0
|
2104
|
Chris@88
|
2105 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2106
|
Chris@0
|
2107 if (path != "") {
|
Chris@0
|
2108
|
Chris@82
|
2109 if (openLayerFile(path) == FileOpenFailed) {
|
Chris@0
|
2110 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2111 tr("File %1 could not be opened.").arg(path));
|
Chris@0
|
2112 return;
|
Chris@0
|
2113 }
|
Chris@0
|
2114 }
|
Chris@0
|
2115 }
|
Chris@0
|
2116
|
Chris@82
|
2117 MainWindow::FileOpenStatus
|
Chris@0
|
2118 MainWindow::openLayerFile(QString path)
|
Chris@0
|
2119 {
|
Chris@86
|
2120 return openLayerFile(path, path);
|
Chris@86
|
2121 }
|
Chris@86
|
2122
|
Chris@86
|
2123 MainWindow::FileOpenStatus
|
Chris@86
|
2124 MainWindow::openLayerFile(QString path, QString location)
|
Chris@86
|
2125 {
|
Chris@0
|
2126 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2127
|
Chris@0
|
2128 if (!pane) {
|
Chris@0
|
2129 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2130 std::cerr << "WARNING: MainWindow::openLayerFile: no current pane" << std::endl;
|
Chris@82
|
2131 return FileOpenFailed;
|
Chris@0
|
2132 }
|
Chris@0
|
2133
|
Chris@0
|
2134 if (!getMainModel()) {
|
Chris@0
|
2135 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2136 std::cerr << "WARNING: MainWindow::openLayerFile: No main model -- hence no default sample rate available" << std::endl;
|
Chris@82
|
2137 return FileOpenFailed;
|
Chris@0
|
2138 }
|
Chris@0
|
2139
|
Chris@86
|
2140 bool realFile = (location == path);
|
Chris@86
|
2141
|
Chris@0
|
2142 if (path.endsWith(".svl") || path.endsWith(".xml")) {
|
Chris@0
|
2143
|
Chris@0
|
2144 PaneCallback callback(this);
|
Chris@0
|
2145 QFile file(path);
|
Chris@0
|
2146
|
Chris@0
|
2147 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
Chris@0
|
2148 std::cerr << "ERROR: MainWindow::openLayerFile("
|
Chris@86
|
2149 << location.toStdString()
|
Chris@0
|
2150 << "): Failed to open file for reading" << std::endl;
|
Chris@82
|
2151 return FileOpenFailed;
|
Chris@0
|
2152 }
|
Chris@0
|
2153
|
Chris@87
|
2154 SVFileReader reader(m_document, callback, location);
|
Chris@0
|
2155 reader.setCurrentPane(pane);
|
Chris@0
|
2156
|
Chris@0
|
2157 QXmlInputSource inputSource(&file);
|
Chris@0
|
2158 reader.parse(inputSource);
|
Chris@0
|
2159
|
Chris@0
|
2160 if (!reader.isOK()) {
|
Chris@0
|
2161 std::cerr << "ERROR: MainWindow::openLayerFile("
|
Chris@86
|
2162 << location.toStdString()
|
Chris@0
|
2163 << "): Failed to read XML file: "
|
Chris@0
|
2164 << reader.getErrorString().toStdString() << std::endl;
|
Chris@82
|
2165 return FileOpenFailed;
|
Chris@0
|
2166 }
|
Chris@0
|
2167
|
Chris@86
|
2168 m_recentFiles.addFile(location);
|
Chris@86
|
2169
|
Chris@86
|
2170 if (realFile) {
|
Chris@88
|
2171 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog
|
Chris@86
|
2172 }
|
Chris@86
|
2173
|
Chris@82
|
2174 return FileOpenSucceeded;
|
Chris@0
|
2175
|
Chris@0
|
2176 } else {
|
Chris@0
|
2177
|
Chris@0
|
2178 Model *model = DataFileReaderFactory::load(path, getMainModel()->getSampleRate());
|
Chris@0
|
2179
|
Chris@0
|
2180 if (model) {
|
Chris@86
|
2181
|
Chris@0
|
2182 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@86
|
2183
|
Chris@0
|
2184 if (newLayer) {
|
Chris@86
|
2185
|
Chris@0
|
2186 m_document->addLayerToView(pane, newLayer);
|
Chris@86
|
2187 m_recentFiles.addFile(location);
|
Chris@86
|
2188
|
Chris@86
|
2189 if (realFile) {
|
Chris@88
|
2190 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog
|
Chris@86
|
2191 }
|
Chris@86
|
2192
|
Chris@82
|
2193 return FileOpenSucceeded;
|
Chris@0
|
2194 }
|
Chris@0
|
2195 }
|
Chris@0
|
2196 }
|
Chris@0
|
2197
|
Chris@82
|
2198 return FileOpenFailed;
|
Chris@0
|
2199 }
|
Chris@0
|
2200
|
Chris@0
|
2201 void
|
Chris@0
|
2202 MainWindow::exportLayer()
|
Chris@0
|
2203 {
|
Chris@0
|
2204 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2205 if (!pane) return;
|
Chris@0
|
2206
|
Chris@0
|
2207 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2208 if (!layer) return;
|
Chris@0
|
2209
|
Chris@0
|
2210 Model *model = layer->getModel();
|
Chris@0
|
2211 if (!model) return;
|
Chris@0
|
2212
|
Chris@88
|
2213 QString path = getSaveFileName(FileFinder::LayerFile);
|
Chris@0
|
2214
|
Chris@0
|
2215 if (path == "") return;
|
Chris@0
|
2216
|
Chris@0
|
2217 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
2218
|
Chris@0
|
2219 QString error;
|
Chris@0
|
2220
|
Chris@0
|
2221 if (path.endsWith(".xml") || path.endsWith(".svl")) {
|
Chris@0
|
2222
|
Chris@0
|
2223 QFile file(path);
|
Chris@0
|
2224 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
2225 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
2226 } else {
|
Chris@0
|
2227 QTextStream out(&file);
|
Chris@0
|
2228 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
2229 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
2230 << "<sv>\n"
|
Chris@0
|
2231 << " <data>\n";
|
Chris@0
|
2232
|
Chris@0
|
2233 model->toXml(out, " ");
|
Chris@0
|
2234
|
Chris@0
|
2235 out << " </data>\n"
|
Chris@0
|
2236 << " <display>\n";
|
Chris@0
|
2237
|
Chris@0
|
2238 layer->toXml(out, " ");
|
Chris@0
|
2239
|
Chris@0
|
2240 out << " </display>\n"
|
Chris@0
|
2241 << "</sv>\n";
|
Chris@0
|
2242 }
|
Chris@0
|
2243
|
Chris@0
|
2244 } else {
|
Chris@0
|
2245
|
Chris@0
|
2246 CSVFileWriter writer(path, model,
|
Chris@0
|
2247 (path.endsWith(".csv") ? "," : "\t"));
|
Chris@0
|
2248 writer.write();
|
Chris@0
|
2249
|
Chris@0
|
2250 if (!writer.isOK()) {
|
Chris@0
|
2251 error = writer.getError();
|
Chris@0
|
2252 }
|
Chris@0
|
2253 }
|
Chris@0
|
2254
|
Chris@0
|
2255 if (error != "") {
|
Chris@0
|
2256 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2257 } else {
|
Chris@34
|
2258 m_recentFiles.addFile(path);
|
Chris@0
|
2259 }
|
Chris@0
|
2260 }
|
Chris@0
|
2261
|
Chris@82
|
2262 MainWindow::FileOpenStatus
|
Chris@0
|
2263 MainWindow::openAudioFile(QString path, AudioFileOpenMode mode)
|
Chris@0
|
2264 {
|
Chris@86
|
2265 return openAudioFile(path, path, mode);
|
Chris@86
|
2266 }
|
Chris@86
|
2267
|
Chris@86
|
2268 MainWindow::FileOpenStatus
|
Chris@86
|
2269 MainWindow::openAudioFile(QString path, QString location, AudioFileOpenMode mode)
|
Chris@86
|
2270 {
|
Chris@0
|
2271 if (!(QFileInfo(path).exists() &&
|
Chris@0
|
2272 QFileInfo(path).isFile() &&
|
Chris@0
|
2273 QFileInfo(path).isReadable())) {
|
Chris@82
|
2274 return FileOpenFailed;
|
Chris@0
|
2275 }
|
Chris@0
|
2276
|
Chris@70
|
2277 m_openingAudioFile = true;
|
Chris@70
|
2278
|
Chris@88
|
2279 WaveFileModel *newModel = new WaveFileModel(path, location);
|
Chris@0
|
2280
|
Chris@0
|
2281 if (!newModel->isOK()) {
|
Chris@0
|
2282 delete newModel;
|
Chris@70
|
2283 m_openingAudioFile = false;
|
Chris@82
|
2284 return FileOpenFailed;
|
Chris@0
|
2285 }
|
Chris@0
|
2286
|
Chris@0
|
2287 bool setAsMain = true;
|
Chris@0
|
2288 static bool prevSetAsMain = true;
|
Chris@0
|
2289
|
Chris@86
|
2290 bool realFile = (location == path);
|
Chris@86
|
2291
|
Chris@0
|
2292 if (mode == CreateAdditionalModel) setAsMain = false;
|
Chris@0
|
2293 else if (mode == AskUser) {
|
Chris@0
|
2294 if (m_document->getMainModel()) {
|
Chris@0
|
2295
|
Chris@0
|
2296 QStringList items;
|
Chris@0
|
2297 items << tr("Replace the existing main waveform")
|
Chris@0
|
2298 << tr("Load this file into a new waveform pane");
|
Chris@0
|
2299
|
Chris@0
|
2300 bool ok = false;
|
Chris@0
|
2301 QString item = ListInputDialog::getItem
|
Chris@0
|
2302 (this, tr("Select target for import"),
|
Chris@0
|
2303 tr("You already have an audio waveform loaded.\nWhat would you like to do with the new audio file?"),
|
Chris@0
|
2304 items, prevSetAsMain ? 0 : 1, &ok);
|
Chris@0
|
2305
|
Chris@0
|
2306 if (!ok || item.isEmpty()) {
|
Chris@0
|
2307 delete newModel;
|
Chris@70
|
2308 m_openingAudioFile = false;
|
Chris@82
|
2309 return FileOpenCancelled;
|
Chris@0
|
2310 }
|
Chris@0
|
2311
|
Chris@0
|
2312 setAsMain = (item == items[0]);
|
Chris@0
|
2313 prevSetAsMain = setAsMain;
|
Chris@0
|
2314 }
|
Chris@0
|
2315 }
|
Chris@0
|
2316
|
Chris@0
|
2317 if (setAsMain) {
|
Chris@0
|
2318
|
Chris@0
|
2319 Model *prevMain = getMainModel();
|
Chris@0
|
2320 if (prevMain) m_playSource->removeModel(prevMain);
|
Chris@0
|
2321
|
Chris@0
|
2322 PlayParameterRepository::getInstance()->clear();
|
Chris@0
|
2323
|
Chris@0
|
2324 // The clear() call will have removed the parameters for the
|
Chris@0
|
2325 // main model. Re-add them with the new one.
|
Chris@0
|
2326 PlayParameterRepository::getInstance()->addModel(newModel);
|
Chris@0
|
2327
|
Chris@0
|
2328 m_document->setMainModel(newModel);
|
Chris@0
|
2329 setupMenus();
|
Chris@0
|
2330
|
Chris@0
|
2331 if (m_sessionFile == "") {
|
Chris@0
|
2332 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@86
|
2333 .arg(QFileInfo(location).fileName()));
|
Chris@0
|
2334 CommandHistory::getInstance()->clear();
|
Chris@0
|
2335 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2336 m_documentModified = false;
|
Chris@0
|
2337 } else {
|
Chris@0
|
2338 setWindowTitle(tr("Sonic Visualiser: %1 [%2]")
|
Chris@0
|
2339 .arg(QFileInfo(m_sessionFile).fileName())
|
Chris@86
|
2340 .arg(QFileInfo(location).fileName()));
|
Chris@0
|
2341 if (m_documentModified) {
|
Chris@0
|
2342 m_documentModified = false;
|
Chris@0
|
2343 documentModified(); // so as to restore "(modified)" window title
|
Chris@0
|
2344 }
|
Chris@0
|
2345 }
|
Chris@0
|
2346
|
Chris@86
|
2347 if (realFile) m_audioFile = path;
|
Chris@0
|
2348
|
Chris@0
|
2349 } else { // !setAsMain
|
Chris@0
|
2350
|
Chris@0
|
2351 CommandHistory::getInstance()->startCompoundOperation
|
Chris@86
|
2352 (tr("Import \"%1\"").arg(QFileInfo(location).fileName()), true);
|
Chris@0
|
2353
|
Chris@0
|
2354 m_document->addImportedModel(newModel);
|
Chris@0
|
2355
|
Chris@0
|
2356 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2357 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2358
|
Chris@0
|
2359 Pane *pane = command->getPane();
|
Chris@0
|
2360
|
Chris@0
|
2361 if (!m_timeRulerLayer) {
|
Chris@0
|
2362 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2363 (LayerFactory::TimeRuler);
|
Chris@0
|
2364 }
|
Chris@0
|
2365
|
Chris@0
|
2366 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2367
|
Chris@0
|
2368 Layer *newLayer = m_document->createImportedLayer(newModel);
|
Chris@0
|
2369
|
Chris@0
|
2370 if (newLayer) {
|
Chris@0
|
2371 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2372 }
|
Chris@0
|
2373
|
Chris@0
|
2374 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
2375 }
|
Chris@0
|
2376
|
Chris@0
|
2377 updateMenuStates();
|
Chris@86
|
2378 m_recentFiles.addFile(location);
|
Chris@86
|
2379 if (realFile) {
|
Chris@88
|
2380 registerLastOpenedFilePath(FileFinder::AudioFile, path); // for file dialog
|
Chris@86
|
2381 }
|
Chris@70
|
2382 m_openingAudioFile = false;
|
Chris@0
|
2383
|
Chris@82
|
2384 return FileOpenSucceeded;
|
Chris@0
|
2385 }
|
Chris@0
|
2386
|
Chris@0
|
2387 void
|
Chris@0
|
2388 MainWindow::createPlayTarget()
|
Chris@0
|
2389 {
|
Chris@0
|
2390 if (m_playTarget) return;
|
Chris@0
|
2391
|
Chris@0
|
2392 m_playTarget = AudioTargetFactory::createCallbackTarget(m_playSource);
|
Chris@0
|
2393 if (!m_playTarget) {
|
Chris@0
|
2394 QMessageBox::warning
|
Chris@0
|
2395 (this, tr("Couldn't open audio device"),
|
Chris@0
|
2396 tr("Could not open an audio device for playback.\nAudio playback will not be available during this session.\n"),
|
Chris@0
|
2397 QMessageBox::Ok, 0);
|
Chris@0
|
2398 }
|
Chris@0
|
2399 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2400 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2401 }
|
Chris@0
|
2402
|
Chris@0
|
2403 WaveFileModel *
|
Chris@0
|
2404 MainWindow::getMainModel()
|
Chris@0
|
2405 {
|
Chris@0
|
2406 if (!m_document) return 0;
|
Chris@0
|
2407 return m_document->getMainModel();
|
Chris@0
|
2408 }
|
Chris@0
|
2409
|
Chris@0
|
2410 void
|
Chris@0
|
2411 MainWindow::newSession()
|
Chris@0
|
2412 {
|
Chris@0
|
2413 if (!checkSaveModified()) return;
|
Chris@0
|
2414
|
Chris@0
|
2415 closeSession();
|
Chris@0
|
2416 createDocument();
|
Chris@0
|
2417
|
Chris@0
|
2418 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
2419
|
Chris@90
|
2420 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
2421 statusBar(), SLOT(showMessage(const QString &)));
|
Chris@90
|
2422
|
Chris@0
|
2423 if (!m_timeRulerLayer) {
|
Chris@0
|
2424 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2425 (LayerFactory::TimeRuler);
|
Chris@0
|
2426 }
|
Chris@0
|
2427
|
Chris@0
|
2428 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2429
|
Chris@0
|
2430 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
2431 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
2432
|
Chris@65
|
2433 m_overview->registerView(pane);
|
Chris@0
|
2434
|
Chris@0
|
2435 CommandHistory::getInstance()->clear();
|
Chris@0
|
2436 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2437 documentRestored();
|
Chris@0
|
2438 updateMenuStates();
|
Chris@0
|
2439 }
|
Chris@0
|
2440
|
Chris@0
|
2441 void
|
Chris@0
|
2442 MainWindow::createDocument()
|
Chris@0
|
2443 {
|
Chris@0
|
2444 m_document = new Document;
|
Chris@0
|
2445
|
Chris@0
|
2446 connect(m_document, SIGNAL(layerAdded(Layer *)),
|
Chris@0
|
2447 this, SLOT(layerAdded(Layer *)));
|
Chris@0
|
2448 connect(m_document, SIGNAL(layerRemoved(Layer *)),
|
Chris@0
|
2449 this, SLOT(layerRemoved(Layer *)));
|
Chris@0
|
2450 connect(m_document, SIGNAL(layerAboutToBeDeleted(Layer *)),
|
Chris@0
|
2451 this, SLOT(layerAboutToBeDeleted(Layer *)));
|
Chris@0
|
2452 connect(m_document, SIGNAL(layerInAView(Layer *, bool)),
|
Chris@0
|
2453 this, SLOT(layerInAView(Layer *, bool)));
|
Chris@0
|
2454
|
Chris@0
|
2455 connect(m_document, SIGNAL(modelAdded(Model *)),
|
Chris@0
|
2456 this, SLOT(modelAdded(Model *)));
|
Chris@0
|
2457 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)),
|
Chris@0
|
2458 this, SLOT(mainModelChanged(WaveFileModel *)));
|
Chris@0
|
2459 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@0
|
2460 this, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@0
|
2461
|
Chris@0
|
2462 connect(m_document, SIGNAL(modelGenerationFailed(QString)),
|
Chris@0
|
2463 this, SLOT(modelGenerationFailed(QString)));
|
Chris@63
|
2464 connect(m_document, SIGNAL(modelRegenerationFailed(QString, QString)),
|
Chris@63
|
2465 this, SLOT(modelRegenerationFailed(QString, QString)));
|
Chris@0
|
2466 }
|
Chris@0
|
2467
|
Chris@0
|
2468 void
|
Chris@0
|
2469 MainWindow::closeSession()
|
Chris@0
|
2470 {
|
Chris@0
|
2471 if (!checkSaveModified()) return;
|
Chris@0
|
2472
|
Chris@0
|
2473 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
2474
|
Chris@0
|
2475 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
2476
|
Chris@0
|
2477 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2478 m_document->removeLayerFromView
|
Chris@0
|
2479 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2480 }
|
Chris@0
|
2481
|
Chris@65
|
2482 m_overview->unregisterView(pane);
|
Chris@0
|
2483 m_paneStack->deletePane(pane);
|
Chris@0
|
2484 }
|
Chris@0
|
2485
|
Chris@0
|
2486 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
2487
|
Chris@0
|
2488 Pane *pane = m_paneStack->getHiddenPane
|
Chris@0
|
2489 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
2490
|
Chris@0
|
2491 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2492 m_document->removeLayerFromView
|
Chris@0
|
2493 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2494 }
|
Chris@0
|
2495
|
Chris@65
|
2496 m_overview->unregisterView(pane);
|
Chris@0
|
2497 m_paneStack->deletePane(pane);
|
Chris@0
|
2498 }
|
Chris@0
|
2499
|
Chris@0
|
2500 delete m_document;
|
Chris@0
|
2501 m_document = 0;
|
Chris@0
|
2502 m_viewManager->clearSelections();
|
Chris@0
|
2503 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
2504
|
Chris@0
|
2505 m_sessionFile = "";
|
Chris@0
|
2506 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2507
|
Chris@0
|
2508 CommandHistory::getInstance()->clear();
|
Chris@0
|
2509 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2510 documentRestored();
|
Chris@0
|
2511 }
|
Chris@0
|
2512
|
Chris@0
|
2513 void
|
Chris@0
|
2514 MainWindow::openSession()
|
Chris@0
|
2515 {
|
Chris@0
|
2516 if (!checkSaveModified()) return;
|
Chris@0
|
2517
|
Chris@0
|
2518 QString orig = m_audioFile;
|
Chris@0
|
2519 if (orig == "") orig = ".";
|
Chris@0
|
2520 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2521
|
Chris@88
|
2522 QString path = getOpenFileName(FileFinder::SessionFile);
|
Chris@0
|
2523
|
Chris@0
|
2524 if (path.isEmpty()) return;
|
Chris@0
|
2525
|
Chris@82
|
2526 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2527 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2528 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2529 }
|
Chris@0
|
2530 }
|
Chris@0
|
2531
|
Chris@0
|
2532 void
|
Chris@0
|
2533 MainWindow::openSomething()
|
Chris@0
|
2534 {
|
Chris@0
|
2535 QString orig = m_audioFile;
|
Chris@0
|
2536 if (orig == "") orig = ".";
|
Chris@0
|
2537 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2538
|
Chris@0
|
2539 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@0
|
2540 m_paneStack != 0 &&
|
Chris@0
|
2541 m_paneStack->getCurrentPane() != 0);
|
Chris@0
|
2542
|
Chris@88
|
2543 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
2544
|
Chris@0
|
2545 if (path.isEmpty()) return;
|
Chris@0
|
2546
|
Chris@0
|
2547 if (path.endsWith(".sv")) {
|
Chris@0
|
2548
|
Chris@0
|
2549 if (!checkSaveModified()) return;
|
Chris@0
|
2550
|
Chris@82
|
2551 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2552 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2553 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2554 }
|
Chris@0
|
2555
|
Chris@0
|
2556 } else {
|
Chris@0
|
2557
|
Chris@82
|
2558 if (openAudioFile(path, AskUser) == FileOpenFailed) {
|
Chris@82
|
2559
|
Chris@82
|
2560 if (!canImportLayer || (openLayerFile(path) == FileOpenFailed)) {
|
Chris@0
|
2561
|
Chris@0
|
2562 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2563 tr("File \"%1\" could not be opened").arg(path));
|
Chris@0
|
2564 }
|
Chris@0
|
2565 }
|
Chris@0
|
2566 }
|
Chris@0
|
2567 }
|
Chris@0
|
2568
|
Chris@0
|
2569 void
|
Chris@86
|
2570 MainWindow::openLocation()
|
Chris@86
|
2571 {
|
Chris@103
|
2572 QSettings settings;
|
Chris@103
|
2573 settings.beginGroup("MainWindow");
|
Chris@103
|
2574 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
2575
|
Chris@86
|
2576 bool ok = false;
|
Chris@86
|
2577 QString text = QInputDialog::getText
|
Chris@86
|
2578 (this, tr("Open Location"),
|
Chris@86
|
2579 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
2580 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
2581
|
Chris@103
|
2582 if (!ok) return;
|
Chris@103
|
2583
|
Chris@103
|
2584 settings.setValue("lastremote", text);
|
Chris@103
|
2585
|
Chris@103
|
2586 if (text.isEmpty()) return;
|
Chris@86
|
2587
|
Chris@86
|
2588 if (openURL(QUrl(text)) == FileOpenFailed) {
|
Chris@86
|
2589 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@86
|
2590 tr("URL \"%1\" could not be opened").arg(text));
|
Chris@86
|
2591 }
|
Chris@86
|
2592 }
|
Chris@86
|
2593
|
Chris@86
|
2594 void
|
Chris@0
|
2595 MainWindow::openRecentFile()
|
Chris@0
|
2596 {
|
Chris@0
|
2597 QObject *obj = sender();
|
Chris@0
|
2598 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
2599
|
Chris@0
|
2600 if (!action) {
|
Chris@0
|
2601 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@0
|
2602 << std::endl;
|
Chris@0
|
2603 return;
|
Chris@0
|
2604 }
|
Chris@0
|
2605
|
Chris@0
|
2606 QString path = action->text();
|
Chris@0
|
2607 if (path == "") return;
|
Chris@0
|
2608
|
Chris@86
|
2609 QUrl url(path);
|
Chris@86
|
2610 if (RemoteFile::canHandleScheme(url)) {
|
Chris@86
|
2611 openURL(url);
|
Chris@86
|
2612 return;
|
Chris@86
|
2613 }
|
Chris@86
|
2614
|
Chris@0
|
2615 if (path.endsWith("sv")) {
|
Chris@0
|
2616
|
Chris@103
|
2617 if (!checkSaveModified()) return;
|
Chris@0
|
2618
|
Chris@82
|
2619 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2620 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2621 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2622 }
|
Chris@0
|
2623
|
Chris@0
|
2624 } else {
|
Chris@0
|
2625
|
Chris@82
|
2626 if (openAudioFile(path, AskUser) == FileOpenFailed) {
|
Chris@0
|
2627
|
Chris@0
|
2628 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@0
|
2629 m_paneStack != 0 &&
|
Chris@0
|
2630 m_paneStack->getCurrentPane() != 0);
|
Chris@0
|
2631
|
Chris@82
|
2632 if (!canImportLayer || (openLayerFile(path) == FileOpenFailed)) {
|
Chris@0
|
2633
|
Chris@0
|
2634 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2635 tr("File \"%1\" could not be opened").arg(path));
|
Chris@0
|
2636 }
|
Chris@0
|
2637 }
|
Chris@0
|
2638 }
|
Chris@0
|
2639 }
|
Chris@0
|
2640
|
Chris@82
|
2641 MainWindow::FileOpenStatus
|
Chris@85
|
2642 MainWindow::openURL(QUrl url)
|
Chris@85
|
2643 {
|
Chris@85
|
2644 if (url.scheme().toLower() == "file") {
|
Chris@85
|
2645 return openSomeFile(url.toLocalFile());
|
Chris@86
|
2646 } else if (!RemoteFile::canHandleScheme(url)) {
|
Chris@85
|
2647 QMessageBox::critical(this, tr("Unsupported scheme in URL"),
|
Chris@85
|
2648 tr("The URL scheme \"%1\" is not supported")
|
Chris@85
|
2649 .arg(url.scheme()));
|
Chris@85
|
2650 return FileOpenFailed;
|
Chris@85
|
2651 } else {
|
Chris@85
|
2652 RemoteFile rf(url);
|
Chris@85
|
2653 rf.wait();
|
Chris@85
|
2654 if (!rf.isOK()) {
|
Chris@85
|
2655 QMessageBox::critical(this, tr("File download failed"),
|
Chris@85
|
2656 tr("Failed to download URL \"%1\": %2")
|
Chris@85
|
2657 .arg(url.toString()).arg(rf.getErrorString()));
|
Chris@85
|
2658 return FileOpenFailed;
|
Chris@85
|
2659 }
|
Chris@88
|
2660 FileOpenStatus status;
|
Chris@88
|
2661 if ((status = openSomeFile(rf.getLocalFilename(), url.toString())) !=
|
Chris@88
|
2662 FileOpenSucceeded) {
|
Chris@88
|
2663 rf.deleteLocalFile();
|
Chris@88
|
2664 }
|
Chris@88
|
2665 return status;
|
Chris@85
|
2666 }
|
Chris@85
|
2667 }
|
Chris@85
|
2668
|
Chris@85
|
2669 MainWindow::FileOpenStatus
|
Chris@54
|
2670 MainWindow::openSomeFile(QString path, AudioFileOpenMode mode)
|
Chris@0
|
2671 {
|
Chris@86
|
2672 return openSomeFile(path, path, mode);
|
Chris@86
|
2673 }
|
Chris@86
|
2674
|
Chris@86
|
2675 MainWindow::FileOpenStatus
|
Chris@86
|
2676 MainWindow::openSomeFile(QString path, QString location,
|
Chris@86
|
2677 AudioFileOpenMode mode)
|
Chris@86
|
2678 {
|
Chris@82
|
2679 FileOpenStatus status;
|
Chris@82
|
2680
|
Chris@85
|
2681 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@85
|
2682 m_paneStack != 0 &&
|
Chris@85
|
2683 m_paneStack->getCurrentPane() != 0);
|
Chris@85
|
2684
|
Chris@86
|
2685 if ((status = openAudioFile(path, location, mode)) != FileOpenFailed) {
|
Chris@82
|
2686 return status;
|
Chris@86
|
2687 } else if ((status = openSessionFile(path, location)) != FileOpenFailed) {
|
Chris@82
|
2688 return status;
|
Chris@85
|
2689 } else if (!canImportLayer) {
|
Chris@85
|
2690 return FileOpenFailed;
|
Chris@86
|
2691 } else if ((status = openLayerFile(path, location)) != FileOpenFailed) {
|
Chris@85
|
2692 return status;
|
Chris@0
|
2693 } else {
|
Chris@82
|
2694 return FileOpenFailed;
|
Chris@0
|
2695 }
|
Chris@0
|
2696 }
|
Chris@0
|
2697
|
Chris@82
|
2698 MainWindow::FileOpenStatus
|
Chris@0
|
2699 MainWindow::openSessionFile(QString path)
|
Chris@0
|
2700 {
|
Chris@86
|
2701 return openSessionFile(path, path);
|
Chris@86
|
2702 }
|
Chris@86
|
2703
|
Chris@86
|
2704 MainWindow::FileOpenStatus
|
Chris@86
|
2705 MainWindow::openSessionFile(QString path, QString location)
|
Chris@86
|
2706 {
|
Chris@0
|
2707 BZipFileDevice bzFile(path);
|
Chris@0
|
2708 if (!bzFile.open(QIODevice::ReadOnly)) {
|
Chris@86
|
2709 std::cerr << "Failed to open session file \"" << location.toStdString()
|
Chris@0
|
2710 << "\": " << bzFile.errorString().toStdString() << std::endl;
|
Chris@82
|
2711 return FileOpenFailed;
|
Chris@0
|
2712 }
|
Chris@0
|
2713
|
Chris@103
|
2714 if (!checkSaveModified()) return FileOpenCancelled;
|
Chris@103
|
2715
|
Chris@0
|
2716 QString error;
|
Chris@0
|
2717 closeSession();
|
Chris@0
|
2718 createDocument();
|
Chris@0
|
2719
|
Chris@0
|
2720 PaneCallback callback(this);
|
Chris@0
|
2721 m_viewManager->clearSelections();
|
Chris@0
|
2722
|
Chris@87
|
2723 SVFileReader reader(m_document, callback, location);
|
Chris@0
|
2724 QXmlInputSource inputSource(&bzFile);
|
Chris@0
|
2725 reader.parse(inputSource);
|
Chris@0
|
2726
|
Chris@0
|
2727 if (!reader.isOK()) {
|
Chris@0
|
2728 error = tr("SV XML file read error:\n%1").arg(reader.getErrorString());
|
Chris@0
|
2729 }
|
Chris@0
|
2730
|
Chris@0
|
2731 bzFile.close();
|
Chris@0
|
2732
|
Chris@0
|
2733 bool ok = (error == "");
|
Chris@86
|
2734
|
Chris@86
|
2735 bool realFile = (location == path);
|
Chris@0
|
2736
|
Chris@0
|
2737 if (ok) {
|
Chris@86
|
2738
|
Chris@0
|
2739 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@86
|
2740 .arg(QFileInfo(location).fileName()));
|
Chris@86
|
2741
|
Chris@86
|
2742 if (realFile) m_sessionFile = path;
|
Chris@86
|
2743
|
Chris@0
|
2744 setupMenus();
|
Chris@0
|
2745 CommandHistory::getInstance()->clear();
|
Chris@0
|
2746 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2747 m_documentModified = false;
|
Chris@0
|
2748 updateMenuStates();
|
Chris@86
|
2749
|
Chris@86
|
2750 m_recentFiles.addFile(location);
|
Chris@86
|
2751
|
Chris@86
|
2752 if (realFile) {
|
Chris@88
|
2753 registerLastOpenedFilePath(FileFinder::SessionFile, path); // for file dialog
|
Chris@86
|
2754 }
|
Chris@86
|
2755
|
Chris@0
|
2756 } else {
|
Chris@0
|
2757 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2758 }
|
Chris@0
|
2759
|
Chris@82
|
2760 return ok ? FileOpenSucceeded : FileOpenFailed;
|
Chris@0
|
2761 }
|
Chris@0
|
2762
|
Chris@0
|
2763 void
|
Chris@0
|
2764 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
2765 {
|
Chris@70
|
2766 if (!m_abandoning && !checkSaveModified()) {
|
Chris@0
|
2767 e->ignore();
|
Chris@0
|
2768 return;
|
Chris@0
|
2769 }
|
Chris@0
|
2770
|
Chris@5
|
2771 QSettings settings;
|
Chris@5
|
2772 settings.beginGroup("MainWindow");
|
Chris@5
|
2773 settings.setValue("size", size());
|
Chris@5
|
2774 settings.setValue("position", pos());
|
Chris@5
|
2775 settings.endGroup();
|
Chris@5
|
2776
|
Chris@0
|
2777 e->accept();
|
Chris@0
|
2778 return;
|
Chris@0
|
2779 }
|
Chris@0
|
2780
|
Chris@0
|
2781 bool
|
Chris@11
|
2782 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
2783 {
|
Chris@11
|
2784 if (mayAskUser) {
|
Chris@11
|
2785 return checkSaveModified();
|
Chris@11
|
2786 } else {
|
Chris@11
|
2787 if (!m_documentModified) return true;
|
Chris@11
|
2788
|
Chris@11
|
2789 // If we can't check with the user first, then we can't save
|
Chris@11
|
2790 // to the original session file (even if we have it) -- have
|
Chris@11
|
2791 // to use a temporary file
|
Chris@11
|
2792
|
Chris@11
|
2793 QString svDirBase = ".sv1";
|
Chris@11
|
2794 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
2795
|
Chris@11
|
2796 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
2797 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
2798 } else {
|
Chris@11
|
2799 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
2800 }
|
Chris@11
|
2801
|
Chris@11
|
2802 // This name doesn't have to be unguessable
|
Chris@93
|
2803 #ifndef _WIN32
|
Chris@11
|
2804 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
2805 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
2806 .arg(QProcess().pid());
|
Chris@93
|
2807 #else
|
Chris@93
|
2808 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
2809 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
2810 #endif
|
Chris@11
|
2811 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
2812 if (saveSessionFile(fpath)) {
|
Chris@34
|
2813 m_recentFiles.addFile(fpath);
|
Chris@11
|
2814 return true;
|
Chris@11
|
2815 } else {
|
Chris@11
|
2816 return false;
|
Chris@11
|
2817 }
|
Chris@11
|
2818 }
|
Chris@11
|
2819 }
|
Chris@11
|
2820
|
Chris@11
|
2821 bool
|
Chris@0
|
2822 MainWindow::checkSaveModified()
|
Chris@0
|
2823 {
|
Chris@0
|
2824 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
2825 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
2826 // cancel.
|
Chris@0
|
2827
|
Chris@0
|
2828 if (!m_documentModified) return true;
|
Chris@0
|
2829
|
Chris@0
|
2830 int button =
|
Chris@0
|
2831 QMessageBox::warning(this,
|
Chris@0
|
2832 tr("Session modified"),
|
Chris@0
|
2833 tr("The current session has been modified.\nDo you want to save it?"),
|
Chris@0
|
2834 QMessageBox::Yes,
|
Chris@0
|
2835 QMessageBox::No,
|
Chris@0
|
2836 QMessageBox::Cancel);
|
Chris@0
|
2837
|
Chris@0
|
2838 if (button == QMessageBox::Yes) {
|
Chris@0
|
2839 saveSession();
|
Chris@0
|
2840 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@0
|
2841 return false;
|
Chris@0
|
2842 } else {
|
Chris@0
|
2843 return true; // saved, so it's safe to continue now
|
Chris@0
|
2844 }
|
Chris@0
|
2845 } else if (button == QMessageBox::No) {
|
Chris@0
|
2846 m_documentModified = false; // so we know to abandon it
|
Chris@0
|
2847 return true;
|
Chris@0
|
2848 }
|
Chris@0
|
2849
|
Chris@0
|
2850 // else cancel
|
Chris@0
|
2851 return false;
|
Chris@0
|
2852 }
|
Chris@0
|
2853
|
Chris@0
|
2854 void
|
Chris@0
|
2855 MainWindow::saveSession()
|
Chris@0
|
2856 {
|
Chris@0
|
2857 if (m_sessionFile != "") {
|
Chris@0
|
2858 if (!saveSessionFile(m_sessionFile)) {
|
Chris@0
|
2859 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@0
|
2860 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
2861 } else {
|
Chris@0
|
2862 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2863 documentRestored();
|
Chris@0
|
2864 }
|
Chris@0
|
2865 } else {
|
Chris@0
|
2866 saveSessionAs();
|
Chris@0
|
2867 }
|
Chris@0
|
2868 }
|
Chris@0
|
2869
|
Chris@0
|
2870 void
|
Chris@0
|
2871 MainWindow::saveSessionAs()
|
Chris@0
|
2872 {
|
Chris@0
|
2873 QString orig = m_audioFile;
|
Chris@0
|
2874 if (orig == "") orig = ".";
|
Chris@0
|
2875 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2876
|
Chris@88
|
2877 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
2878
|
Chris@81
|
2879 if (path == "") return;
|
Chris@0
|
2880
|
Chris@0
|
2881 if (!saveSessionFile(path)) {
|
Chris@0
|
2882 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@79
|
2883 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
2884 } else {
|
Chris@0
|
2885 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@0
|
2886 .arg(QFileInfo(path).fileName()));
|
Chris@0
|
2887 m_sessionFile = path;
|
Chris@0
|
2888 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2889 documentRestored();
|
Chris@34
|
2890 m_recentFiles.addFile(path);
|
Chris@0
|
2891 }
|
Chris@0
|
2892 }
|
Chris@0
|
2893
|
Chris@0
|
2894 bool
|
Chris@0
|
2895 MainWindow::saveSessionFile(QString path)
|
Chris@0
|
2896 {
|
Chris@0
|
2897 BZipFileDevice bzFile(path);
|
Chris@0
|
2898 if (!bzFile.open(QIODevice::WriteOnly)) {
|
Chris@0
|
2899 std::cerr << "Failed to open session file \"" << path.toStdString()
|
Chris@0
|
2900 << "\" for writing: "
|
Chris@0
|
2901 << bzFile.errorString().toStdString() << std::endl;
|
Chris@0
|
2902 return false;
|
Chris@0
|
2903 }
|
Chris@0
|
2904
|
Chris@0
|
2905 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
Chris@0
|
2906
|
Chris@0
|
2907 QTextStream out(&bzFile);
|
Chris@0
|
2908 toXml(out);
|
Chris@0
|
2909 out.flush();
|
Chris@0
|
2910
|
Chris@0
|
2911 QApplication::restoreOverrideCursor();
|
Chris@0
|
2912
|
Chris@84
|
2913 if (!bzFile.isOK()) {
|
Chris@0
|
2914 QMessageBox::critical(this, tr("Failed to write file"),
|
Chris@0
|
2915 tr("Failed to write to file \"%1\": %2")
|
Chris@0
|
2916 .arg(path).arg(bzFile.errorString()));
|
Chris@0
|
2917 bzFile.close();
|
Chris@0
|
2918 return false;
|
Chris@0
|
2919 }
|
Chris@0
|
2920
|
Chris@0
|
2921 bzFile.close();
|
Chris@0
|
2922 return true;
|
Chris@0
|
2923 }
|
Chris@0
|
2924
|
Chris@0
|
2925 void
|
Chris@0
|
2926 MainWindow::toXml(QTextStream &out)
|
Chris@0
|
2927 {
|
Chris@0
|
2928 QString indent(" ");
|
Chris@0
|
2929
|
Chris@0
|
2930 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
Chris@0
|
2931 out << "<!DOCTYPE sonic-visualiser>\n";
|
Chris@0
|
2932 out << "<sv>\n";
|
Chris@0
|
2933
|
Chris@0
|
2934 m_document->toXml(out, "", "");
|
Chris@0
|
2935
|
Chris@0
|
2936 out << "<display>\n";
|
Chris@0
|
2937
|
Chris@0
|
2938 out << QString(" <window width=\"%1\" height=\"%2\"/>\n")
|
Chris@0
|
2939 .arg(width()).arg(height());
|
Chris@0
|
2940
|
Chris@0
|
2941 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
2942
|
Chris@0
|
2943 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
2944
|
Chris@0
|
2945 if (pane) {
|
Chris@0
|
2946 pane->toXml(out, indent);
|
Chris@0
|
2947 }
|
Chris@0
|
2948 }
|
Chris@0
|
2949
|
Chris@0
|
2950 out << "</display>\n";
|
Chris@0
|
2951
|
Chris@0
|
2952 m_viewManager->getSelection().toXml(out);
|
Chris@0
|
2953
|
Chris@0
|
2954 out << "</sv>\n";
|
Chris@0
|
2955 }
|
Chris@0
|
2956
|
Chris@0
|
2957 Pane *
|
Chris@0
|
2958 MainWindow::addPaneToStack()
|
Chris@0
|
2959 {
|
Chris@0
|
2960 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2961 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2962 return command->getPane();
|
Chris@0
|
2963 }
|
Chris@0
|
2964
|
Chris@0
|
2965 void
|
Chris@0
|
2966 MainWindow::zoomIn()
|
Chris@0
|
2967 {
|
Chris@0
|
2968 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2969 if (currentPane) currentPane->zoom(true);
|
Chris@0
|
2970 }
|
Chris@0
|
2971
|
Chris@0
|
2972 void
|
Chris@0
|
2973 MainWindow::zoomOut()
|
Chris@0
|
2974 {
|
Chris@0
|
2975 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2976 if (currentPane) currentPane->zoom(false);
|
Chris@0
|
2977 }
|
Chris@0
|
2978
|
Chris@0
|
2979 void
|
Chris@0
|
2980 MainWindow::zoomToFit()
|
Chris@0
|
2981 {
|
Chris@0
|
2982 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2983 if (!currentPane) return;
|
Chris@0
|
2984
|
Chris@0
|
2985 Model *model = getMainModel();
|
Chris@0
|
2986 if (!model) return;
|
Chris@0
|
2987
|
Chris@0
|
2988 size_t start = model->getStartFrame();
|
Chris@0
|
2989 size_t end = model->getEndFrame();
|
Chris@0
|
2990 size_t pixels = currentPane->width();
|
Chris@0
|
2991 size_t zoomLevel = (end - start) / pixels;
|
Chris@0
|
2992
|
Chris@0
|
2993 currentPane->setZoomLevel(zoomLevel);
|
Chris@0
|
2994 currentPane->setStartFrame(start);
|
Chris@0
|
2995 }
|
Chris@0
|
2996
|
Chris@0
|
2997 void
|
Chris@0
|
2998 MainWindow::zoomDefault()
|
Chris@0
|
2999 {
|
Chris@0
|
3000 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3001 if (currentPane) currentPane->setZoomLevel(1024);
|
Chris@0
|
3002 }
|
Chris@0
|
3003
|
Chris@0
|
3004 void
|
Chris@0
|
3005 MainWindow::scrollLeft()
|
Chris@0
|
3006 {
|
Chris@0
|
3007 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3008 if (currentPane) currentPane->scroll(false, false);
|
Chris@0
|
3009 }
|
Chris@0
|
3010
|
Chris@0
|
3011 void
|
Chris@0
|
3012 MainWindow::jumpLeft()
|
Chris@0
|
3013 {
|
Chris@0
|
3014 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3015 if (currentPane) currentPane->scroll(false, true);
|
Chris@0
|
3016 }
|
Chris@0
|
3017
|
Chris@0
|
3018 void
|
Chris@0
|
3019 MainWindow::scrollRight()
|
Chris@0
|
3020 {
|
Chris@0
|
3021 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3022 if (currentPane) currentPane->scroll(true, false);
|
Chris@0
|
3023 }
|
Chris@0
|
3024
|
Chris@0
|
3025 void
|
Chris@0
|
3026 MainWindow::jumpRight()
|
Chris@0
|
3027 {
|
Chris@0
|
3028 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3029 if (currentPane) currentPane->scroll(true, true);
|
Chris@0
|
3030 }
|
Chris@0
|
3031
|
Chris@0
|
3032 void
|
Chris@0
|
3033 MainWindow::showNoOverlays()
|
Chris@0
|
3034 {
|
Chris@0
|
3035 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
|
Chris@0
|
3036 }
|
Chris@0
|
3037
|
Chris@0
|
3038 void
|
Chris@90
|
3039 MainWindow::showMinimalOverlays()
|
Chris@0
|
3040 {
|
Chris@90
|
3041 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@0
|
3042 }
|
Chris@0
|
3043
|
Chris@0
|
3044 void
|
Chris@90
|
3045 MainWindow::showStandardOverlays()
|
Chris@90
|
3046 {
|
Chris@90
|
3047 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
|
Chris@90
|
3048 }
|
Chris@90
|
3049
|
Chris@90
|
3050 void
|
Chris@90
|
3051 MainWindow::showAllOverlays()
|
Chris@0
|
3052 {
|
Chris@0
|
3053 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
|
Chris@0
|
3054 }
|
Chris@0
|
3055
|
Chris@0
|
3056 void
|
Chris@7
|
3057 MainWindow::toggleZoomWheels()
|
Chris@7
|
3058 {
|
Chris@7
|
3059 if (m_viewManager->getZoomWheelsEnabled()) {
|
Chris@7
|
3060 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@7
|
3061 } else {
|
Chris@7
|
3062 m_viewManager->setZoomWheelsEnabled(true);
|
Chris@7
|
3063 }
|
Chris@7
|
3064 }
|
Chris@7
|
3065
|
Chris@7
|
3066 void
|
Chris@72
|
3067 MainWindow::togglePropertyBoxes()
|
Chris@72
|
3068 {
|
Chris@72
|
3069 if (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks) {
|
Chris@72
|
3070 if (Preferences::getInstance()->getPropertyBoxLayout() ==
|
Chris@72
|
3071 Preferences::VerticallyStacked) {
|
Chris@72
|
3072 m_paneStack->setLayoutStyle(PaneStack::PropertyStackPerPaneLayout);
|
Chris@72
|
3073 } else {
|
Chris@72
|
3074 m_paneStack->setLayoutStyle(PaneStack::SinglePropertyStackLayout);
|
Chris@72
|
3075 }
|
Chris@72
|
3076 } else {
|
Chris@72
|
3077 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@72
|
3078 }
|
Chris@72
|
3079 }
|
Chris@72
|
3080
|
Chris@72
|
3081 void
|
Chris@90
|
3082 MainWindow::toggleStatusBar()
|
Chris@90
|
3083 {
|
Chris@90
|
3084 QSettings settings;
|
Chris@90
|
3085 settings.beginGroup("MainWindow");
|
Chris@90
|
3086 bool sb = settings.value("showstatusbar", true).toBool();
|
Chris@90
|
3087
|
Chris@90
|
3088 if (sb) {
|
Chris@90
|
3089 statusBar()->hide();
|
Chris@90
|
3090 } else {
|
Chris@90
|
3091 statusBar()->show();
|
Chris@90
|
3092 }
|
Chris@90
|
3093
|
Chris@90
|
3094 settings.setValue("showstatusbar", !sb);
|
Chris@90
|
3095
|
Chris@90
|
3096 settings.endGroup();
|
Chris@90
|
3097 }
|
Chris@90
|
3098
|
Chris@90
|
3099 void
|
Chris@72
|
3100 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
3101 {
|
Chris@72
|
3102 if (name == "Property Box Layout") {
|
Chris@72
|
3103 if (m_paneStack->getLayoutStyle() != PaneStack::NoPropertyStacks) {
|
Chris@72
|
3104 if (Preferences::getInstance()->getPropertyBoxLayout() ==
|
Chris@72
|
3105 Preferences::VerticallyStacked) {
|
Chris@72
|
3106 m_paneStack->setLayoutStyle(PaneStack::PropertyStackPerPaneLayout);
|
Chris@72
|
3107 } else {
|
Chris@72
|
3108 m_paneStack->setLayoutStyle(PaneStack::SinglePropertyStackLayout);
|
Chris@72
|
3109 }
|
Chris@72
|
3110 }
|
Chris@72
|
3111 }
|
Chris@72
|
3112 }
|
Chris@72
|
3113
|
Chris@72
|
3114 void
|
Chris@0
|
3115 MainWindow::play()
|
Chris@0
|
3116 {
|
Chris@0
|
3117 if (m_playSource->isPlaying()) {
|
Chris@0
|
3118 m_playSource->stop();
|
Chris@0
|
3119 } else {
|
Chris@0
|
3120 m_playSource->play(m_viewManager->getPlaybackFrame());
|
Chris@0
|
3121 }
|
Chris@0
|
3122 }
|
Chris@0
|
3123
|
Chris@0
|
3124 void
|
Chris@0
|
3125 MainWindow::ffwd()
|
Chris@0
|
3126 {
|
Chris@0
|
3127 if (!getMainModel()) return;
|
Chris@0
|
3128
|
Chris@0
|
3129 int frame = m_viewManager->getPlaybackFrame();
|
Chris@0
|
3130 ++frame;
|
Chris@0
|
3131
|
Chris@0
|
3132 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3133 if (!pane) return;
|
Chris@0
|
3134
|
Chris@0
|
3135 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3136
|
Chris@0
|
3137 if (!dynamic_cast<TimeInstantLayer *>(layer) &&
|
Chris@0
|
3138 !dynamic_cast<TimeValueLayer *>(layer)) return;
|
Chris@0
|
3139
|
Chris@0
|
3140 size_t resolution = 0;
|
Chris@0
|
3141 if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapRight)) {
|
Chris@0
|
3142 frame = getMainModel()->getEndFrame();
|
Chris@0
|
3143 }
|
Chris@0
|
3144
|
Chris@0
|
3145 m_viewManager->setPlaybackFrame(frame);
|
Chris@0
|
3146 }
|
Chris@0
|
3147
|
Chris@0
|
3148 void
|
Chris@0
|
3149 MainWindow::ffwdEnd()
|
Chris@0
|
3150 {
|
Chris@0
|
3151 if (!getMainModel()) return;
|
Chris@0
|
3152 m_viewManager->setPlaybackFrame(getMainModel()->getEndFrame());
|
Chris@0
|
3153 }
|
Chris@0
|
3154
|
Chris@0
|
3155 void
|
Chris@0
|
3156 MainWindow::rewind()
|
Chris@0
|
3157 {
|
Chris@0
|
3158 if (!getMainModel()) return;
|
Chris@0
|
3159
|
Chris@0
|
3160 int frame = m_viewManager->getPlaybackFrame();
|
Chris@0
|
3161 if (frame > 0) --frame;
|
Chris@0
|
3162
|
Chris@0
|
3163 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3164 if (!pane) return;
|
Chris@0
|
3165
|
Chris@0
|
3166 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3167
|
Chris@0
|
3168 if (!dynamic_cast<TimeInstantLayer *>(layer) &&
|
Chris@0
|
3169 !dynamic_cast<TimeValueLayer *>(layer)) return;
|
Chris@0
|
3170
|
Chris@0
|
3171 size_t resolution = 0;
|
Chris@0
|
3172 if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapLeft)) {
|
Chris@0
|
3173 frame = getMainModel()->getEndFrame();
|
Chris@0
|
3174 }
|
Chris@0
|
3175
|
Chris@0
|
3176 m_viewManager->setPlaybackFrame(frame);
|
Chris@0
|
3177 }
|
Chris@0
|
3178
|
Chris@0
|
3179 void
|
Chris@0
|
3180 MainWindow::rewindStart()
|
Chris@0
|
3181 {
|
Chris@0
|
3182 if (!getMainModel()) return;
|
Chris@0
|
3183 m_viewManager->setPlaybackFrame(getMainModel()->getStartFrame());
|
Chris@0
|
3184 }
|
Chris@0
|
3185
|
Chris@0
|
3186 void
|
Chris@0
|
3187 MainWindow::stop()
|
Chris@0
|
3188 {
|
Chris@0
|
3189 m_playSource->stop();
|
Chris@0
|
3190 }
|
Chris@0
|
3191
|
Chris@0
|
3192 void
|
Chris@0
|
3193 MainWindow::addPane()
|
Chris@0
|
3194 {
|
Chris@0
|
3195 QObject *s = sender();
|
Chris@0
|
3196 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3197
|
Chris@0
|
3198 if (!action) {
|
Chris@0
|
3199 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@0
|
3200 << std::endl;
|
Chris@0
|
3201 return;
|
Chris@0
|
3202 }
|
Chris@0
|
3203
|
Chris@0
|
3204 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
3205
|
Chris@0
|
3206 if (i == m_paneActions.end()) {
|
Chris@0
|
3207 std::cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@0
|
3208 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3209 return;
|
Chris@0
|
3210 }
|
Chris@0
|
3211
|
Chris@69
|
3212 addPane(i->second, action->text());
|
Chris@69
|
3213 }
|
Chris@69
|
3214
|
Chris@69
|
3215 void
|
Chris@69
|
3216 MainWindow::addPane(const PaneConfiguration &configuration, QString text)
|
Chris@69
|
3217 {
|
Chris@69
|
3218 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
3219
|
Chris@0
|
3220 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
3221 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3222
|
Chris@0
|
3223 Pane *pane = command->getPane();
|
Chris@0
|
3224
|
Chris@69
|
3225 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
3226 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
3227 pane->setFollowGlobalZoom(false);
|
Chris@110
|
3228 pane->setZoomLevel(1);
|
Chris@7
|
3229 }
|
Chris@7
|
3230
|
Chris@69
|
3231 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
3232 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
3233
|
Chris@0
|
3234 if (!m_timeRulerLayer) {
|
Chris@0
|
3235 // std::cerr << "no time ruler layer, creating one" << std::endl;
|
Chris@0
|
3236 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
3237 (LayerFactory::TimeRuler);
|
Chris@0
|
3238 }
|
Chris@0
|
3239
|
Chris@0
|
3240 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
|
Chris@0
|
3241
|
Chris@0
|
3242 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3243 }
|
Chris@0
|
3244
|
Chris@69
|
3245 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
3246
|
Chris@69
|
3247 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
3248 Model *model = 0;
|
Chris@66
|
3249
|
Chris@66
|
3250 if (suggestedModel) {
|
Chris@66
|
3251
|
Chris@66
|
3252 // check its validity
|
Chris@66
|
3253 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
3254 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
3255 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
3256 model = suggestedModel;
|
Chris@66
|
3257 break;
|
Chris@66
|
3258 }
|
Chris@66
|
3259 }
|
Chris@66
|
3260
|
Chris@66
|
3261 if (!model) {
|
Chris@66
|
3262 std::cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
3263 << " appears in pane action map, but is not reported "
|
Chris@66
|
3264 << "by document as a valid transform source" << std::endl;
|
Chris@66
|
3265 }
|
Chris@66
|
3266 }
|
Chris@66
|
3267
|
Chris@66
|
3268 if (!model) model = m_document->getMainModel();
|
Chris@66
|
3269
|
Chris@66
|
3270 m_document->setModel(newLayer, model);
|
Chris@66
|
3271
|
Chris@69
|
3272 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
3273 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3274
|
Chris@0
|
3275 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
3276 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3277
|
Chris@73
|
3278 std::cerr << "MainWindow::addPane: global centre frame is "
|
Chris@73
|
3279 << m_viewManager->getGlobalCentreFrame() << std::endl;
|
Chris@73
|
3280 pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
3281
|
Chris@0
|
3282 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3283
|
Chris@0
|
3284 updateMenuStates();
|
Chris@0
|
3285 }
|
Chris@0
|
3286
|
Chris@0
|
3287 MainWindow::AddPaneCommand::AddPaneCommand(MainWindow *mw) :
|
Chris@0
|
3288 m_mw(mw),
|
Chris@0
|
3289 m_pane(0),
|
Chris@0
|
3290 m_prevCurrentPane(0),
|
Chris@0
|
3291 m_added(false)
|
Chris@0
|
3292 {
|
Chris@0
|
3293 }
|
Chris@0
|
3294
|
Chris@0
|
3295 MainWindow::AddPaneCommand::~AddPaneCommand()
|
Chris@0
|
3296 {
|
Chris@0
|
3297 if (m_pane && !m_added) {
|
Chris@0
|
3298 m_mw->m_paneStack->deletePane(m_pane);
|
Chris@0
|
3299 }
|
Chris@0
|
3300 }
|
Chris@0
|
3301
|
Chris@0
|
3302 QString
|
Chris@0
|
3303 MainWindow::AddPaneCommand::getName() const
|
Chris@0
|
3304 {
|
Chris@0
|
3305 return tr("Add Pane");
|
Chris@0
|
3306 }
|
Chris@0
|
3307
|
Chris@0
|
3308 void
|
Chris@0
|
3309 MainWindow::AddPaneCommand::execute()
|
Chris@0
|
3310 {
|
Chris@0
|
3311 if (!m_pane) {
|
Chris@0
|
3312 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane();
|
Chris@0
|
3313 m_pane = m_mw->m_paneStack->addPane();
|
Chris@90
|
3314
|
Chris@90
|
3315 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
3316 m_mw->statusBar(), SLOT(showMessage(const QString &)));
|
Chris@0
|
3317 } else {
|
Chris@0
|
3318 m_mw->m_paneStack->showPane(m_pane);
|
Chris@0
|
3319 }
|
Chris@0
|
3320
|
Chris@0
|
3321 m_mw->m_paneStack->setCurrentPane(m_pane);
|
Chris@65
|
3322 m_mw->m_overview->registerView(m_pane);
|
Chris@0
|
3323 m_added = true;
|
Chris@0
|
3324 }
|
Chris@0
|
3325
|
Chris@0
|
3326 void
|
Chris@0
|
3327 MainWindow::AddPaneCommand::unexecute()
|
Chris@0
|
3328 {
|
Chris@0
|
3329 m_mw->m_paneStack->hidePane(m_pane);
|
Chris@0
|
3330 m_mw->m_paneStack->setCurrentPane(m_prevCurrentPane);
|
Chris@65
|
3331 m_mw->m_overview->unregisterView(m_pane);
|
Chris@0
|
3332 m_added = false;
|
Chris@0
|
3333 }
|
Chris@0
|
3334
|
Chris@0
|
3335 MainWindow::RemovePaneCommand::RemovePaneCommand(MainWindow *mw, Pane *pane) :
|
Chris@0
|
3336 m_mw(mw),
|
Chris@0
|
3337 m_pane(pane),
|
Chris@0
|
3338 m_added(true)
|
Chris@0
|
3339 {
|
Chris@0
|
3340 }
|
Chris@0
|
3341
|
Chris@0
|
3342 MainWindow::RemovePaneCommand::~RemovePaneCommand()
|
Chris@0
|
3343 {
|
Chris@0
|
3344 if (m_pane && !m_added) {
|
Chris@0
|
3345 m_mw->m_paneStack->deletePane(m_pane);
|
Chris@0
|
3346 }
|
Chris@0
|
3347 }
|
Chris@0
|
3348
|
Chris@0
|
3349 QString
|
Chris@0
|
3350 MainWindow::RemovePaneCommand::getName() const
|
Chris@0
|
3351 {
|
Chris@0
|
3352 return tr("Remove Pane");
|
Chris@0
|
3353 }
|
Chris@0
|
3354
|
Chris@0
|
3355 void
|
Chris@0
|
3356 MainWindow::RemovePaneCommand::execute()
|
Chris@0
|
3357 {
|
Chris@0
|
3358 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane();
|
Chris@0
|
3359 m_mw->m_paneStack->hidePane(m_pane);
|
Chris@65
|
3360 m_mw->m_overview->unregisterView(m_pane);
|
Chris@0
|
3361 m_added = false;
|
Chris@0
|
3362 }
|
Chris@0
|
3363
|
Chris@0
|
3364 void
|
Chris@0
|
3365 MainWindow::RemovePaneCommand::unexecute()
|
Chris@0
|
3366 {
|
Chris@0
|
3367 m_mw->m_paneStack->showPane(m_pane);
|
Chris@0
|
3368 m_mw->m_paneStack->setCurrentPane(m_prevCurrentPane);
|
Chris@65
|
3369 m_mw->m_overview->registerView(m_pane);
|
Chris@0
|
3370 m_added = true;
|
Chris@0
|
3371 }
|
Chris@0
|
3372
|
Chris@0
|
3373 void
|
Chris@0
|
3374 MainWindow::addLayer()
|
Chris@0
|
3375 {
|
Chris@0
|
3376 QObject *s = sender();
|
Chris@0
|
3377 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3378
|
Chris@0
|
3379 if (!action) {
|
Chris@0
|
3380 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@0
|
3381 << std::endl;
|
Chris@0
|
3382 return;
|
Chris@0
|
3383 }
|
Chris@0
|
3384
|
Chris@0
|
3385 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3386
|
Chris@0
|
3387 if (!pane) {
|
Chris@0
|
3388 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@0
|
3389 return;
|
Chris@0
|
3390 }
|
Chris@0
|
3391
|
Chris@0
|
3392 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
3393
|
Chris@0
|
3394 if (ei != m_existingLayerActions.end()) {
|
Chris@0
|
3395 Layer *newLayer = ei->second;
|
Chris@0
|
3396 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3397 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3398 return;
|
Chris@0
|
3399 }
|
Chris@0
|
3400
|
Chris@95
|
3401 ei = m_sliceActions.find(action);
|
Chris@95
|
3402
|
Chris@95
|
3403 if (ei != m_sliceActions.end()) {
|
Chris@95
|
3404 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
3405 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
3406 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
3407 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
3408 if (source && dest) {
|
Chris@95
|
3409 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
3410 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
3411 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
3412 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
3413 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
3414 }
|
Chris@95
|
3415 m_document->addLayerToView(pane, newLayer);
|
Chris@95
|
3416 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@95
|
3417 return;
|
Chris@95
|
3418 }
|
Chris@95
|
3419
|
Chris@34
|
3420 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
3421
|
Chris@34
|
3422 if (i == m_transformActions.end()) {
|
Chris@0
|
3423
|
Chris@0
|
3424 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@0
|
3425
|
Chris@0
|
3426 if (i == m_layerActions.end()) {
|
Chris@0
|
3427 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@0
|
3428 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3429 return;
|
Chris@0
|
3430 }
|
Chris@0
|
3431
|
Chris@0
|
3432 LayerFactory::LayerType type = i->second;
|
Chris@0
|
3433
|
Chris@0
|
3434 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@0
|
3435 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@0
|
3436
|
Chris@0
|
3437 Layer *newLayer;
|
Chris@0
|
3438
|
Chris@0
|
3439 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@0
|
3440
|
Chris@0
|
3441 newLayer = m_document->createEmptyLayer(type);
|
Chris@0
|
3442 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@0
|
3443
|
Chris@0
|
3444 } else {
|
Chris@0
|
3445
|
Chris@0
|
3446 newLayer = m_document->createMainModelLayer(type);
|
Chris@0
|
3447 }
|
Chris@0
|
3448
|
Chris@0
|
3449 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3450 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3451
|
Chris@0
|
3452 return;
|
Chris@0
|
3453 }
|
Chris@0
|
3454
|
Chris@107
|
3455 TransformId transform = i->second;
|
Chris@0
|
3456 TransformFactory *factory = TransformFactory::getInstance();
|
Chris@0
|
3457
|
Chris@0
|
3458 QString configurationXml;
|
Chris@0
|
3459
|
Chris@0
|
3460 int channel = -1;
|
Chris@0
|
3461 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
3462 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3463 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@0
|
3464 if (c != -1) {
|
Chris@0
|
3465 channel = c;
|
Chris@0
|
3466 break;
|
Chris@0
|
3467 }
|
Chris@0
|
3468 }
|
Chris@0
|
3469
|
Chris@33
|
3470 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
3471 // supposed to be configurable, because we need to let the user
|
Chris@33
|
3472 // change the execution context (block size etc).
|
Chris@0
|
3473
|
Chris@27
|
3474 PluginTransform::ExecutionContext context(channel);
|
Chris@27
|
3475
|
Chris@66
|
3476 std::vector<Model *> candidateInputModels =
|
Chris@66
|
3477 m_document->getTransformInputModels();
|
Chris@53
|
3478
|
Chris@54
|
3479 Model *inputModel = factory->getConfigurationForTransform(transform,
|
Chris@54
|
3480 candidateInputModels,
|
Chris@54
|
3481 context,
|
Chris@54
|
3482 configurationXml,
|
Chris@54
|
3483 m_playSource);
|
Chris@54
|
3484 if (!inputModel) return;
|
Chris@54
|
3485
|
Chris@54
|
3486 std::cerr << "Input model is " << inputModel << " \"" << inputModel->objectName().toStdString() << std::endl;
|
Chris@0
|
3487
|
Chris@0
|
3488 Layer *newLayer = m_document->createDerivedLayer(transform,
|
Chris@54
|
3489 inputModel,
|
Chris@27
|
3490 context,
|
Chris@0
|
3491 configurationXml);
|
Chris@0
|
3492
|
Chris@0
|
3493 if (newLayer) {
|
Chris@0
|
3494 m_document->addLayerToView(pane, newLayer);
|
Chris@27
|
3495 m_document->setChannel(newLayer, context.channel);
|
Chris@34
|
3496 m_recentTransforms.add(transform);
|
Chris@70
|
3497 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3498 }
|
Chris@0
|
3499
|
Chris@0
|
3500 updateMenuStates();
|
Chris@0
|
3501 }
|
Chris@0
|
3502
|
Chris@0
|
3503 void
|
Chris@0
|
3504 MainWindow::deleteCurrentPane()
|
Chris@0
|
3505 {
|
Chris@0
|
3506 CommandHistory::getInstance()->startCompoundOperation
|
Chris@0
|
3507 (tr("Delete Pane"), true);
|
Chris@0
|
3508
|
Chris@0
|
3509 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3510 if (pane) {
|
Chris@0
|
3511 while (pane->getLayerCount() > 0) {
|
Chris@0
|
3512 Layer *layer = pane->getLayer(0);
|
Chris@0
|
3513 if (layer) {
|
Chris@0
|
3514 m_document->removeLayerFromView(pane, layer);
|
Chris@0
|
3515 } else {
|
Chris@0
|
3516 break;
|
Chris@0
|
3517 }
|
Chris@0
|
3518 }
|
Chris@0
|
3519
|
Chris@0
|
3520 RemovePaneCommand *command = new RemovePaneCommand(this, pane);
|
Chris@0
|
3521 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3522 }
|
Chris@0
|
3523
|
Chris@0
|
3524 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3525
|
Chris@0
|
3526 updateMenuStates();
|
Chris@0
|
3527 }
|
Chris@0
|
3528
|
Chris@0
|
3529 void
|
Chris@0
|
3530 MainWindow::deleteCurrentLayer()
|
Chris@0
|
3531 {
|
Chris@0
|
3532 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3533 if (pane) {
|
Chris@0
|
3534 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3535 if (layer) {
|
Chris@0
|
3536 m_document->removeLayerFromView(pane, layer);
|
Chris@0
|
3537 }
|
Chris@0
|
3538 }
|
Chris@0
|
3539 updateMenuStates();
|
Chris@0
|
3540 }
|
Chris@0
|
3541
|
Chris@0
|
3542 void
|
Chris@0
|
3543 MainWindow::renameCurrentLayer()
|
Chris@0
|
3544 {
|
Chris@0
|
3545 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3546 if (pane) {
|
Chris@0
|
3547 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3548 if (layer) {
|
Chris@0
|
3549 bool ok = false;
|
Chris@0
|
3550 QString newName = QInputDialog::getText
|
Chris@0
|
3551 (this, tr("Rename Layer"),
|
Chris@0
|
3552 tr("New name for this layer:"),
|
Chris@0
|
3553 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@0
|
3554 if (ok) {
|
Chris@0
|
3555 layer->setObjectName(newName);
|
Chris@95
|
3556 setupExistingLayersMenus();
|
Chris@0
|
3557 }
|
Chris@0
|
3558 }
|
Chris@0
|
3559 }
|
Chris@0
|
3560 }
|
Chris@0
|
3561
|
Chris@0
|
3562 void
|
Chris@59
|
3563 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
3564 {
|
Chris@59
|
3565 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@60
|
3566
|
Chris@60
|
3567 float percent = m_playSpeed->mappedValue();
|
Chris@60
|
3568
|
Chris@60
|
3569 float factor = mapper.getFactorForValue(percent);
|
Chris@60
|
3570
|
Chris@60
|
3571 // float factor = mapper.getFactorForPosition(position);
|
Chris@60
|
3572 // float percent = mapper.getValueForPosition(position);
|
Chris@60
|
3573
|
Chris@60
|
3574 std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
|
Chris@60
|
3575
|
Chris@60
|
3576 //!!! bool slow = (position < 100);
|
Chris@59
|
3577 bool something = (position != 100);
|
Chris@60
|
3578 /*!!!
|
Chris@59
|
3579 int pc = lrintf(percent);
|
Chris@21
|
3580
|
Chris@21
|
3581 m_playSpeed->setToolTip(tr("Playback speed: %1%2%")
|
Chris@60
|
3582 .arg(!slow ? "+" : "")
|
Chris@21
|
3583 .arg(pc));
|
Chris@60
|
3584 */
|
Chris@25
|
3585 m_playSharpen->setEnabled(something);
|
Chris@26
|
3586 m_playMono->setEnabled(something);
|
Chris@25
|
3587 bool sharpen = (something && m_playSharpen->isChecked());
|
Chris@26
|
3588 bool mono = (something && m_playMono->isChecked());
|
Chris@26
|
3589 m_playSource->setTimeStretch(factor, sharpen, mono);
|
Chris@16
|
3590 }
|
Chris@16
|
3591
|
Chris@16
|
3592 void
|
Chris@16
|
3593 MainWindow::playSharpenToggled()
|
Chris@16
|
3594 {
|
Chris@21
|
3595 QSettings settings;
|
Chris@21
|
3596 settings.beginGroup("MainWindow");
|
Chris@21
|
3597 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@21
|
3598 settings.endGroup();
|
Chris@21
|
3599
|
Chris@16
|
3600 playSpeedChanged(m_playSpeed->value());
|
Chris@0
|
3601 }
|
Chris@0
|
3602
|
Chris@0
|
3603 void
|
Chris@26
|
3604 MainWindow::playMonoToggled()
|
Chris@26
|
3605 {
|
Chris@26
|
3606 QSettings settings;
|
Chris@26
|
3607 settings.beginGroup("MainWindow");
|
Chris@26
|
3608 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@26
|
3609 settings.endGroup();
|
Chris@26
|
3610
|
Chris@26
|
3611 playSpeedChanged(m_playSpeed->value());
|
Chris@26
|
3612 }
|
Chris@26
|
3613
|
Chris@26
|
3614 void
|
Chris@0
|
3615 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
3616 {
|
Chris@0
|
3617 m_fader->setPeakLeft(left);
|
Chris@0
|
3618 m_fader->setPeakRight(right);
|
Chris@0
|
3619 }
|
Chris@0
|
3620
|
Chris@0
|
3621 void
|
Chris@0
|
3622 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
3623 bool willResample)
|
Chris@0
|
3624 {
|
Chris@0
|
3625 if (!willResample) {
|
Chris@0
|
3626 //!!! more helpful message needed
|
Chris@0
|
3627 QMessageBox::information
|
Chris@0
|
3628 (this, tr("Sample rate mismatch"),
|
Chris@0
|
3629 tr("The sample rate of this audio file (%1 Hz) does not match\nthe current playback rate (%2 Hz).\n\nThe file will play at the wrong speed.")
|
Chris@0
|
3630 .arg(requested).arg(actual));
|
Chris@0
|
3631 }
|
Chris@0
|
3632
|
Chris@0
|
3633 /*!!! Let's not do this for now, and see how we go -- now that we're putting
|
Chris@0
|
3634 sample rate information in the status bar
|
Chris@0
|
3635
|
Chris@0
|
3636 QMessageBox::information
|
Chris@0
|
3637 (this, tr("Sample rate mismatch"),
|
Chris@0
|
3638 tr("The sample rate of this audio file (%1 Hz) does not match\nthat of the output audio device (%2 Hz).\n\nThe file will be resampled automatically during playback.")
|
Chris@0
|
3639 .arg(requested).arg(actual));
|
Chris@0
|
3640 */
|
Chris@0
|
3641
|
Chris@0
|
3642 updateDescriptionLabel();
|
Chris@0
|
3643 }
|
Chris@0
|
3644
|
Chris@0
|
3645 void
|
Chris@42
|
3646 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
3647 {
|
Chris@42
|
3648 QMessageBox::information
|
Chris@42
|
3649 (this, tr("Audio processing overload"),
|
Chris@42
|
3650 tr("Audio effects plugin auditioning has been disabled\ndue to a processing overload."));
|
Chris@42
|
3651 }
|
Chris@42
|
3652
|
Chris@42
|
3653 void
|
Chris@0
|
3654 MainWindow::layerAdded(Layer *layer)
|
Chris@0
|
3655 {
|
Chris@0
|
3656 // std::cerr << "MainWindow::layerAdded(" << layer << ")" << std::endl;
|
Chris@0
|
3657 // setupExistingLayersMenu();
|
Chris@0
|
3658 updateMenuStates();
|
Chris@0
|
3659 }
|
Chris@0
|
3660
|
Chris@0
|
3661 void
|
Chris@0
|
3662 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
3663 {
|
Chris@0
|
3664 // std::cerr << "MainWindow::layerRemoved(" << layer << ")" << std::endl;
|
Chris@95
|
3665 setupExistingLayersMenus();
|
Chris@0
|
3666 updateMenuStates();
|
Chris@0
|
3667 }
|
Chris@0
|
3668
|
Chris@0
|
3669 void
|
Chris@0
|
3670 MainWindow::layerAboutToBeDeleted(Layer *layer)
|
Chris@0
|
3671 {
|
Chris@0
|
3672 // std::cerr << "MainWindow::layerAboutToBeDeleted(" << layer << ")" << std::endl;
|
Chris@0
|
3673 if (layer == m_timeRulerLayer) {
|
Chris@0
|
3674 // std::cerr << "(this is the time ruler layer)" << std::endl;
|
Chris@0
|
3675 m_timeRulerLayer = 0;
|
Chris@0
|
3676 }
|
Chris@0
|
3677 }
|
Chris@0
|
3678
|
Chris@0
|
3679 void
|
Chris@0
|
3680 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
3681 {
|
Chris@0
|
3682 // std::cerr << "MainWindow::layerInAView(" << layer << "," << inAView << ")" << std::endl;
|
Chris@0
|
3683
|
Chris@0
|
3684 // Check whether we need to add or remove model from play source
|
Chris@0
|
3685 Model *model = layer->getModel();
|
Chris@0
|
3686 if (model) {
|
Chris@0
|
3687 if (inAView) {
|
Chris@0
|
3688 m_playSource->addModel(model);
|
Chris@0
|
3689 } else {
|
Chris@0
|
3690 bool found = false;
|
Chris@0
|
3691 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
3692 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
3693 if (!pane) continue;
|
Chris@0
|
3694 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3695 Layer *pl = pane->getLayer(j);
|
Chris@0
|
3696 if (pl && pl->getModel() == model) {
|
Chris@0
|
3697 found = true;
|
Chris@0
|
3698 break;
|
Chris@0
|
3699 }
|
Chris@0
|
3700 }
|
Chris@0
|
3701 if (found) break;
|
Chris@0
|
3702 }
|
Chris@0
|
3703 if (!found) m_playSource->removeModel(model);
|
Chris@0
|
3704 }
|
Chris@0
|
3705 }
|
Chris@0
|
3706
|
Chris@95
|
3707 setupExistingLayersMenus();
|
Chris@0
|
3708 updateMenuStates();
|
Chris@0
|
3709 }
|
Chris@0
|
3710
|
Chris@0
|
3711 void
|
Chris@0
|
3712 MainWindow::modelAdded(Model *model)
|
Chris@0
|
3713 {
|
Chris@0
|
3714 // std::cerr << "MainWindow::modelAdded(" << model << ")" << std::endl;
|
Chris@0
|
3715 m_playSource->addModel(model);
|
Chris@66
|
3716 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
3717 setupPaneAndLayerMenus();
|
Chris@66
|
3718 }
|
Chris@0
|
3719 }
|
Chris@0
|
3720
|
Chris@0
|
3721 void
|
Chris@0
|
3722 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
3723 {
|
Chris@0
|
3724 // std::cerr << "MainWindow::mainModelChanged(" << model << ")" << std::endl;
|
Chris@0
|
3725 updateDescriptionLabel();
|
Chris@0
|
3726 m_panLayer->setModel(model);
|
Chris@0
|
3727 if (model) m_viewManager->setMainModelSampleRate(model->getSampleRate());
|
Chris@46
|
3728 if (model && !m_playTarget && m_audioOutput) createPlayTarget();
|
Chris@0
|
3729 }
|
Chris@0
|
3730
|
Chris@0
|
3731 void
|
Chris@0
|
3732 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
3733 {
|
Chris@0
|
3734 // std::cerr << "MainWindow::modelAboutToBeDeleted(" << model << ")" << std::endl;
|
Chris@0
|
3735 m_playSource->removeModel(model);
|
Chris@91
|
3736 FFTDataServer::modelAboutToBeDeleted(model);
|
Chris@0
|
3737 }
|
Chris@0
|
3738
|
Chris@0
|
3739 void
|
Chris@0
|
3740 MainWindow::modelGenerationFailed(QString transformName)
|
Chris@0
|
3741 {
|
Chris@0
|
3742 QMessageBox::warning
|
Chris@0
|
3743 (this,
|
Chris@0
|
3744 tr("Failed to generate layer"),
|
Chris@34
|
3745 tr("Failed to generate a derived layer.\n\nThe layer transform \"%1\" failed.\n\nThis probably means that a plugin failed to initialise, perhaps because it\nrejected the processing block size that was requested.")
|
Chris@0
|
3746 .arg(transformName),
|
Chris@0
|
3747 QMessageBox::Ok, 0);
|
Chris@0
|
3748 }
|
Chris@0
|
3749
|
Chris@0
|
3750 void
|
Chris@0
|
3751 MainWindow::modelRegenerationFailed(QString layerName, QString transformName)
|
Chris@0
|
3752 {
|
Chris@0
|
3753 QMessageBox::warning
|
Chris@0
|
3754 (this,
|
Chris@0
|
3755 tr("Failed to regenerate layer"),
|
Chris@34
|
3756 tr("Failed to regenerate derived layer \"%1\".\n\nThe layer transform \"%2\" failed to run.\n\nThis probably means the layer used a plugin that is not currently available.")
|
Chris@0
|
3757 .arg(layerName).arg(transformName),
|
Chris@0
|
3758 QMessageBox::Ok, 0);
|
Chris@0
|
3759 }
|
Chris@0
|
3760
|
Chris@0
|
3761 void
|
Chris@0
|
3762 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
3763 {
|
Chris@0
|
3764 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
|
Chris@0
|
3765 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
3766 m_rightButtonMenu->popup(position);
|
Chris@0
|
3767 }
|
Chris@0
|
3768
|
Chris@0
|
3769 void
|
Chris@73
|
3770 MainWindow::propertyStacksResized()
|
Chris@73
|
3771 {
|
Chris@73
|
3772 /*
|
Chris@73
|
3773 std::cerr << "MainWindow::propertyStacksResized" << std::endl;
|
Chris@73
|
3774 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
3775 if (pane && m_overview) {
|
Chris@73
|
3776 std::cerr << "Fixed width: " << pane->width() << std::endl;
|
Chris@73
|
3777 m_overview->setFixedWidth(pane->width());
|
Chris@73
|
3778 }
|
Chris@73
|
3779 */
|
Chris@73
|
3780 }
|
Chris@73
|
3781
|
Chris@73
|
3782 void
|
Chris@0
|
3783 MainWindow::showLayerTree()
|
Chris@0
|
3784 {
|
Chris@0
|
3785 QTreeView *view = new QTreeView();
|
Chris@0
|
3786 LayerTreeModel *tree = new LayerTreeModel(m_paneStack);
|
Chris@0
|
3787 view->expand(tree->index(0, 0, QModelIndex()));
|
Chris@0
|
3788 view->setModel(tree);
|
Chris@0
|
3789 view->show();
|
Chris@0
|
3790 }
|
Chris@0
|
3791
|
Chris@0
|
3792 void
|
Chris@69
|
3793 MainWindow::pollOSC()
|
Chris@69
|
3794 {
|
Chris@70
|
3795 if (!m_oscQueue || m_oscQueue->isEmpty()) return;
|
Chris@69
|
3796 std::cerr << "MainWindow::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << std::endl;
|
Chris@69
|
3797
|
Chris@70
|
3798 if (m_openingAudioFile) return;
|
Chris@70
|
3799
|
Chris@69
|
3800 OSCMessage message = m_oscQueue->readMessage();
|
Chris@69
|
3801
|
Chris@69
|
3802 if (message.getTarget() != 0) {
|
Chris@69
|
3803 return; //!!! for now -- this class is target 0, others not handled yet
|
Chris@69
|
3804 }
|
Chris@69
|
3805
|
Chris@69
|
3806 handleOSCMessage(message);
|
Chris@69
|
3807 }
|
Chris@69
|
3808
|
Chris@69
|
3809 void
|
Chris@69
|
3810 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@69
|
3811 {
|
Chris@70
|
3812 std::cerr << "MainWindow::handleOSCMessage: thread id = "
|
Chris@70
|
3813 << QThread::currentThreadId() << std::endl;
|
Chris@70
|
3814
|
Chris@69
|
3815 // This large function should really be abstracted out.
|
Chris@69
|
3816
|
Chris@69
|
3817 if (message.getMethod() == "open") {
|
Chris@69
|
3818
|
Chris@69
|
3819 if (message.getArgCount() == 1 &&
|
Chris@69
|
3820 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3821 QString path = message.getArg(0).toString();
|
Chris@82
|
3822 if (openSomeFile(path, ReplaceMainModel) != FileOpenSucceeded) {
|
Chris@69
|
3823 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3824 << path.toStdString() << "\"" << std::endl;
|
Chris@69
|
3825 }
|
Chris@69
|
3826 //!!! we really need to spin here and not return until the
|
Chris@69
|
3827 // file has been completely decoded...
|
Chris@69
|
3828 }
|
Chris@69
|
3829
|
Chris@69
|
3830 } else if (message.getMethod() == "openadditional") {
|
Chris@69
|
3831
|
Chris@69
|
3832 if (message.getArgCount() == 1 &&
|
Chris@69
|
3833 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3834 QString path = message.getArg(0).toString();
|
Chris@82
|
3835 if (openSomeFile(path, CreateAdditionalModel) != FileOpenSucceeded) {
|
Chris@69
|
3836 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3837 << path.toStdString() << "\"" << std::endl;
|
Chris@69
|
3838 }
|
Chris@69
|
3839 }
|
Chris@69
|
3840
|
Chris@69
|
3841 } else if (message.getMethod() == "recent" ||
|
Chris@69
|
3842 message.getMethod() == "last") {
|
Chris@69
|
3843
|
Chris@69
|
3844 int n = 0;
|
Chris@69
|
3845 if (message.getMethod() == "recent" &&
|
Chris@69
|
3846 message.getArgCount() == 1 &&
|
Chris@69
|
3847 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
3848 n = message.getArg(0).toInt() - 1;
|
Chris@69
|
3849 }
|
Chris@69
|
3850 std::vector<QString> recent = m_recentFiles.getRecent();
|
Chris@69
|
3851 if (n >= 0 && n < recent.size()) {
|
Chris@82
|
3852 if (openSomeFile(recent[n], ReplaceMainModel) != FileOpenSucceeded) {
|
Chris@69
|
3853 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3854 << recent[n].toStdString() << "\"" << std::endl;
|
Chris@69
|
3855 }
|
Chris@69
|
3856 }
|
Chris@69
|
3857
|
Chris@69
|
3858 } else if (message.getMethod() == "save") {
|
Chris@69
|
3859
|
Chris@69
|
3860 QString path;
|
Chris@69
|
3861 if (message.getArgCount() == 1 &&
|
Chris@69
|
3862 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3863 path = message.getArg(0).toString();
|
Chris@69
|
3864 if (QFileInfo(path).exists()) {
|
Chris@69
|
3865 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in save" << std::endl;
|
Chris@69
|
3866 } else {
|
Chris@69
|
3867 saveSessionFile(path);
|
Chris@69
|
3868 }
|
Chris@69
|
3869 }
|
Chris@69
|
3870
|
Chris@69
|
3871 } else if (message.getMethod() == "export") {
|
Chris@69
|
3872
|
Chris@69
|
3873 QString path;
|
Chris@69
|
3874 if (getMainModel()) {
|
Chris@69
|
3875 if (message.getArgCount() == 1 &&
|
Chris@69
|
3876 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3877 path = message.getArg(0).toString();
|
Chris@69
|
3878 if (QFileInfo(path).exists()) {
|
Chris@69
|
3879 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in export" << std::endl;
|
Chris@69
|
3880 } else {
|
Chris@69
|
3881 WavFileWriter writer(path,
|
Chris@69
|
3882 getMainModel()->getSampleRate(),
|
Chris@69
|
3883 getMainModel()->getChannelCount());
|
Chris@69
|
3884 MultiSelection ms = m_viewManager->getSelection();
|
Chris@69
|
3885 if (!ms.getSelections().empty()) {
|
Chris@69
|
3886 writer.writeModel(getMainModel(), &ms);
|
Chris@69
|
3887 } else {
|
Chris@69
|
3888 writer.writeModel(getMainModel());
|
Chris@69
|
3889 }
|
Chris@69
|
3890 }
|
Chris@69
|
3891 }
|
Chris@69
|
3892 }
|
Chris@69
|
3893
|
Chris@69
|
3894 } else if (message.getMethod() == "jump" ||
|
Chris@69
|
3895 message.getMethod() == "play") {
|
Chris@69
|
3896
|
Chris@69
|
3897 if (getMainModel()) {
|
Chris@69
|
3898
|
Chris@69
|
3899 unsigned long frame = m_viewManager->getPlaybackFrame();
|
Chris@69
|
3900 bool selection = false;
|
Chris@69
|
3901 bool play = (message.getMethod() == "play");
|
Chris@69
|
3902
|
Chris@69
|
3903 if (message.getArgCount() == 1) {
|
Chris@69
|
3904
|
Chris@69
|
3905 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
3906 message.getArg(0).toString() == "selection") {
|
Chris@69
|
3907
|
Chris@69
|
3908 selection = true;
|
Chris@69
|
3909
|
Chris@69
|
3910 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
3911 message.getArg(0).toString() == "end") {
|
Chris@69
|
3912
|
Chris@69
|
3913 frame = getMainModel()->getEndFrame();
|
Chris@69
|
3914
|
Chris@69
|
3915 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@69
|
3916
|
Chris@69
|
3917 double time = message.getArg(0).toDouble();
|
Chris@69
|
3918 if (time < 0.0) time = 0.0;
|
Chris@69
|
3919
|
Chris@69
|
3920 frame = lrint(time * getMainModel()->getSampleRate());
|
Chris@69
|
3921 }
|
Chris@69
|
3922 }
|
Chris@69
|
3923
|
Chris@69
|
3924 if (frame > getMainModel()->getEndFrame()) {
|
Chris@69
|
3925 frame = getMainModel()->getEndFrame();
|
Chris@69
|
3926 }
|
Chris@69
|
3927
|
Chris@69
|
3928 if (play) {
|
Chris@69
|
3929 m_viewManager->setPlaySelectionMode(selection);
|
Chris@69
|
3930 }
|
Chris@69
|
3931
|
Chris@69
|
3932 if (selection) {
|
Chris@69
|
3933 MultiSelection::SelectionList sl = m_viewManager->getSelections();
|
Chris@69
|
3934 if (!sl.empty()) {
|
Chris@69
|
3935 frame = sl.begin()->getStartFrame();
|
Chris@69
|
3936 }
|
Chris@69
|
3937 }
|
Chris@69
|
3938
|
Chris@69
|
3939 m_viewManager->setPlaybackFrame(frame);
|
Chris@69
|
3940
|
Chris@69
|
3941 if (play && !m_playSource->isPlaying()) {
|
Chris@69
|
3942 m_playSource->play(frame);
|
Chris@69
|
3943 }
|
Chris@69
|
3944 }
|
Chris@69
|
3945
|
Chris@69
|
3946 } else if (message.getMethod() == "stop") {
|
Chris@69
|
3947
|
Chris@69
|
3948 if (m_playSource->isPlaying()) m_playSource->stop();
|
Chris@69
|
3949
|
Chris@69
|
3950 } else if (message.getMethod() == "loop") {
|
Chris@69
|
3951
|
Chris@69
|
3952 if (message.getArgCount() == 1 &&
|
Chris@69
|
3953 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3954
|
Chris@69
|
3955 QString str = message.getArg(0).toString();
|
Chris@69
|
3956 if (str == "on") {
|
Chris@69
|
3957 m_viewManager->setPlayLoopMode(true);
|
Chris@69
|
3958 } else if (str == "off") {
|
Chris@69
|
3959 m_viewManager->setPlayLoopMode(false);
|
Chris@69
|
3960 }
|
Chris@69
|
3961 }
|
Chris@69
|
3962
|
Chris@69
|
3963 } else if (message.getMethod() == "select" ||
|
Chris@69
|
3964 message.getMethod() == "addselect") {
|
Chris@69
|
3965
|
Chris@69
|
3966 if (getMainModel()) {
|
Chris@69
|
3967
|
Chris@73
|
3968 int f0 = getMainModel()->getStartFrame();
|
Chris@73
|
3969 int f1 = getMainModel()->getEndFrame();
|
Chris@69
|
3970
|
Chris@69
|
3971 bool done = false;
|
Chris@69
|
3972
|
Chris@69
|
3973 if (message.getArgCount() == 2 &&
|
Chris@69
|
3974 message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@69
|
3975 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@69
|
3976
|
Chris@69
|
3977 double t0 = message.getArg(0).toDouble();
|
Chris@69
|
3978 double t1 = message.getArg(1).toDouble();
|
Chris@69
|
3979 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; }
|
Chris@69
|
3980 if (t0 < 0.0) t0 = 0.0;
|
Chris@69
|
3981 if (t1 < 0.0) t1 = 0.0;
|
Chris@69
|
3982
|
Chris@69
|
3983 f0 = lrint(t0 * getMainModel()->getSampleRate());
|
Chris@69
|
3984 f1 = lrint(t1 * getMainModel()->getSampleRate());
|
Chris@73
|
3985
|
Chris@73
|
3986 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
3987 Layer *layer = 0;
|
Chris@73
|
3988 if (pane) layer = pane->getSelectedLayer();
|
Chris@73
|
3989 if (layer) {
|
Chris@73
|
3990 size_t resolution;
|
Chris@73
|
3991 layer->snapToFeatureFrame(pane, f0, resolution,
|
Chris@73
|
3992 Layer::SnapLeft);
|
Chris@73
|
3993 layer->snapToFeatureFrame(pane, f1, resolution,
|
Chris@73
|
3994 Layer::SnapRight);
|
Chris@73
|
3995 }
|
Chris@69
|
3996
|
Chris@69
|
3997 } else if (message.getArgCount() == 1 &&
|
Chris@69
|
3998 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3999
|
Chris@69
|
4000 QString str = message.getArg(0).toString();
|
Chris@69
|
4001 if (str == "none") {
|
Chris@69
|
4002 m_viewManager->clearSelections();
|
Chris@69
|
4003 done = true;
|
Chris@69
|
4004 }
|
Chris@69
|
4005 }
|
Chris@69
|
4006
|
Chris@69
|
4007 if (!done) {
|
Chris@69
|
4008 if (message.getMethod() == "select") {
|
Chris@69
|
4009 m_viewManager->setSelection(Selection(f0, f1));
|
Chris@69
|
4010 } else {
|
Chris@69
|
4011 m_viewManager->addSelection(Selection(f0, f1));
|
Chris@69
|
4012 }
|
Chris@69
|
4013 }
|
Chris@69
|
4014 }
|
Chris@69
|
4015
|
Chris@69
|
4016 } else if (message.getMethod() == "add") {
|
Chris@69
|
4017
|
Chris@69
|
4018 if (getMainModel()) {
|
Chris@69
|
4019
|
Chris@69
|
4020 if (message.getArgCount() >= 1 &&
|
Chris@69
|
4021 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
4022
|
Chris@69
|
4023 int channel = -1;
|
Chris@69
|
4024 if (message.getArgCount() == 2 &&
|
Chris@69
|
4025 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
4026 channel = message.getArg(0).toInt();
|
Chris@69
|
4027 if (channel < -1 ||
|
Chris@69
|
4028 channel > getMainModel()->getChannelCount()) {
|
Chris@69
|
4029 std::cerr << "WARNING: MainWindow::handleOSCMessage: channel "
|
Chris@69
|
4030 << channel << " out of range" << std::endl;
|
Chris@69
|
4031 channel = -1;
|
Chris@69
|
4032 }
|
Chris@69
|
4033 }
|
Chris@69
|
4034
|
Chris@69
|
4035 QString str = message.getArg(0).toString();
|
Chris@69
|
4036
|
Chris@69
|
4037 LayerFactory::LayerType type =
|
Chris@69
|
4038 LayerFactory::getInstance()->getLayerTypeForName(str);
|
Chris@69
|
4039
|
Chris@69
|
4040 if (type == LayerFactory::UnknownLayer) {
|
Chris@69
|
4041 std::cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer "
|
Chris@69
|
4042 << "type " << str.toStdString() << std::endl;
|
Chris@69
|
4043 } else {
|
Chris@69
|
4044
|
Chris@69
|
4045 PaneConfiguration configuration(type,
|
Chris@69
|
4046 getMainModel(),
|
Chris@69
|
4047 channel);
|
Chris@69
|
4048
|
Chris@69
|
4049 addPane(configuration,
|
Chris@69
|
4050 tr("Add %1 Pane")
|
Chris@69
|
4051 .arg(LayerFactory::getInstance()->
|
Chris@69
|
4052 getLayerPresentationName(type)));
|
Chris@69
|
4053 }
|
Chris@69
|
4054 }
|
Chris@69
|
4055 }
|
Chris@69
|
4056
|
Chris@69
|
4057 } else if (message.getMethod() == "undo") {
|
Chris@69
|
4058
|
Chris@69
|
4059 CommandHistory::getInstance()->undo();
|
Chris@69
|
4060
|
Chris@69
|
4061 } else if (message.getMethod() == "redo") {
|
Chris@69
|
4062
|
Chris@69
|
4063 CommandHistory::getInstance()->redo();
|
Chris@69
|
4064
|
Chris@69
|
4065 } else if (message.getMethod() == "set") {
|
Chris@69
|
4066
|
Chris@70
|
4067 if (message.getArgCount() == 2 &&
|
Chris@69
|
4068 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4069 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@69
|
4070
|
Chris@69
|
4071 QString property = message.getArg(0).toString();
|
Chris@69
|
4072 float value = (float)message.getArg(1).toDouble();
|
Chris@69
|
4073
|
Chris@69
|
4074 if (property == "gain") {
|
Chris@69
|
4075 if (value < 0.0) value = 0.0;
|
Chris@69
|
4076 m_fader->setValue(value);
|
Chris@69
|
4077 if (m_playTarget) m_playTarget->setOutputGain(value);
|
Chris@69
|
4078 } else if (property == "speedup") {
|
Chris@69
|
4079 m_playSpeed->setMappedValue(value);
|
Chris@69
|
4080 } else if (property == "overlays") {
|
Chris@69
|
4081 if (value < 0.5) {
|
Chris@69
|
4082 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
|
Chris@69
|
4083 } else if (value < 1.5) {
|
Chris@90
|
4084 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@90
|
4085 } else if (value < 2.5) {
|
Chris@90
|
4086 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
|
Chris@69
|
4087 } else {
|
Chris@69
|
4088 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
|
Chris@69
|
4089 }
|
Chris@70
|
4090 } else if (property == "zoomwheels") {
|
Chris@70
|
4091 m_viewManager->setZoomWheelsEnabled(value > 0.5);
|
Chris@72
|
4092 } else if (property == "propertyboxes") {
|
Chris@72
|
4093 bool toggle = ((value < 0.5) !=
|
Chris@72
|
4094 (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks));
|
Chris@72
|
4095 if (toggle) togglePropertyBoxes();
|
Chris@70
|
4096 }
|
Chris@70
|
4097
|
Chris@70
|
4098 } else {
|
Chris@70
|
4099 PropertyContainer *container = 0;
|
Chris@70
|
4100 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4101 if (pane &&
|
Chris@70
|
4102 message.getArgCount() == 3 &&
|
Chris@70
|
4103 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@70
|
4104 message.getArg(1).canConvert(QVariant::String) &&
|
Chris@70
|
4105 message.getArg(2).canConvert(QVariant::String)) {
|
Chris@70
|
4106 if (message.getArg(0).toString() == "pane") {
|
Chris@70
|
4107 container = pane->getPropertyContainer(0);
|
Chris@70
|
4108 } else if (message.getArg(0).toString() == "layer") {
|
Chris@70
|
4109 container = pane->getSelectedLayer();
|
Chris@70
|
4110 }
|
Chris@70
|
4111 }
|
Chris@70
|
4112 if (container) {
|
Chris@70
|
4113 QString nameString = message.getArg(1).toString();
|
Chris@70
|
4114 QString valueString = message.getArg(2).toString();
|
Chris@70
|
4115 container->setPropertyWithCommand(nameString, valueString);
|
Chris@69
|
4116 }
|
Chris@69
|
4117 }
|
Chris@69
|
4118
|
Chris@69
|
4119 } else if (message.getMethod() == "setcurrent") {
|
Chris@69
|
4120
|
Chris@69
|
4121 int paneIndex = -1, layerIndex = -1;
|
Chris@69
|
4122 bool wantLayer = false;
|
Chris@69
|
4123
|
Chris@69
|
4124 if (message.getArgCount() >= 1 &&
|
Chris@69
|
4125 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
4126
|
Chris@69
|
4127 paneIndex = message.getArg(0).toInt() - 1;
|
Chris@69
|
4128
|
Chris@69
|
4129 if (message.getArgCount() >= 2 &&
|
Chris@69
|
4130 message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@69
|
4131 wantLayer = true;
|
Chris@69
|
4132 layerIndex = message.getArg(1).toInt() - 1;
|
Chris@69
|
4133 }
|
Chris@69
|
4134 }
|
Chris@69
|
4135
|
Chris@69
|
4136 if (paneIndex >= 0 && paneIndex < m_paneStack->getPaneCount()) {
|
Chris@69
|
4137 Pane *pane = m_paneStack->getPane(paneIndex);
|
Chris@70
|
4138 m_paneStack->setCurrentPane(pane);
|
Chris@69
|
4139 if (layerIndex >= 0 && layerIndex < pane->getLayerCount()) {
|
Chris@69
|
4140 Layer *layer = pane->getLayer(layerIndex);
|
Chris@69
|
4141 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@69
|
4142 } else if (wantLayer && layerIndex == -1) {
|
Chris@69
|
4143 m_paneStack->setCurrentLayer(pane, 0);
|
Chris@69
|
4144 }
|
Chris@69
|
4145 }
|
Chris@69
|
4146
|
Chris@69
|
4147 } else if (message.getMethod() == "delete") {
|
Chris@69
|
4148
|
Chris@69
|
4149 if (message.getArgCount() == 1 &&
|
Chris@69
|
4150 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
4151
|
Chris@69
|
4152 QString target = message.getArg(0).toString();
|
Chris@69
|
4153
|
Chris@69
|
4154 if (target == "pane") {
|
Chris@69
|
4155
|
Chris@69
|
4156 deleteCurrentPane();
|
Chris@69
|
4157
|
Chris@69
|
4158 } else if (target == "layer") {
|
Chris@69
|
4159
|
Chris@69
|
4160 deleteCurrentLayer();
|
Chris@69
|
4161
|
Chris@69
|
4162 } else {
|
Chris@69
|
4163
|
Chris@69
|
4164 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown delete target " << target.toStdString() << std::endl;
|
Chris@69
|
4165 }
|
Chris@69
|
4166 }
|
Chris@69
|
4167
|
Chris@69
|
4168 } else if (message.getMethod() == "zoom") {
|
Chris@69
|
4169
|
Chris@69
|
4170 if (message.getArgCount() == 1) {
|
Chris@69
|
4171 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4172 message.getArg(0).toString() == "in") {
|
Chris@69
|
4173 zoomIn();
|
Chris@69
|
4174 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4175 message.getArg(0).toString() == "out") {
|
Chris@69
|
4176 zoomOut();
|
Chris@69
|
4177 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4178 message.getArg(0).toString() == "default") {
|
Chris@69
|
4179 zoomDefault();
|
Chris@69
|
4180 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@69
|
4181 double level = message.getArg(0).toDouble();
|
Chris@69
|
4182 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@69
|
4183 if (level < 1.0) level = 1.0;
|
Chris@69
|
4184 if (currentPane) currentPane->setZoomLevel(lrint(level));
|
Chris@69
|
4185 }
|
Chris@69
|
4186 }
|
Chris@69
|
4187
|
Chris@73
|
4188 } else if (message.getMethod() == "zoomvertical") {
|
Chris@73
|
4189
|
Chris@73
|
4190 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
4191 Layer *layer = 0;
|
Chris@73
|
4192 if (pane && pane->getLayerCount() > 0) {
|
Chris@73
|
4193 layer = pane->getLayer(pane->getLayerCount() - 1);
|
Chris@73
|
4194 }
|
Chris@73
|
4195 int defaultStep = 0;
|
Chris@73
|
4196 int steps = 0;
|
Chris@73
|
4197 if (layer) {
|
Chris@73
|
4198 steps = layer->getVerticalZoomSteps(defaultStep);
|
Chris@73
|
4199 if (message.getArgCount() == 1 && steps > 0) {
|
Chris@73
|
4200 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4201 message.getArg(0).toString() == "in") {
|
Chris@73
|
4202 int step = layer->getCurrentVerticalZoomStep() + 1;
|
Chris@73
|
4203 if (step < steps) layer->setVerticalZoomStep(step);
|
Chris@73
|
4204 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4205 message.getArg(0).toString() == "out") {
|
Chris@73
|
4206 int step = layer->getCurrentVerticalZoomStep() - 1;
|
Chris@73
|
4207 if (step >= 0) layer->setVerticalZoomStep(step);
|
Chris@73
|
4208 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4209 message.getArg(0).toString() == "default") {
|
Chris@73
|
4210 layer->setVerticalZoomStep(defaultStep);
|
Chris@73
|
4211 }
|
Chris@73
|
4212 } else if (message.getArgCount() == 2) {
|
Chris@73
|
4213 if (message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@73
|
4214 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@73
|
4215 double min = message.getArg(0).toDouble();
|
Chris@73
|
4216 double max = message.getArg(1).toDouble();
|
Chris@73
|
4217 layer->setDisplayExtents(min, max);
|
Chris@73
|
4218 }
|
Chris@73
|
4219 }
|
Chris@73
|
4220 }
|
Chris@73
|
4221
|
Chris@70
|
4222 } else if (message.getMethod() == "quit") {
|
Chris@70
|
4223
|
Chris@70
|
4224 m_abandoning = true;
|
Chris@70
|
4225 close();
|
Chris@70
|
4226
|
Chris@70
|
4227 } else if (message.getMethod() == "resize") {
|
Chris@70
|
4228
|
Chris@70
|
4229 if (message.getArgCount() == 2) {
|
Chris@70
|
4230
|
Chris@70
|
4231 int width = 0, height = 0;
|
Chris@70
|
4232
|
Chris@70
|
4233 if (message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@70
|
4234
|
Chris@70
|
4235 height = message.getArg(1).toInt();
|
Chris@70
|
4236
|
Chris@70
|
4237 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@70
|
4238 message.getArg(0).toString() == "pane") {
|
Chris@70
|
4239
|
Chris@70
|
4240 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4241 if (pane) pane->resize(pane->width(), height);
|
Chris@70
|
4242
|
Chris@70
|
4243 } else if (message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@70
|
4244
|
Chris@70
|
4245 width = message.getArg(0).toInt();
|
Chris@70
|
4246 resize(width, height);
|
Chris@70
|
4247 }
|
Chris@70
|
4248 }
|
Chris@70
|
4249 }
|
Chris@70
|
4250
|
Chris@70
|
4251 } else if (message.getMethod() == "transform") {
|
Chris@70
|
4252
|
Chris@70
|
4253 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4254
|
Chris@70
|
4255 if (getMainModel() &&
|
Chris@70
|
4256 pane &&
|
Chris@70
|
4257 message.getArgCount() == 1 &&
|
Chris@70
|
4258 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@70
|
4259
|
Chris@107
|
4260 TransformId transform = message.getArg(0).toString();
|
Chris@70
|
4261
|
Chris@70
|
4262 Layer *newLayer = m_document->createDerivedLayer
|
Chris@70
|
4263 (transform,
|
Chris@70
|
4264 getMainModel(),
|
Chris@73
|
4265 TransformFactory::getInstance()->getDefaultContextForTransform
|
Chris@73
|
4266 (transform, getMainModel()),
|
Chris@70
|
4267 "");
|
Chris@70
|
4268
|
Chris@70
|
4269 if (newLayer) {
|
Chris@70
|
4270 m_document->addLayerToView(pane, newLayer);
|
Chris@70
|
4271 m_recentTransforms.add(transform);
|
Chris@70
|
4272 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@70
|
4273 }
|
Chris@70
|
4274 }
|
Chris@70
|
4275
|
Chris@69
|
4276 } else {
|
Chris@69
|
4277 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown or unsupported "
|
Chris@69
|
4278 << "method \"" << message.getMethod().toStdString()
|
Chris@69
|
4279 << "\"" << std::endl;
|
Chris@69
|
4280 }
|
Chris@69
|
4281
|
Chris@69
|
4282 }
|
Chris@69
|
4283
|
Chris@69
|
4284 void
|
Chris@0
|
4285 MainWindow::preferences()
|
Chris@0
|
4286 {
|
Chris@0
|
4287 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
4288 m_preferencesDialog->show();
|
Chris@0
|
4289 m_preferencesDialog->raise();
|
Chris@0
|
4290 return;
|
Chris@0
|
4291 }
|
Chris@0
|
4292
|
Chris@0
|
4293 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
4294
|
Chris@0
|
4295 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
4296 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
4297 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
4298 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
4299 // without resetting its own widgets, so its state will be
|
Chris@0
|
4300 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
4301 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
4302
|
Chris@0
|
4303 m_preferencesDialog->show();
|
Chris@0
|
4304 }
|
Chris@0
|
4305
|
Chris@0
|
4306 void
|
Chris@90
|
4307 MainWindow::mouseEnteredWidget()
|
Chris@90
|
4308 {
|
Chris@90
|
4309 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
4310 if (!w) return;
|
Chris@90
|
4311
|
Chris@90
|
4312 if (w == m_fader) {
|
Chris@90
|
4313 statusBar()->showMessage(tr("Adjust the master playback level"));
|
Chris@90
|
4314 } else if (w == m_playSpeed) {
|
Chris@90
|
4315 statusBar()->showMessage(tr("Adjust the master playback speed"));
|
Chris@90
|
4316 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@90
|
4317 statusBar()->showMessage(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@90
|
4318 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@90
|
4319 statusBar()->showMessage(tr("Toggle mono mode for playback time scaling"));
|
Chris@90
|
4320 }
|
Chris@90
|
4321 }
|
Chris@90
|
4322
|
Chris@90
|
4323 void
|
Chris@90
|
4324 MainWindow::mouseLeftWidget()
|
Chris@90
|
4325 {
|
Chris@90
|
4326 statusBar()->showMessage("");
|
Chris@90
|
4327 }
|
Chris@90
|
4328
|
Chris@90
|
4329 void
|
Chris@0
|
4330 MainWindow::website()
|
Chris@0
|
4331 {
|
Chris@0
|
4332 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
4333 }
|
Chris@0
|
4334
|
Chris@0
|
4335 void
|
Chris@0
|
4336 MainWindow::help()
|
Chris@0
|
4337 {
|
Chris@0
|
4338 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/en/"));
|
Chris@0
|
4339 }
|
Chris@0
|
4340
|
Chris@0
|
4341 void
|
Chris@0
|
4342 MainWindow::openHelpUrl(QString url)
|
Chris@0
|
4343 {
|
Chris@0
|
4344 // This method mostly lifted from Qt Assistant source code
|
Chris@0
|
4345
|
Chris@0
|
4346 QProcess *process = new QProcess(this);
|
Chris@0
|
4347 connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
|
Chris@0
|
4348
|
Chris@0
|
4349 QStringList args;
|
Chris@0
|
4350
|
Chris@0
|
4351 #ifdef Q_OS_MAC
|
Chris@0
|
4352 args.append(url);
|
Chris@0
|
4353 process->start("open", args);
|
Chris@0
|
4354 #else
|
Chris@0
|
4355 #ifdef Q_OS_WIN32
|
Chris@0
|
4356
|
Chris@0
|
4357 QString pf(getenv("ProgramFiles"));
|
Chris@0
|
4358 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE");
|
Chris@0
|
4359
|
Chris@0
|
4360 args.append(url);
|
Chris@0
|
4361 process->start(command, args);
|
Chris@0
|
4362
|
Chris@0
|
4363 #else
|
Chris@0
|
4364 #ifdef Q_WS_X11
|
Chris@0
|
4365 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
|
Chris@0
|
4366 args.append("exec");
|
Chris@0
|
4367 args.append(url);
|
Chris@0
|
4368 process->start("kfmclient", args);
|
Chris@0
|
4369 } else if (!qgetenv("BROWSER").isEmpty()) {
|
Chris@0
|
4370 args.append(url);
|
Chris@0
|
4371 process->start(qgetenv("BROWSER"), args);
|
Chris@0
|
4372 } else {
|
Chris@0
|
4373 args.append(url);
|
Chris@0
|
4374 process->start("firefox", args);
|
Chris@0
|
4375 }
|
Chris@0
|
4376 #endif
|
Chris@0
|
4377 #endif
|
Chris@0
|
4378 #endif
|
Chris@0
|
4379 }
|
Chris@0
|
4380
|
Chris@0
|
4381 void
|
Chris@0
|
4382 MainWindow::about()
|
Chris@0
|
4383 {
|
Chris@0
|
4384 bool debug = false;
|
Chris@0
|
4385 QString version = "(unknown version)";
|
Chris@0
|
4386
|
Chris@0
|
4387 #ifdef BUILD_DEBUG
|
Chris@0
|
4388 debug = true;
|
Chris@0
|
4389 #endif
|
Chris@0
|
4390 #ifdef SV_VERSION
|
Chris@0
|
4391 #ifdef SVNREV
|
Chris@0
|
4392 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@0
|
4393 #else
|
Chris@0
|
4394 version = tr("Release %1").arg(SV_VERSION);
|
Chris@0
|
4395 #endif
|
Chris@0
|
4396 #else
|
Chris@0
|
4397 #ifdef SVNREV
|
Chris@0
|
4398 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@0
|
4399 #endif
|
Chris@0
|
4400 #endif
|
Chris@0
|
4401
|
Chris@0
|
4402 QString aboutText;
|
Chris@0
|
4403
|
Chris@0
|
4404 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@90
|
4405 aboutText += tr("<p>Sonic Visualiser is a program for viewing and exploring audio data for<br>semantic music analysis and annotation.</p>");
|
Chris@111
|
4406 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
4407 .arg(version)
|
Chris@0
|
4408 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
4409
|
Chris@0
|
4410 #ifdef BUILD_STATIC
|
Chris@0
|
4411 aboutText += tr("<p>Statically linked");
|
Chris@0
|
4412 #ifndef QT_SHARED
|
Chris@0
|
4413 aboutText += tr("<br>With Qt (v%1) © Trolltech AS").arg(QT_VERSION_STR);
|
Chris@0
|
4414 #endif
|
Chris@0
|
4415 #ifdef HAVE_JACK
|
Chris@93
|
4416 #ifdef JACK_VERSION
|
Chris@0
|
4417 aboutText += tr("<br>With JACK audio output (v%1) © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@93
|
4418 #else
|
Chris@93
|
4419 aboutText += tr("<br>With JACK audio output © Paul Davis and Jack O'Quin");
|
Chris@93
|
4420 #endif
|
Chris@0
|
4421 #endif
|
Chris@0
|
4422 #ifdef HAVE_PORTAUDIO
|
Chris@0
|
4423 aboutText += tr("<br>With PortAudio audio output © Ross Bencina and Phil Burk");
|
Chris@0
|
4424 #endif
|
Chris@0
|
4425 #ifdef HAVE_OGGZ
|
Chris@93
|
4426 #ifdef OGGZ_VERSION
|
Chris@0
|
4427 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@93
|
4428 #else
|
Chris@93
|
4429 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@93
|
4430 #endif
|
Chris@0
|
4431 #endif
|
Chris@0
|
4432 #ifdef HAVE_MAD
|
Chris@93
|
4433 #ifdef MAD_VERSION
|
Chris@0
|
4434 aboutText += tr("<br>With MAD mp3 decoder (v%1) © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@93
|
4435 #else
|
Chris@93
|
4436 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@93
|
4437 #endif
|
Chris@0
|
4438 #endif
|
Chris@0
|
4439 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
4440 #ifdef SAMPLERATE_VERSION
|
Chris@0
|
4441 aboutText += tr("<br>With libsamplerate (v%1) © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@93
|
4442 #else
|
Chris@93
|
4443 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@93
|
4444 #endif
|
Chris@0
|
4445 #endif
|
Chris@0
|
4446 #ifdef HAVE_SNDFILE
|
Chris@93
|
4447 #ifdef SNDFILE_VERSION
|
Chris@0
|
4448 aboutText += tr("<br>With libsndfile (v%1) © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@93
|
4449 #else
|
Chris@93
|
4450 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@93
|
4451 #endif
|
Chris@0
|
4452 #endif
|
Chris@0
|
4453 #ifdef HAVE_FFTW3
|
Chris@93
|
4454 #ifdef FFTW3_VERSION
|
Chris@0
|
4455 aboutText += tr("<br>With FFTW3 (v%1) © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@93
|
4456 #else
|
Chris@93
|
4457 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@93
|
4458 #endif
|
Chris@0
|
4459 #endif
|
Chris@0
|
4460 #ifdef HAVE_VAMP
|
Chris@0
|
4461 aboutText += tr("<br>With Vamp plugin support (API v%1, SDK v%2) © Chris Cannam").arg(VAMP_API_VERSION).arg(VAMP_SDK_VERSION);
|
Chris@0
|
4462 #endif
|
Chris@0
|
4463 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
4464 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@69
|
4465 #ifdef HAVE_LIBLO
|
Chris@93
|
4466 #ifdef LIBLO_VERSION
|
Chris@69
|
4467 aboutText += tr("<br>With liblo Lite OSC library (v%1) © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
4468 #else
|
Chris@93
|
4469 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
4470 #endif
|
Chris@70
|
4471 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@69
|
4472 aboutText += tr("<p>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@69
|
4473 }
|
Chris@69
|
4474 #endif
|
Chris@0
|
4475 aboutText += "</p>";
|
Chris@0
|
4476 #endif
|
Chris@0
|
4477
|
Chris@0
|
4478 aboutText +=
|
Chris@90
|
4479 "<p>Sonic Visualiser Copyright © 2005 - 2007 Chris Cannam and<br>"
|
Chris@90
|
4480 "Queen Mary, University of London.</p>"
|
Chris@0
|
4481 "<p>This program is free software; you can redistribute it and/or<br>"
|
Chris@0
|
4482 "modify it under the terms of the GNU General Public License as<br>"
|
Chris@0
|
4483 "published by the Free Software Foundation; either version 2 of the<br>"
|
Chris@0
|
4484 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
4485 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
4486
|
Chris@0
|
4487 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
|
Chris@0
|
4488 }
|
Chris@0
|
4489
|