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