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