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