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