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