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