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