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