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