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