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@90
|
1245 QString tip;
|
Chris@90
|
1246 if (output == "") {
|
Chris@90
|
1247 tip = tr("Transform with \"%1\" plugin (from %3)")
|
Chris@90
|
1248 .arg(pluginName).arg(maker);
|
Chris@90
|
1249 } else {
|
Chris@90
|
1250 tip = tr("Transform with \"%1\" output of \"%2\" plugin (from %3)")
|
Chris@90
|
1251 .arg(output).arg(pluginName).arg(maker);
|
Chris@90
|
1252 }
|
Chris@90
|
1253 action->setStatusTip(tip);
|
Chris@90
|
1254
|
Chris@33
|
1255 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
|
Chris@33
|
1256 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1257 << "No category menu for transform \""
|
Chris@107
|
1258 << name.toStdString() << "\" (category = \""
|
Chris@33
|
1259 << category.toStdString() << "\")" << std::endl;
|
Chris@33
|
1260 } else {
|
Chris@33
|
1261 categoryMenus[type][category]->addAction(action);
|
Chris@33
|
1262 }
|
Chris@33
|
1263
|
Chris@33
|
1264 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
|
Chris@33
|
1265 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1266 << "No maker menu for transform \""
|
Chris@107
|
1267 << name.toStdString() << "\" (maker = \""
|
Chris@33
|
1268 << maker.toStdString() << "\")" << std::endl;
|
Chris@33
|
1269 } else {
|
Chris@80
|
1270 makerMenus[type][maker]->addAction(action);
|
Chris@33
|
1271 }
|
Chris@33
|
1272
|
Chris@33
|
1273 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
|
Chris@33
|
1274 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1275 m_transformActions[action] = transforms[i].identifier;
|
Chris@33
|
1276 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@90
|
1277 action->setStatusTip(tip);
|
Chris@33
|
1278
|
Chris@34
|
1279 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl;
|
Chris@34
|
1280
|
Chris@33
|
1281 if (pluginNameMenus[type].find(pluginName) ==
|
Chris@33
|
1282 pluginNameMenus[type].end()) {
|
Chris@33
|
1283
|
Chris@36
|
1284 SubdividingMenu *parentMenu = byPluginNameMenus[type];
|
Chris@97
|
1285 parentMenu->setTearOffEnabled(true);
|
Chris@34
|
1286
|
Chris@33
|
1287 if (output == "") {
|
Chris@36
|
1288 parentMenu->addAction(pluginName, action);
|
Chris@33
|
1289 } else {
|
Chris@34
|
1290 pluginNameMenus[type][pluginName] =
|
Chris@34
|
1291 parentMenu->addMenu(pluginName);
|
Chris@33
|
1292 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@33
|
1293 pluginNameMenus[type][pluginName],
|
Chris@33
|
1294 SLOT(setEnabled(bool)));
|
Chris@33
|
1295 }
|
Chris@33
|
1296 }
|
Chris@33
|
1297
|
Chris@33
|
1298 if (pluginNameMenus[type].find(pluginName) !=
|
Chris@33
|
1299 pluginNameMenus[type].end()) {
|
Chris@33
|
1300 pluginNameMenus[type][pluginName]->addAction(action);
|
Chris@33
|
1301 }
|
Chris@0
|
1302 }
|
Chris@0
|
1303
|
Chris@37
|
1304 for (set<SubdividingMenu *>::iterator i = pendingMenus.begin();
|
Chris@37
|
1305 i != pendingMenus.end(); ++i) {
|
Chris@37
|
1306 (*i)->entriesAdded();
|
Chris@37
|
1307 }
|
Chris@37
|
1308
|
Chris@34
|
1309 setupRecentTransformsMenu();
|
Chris@66
|
1310 }
|
Chris@66
|
1311
|
Chris@66
|
1312 void
|
Chris@66
|
1313 MainWindow::setupHelpMenu()
|
Chris@66
|
1314 {
|
Chris@66
|
1315 if (m_mainMenusCreated) return;
|
Chris@66
|
1316
|
Chris@66
|
1317 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@97
|
1318 menu->setTearOffEnabled(true);
|
Chris@66
|
1319
|
Chris@66
|
1320 QAction *action = new QAction(tr("&Help Reference"), this);
|
Chris@66
|
1321 action->setStatusTip(tr("Open the Sonic Visualiser reference manual"));
|
Chris@66
|
1322 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
1323 menu->addAction(action);
|
Chris@0
|
1324
|
Chris@66
|
1325 action = new QAction(tr("Sonic Visualiser on the &Web"), this);
|
Chris@66
|
1326 action->setStatusTip(tr("Open the Sonic Visualiser website"));
|
Chris@66
|
1327 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
1328 menu->addAction(action);
|
Chris@66
|
1329
|
Chris@66
|
1330 action = new QAction(tr("&About Sonic Visualiser"), this);
|
Chris@66
|
1331 action->setStatusTip(tr("Show information about Sonic Visualiser"));
|
Chris@66
|
1332 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
1333 menu->addAction(action);
|
Chris@0
|
1334 }
|
Chris@0
|
1335
|
Chris@0
|
1336 void
|
Chris@0
|
1337 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
1338 {
|
Chris@0
|
1339 m_recentFilesMenu->clear();
|
Chris@34
|
1340 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
1341 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@0
|
1342 QAction *action = new QAction(files[i], this);
|
Chris@0
|
1343 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
1344 m_recentFilesMenu->addAction(action);
|
Chris@0
|
1345 }
|
Chris@0
|
1346 }
|
Chris@0
|
1347
|
Chris@0
|
1348 void
|
Chris@34
|
1349 MainWindow::setupRecentTransformsMenu()
|
Chris@34
|
1350 {
|
Chris@34
|
1351 m_recentTransformsMenu->clear();
|
Chris@34
|
1352 vector<QString> transforms = m_recentTransforms.getRecent();
|
Chris@34
|
1353 for (size_t i = 0; i < transforms.size(); ++i) {
|
Chris@34
|
1354 TransformActionReverseMap::iterator ti =
|
Chris@34
|
1355 m_transformActionsReverse.find(transforms[i]);
|
Chris@34
|
1356 if (ti == m_transformActionsReverse.end()) {
|
Chris@34
|
1357 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
|
Chris@34
|
1358 << "Unknown transform \"" << transforms[i].toStdString()
|
Chris@34
|
1359 << "\" in recent transforms list" << std::endl;
|
Chris@34
|
1360 continue;
|
Chris@34
|
1361 }
|
Chris@34
|
1362 m_recentTransformsMenu->addAction(ti->second);
|
Chris@34
|
1363 }
|
Chris@34
|
1364 }
|
Chris@34
|
1365
|
Chris@34
|
1366 void
|
Chris@95
|
1367 MainWindow::setupExistingLayersMenus()
|
Chris@0
|
1368 {
|
Chris@0
|
1369 if (!m_existingLayersMenu) return; // should have been created by setupMenus
|
Chris@0
|
1370
|
Chris@0
|
1371 // std::cerr << "MainWindow::setupExistingLayersMenu" << std::endl;
|
Chris@0
|
1372
|
Chris@0
|
1373 m_existingLayersMenu->clear();
|
Chris@0
|
1374 m_existingLayerActions.clear();
|
Chris@0
|
1375
|
Chris@95
|
1376 m_sliceMenu->clear();
|
Chris@95
|
1377 m_sliceActions.clear();
|
Chris@95
|
1378
|
Chris@33
|
1379 vector<Layer *> orderedLayers;
|
Chris@33
|
1380 set<Layer *> observedLayers;
|
Chris@95
|
1381 set<Layer *> sliceableLayers;
|
Chris@95
|
1382
|
Chris@95
|
1383 LayerFactory *factory = LayerFactory::getInstance();
|
Chris@0
|
1384
|
Chris@0
|
1385 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
1386
|
Chris@0
|
1387 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
1388 if (!pane) continue;
|
Chris@0
|
1389
|
Chris@0
|
1390 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
1391
|
Chris@0
|
1392 Layer *layer = pane->getLayer(j);
|
Chris@0
|
1393 if (!layer) continue;
|
Chris@0
|
1394 if (observedLayers.find(layer) != observedLayers.end()) {
|
Chris@0
|
1395 std::cerr << "found duplicate layer " << layer << std::endl;
|
Chris@0
|
1396 continue;
|
Chris@0
|
1397 }
|
Chris@0
|
1398
|
Chris@0
|
1399 // std::cerr << "found new layer " << layer << " (name = "
|
Chris@0
|
1400 // << layer->getLayerPresentationName().toStdString() << ")" << std::endl;
|
Chris@0
|
1401
|
Chris@0
|
1402 orderedLayers.push_back(layer);
|
Chris@0
|
1403 observedLayers.insert(layer);
|
Chris@95
|
1404
|
Chris@95
|
1405 if (factory->isLayerSliceable(layer)) {
|
Chris@95
|
1406 sliceableLayers.insert(layer);
|
Chris@95
|
1407 }
|
Chris@0
|
1408 }
|
Chris@0
|
1409 }
|
Chris@0
|
1410
|
Chris@33
|
1411 map<QString, int> observedNames;
|
Chris@0
|
1412
|
Chris@0
|
1413 for (int i = 0; i < orderedLayers.size(); ++i) {
|
Chris@0
|
1414
|
Chris@95
|
1415 Layer *layer = orderedLayers[i];
|
Chris@95
|
1416
|
Chris@95
|
1417 QString name = layer->getLayerPresentationName();
|
Chris@0
|
1418 int n = ++observedNames[name];
|
Chris@0
|
1419 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n);
|
Chris@0
|
1420
|
Chris@95
|
1421 QIcon icon = QIcon(QString(":/icons/%1.png")
|
Chris@95
|
1422 .arg(factory->getLayerIconName
|
Chris@95
|
1423 (factory->getLayerType(layer))));
|
Chris@95
|
1424
|
Chris@95
|
1425 QAction *action = new QAction(icon, name, this);
|
Chris@0
|
1426 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@0
|
1427 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1428 m_existingLayerActions[action] = layer;
|
Chris@0
|
1429
|
Chris@0
|
1430 m_existingLayersMenu->addAction(action);
|
Chris@95
|
1431
|
Chris@95
|
1432 if (sliceableLayers.find(layer) != sliceableLayers.end()) {
|
Chris@95
|
1433 action = new QAction(icon, name, this);
|
Chris@95
|
1434 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@95
|
1435 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1436 m_sliceActions[action] = layer;
|
Chris@95
|
1437 m_sliceMenu->addAction(action);
|
Chris@95
|
1438 }
|
Chris@0
|
1439 }
|
Chris@95
|
1440
|
Chris@95
|
1441 m_sliceMenu->setEnabled(!m_sliceActions.empty());
|
Chris@0
|
1442 }
|
Chris@0
|
1443
|
Chris@0
|
1444 void
|
Chris@0
|
1445 MainWindow::setupToolbars()
|
Chris@0
|
1446 {
|
Chris@0
|
1447 QToolBar *toolbar = addToolBar(tr("Transport Toolbar"));
|
Chris@0
|
1448
|
Chris@0
|
1449 QAction *action = toolbar->addAction(QIcon(":/icons/rewind-start.png"),
|
Chris@0
|
1450 tr("Rewind to Start"));
|
Chris@0
|
1451 action->setShortcut(tr("Home"));
|
Chris@0
|
1452 action->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
1453 connect(action, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
1454 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1455
|
Chris@0
|
1456 action = toolbar->addAction(QIcon(":/icons/rewind.png"),
|
Chris@0
|
1457 tr("Rewind"));
|
Chris@0
|
1458 action->setShortcut(tr("PageUp"));
|
Chris@0
|
1459 action->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1460 connect(action, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
1461 connect(this, SIGNAL(canRewind(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1462
|
Chris@0
|
1463 action = toolbar->addAction(QIcon(":/icons/playpause.png"),
|
Chris@0
|
1464 tr("Play / Pause"));
|
Chris@0
|
1465 action->setCheckable(true);
|
Chris@0
|
1466 action->setShortcut(tr("Space"));
|
Chris@0
|
1467 action->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
1468 connect(action, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
1469 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@0
|
1470 action, SLOT(setChecked(bool)));
|
Chris@0
|
1471 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1472
|
Chris@0
|
1473 action = toolbar->addAction(QIcon(":/icons/ffwd.png"),
|
Chris@0
|
1474 tr("Fast Forward"));
|
Chris@0
|
1475 action->setShortcut(tr("PageDown"));
|
Chris@0
|
1476 action->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1477 connect(action, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
1478 connect(this, SIGNAL(canFfwd(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1479
|
Chris@0
|
1480 action = toolbar->addAction(QIcon(":/icons/ffwd-end.png"),
|
Chris@0
|
1481 tr("Fast Forward to End"));
|
Chris@0
|
1482 action->setShortcut(tr("End"));
|
Chris@0
|
1483 action->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
1484 connect(action, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
1485 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1486
|
Chris@0
|
1487 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
1488
|
Chris@0
|
1489 action = toolbar->addAction(QIcon(":/icons/playselection.png"),
|
Chris@0
|
1490 tr("Constrain Playback to Selection"));
|
Chris@0
|
1491 action->setCheckable(true);
|
Chris@0
|
1492 action->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
1493 action->setShortcut(tr("s"));
|
Chris@0
|
1494 action->setStatusTip(tr("Constrain playback to the selected area"));
|
Chris@69
|
1495 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@69
|
1496 action, SLOT(setChecked(bool)));
|
Chris@0
|
1497 connect(action, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
1498 connect(this, SIGNAL(canPlaySelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1499
|
Chris@0
|
1500 action = toolbar->addAction(QIcon(":/icons/playloop.png"),
|
Chris@0
|
1501 tr("Loop Playback"));
|
Chris@0
|
1502 action->setCheckable(true);
|
Chris@0
|
1503 action->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
1504 action->setShortcut(tr("l"));
|
Chris@0
|
1505 action->setStatusTip(tr("Loop playback"));
|
Chris@69
|
1506 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@69
|
1507 action, SLOT(setChecked(bool)));
|
Chris@0
|
1508 connect(action, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
1509 connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1510
|
Chris@0
|
1511 toolbar = addToolBar(tr("Edit Toolbar"));
|
Chris@0
|
1512 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@0
|
1513
|
Chris@0
|
1514 toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@0
|
1515 QActionGroup *group = new QActionGroup(this);
|
Chris@0
|
1516
|
Chris@0
|
1517 action = toolbar->addAction(QIcon(":/icons/navigate.png"),
|
Chris@0
|
1518 tr("Navigate"));
|
Chris@0
|
1519 action->setCheckable(true);
|
Chris@0
|
1520 action->setChecked(true);
|
Chris@0
|
1521 action->setShortcut(tr("1"));
|
Chris@90
|
1522 action->setStatusTip(tr("Navigate"));
|
Chris@0
|
1523 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@0
|
1524 group->addAction(action);
|
Chris@0
|
1525 m_toolActions[ViewManager::NavigateMode] = action;
|
Chris@0
|
1526
|
Chris@0
|
1527 action = toolbar->addAction(QIcon(":/icons/select.png"),
|
Chris@0
|
1528 tr("Select"));
|
Chris@0
|
1529 action->setCheckable(true);
|
Chris@0
|
1530 action->setShortcut(tr("2"));
|
Chris@90
|
1531 action->setStatusTip(tr("Select ranges"));
|
Chris@0
|
1532 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected()));
|
Chris@0
|
1533 group->addAction(action);
|
Chris@0
|
1534 m_toolActions[ViewManager::SelectMode] = action;
|
Chris@0
|
1535
|
Chris@0
|
1536 action = toolbar->addAction(QIcon(":/icons/move.png"),
|
Chris@0
|
1537 tr("Edit"));
|
Chris@0
|
1538 action->setCheckable(true);
|
Chris@0
|
1539 action->setShortcut(tr("3"));
|
Chris@90
|
1540 action->setStatusTip(tr("Edit items in layer"));
|
Chris@0
|
1541 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@0
|
1542 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1543 group->addAction(action);
|
Chris@0
|
1544 m_toolActions[ViewManager::EditMode] = action;
|
Chris@0
|
1545
|
Chris@0
|
1546 action = toolbar->addAction(QIcon(":/icons/draw.png"),
|
Chris@0
|
1547 tr("Draw"));
|
Chris@0
|
1548 action->setCheckable(true);
|
Chris@0
|
1549 action->setShortcut(tr("4"));
|
Chris@90
|
1550 action->setStatusTip(tr("Draw new items in layer"));
|
Chris@0
|
1551 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected()));
|
Chris@0
|
1552 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1553 group->addAction(action);
|
Chris@0
|
1554 m_toolActions[ViewManager::DrawMode] = action;
|
Chris@0
|
1555
|
Chris@0
|
1556 // action = toolbar->addAction(QIcon(":/icons/text.png"),
|
Chris@0
|
1557 // tr("Text"));
|
Chris@0
|
1558 // action->setCheckable(true);
|
Chris@0
|
1559 // action->setShortcut(tr("5"));
|
Chris@0
|
1560 // connect(action, SIGNAL(triggered()), this, SLOT(toolTextSelected()));
|
Chris@0
|
1561 // group->addAction(action);
|
Chris@0
|
1562 // m_toolActions[ViewManager::TextMode] = action;
|
Chris@0
|
1563
|
Chris@0
|
1564 toolNavigateSelected();
|
Chris@0
|
1565 }
|
Chris@0
|
1566
|
Chris@0
|
1567 void
|
Chris@0
|
1568 MainWindow::updateMenuStates()
|
Chris@0
|
1569 {
|
Chris@0
|
1570 bool haveCurrentPane =
|
Chris@0
|
1571 (m_paneStack &&
|
Chris@0
|
1572 (m_paneStack->getCurrentPane() != 0));
|
Chris@0
|
1573 bool haveCurrentLayer =
|
Chris@0
|
1574 (haveCurrentPane &&
|
Chris@0
|
1575 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1576 bool haveMainModel =
|
Chris@0
|
1577 (getMainModel() != 0);
|
Chris@0
|
1578 bool havePlayTarget =
|
Chris@0
|
1579 (m_playTarget != 0);
|
Chris@0
|
1580 bool haveSelection =
|
Chris@0
|
1581 (m_viewManager &&
|
Chris@0
|
1582 !m_viewManager->getSelections().empty());
|
Chris@0
|
1583 bool haveCurrentEditableLayer =
|
Chris@0
|
1584 (haveCurrentLayer &&
|
Chris@0
|
1585 m_paneStack->getCurrentPane()->getSelectedLayer()->
|
Chris@0
|
1586 isLayerEditable());
|
Chris@0
|
1587 bool haveCurrentTimeInstantsLayer =
|
Chris@0
|
1588 (haveCurrentLayer &&
|
Chris@0
|
1589 dynamic_cast<TimeInstantLayer *>
|
Chris@0
|
1590 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1591 bool haveCurrentTimeValueLayer =
|
Chris@0
|
1592 (haveCurrentLayer &&
|
Chris@0
|
1593 dynamic_cast<TimeValueLayer *>
|
Chris@0
|
1594 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1595 bool haveCurrentColour3DPlot =
|
Chris@0
|
1596 (haveCurrentLayer &&
|
Chris@0
|
1597 dynamic_cast<Colour3DPlotLayer *>
|
Chris@0
|
1598 (m_paneStack->getCurrentPane()->getSelectedLayer()));
|
Chris@0
|
1599 bool haveClipboardContents =
|
Chris@0
|
1600 (m_viewManager &&
|
Chris@0
|
1601 !m_viewManager->getClipboard().empty());
|
Chris@0
|
1602
|
Chris@0
|
1603 emit canAddPane(haveMainModel);
|
Chris@0
|
1604 emit canDeleteCurrentPane(haveCurrentPane);
|
Chris@0
|
1605 emit canZoom(haveMainModel && haveCurrentPane);
|
Chris@0
|
1606 emit canScroll(haveMainModel && haveCurrentPane);
|
Chris@0
|
1607 emit canAddLayer(haveMainModel && haveCurrentPane);
|
Chris@0
|
1608 emit canImportMoreAudio(haveMainModel);
|
Chris@0
|
1609 emit canImportLayer(haveMainModel && haveCurrentPane);
|
Chris@0
|
1610 emit canExportAudio(haveMainModel);
|
Chris@0
|
1611 emit canExportLayer(haveMainModel &&
|
Chris@0
|
1612 (haveCurrentEditableLayer || haveCurrentColour3DPlot));
|
Chris@0
|
1613 emit canDeleteCurrentLayer(haveCurrentLayer);
|
Chris@0
|
1614 emit canRenameLayer(haveCurrentLayer);
|
Chris@0
|
1615 emit canEditLayer(haveCurrentEditableLayer);
|
Chris@0
|
1616 emit canSelect(haveMainModel && haveCurrentPane);
|
Chris@0
|
1617 emit canPlay(/*!!! haveMainModel && */ havePlayTarget);
|
Chris@0
|
1618 emit canFfwd(haveCurrentTimeInstantsLayer || haveCurrentTimeValueLayer);
|
Chris@0
|
1619 emit canRewind(haveCurrentTimeInstantsLayer || haveCurrentTimeValueLayer);
|
Chris@0
|
1620 emit canPaste(haveCurrentEditableLayer && haveClipboardContents);
|
Chris@0
|
1621 emit canInsertInstant(haveCurrentPane);
|
Chris@81
|
1622 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection);
|
Chris@0
|
1623 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
|
Chris@0
|
1624 emit canClearSelection(haveSelection);
|
Chris@0
|
1625 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
|
Chris@0
|
1626 emit canSave(m_sessionFile != "" && m_documentModified);
|
Chris@0
|
1627 }
|
Chris@0
|
1628
|
Chris@0
|
1629 void
|
Chris@0
|
1630 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1631 {
|
Chris@0
|
1632 if (!getMainModel()) {
|
Chris@0
|
1633 m_descriptionLabel->setText(tr("No audio file loaded."));
|
Chris@0
|
1634 return;
|
Chris@0
|
1635 }
|
Chris@0
|
1636
|
Chris@0
|
1637 QString description;
|
Chris@0
|
1638
|
Chris@0
|
1639 size_t ssr = getMainModel()->getSampleRate();
|
Chris@0
|
1640 size_t tsr = ssr;
|
Chris@0
|
1641 if (m_playSource) tsr = m_playSource->getTargetSampleRate();
|
Chris@0
|
1642
|
Chris@0
|
1643 if (ssr != tsr) {
|
Chris@0
|
1644 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
|
Chris@0
|
1645 } else {
|
Chris@0
|
1646 description = QString("%1Hz").arg(ssr);
|
Chris@0
|
1647 }
|
Chris@0
|
1648
|
Chris@0
|
1649 description = QString("%1 - %2")
|
Chris@0
|
1650 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr)
|
Chris@0
|
1651 .toText(false).c_str())
|
Chris@0
|
1652 .arg(description);
|
Chris@0
|
1653
|
Chris@0
|
1654 m_descriptionLabel->setText(description);
|
Chris@0
|
1655 }
|
Chris@0
|
1656
|
Chris@0
|
1657 void
|
Chris@0
|
1658 MainWindow::documentModified()
|
Chris@0
|
1659 {
|
Chris@0
|
1660 // std::cerr << "MainWindow::documentModified" << std::endl;
|
Chris@0
|
1661
|
Chris@0
|
1662 if (!m_documentModified) {
|
Chris@0
|
1663 setWindowTitle(tr("%1 (modified)").arg(windowTitle()));
|
Chris@0
|
1664 }
|
Chris@0
|
1665
|
Chris@0
|
1666 m_documentModified = true;
|
Chris@0
|
1667 updateMenuStates();
|
Chris@0
|
1668 }
|
Chris@0
|
1669
|
Chris@0
|
1670 void
|
Chris@0
|
1671 MainWindow::documentRestored()
|
Chris@0
|
1672 {
|
Chris@0
|
1673 // std::cerr << "MainWindow::documentRestored" << std::endl;
|
Chris@0
|
1674
|
Chris@0
|
1675 if (m_documentModified) {
|
Chris@0
|
1676 QString wt(windowTitle());
|
Chris@0
|
1677 wt.replace(tr(" (modified)"), "");
|
Chris@0
|
1678 setWindowTitle(wt);
|
Chris@0
|
1679 }
|
Chris@0
|
1680
|
Chris@0
|
1681 m_documentModified = false;
|
Chris@0
|
1682 updateMenuStates();
|
Chris@0
|
1683 }
|
Chris@0
|
1684
|
Chris@0
|
1685 void
|
Chris@0
|
1686 MainWindow::playLoopToggled()
|
Chris@0
|
1687 {
|
Chris@0
|
1688 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@0
|
1689
|
Chris@0
|
1690 if (action) {
|
Chris@0
|
1691 m_viewManager->setPlayLoopMode(action->isChecked());
|
Chris@0
|
1692 } else {
|
Chris@0
|
1693 m_viewManager->setPlayLoopMode(!m_viewManager->getPlayLoopMode());
|
Chris@0
|
1694 }
|
Chris@0
|
1695 }
|
Chris@0
|
1696
|
Chris@0
|
1697 void
|
Chris@0
|
1698 MainWindow::playSelectionToggled()
|
Chris@0
|
1699 {
|
Chris@0
|
1700 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@0
|
1701
|
Chris@0
|
1702 if (action) {
|
Chris@0
|
1703 m_viewManager->setPlaySelectionMode(action->isChecked());
|
Chris@0
|
1704 } else {
|
Chris@0
|
1705 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode());
|
Chris@0
|
1706 }
|
Chris@0
|
1707 }
|
Chris@0
|
1708
|
Chris@0
|
1709 void
|
Chris@0
|
1710 MainWindow::currentPaneChanged(Pane *)
|
Chris@0
|
1711 {
|
Chris@0
|
1712 updateMenuStates();
|
Chris@0
|
1713 }
|
Chris@0
|
1714
|
Chris@0
|
1715 void
|
Chris@0
|
1716 MainWindow::currentLayerChanged(Pane *, Layer *)
|
Chris@0
|
1717 {
|
Chris@0
|
1718 updateMenuStates();
|
Chris@0
|
1719 }
|
Chris@0
|
1720
|
Chris@0
|
1721 void
|
Chris@0
|
1722 MainWindow::toolNavigateSelected()
|
Chris@0
|
1723 {
|
Chris@0
|
1724 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
1725 }
|
Chris@0
|
1726
|
Chris@0
|
1727 void
|
Chris@0
|
1728 MainWindow::toolSelectSelected()
|
Chris@0
|
1729 {
|
Chris@0
|
1730 m_viewManager->setToolMode(ViewManager::SelectMode);
|
Chris@0
|
1731 }
|
Chris@0
|
1732
|
Chris@0
|
1733 void
|
Chris@0
|
1734 MainWindow::toolEditSelected()
|
Chris@0
|
1735 {
|
Chris@0
|
1736 m_viewManager->setToolMode(ViewManager::EditMode);
|
Chris@0
|
1737 }
|
Chris@0
|
1738
|
Chris@0
|
1739 void
|
Chris@0
|
1740 MainWindow::toolDrawSelected()
|
Chris@0
|
1741 {
|
Chris@0
|
1742 m_viewManager->setToolMode(ViewManager::DrawMode);
|
Chris@0
|
1743 }
|
Chris@0
|
1744
|
Chris@0
|
1745 //void
|
Chris@0
|
1746 //MainWindow::toolTextSelected()
|
Chris@0
|
1747 //{
|
Chris@0
|
1748 // m_viewManager->setToolMode(ViewManager::TextMode);
|
Chris@0
|
1749 //}
|
Chris@0
|
1750
|
Chris@0
|
1751 void
|
Chris@0
|
1752 MainWindow::selectAll()
|
Chris@0
|
1753 {
|
Chris@0
|
1754 if (!getMainModel()) return;
|
Chris@0
|
1755 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(),
|
Chris@0
|
1756 getMainModel()->getEndFrame()));
|
Chris@0
|
1757 }
|
Chris@0
|
1758
|
Chris@0
|
1759 void
|
Chris@0
|
1760 MainWindow::selectToStart()
|
Chris@0
|
1761 {
|
Chris@0
|
1762 if (!getMainModel()) return;
|
Chris@0
|
1763 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(),
|
Chris@0
|
1764 m_viewManager->getGlobalCentreFrame()));
|
Chris@0
|
1765 }
|
Chris@0
|
1766
|
Chris@0
|
1767 void
|
Chris@0
|
1768 MainWindow::selectToEnd()
|
Chris@0
|
1769 {
|
Chris@0
|
1770 if (!getMainModel()) return;
|
Chris@0
|
1771 m_viewManager->setSelection(Selection(m_viewManager->getGlobalCentreFrame(),
|
Chris@0
|
1772 getMainModel()->getEndFrame()));
|
Chris@0
|
1773 }
|
Chris@0
|
1774
|
Chris@0
|
1775 void
|
Chris@0
|
1776 MainWindow::selectVisible()
|
Chris@0
|
1777 {
|
Chris@0
|
1778 Model *model = getMainModel();
|
Chris@0
|
1779 if (!model) return;
|
Chris@0
|
1780
|
Chris@0
|
1781 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1782 if (!currentPane) return;
|
Chris@0
|
1783
|
Chris@0
|
1784 size_t startFrame, endFrame;
|
Chris@0
|
1785
|
Chris@0
|
1786 if (currentPane->getStartFrame() < 0) startFrame = 0;
|
Chris@0
|
1787 else startFrame = currentPane->getStartFrame();
|
Chris@0
|
1788
|
Chris@0
|
1789 if (currentPane->getEndFrame() > model->getEndFrame()) endFrame = model->getEndFrame();
|
Chris@0
|
1790 else endFrame = currentPane->getEndFrame();
|
Chris@0
|
1791
|
Chris@0
|
1792 m_viewManager->setSelection(Selection(startFrame, endFrame));
|
Chris@0
|
1793 }
|
Chris@0
|
1794
|
Chris@0
|
1795 void
|
Chris@0
|
1796 MainWindow::clearSelection()
|
Chris@0
|
1797 {
|
Chris@0
|
1798 m_viewManager->clearSelections();
|
Chris@0
|
1799 }
|
Chris@0
|
1800
|
Chris@0
|
1801 void
|
Chris@0
|
1802 MainWindow::cut()
|
Chris@0
|
1803 {
|
Chris@0
|
1804 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1805 if (!currentPane) return;
|
Chris@0
|
1806
|
Chris@0
|
1807 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1808 if (!layer) return;
|
Chris@0
|
1809
|
Chris@0
|
1810 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1811 clipboard.clear();
|
Chris@0
|
1812
|
Chris@0
|
1813 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
1814
|
Chris@0
|
1815 CommandHistory::getInstance()->startCompoundOperation(tr("Cut"), true);
|
Chris@0
|
1816
|
Chris@0
|
1817 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1818 i != selections.end(); ++i) {
|
Chris@0
|
1819 layer->copy(*i, clipboard);
|
Chris@0
|
1820 layer->deleteSelection(*i);
|
Chris@0
|
1821 }
|
Chris@0
|
1822
|
Chris@0
|
1823 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
1824 }
|
Chris@0
|
1825
|
Chris@0
|
1826 void
|
Chris@0
|
1827 MainWindow::copy()
|
Chris@0
|
1828 {
|
Chris@0
|
1829 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1830 if (!currentPane) return;
|
Chris@0
|
1831
|
Chris@0
|
1832 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1833 if (!layer) return;
|
Chris@0
|
1834
|
Chris@0
|
1835 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1836 clipboard.clear();
|
Chris@0
|
1837
|
Chris@0
|
1838 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
1839
|
Chris@0
|
1840 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1841 i != selections.end(); ++i) {
|
Chris@0
|
1842 layer->copy(*i, clipboard);
|
Chris@0
|
1843 }
|
Chris@0
|
1844 }
|
Chris@0
|
1845
|
Chris@0
|
1846 void
|
Chris@0
|
1847 MainWindow::paste()
|
Chris@0
|
1848 {
|
Chris@0
|
1849 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1850 if (!currentPane) return;
|
Chris@0
|
1851
|
Chris@0
|
1852 //!!! if we have no current layer, we should create one of the most
|
Chris@0
|
1853 // appropriate type
|
Chris@0
|
1854
|
Chris@0
|
1855 Layer *layer = currentPane->getSelectedLayer();
|
Chris@0
|
1856 if (!layer) return;
|
Chris@0
|
1857
|
Chris@0
|
1858 Clipboard &clipboard = m_viewManager->getClipboard();
|
Chris@0
|
1859 Clipboard::PointList contents = clipboard.getPoints();
|
Chris@0
|
1860 /*
|
Chris@0
|
1861 long minFrame = 0;
|
Chris@0
|
1862 bool have = false;
|
Chris@0
|
1863 for (int i = 0; i < contents.size(); ++i) {
|
Chris@0
|
1864 if (!contents[i].haveFrame()) continue;
|
Chris@0
|
1865 if (!have || contents[i].getFrame() < minFrame) {
|
Chris@0
|
1866 minFrame = contents[i].getFrame();
|
Chris@0
|
1867 have = true;
|
Chris@0
|
1868 }
|
Chris@0
|
1869 }
|
Chris@0
|
1870
|
Chris@0
|
1871 long frameOffset = long(m_viewManager->getGlobalCentreFrame()) - minFrame;
|
Chris@0
|
1872
|
Chris@0
|
1873 layer->paste(clipboard, frameOffset);
|
Chris@0
|
1874 */
|
Chris@0
|
1875 layer->paste(clipboard, 0, true);
|
Chris@0
|
1876 }
|
Chris@0
|
1877
|
Chris@0
|
1878 void
|
Chris@0
|
1879 MainWindow::deleteSelected()
|
Chris@0
|
1880 {
|
Chris@0
|
1881 if (m_paneStack->getCurrentPane() &&
|
Chris@0
|
1882 m_paneStack->getCurrentPane()->getSelectedLayer()) {
|
Chris@0
|
1883
|
Chris@0
|
1884 MultiSelection::SelectionList selections =
|
Chris@0
|
1885 m_viewManager->getSelections();
|
Chris@0
|
1886
|
Chris@0
|
1887 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
1888 i != selections.end(); ++i) {
|
Chris@0
|
1889
|
Chris@0
|
1890 m_paneStack->getCurrentPane()->getSelectedLayer()->deleteSelection(*i);
|
Chris@0
|
1891 }
|
Chris@0
|
1892 }
|
Chris@0
|
1893 }
|
Chris@0
|
1894
|
Chris@0
|
1895 void
|
Chris@0
|
1896 MainWindow::insertInstant()
|
Chris@0
|
1897 {
|
Chris@0
|
1898 int frame = m_viewManager->getPlaybackFrame();
|
Chris@81
|
1899 insertInstantAt(frame);
|
Chris@81
|
1900 }
|
Chris@81
|
1901
|
Chris@81
|
1902 void
|
Chris@81
|
1903 MainWindow::insertInstantsAtBoundaries()
|
Chris@81
|
1904 {
|
Chris@81
|
1905 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@81
|
1906 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@81
|
1907 i != selections.end(); ++i) {
|
Chris@81
|
1908 size_t start = i->getStartFrame();
|
Chris@81
|
1909 size_t end = i->getEndFrame();
|
Chris@81
|
1910 if (start != end) {
|
Chris@81
|
1911 insertInstantAt(i->getStartFrame());
|
Chris@81
|
1912 insertInstantAt(i->getEndFrame());
|
Chris@81
|
1913 }
|
Chris@81
|
1914 }
|
Chris@81
|
1915 }
|
Chris@81
|
1916
|
Chris@81
|
1917 void
|
Chris@81
|
1918 MainWindow::insertInstantAt(size_t frame)
|
Chris@81
|
1919 {
|
Chris@0
|
1920 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
1921 if (!pane) {
|
Chris@0
|
1922 return;
|
Chris@0
|
1923 }
|
Chris@0
|
1924
|
Chris@0
|
1925 Layer *layer = dynamic_cast<TimeInstantLayer *>
|
Chris@0
|
1926 (pane->getSelectedLayer());
|
Chris@0
|
1927
|
Chris@0
|
1928 if (!layer) {
|
Chris@0
|
1929 for (int i = pane->getLayerCount(); i > 0; --i) {
|
Chris@0
|
1930 layer = dynamic_cast<TimeInstantLayer *>(pane->getLayer(i - 1));
|
Chris@0
|
1931 if (layer) break;
|
Chris@0
|
1932 }
|
Chris@0
|
1933
|
Chris@0
|
1934 if (!layer) {
|
Chris@0
|
1935 CommandHistory::getInstance()->startCompoundOperation
|
Chris@0
|
1936 (tr("Add Point"), true);
|
Chris@0
|
1937 layer = m_document->createEmptyLayer(LayerFactory::TimeInstants);
|
Chris@0
|
1938 if (layer) {
|
Chris@0
|
1939 m_document->addLayerToView(pane, layer);
|
Chris@0
|
1940 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@0
|
1941 }
|
Chris@0
|
1942 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
1943 }
|
Chris@0
|
1944 }
|
Chris@0
|
1945
|
Chris@0
|
1946 if (layer) {
|
Chris@0
|
1947
|
Chris@0
|
1948 Model *model = layer->getModel();
|
Chris@0
|
1949 SparseOneDimensionalModel *sodm = dynamic_cast<SparseOneDimensionalModel *>
|
Chris@0
|
1950 (model);
|
Chris@0
|
1951
|
Chris@0
|
1952 if (sodm) {
|
Chris@0
|
1953 SparseOneDimensionalModel::Point point
|
Chris@0
|
1954 (frame, QString("%1").arg(sodm->getPointCount() + 1));
|
Chris@0
|
1955 CommandHistory::getInstance()->addCommand
|
Chris@0
|
1956 (new SparseOneDimensionalModel::AddPointCommand(sodm, point,
|
Chris@0
|
1957 tr("Add Points")),
|
Chris@0
|
1958 true, true); // bundled
|
Chris@0
|
1959 }
|
Chris@0
|
1960 }
|
Chris@0
|
1961 }
|
Chris@0
|
1962
|
Chris@0
|
1963 void
|
Chris@0
|
1964 MainWindow::importAudio()
|
Chris@0
|
1965 {
|
Chris@88
|
1966 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
1967
|
Chris@0
|
1968 if (path != "") {
|
Chris@82
|
1969 if (openAudioFile(path, ReplaceMainModel) == FileOpenFailed) {
|
Chris@0
|
1970 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1971 tr("Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1972 }
|
Chris@0
|
1973 }
|
Chris@0
|
1974 }
|
Chris@0
|
1975
|
Chris@0
|
1976 void
|
Chris@0
|
1977 MainWindow::importMoreAudio()
|
Chris@0
|
1978 {
|
Chris@88
|
1979 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
1980
|
Chris@0
|
1981 if (path != "") {
|
Chris@82
|
1982 if (openAudioFile(path, CreateAdditionalModel) == FileOpenFailed) {
|
Chris@0
|
1983 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1984 tr("Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1985 }
|
Chris@0
|
1986 }
|
Chris@0
|
1987 }
|
Chris@0
|
1988
|
Chris@0
|
1989 void
|
Chris@0
|
1990 MainWindow::exportAudio()
|
Chris@0
|
1991 {
|
Chris@0
|
1992 if (!getMainModel()) return;
|
Chris@0
|
1993
|
Chris@88
|
1994 QString path = getSaveFileName(FileFinder::AudioFile);
|
Chris@0
|
1995
|
Chris@0
|
1996 if (path == "") return;
|
Chris@0
|
1997
|
Chris@0
|
1998 bool ok = false;
|
Chris@0
|
1999 QString error;
|
Chris@0
|
2000
|
Chris@0
|
2001 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
2002 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
2003
|
Chris@0
|
2004 bool multiple = false;
|
Chris@0
|
2005
|
Chris@38
|
2006 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
2007
|
Chris@38
|
2008 if (selections.size() == 1) {
|
Chris@0
|
2009
|
Chris@0
|
2010 QStringList items;
|
Chris@0
|
2011 items << tr("Export the selected region only")
|
Chris@0
|
2012 << tr("Export the whole audio file");
|
Chris@0
|
2013
|
Chris@0
|
2014 bool ok = false;
|
Chris@0
|
2015 QString item = ListInputDialog::getItem
|
Chris@0
|
2016 (this, tr("Select region to export"),
|
Chris@0
|
2017 tr("Which region from the original audio file do you want to export?"),
|
Chris@0
|
2018 items, 0, &ok);
|
Chris@0
|
2019
|
Chris@0
|
2020 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2021
|
Chris@38
|
2022 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2023
|
Chris@38
|
2024 } else if (selections.size() > 1) {
|
Chris@0
|
2025
|
Chris@0
|
2026 QStringList items;
|
Chris@0
|
2027 items << tr("Export the selected regions into a single audio file")
|
Chris@0
|
2028 << tr("Export the selected regions into separate files")
|
Chris@0
|
2029 << tr("Export the whole audio file");
|
Chris@0
|
2030
|
Chris@0
|
2031 QString item = ListInputDialog::getItem
|
Chris@0
|
2032 (this, tr("Select region to export"),
|
Chris@0
|
2033 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@0
|
2034 items, 0, &ok);
|
Chris@0
|
2035
|
Chris@0
|
2036 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2037
|
Chris@0
|
2038 if (item == items[0]) {
|
Chris@0
|
2039
|
Chris@38
|
2040 selectionToWrite = &ms;
|
Chris@38
|
2041
|
Chris@38
|
2042 } else if (item == items[1]) {
|
Chris@0
|
2043
|
Chris@0
|
2044 multiple = true;
|
Chris@0
|
2045
|
Chris@0
|
2046 int n = 1;
|
Chris@0
|
2047 QString base = path;
|
Chris@0
|
2048 base.replace(".wav", "");
|
Chris@0
|
2049
|
Chris@0
|
2050 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
2051 i != selections.end(); ++i) {
|
Chris@0
|
2052
|
Chris@0
|
2053 MultiSelection subms;
|
Chris@0
|
2054 subms.setSelection(*i);
|
Chris@0
|
2055
|
Chris@0
|
2056 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@0
|
2057 ++n;
|
Chris@0
|
2058
|
Chris@0
|
2059 if (QFileInfo(subpath).exists()) {
|
Chris@0
|
2060 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@0
|
2061 break;
|
Chris@0
|
2062 }
|
Chris@0
|
2063
|
Chris@38
|
2064 WavFileWriter subwriter(subpath,
|
Chris@38
|
2065 getMainModel()->getSampleRate(),
|
Chris@38
|
2066 getMainModel()->getChannelCount());
|
Chris@38
|
2067 subwriter.writeModel(getMainModel(), &subms);
|
Chris@0
|
2068 ok = subwriter.isOK();
|
Chris@0
|
2069
|
Chris@0
|
2070 if (!ok) {
|
Chris@0
|
2071 error = subwriter.getError();
|
Chris@0
|
2072 break;
|
Chris@0
|
2073 }
|
Chris@0
|
2074 }
|
Chris@0
|
2075 }
|
Chris@0
|
2076 }
|
Chris@0
|
2077
|
Chris@38
|
2078 if (!multiple) {
|
Chris@38
|
2079 WavFileWriter writer(path,
|
Chris@38
|
2080 getMainModel()->getSampleRate(),
|
Chris@38
|
2081 getMainModel()->getChannelCount());
|
Chris@38
|
2082 writer.writeModel(getMainModel(), selectionToWrite);
|
Chris@38
|
2083 ok = writer.isOK();
|
Chris@38
|
2084 error = writer.getError();
|
Chris@0
|
2085 }
|
Chris@0
|
2086
|
Chris@0
|
2087 if (ok) {
|
Chris@0
|
2088 if (!multiple) {
|
Chris@34
|
2089 m_recentFiles.addFile(path);
|
Chris@0
|
2090 }
|
Chris@0
|
2091 } else {
|
Chris@0
|
2092 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2093 }
|
Chris@0
|
2094 }
|
Chris@0
|
2095
|
Chris@0
|
2096 void
|
Chris@0
|
2097 MainWindow::importLayer()
|
Chris@0
|
2098 {
|
Chris@0
|
2099 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2100
|
Chris@0
|
2101 if (!pane) {
|
Chris@0
|
2102 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2103 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
|
Chris@0
|
2104 return;
|
Chris@0
|
2105 }
|
Chris@0
|
2106
|
Chris@0
|
2107 if (!getMainModel()) {
|
Chris@0
|
2108 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2109 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
|
Chris@0
|
2110 return;
|
Chris@0
|
2111 }
|
Chris@0
|
2112
|
Chris@88
|
2113 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2114
|
Chris@0
|
2115 if (path != "") {
|
Chris@0
|
2116
|
Chris@82
|
2117 if (openLayerFile(path) == FileOpenFailed) {
|
Chris@0
|
2118 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2119 tr("File %1 could not be opened.").arg(path));
|
Chris@0
|
2120 return;
|
Chris@0
|
2121 }
|
Chris@0
|
2122 }
|
Chris@0
|
2123 }
|
Chris@0
|
2124
|
Chris@82
|
2125 MainWindow::FileOpenStatus
|
Chris@0
|
2126 MainWindow::openLayerFile(QString path)
|
Chris@0
|
2127 {
|
Chris@86
|
2128 return openLayerFile(path, path);
|
Chris@86
|
2129 }
|
Chris@86
|
2130
|
Chris@86
|
2131 MainWindow::FileOpenStatus
|
Chris@86
|
2132 MainWindow::openLayerFile(QString path, QString location)
|
Chris@86
|
2133 {
|
Chris@0
|
2134 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2135
|
Chris@0
|
2136 if (!pane) {
|
Chris@0
|
2137 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2138 std::cerr << "WARNING: MainWindow::openLayerFile: no current pane" << std::endl;
|
Chris@82
|
2139 return FileOpenFailed;
|
Chris@0
|
2140 }
|
Chris@0
|
2141
|
Chris@0
|
2142 if (!getMainModel()) {
|
Chris@0
|
2143 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2144 std::cerr << "WARNING: MainWindow::openLayerFile: No main model -- hence no default sample rate available" << std::endl;
|
Chris@82
|
2145 return FileOpenFailed;
|
Chris@0
|
2146 }
|
Chris@0
|
2147
|
Chris@86
|
2148 bool realFile = (location == path);
|
Chris@86
|
2149
|
Chris@0
|
2150 if (path.endsWith(".svl") || path.endsWith(".xml")) {
|
Chris@0
|
2151
|
Chris@0
|
2152 PaneCallback callback(this);
|
Chris@0
|
2153 QFile file(path);
|
Chris@0
|
2154
|
Chris@0
|
2155 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
Chris@0
|
2156 std::cerr << "ERROR: MainWindow::openLayerFile("
|
Chris@86
|
2157 << location.toStdString()
|
Chris@0
|
2158 << "): Failed to open file for reading" << std::endl;
|
Chris@82
|
2159 return FileOpenFailed;
|
Chris@0
|
2160 }
|
Chris@0
|
2161
|
Chris@87
|
2162 SVFileReader reader(m_document, callback, location);
|
Chris@0
|
2163 reader.setCurrentPane(pane);
|
Chris@0
|
2164
|
Chris@0
|
2165 QXmlInputSource inputSource(&file);
|
Chris@0
|
2166 reader.parse(inputSource);
|
Chris@0
|
2167
|
Chris@0
|
2168 if (!reader.isOK()) {
|
Chris@0
|
2169 std::cerr << "ERROR: MainWindow::openLayerFile("
|
Chris@86
|
2170 << location.toStdString()
|
Chris@0
|
2171 << "): Failed to read XML file: "
|
Chris@0
|
2172 << reader.getErrorString().toStdString() << std::endl;
|
Chris@82
|
2173 return FileOpenFailed;
|
Chris@0
|
2174 }
|
Chris@0
|
2175
|
Chris@86
|
2176 m_recentFiles.addFile(location);
|
Chris@86
|
2177
|
Chris@86
|
2178 if (realFile) {
|
Chris@88
|
2179 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog
|
Chris@86
|
2180 }
|
Chris@86
|
2181
|
Chris@82
|
2182 return FileOpenSucceeded;
|
Chris@0
|
2183
|
Chris@0
|
2184 } else {
|
Chris@0
|
2185
|
Chris@0
|
2186 Model *model = DataFileReaderFactory::load(path, getMainModel()->getSampleRate());
|
Chris@0
|
2187
|
Chris@0
|
2188 if (model) {
|
Chris@86
|
2189
|
Chris@0
|
2190 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@86
|
2191
|
Chris@0
|
2192 if (newLayer) {
|
Chris@86
|
2193
|
Chris@0
|
2194 m_document->addLayerToView(pane, newLayer);
|
Chris@86
|
2195 m_recentFiles.addFile(location);
|
Chris@86
|
2196
|
Chris@86
|
2197 if (realFile) {
|
Chris@88
|
2198 registerLastOpenedFilePath(FileFinder::LayerFile, path); // for file dialog
|
Chris@86
|
2199 }
|
Chris@86
|
2200
|
Chris@82
|
2201 return FileOpenSucceeded;
|
Chris@0
|
2202 }
|
Chris@0
|
2203 }
|
Chris@0
|
2204 }
|
Chris@0
|
2205
|
Chris@82
|
2206 return FileOpenFailed;
|
Chris@0
|
2207 }
|
Chris@0
|
2208
|
Chris@0
|
2209 void
|
Chris@0
|
2210 MainWindow::exportLayer()
|
Chris@0
|
2211 {
|
Chris@0
|
2212 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2213 if (!pane) return;
|
Chris@0
|
2214
|
Chris@0
|
2215 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2216 if (!layer) return;
|
Chris@0
|
2217
|
Chris@0
|
2218 Model *model = layer->getModel();
|
Chris@0
|
2219 if (!model) return;
|
Chris@0
|
2220
|
Chris@88
|
2221 QString path = getSaveFileName(FileFinder::LayerFile);
|
Chris@0
|
2222
|
Chris@0
|
2223 if (path == "") return;
|
Chris@0
|
2224
|
Chris@0
|
2225 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
2226
|
Chris@0
|
2227 QString error;
|
Chris@0
|
2228
|
Chris@0
|
2229 if (path.endsWith(".xml") || path.endsWith(".svl")) {
|
Chris@0
|
2230
|
Chris@0
|
2231 QFile file(path);
|
Chris@0
|
2232 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
2233 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
2234 } else {
|
Chris@0
|
2235 QTextStream out(&file);
|
Chris@0
|
2236 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
2237 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
2238 << "<sv>\n"
|
Chris@0
|
2239 << " <data>\n";
|
Chris@0
|
2240
|
Chris@0
|
2241 model->toXml(out, " ");
|
Chris@0
|
2242
|
Chris@0
|
2243 out << " </data>\n"
|
Chris@0
|
2244 << " <display>\n";
|
Chris@0
|
2245
|
Chris@0
|
2246 layer->toXml(out, " ");
|
Chris@0
|
2247
|
Chris@0
|
2248 out << " </display>\n"
|
Chris@0
|
2249 << "</sv>\n";
|
Chris@0
|
2250 }
|
Chris@0
|
2251
|
Chris@0
|
2252 } else {
|
Chris@0
|
2253
|
Chris@0
|
2254 CSVFileWriter writer(path, model,
|
Chris@0
|
2255 (path.endsWith(".csv") ? "," : "\t"));
|
Chris@0
|
2256 writer.write();
|
Chris@0
|
2257
|
Chris@0
|
2258 if (!writer.isOK()) {
|
Chris@0
|
2259 error = writer.getError();
|
Chris@0
|
2260 }
|
Chris@0
|
2261 }
|
Chris@0
|
2262
|
Chris@0
|
2263 if (error != "") {
|
Chris@0
|
2264 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2265 } else {
|
Chris@34
|
2266 m_recentFiles.addFile(path);
|
Chris@0
|
2267 }
|
Chris@0
|
2268 }
|
Chris@0
|
2269
|
Chris@82
|
2270 MainWindow::FileOpenStatus
|
Chris@0
|
2271 MainWindow::openAudioFile(QString path, AudioFileOpenMode mode)
|
Chris@0
|
2272 {
|
Chris@86
|
2273 return openAudioFile(path, path, mode);
|
Chris@86
|
2274 }
|
Chris@86
|
2275
|
Chris@86
|
2276 MainWindow::FileOpenStatus
|
Chris@86
|
2277 MainWindow::openAudioFile(QString path, QString location, AudioFileOpenMode mode)
|
Chris@86
|
2278 {
|
Chris@0
|
2279 if (!(QFileInfo(path).exists() &&
|
Chris@0
|
2280 QFileInfo(path).isFile() &&
|
Chris@0
|
2281 QFileInfo(path).isReadable())) {
|
Chris@82
|
2282 return FileOpenFailed;
|
Chris@0
|
2283 }
|
Chris@0
|
2284
|
Chris@70
|
2285 m_openingAudioFile = true;
|
Chris@70
|
2286
|
Chris@88
|
2287 WaveFileModel *newModel = new WaveFileModel(path, location);
|
Chris@0
|
2288
|
Chris@0
|
2289 if (!newModel->isOK()) {
|
Chris@0
|
2290 delete newModel;
|
Chris@70
|
2291 m_openingAudioFile = false;
|
Chris@82
|
2292 return FileOpenFailed;
|
Chris@0
|
2293 }
|
Chris@0
|
2294
|
Chris@0
|
2295 bool setAsMain = true;
|
Chris@0
|
2296 static bool prevSetAsMain = true;
|
Chris@0
|
2297
|
Chris@86
|
2298 bool realFile = (location == path);
|
Chris@86
|
2299
|
Chris@0
|
2300 if (mode == CreateAdditionalModel) setAsMain = false;
|
Chris@0
|
2301 else if (mode == AskUser) {
|
Chris@0
|
2302 if (m_document->getMainModel()) {
|
Chris@0
|
2303
|
Chris@0
|
2304 QStringList items;
|
Chris@0
|
2305 items << tr("Replace the existing main waveform")
|
Chris@0
|
2306 << tr("Load this file into a new waveform pane");
|
Chris@0
|
2307
|
Chris@0
|
2308 bool ok = false;
|
Chris@0
|
2309 QString item = ListInputDialog::getItem
|
Chris@0
|
2310 (this, tr("Select target for import"),
|
Chris@0
|
2311 tr("You already have an audio waveform loaded.\nWhat would you like to do with the new audio file?"),
|
Chris@0
|
2312 items, prevSetAsMain ? 0 : 1, &ok);
|
Chris@0
|
2313
|
Chris@0
|
2314 if (!ok || item.isEmpty()) {
|
Chris@0
|
2315 delete newModel;
|
Chris@70
|
2316 m_openingAudioFile = false;
|
Chris@82
|
2317 return FileOpenCancelled;
|
Chris@0
|
2318 }
|
Chris@0
|
2319
|
Chris@0
|
2320 setAsMain = (item == items[0]);
|
Chris@0
|
2321 prevSetAsMain = setAsMain;
|
Chris@0
|
2322 }
|
Chris@0
|
2323 }
|
Chris@0
|
2324
|
Chris@0
|
2325 if (setAsMain) {
|
Chris@0
|
2326
|
Chris@0
|
2327 Model *prevMain = getMainModel();
|
Chris@0
|
2328 if (prevMain) m_playSource->removeModel(prevMain);
|
Chris@0
|
2329
|
Chris@0
|
2330 PlayParameterRepository::getInstance()->clear();
|
Chris@0
|
2331
|
Chris@0
|
2332 // The clear() call will have removed the parameters for the
|
Chris@0
|
2333 // main model. Re-add them with the new one.
|
Chris@0
|
2334 PlayParameterRepository::getInstance()->addModel(newModel);
|
Chris@0
|
2335
|
Chris@0
|
2336 m_document->setMainModel(newModel);
|
Chris@0
|
2337 setupMenus();
|
Chris@0
|
2338
|
Chris@0
|
2339 if (m_sessionFile == "") {
|
Chris@0
|
2340 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@86
|
2341 .arg(QFileInfo(location).fileName()));
|
Chris@0
|
2342 CommandHistory::getInstance()->clear();
|
Chris@0
|
2343 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2344 m_documentModified = false;
|
Chris@0
|
2345 } else {
|
Chris@0
|
2346 setWindowTitle(tr("Sonic Visualiser: %1 [%2]")
|
Chris@0
|
2347 .arg(QFileInfo(m_sessionFile).fileName())
|
Chris@86
|
2348 .arg(QFileInfo(location).fileName()));
|
Chris@0
|
2349 if (m_documentModified) {
|
Chris@0
|
2350 m_documentModified = false;
|
Chris@0
|
2351 documentModified(); // so as to restore "(modified)" window title
|
Chris@0
|
2352 }
|
Chris@0
|
2353 }
|
Chris@0
|
2354
|
Chris@86
|
2355 if (realFile) m_audioFile = path;
|
Chris@0
|
2356
|
Chris@0
|
2357 } else { // !setAsMain
|
Chris@0
|
2358
|
Chris@0
|
2359 CommandHistory::getInstance()->startCompoundOperation
|
Chris@86
|
2360 (tr("Import \"%1\"").arg(QFileInfo(location).fileName()), true);
|
Chris@0
|
2361
|
Chris@0
|
2362 m_document->addImportedModel(newModel);
|
Chris@0
|
2363
|
Chris@0
|
2364 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2365 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2366
|
Chris@0
|
2367 Pane *pane = command->getPane();
|
Chris@0
|
2368
|
Chris@0
|
2369 if (!m_timeRulerLayer) {
|
Chris@0
|
2370 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2371 (LayerFactory::TimeRuler);
|
Chris@0
|
2372 }
|
Chris@0
|
2373
|
Chris@0
|
2374 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2375
|
Chris@0
|
2376 Layer *newLayer = m_document->createImportedLayer(newModel);
|
Chris@0
|
2377
|
Chris@0
|
2378 if (newLayer) {
|
Chris@0
|
2379 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2380 }
|
Chris@0
|
2381
|
Chris@0
|
2382 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
2383 }
|
Chris@0
|
2384
|
Chris@0
|
2385 updateMenuStates();
|
Chris@86
|
2386 m_recentFiles.addFile(location);
|
Chris@86
|
2387 if (realFile) {
|
Chris@88
|
2388 registerLastOpenedFilePath(FileFinder::AudioFile, path); // for file dialog
|
Chris@86
|
2389 }
|
Chris@70
|
2390 m_openingAudioFile = false;
|
Chris@0
|
2391
|
Chris@82
|
2392 return FileOpenSucceeded;
|
Chris@0
|
2393 }
|
Chris@0
|
2394
|
Chris@0
|
2395 void
|
Chris@0
|
2396 MainWindow::createPlayTarget()
|
Chris@0
|
2397 {
|
Chris@0
|
2398 if (m_playTarget) return;
|
Chris@0
|
2399
|
Chris@0
|
2400 m_playTarget = AudioTargetFactory::createCallbackTarget(m_playSource);
|
Chris@0
|
2401 if (!m_playTarget) {
|
Chris@0
|
2402 QMessageBox::warning
|
Chris@0
|
2403 (this, tr("Couldn't open audio device"),
|
Chris@0
|
2404 tr("Could not open an audio device for playback.\nAudio playback will not be available during this session.\n"),
|
Chris@0
|
2405 QMessageBox::Ok, 0);
|
Chris@0
|
2406 }
|
Chris@0
|
2407 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2408 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2409 }
|
Chris@0
|
2410
|
Chris@0
|
2411 WaveFileModel *
|
Chris@0
|
2412 MainWindow::getMainModel()
|
Chris@0
|
2413 {
|
Chris@0
|
2414 if (!m_document) return 0;
|
Chris@0
|
2415 return m_document->getMainModel();
|
Chris@0
|
2416 }
|
Chris@0
|
2417
|
Chris@0
|
2418 void
|
Chris@0
|
2419 MainWindow::newSession()
|
Chris@0
|
2420 {
|
Chris@0
|
2421 if (!checkSaveModified()) return;
|
Chris@0
|
2422
|
Chris@0
|
2423 closeSession();
|
Chris@0
|
2424 createDocument();
|
Chris@0
|
2425
|
Chris@0
|
2426 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
2427
|
Chris@90
|
2428 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
2429 statusBar(), SLOT(showMessage(const QString &)));
|
Chris@90
|
2430
|
Chris@0
|
2431 if (!m_timeRulerLayer) {
|
Chris@0
|
2432 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2433 (LayerFactory::TimeRuler);
|
Chris@0
|
2434 }
|
Chris@0
|
2435
|
Chris@0
|
2436 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2437
|
Chris@0
|
2438 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
2439 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
2440
|
Chris@65
|
2441 m_overview->registerView(pane);
|
Chris@0
|
2442
|
Chris@0
|
2443 CommandHistory::getInstance()->clear();
|
Chris@0
|
2444 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2445 documentRestored();
|
Chris@0
|
2446 updateMenuStates();
|
Chris@0
|
2447 }
|
Chris@0
|
2448
|
Chris@0
|
2449 void
|
Chris@0
|
2450 MainWindow::createDocument()
|
Chris@0
|
2451 {
|
Chris@0
|
2452 m_document = new Document;
|
Chris@0
|
2453
|
Chris@0
|
2454 connect(m_document, SIGNAL(layerAdded(Layer *)),
|
Chris@0
|
2455 this, SLOT(layerAdded(Layer *)));
|
Chris@0
|
2456 connect(m_document, SIGNAL(layerRemoved(Layer *)),
|
Chris@0
|
2457 this, SLOT(layerRemoved(Layer *)));
|
Chris@0
|
2458 connect(m_document, SIGNAL(layerAboutToBeDeleted(Layer *)),
|
Chris@0
|
2459 this, SLOT(layerAboutToBeDeleted(Layer *)));
|
Chris@0
|
2460 connect(m_document, SIGNAL(layerInAView(Layer *, bool)),
|
Chris@0
|
2461 this, SLOT(layerInAView(Layer *, bool)));
|
Chris@0
|
2462
|
Chris@0
|
2463 connect(m_document, SIGNAL(modelAdded(Model *)),
|
Chris@0
|
2464 this, SLOT(modelAdded(Model *)));
|
Chris@0
|
2465 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)),
|
Chris@0
|
2466 this, SLOT(mainModelChanged(WaveFileModel *)));
|
Chris@0
|
2467 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@0
|
2468 this, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@0
|
2469
|
Chris@0
|
2470 connect(m_document, SIGNAL(modelGenerationFailed(QString)),
|
Chris@0
|
2471 this, SLOT(modelGenerationFailed(QString)));
|
Chris@63
|
2472 connect(m_document, SIGNAL(modelRegenerationFailed(QString, QString)),
|
Chris@63
|
2473 this, SLOT(modelRegenerationFailed(QString, QString)));
|
Chris@0
|
2474 }
|
Chris@0
|
2475
|
Chris@0
|
2476 void
|
Chris@0
|
2477 MainWindow::closeSession()
|
Chris@0
|
2478 {
|
Chris@0
|
2479 if (!checkSaveModified()) return;
|
Chris@0
|
2480
|
Chris@0
|
2481 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
2482
|
Chris@0
|
2483 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
2484
|
Chris@0
|
2485 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2486 m_document->removeLayerFromView
|
Chris@0
|
2487 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2488 }
|
Chris@0
|
2489
|
Chris@65
|
2490 m_overview->unregisterView(pane);
|
Chris@0
|
2491 m_paneStack->deletePane(pane);
|
Chris@0
|
2492 }
|
Chris@0
|
2493
|
Chris@0
|
2494 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
2495
|
Chris@0
|
2496 Pane *pane = m_paneStack->getHiddenPane
|
Chris@0
|
2497 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
2498
|
Chris@0
|
2499 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2500 m_document->removeLayerFromView
|
Chris@0
|
2501 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2502 }
|
Chris@0
|
2503
|
Chris@65
|
2504 m_overview->unregisterView(pane);
|
Chris@0
|
2505 m_paneStack->deletePane(pane);
|
Chris@0
|
2506 }
|
Chris@0
|
2507
|
Chris@0
|
2508 delete m_document;
|
Chris@0
|
2509 m_document = 0;
|
Chris@0
|
2510 m_viewManager->clearSelections();
|
Chris@0
|
2511 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
2512
|
Chris@0
|
2513 m_sessionFile = "";
|
Chris@0
|
2514 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2515
|
Chris@0
|
2516 CommandHistory::getInstance()->clear();
|
Chris@0
|
2517 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2518 documentRestored();
|
Chris@0
|
2519 }
|
Chris@0
|
2520
|
Chris@0
|
2521 void
|
Chris@0
|
2522 MainWindow::openSession()
|
Chris@0
|
2523 {
|
Chris@0
|
2524 if (!checkSaveModified()) return;
|
Chris@0
|
2525
|
Chris@0
|
2526 QString orig = m_audioFile;
|
Chris@0
|
2527 if (orig == "") orig = ".";
|
Chris@0
|
2528 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2529
|
Chris@88
|
2530 QString path = getOpenFileName(FileFinder::SessionFile);
|
Chris@0
|
2531
|
Chris@0
|
2532 if (path.isEmpty()) return;
|
Chris@0
|
2533
|
Chris@82
|
2534 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2535 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2536 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2537 }
|
Chris@0
|
2538 }
|
Chris@0
|
2539
|
Chris@0
|
2540 void
|
Chris@0
|
2541 MainWindow::openSomething()
|
Chris@0
|
2542 {
|
Chris@0
|
2543 QString orig = m_audioFile;
|
Chris@0
|
2544 if (orig == "") orig = ".";
|
Chris@0
|
2545 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2546
|
Chris@0
|
2547 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@0
|
2548 m_paneStack != 0 &&
|
Chris@0
|
2549 m_paneStack->getCurrentPane() != 0);
|
Chris@0
|
2550
|
Chris@88
|
2551 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
2552
|
Chris@0
|
2553 if (path.isEmpty()) return;
|
Chris@0
|
2554
|
Chris@0
|
2555 if (path.endsWith(".sv")) {
|
Chris@0
|
2556
|
Chris@0
|
2557 if (!checkSaveModified()) return;
|
Chris@0
|
2558
|
Chris@82
|
2559 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2560 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2561 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2562 }
|
Chris@0
|
2563
|
Chris@0
|
2564 } else {
|
Chris@0
|
2565
|
Chris@82
|
2566 if (openAudioFile(path, AskUser) == FileOpenFailed) {
|
Chris@82
|
2567
|
Chris@82
|
2568 if (!canImportLayer || (openLayerFile(path) == FileOpenFailed)) {
|
Chris@0
|
2569
|
Chris@0
|
2570 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2571 tr("File \"%1\" could not be opened").arg(path));
|
Chris@0
|
2572 }
|
Chris@0
|
2573 }
|
Chris@0
|
2574 }
|
Chris@0
|
2575 }
|
Chris@0
|
2576
|
Chris@0
|
2577 void
|
Chris@86
|
2578 MainWindow::openLocation()
|
Chris@86
|
2579 {
|
Chris@103
|
2580 QSettings settings;
|
Chris@103
|
2581 settings.beginGroup("MainWindow");
|
Chris@103
|
2582 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
2583
|
Chris@86
|
2584 bool ok = false;
|
Chris@86
|
2585 QString text = QInputDialog::getText
|
Chris@86
|
2586 (this, tr("Open Location"),
|
Chris@86
|
2587 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
2588 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
2589
|
Chris@103
|
2590 if (!ok) return;
|
Chris@103
|
2591
|
Chris@103
|
2592 settings.setValue("lastremote", text);
|
Chris@103
|
2593
|
Chris@103
|
2594 if (text.isEmpty()) return;
|
Chris@86
|
2595
|
Chris@86
|
2596 if (openURL(QUrl(text)) == FileOpenFailed) {
|
Chris@86
|
2597 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@86
|
2598 tr("URL \"%1\" could not be opened").arg(text));
|
Chris@86
|
2599 }
|
Chris@86
|
2600 }
|
Chris@86
|
2601
|
Chris@86
|
2602 void
|
Chris@0
|
2603 MainWindow::openRecentFile()
|
Chris@0
|
2604 {
|
Chris@0
|
2605 QObject *obj = sender();
|
Chris@0
|
2606 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
2607
|
Chris@0
|
2608 if (!action) {
|
Chris@0
|
2609 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@0
|
2610 << std::endl;
|
Chris@0
|
2611 return;
|
Chris@0
|
2612 }
|
Chris@0
|
2613
|
Chris@0
|
2614 QString path = action->text();
|
Chris@0
|
2615 if (path == "") return;
|
Chris@0
|
2616
|
Chris@86
|
2617 QUrl url(path);
|
Chris@86
|
2618 if (RemoteFile::canHandleScheme(url)) {
|
Chris@86
|
2619 openURL(url);
|
Chris@86
|
2620 return;
|
Chris@86
|
2621 }
|
Chris@86
|
2622
|
Chris@0
|
2623 if (path.endsWith("sv")) {
|
Chris@0
|
2624
|
Chris@103
|
2625 if (!checkSaveModified()) return;
|
Chris@0
|
2626
|
Chris@82
|
2627 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@0
|
2628 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2629 tr("Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2630 }
|
Chris@0
|
2631
|
Chris@0
|
2632 } else {
|
Chris@0
|
2633
|
Chris@82
|
2634 if (openAudioFile(path, AskUser) == FileOpenFailed) {
|
Chris@0
|
2635
|
Chris@0
|
2636 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@0
|
2637 m_paneStack != 0 &&
|
Chris@0
|
2638 m_paneStack->getCurrentPane() != 0);
|
Chris@0
|
2639
|
Chris@82
|
2640 if (!canImportLayer || (openLayerFile(path) == FileOpenFailed)) {
|
Chris@0
|
2641
|
Chris@0
|
2642 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
2643 tr("File \"%1\" could not be opened").arg(path));
|
Chris@0
|
2644 }
|
Chris@0
|
2645 }
|
Chris@0
|
2646 }
|
Chris@0
|
2647 }
|
Chris@0
|
2648
|
Chris@82
|
2649 MainWindow::FileOpenStatus
|
Chris@85
|
2650 MainWindow::openURL(QUrl url)
|
Chris@85
|
2651 {
|
Chris@85
|
2652 if (url.scheme().toLower() == "file") {
|
Chris@85
|
2653 return openSomeFile(url.toLocalFile());
|
Chris@86
|
2654 } else if (!RemoteFile::canHandleScheme(url)) {
|
Chris@85
|
2655 QMessageBox::critical(this, tr("Unsupported scheme in URL"),
|
Chris@85
|
2656 tr("The URL scheme \"%1\" is not supported")
|
Chris@85
|
2657 .arg(url.scheme()));
|
Chris@85
|
2658 return FileOpenFailed;
|
Chris@85
|
2659 } else {
|
Chris@85
|
2660 RemoteFile rf(url);
|
Chris@85
|
2661 rf.wait();
|
Chris@85
|
2662 if (!rf.isOK()) {
|
Chris@85
|
2663 QMessageBox::critical(this, tr("File download failed"),
|
Chris@85
|
2664 tr("Failed to download URL \"%1\": %2")
|
Chris@85
|
2665 .arg(url.toString()).arg(rf.getErrorString()));
|
Chris@85
|
2666 return FileOpenFailed;
|
Chris@85
|
2667 }
|
Chris@88
|
2668 FileOpenStatus status;
|
Chris@88
|
2669 if ((status = openSomeFile(rf.getLocalFilename(), url.toString())) !=
|
Chris@88
|
2670 FileOpenSucceeded) {
|
Chris@88
|
2671 rf.deleteLocalFile();
|
Chris@88
|
2672 }
|
Chris@88
|
2673 return status;
|
Chris@85
|
2674 }
|
Chris@85
|
2675 }
|
Chris@85
|
2676
|
Chris@85
|
2677 MainWindow::FileOpenStatus
|
Chris@54
|
2678 MainWindow::openSomeFile(QString path, AudioFileOpenMode mode)
|
Chris@0
|
2679 {
|
Chris@86
|
2680 return openSomeFile(path, path, mode);
|
Chris@86
|
2681 }
|
Chris@86
|
2682
|
Chris@86
|
2683 MainWindow::FileOpenStatus
|
Chris@86
|
2684 MainWindow::openSomeFile(QString path, QString location,
|
Chris@86
|
2685 AudioFileOpenMode mode)
|
Chris@86
|
2686 {
|
Chris@82
|
2687 FileOpenStatus status;
|
Chris@82
|
2688
|
Chris@85
|
2689 bool canImportLayer = (getMainModel() != 0 &&
|
Chris@85
|
2690 m_paneStack != 0 &&
|
Chris@85
|
2691 m_paneStack->getCurrentPane() != 0);
|
Chris@85
|
2692
|
Chris@86
|
2693 if ((status = openAudioFile(path, location, mode)) != FileOpenFailed) {
|
Chris@82
|
2694 return status;
|
Chris@86
|
2695 } else if ((status = openSessionFile(path, location)) != FileOpenFailed) {
|
Chris@82
|
2696 return status;
|
Chris@85
|
2697 } else if (!canImportLayer) {
|
Chris@85
|
2698 return FileOpenFailed;
|
Chris@86
|
2699 } else if ((status = openLayerFile(path, location)) != FileOpenFailed) {
|
Chris@85
|
2700 return status;
|
Chris@0
|
2701 } else {
|
Chris@82
|
2702 return FileOpenFailed;
|
Chris@0
|
2703 }
|
Chris@0
|
2704 }
|
Chris@0
|
2705
|
Chris@82
|
2706 MainWindow::FileOpenStatus
|
Chris@0
|
2707 MainWindow::openSessionFile(QString path)
|
Chris@0
|
2708 {
|
Chris@86
|
2709 return openSessionFile(path, path);
|
Chris@86
|
2710 }
|
Chris@86
|
2711
|
Chris@86
|
2712 MainWindow::FileOpenStatus
|
Chris@86
|
2713 MainWindow::openSessionFile(QString path, QString location)
|
Chris@86
|
2714 {
|
Chris@0
|
2715 BZipFileDevice bzFile(path);
|
Chris@0
|
2716 if (!bzFile.open(QIODevice::ReadOnly)) {
|
Chris@86
|
2717 std::cerr << "Failed to open session file \"" << location.toStdString()
|
Chris@0
|
2718 << "\": " << bzFile.errorString().toStdString() << std::endl;
|
Chris@82
|
2719 return FileOpenFailed;
|
Chris@0
|
2720 }
|
Chris@0
|
2721
|
Chris@103
|
2722 if (!checkSaveModified()) return FileOpenCancelled;
|
Chris@103
|
2723
|
Chris@0
|
2724 QString error;
|
Chris@0
|
2725 closeSession();
|
Chris@0
|
2726 createDocument();
|
Chris@0
|
2727
|
Chris@0
|
2728 PaneCallback callback(this);
|
Chris@0
|
2729 m_viewManager->clearSelections();
|
Chris@0
|
2730
|
Chris@87
|
2731 SVFileReader reader(m_document, callback, location);
|
Chris@0
|
2732 QXmlInputSource inputSource(&bzFile);
|
Chris@0
|
2733 reader.parse(inputSource);
|
Chris@0
|
2734
|
Chris@0
|
2735 if (!reader.isOK()) {
|
Chris@0
|
2736 error = tr("SV XML file read error:\n%1").arg(reader.getErrorString());
|
Chris@0
|
2737 }
|
Chris@0
|
2738
|
Chris@0
|
2739 bzFile.close();
|
Chris@0
|
2740
|
Chris@0
|
2741 bool ok = (error == "");
|
Chris@86
|
2742
|
Chris@86
|
2743 bool realFile = (location == path);
|
Chris@0
|
2744
|
Chris@0
|
2745 if (ok) {
|
Chris@86
|
2746
|
Chris@0
|
2747 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@86
|
2748 .arg(QFileInfo(location).fileName()));
|
Chris@86
|
2749
|
Chris@86
|
2750 if (realFile) m_sessionFile = path;
|
Chris@86
|
2751
|
Chris@0
|
2752 setupMenus();
|
Chris@0
|
2753 CommandHistory::getInstance()->clear();
|
Chris@0
|
2754 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2755 m_documentModified = false;
|
Chris@0
|
2756 updateMenuStates();
|
Chris@86
|
2757
|
Chris@86
|
2758 m_recentFiles.addFile(location);
|
Chris@86
|
2759
|
Chris@86
|
2760 if (realFile) {
|
Chris@88
|
2761 registerLastOpenedFilePath(FileFinder::SessionFile, path); // for file dialog
|
Chris@86
|
2762 }
|
Chris@86
|
2763
|
Chris@0
|
2764 } else {
|
Chris@0
|
2765 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2766 }
|
Chris@0
|
2767
|
Chris@82
|
2768 return ok ? FileOpenSucceeded : FileOpenFailed;
|
Chris@0
|
2769 }
|
Chris@0
|
2770
|
Chris@0
|
2771 void
|
Chris@0
|
2772 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
2773 {
|
Chris@70
|
2774 if (!m_abandoning && !checkSaveModified()) {
|
Chris@0
|
2775 e->ignore();
|
Chris@0
|
2776 return;
|
Chris@0
|
2777 }
|
Chris@0
|
2778
|
Chris@5
|
2779 QSettings settings;
|
Chris@5
|
2780 settings.beginGroup("MainWindow");
|
Chris@5
|
2781 settings.setValue("size", size());
|
Chris@5
|
2782 settings.setValue("position", pos());
|
Chris@5
|
2783 settings.endGroup();
|
Chris@5
|
2784
|
Chris@0
|
2785 e->accept();
|
Chris@0
|
2786 return;
|
Chris@0
|
2787 }
|
Chris@0
|
2788
|
Chris@0
|
2789 bool
|
Chris@11
|
2790 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
2791 {
|
Chris@11
|
2792 if (mayAskUser) {
|
Chris@11
|
2793 return checkSaveModified();
|
Chris@11
|
2794 } else {
|
Chris@11
|
2795 if (!m_documentModified) return true;
|
Chris@11
|
2796
|
Chris@11
|
2797 // If we can't check with the user first, then we can't save
|
Chris@11
|
2798 // to the original session file (even if we have it) -- have
|
Chris@11
|
2799 // to use a temporary file
|
Chris@11
|
2800
|
Chris@11
|
2801 QString svDirBase = ".sv1";
|
Chris@11
|
2802 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
2803
|
Chris@11
|
2804 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
2805 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
2806 } else {
|
Chris@11
|
2807 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
2808 }
|
Chris@11
|
2809
|
Chris@11
|
2810 // This name doesn't have to be unguessable
|
Chris@93
|
2811 #ifndef _WIN32
|
Chris@11
|
2812 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
2813 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
2814 .arg(QProcess().pid());
|
Chris@93
|
2815 #else
|
Chris@93
|
2816 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
2817 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
2818 #endif
|
Chris@11
|
2819 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
2820 if (saveSessionFile(fpath)) {
|
Chris@34
|
2821 m_recentFiles.addFile(fpath);
|
Chris@11
|
2822 return true;
|
Chris@11
|
2823 } else {
|
Chris@11
|
2824 return false;
|
Chris@11
|
2825 }
|
Chris@11
|
2826 }
|
Chris@11
|
2827 }
|
Chris@11
|
2828
|
Chris@11
|
2829 bool
|
Chris@0
|
2830 MainWindow::checkSaveModified()
|
Chris@0
|
2831 {
|
Chris@0
|
2832 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
2833 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
2834 // cancel.
|
Chris@0
|
2835
|
Chris@0
|
2836 if (!m_documentModified) return true;
|
Chris@0
|
2837
|
Chris@0
|
2838 int button =
|
Chris@0
|
2839 QMessageBox::warning(this,
|
Chris@0
|
2840 tr("Session modified"),
|
Chris@0
|
2841 tr("The current session has been modified.\nDo you want to save it?"),
|
Chris@0
|
2842 QMessageBox::Yes,
|
Chris@0
|
2843 QMessageBox::No,
|
Chris@0
|
2844 QMessageBox::Cancel);
|
Chris@0
|
2845
|
Chris@0
|
2846 if (button == QMessageBox::Yes) {
|
Chris@0
|
2847 saveSession();
|
Chris@0
|
2848 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@0
|
2849 return false;
|
Chris@0
|
2850 } else {
|
Chris@0
|
2851 return true; // saved, so it's safe to continue now
|
Chris@0
|
2852 }
|
Chris@0
|
2853 } else if (button == QMessageBox::No) {
|
Chris@0
|
2854 m_documentModified = false; // so we know to abandon it
|
Chris@0
|
2855 return true;
|
Chris@0
|
2856 }
|
Chris@0
|
2857
|
Chris@0
|
2858 // else cancel
|
Chris@0
|
2859 return false;
|
Chris@0
|
2860 }
|
Chris@0
|
2861
|
Chris@0
|
2862 void
|
Chris@0
|
2863 MainWindow::saveSession()
|
Chris@0
|
2864 {
|
Chris@0
|
2865 if (m_sessionFile != "") {
|
Chris@0
|
2866 if (!saveSessionFile(m_sessionFile)) {
|
Chris@0
|
2867 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@0
|
2868 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
2869 } else {
|
Chris@0
|
2870 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2871 documentRestored();
|
Chris@0
|
2872 }
|
Chris@0
|
2873 } else {
|
Chris@0
|
2874 saveSessionAs();
|
Chris@0
|
2875 }
|
Chris@0
|
2876 }
|
Chris@0
|
2877
|
Chris@0
|
2878 void
|
Chris@0
|
2879 MainWindow::saveSessionAs()
|
Chris@0
|
2880 {
|
Chris@0
|
2881 QString orig = m_audioFile;
|
Chris@0
|
2882 if (orig == "") orig = ".";
|
Chris@0
|
2883 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2884
|
Chris@88
|
2885 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
2886
|
Chris@81
|
2887 if (path == "") return;
|
Chris@0
|
2888
|
Chris@0
|
2889 if (!saveSessionFile(path)) {
|
Chris@0
|
2890 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@79
|
2891 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
2892 } else {
|
Chris@0
|
2893 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@0
|
2894 .arg(QFileInfo(path).fileName()));
|
Chris@0
|
2895 m_sessionFile = path;
|
Chris@0
|
2896 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2897 documentRestored();
|
Chris@34
|
2898 m_recentFiles.addFile(path);
|
Chris@0
|
2899 }
|
Chris@0
|
2900 }
|
Chris@0
|
2901
|
Chris@0
|
2902 bool
|
Chris@0
|
2903 MainWindow::saveSessionFile(QString path)
|
Chris@0
|
2904 {
|
Chris@0
|
2905 BZipFileDevice bzFile(path);
|
Chris@0
|
2906 if (!bzFile.open(QIODevice::WriteOnly)) {
|
Chris@0
|
2907 std::cerr << "Failed to open session file \"" << path.toStdString()
|
Chris@0
|
2908 << "\" for writing: "
|
Chris@0
|
2909 << bzFile.errorString().toStdString() << std::endl;
|
Chris@0
|
2910 return false;
|
Chris@0
|
2911 }
|
Chris@0
|
2912
|
Chris@0
|
2913 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
Chris@0
|
2914
|
Chris@0
|
2915 QTextStream out(&bzFile);
|
Chris@0
|
2916 toXml(out);
|
Chris@0
|
2917 out.flush();
|
Chris@0
|
2918
|
Chris@0
|
2919 QApplication::restoreOverrideCursor();
|
Chris@0
|
2920
|
Chris@84
|
2921 if (!bzFile.isOK()) {
|
Chris@0
|
2922 QMessageBox::critical(this, tr("Failed to write file"),
|
Chris@0
|
2923 tr("Failed to write to file \"%1\": %2")
|
Chris@0
|
2924 .arg(path).arg(bzFile.errorString()));
|
Chris@0
|
2925 bzFile.close();
|
Chris@0
|
2926 return false;
|
Chris@0
|
2927 }
|
Chris@0
|
2928
|
Chris@0
|
2929 bzFile.close();
|
Chris@0
|
2930 return true;
|
Chris@0
|
2931 }
|
Chris@0
|
2932
|
Chris@0
|
2933 void
|
Chris@0
|
2934 MainWindow::toXml(QTextStream &out)
|
Chris@0
|
2935 {
|
Chris@0
|
2936 QString indent(" ");
|
Chris@0
|
2937
|
Chris@0
|
2938 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
Chris@0
|
2939 out << "<!DOCTYPE sonic-visualiser>\n";
|
Chris@0
|
2940 out << "<sv>\n";
|
Chris@0
|
2941
|
Chris@0
|
2942 m_document->toXml(out, "", "");
|
Chris@0
|
2943
|
Chris@0
|
2944 out << "<display>\n";
|
Chris@0
|
2945
|
Chris@0
|
2946 out << QString(" <window width=\"%1\" height=\"%2\"/>\n")
|
Chris@0
|
2947 .arg(width()).arg(height());
|
Chris@0
|
2948
|
Chris@0
|
2949 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
2950
|
Chris@0
|
2951 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
2952
|
Chris@0
|
2953 if (pane) {
|
Chris@0
|
2954 pane->toXml(out, indent);
|
Chris@0
|
2955 }
|
Chris@0
|
2956 }
|
Chris@0
|
2957
|
Chris@0
|
2958 out << "</display>\n";
|
Chris@0
|
2959
|
Chris@0
|
2960 m_viewManager->getSelection().toXml(out);
|
Chris@0
|
2961
|
Chris@0
|
2962 out << "</sv>\n";
|
Chris@0
|
2963 }
|
Chris@0
|
2964
|
Chris@0
|
2965 Pane *
|
Chris@0
|
2966 MainWindow::addPaneToStack()
|
Chris@0
|
2967 {
|
Chris@0
|
2968 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2969 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2970 return command->getPane();
|
Chris@0
|
2971 }
|
Chris@0
|
2972
|
Chris@0
|
2973 void
|
Chris@0
|
2974 MainWindow::zoomIn()
|
Chris@0
|
2975 {
|
Chris@0
|
2976 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2977 if (currentPane) currentPane->zoom(true);
|
Chris@0
|
2978 }
|
Chris@0
|
2979
|
Chris@0
|
2980 void
|
Chris@0
|
2981 MainWindow::zoomOut()
|
Chris@0
|
2982 {
|
Chris@0
|
2983 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2984 if (currentPane) currentPane->zoom(false);
|
Chris@0
|
2985 }
|
Chris@0
|
2986
|
Chris@0
|
2987 void
|
Chris@0
|
2988 MainWindow::zoomToFit()
|
Chris@0
|
2989 {
|
Chris@0
|
2990 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
2991 if (!currentPane) return;
|
Chris@0
|
2992
|
Chris@0
|
2993 Model *model = getMainModel();
|
Chris@0
|
2994 if (!model) return;
|
Chris@0
|
2995
|
Chris@0
|
2996 size_t start = model->getStartFrame();
|
Chris@0
|
2997 size_t end = model->getEndFrame();
|
Chris@0
|
2998 size_t pixels = currentPane->width();
|
Chris@0
|
2999 size_t zoomLevel = (end - start) / pixels;
|
Chris@0
|
3000
|
Chris@0
|
3001 currentPane->setZoomLevel(zoomLevel);
|
Chris@0
|
3002 currentPane->setStartFrame(start);
|
Chris@0
|
3003 }
|
Chris@0
|
3004
|
Chris@0
|
3005 void
|
Chris@0
|
3006 MainWindow::zoomDefault()
|
Chris@0
|
3007 {
|
Chris@0
|
3008 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3009 if (currentPane) currentPane->setZoomLevel(1024);
|
Chris@0
|
3010 }
|
Chris@0
|
3011
|
Chris@0
|
3012 void
|
Chris@0
|
3013 MainWindow::scrollLeft()
|
Chris@0
|
3014 {
|
Chris@0
|
3015 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3016 if (currentPane) currentPane->scroll(false, false);
|
Chris@0
|
3017 }
|
Chris@0
|
3018
|
Chris@0
|
3019 void
|
Chris@0
|
3020 MainWindow::jumpLeft()
|
Chris@0
|
3021 {
|
Chris@0
|
3022 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3023 if (currentPane) currentPane->scroll(false, true);
|
Chris@0
|
3024 }
|
Chris@0
|
3025
|
Chris@0
|
3026 void
|
Chris@0
|
3027 MainWindow::scrollRight()
|
Chris@0
|
3028 {
|
Chris@0
|
3029 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3030 if (currentPane) currentPane->scroll(true, false);
|
Chris@0
|
3031 }
|
Chris@0
|
3032
|
Chris@0
|
3033 void
|
Chris@0
|
3034 MainWindow::jumpRight()
|
Chris@0
|
3035 {
|
Chris@0
|
3036 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
3037 if (currentPane) currentPane->scroll(true, true);
|
Chris@0
|
3038 }
|
Chris@0
|
3039
|
Chris@0
|
3040 void
|
Chris@0
|
3041 MainWindow::showNoOverlays()
|
Chris@0
|
3042 {
|
Chris@0
|
3043 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
|
Chris@0
|
3044 }
|
Chris@0
|
3045
|
Chris@0
|
3046 void
|
Chris@90
|
3047 MainWindow::showMinimalOverlays()
|
Chris@0
|
3048 {
|
Chris@90
|
3049 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@0
|
3050 }
|
Chris@0
|
3051
|
Chris@0
|
3052 void
|
Chris@90
|
3053 MainWindow::showStandardOverlays()
|
Chris@90
|
3054 {
|
Chris@90
|
3055 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
|
Chris@90
|
3056 }
|
Chris@90
|
3057
|
Chris@90
|
3058 void
|
Chris@90
|
3059 MainWindow::showAllOverlays()
|
Chris@0
|
3060 {
|
Chris@0
|
3061 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
|
Chris@0
|
3062 }
|
Chris@0
|
3063
|
Chris@0
|
3064 void
|
Chris@7
|
3065 MainWindow::toggleZoomWheels()
|
Chris@7
|
3066 {
|
Chris@7
|
3067 if (m_viewManager->getZoomWheelsEnabled()) {
|
Chris@7
|
3068 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@7
|
3069 } else {
|
Chris@7
|
3070 m_viewManager->setZoomWheelsEnabled(true);
|
Chris@7
|
3071 }
|
Chris@7
|
3072 }
|
Chris@7
|
3073
|
Chris@7
|
3074 void
|
Chris@72
|
3075 MainWindow::togglePropertyBoxes()
|
Chris@72
|
3076 {
|
Chris@72
|
3077 if (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks) {
|
Chris@72
|
3078 if (Preferences::getInstance()->getPropertyBoxLayout() ==
|
Chris@72
|
3079 Preferences::VerticallyStacked) {
|
Chris@72
|
3080 m_paneStack->setLayoutStyle(PaneStack::PropertyStackPerPaneLayout);
|
Chris@72
|
3081 } else {
|
Chris@72
|
3082 m_paneStack->setLayoutStyle(PaneStack::SinglePropertyStackLayout);
|
Chris@72
|
3083 }
|
Chris@72
|
3084 } else {
|
Chris@72
|
3085 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@72
|
3086 }
|
Chris@72
|
3087 }
|
Chris@72
|
3088
|
Chris@72
|
3089 void
|
Chris@90
|
3090 MainWindow::toggleStatusBar()
|
Chris@90
|
3091 {
|
Chris@90
|
3092 QSettings settings;
|
Chris@90
|
3093 settings.beginGroup("MainWindow");
|
Chris@90
|
3094 bool sb = settings.value("showstatusbar", true).toBool();
|
Chris@90
|
3095
|
Chris@90
|
3096 if (sb) {
|
Chris@90
|
3097 statusBar()->hide();
|
Chris@90
|
3098 } else {
|
Chris@90
|
3099 statusBar()->show();
|
Chris@90
|
3100 }
|
Chris@90
|
3101
|
Chris@90
|
3102 settings.setValue("showstatusbar", !sb);
|
Chris@90
|
3103
|
Chris@90
|
3104 settings.endGroup();
|
Chris@90
|
3105 }
|
Chris@90
|
3106
|
Chris@90
|
3107 void
|
Chris@72
|
3108 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
3109 {
|
Chris@72
|
3110 if (name == "Property Box Layout") {
|
Chris@72
|
3111 if (m_paneStack->getLayoutStyle() != PaneStack::NoPropertyStacks) {
|
Chris@72
|
3112 if (Preferences::getInstance()->getPropertyBoxLayout() ==
|
Chris@72
|
3113 Preferences::VerticallyStacked) {
|
Chris@72
|
3114 m_paneStack->setLayoutStyle(PaneStack::PropertyStackPerPaneLayout);
|
Chris@72
|
3115 } else {
|
Chris@72
|
3116 m_paneStack->setLayoutStyle(PaneStack::SinglePropertyStackLayout);
|
Chris@72
|
3117 }
|
Chris@72
|
3118 }
|
Chris@72
|
3119 }
|
Chris@72
|
3120 }
|
Chris@72
|
3121
|
Chris@72
|
3122 void
|
Chris@0
|
3123 MainWindow::play()
|
Chris@0
|
3124 {
|
Chris@0
|
3125 if (m_playSource->isPlaying()) {
|
Chris@0
|
3126 m_playSource->stop();
|
Chris@0
|
3127 } else {
|
Chris@0
|
3128 m_playSource->play(m_viewManager->getPlaybackFrame());
|
Chris@0
|
3129 }
|
Chris@0
|
3130 }
|
Chris@0
|
3131
|
Chris@0
|
3132 void
|
Chris@0
|
3133 MainWindow::ffwd()
|
Chris@0
|
3134 {
|
Chris@0
|
3135 if (!getMainModel()) return;
|
Chris@0
|
3136
|
Chris@0
|
3137 int frame = m_viewManager->getPlaybackFrame();
|
Chris@0
|
3138 ++frame;
|
Chris@0
|
3139
|
Chris@0
|
3140 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3141 if (!pane) return;
|
Chris@0
|
3142
|
Chris@0
|
3143 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3144
|
Chris@0
|
3145 if (!dynamic_cast<TimeInstantLayer *>(layer) &&
|
Chris@0
|
3146 !dynamic_cast<TimeValueLayer *>(layer)) return;
|
Chris@0
|
3147
|
Chris@0
|
3148 size_t resolution = 0;
|
Chris@0
|
3149 if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapRight)) {
|
Chris@0
|
3150 frame = getMainModel()->getEndFrame();
|
Chris@0
|
3151 }
|
Chris@0
|
3152
|
Chris@0
|
3153 m_viewManager->setPlaybackFrame(frame);
|
Chris@0
|
3154 }
|
Chris@0
|
3155
|
Chris@0
|
3156 void
|
Chris@0
|
3157 MainWindow::ffwdEnd()
|
Chris@0
|
3158 {
|
Chris@0
|
3159 if (!getMainModel()) return;
|
Chris@0
|
3160 m_viewManager->setPlaybackFrame(getMainModel()->getEndFrame());
|
Chris@0
|
3161 }
|
Chris@0
|
3162
|
Chris@0
|
3163 void
|
Chris@0
|
3164 MainWindow::rewind()
|
Chris@0
|
3165 {
|
Chris@0
|
3166 if (!getMainModel()) return;
|
Chris@0
|
3167
|
Chris@0
|
3168 int frame = m_viewManager->getPlaybackFrame();
|
Chris@0
|
3169 if (frame > 0) --frame;
|
Chris@0
|
3170
|
Chris@0
|
3171 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3172 if (!pane) return;
|
Chris@0
|
3173
|
Chris@0
|
3174 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3175
|
Chris@0
|
3176 if (!dynamic_cast<TimeInstantLayer *>(layer) &&
|
Chris@0
|
3177 !dynamic_cast<TimeValueLayer *>(layer)) return;
|
Chris@0
|
3178
|
Chris@0
|
3179 size_t resolution = 0;
|
Chris@0
|
3180 if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapLeft)) {
|
Chris@0
|
3181 frame = getMainModel()->getEndFrame();
|
Chris@0
|
3182 }
|
Chris@0
|
3183
|
Chris@0
|
3184 m_viewManager->setPlaybackFrame(frame);
|
Chris@0
|
3185 }
|
Chris@0
|
3186
|
Chris@0
|
3187 void
|
Chris@0
|
3188 MainWindow::rewindStart()
|
Chris@0
|
3189 {
|
Chris@0
|
3190 if (!getMainModel()) return;
|
Chris@0
|
3191 m_viewManager->setPlaybackFrame(getMainModel()->getStartFrame());
|
Chris@0
|
3192 }
|
Chris@0
|
3193
|
Chris@0
|
3194 void
|
Chris@0
|
3195 MainWindow::stop()
|
Chris@0
|
3196 {
|
Chris@0
|
3197 m_playSource->stop();
|
Chris@0
|
3198 }
|
Chris@0
|
3199
|
Chris@0
|
3200 void
|
Chris@0
|
3201 MainWindow::addPane()
|
Chris@0
|
3202 {
|
Chris@0
|
3203 QObject *s = sender();
|
Chris@0
|
3204 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3205
|
Chris@0
|
3206 if (!action) {
|
Chris@0
|
3207 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@0
|
3208 << std::endl;
|
Chris@0
|
3209 return;
|
Chris@0
|
3210 }
|
Chris@0
|
3211
|
Chris@0
|
3212 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
3213
|
Chris@0
|
3214 if (i == m_paneActions.end()) {
|
Chris@0
|
3215 std::cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@0
|
3216 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3217 return;
|
Chris@0
|
3218 }
|
Chris@0
|
3219
|
Chris@69
|
3220 addPane(i->second, action->text());
|
Chris@69
|
3221 }
|
Chris@69
|
3222
|
Chris@69
|
3223 void
|
Chris@69
|
3224 MainWindow::addPane(const PaneConfiguration &configuration, QString text)
|
Chris@69
|
3225 {
|
Chris@69
|
3226 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
3227
|
Chris@0
|
3228 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
3229 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3230
|
Chris@0
|
3231 Pane *pane = command->getPane();
|
Chris@0
|
3232
|
Chris@69
|
3233 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@7
|
3234 pane->setPlaybackFollow(View::PlaybackScrollContinuous);
|
Chris@7
|
3235 }
|
Chris@7
|
3236
|
Chris@69
|
3237 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
3238 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
3239
|
Chris@0
|
3240 if (!m_timeRulerLayer) {
|
Chris@0
|
3241 // std::cerr << "no time ruler layer, creating one" << std::endl;
|
Chris@0
|
3242 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
3243 (LayerFactory::TimeRuler);
|
Chris@0
|
3244 }
|
Chris@0
|
3245
|
Chris@0
|
3246 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
|
Chris@0
|
3247
|
Chris@0
|
3248 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3249 }
|
Chris@0
|
3250
|
Chris@69
|
3251 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
3252
|
Chris@69
|
3253 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
3254 Model *model = 0;
|
Chris@66
|
3255
|
Chris@66
|
3256 if (suggestedModel) {
|
Chris@66
|
3257
|
Chris@66
|
3258 // check its validity
|
Chris@66
|
3259 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
3260 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
3261 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
3262 model = suggestedModel;
|
Chris@66
|
3263 break;
|
Chris@66
|
3264 }
|
Chris@66
|
3265 }
|
Chris@66
|
3266
|
Chris@66
|
3267 if (!model) {
|
Chris@66
|
3268 std::cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
3269 << " appears in pane action map, but is not reported "
|
Chris@66
|
3270 << "by document as a valid transform source" << std::endl;
|
Chris@66
|
3271 }
|
Chris@66
|
3272 }
|
Chris@66
|
3273
|
Chris@66
|
3274 if (!model) model = m_document->getMainModel();
|
Chris@66
|
3275
|
Chris@66
|
3276 m_document->setModel(newLayer, model);
|
Chris@66
|
3277
|
Chris@69
|
3278 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
3279 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3280
|
Chris@0
|
3281 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
3282 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3283
|
Chris@73
|
3284 std::cerr << "MainWindow::addPane: global centre frame is "
|
Chris@73
|
3285 << m_viewManager->getGlobalCentreFrame() << std::endl;
|
Chris@73
|
3286 pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
3287
|
Chris@0
|
3288 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3289
|
Chris@0
|
3290 updateMenuStates();
|
Chris@0
|
3291 }
|
Chris@0
|
3292
|
Chris@0
|
3293 MainWindow::AddPaneCommand::AddPaneCommand(MainWindow *mw) :
|
Chris@0
|
3294 m_mw(mw),
|
Chris@0
|
3295 m_pane(0),
|
Chris@0
|
3296 m_prevCurrentPane(0),
|
Chris@0
|
3297 m_added(false)
|
Chris@0
|
3298 {
|
Chris@0
|
3299 }
|
Chris@0
|
3300
|
Chris@0
|
3301 MainWindow::AddPaneCommand::~AddPaneCommand()
|
Chris@0
|
3302 {
|
Chris@0
|
3303 if (m_pane && !m_added) {
|
Chris@0
|
3304 m_mw->m_paneStack->deletePane(m_pane);
|
Chris@0
|
3305 }
|
Chris@0
|
3306 }
|
Chris@0
|
3307
|
Chris@0
|
3308 QString
|
Chris@0
|
3309 MainWindow::AddPaneCommand::getName() const
|
Chris@0
|
3310 {
|
Chris@0
|
3311 return tr("Add Pane");
|
Chris@0
|
3312 }
|
Chris@0
|
3313
|
Chris@0
|
3314 void
|
Chris@0
|
3315 MainWindow::AddPaneCommand::execute()
|
Chris@0
|
3316 {
|
Chris@0
|
3317 if (!m_pane) {
|
Chris@0
|
3318 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane();
|
Chris@0
|
3319 m_pane = m_mw->m_paneStack->addPane();
|
Chris@90
|
3320
|
Chris@90
|
3321 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@90
|
3322 m_mw->statusBar(), SLOT(showMessage(const QString &)));
|
Chris@0
|
3323 } else {
|
Chris@0
|
3324 m_mw->m_paneStack->showPane(m_pane);
|
Chris@0
|
3325 }
|
Chris@0
|
3326
|
Chris@0
|
3327 m_mw->m_paneStack->setCurrentPane(m_pane);
|
Chris@65
|
3328 m_mw->m_overview->registerView(m_pane);
|
Chris@0
|
3329 m_added = true;
|
Chris@0
|
3330 }
|
Chris@0
|
3331
|
Chris@0
|
3332 void
|
Chris@0
|
3333 MainWindow::AddPaneCommand::unexecute()
|
Chris@0
|
3334 {
|
Chris@0
|
3335 m_mw->m_paneStack->hidePane(m_pane);
|
Chris@0
|
3336 m_mw->m_paneStack->setCurrentPane(m_prevCurrentPane);
|
Chris@65
|
3337 m_mw->m_overview->unregisterView(m_pane);
|
Chris@0
|
3338 m_added = false;
|
Chris@0
|
3339 }
|
Chris@0
|
3340
|
Chris@0
|
3341 MainWindow::RemovePaneCommand::RemovePaneCommand(MainWindow *mw, Pane *pane) :
|
Chris@0
|
3342 m_mw(mw),
|
Chris@0
|
3343 m_pane(pane),
|
Chris@0
|
3344 m_added(true)
|
Chris@0
|
3345 {
|
Chris@0
|
3346 }
|
Chris@0
|
3347
|
Chris@0
|
3348 MainWindow::RemovePaneCommand::~RemovePaneCommand()
|
Chris@0
|
3349 {
|
Chris@0
|
3350 if (m_pane && !m_added) {
|
Chris@0
|
3351 m_mw->m_paneStack->deletePane(m_pane);
|
Chris@0
|
3352 }
|
Chris@0
|
3353 }
|
Chris@0
|
3354
|
Chris@0
|
3355 QString
|
Chris@0
|
3356 MainWindow::RemovePaneCommand::getName() const
|
Chris@0
|
3357 {
|
Chris@0
|
3358 return tr("Remove Pane");
|
Chris@0
|
3359 }
|
Chris@0
|
3360
|
Chris@0
|
3361 void
|
Chris@0
|
3362 MainWindow::RemovePaneCommand::execute()
|
Chris@0
|
3363 {
|
Chris@0
|
3364 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane();
|
Chris@0
|
3365 m_mw->m_paneStack->hidePane(m_pane);
|
Chris@65
|
3366 m_mw->m_overview->unregisterView(m_pane);
|
Chris@0
|
3367 m_added = false;
|
Chris@0
|
3368 }
|
Chris@0
|
3369
|
Chris@0
|
3370 void
|
Chris@0
|
3371 MainWindow::RemovePaneCommand::unexecute()
|
Chris@0
|
3372 {
|
Chris@0
|
3373 m_mw->m_paneStack->showPane(m_pane);
|
Chris@0
|
3374 m_mw->m_paneStack->setCurrentPane(m_prevCurrentPane);
|
Chris@65
|
3375 m_mw->m_overview->registerView(m_pane);
|
Chris@0
|
3376 m_added = true;
|
Chris@0
|
3377 }
|
Chris@0
|
3378
|
Chris@0
|
3379 void
|
Chris@0
|
3380 MainWindow::addLayer()
|
Chris@0
|
3381 {
|
Chris@0
|
3382 QObject *s = sender();
|
Chris@0
|
3383 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3384
|
Chris@0
|
3385 if (!action) {
|
Chris@0
|
3386 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@0
|
3387 << std::endl;
|
Chris@0
|
3388 return;
|
Chris@0
|
3389 }
|
Chris@0
|
3390
|
Chris@0
|
3391 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3392
|
Chris@0
|
3393 if (!pane) {
|
Chris@0
|
3394 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@0
|
3395 return;
|
Chris@0
|
3396 }
|
Chris@0
|
3397
|
Chris@0
|
3398 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
3399
|
Chris@0
|
3400 if (ei != m_existingLayerActions.end()) {
|
Chris@0
|
3401 Layer *newLayer = ei->second;
|
Chris@0
|
3402 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3403 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3404 return;
|
Chris@0
|
3405 }
|
Chris@0
|
3406
|
Chris@95
|
3407 ei = m_sliceActions.find(action);
|
Chris@95
|
3408
|
Chris@95
|
3409 if (ei != m_sliceActions.end()) {
|
Chris@95
|
3410 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
3411 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
3412 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
3413 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
3414 if (source && dest) {
|
Chris@95
|
3415 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
3416 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
3417 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
3418 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
3419 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
3420 }
|
Chris@95
|
3421 m_document->addLayerToView(pane, newLayer);
|
Chris@95
|
3422 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@95
|
3423 return;
|
Chris@95
|
3424 }
|
Chris@95
|
3425
|
Chris@34
|
3426 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
3427
|
Chris@34
|
3428 if (i == m_transformActions.end()) {
|
Chris@0
|
3429
|
Chris@0
|
3430 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@0
|
3431
|
Chris@0
|
3432 if (i == m_layerActions.end()) {
|
Chris@0
|
3433 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@0
|
3434 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3435 return;
|
Chris@0
|
3436 }
|
Chris@0
|
3437
|
Chris@0
|
3438 LayerFactory::LayerType type = i->second;
|
Chris@0
|
3439
|
Chris@0
|
3440 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@0
|
3441 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@0
|
3442
|
Chris@0
|
3443 Layer *newLayer;
|
Chris@0
|
3444
|
Chris@0
|
3445 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@0
|
3446
|
Chris@0
|
3447 newLayer = m_document->createEmptyLayer(type);
|
Chris@0
|
3448 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@0
|
3449
|
Chris@0
|
3450 } else {
|
Chris@0
|
3451
|
Chris@0
|
3452 newLayer = m_document->createMainModelLayer(type);
|
Chris@0
|
3453 }
|
Chris@0
|
3454
|
Chris@0
|
3455 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3456 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3457
|
Chris@0
|
3458 return;
|
Chris@0
|
3459 }
|
Chris@0
|
3460
|
Chris@107
|
3461 TransformId transform = i->second;
|
Chris@0
|
3462 TransformFactory *factory = TransformFactory::getInstance();
|
Chris@0
|
3463
|
Chris@0
|
3464 QString configurationXml;
|
Chris@0
|
3465
|
Chris@0
|
3466 int channel = -1;
|
Chris@0
|
3467 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
3468 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3469 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@0
|
3470 if (c != -1) {
|
Chris@0
|
3471 channel = c;
|
Chris@0
|
3472 break;
|
Chris@0
|
3473 }
|
Chris@0
|
3474 }
|
Chris@0
|
3475
|
Chris@33
|
3476 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
3477 // supposed to be configurable, because we need to let the user
|
Chris@33
|
3478 // change the execution context (block size etc).
|
Chris@0
|
3479
|
Chris@27
|
3480 PluginTransform::ExecutionContext context(channel);
|
Chris@27
|
3481
|
Chris@66
|
3482 std::vector<Model *> candidateInputModels =
|
Chris@66
|
3483 m_document->getTransformInputModels();
|
Chris@53
|
3484
|
Chris@54
|
3485 Model *inputModel = factory->getConfigurationForTransform(transform,
|
Chris@54
|
3486 candidateInputModels,
|
Chris@54
|
3487 context,
|
Chris@54
|
3488 configurationXml,
|
Chris@54
|
3489 m_playSource);
|
Chris@54
|
3490 if (!inputModel) return;
|
Chris@54
|
3491
|
Chris@54
|
3492 std::cerr << "Input model is " << inputModel << " \"" << inputModel->objectName().toStdString() << std::endl;
|
Chris@0
|
3493
|
Chris@0
|
3494 Layer *newLayer = m_document->createDerivedLayer(transform,
|
Chris@54
|
3495 inputModel,
|
Chris@27
|
3496 context,
|
Chris@0
|
3497 configurationXml);
|
Chris@0
|
3498
|
Chris@0
|
3499 if (newLayer) {
|
Chris@0
|
3500 m_document->addLayerToView(pane, newLayer);
|
Chris@27
|
3501 m_document->setChannel(newLayer, context.channel);
|
Chris@34
|
3502 m_recentTransforms.add(transform);
|
Chris@70
|
3503 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3504 }
|
Chris@0
|
3505
|
Chris@0
|
3506 updateMenuStates();
|
Chris@0
|
3507 }
|
Chris@0
|
3508
|
Chris@0
|
3509 void
|
Chris@0
|
3510 MainWindow::deleteCurrentPane()
|
Chris@0
|
3511 {
|
Chris@0
|
3512 CommandHistory::getInstance()->startCompoundOperation
|
Chris@0
|
3513 (tr("Delete Pane"), true);
|
Chris@0
|
3514
|
Chris@0
|
3515 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3516 if (pane) {
|
Chris@0
|
3517 while (pane->getLayerCount() > 0) {
|
Chris@0
|
3518 Layer *layer = pane->getLayer(0);
|
Chris@0
|
3519 if (layer) {
|
Chris@0
|
3520 m_document->removeLayerFromView(pane, layer);
|
Chris@0
|
3521 } else {
|
Chris@0
|
3522 break;
|
Chris@0
|
3523 }
|
Chris@0
|
3524 }
|
Chris@0
|
3525
|
Chris@0
|
3526 RemovePaneCommand *command = new RemovePaneCommand(this, pane);
|
Chris@0
|
3527 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3528 }
|
Chris@0
|
3529
|
Chris@0
|
3530 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3531
|
Chris@0
|
3532 updateMenuStates();
|
Chris@0
|
3533 }
|
Chris@0
|
3534
|
Chris@0
|
3535 void
|
Chris@0
|
3536 MainWindow::deleteCurrentLayer()
|
Chris@0
|
3537 {
|
Chris@0
|
3538 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3539 if (pane) {
|
Chris@0
|
3540 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3541 if (layer) {
|
Chris@0
|
3542 m_document->removeLayerFromView(pane, layer);
|
Chris@0
|
3543 }
|
Chris@0
|
3544 }
|
Chris@0
|
3545 updateMenuStates();
|
Chris@0
|
3546 }
|
Chris@0
|
3547
|
Chris@0
|
3548 void
|
Chris@0
|
3549 MainWindow::renameCurrentLayer()
|
Chris@0
|
3550 {
|
Chris@0
|
3551 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3552 if (pane) {
|
Chris@0
|
3553 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3554 if (layer) {
|
Chris@0
|
3555 bool ok = false;
|
Chris@0
|
3556 QString newName = QInputDialog::getText
|
Chris@0
|
3557 (this, tr("Rename Layer"),
|
Chris@0
|
3558 tr("New name for this layer:"),
|
Chris@0
|
3559 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@0
|
3560 if (ok) {
|
Chris@0
|
3561 layer->setObjectName(newName);
|
Chris@95
|
3562 setupExistingLayersMenus();
|
Chris@0
|
3563 }
|
Chris@0
|
3564 }
|
Chris@0
|
3565 }
|
Chris@0
|
3566 }
|
Chris@0
|
3567
|
Chris@0
|
3568 void
|
Chris@59
|
3569 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
3570 {
|
Chris@59
|
3571 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@60
|
3572
|
Chris@60
|
3573 float percent = m_playSpeed->mappedValue();
|
Chris@60
|
3574
|
Chris@60
|
3575 float factor = mapper.getFactorForValue(percent);
|
Chris@60
|
3576
|
Chris@60
|
3577 // float factor = mapper.getFactorForPosition(position);
|
Chris@60
|
3578 // float percent = mapper.getValueForPosition(position);
|
Chris@60
|
3579
|
Chris@60
|
3580 std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
|
Chris@60
|
3581
|
Chris@60
|
3582 //!!! bool slow = (position < 100);
|
Chris@59
|
3583 bool something = (position != 100);
|
Chris@60
|
3584 /*!!!
|
Chris@59
|
3585 int pc = lrintf(percent);
|
Chris@21
|
3586
|
Chris@21
|
3587 m_playSpeed->setToolTip(tr("Playback speed: %1%2%")
|
Chris@60
|
3588 .arg(!slow ? "+" : "")
|
Chris@21
|
3589 .arg(pc));
|
Chris@60
|
3590 */
|
Chris@25
|
3591 m_playSharpen->setEnabled(something);
|
Chris@26
|
3592 m_playMono->setEnabled(something);
|
Chris@25
|
3593 bool sharpen = (something && m_playSharpen->isChecked());
|
Chris@26
|
3594 bool mono = (something && m_playMono->isChecked());
|
Chris@26
|
3595 m_playSource->setTimeStretch(factor, sharpen, mono);
|
Chris@16
|
3596 }
|
Chris@16
|
3597
|
Chris@16
|
3598 void
|
Chris@16
|
3599 MainWindow::playSharpenToggled()
|
Chris@16
|
3600 {
|
Chris@21
|
3601 QSettings settings;
|
Chris@21
|
3602 settings.beginGroup("MainWindow");
|
Chris@21
|
3603 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@21
|
3604 settings.endGroup();
|
Chris@21
|
3605
|
Chris@16
|
3606 playSpeedChanged(m_playSpeed->value());
|
Chris@0
|
3607 }
|
Chris@0
|
3608
|
Chris@0
|
3609 void
|
Chris@26
|
3610 MainWindow::playMonoToggled()
|
Chris@26
|
3611 {
|
Chris@26
|
3612 QSettings settings;
|
Chris@26
|
3613 settings.beginGroup("MainWindow");
|
Chris@26
|
3614 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@26
|
3615 settings.endGroup();
|
Chris@26
|
3616
|
Chris@26
|
3617 playSpeedChanged(m_playSpeed->value());
|
Chris@26
|
3618 }
|
Chris@26
|
3619
|
Chris@26
|
3620 void
|
Chris@0
|
3621 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
3622 {
|
Chris@0
|
3623 m_fader->setPeakLeft(left);
|
Chris@0
|
3624 m_fader->setPeakRight(right);
|
Chris@0
|
3625 }
|
Chris@0
|
3626
|
Chris@0
|
3627 void
|
Chris@0
|
3628 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
3629 bool willResample)
|
Chris@0
|
3630 {
|
Chris@0
|
3631 if (!willResample) {
|
Chris@0
|
3632 //!!! more helpful message needed
|
Chris@0
|
3633 QMessageBox::information
|
Chris@0
|
3634 (this, tr("Sample rate mismatch"),
|
Chris@0
|
3635 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
|
3636 .arg(requested).arg(actual));
|
Chris@0
|
3637 }
|
Chris@0
|
3638
|
Chris@0
|
3639 /*!!! Let's not do this for now, and see how we go -- now that we're putting
|
Chris@0
|
3640 sample rate information in the status bar
|
Chris@0
|
3641
|
Chris@0
|
3642 QMessageBox::information
|
Chris@0
|
3643 (this, tr("Sample rate mismatch"),
|
Chris@0
|
3644 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
|
3645 .arg(requested).arg(actual));
|
Chris@0
|
3646 */
|
Chris@0
|
3647
|
Chris@0
|
3648 updateDescriptionLabel();
|
Chris@0
|
3649 }
|
Chris@0
|
3650
|
Chris@0
|
3651 void
|
Chris@42
|
3652 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
3653 {
|
Chris@42
|
3654 QMessageBox::information
|
Chris@42
|
3655 (this, tr("Audio processing overload"),
|
Chris@42
|
3656 tr("Audio effects plugin auditioning has been disabled\ndue to a processing overload."));
|
Chris@42
|
3657 }
|
Chris@42
|
3658
|
Chris@42
|
3659 void
|
Chris@0
|
3660 MainWindow::layerAdded(Layer *layer)
|
Chris@0
|
3661 {
|
Chris@0
|
3662 // std::cerr << "MainWindow::layerAdded(" << layer << ")" << std::endl;
|
Chris@0
|
3663 // setupExistingLayersMenu();
|
Chris@0
|
3664 updateMenuStates();
|
Chris@0
|
3665 }
|
Chris@0
|
3666
|
Chris@0
|
3667 void
|
Chris@0
|
3668 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
3669 {
|
Chris@0
|
3670 // std::cerr << "MainWindow::layerRemoved(" << layer << ")" << std::endl;
|
Chris@95
|
3671 setupExistingLayersMenus();
|
Chris@0
|
3672 updateMenuStates();
|
Chris@0
|
3673 }
|
Chris@0
|
3674
|
Chris@0
|
3675 void
|
Chris@0
|
3676 MainWindow::layerAboutToBeDeleted(Layer *layer)
|
Chris@0
|
3677 {
|
Chris@0
|
3678 // std::cerr << "MainWindow::layerAboutToBeDeleted(" << layer << ")" << std::endl;
|
Chris@0
|
3679 if (layer == m_timeRulerLayer) {
|
Chris@0
|
3680 // std::cerr << "(this is the time ruler layer)" << std::endl;
|
Chris@0
|
3681 m_timeRulerLayer = 0;
|
Chris@0
|
3682 }
|
Chris@0
|
3683 }
|
Chris@0
|
3684
|
Chris@0
|
3685 void
|
Chris@0
|
3686 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
3687 {
|
Chris@0
|
3688 // std::cerr << "MainWindow::layerInAView(" << layer << "," << inAView << ")" << std::endl;
|
Chris@0
|
3689
|
Chris@0
|
3690 // Check whether we need to add or remove model from play source
|
Chris@0
|
3691 Model *model = layer->getModel();
|
Chris@0
|
3692 if (model) {
|
Chris@0
|
3693 if (inAView) {
|
Chris@0
|
3694 m_playSource->addModel(model);
|
Chris@0
|
3695 } else {
|
Chris@0
|
3696 bool found = false;
|
Chris@0
|
3697 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
3698 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
3699 if (!pane) continue;
|
Chris@0
|
3700 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3701 Layer *pl = pane->getLayer(j);
|
Chris@0
|
3702 if (pl && pl->getModel() == model) {
|
Chris@0
|
3703 found = true;
|
Chris@0
|
3704 break;
|
Chris@0
|
3705 }
|
Chris@0
|
3706 }
|
Chris@0
|
3707 if (found) break;
|
Chris@0
|
3708 }
|
Chris@0
|
3709 if (!found) m_playSource->removeModel(model);
|
Chris@0
|
3710 }
|
Chris@0
|
3711 }
|
Chris@0
|
3712
|
Chris@95
|
3713 setupExistingLayersMenus();
|
Chris@0
|
3714 updateMenuStates();
|
Chris@0
|
3715 }
|
Chris@0
|
3716
|
Chris@0
|
3717 void
|
Chris@0
|
3718 MainWindow::modelAdded(Model *model)
|
Chris@0
|
3719 {
|
Chris@0
|
3720 // std::cerr << "MainWindow::modelAdded(" << model << ")" << std::endl;
|
Chris@0
|
3721 m_playSource->addModel(model);
|
Chris@66
|
3722 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
3723 setupPaneAndLayerMenus();
|
Chris@66
|
3724 }
|
Chris@0
|
3725 }
|
Chris@0
|
3726
|
Chris@0
|
3727 void
|
Chris@0
|
3728 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
3729 {
|
Chris@0
|
3730 // std::cerr << "MainWindow::mainModelChanged(" << model << ")" << std::endl;
|
Chris@0
|
3731 updateDescriptionLabel();
|
Chris@0
|
3732 m_panLayer->setModel(model);
|
Chris@0
|
3733 if (model) m_viewManager->setMainModelSampleRate(model->getSampleRate());
|
Chris@46
|
3734 if (model && !m_playTarget && m_audioOutput) createPlayTarget();
|
Chris@0
|
3735 }
|
Chris@0
|
3736
|
Chris@0
|
3737 void
|
Chris@0
|
3738 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
3739 {
|
Chris@0
|
3740 // std::cerr << "MainWindow::modelAboutToBeDeleted(" << model << ")" << std::endl;
|
Chris@0
|
3741 m_playSource->removeModel(model);
|
Chris@91
|
3742 FFTDataServer::modelAboutToBeDeleted(model);
|
Chris@0
|
3743 }
|
Chris@0
|
3744
|
Chris@0
|
3745 void
|
Chris@0
|
3746 MainWindow::modelGenerationFailed(QString transformName)
|
Chris@0
|
3747 {
|
Chris@0
|
3748 QMessageBox::warning
|
Chris@0
|
3749 (this,
|
Chris@0
|
3750 tr("Failed to generate layer"),
|
Chris@34
|
3751 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
|
3752 .arg(transformName),
|
Chris@0
|
3753 QMessageBox::Ok, 0);
|
Chris@0
|
3754 }
|
Chris@0
|
3755
|
Chris@0
|
3756 void
|
Chris@0
|
3757 MainWindow::modelRegenerationFailed(QString layerName, QString transformName)
|
Chris@0
|
3758 {
|
Chris@0
|
3759 QMessageBox::warning
|
Chris@0
|
3760 (this,
|
Chris@0
|
3761 tr("Failed to regenerate layer"),
|
Chris@34
|
3762 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
|
3763 .arg(layerName).arg(transformName),
|
Chris@0
|
3764 QMessageBox::Ok, 0);
|
Chris@0
|
3765 }
|
Chris@0
|
3766
|
Chris@0
|
3767 void
|
Chris@0
|
3768 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
3769 {
|
Chris@0
|
3770 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
|
Chris@0
|
3771 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
3772 m_rightButtonMenu->popup(position);
|
Chris@0
|
3773 }
|
Chris@0
|
3774
|
Chris@0
|
3775 void
|
Chris@73
|
3776 MainWindow::propertyStacksResized()
|
Chris@73
|
3777 {
|
Chris@73
|
3778 /*
|
Chris@73
|
3779 std::cerr << "MainWindow::propertyStacksResized" << std::endl;
|
Chris@73
|
3780 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
3781 if (pane && m_overview) {
|
Chris@73
|
3782 std::cerr << "Fixed width: " << pane->width() << std::endl;
|
Chris@73
|
3783 m_overview->setFixedWidth(pane->width());
|
Chris@73
|
3784 }
|
Chris@73
|
3785 */
|
Chris@73
|
3786 }
|
Chris@73
|
3787
|
Chris@73
|
3788 void
|
Chris@0
|
3789 MainWindow::showLayerTree()
|
Chris@0
|
3790 {
|
Chris@0
|
3791 QTreeView *view = new QTreeView();
|
Chris@0
|
3792 LayerTreeModel *tree = new LayerTreeModel(m_paneStack);
|
Chris@0
|
3793 view->expand(tree->index(0, 0, QModelIndex()));
|
Chris@0
|
3794 view->setModel(tree);
|
Chris@0
|
3795 view->show();
|
Chris@0
|
3796 }
|
Chris@0
|
3797
|
Chris@0
|
3798 void
|
Chris@69
|
3799 MainWindow::pollOSC()
|
Chris@69
|
3800 {
|
Chris@70
|
3801 if (!m_oscQueue || m_oscQueue->isEmpty()) return;
|
Chris@69
|
3802 std::cerr << "MainWindow::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << std::endl;
|
Chris@69
|
3803
|
Chris@70
|
3804 if (m_openingAudioFile) return;
|
Chris@70
|
3805
|
Chris@69
|
3806 OSCMessage message = m_oscQueue->readMessage();
|
Chris@69
|
3807
|
Chris@69
|
3808 if (message.getTarget() != 0) {
|
Chris@69
|
3809 return; //!!! for now -- this class is target 0, others not handled yet
|
Chris@69
|
3810 }
|
Chris@69
|
3811
|
Chris@69
|
3812 handleOSCMessage(message);
|
Chris@69
|
3813 }
|
Chris@69
|
3814
|
Chris@69
|
3815 void
|
Chris@69
|
3816 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@69
|
3817 {
|
Chris@70
|
3818 std::cerr << "MainWindow::handleOSCMessage: thread id = "
|
Chris@70
|
3819 << QThread::currentThreadId() << std::endl;
|
Chris@70
|
3820
|
Chris@69
|
3821 // This large function should really be abstracted out.
|
Chris@69
|
3822
|
Chris@69
|
3823 if (message.getMethod() == "open") {
|
Chris@69
|
3824
|
Chris@69
|
3825 if (message.getArgCount() == 1 &&
|
Chris@69
|
3826 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3827 QString path = message.getArg(0).toString();
|
Chris@82
|
3828 if (openSomeFile(path, ReplaceMainModel) != FileOpenSucceeded) {
|
Chris@69
|
3829 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3830 << path.toStdString() << "\"" << std::endl;
|
Chris@69
|
3831 }
|
Chris@69
|
3832 //!!! we really need to spin here and not return until the
|
Chris@69
|
3833 // file has been completely decoded...
|
Chris@69
|
3834 }
|
Chris@69
|
3835
|
Chris@69
|
3836 } else if (message.getMethod() == "openadditional") {
|
Chris@69
|
3837
|
Chris@69
|
3838 if (message.getArgCount() == 1 &&
|
Chris@69
|
3839 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3840 QString path = message.getArg(0).toString();
|
Chris@82
|
3841 if (openSomeFile(path, CreateAdditionalModel) != FileOpenSucceeded) {
|
Chris@69
|
3842 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3843 << path.toStdString() << "\"" << std::endl;
|
Chris@69
|
3844 }
|
Chris@69
|
3845 }
|
Chris@69
|
3846
|
Chris@69
|
3847 } else if (message.getMethod() == "recent" ||
|
Chris@69
|
3848 message.getMethod() == "last") {
|
Chris@69
|
3849
|
Chris@69
|
3850 int n = 0;
|
Chris@69
|
3851 if (message.getMethod() == "recent" &&
|
Chris@69
|
3852 message.getArgCount() == 1 &&
|
Chris@69
|
3853 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
3854 n = message.getArg(0).toInt() - 1;
|
Chris@69
|
3855 }
|
Chris@69
|
3856 std::vector<QString> recent = m_recentFiles.getRecent();
|
Chris@69
|
3857 if (n >= 0 && n < recent.size()) {
|
Chris@82
|
3858 if (openSomeFile(recent[n], ReplaceMainModel) != FileOpenSucceeded) {
|
Chris@69
|
3859 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
|
Chris@69
|
3860 << recent[n].toStdString() << "\"" << std::endl;
|
Chris@69
|
3861 }
|
Chris@69
|
3862 }
|
Chris@69
|
3863
|
Chris@69
|
3864 } else if (message.getMethod() == "save") {
|
Chris@69
|
3865
|
Chris@69
|
3866 QString path;
|
Chris@69
|
3867 if (message.getArgCount() == 1 &&
|
Chris@69
|
3868 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3869 path = message.getArg(0).toString();
|
Chris@69
|
3870 if (QFileInfo(path).exists()) {
|
Chris@69
|
3871 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in save" << std::endl;
|
Chris@69
|
3872 } else {
|
Chris@69
|
3873 saveSessionFile(path);
|
Chris@69
|
3874 }
|
Chris@69
|
3875 }
|
Chris@69
|
3876
|
Chris@69
|
3877 } else if (message.getMethod() == "export") {
|
Chris@69
|
3878
|
Chris@69
|
3879 QString path;
|
Chris@69
|
3880 if (getMainModel()) {
|
Chris@69
|
3881 if (message.getArgCount() == 1 &&
|
Chris@69
|
3882 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3883 path = message.getArg(0).toString();
|
Chris@69
|
3884 if (QFileInfo(path).exists()) {
|
Chris@69
|
3885 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in export" << std::endl;
|
Chris@69
|
3886 } else {
|
Chris@69
|
3887 WavFileWriter writer(path,
|
Chris@69
|
3888 getMainModel()->getSampleRate(),
|
Chris@69
|
3889 getMainModel()->getChannelCount());
|
Chris@69
|
3890 MultiSelection ms = m_viewManager->getSelection();
|
Chris@69
|
3891 if (!ms.getSelections().empty()) {
|
Chris@69
|
3892 writer.writeModel(getMainModel(), &ms);
|
Chris@69
|
3893 } else {
|
Chris@69
|
3894 writer.writeModel(getMainModel());
|
Chris@69
|
3895 }
|
Chris@69
|
3896 }
|
Chris@69
|
3897 }
|
Chris@69
|
3898 }
|
Chris@69
|
3899
|
Chris@69
|
3900 } else if (message.getMethod() == "jump" ||
|
Chris@69
|
3901 message.getMethod() == "play") {
|
Chris@69
|
3902
|
Chris@69
|
3903 if (getMainModel()) {
|
Chris@69
|
3904
|
Chris@69
|
3905 unsigned long frame = m_viewManager->getPlaybackFrame();
|
Chris@69
|
3906 bool selection = false;
|
Chris@69
|
3907 bool play = (message.getMethod() == "play");
|
Chris@69
|
3908
|
Chris@69
|
3909 if (message.getArgCount() == 1) {
|
Chris@69
|
3910
|
Chris@69
|
3911 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
3912 message.getArg(0).toString() == "selection") {
|
Chris@69
|
3913
|
Chris@69
|
3914 selection = true;
|
Chris@69
|
3915
|
Chris@69
|
3916 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
3917 message.getArg(0).toString() == "end") {
|
Chris@69
|
3918
|
Chris@69
|
3919 frame = getMainModel()->getEndFrame();
|
Chris@69
|
3920
|
Chris@69
|
3921 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@69
|
3922
|
Chris@69
|
3923 double time = message.getArg(0).toDouble();
|
Chris@69
|
3924 if (time < 0.0) time = 0.0;
|
Chris@69
|
3925
|
Chris@69
|
3926 frame = lrint(time * getMainModel()->getSampleRate());
|
Chris@69
|
3927 }
|
Chris@69
|
3928 }
|
Chris@69
|
3929
|
Chris@69
|
3930 if (frame > getMainModel()->getEndFrame()) {
|
Chris@69
|
3931 frame = getMainModel()->getEndFrame();
|
Chris@69
|
3932 }
|
Chris@69
|
3933
|
Chris@69
|
3934 if (play) {
|
Chris@69
|
3935 m_viewManager->setPlaySelectionMode(selection);
|
Chris@69
|
3936 }
|
Chris@69
|
3937
|
Chris@69
|
3938 if (selection) {
|
Chris@69
|
3939 MultiSelection::SelectionList sl = m_viewManager->getSelections();
|
Chris@69
|
3940 if (!sl.empty()) {
|
Chris@69
|
3941 frame = sl.begin()->getStartFrame();
|
Chris@69
|
3942 }
|
Chris@69
|
3943 }
|
Chris@69
|
3944
|
Chris@69
|
3945 m_viewManager->setPlaybackFrame(frame);
|
Chris@69
|
3946
|
Chris@69
|
3947 if (play && !m_playSource->isPlaying()) {
|
Chris@69
|
3948 m_playSource->play(frame);
|
Chris@69
|
3949 }
|
Chris@69
|
3950 }
|
Chris@69
|
3951
|
Chris@69
|
3952 } else if (message.getMethod() == "stop") {
|
Chris@69
|
3953
|
Chris@69
|
3954 if (m_playSource->isPlaying()) m_playSource->stop();
|
Chris@69
|
3955
|
Chris@69
|
3956 } else if (message.getMethod() == "loop") {
|
Chris@69
|
3957
|
Chris@69
|
3958 if (message.getArgCount() == 1 &&
|
Chris@69
|
3959 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
3960
|
Chris@69
|
3961 QString str = message.getArg(0).toString();
|
Chris@69
|
3962 if (str == "on") {
|
Chris@69
|
3963 m_viewManager->setPlayLoopMode(true);
|
Chris@69
|
3964 } else if (str == "off") {
|
Chris@69
|
3965 m_viewManager->setPlayLoopMode(false);
|
Chris@69
|
3966 }
|
Chris@69
|
3967 }
|
Chris@69
|
3968
|
Chris@69
|
3969 } else if (message.getMethod() == "select" ||
|
Chris@69
|
3970 message.getMethod() == "addselect") {
|
Chris@69
|
3971
|
Chris@69
|
3972 if (getMainModel()) {
|
Chris@69
|
3973
|
Chris@73
|
3974 int f0 = getMainModel()->getStartFrame();
|
Chris@73
|
3975 int f1 = getMainModel()->getEndFrame();
|
Chris@69
|
3976
|
Chris@69
|
3977 bool done = false;
|
Chris@69
|
3978
|
Chris@69
|
3979 if (message.getArgCount() == 2 &&
|
Chris@69
|
3980 message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@69
|
3981 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@69
|
3982
|
Chris@69
|
3983 double t0 = message.getArg(0).toDouble();
|
Chris@69
|
3984 double t1 = message.getArg(1).toDouble();
|
Chris@69
|
3985 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; }
|
Chris@69
|
3986 if (t0 < 0.0) t0 = 0.0;
|
Chris@69
|
3987 if (t1 < 0.0) t1 = 0.0;
|
Chris@69
|
3988
|
Chris@69
|
3989 f0 = lrint(t0 * getMainModel()->getSampleRate());
|
Chris@69
|
3990 f1 = lrint(t1 * getMainModel()->getSampleRate());
|
Chris@73
|
3991
|
Chris@73
|
3992 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
3993 Layer *layer = 0;
|
Chris@73
|
3994 if (pane) layer = pane->getSelectedLayer();
|
Chris@73
|
3995 if (layer) {
|
Chris@73
|
3996 size_t resolution;
|
Chris@73
|
3997 layer->snapToFeatureFrame(pane, f0, resolution,
|
Chris@73
|
3998 Layer::SnapLeft);
|
Chris@73
|
3999 layer->snapToFeatureFrame(pane, f1, resolution,
|
Chris@73
|
4000 Layer::SnapRight);
|
Chris@73
|
4001 }
|
Chris@69
|
4002
|
Chris@69
|
4003 } else if (message.getArgCount() == 1 &&
|
Chris@69
|
4004 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
4005
|
Chris@69
|
4006 QString str = message.getArg(0).toString();
|
Chris@69
|
4007 if (str == "none") {
|
Chris@69
|
4008 m_viewManager->clearSelections();
|
Chris@69
|
4009 done = true;
|
Chris@69
|
4010 }
|
Chris@69
|
4011 }
|
Chris@69
|
4012
|
Chris@69
|
4013 if (!done) {
|
Chris@69
|
4014 if (message.getMethod() == "select") {
|
Chris@69
|
4015 m_viewManager->setSelection(Selection(f0, f1));
|
Chris@69
|
4016 } else {
|
Chris@69
|
4017 m_viewManager->addSelection(Selection(f0, f1));
|
Chris@69
|
4018 }
|
Chris@69
|
4019 }
|
Chris@69
|
4020 }
|
Chris@69
|
4021
|
Chris@69
|
4022 } else if (message.getMethod() == "add") {
|
Chris@69
|
4023
|
Chris@69
|
4024 if (getMainModel()) {
|
Chris@69
|
4025
|
Chris@69
|
4026 if (message.getArgCount() >= 1 &&
|
Chris@69
|
4027 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
4028
|
Chris@69
|
4029 int channel = -1;
|
Chris@69
|
4030 if (message.getArgCount() == 2 &&
|
Chris@69
|
4031 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
4032 channel = message.getArg(0).toInt();
|
Chris@69
|
4033 if (channel < -1 ||
|
Chris@69
|
4034 channel > getMainModel()->getChannelCount()) {
|
Chris@69
|
4035 std::cerr << "WARNING: MainWindow::handleOSCMessage: channel "
|
Chris@69
|
4036 << channel << " out of range" << std::endl;
|
Chris@69
|
4037 channel = -1;
|
Chris@69
|
4038 }
|
Chris@69
|
4039 }
|
Chris@69
|
4040
|
Chris@69
|
4041 QString str = message.getArg(0).toString();
|
Chris@69
|
4042
|
Chris@69
|
4043 LayerFactory::LayerType type =
|
Chris@69
|
4044 LayerFactory::getInstance()->getLayerTypeForName(str);
|
Chris@69
|
4045
|
Chris@69
|
4046 if (type == LayerFactory::UnknownLayer) {
|
Chris@69
|
4047 std::cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer "
|
Chris@69
|
4048 << "type " << str.toStdString() << std::endl;
|
Chris@69
|
4049 } else {
|
Chris@69
|
4050
|
Chris@69
|
4051 PaneConfiguration configuration(type,
|
Chris@69
|
4052 getMainModel(),
|
Chris@69
|
4053 channel);
|
Chris@69
|
4054
|
Chris@69
|
4055 addPane(configuration,
|
Chris@69
|
4056 tr("Add %1 Pane")
|
Chris@69
|
4057 .arg(LayerFactory::getInstance()->
|
Chris@69
|
4058 getLayerPresentationName(type)));
|
Chris@69
|
4059 }
|
Chris@69
|
4060 }
|
Chris@69
|
4061 }
|
Chris@69
|
4062
|
Chris@69
|
4063 } else if (message.getMethod() == "undo") {
|
Chris@69
|
4064
|
Chris@69
|
4065 CommandHistory::getInstance()->undo();
|
Chris@69
|
4066
|
Chris@69
|
4067 } else if (message.getMethod() == "redo") {
|
Chris@69
|
4068
|
Chris@69
|
4069 CommandHistory::getInstance()->redo();
|
Chris@69
|
4070
|
Chris@69
|
4071 } else if (message.getMethod() == "set") {
|
Chris@69
|
4072
|
Chris@70
|
4073 if (message.getArgCount() == 2 &&
|
Chris@69
|
4074 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4075 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@69
|
4076
|
Chris@69
|
4077 QString property = message.getArg(0).toString();
|
Chris@69
|
4078 float value = (float)message.getArg(1).toDouble();
|
Chris@69
|
4079
|
Chris@69
|
4080 if (property == "gain") {
|
Chris@69
|
4081 if (value < 0.0) value = 0.0;
|
Chris@69
|
4082 m_fader->setValue(value);
|
Chris@69
|
4083 if (m_playTarget) m_playTarget->setOutputGain(value);
|
Chris@69
|
4084 } else if (property == "speedup") {
|
Chris@69
|
4085 m_playSpeed->setMappedValue(value);
|
Chris@69
|
4086 } else if (property == "overlays") {
|
Chris@69
|
4087 if (value < 0.5) {
|
Chris@69
|
4088 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
|
Chris@69
|
4089 } else if (value < 1.5) {
|
Chris@90
|
4090 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
|
Chris@90
|
4091 } else if (value < 2.5) {
|
Chris@90
|
4092 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
|
Chris@69
|
4093 } else {
|
Chris@69
|
4094 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
|
Chris@69
|
4095 }
|
Chris@70
|
4096 } else if (property == "zoomwheels") {
|
Chris@70
|
4097 m_viewManager->setZoomWheelsEnabled(value > 0.5);
|
Chris@72
|
4098 } else if (property == "propertyboxes") {
|
Chris@72
|
4099 bool toggle = ((value < 0.5) !=
|
Chris@72
|
4100 (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks));
|
Chris@72
|
4101 if (toggle) togglePropertyBoxes();
|
Chris@70
|
4102 }
|
Chris@70
|
4103
|
Chris@70
|
4104 } else {
|
Chris@70
|
4105 PropertyContainer *container = 0;
|
Chris@70
|
4106 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4107 if (pane &&
|
Chris@70
|
4108 message.getArgCount() == 3 &&
|
Chris@70
|
4109 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@70
|
4110 message.getArg(1).canConvert(QVariant::String) &&
|
Chris@70
|
4111 message.getArg(2).canConvert(QVariant::String)) {
|
Chris@70
|
4112 if (message.getArg(0).toString() == "pane") {
|
Chris@70
|
4113 container = pane->getPropertyContainer(0);
|
Chris@70
|
4114 } else if (message.getArg(0).toString() == "layer") {
|
Chris@70
|
4115 container = pane->getSelectedLayer();
|
Chris@70
|
4116 }
|
Chris@70
|
4117 }
|
Chris@70
|
4118 if (container) {
|
Chris@70
|
4119 QString nameString = message.getArg(1).toString();
|
Chris@70
|
4120 QString valueString = message.getArg(2).toString();
|
Chris@70
|
4121 container->setPropertyWithCommand(nameString, valueString);
|
Chris@69
|
4122 }
|
Chris@69
|
4123 }
|
Chris@69
|
4124
|
Chris@69
|
4125 } else if (message.getMethod() == "setcurrent") {
|
Chris@69
|
4126
|
Chris@69
|
4127 int paneIndex = -1, layerIndex = -1;
|
Chris@69
|
4128 bool wantLayer = false;
|
Chris@69
|
4129
|
Chris@69
|
4130 if (message.getArgCount() >= 1 &&
|
Chris@69
|
4131 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@69
|
4132
|
Chris@69
|
4133 paneIndex = message.getArg(0).toInt() - 1;
|
Chris@69
|
4134
|
Chris@69
|
4135 if (message.getArgCount() >= 2 &&
|
Chris@69
|
4136 message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@69
|
4137 wantLayer = true;
|
Chris@69
|
4138 layerIndex = message.getArg(1).toInt() - 1;
|
Chris@69
|
4139 }
|
Chris@69
|
4140 }
|
Chris@69
|
4141
|
Chris@69
|
4142 if (paneIndex >= 0 && paneIndex < m_paneStack->getPaneCount()) {
|
Chris@69
|
4143 Pane *pane = m_paneStack->getPane(paneIndex);
|
Chris@70
|
4144 m_paneStack->setCurrentPane(pane);
|
Chris@69
|
4145 if (layerIndex >= 0 && layerIndex < pane->getLayerCount()) {
|
Chris@69
|
4146 Layer *layer = pane->getLayer(layerIndex);
|
Chris@69
|
4147 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@69
|
4148 } else if (wantLayer && layerIndex == -1) {
|
Chris@69
|
4149 m_paneStack->setCurrentLayer(pane, 0);
|
Chris@69
|
4150 }
|
Chris@69
|
4151 }
|
Chris@69
|
4152
|
Chris@69
|
4153 } else if (message.getMethod() == "delete") {
|
Chris@69
|
4154
|
Chris@69
|
4155 if (message.getArgCount() == 1 &&
|
Chris@69
|
4156 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@69
|
4157
|
Chris@69
|
4158 QString target = message.getArg(0).toString();
|
Chris@69
|
4159
|
Chris@69
|
4160 if (target == "pane") {
|
Chris@69
|
4161
|
Chris@69
|
4162 deleteCurrentPane();
|
Chris@69
|
4163
|
Chris@69
|
4164 } else if (target == "layer") {
|
Chris@69
|
4165
|
Chris@69
|
4166 deleteCurrentLayer();
|
Chris@69
|
4167
|
Chris@69
|
4168 } else {
|
Chris@69
|
4169
|
Chris@69
|
4170 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown delete target " << target.toStdString() << std::endl;
|
Chris@69
|
4171 }
|
Chris@69
|
4172 }
|
Chris@69
|
4173
|
Chris@69
|
4174 } else if (message.getMethod() == "zoom") {
|
Chris@69
|
4175
|
Chris@69
|
4176 if (message.getArgCount() == 1) {
|
Chris@69
|
4177 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4178 message.getArg(0).toString() == "in") {
|
Chris@69
|
4179 zoomIn();
|
Chris@69
|
4180 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4181 message.getArg(0).toString() == "out") {
|
Chris@69
|
4182 zoomOut();
|
Chris@69
|
4183 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@69
|
4184 message.getArg(0).toString() == "default") {
|
Chris@69
|
4185 zoomDefault();
|
Chris@69
|
4186 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@69
|
4187 double level = message.getArg(0).toDouble();
|
Chris@69
|
4188 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@69
|
4189 if (level < 1.0) level = 1.0;
|
Chris@69
|
4190 if (currentPane) currentPane->setZoomLevel(lrint(level));
|
Chris@69
|
4191 }
|
Chris@69
|
4192 }
|
Chris@69
|
4193
|
Chris@73
|
4194 } else if (message.getMethod() == "zoomvertical") {
|
Chris@73
|
4195
|
Chris@73
|
4196 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@73
|
4197 Layer *layer = 0;
|
Chris@73
|
4198 if (pane && pane->getLayerCount() > 0) {
|
Chris@73
|
4199 layer = pane->getLayer(pane->getLayerCount() - 1);
|
Chris@73
|
4200 }
|
Chris@73
|
4201 int defaultStep = 0;
|
Chris@73
|
4202 int steps = 0;
|
Chris@73
|
4203 if (layer) {
|
Chris@73
|
4204 steps = layer->getVerticalZoomSteps(defaultStep);
|
Chris@73
|
4205 if (message.getArgCount() == 1 && steps > 0) {
|
Chris@73
|
4206 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4207 message.getArg(0).toString() == "in") {
|
Chris@73
|
4208 int step = layer->getCurrentVerticalZoomStep() + 1;
|
Chris@73
|
4209 if (step < steps) layer->setVerticalZoomStep(step);
|
Chris@73
|
4210 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4211 message.getArg(0).toString() == "out") {
|
Chris@73
|
4212 int step = layer->getCurrentVerticalZoomStep() - 1;
|
Chris@73
|
4213 if (step >= 0) layer->setVerticalZoomStep(step);
|
Chris@73
|
4214 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@73
|
4215 message.getArg(0).toString() == "default") {
|
Chris@73
|
4216 layer->setVerticalZoomStep(defaultStep);
|
Chris@73
|
4217 }
|
Chris@73
|
4218 } else if (message.getArgCount() == 2) {
|
Chris@73
|
4219 if (message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@73
|
4220 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@73
|
4221 double min = message.getArg(0).toDouble();
|
Chris@73
|
4222 double max = message.getArg(1).toDouble();
|
Chris@73
|
4223 layer->setDisplayExtents(min, max);
|
Chris@73
|
4224 }
|
Chris@73
|
4225 }
|
Chris@73
|
4226 }
|
Chris@73
|
4227
|
Chris@70
|
4228 } else if (message.getMethod() == "quit") {
|
Chris@70
|
4229
|
Chris@70
|
4230 m_abandoning = true;
|
Chris@70
|
4231 close();
|
Chris@70
|
4232
|
Chris@70
|
4233 } else if (message.getMethod() == "resize") {
|
Chris@70
|
4234
|
Chris@70
|
4235 if (message.getArgCount() == 2) {
|
Chris@70
|
4236
|
Chris@70
|
4237 int width = 0, height = 0;
|
Chris@70
|
4238
|
Chris@70
|
4239 if (message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@70
|
4240
|
Chris@70
|
4241 height = message.getArg(1).toInt();
|
Chris@70
|
4242
|
Chris@70
|
4243 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@70
|
4244 message.getArg(0).toString() == "pane") {
|
Chris@70
|
4245
|
Chris@70
|
4246 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4247 if (pane) pane->resize(pane->width(), height);
|
Chris@70
|
4248
|
Chris@70
|
4249 } else if (message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@70
|
4250
|
Chris@70
|
4251 width = message.getArg(0).toInt();
|
Chris@70
|
4252 resize(width, height);
|
Chris@70
|
4253 }
|
Chris@70
|
4254 }
|
Chris@70
|
4255 }
|
Chris@70
|
4256
|
Chris@70
|
4257 } else if (message.getMethod() == "transform") {
|
Chris@70
|
4258
|
Chris@70
|
4259 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@70
|
4260
|
Chris@70
|
4261 if (getMainModel() &&
|
Chris@70
|
4262 pane &&
|
Chris@70
|
4263 message.getArgCount() == 1 &&
|
Chris@70
|
4264 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@70
|
4265
|
Chris@107
|
4266 TransformId transform = message.getArg(0).toString();
|
Chris@70
|
4267
|
Chris@70
|
4268 Layer *newLayer = m_document->createDerivedLayer
|
Chris@70
|
4269 (transform,
|
Chris@70
|
4270 getMainModel(),
|
Chris@73
|
4271 TransformFactory::getInstance()->getDefaultContextForTransform
|
Chris@73
|
4272 (transform, getMainModel()),
|
Chris@70
|
4273 "");
|
Chris@70
|
4274
|
Chris@70
|
4275 if (newLayer) {
|
Chris@70
|
4276 m_document->addLayerToView(pane, newLayer);
|
Chris@70
|
4277 m_recentTransforms.add(transform);
|
Chris@70
|
4278 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@70
|
4279 }
|
Chris@70
|
4280 }
|
Chris@70
|
4281
|
Chris@69
|
4282 } else {
|
Chris@69
|
4283 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown or unsupported "
|
Chris@69
|
4284 << "method \"" << message.getMethod().toStdString()
|
Chris@69
|
4285 << "\"" << std::endl;
|
Chris@69
|
4286 }
|
Chris@69
|
4287
|
Chris@69
|
4288 }
|
Chris@69
|
4289
|
Chris@69
|
4290 void
|
Chris@0
|
4291 MainWindow::preferences()
|
Chris@0
|
4292 {
|
Chris@0
|
4293 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
4294 m_preferencesDialog->show();
|
Chris@0
|
4295 m_preferencesDialog->raise();
|
Chris@0
|
4296 return;
|
Chris@0
|
4297 }
|
Chris@0
|
4298
|
Chris@0
|
4299 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
4300
|
Chris@0
|
4301 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
4302 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
4303 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
4304 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
4305 // without resetting its own widgets, so its state will be
|
Chris@0
|
4306 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
4307 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
4308
|
Chris@0
|
4309 m_preferencesDialog->show();
|
Chris@0
|
4310 }
|
Chris@0
|
4311
|
Chris@0
|
4312 void
|
Chris@90
|
4313 MainWindow::mouseEnteredWidget()
|
Chris@90
|
4314 {
|
Chris@90
|
4315 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
4316 if (!w) return;
|
Chris@90
|
4317
|
Chris@90
|
4318 if (w == m_fader) {
|
Chris@90
|
4319 statusBar()->showMessage(tr("Adjust the master playback level"));
|
Chris@90
|
4320 } else if (w == m_playSpeed) {
|
Chris@90
|
4321 statusBar()->showMessage(tr("Adjust the master playback speed"));
|
Chris@90
|
4322 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@90
|
4323 statusBar()->showMessage(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@90
|
4324 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@90
|
4325 statusBar()->showMessage(tr("Toggle mono mode for playback time scaling"));
|
Chris@90
|
4326 }
|
Chris@90
|
4327 }
|
Chris@90
|
4328
|
Chris@90
|
4329 void
|
Chris@90
|
4330 MainWindow::mouseLeftWidget()
|
Chris@90
|
4331 {
|
Chris@90
|
4332 statusBar()->showMessage("");
|
Chris@90
|
4333 }
|
Chris@90
|
4334
|
Chris@90
|
4335 void
|
Chris@0
|
4336 MainWindow::website()
|
Chris@0
|
4337 {
|
Chris@0
|
4338 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
4339 }
|
Chris@0
|
4340
|
Chris@0
|
4341 void
|
Chris@0
|
4342 MainWindow::help()
|
Chris@0
|
4343 {
|
Chris@0
|
4344 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/en/"));
|
Chris@0
|
4345 }
|
Chris@0
|
4346
|
Chris@0
|
4347 void
|
Chris@0
|
4348 MainWindow::openHelpUrl(QString url)
|
Chris@0
|
4349 {
|
Chris@0
|
4350 // This method mostly lifted from Qt Assistant source code
|
Chris@0
|
4351
|
Chris@0
|
4352 QProcess *process = new QProcess(this);
|
Chris@0
|
4353 connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
|
Chris@0
|
4354
|
Chris@0
|
4355 QStringList args;
|
Chris@0
|
4356
|
Chris@0
|
4357 #ifdef Q_OS_MAC
|
Chris@0
|
4358 args.append(url);
|
Chris@0
|
4359 process->start("open", args);
|
Chris@0
|
4360 #else
|
Chris@0
|
4361 #ifdef Q_OS_WIN32
|
Chris@0
|
4362
|
Chris@0
|
4363 QString pf(getenv("ProgramFiles"));
|
Chris@0
|
4364 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE");
|
Chris@0
|
4365
|
Chris@0
|
4366 args.append(url);
|
Chris@0
|
4367 process->start(command, args);
|
Chris@0
|
4368
|
Chris@0
|
4369 #else
|
Chris@0
|
4370 #ifdef Q_WS_X11
|
Chris@0
|
4371 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
|
Chris@0
|
4372 args.append("exec");
|
Chris@0
|
4373 args.append(url);
|
Chris@0
|
4374 process->start("kfmclient", args);
|
Chris@0
|
4375 } else if (!qgetenv("BROWSER").isEmpty()) {
|
Chris@0
|
4376 args.append(url);
|
Chris@0
|
4377 process->start(qgetenv("BROWSER"), args);
|
Chris@0
|
4378 } else {
|
Chris@0
|
4379 args.append(url);
|
Chris@0
|
4380 process->start("firefox", args);
|
Chris@0
|
4381 }
|
Chris@0
|
4382 #endif
|
Chris@0
|
4383 #endif
|
Chris@0
|
4384 #endif
|
Chris@0
|
4385 }
|
Chris@0
|
4386
|
Chris@0
|
4387 void
|
Chris@0
|
4388 MainWindow::about()
|
Chris@0
|
4389 {
|
Chris@0
|
4390 bool debug = false;
|
Chris@0
|
4391 QString version = "(unknown version)";
|
Chris@0
|
4392
|
Chris@0
|
4393 #ifdef BUILD_DEBUG
|
Chris@0
|
4394 debug = true;
|
Chris@0
|
4395 #endif
|
Chris@0
|
4396 #ifdef SV_VERSION
|
Chris@0
|
4397 #ifdef SVNREV
|
Chris@0
|
4398 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@0
|
4399 #else
|
Chris@0
|
4400 version = tr("Release %1").arg(SV_VERSION);
|
Chris@0
|
4401 #endif
|
Chris@0
|
4402 #else
|
Chris@0
|
4403 #ifdef SVNREV
|
Chris@0
|
4404 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@0
|
4405 #endif
|
Chris@0
|
4406 #endif
|
Chris@0
|
4407
|
Chris@0
|
4408 QString aboutText;
|
Chris@0
|
4409
|
Chris@0
|
4410 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@90
|
4411 aboutText += tr("<p>Sonic Visualiser is a program for viewing and exploring audio data for<br>semantic music analysis and annotation.</p>");
|
Chris@0
|
4412 aboutText += tr("<p>%1 : %2 build</p>")
|
Chris@0
|
4413 .arg(version)
|
Chris@0
|
4414 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
4415
|
Chris@0
|
4416 #ifdef BUILD_STATIC
|
Chris@0
|
4417 aboutText += tr("<p>Statically linked");
|
Chris@0
|
4418 #ifndef QT_SHARED
|
Chris@0
|
4419 aboutText += tr("<br>With Qt (v%1) © Trolltech AS").arg(QT_VERSION_STR);
|
Chris@0
|
4420 #endif
|
Chris@0
|
4421 #ifdef HAVE_JACK
|
Chris@93
|
4422 #ifdef JACK_VERSION
|
Chris@0
|
4423 aboutText += tr("<br>With JACK audio output (v%1) © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@93
|
4424 #else
|
Chris@93
|
4425 aboutText += tr("<br>With JACK audio output © Paul Davis and Jack O'Quin");
|
Chris@93
|
4426 #endif
|
Chris@0
|
4427 #endif
|
Chris@0
|
4428 #ifdef HAVE_PORTAUDIO
|
Chris@0
|
4429 aboutText += tr("<br>With PortAudio audio output © Ross Bencina and Phil Burk");
|
Chris@0
|
4430 #endif
|
Chris@0
|
4431 #ifdef HAVE_OGGZ
|
Chris@93
|
4432 #ifdef OGGZ_VERSION
|
Chris@0
|
4433 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@93
|
4434 #else
|
Chris@93
|
4435 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@93
|
4436 #endif
|
Chris@0
|
4437 #endif
|
Chris@0
|
4438 #ifdef HAVE_MAD
|
Chris@93
|
4439 #ifdef MAD_VERSION
|
Chris@0
|
4440 aboutText += tr("<br>With MAD mp3 decoder (v%1) © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@93
|
4441 #else
|
Chris@93
|
4442 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@93
|
4443 #endif
|
Chris@0
|
4444 #endif
|
Chris@0
|
4445 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
4446 #ifdef SAMPLERATE_VERSION
|
Chris@0
|
4447 aboutText += tr("<br>With libsamplerate (v%1) © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@93
|
4448 #else
|
Chris@93
|
4449 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@93
|
4450 #endif
|
Chris@0
|
4451 #endif
|
Chris@0
|
4452 #ifdef HAVE_SNDFILE
|
Chris@93
|
4453 #ifdef SNDFILE_VERSION
|
Chris@0
|
4454 aboutText += tr("<br>With libsndfile (v%1) © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@93
|
4455 #else
|
Chris@93
|
4456 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@93
|
4457 #endif
|
Chris@0
|
4458 #endif
|
Chris@0
|
4459 #ifdef HAVE_FFTW3
|
Chris@93
|
4460 #ifdef FFTW3_VERSION
|
Chris@0
|
4461 aboutText += tr("<br>With FFTW3 (v%1) © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@93
|
4462 #else
|
Chris@93
|
4463 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@93
|
4464 #endif
|
Chris@0
|
4465 #endif
|
Chris@0
|
4466 #ifdef HAVE_VAMP
|
Chris@0
|
4467 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
|
4468 #endif
|
Chris@0
|
4469 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
4470 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@69
|
4471 #ifdef HAVE_LIBLO
|
Chris@93
|
4472 #ifdef LIBLO_VERSION
|
Chris@69
|
4473 aboutText += tr("<br>With liblo Lite OSC library (v%1) © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
4474 #else
|
Chris@93
|
4475 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
4476 #endif
|
Chris@70
|
4477 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@69
|
4478 aboutText += tr("<p>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@69
|
4479 }
|
Chris@69
|
4480 #endif
|
Chris@0
|
4481 aboutText += "</p>";
|
Chris@0
|
4482 #endif
|
Chris@0
|
4483
|
Chris@0
|
4484 aboutText +=
|
Chris@90
|
4485 "<p>Sonic Visualiser Copyright © 2005 - 2007 Chris Cannam and<br>"
|
Chris@90
|
4486 "Queen Mary, University of London.</p>"
|
Chris@0
|
4487 "<p>This program is free software; you can redistribute it and/or<br>"
|
Chris@0
|
4488 "modify it under the terms of the GNU General Public License as<br>"
|
Chris@0
|
4489 "published by the Free Software Foundation; either version 2 of the<br>"
|
Chris@0
|
4490 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
4491 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
4492
|
Chris@0
|
4493 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
|
Chris@0
|
4494 }
|
Chris@0
|
4495
|