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@320
|
2156 bool ok = false;
|
Chris@320
|
2157 QString item = QInputDialog::getItem
|
Chris@320
|
2158 (this, tr("Select audio file to export"),
|
Chris@320
|
2159 tr("Which audio file do you want to export from?"),
|
Chris@320
|
2160 items, c, false, &ok);
|
Chris@320
|
2161 if (!ok || item.isEmpty()) return;
|
Chris@320
|
2162 if (m.find(item) == m.end()) {
|
Chris@320
|
2163 cerr << "WARNING: Model " << item.toStdString()
|
Chris@320
|
2164 << " not found in list!" << endl;
|
Chris@320
|
2165 } else {
|
Chris@320
|
2166 model = m[item];
|
Chris@320
|
2167 }
|
Chris@320
|
2168 }
|
Chris@320
|
2169
|
Chris@88
|
2170 QString path = getSaveFileName(FileFinder::AudioFile);
|
Chris@0
|
2171 if (path == "") return;
|
Chris@0
|
2172
|
Chris@0
|
2173 bool ok = false;
|
Chris@0
|
2174 QString error;
|
Chris@0
|
2175
|
Chris@0
|
2176 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
2177 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
2178
|
Chris@0
|
2179 bool multiple = false;
|
Chris@0
|
2180
|
Chris@38
|
2181 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
2182
|
Chris@38
|
2183 if (selections.size() == 1) {
|
Chris@0
|
2184
|
Chris@0
|
2185 QStringList items;
|
Chris@0
|
2186 items << tr("Export the selected region only")
|
Chris@0
|
2187 << tr("Export the whole audio file");
|
Chris@0
|
2188
|
Chris@0
|
2189 bool ok = false;
|
Chris@0
|
2190 QString item = ListInputDialog::getItem
|
Chris@0
|
2191 (this, tr("Select region to export"),
|
Chris@0
|
2192 tr("Which region from the original audio file do you want to export?"),
|
Chris@0
|
2193 items, 0, &ok);
|
Chris@0
|
2194
|
Chris@0
|
2195 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2196
|
Chris@38
|
2197 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2198
|
Chris@38
|
2199 } else if (selections.size() > 1) {
|
Chris@0
|
2200
|
Chris@0
|
2201 QStringList items;
|
Chris@0
|
2202 items << tr("Export the selected regions into a single audio file")
|
Chris@0
|
2203 << tr("Export the selected regions into separate files")
|
Chris@0
|
2204 << tr("Export the whole audio file");
|
Chris@0
|
2205
|
Chris@0
|
2206 QString item = ListInputDialog::getItem
|
Chris@0
|
2207 (this, tr("Select region to export"),
|
Chris@0
|
2208 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@0
|
2209 items, 0, &ok);
|
Chris@0
|
2210
|
Chris@0
|
2211 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2212
|
Chris@0
|
2213 if (item == items[0]) {
|
Chris@0
|
2214
|
Chris@38
|
2215 selectionToWrite = &ms;
|
Chris@38
|
2216
|
Chris@38
|
2217 } else if (item == items[1]) {
|
Chris@0
|
2218
|
Chris@0
|
2219 multiple = true;
|
Chris@0
|
2220
|
Chris@0
|
2221 int n = 1;
|
Chris@0
|
2222 QString base = path;
|
Chris@0
|
2223 base.replace(".wav", "");
|
Chris@0
|
2224
|
Chris@0
|
2225 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
2226 i != selections.end(); ++i) {
|
Chris@0
|
2227
|
Chris@0
|
2228 MultiSelection subms;
|
Chris@0
|
2229 subms.setSelection(*i);
|
Chris@0
|
2230
|
Chris@0
|
2231 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@0
|
2232 ++n;
|
Chris@0
|
2233
|
Chris@0
|
2234 if (QFileInfo(subpath).exists()) {
|
Chris@0
|
2235 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@0
|
2236 break;
|
Chris@0
|
2237 }
|
Chris@0
|
2238
|
Chris@38
|
2239 WavFileWriter subwriter(subpath,
|
Chris@320
|
2240 model->getSampleRate(),
|
Chris@320
|
2241 model->getChannelCount());
|
Chris@320
|
2242 subwriter.writeModel(model, &subms);
|
Chris@0
|
2243 ok = subwriter.isOK();
|
Chris@0
|
2244
|
Chris@0
|
2245 if (!ok) {
|
Chris@0
|
2246 error = subwriter.getError();
|
Chris@0
|
2247 break;
|
Chris@0
|
2248 }
|
Chris@0
|
2249 }
|
Chris@0
|
2250 }
|
Chris@0
|
2251 }
|
Chris@0
|
2252
|
Chris@38
|
2253 if (!multiple) {
|
Chris@38
|
2254 WavFileWriter writer(path,
|
Chris@320
|
2255 model->getSampleRate(),
|
Chris@320
|
2256 model->getChannelCount());
|
Chris@320
|
2257 writer.writeModel(model, selectionToWrite);
|
Chris@38
|
2258 ok = writer.isOK();
|
Chris@38
|
2259 error = writer.getError();
|
Chris@0
|
2260 }
|
Chris@0
|
2261
|
Chris@0
|
2262 if (ok) {
|
Chris@310
|
2263 if (multiple) {
|
Chris@310
|
2264 emit activity(tr("Export multiple audio files"));
|
Chris@310
|
2265 } else {
|
Chris@310
|
2266 emit activity(tr("Export audio to \"%1\"").arg(path));
|
Chris@34
|
2267 m_recentFiles.addFile(path);
|
Chris@0
|
2268 }
|
Chris@0
|
2269 } else {
|
Chris@0
|
2270 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2271 }
|
Chris@0
|
2272 }
|
Chris@0
|
2273
|
Chris@0
|
2274 void
|
Chris@0
|
2275 MainWindow::importLayer()
|
Chris@0
|
2276 {
|
Chris@0
|
2277 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2278
|
Chris@0
|
2279 if (!pane) {
|
Chris@0
|
2280 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2281 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
|
Chris@0
|
2282 return;
|
Chris@0
|
2283 }
|
Chris@0
|
2284
|
Chris@0
|
2285 if (!getMainModel()) {
|
Chris@0
|
2286 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2287 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
|
Chris@0
|
2288 return;
|
Chris@0
|
2289 }
|
Chris@0
|
2290
|
Chris@88
|
2291 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2292
|
Chris@0
|
2293 if (path != "") {
|
Chris@0
|
2294
|
Chris@197
|
2295 FileOpenStatus status = openLayer(path);
|
Chris@193
|
2296
|
Chris@193
|
2297 if (status == FileOpenFailed) {
|
Chris@247
|
2298 emit hideSplash();
|
Chris@0
|
2299 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2300 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@0
|
2301 return;
|
Chris@193
|
2302 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2303 emit hideSplash();
|
Chris@193
|
2304 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
2305 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
|
2306 }
|
Chris@0
|
2307 }
|
Chris@0
|
2308 }
|
Chris@0
|
2309
|
Chris@0
|
2310 void
|
Chris@0
|
2311 MainWindow::exportLayer()
|
Chris@0
|
2312 {
|
Chris@0
|
2313 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2314 if (!pane) return;
|
Chris@0
|
2315
|
Chris@0
|
2316 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2317 if (!layer) return;
|
Chris@0
|
2318
|
Chris@0
|
2319 Model *model = layer->getModel();
|
Chris@0
|
2320 if (!model) return;
|
Chris@0
|
2321
|
Chris@185
|
2322 FileFinder::FileType type = FileFinder::LayerFileNoMidi;
|
Chris@185
|
2323
|
Chris@185
|
2324 if (dynamic_cast<NoteModel *>(model)) type = FileFinder::LayerFile;
|
Chris@185
|
2325
|
Chris@185
|
2326 QString path = getSaveFileName(type);
|
Chris@0
|
2327
|
Chris@0
|
2328 if (path == "") return;
|
Chris@0
|
2329
|
Chris@0
|
2330 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
2331
|
Chris@185
|
2332 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@185
|
2333
|
Chris@0
|
2334 QString error;
|
Chris@0
|
2335
|
Chris@185
|
2336 if (suffix == "xml" || suffix == "svl") {
|
Chris@0
|
2337
|
Chris@0
|
2338 QFile file(path);
|
Chris@0
|
2339 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
2340 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
2341 } else {
|
Chris@0
|
2342 QTextStream out(&file);
|
Chris@0
|
2343 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
2344 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
2345 << "<sv>\n"
|
Chris@0
|
2346 << " <data>\n";
|
Chris@0
|
2347
|
Chris@0
|
2348 model->toXml(out, " ");
|
Chris@0
|
2349
|
Chris@0
|
2350 out << " </data>\n"
|
Chris@0
|
2351 << " <display>\n";
|
Chris@0
|
2352
|
Chris@0
|
2353 layer->toXml(out, " ");
|
Chris@0
|
2354
|
Chris@0
|
2355 out << " </display>\n"
|
Chris@0
|
2356 << "</sv>\n";
|
Chris@0
|
2357 }
|
Chris@0
|
2358
|
Chris@185
|
2359 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@185
|
2360
|
Chris@185
|
2361 NoteModel *nm = dynamic_cast<NoteModel *>(model);
|
Chris@185
|
2362
|
Chris@185
|
2363 if (!nm) {
|
Chris@185
|
2364 error = tr("Can't export non-note layers to MIDI");
|
Chris@185
|
2365 } else {
|
Chris@185
|
2366 MIDIFileWriter writer(path, nm);
|
Chris@185
|
2367 writer.write();
|
Chris@185
|
2368 if (!writer.isOK()) {
|
Chris@185
|
2369 error = writer.getError();
|
Chris@185
|
2370 }
|
Chris@185
|
2371 }
|
Chris@185
|
2372
|
Chris@291
|
2373 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@291
|
2374
|
Chris@291
|
2375 RDFExporter exporter(path, model);
|
Chris@291
|
2376 exporter.write();
|
Chris@291
|
2377 if (!exporter.isOK()) {
|
Chris@291
|
2378 error = exporter.getError();
|
Chris@291
|
2379 }
|
Chris@291
|
2380
|
Chris@0
|
2381 } else {
|
Chris@0
|
2382
|
Chris@0
|
2383 CSVFileWriter writer(path, model,
|
Chris@185
|
2384 ((suffix == "csv") ? "," : "\t"));
|
Chris@0
|
2385 writer.write();
|
Chris@0
|
2386
|
Chris@0
|
2387 if (!writer.isOK()) {
|
Chris@0
|
2388 error = writer.getError();
|
Chris@0
|
2389 }
|
Chris@0
|
2390 }
|
Chris@0
|
2391
|
Chris@0
|
2392 if (error != "") {
|
Chris@0
|
2393 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2394 } else {
|
Chris@34
|
2395 m_recentFiles.addFile(path);
|
Chris@310
|
2396 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@0
|
2397 }
|
Chris@0
|
2398 }
|
Chris@0
|
2399
|
Chris@121
|
2400 void
|
Chris@121
|
2401 MainWindow::exportImage()
|
Chris@121
|
2402 {
|
Chris@121
|
2403 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@121
|
2404 if (!pane) return;
|
Chris@121
|
2405
|
Chris@121
|
2406 QString path = getSaveFileName(FileFinder::ImageFile);
|
Chris@121
|
2407
|
Chris@121
|
2408 if (path == "") return;
|
Chris@121
|
2409
|
Chris@121
|
2410 if (QFileInfo(path).suffix() == "") path += ".png";
|
Chris@121
|
2411
|
Chris@123
|
2412 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@123
|
2413
|
Chris@123
|
2414 QSize total, visible, selected;
|
Chris@123
|
2415 total = pane->getImageSize();
|
Chris@123
|
2416 visible = pane->getImageSize(pane->getFirstVisibleFrame(),
|
Chris@123
|
2417 pane->getLastVisibleFrame());
|
Chris@123
|
2418
|
Chris@123
|
2419 size_t sf0 = 0, sf1 = 0;
|
Chris@123
|
2420
|
Chris@123
|
2421 if (haveSelection) {
|
Chris@123
|
2422 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@123
|
2423 sf0 = selections.begin()->getStartFrame();
|
Chris@123
|
2424 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@123
|
2425 --e;
|
Chris@123
|
2426 sf1 = e->getEndFrame();
|
Chris@123
|
2427 selected = pane->getImageSize(sf0, sf1);
|
Chris@123
|
2428 }
|
Chris@123
|
2429
|
Chris@123
|
2430 QStringList items;
|
Chris@125
|
2431 items << tr("Export the whole pane (%1x%2 pixels)")
|
Chris@123
|
2432 .arg(total.width()).arg(total.height());
|
Chris@123
|
2433 items << tr("Export the visible area only (%1x%2 pixels)")
|
Chris@123
|
2434 .arg(visible.width()).arg(visible.height());
|
Chris@123
|
2435 if (haveSelection) {
|
Chris@123
|
2436 items << tr("Export the selection extent (%1x%2 pixels)")
|
Chris@123
|
2437 .arg(selected.width()).arg(selected.height());
|
Chris@124
|
2438 } else {
|
Chris@124
|
2439 items << tr("Export the selection extent");
|
Chris@123
|
2440 }
|
Chris@123
|
2441
|
Chris@123
|
2442 QSettings settings;
|
Chris@123
|
2443 settings.beginGroup("MainWindow");
|
Chris@123
|
2444 int deflt = settings.value("lastimageexportregion", 0).toInt();
|
Chris@123
|
2445 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@124
|
2446 if (deflt == 0 && total.width() > 32767) deflt = 1;
|
Chris@124
|
2447
|
Chris@124
|
2448 ListInputDialog *lid = new ListInputDialog
|
Chris@123
|
2449 (this, tr("Select region to export"),
|
Chris@123
|
2450 tr("Which region of the current pane do you want to export as an image?"),
|
Chris@124
|
2451 items, deflt);
|
Chris@124
|
2452
|
Chris@124
|
2453 if (!haveSelection) {
|
Chris@124
|
2454 lid->setItemAvailability(2, false);
|
Chris@124
|
2455 }
|
Chris@124
|
2456 if (total.width() > 32767) { // appears to be the limit of a QImage
|
Chris@124
|
2457 lid->setItemAvailability(0, false);
|
Chris@124
|
2458 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
|
Chris@124
|
2459 }
|
Chris@124
|
2460
|
Chris@124
|
2461 bool ok = lid->exec();
|
Chris@124
|
2462 QString item = lid->getCurrentString();
|
Chris@124
|
2463 delete lid;
|
Chris@123
|
2464
|
Chris@123
|
2465 if (!ok || item.isEmpty()) return;
|
Chris@123
|
2466
|
Chris@123
|
2467 settings.setValue("lastimageexportregion", deflt);
|
Chris@123
|
2468
|
Chris@123
|
2469 QImage *image = 0;
|
Chris@123
|
2470
|
Chris@123
|
2471 if (item == items[0]) {
|
Chris@123
|
2472 image = pane->toNewImage();
|
Chris@123
|
2473 } else if (item == items[1]) {
|
Chris@123
|
2474 image = pane->toNewImage(pane->getFirstVisibleFrame(),
|
Chris@123
|
2475 pane->getLastVisibleFrame());
|
Chris@123
|
2476 } else if (haveSelection) {
|
Chris@123
|
2477 image = pane->toNewImage(sf0, sf1);
|
Chris@123
|
2478 }
|
Chris@123
|
2479
|
Chris@121
|
2480 if (!image) return;
|
Chris@121
|
2481
|
Chris@121
|
2482 if (!image->save(path, "PNG")) {
|
Chris@121
|
2483 QMessageBox::critical(this, tr("Failed to save image file"),
|
Chris@121
|
2484 tr("Failed to save image file %1").arg(path));
|
Chris@121
|
2485 }
|
Chris@121
|
2486
|
Chris@121
|
2487 delete image;
|
Chris@121
|
2488 }
|
Chris@121
|
2489
|
Chris@0
|
2490 void
|
Chris@0
|
2491 MainWindow::newSession()
|
Chris@0
|
2492 {
|
Chris@0
|
2493 if (!checkSaveModified()) return;
|
Chris@0
|
2494
|
Chris@0
|
2495 closeSession();
|
Chris@0
|
2496 createDocument();
|
Chris@0
|
2497
|
Chris@0
|
2498 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
2499
|
Chris@90
|
2500 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
2501 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@90
|
2502
|
Chris@0
|
2503 if (!m_timeRulerLayer) {
|
Chris@0
|
2504 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2505 (LayerFactory::TimeRuler);
|
Chris@0
|
2506 }
|
Chris@0
|
2507
|
Chris@0
|
2508 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2509
|
Chris@0
|
2510 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
2511 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
2512
|
Chris@65
|
2513 m_overview->registerView(pane);
|
Chris@0
|
2514
|
Chris@0
|
2515 CommandHistory::getInstance()->clear();
|
Chris@0
|
2516 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2517 documentRestored();
|
Chris@0
|
2518 updateMenuStates();
|
Chris@0
|
2519 }
|
Chris@0
|
2520
|
Chris@0
|
2521 void
|
Chris@303
|
2522 MainWindow::documentReplaced()
|
Chris@303
|
2523 {
|
Chris@303
|
2524 if (m_document) {
|
Chris@303
|
2525 connect(m_document, SIGNAL(activity(QString)),
|
Chris@303
|
2526 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
2527 }
|
Chris@303
|
2528 }
|
Chris@303
|
2529
|
Chris@303
|
2530 void
|
Chris@0
|
2531 MainWindow::closeSession()
|
Chris@0
|
2532 {
|
Chris@0
|
2533 if (!checkSaveModified()) return;
|
Chris@0
|
2534
|
Chris@0
|
2535 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
2536
|
Chris@0
|
2537 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
2538
|
Chris@0
|
2539 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2540 m_document->removeLayerFromView
|
Chris@0
|
2541 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2542 }
|
Chris@0
|
2543
|
Chris@65
|
2544 m_overview->unregisterView(pane);
|
Chris@0
|
2545 m_paneStack->deletePane(pane);
|
Chris@0
|
2546 }
|
Chris@0
|
2547
|
Chris@0
|
2548 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
2549
|
Chris@0
|
2550 Pane *pane = m_paneStack->getHiddenPane
|
Chris@0
|
2551 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
2552
|
Chris@0
|
2553 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2554 m_document->removeLayerFromView
|
Chris@0
|
2555 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2556 }
|
Chris@0
|
2557
|
Chris@65
|
2558 m_overview->unregisterView(pane);
|
Chris@0
|
2559 m_paneStack->deletePane(pane);
|
Chris@0
|
2560 }
|
Chris@0
|
2561
|
Chris@0
|
2562 delete m_document;
|
Chris@0
|
2563 m_document = 0;
|
Chris@0
|
2564 m_viewManager->clearSelections();
|
Chris@0
|
2565 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
2566
|
Chris@0
|
2567 m_sessionFile = "";
|
Chris@0
|
2568 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2569
|
Chris@0
|
2570 CommandHistory::getInstance()->clear();
|
Chris@0
|
2571 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2572 documentRestored();
|
Chris@0
|
2573 }
|
Chris@0
|
2574
|
Chris@0
|
2575 void
|
Chris@0
|
2576 MainWindow::openSession()
|
Chris@0
|
2577 {
|
Chris@0
|
2578 if (!checkSaveModified()) return;
|
Chris@0
|
2579
|
Chris@0
|
2580 QString orig = m_audioFile;
|
Chris@0
|
2581 if (orig == "") orig = ".";
|
Chris@0
|
2582 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2583
|
Chris@88
|
2584 QString path = getOpenFileName(FileFinder::SessionFile);
|
Chris@0
|
2585
|
Chris@0
|
2586 if (path.isEmpty()) return;
|
Chris@0
|
2587
|
Chris@200
|
2588 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@247
|
2589 emit hideSplash();
|
Chris@0
|
2590 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2591 tr("<b>File open failed</b><p>Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2592 }
|
Chris@0
|
2593 }
|
Chris@0
|
2594
|
Chris@0
|
2595 void
|
Chris@0
|
2596 MainWindow::openSomething()
|
Chris@0
|
2597 {
|
Chris@0
|
2598 QString orig = m_audioFile;
|
Chris@0
|
2599 if (orig == "") orig = ".";
|
Chris@0
|
2600 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2601
|
Chris@88
|
2602 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
2603
|
Chris@0
|
2604 if (path.isEmpty()) return;
|
Chris@0
|
2605
|
Chris@197
|
2606 FileOpenStatus status = open(path, AskUser);
|
Chris@193
|
2607
|
Chris@193
|
2608 if (status == FileOpenFailed) {
|
Chris@247
|
2609 emit hideSplash();
|
Chris@193
|
2610 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2611 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@193
|
2612 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2613 emit hideSplash();
|
Chris@193
|
2614 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
2615 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
|
2616 }
|
Chris@0
|
2617 }
|
Chris@0
|
2618
|
Chris@0
|
2619 void
|
Chris@86
|
2620 MainWindow::openLocation()
|
Chris@86
|
2621 {
|
Chris@103
|
2622 QSettings settings;
|
Chris@103
|
2623 settings.beginGroup("MainWindow");
|
Chris@103
|
2624 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
2625
|
Chris@86
|
2626 bool ok = false;
|
Chris@86
|
2627 QString text = QInputDialog::getText
|
Chris@86
|
2628 (this, tr("Open Location"),
|
Chris@86
|
2629 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
2630 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
2631
|
Chris@103
|
2632 if (!ok) return;
|
Chris@103
|
2633
|
Chris@103
|
2634 settings.setValue("lastremote", text);
|
Chris@103
|
2635
|
Chris@103
|
2636 if (text.isEmpty()) return;
|
Chris@86
|
2637
|
Chris@197
|
2638 FileOpenStatus status = open(text);
|
Chris@193
|
2639
|
Chris@193
|
2640 if (status == FileOpenFailed) {
|
Chris@247
|
2641 emit hideSplash();
|
Chris@86
|
2642 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2643 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@193
|
2644 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2645 emit hideSplash();
|
Chris@193
|
2646 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
2647 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
|
2648 }
|
Chris@86
|
2649 }
|
Chris@86
|
2650
|
Chris@86
|
2651 void
|
Chris@0
|
2652 MainWindow::openRecentFile()
|
Chris@0
|
2653 {
|
Chris@0
|
2654 QObject *obj = sender();
|
Chris@0
|
2655 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
2656
|
Chris@0
|
2657 if (!action) {
|
Chris@0
|
2658 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@0
|
2659 << std::endl;
|
Chris@0
|
2660 return;
|
Chris@0
|
2661 }
|
Chris@0
|
2662
|
Chris@0
|
2663 QString path = action->text();
|
Chris@0
|
2664 if (path == "") return;
|
Chris@0
|
2665
|
Chris@197
|
2666 FileOpenStatus status = open(path);
|
Chris@193
|
2667
|
Chris@193
|
2668 if (status == FileOpenFailed) {
|
Chris@247
|
2669 emit hideSplash();
|
Chris@193
|
2670 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2671 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@193
|
2672 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2673 emit hideSplash();
|
Chris@193
|
2674 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
2675 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
|
2676 }
|
Chris@0
|
2677 }
|
Chris@0
|
2678
|
Chris@0
|
2679 void
|
Chris@200
|
2680 MainWindow::paneAdded(Pane *pane)
|
Chris@200
|
2681 {
|
Chris@200
|
2682 if (m_overview) m_overview->registerView(pane);
|
Chris@200
|
2683 }
|
Chris@200
|
2684
|
Chris@200
|
2685 void
|
Chris@200
|
2686 MainWindow::paneHidden(Pane *pane)
|
Chris@200
|
2687 {
|
Chris@200
|
2688 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2689 }
|
Chris@200
|
2690
|
Chris@200
|
2691 void
|
Chris@200
|
2692 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@200
|
2693 {
|
Chris@200
|
2694 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2695 }
|
Chris@200
|
2696
|
Chris@200
|
2697 void
|
Chris@193
|
2698 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@193
|
2699 {
|
Chris@193
|
2700 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2701
|
Chris@193
|
2702 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@193
|
2703
|
Chris@295
|
2704 FileOpenStatus status;
|
Chris@295
|
2705
|
Chris@295
|
2706 if (i == uriList.begin()) {
|
Chris@295
|
2707 status = open(*i, ReplaceCurrentPane);
|
Chris@295
|
2708 } else {
|
Chris@295
|
2709 status = open(*i, CreateAdditionalModel);
|
Chris@295
|
2710 }
|
Chris@193
|
2711
|
Chris@193
|
2712 if (status == FileOpenFailed) {
|
Chris@247
|
2713 emit hideSplash();
|
Chris@193
|
2714 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
2715 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@295
|
2716 break;
|
Chris@193
|
2717 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2718 emit hideSplash();
|
Chris@193
|
2719 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@294
|
2720 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
|
2721 break;
|
Chris@295
|
2722 } else if (status == FileOpenCancelled) {
|
Chris@295
|
2723 break;
|
Chris@193
|
2724 }
|
Chris@193
|
2725 }
|
Chris@193
|
2726 }
|
Chris@193
|
2727
|
Chris@193
|
2728 void
|
Chris@193
|
2729 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@193
|
2730 {
|
Chris@193
|
2731 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2732
|
Chris@193
|
2733 QUrl testUrl(text);
|
Chris@193
|
2734 if (testUrl.scheme() == "file" ||
|
Chris@193
|
2735 testUrl.scheme() == "http" ||
|
Chris@193
|
2736 testUrl.scheme() == "ftp") {
|
Chris@193
|
2737 QStringList list;
|
Chris@193
|
2738 list.push_back(text);
|
Chris@193
|
2739 paneDropAccepted(pane, list);
|
Chris@193
|
2740 return;
|
Chris@193
|
2741 }
|
Chris@193
|
2742
|
Chris@193
|
2743 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@193
|
2744 //to a text layer?
|
Chris@193
|
2745 }
|
Chris@193
|
2746
|
Chris@193
|
2747 void
|
Chris@0
|
2748 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
2749 {
|
Chris@137
|
2750 // std::cerr << "MainWindow::closeEvent" << std::endl;
|
Chris@118
|
2751
|
Chris@136
|
2752 if (m_openingAudioFile) {
|
Chris@137
|
2753 // std::cerr << "Busy - ignoring close event" << std::endl;
|
Chris@136
|
2754 e->ignore();
|
Chris@136
|
2755 return;
|
Chris@136
|
2756 }
|
Chris@136
|
2757
|
Chris@70
|
2758 if (!m_abandoning && !checkSaveModified()) {
|
Chris@137
|
2759 // std::cerr << "Ignoring close event" << std::endl;
|
Chris@0
|
2760 e->ignore();
|
Chris@0
|
2761 return;
|
Chris@0
|
2762 }
|
Chris@0
|
2763
|
Chris@5
|
2764 QSettings settings;
|
Chris@5
|
2765 settings.beginGroup("MainWindow");
|
Chris@5
|
2766 settings.setValue("size", size());
|
Chris@5
|
2767 settings.setValue("position", pos());
|
Chris@5
|
2768 settings.endGroup();
|
Chris@5
|
2769
|
Chris@163
|
2770 delete m_keyReference;
|
Chris@163
|
2771 m_keyReference = 0;
|
Chris@163
|
2772
|
Chris@163
|
2773 if (m_preferencesDialog &&
|
Chris@163
|
2774 m_preferencesDialog->isVisible()) {
|
Chris@164
|
2775 closeSession(); // otherwise we'll have to wait for prefs changes
|
Chris@163
|
2776 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2777 }
|
Chris@163
|
2778
|
Chris@200
|
2779 closeSession();
|
Chris@200
|
2780
|
Chris@0
|
2781 e->accept();
|
Chris@0
|
2782 return;
|
Chris@0
|
2783 }
|
Chris@0
|
2784
|
Chris@0
|
2785 bool
|
Chris@11
|
2786 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
2787 {
|
Chris@11
|
2788 if (mayAskUser) {
|
Chris@163
|
2789 bool rv = checkSaveModified();
|
Chris@163
|
2790 if (rv) {
|
Chris@163
|
2791 if (m_preferencesDialog &&
|
Chris@163
|
2792 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2793 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2794 }
|
Chris@163
|
2795 }
|
Chris@163
|
2796 return rv;
|
Chris@11
|
2797 } else {
|
Chris@163
|
2798 if (m_preferencesDialog &&
|
Chris@163
|
2799 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2800 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
2801 }
|
Chris@11
|
2802 if (!m_documentModified) return true;
|
Chris@11
|
2803
|
Chris@11
|
2804 // If we can't check with the user first, then we can't save
|
Chris@11
|
2805 // to the original session file (even if we have it) -- have
|
Chris@11
|
2806 // to use a temporary file
|
Chris@11
|
2807
|
Chris@11
|
2808 QString svDirBase = ".sv1";
|
Chris@11
|
2809 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
2810
|
Chris@11
|
2811 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
2812 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
2813 } else {
|
Chris@11
|
2814 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
2815 }
|
Chris@11
|
2816
|
Chris@11
|
2817 // This name doesn't have to be unguessable
|
Chris@93
|
2818 #ifndef _WIN32
|
Chris@11
|
2819 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
2820 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
2821 .arg(QProcess().pid());
|
Chris@93
|
2822 #else
|
Chris@93
|
2823 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
2824 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
2825 #endif
|
Chris@11
|
2826 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
2827 if (saveSessionFile(fpath)) {
|
Chris@34
|
2828 m_recentFiles.addFile(fpath);
|
Chris@310
|
2829 emit activity(tr("Export image to \"%1\"").arg(fpath));
|
Chris@11
|
2830 return true;
|
Chris@11
|
2831 } else {
|
Chris@11
|
2832 return false;
|
Chris@11
|
2833 }
|
Chris@11
|
2834 }
|
Chris@11
|
2835 }
|
Chris@11
|
2836
|
Chris@11
|
2837 bool
|
Chris@0
|
2838 MainWindow::checkSaveModified()
|
Chris@0
|
2839 {
|
Chris@0
|
2840 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
2841 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
2842 // cancel.
|
Chris@0
|
2843
|
Chris@0
|
2844 if (!m_documentModified) return true;
|
Chris@0
|
2845
|
Chris@247
|
2846 emit hideSplash();
|
Chris@247
|
2847
|
Chris@0
|
2848 int button =
|
Chris@0
|
2849 QMessageBox::warning(this,
|
Chris@0
|
2850 tr("Session modified"),
|
Chris@207
|
2851 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
|
Chris@165
|
2852 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@165
|
2853 QMessageBox::Yes);
|
Chris@0
|
2854
|
Chris@0
|
2855 if (button == QMessageBox::Yes) {
|
Chris@0
|
2856 saveSession();
|
Chris@0
|
2857 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@0
|
2858 return false;
|
Chris@0
|
2859 } else {
|
Chris@0
|
2860 return true; // saved, so it's safe to continue now
|
Chris@0
|
2861 }
|
Chris@0
|
2862 } else if (button == QMessageBox::No) {
|
Chris@0
|
2863 m_documentModified = false; // so we know to abandon it
|
Chris@0
|
2864 return true;
|
Chris@0
|
2865 }
|
Chris@0
|
2866
|
Chris@0
|
2867 // else cancel
|
Chris@0
|
2868 return false;
|
Chris@0
|
2869 }
|
Chris@0
|
2870
|
Chris@290
|
2871 bool
|
Chris@294
|
2872 MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
|
Chris@290
|
2873 {
|
Chris@294
|
2874 //!!! This is very similar to part of MainWindowBase::openAudio --
|
Chris@294
|
2875 //!!! make them a bit more uniform
|
Chris@294
|
2876
|
Chris@294
|
2877 QSettings settings;
|
Chris@294
|
2878 settings.beginGroup("MainWindow");
|
Chris@294
|
2879 bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
|
Chris@294
|
2880 settings.endGroup();
|
Chris@294
|
2881 bool newSession = true;
|
Chris@294
|
2882
|
Chris@294
|
2883 QStringList items;
|
Chris@294
|
2884 items << tr("Close the current session and create a new one")
|
Chris@294
|
2885 << tr("Add this data to the current session");
|
Chris@294
|
2886
|
Chris@294
|
2887 bool ok = false;
|
Chris@294
|
2888 QString item = ListInputDialog::getItem
|
Chris@294
|
2889 (this, tr("Select target for import"),
|
Chris@294
|
2890 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
|
2891 items, prevNewSession ? 0 : 1, &ok);
|
Chris@294
|
2892
|
Chris@294
|
2893 if (!ok || item.isEmpty()) {
|
Chris@294
|
2894 *cancel = true;
|
Chris@290
|
2895 return false;
|
Chris@290
|
2896 }
|
Chris@294
|
2897
|
Chris@294
|
2898 newSession = (item == items[0]);
|
Chris@294
|
2899 settings.beginGroup("MainWindow");
|
Chris@294
|
2900 settings.setValue("newsessionforrdfaudio", newSession);
|
Chris@294
|
2901 settings.endGroup();
|
Chris@294
|
2902
|
Chris@294
|
2903 if (newSession) return true;
|
Chris@294
|
2904 else return false;
|
Chris@290
|
2905 }
|
Chris@290
|
2906
|
Chris@0
|
2907 void
|
Chris@0
|
2908 MainWindow::saveSession()
|
Chris@0
|
2909 {
|
Chris@0
|
2910 if (m_sessionFile != "") {
|
Chris@0
|
2911 if (!saveSessionFile(m_sessionFile)) {
|
Chris@0
|
2912 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2913 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
2914 } else {
|
Chris@0
|
2915 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2916 documentRestored();
|
Chris@0
|
2917 }
|
Chris@0
|
2918 } else {
|
Chris@0
|
2919 saveSessionAs();
|
Chris@0
|
2920 }
|
Chris@0
|
2921 }
|
Chris@0
|
2922
|
Chris@0
|
2923 void
|
Chris@0
|
2924 MainWindow::saveSessionAs()
|
Chris@0
|
2925 {
|
Chris@0
|
2926 QString orig = m_audioFile;
|
Chris@0
|
2927 if (orig == "") orig = ".";
|
Chris@0
|
2928 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2929
|
Chris@88
|
2930 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
2931
|
Chris@81
|
2932 if (path == "") return;
|
Chris@0
|
2933
|
Chris@0
|
2934 if (!saveSessionFile(path)) {
|
Chris@0
|
2935 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2936 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
2937 } else {
|
Chris@0
|
2938 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@0
|
2939 .arg(QFileInfo(path).fileName()));
|
Chris@0
|
2940 m_sessionFile = path;
|
Chris@0
|
2941 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2942 documentRestored();
|
Chris@34
|
2943 m_recentFiles.addFile(path);
|
Chris@310
|
2944 emit activity(tr("Save session as \"%1\"").arg(path));
|
Chris@0
|
2945 }
|
Chris@0
|
2946 }
|
Chris@0
|
2947
|
Chris@90
|
2948 void
|
Chris@72
|
2949 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
2950 {
|
Chris@200
|
2951 MainWindowBase::preferenceChanged(name);
|
Chris@200
|
2952
|
Chris@200
|
2953 if (name == "Background Mode" && m_viewManager) {
|
Chris@180
|
2954 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@180
|
2955 m_panLayer->setBaseColour
|
Chris@180
|
2956 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@180
|
2957 } else {
|
Chris@180
|
2958 m_panLayer->setBaseColour
|
Chris@180
|
2959 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
|
Chris@180
|
2960 }
|
Chris@200
|
2961 }
|
Chris@0
|
2962 }
|
Chris@0
|
2963
|
Chris@0
|
2964 void
|
Chris@239
|
2965 MainWindow::propertyStacksResized(int width)
|
Chris@239
|
2966 {
|
Chris@251
|
2967 // std::cerr << "MainWindow::propertyStacksResized(" << width << ")" << std::endl;
|
Chris@239
|
2968
|
Chris@239
|
2969 if (!m_playControlsSpacer) return;
|
Chris@239
|
2970
|
Chris@239
|
2971 int spacerWidth = width - m_playControlsWidth - 4;
|
Chris@239
|
2972
|
Chris@251
|
2973 // std::cerr << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << std::endl;
|
Chris@239
|
2974
|
Chris@239
|
2975 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
|
Chris@239
|
2976 }
|
Chris@239
|
2977
|
Chris@239
|
2978 void
|
Chris@0
|
2979 MainWindow::addPane()
|
Chris@0
|
2980 {
|
Chris@0
|
2981 QObject *s = sender();
|
Chris@0
|
2982 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
2983
|
Chris@0
|
2984 if (!action) {
|
Chris@0
|
2985 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@0
|
2986 << std::endl;
|
Chris@0
|
2987 return;
|
Chris@0
|
2988 }
|
Chris@0
|
2989
|
Chris@0
|
2990 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
2991
|
Chris@0
|
2992 if (i == m_paneActions.end()) {
|
Chris@0
|
2993 std::cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@0
|
2994 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
2995 return;
|
Chris@0
|
2996 }
|
Chris@0
|
2997
|
Chris@69
|
2998 addPane(i->second, action->text());
|
Chris@69
|
2999 }
|
Chris@69
|
3000
|
Chris@69
|
3001 void
|
Chris@232
|
3002 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
|
Chris@69
|
3003 {
|
Chris@69
|
3004 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
3005
|
Chris@0
|
3006 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
3007 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3008
|
Chris@0
|
3009 Pane *pane = command->getPane();
|
Chris@0
|
3010
|
Chris@69
|
3011 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
3012 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
3013 pane->setFollowGlobalZoom(false);
|
Chris@112
|
3014 pane->setZoomLevel(512);
|
Chris@7
|
3015 }
|
Chris@7
|
3016
|
Chris@69
|
3017 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
3018 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
3019
|
Chris@0
|
3020 if (!m_timeRulerLayer) {
|
Chris@0
|
3021 // std::cerr << "no time ruler layer, creating one" << std::endl;
|
Chris@0
|
3022 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
3023 (LayerFactory::TimeRuler);
|
Chris@0
|
3024 }
|
Chris@0
|
3025
|
Chris@0
|
3026 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
|
Chris@0
|
3027
|
Chris@0
|
3028 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3029 }
|
Chris@0
|
3030
|
Chris@69
|
3031 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
3032
|
Chris@69
|
3033 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
3034 Model *model = 0;
|
Chris@66
|
3035
|
Chris@66
|
3036 if (suggestedModel) {
|
Chris@66
|
3037
|
Chris@66
|
3038 // check its validity
|
Chris@224
|
3039 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
3040 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
3041 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
3042 model = suggestedModel;
|
Chris@66
|
3043 break;
|
Chris@66
|
3044 }
|
Chris@66
|
3045 }
|
Chris@66
|
3046
|
Chris@66
|
3047 if (!model) {
|
Chris@66
|
3048 std::cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
3049 << " appears in pane action map, but is not reported "
|
Chris@66
|
3050 << "by document as a valid transform source" << std::endl;
|
Chris@66
|
3051 }
|
Chris@66
|
3052 }
|
Chris@66
|
3053
|
Chris@66
|
3054 if (!model) model = m_document->getMainModel();
|
Chris@66
|
3055
|
Chris@66
|
3056 m_document->setModel(newLayer, model);
|
Chris@66
|
3057
|
Chris@69
|
3058 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
3059 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3060
|
Chris@0
|
3061 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
3062 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3063
|
Chris@130
|
3064 // std::cerr << "MainWindow::addPane: global centre frame is "
|
Chris@130
|
3065 // << m_viewManager->getGlobalCentreFrame() << std::endl;
|
Chris@130
|
3066 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
3067
|
Chris@0
|
3068 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3069
|
Chris@0
|
3070 updateMenuStates();
|
Chris@0
|
3071 }
|
Chris@0
|
3072
|
Chris@0
|
3073 void
|
Chris@0
|
3074 MainWindow::addLayer()
|
Chris@0
|
3075 {
|
Chris@0
|
3076 QObject *s = sender();
|
Chris@0
|
3077 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3078
|
Chris@0
|
3079 if (!action) {
|
Chris@0
|
3080 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@0
|
3081 << std::endl;
|
Chris@0
|
3082 return;
|
Chris@0
|
3083 }
|
Chris@0
|
3084
|
Chris@0
|
3085 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3086
|
Chris@0
|
3087 if (!pane) {
|
Chris@0
|
3088 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@0
|
3089 return;
|
Chris@0
|
3090 }
|
Chris@0
|
3091
|
Chris@0
|
3092 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
3093
|
Chris@0
|
3094 if (ei != m_existingLayerActions.end()) {
|
Chris@0
|
3095 Layer *newLayer = ei->second;
|
Chris@0
|
3096 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3097 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3098 return;
|
Chris@0
|
3099 }
|
Chris@0
|
3100
|
Chris@95
|
3101 ei = m_sliceActions.find(action);
|
Chris@95
|
3102
|
Chris@95
|
3103 if (ei != m_sliceActions.end()) {
|
Chris@95
|
3104 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
3105 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
3106 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
3107 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
3108 if (source && dest) {
|
Chris@205
|
3109 //!!!???
|
Chris@95
|
3110 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
3111 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
3112 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
3113 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
3114 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
3115 }
|
Chris@95
|
3116 m_document->addLayerToView(pane, newLayer);
|
Chris@95
|
3117 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@95
|
3118 return;
|
Chris@95
|
3119 }
|
Chris@95
|
3120
|
Chris@211
|
3121 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
3122
|
Chris@34
|
3123 if (i == m_transformActions.end()) {
|
Chris@0
|
3124
|
Chris@0
|
3125 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@0
|
3126
|
Chris@0
|
3127 if (i == m_layerActions.end()) {
|
Chris@0
|
3128 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@0
|
3129 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3130 return;
|
Chris@0
|
3131 }
|
Chris@0
|
3132
|
Chris@232
|
3133 LayerFactory::LayerType type = i->second.layer;
|
Chris@0
|
3134
|
Chris@0
|
3135 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@0
|
3136 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@0
|
3137
|
Chris@0
|
3138 Layer *newLayer;
|
Chris@0
|
3139
|
Chris@0
|
3140 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@0
|
3141
|
Chris@0
|
3142 newLayer = m_document->createEmptyLayer(type);
|
Chris@217
|
3143 if (newLayer) {
|
Chris@217
|
3144 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@217
|
3145 }
|
Chris@0
|
3146
|
Chris@0
|
3147 } else {
|
Chris@0
|
3148
|
Chris@238
|
3149 if (!i->second.sourceModel) {
|
Chris@238
|
3150 // e.g. time ruler
|
Chris@238
|
3151 newLayer = m_document->createMainModelLayer(type);
|
Chris@232
|
3152 } else {
|
Chris@238
|
3153 newLayer = m_document->createLayer(type);
|
Chris@238
|
3154 if (m_document->isKnownModel(i->second.sourceModel)) {
|
Chris@238
|
3155 m_document->setChannel(newLayer, i->second.channel);
|
Chris@238
|
3156 m_document->setModel(newLayer, i->second.sourceModel);
|
Chris@238
|
3157 } else {
|
Chris@238
|
3158 std::cerr << "WARNING: MainWindow::addLayer: unknown model "
|
Chris@238
|
3159 << i->second.sourceModel
|
Chris@238
|
3160 << " (\""
|
Chris@238
|
3161 << (i->second.sourceModel ? i->second.sourceModel->objectName().toStdString() : "")
|
Chris@238
|
3162 << "\") in layer action map"
|
Chris@238
|
3163 << std::endl;
|
Chris@238
|
3164 }
|
Chris@232
|
3165 }
|
Chris@238
|
3166 }
|
Chris@0
|
3167
|
Chris@217
|
3168 if (newLayer) {
|
Chris@217
|
3169 m_document->addLayerToView(pane, newLayer);
|
Chris@217
|
3170 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@217
|
3171 }
|
Chris@0
|
3172
|
Chris@0
|
3173 return;
|
Chris@0
|
3174 }
|
Chris@0
|
3175
|
Chris@224
|
3176 //!!! want to do something like this, but it's not supported in
|
Chris@224
|
3177 //ModelTransformerFactory yet
|
Chris@224
|
3178 /*
|
Chris@0
|
3179 int channel = -1;
|
Chris@0
|
3180 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
3181 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3182 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@0
|
3183 if (c != -1) {
|
Chris@0
|
3184 channel = c;
|
Chris@0
|
3185 break;
|
Chris@0
|
3186 }
|
Chris@0
|
3187 }
|
Chris@224
|
3188 */
|
Chris@0
|
3189
|
Chris@33
|
3190 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
3191 // supposed to be configurable, because we need to let the user
|
Chris@33
|
3192 // change the execution context (block size etc).
|
Chris@0
|
3193
|
Chris@224
|
3194 QString transformId = i->second;
|
Chris@274
|
3195
|
Chris@274
|
3196 addLayer(transformId);
|
Chris@274
|
3197 }
|
Chris@274
|
3198
|
Chris@274
|
3199 void
|
Chris@274
|
3200 MainWindow::addLayer(QString transformId)
|
Chris@274
|
3201 {
|
Chris@274
|
3202 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@274
|
3203 if (!pane) {
|
Chris@274
|
3204 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@274
|
3205 return;
|
Chris@274
|
3206 }
|
Chris@274
|
3207
|
Chris@224
|
3208 Transform transform = TransformFactory::getInstance()->
|
Chris@224
|
3209 getDefaultTransformFor(transformId);
|
Chris@27
|
3210
|
Chris@66
|
3211 std::vector<Model *> candidateInputModels =
|
Chris@224
|
3212 m_document->getTransformInputModels();
|
Chris@53
|
3213
|
Chris@219
|
3214 Model *defaultInputModel = 0;
|
Chris@219
|
3215 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@219
|
3216 Layer *layer = pane->getLayer(j);
|
Chris@219
|
3217 if (!layer) continue;
|
Chris@243
|
3218 if (LayerFactory::getInstance()->getLayerType(layer) !=
|
Chris@243
|
3219 LayerFactory::Waveform &&
|
Chris@243
|
3220 !layer->isLayerOpaque()) continue;
|
Chris@219
|
3221 Model *model = layer->getModel();
|
Chris@219
|
3222 if (!model) continue;
|
Chris@219
|
3223 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
|
Chris@219
|
3224 if (candidateInputModels[k] == model) {
|
Chris@219
|
3225 defaultInputModel = model;
|
Chris@219
|
3226 break;
|
Chris@219
|
3227 }
|
Chris@219
|
3228 }
|
Chris@219
|
3229 if (defaultInputModel) break;
|
Chris@219
|
3230 }
|
Chris@219
|
3231
|
Chris@184
|
3232 size_t startFrame = 0, duration = 0;
|
Chris@184
|
3233 size_t endFrame = 0;
|
Chris@184
|
3234 m_viewManager->getSelection().getExtents(startFrame, endFrame);
|
Chris@184
|
3235 if (endFrame > startFrame) duration = endFrame - startFrame;
|
Chris@184
|
3236 else startFrame = 0;
|
Chris@184
|
3237
|
Chris@224
|
3238 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
Chris@224
|
3239 getConfigurationForTransform
|
Chris@211
|
3240 (transform,
|
Chris@211
|
3241 candidateInputModels,
|
Chris@219
|
3242 defaultInputModel,
|
Chris@211
|
3243 m_playSource,
|
Chris@211
|
3244 startFrame,
|
Chris@211
|
3245 duration);
|
Chris@211
|
3246
|
Chris@224
|
3247 if (!input.getModel()) return;
|
Chris@224
|
3248
|
Chris@324
|
3249 // 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
|
3250
|
Chris@224
|
3251 Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
Chris@0
|
3252
|
Chris@0
|
3253 if (newLayer) {
|
Chris@0
|
3254 m_document->addLayerToView(pane, newLayer);
|
Chris@224
|
3255 m_document->setChannel(newLayer, input.getChannel());
|
Chris@224
|
3256 m_recentTransforms.add(transformId);
|
Chris@70
|
3257 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3258 }
|
Chris@0
|
3259
|
Chris@0
|
3260 updateMenuStates();
|
Chris@0
|
3261 }
|
Chris@0
|
3262
|
Chris@0
|
3263 void
|
Chris@0
|
3264 MainWindow::renameCurrentLayer()
|
Chris@0
|
3265 {
|
Chris@0
|
3266 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3267 if (pane) {
|
Chris@0
|
3268 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3269 if (layer) {
|
Chris@0
|
3270 bool ok = false;
|
Chris@0
|
3271 QString newName = QInputDialog::getText
|
Chris@0
|
3272 (this, tr("Rename Layer"),
|
Chris@0
|
3273 tr("New name for this layer:"),
|
Chris@0
|
3274 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@0
|
3275 if (ok) {
|
Chris@239
|
3276 layer->setPresentationName(newName);
|
Chris@95
|
3277 setupExistingLayersMenus();
|
Chris@0
|
3278 }
|
Chris@0
|
3279 }
|
Chris@0
|
3280 }
|
Chris@0
|
3281 }
|
Chris@0
|
3282
|
Chris@0
|
3283 void
|
Chris@272
|
3284 MainWindow::findTransform()
|
Chris@272
|
3285 {
|
Chris@274
|
3286 TransformFinder *finder = new TransformFinder(this);
|
Chris@274
|
3287 if (!finder->exec()) {
|
Chris@274
|
3288 delete finder;
|
Chris@274
|
3289 return;
|
Chris@273
|
3290 }
|
Chris@274
|
3291 TransformId transform = finder->getTransform();
|
Chris@274
|
3292 delete finder;
|
Chris@287
|
3293
|
Chris@287
|
3294 if (getMainModel() != 0 && m_paneStack->getCurrentPane() != 0) {
|
Chris@287
|
3295 addLayer(transform);
|
Chris@287
|
3296 }
|
Chris@272
|
3297 }
|
Chris@272
|
3298
|
Chris@272
|
3299 void
|
Chris@207
|
3300 MainWindow::playSoloToggled()
|
Chris@207
|
3301 {
|
Chris@207
|
3302 MainWindowBase::playSoloToggled();
|
Chris@207
|
3303 m_soloModified = true;
|
Chris@207
|
3304 }
|
Chris@207
|
3305
|
Chris@207
|
3306 void
|
Chris@206
|
3307 MainWindow::alignToggled()
|
Chris@206
|
3308 {
|
Chris@206
|
3309 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@206
|
3310
|
Chris@207
|
3311 if (!m_viewManager) return;
|
Chris@207
|
3312
|
Chris@206
|
3313 if (action) {
|
Chris@206
|
3314 m_viewManager->setAlignMode(action->isChecked());
|
Chris@206
|
3315 } else {
|
Chris@206
|
3316 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
|
Chris@206
|
3317 }
|
Chris@206
|
3318
|
Chris@206
|
3319 if (m_viewManager->getAlignMode()) {
|
Chris@207
|
3320 m_prevSolo = m_soloAction->isChecked();
|
Chris@208
|
3321 if (!m_soloAction->isChecked()) {
|
Chris@208
|
3322 m_soloAction->setChecked(true);
|
Chris@208
|
3323 MainWindowBase::playSoloToggled();
|
Chris@208
|
3324 }
|
Chris@207
|
3325 m_soloModified = false;
|
Chris@207
|
3326 emit canChangeSolo(false);
|
Chris@206
|
3327 m_document->alignModels();
|
Chris@206
|
3328 m_document->setAutoAlignment(true);
|
Chris@206
|
3329 } else {
|
Chris@207
|
3330 if (!m_soloModified) {
|
Chris@208
|
3331 if (m_soloAction->isChecked() != m_prevSolo) {
|
Chris@208
|
3332 m_soloAction->setChecked(m_prevSolo);
|
Chris@208
|
3333 MainWindowBase::playSoloToggled();
|
Chris@208
|
3334 }
|
Chris@207
|
3335 }
|
Chris@207
|
3336 emit canChangeSolo(true);
|
Chris@206
|
3337 m_document->setAutoAlignment(false);
|
Chris@206
|
3338 }
|
Chris@206
|
3339
|
Chris@206
|
3340 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@206
|
3341
|
Chris@206
|
3342 Pane *pane = m_paneStack->getPane(i);
|
Chris@206
|
3343 if (!pane) continue;
|
Chris@206
|
3344
|
Chris@206
|
3345 pane->update();
|
Chris@206
|
3346 }
|
Chris@206
|
3347 }
|
Chris@206
|
3348
|
Chris@206
|
3349 void
|
Chris@59
|
3350 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
3351 {
|
Chris@59
|
3352 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@60
|
3353
|
Chris@60
|
3354 float percent = m_playSpeed->mappedValue();
|
Chris@60
|
3355 float factor = mapper.getFactorForValue(percent);
|
Chris@60
|
3356
|
Chris@267
|
3357 // std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
|
Chris@60
|
3358
|
Chris@59
|
3359 bool something = (position != 100);
|
Chris@155
|
3360
|
Chris@59
|
3361 int pc = lrintf(percent);
|
Chris@21
|
3362
|
Chris@155
|
3363 if (!something) {
|
Chris@155
|
3364 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@155
|
3365 } else {
|
Chris@155
|
3366 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@155
|
3367 .arg(position > 100 ? "+" : "")
|
Chris@155
|
3368 .arg(pc));
|
Chris@155
|
3369 }
|
Chris@155
|
3370
|
Chris@240
|
3371 m_playSource->setTimeStretch(factor);
|
Chris@155
|
3372
|
Chris@155
|
3373 updateMenuStates();
|
Chris@16
|
3374 }
|
Chris@16
|
3375
|
Chris@26
|
3376 void
|
Chris@155
|
3377 MainWindow::speedUpPlayback()
|
Chris@155
|
3378 {
|
Chris@155
|
3379 int value = m_playSpeed->value();
|
Chris@155
|
3380 value = value + m_playSpeed->pageStep();
|
Chris@155
|
3381 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@155
|
3382 m_playSpeed->setValue(value);
|
Chris@155
|
3383 }
|
Chris@155
|
3384
|
Chris@155
|
3385 void
|
Chris@155
|
3386 MainWindow::slowDownPlayback()
|
Chris@155
|
3387 {
|
Chris@155
|
3388 int value = m_playSpeed->value();
|
Chris@155
|
3389 value = value - m_playSpeed->pageStep();
|
Chris@155
|
3390 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@155
|
3391 m_playSpeed->setValue(value);
|
Chris@155
|
3392 }
|
Chris@155
|
3393
|
Chris@155
|
3394 void
|
Chris@155
|
3395 MainWindow::restoreNormalPlayback()
|
Chris@155
|
3396 {
|
Chris@155
|
3397 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@155
|
3398 }
|
Chris@155
|
3399
|
Chris@155
|
3400 void
|
Chris@227
|
3401 MainWindow::currentPaneChanged(Pane *pane)
|
Chris@227
|
3402 {
|
Chris@228
|
3403 MainWindowBase::currentPaneChanged(pane);
|
Chris@228
|
3404
|
Chris@227
|
3405 if (!pane || !m_panLayer) return;
|
Chris@227
|
3406 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@227
|
3407 --i;
|
Chris@227
|
3408 Layer *layer = pane->getLayer(i);
|
Chris@227
|
3409 if (LayerFactory::getInstance()->getLayerType(layer) ==
|
Chris@227
|
3410 LayerFactory::Waveform) {
|
Chris@227
|
3411 RangeSummarisableTimeValueModel *tvm =
|
Chris@227
|
3412 dynamic_cast<RangeSummarisableTimeValueModel *>(layer->getModel());
|
Chris@227
|
3413 if (tvm) {
|
Chris@227
|
3414 m_panLayer->setModel(tvm);
|
Chris@227
|
3415 return;
|
Chris@227
|
3416 }
|
Chris@227
|
3417 }
|
Chris@227
|
3418 }
|
Chris@227
|
3419 }
|
Chris@227
|
3420
|
Chris@227
|
3421 void
|
Chris@116
|
3422 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@116
|
3423 {
|
Chris@116
|
3424 if (!getMainModel() || !p) {
|
Chris@116
|
3425 return;
|
Chris@116
|
3426 }
|
Chris@116
|
3427
|
Chris@117
|
3428 bool haveSelection = false;
|
Chris@117
|
3429 size_t startFrame = 0, endFrame = 0;
|
Chris@117
|
3430
|
Chris@117
|
3431 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@117
|
3432
|
Chris@117
|
3433 bool exclusive = false;
|
Chris@117
|
3434 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@117
|
3435
|
Chris@117
|
3436 if (!s.isEmpty()) {
|
Chris@117
|
3437 haveSelection = true;
|
Chris@117
|
3438 startFrame = s.getStartFrame();
|
Chris@117
|
3439 endFrame = s.getEndFrame();
|
Chris@117
|
3440 }
|
Chris@117
|
3441 }
|
Chris@117
|
3442
|
Chris@117
|
3443 if (!haveSelection) {
|
Chris@117
|
3444 startFrame = p->getFirstVisibleFrame();
|
Chris@117
|
3445 endFrame = p->getLastVisibleFrame();
|
Chris@117
|
3446 }
|
Chris@117
|
3447
|
Chris@116
|
3448 RealTime start = RealTime::frame2RealTime
|
Chris@117
|
3449 (startFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3450
|
Chris@116
|
3451 RealTime end = RealTime::frame2RealTime
|
Chris@117
|
3452 (endFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3453
|
Chris@116
|
3454 RealTime duration = end - start;
|
Chris@116
|
3455
|
Chris@116
|
3456 QString startStr, endStr, durationStr;
|
Chris@116
|
3457 startStr = start.toText(true).c_str();
|
Chris@116
|
3458 endStr = end.toText(true).c_str();
|
Chris@116
|
3459 durationStr = duration.toText(true).c_str();
|
Chris@116
|
3460
|
Chris@117
|
3461 if (haveSelection) {
|
Chris@117
|
3462 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@117
|
3463 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3464 } else {
|
Chris@117
|
3465 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@117
|
3466 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3467 }
|
Chris@116
|
3468
|
Chris@116
|
3469 statusBar()->showMessage(m_myStatusMessage);
|
Chris@116
|
3470 }
|
Chris@116
|
3471
|
Chris@116
|
3472 void
|
Chris@0
|
3473 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
3474 {
|
Chris@0
|
3475 m_fader->setPeakLeft(left);
|
Chris@0
|
3476 m_fader->setPeakRight(right);
|
Chris@0
|
3477 }
|
Chris@0
|
3478
|
Chris@0
|
3479 void
|
Chris@0
|
3480 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
3481 bool willResample)
|
Chris@0
|
3482 {
|
Chris@0
|
3483 if (!willResample) {
|
Chris@247
|
3484 emit hideSplash();
|
Chris@0
|
3485 QMessageBox::information
|
Chris@0
|
3486 (this, tr("Sample rate mismatch"),
|
Chris@193
|
3487 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
|
3488 .arg(requested).arg(actual));
|
Chris@0
|
3489 }
|
Chris@0
|
3490
|
Chris@0
|
3491 updateDescriptionLabel();
|
Chris@0
|
3492 }
|
Chris@0
|
3493
|
Chris@0
|
3494 void
|
Chris@42
|
3495 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
3496 {
|
Chris@42
|
3497 QMessageBox::information
|
Chris@42
|
3498 (this, tr("Audio processing overload"),
|
Chris@193
|
3499 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@42
|
3500 }
|
Chris@42
|
3501
|
Chris@42
|
3502 void
|
Chris@266
|
3503 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@266
|
3504 {
|
Chris@266
|
3505 static bool shownOnce = false;
|
Chris@266
|
3506 if (shownOnce) return;
|
Chris@266
|
3507 QMessageBox::information
|
Chris@266
|
3508 (this, tr("Audio processing overload"),
|
Chris@266
|
3509 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@266
|
3510 shownOnce = true;
|
Chris@266
|
3511 }
|
Chris@266
|
3512
|
Chris@266
|
3513 void
|
Chris@304
|
3514 MainWindow::midiEventsAvailable()
|
Chris@304
|
3515 {
|
Chris@307
|
3516 Pane *currentPane = 0;
|
Chris@307
|
3517 NoteLayer *currentNoteLayer = 0;
|
Chris@309
|
3518 TimeValueLayer *currentTimeValueLayer = 0;
|
Chris@307
|
3519
|
Chris@307
|
3520 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@307
|
3521 if (currentPane) {
|
Chris@307
|
3522 currentNoteLayer = dynamic_cast<NoteLayer *>
|
Chris@307
|
3523 (currentPane->getSelectedLayer());
|
Chris@309
|
3524 currentTimeValueLayer = dynamic_cast<TimeValueLayer *>
|
Chris@309
|
3525 (currentPane->getSelectedLayer());
|
Chris@307
|
3526 }
|
Chris@307
|
3527
|
Chris@305
|
3528 // This is called through a serialised signal/slot invocation
|
Chris@305
|
3529 // (across threads). It could happen quite some time after the
|
Chris@305
|
3530 // event was actually received, which is why event timestamping
|
Chris@305
|
3531 // happens in the MIDI input class and not here.
|
Chris@307
|
3532
|
Chris@305
|
3533 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@308
|
3534
|
Chris@305
|
3535 MIDIEvent ev(m_midiInput->readEvent());
|
Chris@307
|
3536
|
Chris@309
|
3537 size_t frame = currentPane->alignFromReference(ev.getTime());
|
Chris@309
|
3538
|
Chris@308
|
3539 bool noteOn = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
3540 ev.getVelocity() > 0);
|
Chris@308
|
3541
|
Chris@308
|
3542 bool noteOff = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_OFF ||
|
Chris@308
|
3543 (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
3544 ev.getVelocity() == 0));
|
Chris@308
|
3545
|
Chris@307
|
3546 if (currentNoteLayer) {
|
Chris@307
|
3547
|
Chris@310
|
3548 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
3549
|
Chris@308
|
3550 if (noteOn) {
|
Chris@307
|
3551
|
Chris@309
|
3552 currentNoteLayer->addNoteOn(frame,
|
Chris@307
|
3553 ev.getPitch(),
|
Chris@307
|
3554 ev.getVelocity());
|
Chris@307
|
3555
|
Chris@308
|
3556 } else if (noteOff) {
|
Chris@307
|
3557
|
Chris@309
|
3558 currentNoteLayer->addNoteOff(frame,
|
Chris@307
|
3559 ev.getPitch());
|
Chris@307
|
3560
|
Chris@307
|
3561 }
|
Chris@307
|
3562
|
Chris@309
|
3563 continue;
|
Chris@309
|
3564 }
|
Chris@309
|
3565
|
Chris@309
|
3566 if (currentTimeValueLayer) {
|
Chris@308
|
3567
|
Chris@308
|
3568 if (!noteOn) continue;
|
Chris@310
|
3569
|
Chris@310
|
3570 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
3571
|
Chris@309
|
3572 Model *model = static_cast<Layer *>(currentTimeValueLayer)->getModel();
|
Chris@309
|
3573 SparseTimeValueModel *tvm =
|
Chris@309
|
3574 dynamic_cast<SparseTimeValueModel *>(model);
|
Chris@309
|
3575 if (tvm) {
|
Chris@309
|
3576 SparseTimeValueModel::Point point(frame, ev.getPitch() % 12, "");
|
Chris@309
|
3577 SparseTimeValueModel::AddPointCommand *command =
|
Chris@309
|
3578 new SparseTimeValueModel::AddPointCommand
|
Chris@309
|
3579 (tvm, point, tr("Add Point"));
|
Chris@309
|
3580 CommandHistory::getInstance()->addCommand(command);
|
Chris@309
|
3581 }
|
Chris@309
|
3582 continue;
|
Chris@309
|
3583
|
Chris@305
|
3584 }
|
Chris@309
|
3585
|
Chris@309
|
3586 if (!noteOn) continue;
|
Chris@309
|
3587 insertInstantAt(ev.getTime());
|
Chris@304
|
3588 }
|
Chris@304
|
3589 }
|
Chris@304
|
3590
|
Chris@304
|
3591 void
|
Chris@305
|
3592 MainWindow::playStatusChanged(bool playing)
|
Chris@305
|
3593 {
|
Chris@307
|
3594 Pane *currentPane = 0;
|
Chris@307
|
3595 NoteLayer *currentNoteLayer = 0;
|
Chris@307
|
3596
|
Chris@307
|
3597 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@307
|
3598 if (currentPane) {
|
Chris@307
|
3599 currentNoteLayer = dynamic_cast<NoteLayer *>(currentPane->getSelectedLayer());
|
Chris@307
|
3600 }
|
Chris@307
|
3601
|
Chris@307
|
3602 if (currentNoteLayer) {
|
Chris@307
|
3603 currentNoteLayer->abandonNoteOns();
|
Chris@307
|
3604 }
|
Chris@305
|
3605 }
|
Chris@305
|
3606
|
Chris@305
|
3607 void
|
Chris@200
|
3608 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
3609 {
|
Chris@95
|
3610 setupExistingLayersMenus();
|
Chris@200
|
3611 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
3612 }
|
Chris@0
|
3613
|
Chris@0
|
3614 void
|
Chris@0
|
3615 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
3616 {
|
Chris@95
|
3617 setupExistingLayersMenus();
|
Chris@200
|
3618 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
3619 }
|
Chris@0
|
3620
|
Chris@0
|
3621 void
|
Chris@0
|
3622 MainWindow::modelAdded(Model *model)
|
Chris@0
|
3623 {
|
Chris@200
|
3624 MainWindowBase::modelAdded(model);
|
Chris@66
|
3625 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
3626 setupPaneAndLayerMenus();
|
Chris@66
|
3627 }
|
Chris@0
|
3628 }
|
Chris@0
|
3629
|
Chris@0
|
3630 void
|
Chris@0
|
3631 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
3632 {
|
Chris@0
|
3633 m_panLayer->setModel(model);
|
Chris@200
|
3634
|
Chris@200
|
3635 MainWindowBase::mainModelChanged(model);
|
Chris@200
|
3636
|
Chris@200
|
3637 if (m_playTarget) {
|
Chris@200
|
3638 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@200
|
3639 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@200
|
3640 }
|
Chris@0
|
3641 }
|
Chris@0
|
3642
|
Chris@0
|
3643 void
|
Chris@200
|
3644 MainWindow::setInstantsNumbering()
|
Chris@0
|
3645 {
|
Chris@200
|
3646 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3647 if (!a) return;
|
Chris@200
|
3648
|
Chris@200
|
3649 int type = m_numberingActions[a];
|
Chris@200
|
3650
|
Chris@200
|
3651 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
|
Chris@200
|
3652
|
Chris@200
|
3653 QSettings settings;
|
Chris@200
|
3654 settings.beginGroup("MainWindow");
|
Chris@200
|
3655 settings.setValue("labellertype", type);
|
Chris@200
|
3656 settings.endGroup();
|
Chris@200
|
3657 }
|
Chris@200
|
3658
|
Chris@200
|
3659 void
|
Chris@200
|
3660 MainWindow::setInstantsCounterCycle()
|
Chris@200
|
3661 {
|
Chris@200
|
3662 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3663 if (!a) return;
|
Chris@200
|
3664
|
Chris@200
|
3665 int cycle = a->text().toInt();
|
Chris@200
|
3666 if (cycle == 0) return;
|
Chris@200
|
3667
|
Chris@200
|
3668 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
|
Chris@200
|
3669
|
Chris@200
|
3670 QSettings settings;
|
Chris@200
|
3671 settings.beginGroup("MainWindow");
|
Chris@200
|
3672 settings.setValue("labellercycle", cycle);
|
Chris@200
|
3673 settings.endGroup();
|
Chris@200
|
3674 }
|
Chris@200
|
3675
|
Chris@200
|
3676 void
|
Chris@200
|
3677 MainWindow::resetInstantsCounters()
|
Chris@200
|
3678 {
|
Chris@200
|
3679 LabelCounterInputDialog dialog(m_labeller, this);
|
Chris@241
|
3680 dialog.setWindowTitle(tr("Reset Counters"));
|
Chris@200
|
3681 dialog.exec();
|
Chris@0
|
3682 }
|
Chris@0
|
3683
|
Chris@0
|
3684 void
|
Chris@233
|
3685 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@233
|
3686 {
|
Chris@247
|
3687 emit hideSplash();
|
Chris@247
|
3688
|
Chris@233
|
3689 if (message != "") {
|
Chris@233
|
3690
|
Chris@233
|
3691 QMessageBox::warning
|
Chris@233
|
3692 (this,
|
Chris@233
|
3693 tr("Failed to generate layer"),
|
Chris@233
|
3694 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@233
|
3695 .arg(transformName).arg(message),
|
Chris@233
|
3696 QMessageBox::Ok);
|
Chris@233
|
3697 } else {
|
Chris@233
|
3698 QMessageBox::warning
|
Chris@233
|
3699 (this,
|
Chris@233
|
3700 tr("Failed to generate layer"),
|
Chris@233
|
3701 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
|
3702 .arg(transformName),
|
Chris@233
|
3703 QMessageBox::Ok);
|
Chris@233
|
3704 }
|
Chris@233
|
3705 }
|
Chris@233
|
3706
|
Chris@233
|
3707 void
|
Chris@233
|
3708 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@233
|
3709 {
|
Chris@247
|
3710 emit hideSplash();
|
Chris@247
|
3711
|
Chris@233
|
3712 QMessageBox::warning
|
Chris@233
|
3713 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@233
|
3714 }
|
Chris@233
|
3715
|
Chris@233
|
3716 void
|
Chris@233
|
3717 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@233
|
3718 QString transformName, QString message)
|
Chris@233
|
3719 {
|
Chris@247
|
3720 emit hideSplash();
|
Chris@247
|
3721
|
Chris@233
|
3722 if (message != "") {
|
Chris@233
|
3723
|
Chris@233
|
3724 QMessageBox::warning
|
Chris@233
|
3725 (this,
|
Chris@233
|
3726 tr("Failed to regenerate layer"),
|
Chris@233
|
3727 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
|
3728 .arg(layerName).arg(transformName).arg(message),
|
Chris@233
|
3729 QMessageBox::Ok);
|
Chris@233
|
3730 } else {
|
Chris@233
|
3731 QMessageBox::warning
|
Chris@233
|
3732 (this,
|
Chris@233
|
3733 tr("Failed to regenerate layer"),
|
Chris@233
|
3734 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
|
3735 .arg(layerName).arg(transformName),
|
Chris@233
|
3736 QMessageBox::Ok);
|
Chris@233
|
3737 }
|
Chris@233
|
3738 }
|
Chris@233
|
3739
|
Chris@233
|
3740 void
|
Chris@233
|
3741 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@233
|
3742 QString transformName, QString message)
|
Chris@233
|
3743 {
|
Chris@247
|
3744 emit hideSplash();
|
Chris@247
|
3745
|
Chris@233
|
3746 QMessageBox::warning
|
Chris@233
|
3747 (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
|
3748 }
|
Chris@233
|
3749
|
Chris@233
|
3750 void
|
Chris@233
|
3751 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
3752 {
|
Chris@247
|
3753 emit hideSplash();
|
Chris@247
|
3754
|
Chris@0
|
3755 QMessageBox::warning
|
Chris@0
|
3756 (this,
|
Chris@233
|
3757 tr("Failed to calculate alignment"),
|
Chris@233
|
3758 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@233
|
3759 .arg(transformName).arg(message),
|
Chris@165
|
3760 QMessageBox::Ok);
|
Chris@0
|
3761 }
|
Chris@0
|
3762
|
Chris@0
|
3763 void
|
Chris@0
|
3764 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
3765 {
|
Chris@0
|
3766 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
|
Chris@0
|
3767 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
3768 m_rightButtonMenu->popup(position);
|
Chris@0
|
3769 }
|
Chris@0
|
3770
|
Chris@0
|
3771 void
|
Chris@0
|
3772 MainWindow::showLayerTree()
|
Chris@0
|
3773 {
|
Chris@219
|
3774 if (!m_layerTreeDialog.isNull()) {
|
Chris@219
|
3775 m_layerTreeDialog->show();
|
Chris@219
|
3776 m_layerTreeDialog->raise();
|
Chris@177
|
3777 return;
|
Chris@177
|
3778 }
|
Chris@177
|
3779
|
Chris@219
|
3780 m_layerTreeDialog = new LayerTreeDialog(m_paneStack);
|
Chris@232
|
3781 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
|
Chris@219
|
3782 m_layerTreeDialog->show();
|
Chris@0
|
3783 }
|
Chris@0
|
3784
|
Chris@0
|
3785 void
|
Chris@306
|
3786 MainWindow::showActivityLog()
|
Chris@306
|
3787 {
|
Chris@306
|
3788 m_activityLog->show();
|
Chris@306
|
3789 m_activityLog->raise();
|
Chris@306
|
3790 m_activityLog->scrollToEnd();
|
Chris@306
|
3791 }
|
Chris@306
|
3792
|
Chris@306
|
3793 void
|
Chris@0
|
3794 MainWindow::preferences()
|
Chris@0
|
3795 {
|
Chris@0
|
3796 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
3797 m_preferencesDialog->show();
|
Chris@0
|
3798 m_preferencesDialog->raise();
|
Chris@0
|
3799 return;
|
Chris@0
|
3800 }
|
Chris@0
|
3801
|
Chris@0
|
3802 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
3803
|
Chris@0
|
3804 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
3805 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
3806 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
3807 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
3808 // without resetting its own widgets, so its state will be
|
Chris@0
|
3809 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
3810 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
3811
|
Chris@0
|
3812 m_preferencesDialog->show();
|
Chris@0
|
3813 }
|
Chris@0
|
3814
|
Chris@0
|
3815 void
|
Chris@90
|
3816 MainWindow::mouseEnteredWidget()
|
Chris@90
|
3817 {
|
Chris@90
|
3818 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
3819 if (!w) return;
|
Chris@90
|
3820
|
Chris@90
|
3821 if (w == m_fader) {
|
Chris@116
|
3822 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@90
|
3823 } else if (w == m_playSpeed) {
|
Chris@116
|
3824 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@90
|
3825 }
|
Chris@90
|
3826 }
|
Chris@90
|
3827
|
Chris@90
|
3828 void
|
Chris@90
|
3829 MainWindow::mouseLeftWidget()
|
Chris@90
|
3830 {
|
Chris@116
|
3831 contextHelpChanged("");
|
Chris@116
|
3832 }
|
Chris@116
|
3833
|
Chris@116
|
3834 void
|
Chris@0
|
3835 MainWindow::website()
|
Chris@0
|
3836 {
|
Chris@0
|
3837 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
3838 }
|
Chris@0
|
3839
|
Chris@0
|
3840 void
|
Chris@0
|
3841 MainWindow::help()
|
Chris@0
|
3842 {
|
Chris@318
|
3843 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/%1/en/").arg(SV_VERSION));
|
Chris@0
|
3844 }
|
Chris@0
|
3845
|
Chris@0
|
3846 void
|
Chris@0
|
3847 MainWindow::about()
|
Chris@0
|
3848 {
|
Chris@0
|
3849 bool debug = false;
|
Chris@0
|
3850 QString version = "(unknown version)";
|
Chris@0
|
3851
|
Chris@0
|
3852 #ifdef BUILD_DEBUG
|
Chris@0
|
3853 debug = true;
|
Chris@285
|
3854 #endif // BUILD_DEBUG
|
Chris@0
|
3855 #ifdef SV_VERSION
|
Chris@0
|
3856 #ifdef SVNREV
|
Chris@0
|
3857 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@285
|
3858 #else // !SVNREV
|
Chris@0
|
3859 version = tr("Release %1").arg(SV_VERSION);
|
Chris@285
|
3860 #endif // SVNREV
|
Chris@285
|
3861 #else // !SV_VERSION
|
Chris@0
|
3862 #ifdef SVNREV
|
Chris@0
|
3863 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@285
|
3864 #endif // SVNREV
|
Chris@285
|
3865 #endif // SV_VERSION
|
Chris@0
|
3866
|
Chris@0
|
3867 QString aboutText;
|
Chris@0
|
3868
|
Chris@0
|
3869 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@285
|
3870 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
|
3871 aboutText += tr("<p><small>%1 : %2 configuration</small></p>")
|
Chris@0
|
3872 .arg(version)
|
Chris@0
|
3873 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
3874
|
Chris@285
|
3875 aboutText += "<small>";
|
Chris@285
|
3876
|
Chris@285
|
3877 aboutText += tr("With Qt v%1 © Nokia Corporation").arg(QT_VERSION_STR);
|
Chris@285
|
3878
|
Chris@0
|
3879 #ifdef HAVE_JACK
|
Chris@93
|
3880 #ifdef JACK_VERSION
|
Chris@285
|
3881 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@285
|
3882 #else // !JACK_VERSION
|
Chris@257
|
3883 aboutText += tr("<br>With JACK audio output library © Paul Davis and Jack O'Quin");
|
Chris@285
|
3884 #endif // JACK_VERSION
|
Chris@285
|
3885 #endif // HAVE_JACK
|
Chris@0
|
3886 #ifdef HAVE_PORTAUDIO
|
Chris@257
|
3887 aboutText += tr("<br>With PortAudio audio output library © Ross Bencina and Phil Burk");
|
Chris@285
|
3888 #endif // HAVE_PORTAUDIO
|
Chris@257
|
3889 #ifdef HAVE_LIBPULSE
|
Chris@285
|
3890 #ifdef LIBPULSE_VERSION
|
Chris@285
|
3891 aboutText += tr("<br>With PulseAudio audio output library v%1 © Lennart Poettering and Pierre Ossman").arg(LIBPULSE_VERSION);
|
Chris@285
|
3892 #else // !LIBPULSE_VERSION
|
Chris@257
|
3893 aboutText += tr("<br>With PulseAudio audio output library © Lennart Poettering and Pierre Ossman");
|
Chris@285
|
3894 #endif // LIBPULSE_VERSION
|
Chris@285
|
3895 #endif // HAVE_LIBPULSE
|
Chris@0
|
3896 #ifdef HAVE_OGGZ
|
Chris@93
|
3897 #ifdef OGGZ_VERSION
|
Chris@0
|
3898 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@285
|
3899 #else // !OGGZ_VERSION
|
Chris@93
|
3900 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@285
|
3901 #endif // OGGZ_VERSION
|
Chris@285
|
3902 #endif // HAVE_OGGZ
|
Chris@0
|
3903 #ifdef HAVE_MAD
|
Chris@93
|
3904 #ifdef MAD_VERSION
|
Chris@285
|
3905 aboutText += tr("<br>With MAD mp3 decoder v%1 © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@285
|
3906 #else // !MAD_VERSION
|
Chris@93
|
3907 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@285
|
3908 #endif // MAD_VERSION
|
Chris@285
|
3909 #endif // HAVE_MAD
|
Chris@0
|
3910 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
3911 #ifdef SAMPLERATE_VERSION
|
Chris@285
|
3912 aboutText += tr("<br>With libsamplerate v%1 © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@285
|
3913 #else // !SAMPLERATE_VERSION
|
Chris@93
|
3914 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@285
|
3915 #endif // SAMPLERATE_VERSION
|
Chris@285
|
3916 #endif // HAVE_SAMPLERATE
|
Chris@0
|
3917 #ifdef HAVE_SNDFILE
|
Chris@93
|
3918 #ifdef SNDFILE_VERSION
|
Chris@285
|
3919 aboutText += tr("<br>With libsndfile v%1 © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@285
|
3920 #else // !SNDFILE_VERSION
|
Chris@93
|
3921 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@285
|
3922 #endif // SNDFILE_VERSION
|
Chris@285
|
3923 #endif // HAVE_SNDFILE
|
Chris@127
|
3924 #ifdef HAVE_FFTW3F
|
Chris@93
|
3925 #ifdef FFTW3_VERSION
|
Chris@285
|
3926 aboutText += tr("<br>With FFTW3 v%1 © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@285
|
3927 #else // !FFTW3_VERSION
|
Chris@93
|
3928 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@285
|
3929 #endif // FFTW3_VERSION
|
Chris@285
|
3930 #endif // HAVE_FFTW3F
|
Chris@267
|
3931 #ifdef HAVE_RUBBERBAND
|
Chris@267
|
3932 #ifdef RUBBERBAND_VERSION
|
Chris@285
|
3933 aboutText += tr("<br>With Rubber Band v%1 © Chris Cannam").arg(RUBBERBAND_VERSION);
|
Chris@285
|
3934 #else // !RUBBERBAND_VERSION
|
Chris@267
|
3935 aboutText += tr("<br>With Rubber Band © Chris Cannam");
|
Chris@285
|
3936 #endif // RUBBERBAND_VERSION
|
Chris@285
|
3937 #endif // HAVE_RUBBERBAND
|
Chris@0
|
3938 #ifdef HAVE_VAMP
|
Chris@114
|
3939 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
|
3940 #endif // !HAVE_VAMP
|
Chris@0
|
3941 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
3942 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@285
|
3943 #ifdef RAPTOR_VERSION
|
Chris@285
|
3944 aboutText += tr("<br>With Raptor RDF parser v%1 © Dave Beckett and the University of Bristol").arg(RAPTOR_VERSION);
|
Chris@285
|
3945 #else // !RAPTOR_VERSION
|
Chris@285
|
3946 aboutText += tr("<br>With Raptor RDF parser © Dave Beckett and the University of Bristol");
|
Chris@285
|
3947 #endif // RAPTOR_VERSION
|
Chris@285
|
3948 #ifdef RASQAL_VERSION
|
Chris@285
|
3949 aboutText += tr("<br>With Rasqal RDF query engine v%1 © Dave Beckett and the University of Bristol").arg(RASQAL_VERSION);
|
Chris@285
|
3950 #else // !RASQAL_VERSION
|
Chris@285
|
3951 aboutText += tr("<br>With Rasqal RDF query engine © Dave Beckett and the University of Bristol");
|
Chris@285
|
3952 #endif // RASQAL_VERSION
|
Chris@285
|
3953 #ifdef HAVE_REDLAND
|
Chris@285
|
3954 #ifdef REDLAND_VERSION
|
Chris@285
|
3955 aboutText += tr("<br>With Redland RDF datastore v%1 © Dave Beckett and the University of Bristol").arg(REDLAND_VERSION);
|
Chris@285
|
3956 #else // !REDLAND_VERSION
|
Chris@285
|
3957 aboutText += tr("<br>With Redland RDF datastore © Dave Beckett and the University of Bristol");
|
Chris@285
|
3958 #endif // REDLAND_VERSION
|
Chris@285
|
3959 #endif // HAVE_REDLAND
|
Chris@285
|
3960
|
Chris@300
|
3961 aboutText += tr("<br>With RtMidi © Gary P. Scavone");
|
Chris@300
|
3962
|
Chris@69
|
3963 #ifdef HAVE_LIBLO
|
Chris@93
|
3964 #ifdef LIBLO_VERSION
|
Chris@285
|
3965 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
3966 #else // !LIBLO_VERSION
|
Chris@93
|
3967 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
3968 #endif // LIBLO_VERSION
|
Chris@285
|
3969
|
Chris@285
|
3970 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@285
|
3971 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@285
|
3972 }
|
Chris@285
|
3973
|
Chris@285
|
3974 aboutText += "</small></p>";
|
Chris@285
|
3975 #endif // HAVE_LIBLO
|
Chris@285
|
3976
|
Chris@285
|
3977 #ifndef BUILD_STATIC
|
Chris@285
|
3978 aboutText.replace(tr("With "), tr("Using "));
|
Chris@93
|
3979 #endif
|
Chris@0
|
3980
|
Chris@0
|
3981 aboutText +=
|
Chris@300
|
3982 "<p><small>Sonic Visualiser Copyright © 2005–2009 Chris Cannam and "
|
Chris@285
|
3983 "Queen Mary, University of London.</small></p>"
|
Chris@285
|
3984 "<p><small>This program is free software; you can redistribute it and/or "
|
Chris@231
|
3985 "modify it under the terms of the GNU General Public License as "
|
Chris@231
|
3986 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
3987 "License, or (at your option) any later version.<br>See the file "
|
Chris@285
|
3988 "COPYING included with this distribution for more information.</small></p>";
|
Chris@0
|
3989
|
Chris@0
|
3990 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
|
Chris@0
|
3991 }
|
Chris@0
|
3992
|
Chris@162
|
3993 void
|
Chris@162
|
3994 MainWindow::keyReference()
|
Chris@162
|
3995 {
|
Chris@162
|
3996 m_keyReference->show();
|
Chris@162
|
3997 }
|
Chris@162
|
3998
|
Chris@294
|
3999
|