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