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