Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 Sonic Visualiser
|
Chris@0
|
5 An audio file viewer and annotation editor.
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@200
|
7 This file copyright 2006-2007 Chris Cannam and QMUL.
|
Chris@0
|
8
|
Chris@0
|
9 This program is free software; you can redistribute it and/or
|
Chris@0
|
10 modify it under the terms of the GNU General Public License as
|
Chris@0
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
12 License, or (at your option) any later version. See the file
|
Chris@0
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@144
|
16 #include "../version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@0
|
19 #include "PreferencesDialog.h"
|
Chris@0
|
20
|
Chris@1
|
21 #include "view/Pane.h"
|
Chris@1
|
22 #include "view/PaneStack.h"
|
Chris@1
|
23 #include "data/model/WaveFileModel.h"
|
Chris@1
|
24 #include "data/model/SparseOneDimensionalModel.h"
|
Chris@185
|
25 #include "data/model/NoteModel.h"
|
Chris@189
|
26 #include "data/model/Labeller.h"
|
Chris@222
|
27 #include "data/osc/OSCQueue.h"
|
Chris@216
|
28 #include "framework/Document.h"
|
Chris@1
|
29 #include "view/ViewManager.h"
|
Chris@0
|
30 #include "base/Preferences.h"
|
Chris@0
|
31 #include "layer/WaveformLayer.h"
|
Chris@0
|
32 #include "layer/TimeRulerLayer.h"
|
Chris@0
|
33 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
34 #include "layer/TimeValueLayer.h"
|
Chris@0
|
35 #include "layer/Colour3DPlotLayer.h"
|
Chris@95
|
36 #include "layer/SliceLayer.h"
|
Chris@95
|
37 #include "layer/SliceableLayer.h"
|
Chris@193
|
38 #include "layer/ImageLayer.h"
|
Chris@0
|
39 #include "widgets/Fader.h"
|
Chris@65
|
40 #include "view/Overview.h"
|
Chris@0
|
41 #include "widgets/PropertyBox.h"
|
Chris@0
|
42 #include "widgets/PropertyStack.h"
|
Chris@0
|
43 #include "widgets/AudioDial.h"
|
Chris@168
|
44 #include "widgets/IconLoader.h"
|
Chris@219
|
45 #include "widgets/LayerTreeDialog.h"
|
Chris@0
|
46 #include "widgets/ListInputDialog.h"
|
Chris@36
|
47 #include "widgets/SubdividingMenu.h"
|
Chris@90
|
48 #include "widgets/NotifyingPushButton.h"
|
Chris@162
|
49 #include "widgets/KeyReference.h"
|
Chris@192
|
50 #include "widgets/LabelCounterInputDialog.h"
|
Chris@0
|
51 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
52 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
53 #include "audioio/AudioTargetFactory.h"
|
Chris@59
|
54 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@1
|
55 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@180
|
56 #include "data/fileio/PlaylistFileReader.h"
|
Chris@1
|
57 #include "data/fileio/WavFileWriter.h"
|
Chris@1
|
58 #include "data/fileio/CSVFileWriter.h"
|
Chris@185
|
59 #include "data/fileio/MIDIFileWriter.h"
|
Chris@1
|
60 #include "data/fileio/BZipFileDevice.h"
|
Chris@198
|
61 #include "data/fileio/FileSource.h"
|
Chris@91
|
62 #include "data/fft/FFTDataServer.h"
|
Chris@1
|
63 #include "base/RecentFiles.h"
|
Chris@249
|
64 #include "transform/TransformFactory.h"
|
Chris@249
|
65 #include "transform/ModelTransformerFactory.h"
|
Chris@0
|
66 #include "base/PlayParameterRepository.h"
|
Chris@0
|
67 #include "base/XmlExportable.h"
|
Chris@248
|
68 #include "widgets/CommandHistory.h"
|
Chris@0
|
69 #include "base/Profiler.h"
|
Chris@0
|
70 #include "base/Clipboard.h"
|
Chris@165
|
71 #include "base/UnitDatabase.h"
|
Chris@248
|
72 #include "layer/ColourDatabase.h"
|
Chris@0
|
73
|
Chris@0
|
74 // For version information
|
Chris@0
|
75 #include "vamp/vamp.h"
|
Chris@0
|
76 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
77 #include "plugin/api/ladspa.h"
|
Chris@0
|
78 #include "plugin/api/dssi.h"
|
Chris@0
|
79
|
Chris@0
|
80 #include <QApplication>
|
Chris@0
|
81 #include <QMessageBox>
|
Chris@0
|
82 #include <QGridLayout>
|
Chris@0
|
83 #include <QLabel>
|
Chris@0
|
84 #include <QAction>
|
Chris@0
|
85 #include <QMenuBar>
|
Chris@0
|
86 #include <QToolBar>
|
Chris@0
|
87 #include <QInputDialog>
|
Chris@0
|
88 #include <QStatusBar>
|
Chris@0
|
89 #include <QTreeView>
|
Chris@0
|
90 #include <QFile>
|
Chris@88
|
91 #include <QFileInfo>
|
Chris@88
|
92 #include <QDir>
|
Chris@0
|
93 #include <QTextStream>
|
Chris@0
|
94 #include <QProcess>
|
Chris@7
|
95 #include <QShortcut>
|
Chris@5
|
96 #include <QSettings>
|
Chris@11
|
97 #include <QDateTime>
|
Chris@11
|
98 #include <QProcess>
|
Chris@16
|
99 #include <QCheckBox>
|
Chris@55
|
100 #include <QRegExp>
|
Chris@158
|
101 #include <QScrollArea>
|
Chris@0
|
102
|
Chris@0
|
103 #include <iostream>
|
Chris@0
|
104 #include <cstdio>
|
Chris@0
|
105 #include <errno.h>
|
Chris@0
|
106
|
Chris@0
|
107 using std::cerr;
|
Chris@0
|
108 using std::endl;
|
Chris@0
|
109
|
Chris@33
|
110 using std::vector;
|
Chris@33
|
111 using std::map;
|
Chris@33
|
112 using std::set;
|
Chris@33
|
113
|
Chris@0
|
114
|
Chris@70
|
115 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@200
|
116 MainWindowBase(withAudioOutput, withOSCSupport),
|
Chris@65
|
117 m_overview(0),
|
Chris@0
|
118 m_mainMenusCreated(false),
|
Chris@0
|
119 m_paneMenu(0),
|
Chris@0
|
120 m_layerMenu(0),
|
Chris@34
|
121 m_transformsMenu(0),
|
Chris@155
|
122 m_playbackMenu(0),
|
Chris@0
|
123 m_existingLayersMenu(0),
|
Chris@95
|
124 m_sliceMenu(0),
|
Chris@34
|
125 m_recentFilesMenu(0),
|
Chris@211
|
126 m_recentTransformsMenu(0),
|
Chris@0
|
127 m_rightButtonMenu(0),
|
Chris@0
|
128 m_rightButtonLayerMenu(0),
|
Chris@211
|
129 m_rightButtonTransformsMenu(0),
|
Chris@155
|
130 m_rightButtonPlaybackMenu(0),
|
Chris@207
|
131 m_soloAction(0),
|
Chris@207
|
132 m_soloModified(false),
|
Chris@207
|
133 m_prevSolo(false),
|
Chris@155
|
134 m_ffwdAction(0),
|
Chris@155
|
135 m_rwdAction(0),
|
Chris@239
|
136 m_playControlsSpacer(0),
|
Chris@239
|
137 m_playControlsWidth(0),
|
Chris@162
|
138 m_preferencesDialog(0),
|
Chris@219
|
139 m_layerTreeDialog(0),
|
Chris@162
|
140 m_keyReference(new KeyReference())
|
Chris@0
|
141 {
|
Chris@0
|
142 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
143
|
Chris@165
|
144 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@165
|
145 udb->registerUnit("Hz");
|
Chris@165
|
146 udb->registerUnit("dB");
|
Chris@165
|
147 udb->registerUnit("s");
|
Chris@165
|
148
|
Chris@165
|
149 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@165
|
150 cdb->addColour(Qt::black, tr("Black"));
|
Chris@165
|
151 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@165
|
152 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@165
|
153 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@165
|
154 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@165
|
155 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@166
|
156 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@166
|
157 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@166
|
158 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@166
|
159 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@166
|
160 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@166
|
161 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
162
|
Chris@0
|
163 QFrame *frame = new QFrame;
|
Chris@0
|
164 setCentralWidget(frame);
|
Chris@0
|
165
|
Chris@0
|
166 QGridLayout *layout = new QGridLayout;
|
Chris@180
|
167
|
Chris@205
|
168 m_descriptionLabel = new QLabel; //!!! hang on, this is declared in base class -- should be declared and initialised by same class
|
Chris@0
|
169
|
Chris@158
|
170 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@158
|
171 scroll->setWidgetResizable(true);
|
Chris@158
|
172 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@159
|
173 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@159
|
174
|
Chris@159
|
175 scroll->setWidget(m_paneStack);
|
Chris@159
|
176
|
Chris@65
|
177 m_overview = new Overview(frame);
|
Chris@65
|
178 m_overview->setViewManager(m_viewManager);
|
Chris@65
|
179 m_overview->setFixedHeight(40);
|
Chris@144
|
180 #ifndef _WIN32
|
Chris@144
|
181 // For some reason, the contents of the overview never appear if we
|
Chris@144
|
182 // make this setting on Windows. I have no inclination at the moment
|
Chris@144
|
183 // to track down the reason why.
|
Chris@129
|
184 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@144
|
185 #endif
|
Chris@90
|
186 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
187 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
188
|
Chris@0
|
189 m_panLayer = new WaveformLayer;
|
Chris@0
|
190 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
191 m_panLayer->setAggressiveCacheing(true);
|
Chris@65
|
192 m_overview->addLayer(m_panLayer);
|
Chris@174
|
193
|
Chris@174
|
194 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@174
|
195 m_panLayer->setBaseColour
|
Chris@174
|
196 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@174
|
197 } else {
|
Chris@174
|
198 m_panLayer->setBaseColour
|
Chris@174
|
199 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
|
Chris@200
|
200 }
|
Chris@0
|
201
|
Chris@0
|
202 m_fader = new Fader(frame, false);
|
Chris@90
|
203 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
204 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
205
|
Chris@0
|
206 m_playSpeed = new AudioDial(frame);
|
Chris@12
|
207 m_playSpeed->setMinimum(0);
|
Chris@48
|
208 m_playSpeed->setMaximum(200);
|
Chris@25
|
209 m_playSpeed->setValue(100);
|
Chris@0
|
210 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
211 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
212 m_playSpeed->setNotchesVisible(true);
|
Chris@25
|
213 m_playSpeed->setPageStep(10);
|
Chris@60
|
214 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@25
|
215 m_playSpeed->setDefaultValue(100);
|
Chris@59
|
216 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@60
|
217 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
218 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
Chris@0
|
219 this, SLOT(playSpeedChanged(int)));
|
Chris@90
|
220 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
221 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
222
|
Chris@168
|
223 IconLoader il;
|
Chris@168
|
224
|
Chris@21
|
225 QSettings settings;
|
Chris@21
|
226 settings.beginGroup("MainWindow");
|
Chris@21
|
227 settings.endGroup();
|
Chris@21
|
228
|
Chris@239
|
229 m_playControlsSpacer = new QFrame;
|
Chris@239
|
230
|
Chris@129
|
231 layout->setSpacing(4);
|
Chris@159
|
232 layout->addWidget(scroll, 0, 0, 1, 5);
|
Chris@239
|
233 layout->addWidget(m_overview, 1, 1);
|
Chris@239
|
234 layout->addWidget(m_playControlsSpacer, 1, 2);
|
Chris@239
|
235 layout->addWidget(m_playSpeed, 1, 3);
|
Chris@239
|
236 layout->addWidget(m_fader, 1, 4);
|
Chris@239
|
237
|
Chris@239
|
238 m_playControlsWidth =
|
Chris@240
|
239 m_fader->width() + m_playSpeed->width() + layout->spacing() * 2;
|
Chris@239
|
240
|
Chris@239
|
241 layout->setColumnMinimumWidth(0, 14);
|
Chris@239
|
242 layout->setColumnStretch(0, 0);
|
Chris@239
|
243
|
Chris@239
|
244 m_paneStack->setPropertyStackMinWidth(m_playControlsWidth
|
Chris@239
|
245 + 2 + layout->spacing());
|
Chris@239
|
246 m_playControlsSpacer->setFixedSize(QSize(2, 2));
|
Chris@239
|
247
|
Chris@239
|
248 layout->setColumnStretch(1, 10);
|
Chris@239
|
249
|
Chris@239
|
250 connect(m_paneStack, SIGNAL(propertyStacksResized(int)),
|
Chris@239
|
251 this, SLOT(propertyStacksResized(int)));
|
Chris@16
|
252
|
Chris@0
|
253 frame->setLayout(layout);
|
Chris@0
|
254
|
Chris@0
|
255 setupMenus();
|
Chris@0
|
256 setupToolbars();
|
Chris@155
|
257 setupHelpMenu();
|
Chris@0
|
258
|
Chris@90
|
259 statusBar();
|
Chris@0
|
260
|
Chris@0
|
261 newSession();
|
Chris@0
|
262 }
|
Chris@0
|
263
|
Chris@0
|
264 MainWindow::~MainWindow()
|
Chris@0
|
265 {
|
Chris@162
|
266 delete m_keyReference;
|
Chris@163
|
267 delete m_preferencesDialog;
|
Chris@219
|
268 delete m_layerTreeDialog;
|
Chris@0
|
269 Profiles::getInstance()->dump();
|
Chris@0
|
270 }
|
Chris@0
|
271
|
Chris@81
|
272 void
|
Chris@0
|
273 MainWindow::setupMenus()
|
Chris@0
|
274 {
|
Chris@0
|
275 if (!m_mainMenusCreated) {
|
Chris@0
|
276 m_rightButtonMenu = new QMenu();
|
Chris@104
|
277
|
Chris@104
|
278 // No -- we don't want tear-off enabled on the right-button
|
Chris@104
|
279 // menu. If it is enabled, then simply right-clicking and
|
Chris@104
|
280 // releasing will pop up the menu, activate the tear-off, and
|
Chris@104
|
281 // leave the torn-off menu window in front of the main window.
|
Chris@104
|
282 // That isn't desirable. I'm not sure it ever would be, in a
|
Chris@104
|
283 // context menu -- perhaps technically a Qt bug?
|
Chris@104
|
284 // m_rightButtonMenu->setTearOffEnabled(true);
|
Chris@0
|
285 }
|
Chris@0
|
286
|
Chris@0
|
287 if (m_rightButtonLayerMenu) {
|
Chris@0
|
288 m_rightButtonLayerMenu->clear();
|
Chris@0
|
289 } else {
|
Chris@0
|
290 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
|
Chris@97
|
291 m_rightButtonLayerMenu->setTearOffEnabled(true);
|
Chris@0
|
292 m_rightButtonMenu->addSeparator();
|
Chris@0
|
293 }
|
Chris@0
|
294
|
Chris@211
|
295 if (m_rightButtonTransformsMenu) {
|
Chris@211
|
296 m_rightButtonTransformsMenu->clear();
|
Chris@34
|
297 } else {
|
Chris@211
|
298 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform"));
|
Chris@211
|
299 m_rightButtonTransformsMenu->setTearOffEnabled(true);
|
Chris@34
|
300 m_rightButtonMenu->addSeparator();
|
Chris@34
|
301 }
|
Chris@34
|
302
|
Chris@0
|
303 if (!m_mainMenusCreated) {
|
Chris@0
|
304 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
305 m_rightButtonMenu->addSeparator();
|
Chris@66
|
306 }
|
Chris@66
|
307
|
Chris@66
|
308 setupFileMenu();
|
Chris@66
|
309 setupEditMenu();
|
Chris@66
|
310 setupViewMenu();
|
Chris@66
|
311 setupPaneAndLayerMenus();
|
Chris@211
|
312 setupTransformsMenu();
|
Chris@66
|
313
|
Chris@66
|
314 m_mainMenusCreated = true;
|
Chris@66
|
315 }
|
Chris@66
|
316
|
Chris@66
|
317 void
|
Chris@66
|
318 MainWindow::setupFileMenu()
|
Chris@66
|
319 {
|
Chris@66
|
320 if (m_mainMenusCreated) return;
|
Chris@66
|
321
|
Chris@66
|
322 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@97
|
323 menu->setTearOffEnabled(true);
|
Chris@66
|
324 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@66
|
325
|
Chris@162
|
326 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@162
|
327
|
Chris@168
|
328 IconLoader il;
|
Chris@168
|
329
|
Chris@168
|
330 QIcon icon = il.load("filenew");
|
Chris@168
|
331 icon.addPixmap(il.loadPixmap("filenew-22"));
|
Chris@66
|
332 QAction *action = new QAction(icon, tr("&New Session"), this);
|
Chris@66
|
333 action->setShortcut(tr("Ctrl+N"));
|
Chris@90
|
334 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one"));
|
Chris@66
|
335 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
|
Chris@162
|
336 m_keyReference->registerShortcut(action);
|
Chris@66
|
337 menu->addAction(action);
|
Chris@66
|
338 toolbar->addAction(action);
|
Chris@138
|
339
|
Chris@168
|
340 icon = il.load("fileopensession");
|
Chris@66
|
341 action = new QAction(icon, tr("&Open Session..."), this);
|
Chris@66
|
342 action->setShortcut(tr("Ctrl+O"));
|
Chris@66
|
343 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file"));
|
Chris@66
|
344 connect(action, SIGNAL(triggered()), this, SLOT(openSession()));
|
Chris@162
|
345 m_keyReference->registerShortcut(action);
|
Chris@66
|
346 menu->addAction(action);
|
Chris@66
|
347
|
Chris@168
|
348 icon = il.load("fileopen");
|
Chris@168
|
349 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@138
|
350
|
Chris@66
|
351 action = new QAction(icon, tr("&Open..."), this);
|
Chris@66
|
352 action->setStatusTip(tr("Open a session file, audio file, or layer"));
|
Chris@66
|
353 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
|
Chris@66
|
354 toolbar->addAction(action);
|
Chris@66
|
355
|
Chris@168
|
356 icon = il.load("filesave");
|
Chris@168
|
357 icon.addPixmap(il.loadPixmap("filesave-22"));
|
Chris@66
|
358 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@66
|
359 action->setShortcut(tr("Ctrl+S"));
|
Chris@66
|
360 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file"));
|
Chris@66
|
361 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@66
|
362 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
363 m_keyReference->registerShortcut(action);
|
Chris@66
|
364 menu->addAction(action);
|
Chris@66
|
365 toolbar->addAction(action);
|
Chris@0
|
366
|
Chris@168
|
367 icon = il.load("filesaveas");
|
Chris@168
|
368 icon.addPixmap(il.loadPixmap("filesaveas-22"));
|
Chris@66
|
369 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@66
|
370 action->setStatusTip(tr("Save the current session into a new Sonic Visualiser session file"));
|
Chris@66
|
371 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@66
|
372 menu->addAction(action);
|
Chris@66
|
373 toolbar->addAction(action);
|
Chris@66
|
374
|
Chris@66
|
375 menu->addSeparator();
|
Chris@66
|
376
|
Chris@168
|
377 icon = il.load("fileopenaudio");
|
Chris@138
|
378 action = new QAction(icon, tr("&Import Audio File..."), this);
|
Chris@66
|
379 action->setShortcut(tr("Ctrl+I"));
|
Chris@66
|
380 action->setStatusTip(tr("Import an existing audio file"));
|
Chris@66
|
381 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
|
Chris@162
|
382 m_keyReference->registerShortcut(action);
|
Chris@66
|
383 menu->addAction(action);
|
Chris@66
|
384
|
Chris@66
|
385 action = new QAction(tr("Import Secondary Audio File..."), this);
|
Chris@66
|
386 action->setShortcut(tr("Ctrl+Shift+I"));
|
Chris@66
|
387 action->setStatusTip(tr("Import an extra audio file as a separate layer"));
|
Chris@66
|
388 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
|
Chris@66
|
389 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
390 m_keyReference->registerShortcut(action);
|
Chris@66
|
391 menu->addAction(action);
|
Chris@66
|
392
|
Chris@66
|
393 action = new QAction(tr("&Export Audio File..."), this);
|
Chris@66
|
394 action->setStatusTip(tr("Export selection as an audio file"));
|
Chris@66
|
395 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
|
Chris@66
|
396 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
397 menu->addAction(action);
|
Chris@66
|
398
|
Chris@66
|
399 menu->addSeparator();
|
Chris@66
|
400
|
Chris@66
|
401 action = new QAction(tr("Import Annotation &Layer..."), this);
|
Chris@66
|
402 action->setShortcut(tr("Ctrl+L"));
|
Chris@66
|
403 action->setStatusTip(tr("Import layer data from an existing file"));
|
Chris@66
|
404 connect(action, SIGNAL(triggered()), this, SLOT(importLayer()));
|
Chris@66
|
405 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
406 m_keyReference->registerShortcut(action);
|
Chris@66
|
407 menu->addAction(action);
|
Chris@66
|
408
|
Chris@66
|
409 action = new QAction(tr("Export Annotation Layer..."), this);
|
Chris@66
|
410 action->setStatusTip(tr("Export layer data to a file"));
|
Chris@66
|
411 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer()));
|
Chris@66
|
412 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
413 menu->addAction(action);
|
Chris@66
|
414
|
Chris@66
|
415 menu->addSeparator();
|
Chris@86
|
416
|
Chris@121
|
417 action = new QAction(tr("Export Image File..."), this);
|
Chris@121
|
418 action->setStatusTip(tr("Export a single pane to an image file"));
|
Chris@121
|
419 connect(action, SIGNAL(triggered()), this, SLOT(exportImage()));
|
Chris@121
|
420 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
|
Chris@121
|
421 menu->addAction(action);
|
Chris@121
|
422
|
Chris@121
|
423 menu->addSeparator();
|
Chris@121
|
424
|
Chris@86
|
425 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@86
|
426 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@86
|
427 action->setStatusTip(tr("Open or import a file from a remote URL"));
|
Chris@86
|
428 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@162
|
429 m_keyReference->registerShortcut(action);
|
Chris@86
|
430 menu->addAction(action);
|
Chris@86
|
431
|
Chris@86
|
432 menu->addSeparator();
|
Chris@86
|
433
|
Chris@66
|
434 m_recentFilesMenu = menu->addMenu(tr("&Recent Files"));
|
Chris@97
|
435 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@66
|
436 setupRecentFilesMenu();
|
Chris@66
|
437 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@66
|
438 this, SLOT(setupRecentFilesMenu()));
|
Chris@66
|
439
|
Chris@66
|
440 menu->addSeparator();
|
Chris@66
|
441 action = new QAction(tr("&Preferences..."), this);
|
Chris@66
|
442 action->setStatusTip(tr("Adjust the application preferences"));
|
Chris@66
|
443 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
|
Chris@66
|
444 menu->addAction(action);
|
Chris@0
|
445
|
Chris@66
|
446 menu->addSeparator();
|
Chris@168
|
447 action = new QAction(il.load("exit"),
|
Chris@66
|
448 tr("&Quit"), this);
|
Chris@66
|
449 action->setShortcut(tr("Ctrl+Q"));
|
Chris@90
|
450 action->setStatusTip(tr("Exit Sonic Visualiser"));
|
Chris@66
|
451 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@162
|
452 m_keyReference->registerShortcut(action);
|
Chris@66
|
453 menu->addAction(action);
|
Chris@66
|
454 }
|
Chris@66
|
455
|
Chris@66
|
456 void
|
Chris@66
|
457 MainWindow::setupEditMenu()
|
Chris@66
|
458 {
|
Chris@66
|
459 if (m_mainMenusCreated) return;
|
Chris@66
|
460
|
Chris@66
|
461 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@97
|
462 menu->setTearOffEnabled(true);
|
Chris@66
|
463 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@66
|
464
|
Chris@162
|
465 m_keyReference->setCategory(tr("Editing"));
|
Chris@162
|
466
|
Chris@66
|
467 menu->addSeparator();
|
Chris@66
|
468
|
Chris@168
|
469 IconLoader il;
|
Chris@168
|
470
|
Chris@168
|
471 QAction *action = new QAction(il.load("editcut"),
|
Chris@66
|
472 tr("Cu&t"), this);
|
Chris@66
|
473 action->setShortcut(tr("Ctrl+X"));
|
Chris@90
|
474 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard"));
|
Chris@66
|
475 connect(action, SIGNAL(triggered()), this, SLOT(cut()));
|
Chris@66
|
476 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
477 m_keyReference->registerShortcut(action);
|
Chris@66
|
478 menu->addAction(action);
|
Chris@66
|
479 m_rightButtonMenu->addAction(action);
|
Chris@66
|
480
|
Chris@168
|
481 action = new QAction(il.load("editcopy"),
|
Chris@66
|
482 tr("&Copy"), this);
|
Chris@66
|
483 action->setShortcut(tr("Ctrl+C"));
|
Chris@90
|
484 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard"));
|
Chris@66
|
485 connect(action, SIGNAL(triggered()), this, SLOT(copy()));
|
Chris@66
|
486 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
487 m_keyReference->registerShortcut(action);
|
Chris@66
|
488 menu->addAction(action);
|
Chris@66
|
489 m_rightButtonMenu->addAction(action);
|
Chris@66
|
490
|
Chris@168
|
491 action = new QAction(il.load("editpaste"),
|
Chris@66
|
492 tr("&Paste"), this);
|
Chris@66
|
493 action->setShortcut(tr("Ctrl+V"));
|
Chris@90
|
494 action->setStatusTip(tr("Paste from the clipboard to the current layer"));
|
Chris@66
|
495 connect(action, SIGNAL(triggered()), this, SLOT(paste()));
|
Chris@66
|
496 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
497 m_keyReference->registerShortcut(action);
|
Chris@66
|
498 menu->addAction(action);
|
Chris@66
|
499 m_rightButtonMenu->addAction(action);
|
Chris@66
|
500
|
Chris@164
|
501 m_deleteSelectedAction = new QAction(tr("&Delete Selected Items"), this);
|
Chris@164
|
502 m_deleteSelectedAction->setShortcut(tr("Del"));
|
Chris@164
|
503 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
|
Chris@164
|
504 connect(m_deleteSelectedAction, SIGNAL(triggered()), this, SLOT(deleteSelected()));
|
Chris@164
|
505 connect(this, SIGNAL(canDeleteSelection(bool)), m_deleteSelectedAction, SLOT(setEnabled(bool)));
|
Chris@164
|
506 m_keyReference->registerShortcut(m_deleteSelectedAction);
|
Chris@164
|
507 menu->addAction(m_deleteSelectedAction);
|
Chris@164
|
508 m_rightButtonMenu->addAction(m_deleteSelectedAction);
|
Chris@66
|
509
|
Chris@66
|
510 menu->addSeparator();
|
Chris@66
|
511 m_rightButtonMenu->addSeparator();
|
Chris@162
|
512
|
Chris@162
|
513 m_keyReference->setCategory(tr("Selection"));
|
Chris@162
|
514
|
Chris@66
|
515 action = new QAction(tr("Select &All"), this);
|
Chris@66
|
516 action->setShortcut(tr("Ctrl+A"));
|
Chris@90
|
517 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@66
|
518 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@66
|
519 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
520 m_keyReference->registerShortcut(action);
|
Chris@66
|
521 menu->addAction(action);
|
Chris@66
|
522 m_rightButtonMenu->addAction(action);
|
Chris@0
|
523
|
Chris@66
|
524 action = new QAction(tr("Select &Visible Range"), this);
|
Chris@66
|
525 action->setShortcut(tr("Ctrl+Shift+A"));
|
Chris@90
|
526 action->setStatusTip(tr("Select the time range corresponding to the current window width"));
|
Chris@66
|
527 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible()));
|
Chris@66
|
528 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
529 m_keyReference->registerShortcut(action);
|
Chris@66
|
530 menu->addAction(action);
|
Chris@0
|
531
|
Chris@66
|
532 action = new QAction(tr("Select to &Start"), this);
|
Chris@66
|
533 action->setShortcut(tr("Shift+Left"));
|
Chris@90
|
534 action->setStatusTip(tr("Select from the start of the session to the current playback position"));
|
Chris@66
|
535 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart()));
|
Chris@66
|
536 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
537 m_keyReference->registerShortcut(action);
|
Chris@66
|
538 menu->addAction(action);
|
Chris@0
|
539
|
Chris@66
|
540 action = new QAction(tr("Select to &End"), this);
|
Chris@66
|
541 action->setShortcut(tr("Shift+Right"));
|
Chris@90
|
542 action->setStatusTip(tr("Select from the current playback position to the end of the session"));
|
Chris@66
|
543 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd()));
|
Chris@66
|
544 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
545 m_keyReference->registerShortcut(action);
|
Chris@66
|
546 menu->addAction(action);
|
Chris@66
|
547
|
Chris@66
|
548 action = new QAction(tr("C&lear Selection"), this);
|
Chris@66
|
549 action->setShortcut(tr("Esc"));
|
Chris@90
|
550 action->setStatusTip(tr("Clear the selection"));
|
Chris@66
|
551 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
Chris@66
|
552 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
553 m_keyReference->registerShortcut(action);
|
Chris@66
|
554 menu->addAction(action);
|
Chris@66
|
555 m_rightButtonMenu->addAction(action);
|
Chris@66
|
556
|
Chris@66
|
557 menu->addSeparator();
|
Chris@66
|
558
|
Chris@162
|
559 m_keyReference->setCategory(tr("Tapping Time Instants"));
|
Chris@162
|
560
|
Chris@66
|
561 action = new QAction(tr("&Insert Instant at Playback Position"), this);
|
Chris@66
|
562 action->setShortcut(tr("Enter"));
|
Chris@90
|
563 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary"));
|
Chris@66
|
564 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
|
Chris@66
|
565 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
566 m_keyReference->registerShortcut(action);
|
Chris@66
|
567 menu->addAction(action);
|
Chris@66
|
568
|
Chris@162
|
569 // Laptop shortcut (no keypad Enter key)
|
Chris@162
|
570 QString shortcut(tr(";"));
|
Chris@162
|
571 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@162
|
572 this, SLOT(insertInstant()));
|
Chris@162
|
573 m_keyReference->registerAlternativeShortcut(action, shortcut);
|
Chris@162
|
574
|
Chris@81
|
575 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
|
Chris@81
|
576 action->setShortcut(tr("Shift+Enter"));
|
Chris@163
|
577 action->setStatusTip(tr("Insert new time instants at the start and end of the current selected regions, in a new layer if necessary"));
|
Chris@81
|
578 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
|
Chris@81
|
579 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
580 m_keyReference->registerShortcut(action);
|
Chris@81
|
581 menu->addAction(action);
|
Chris@189
|
582
|
Chris@190
|
583 QMenu *numberingMenu = menu->addMenu(tr("Number New Instants with"));
|
Chris@225
|
584 numberingMenu->setTearOffEnabled(true);
|
Chris@189
|
585 QActionGroup *numberingGroup = new QActionGroup(this);
|
Chris@189
|
586
|
Chris@189
|
587 Labeller::TypeNameMap types = m_labeller->getTypeNames();
|
Chris@189
|
588 for (Labeller::TypeNameMap::iterator i = types.begin(); i != types.end(); ++i) {
|
Chris@190
|
589
|
Chris@190
|
590 if (i->first == Labeller::ValueFromLabel ||
|
Chris@190
|
591 i->first == Labeller::ValueFromExistingNeighbour) continue;
|
Chris@190
|
592
|
Chris@189
|
593 action = new QAction(i->second, this);
|
Chris@189
|
594 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsNumbering()));
|
Chris@189
|
595 action->setCheckable(true);
|
Chris@189
|
596 action->setChecked(m_labeller->getType() == i->first);
|
Chris@189
|
597 numberingGroup->addAction(action);
|
Chris@189
|
598 numberingMenu->addAction(action);
|
Chris@189
|
599 m_numberingActions[action] = (int)i->first;
|
Chris@190
|
600
|
Chris@190
|
601 if (i->first == Labeller::ValueFromTwoLevelCounter) {
|
Chris@192
|
602
|
Chris@190
|
603 QMenu *cycleMenu = numberingMenu->addMenu(tr("Cycle size"));
|
Chris@190
|
604 QActionGroup *cycleGroup = new QActionGroup(this);
|
Chris@190
|
605
|
Chris@229
|
606 int cycles[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16 };
|
Chris@200
|
607 for (int i = 0; i < int(sizeof(cycles)/sizeof(cycles[0])); ++i) {
|
Chris@190
|
608 action = new QAction(QString("%1").arg(cycles[i]), this);
|
Chris@190
|
609 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounterCycle()));
|
Chris@190
|
610 action->setCheckable(true);
|
Chris@190
|
611 action->setChecked(cycles[i] == m_labeller->getCounterCycleSize());
|
Chris@190
|
612 cycleGroup->addAction(action);
|
Chris@190
|
613 cycleMenu->addAction(action);
|
Chris@190
|
614 }
|
Chris@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@241
|
624 action = new QAction(tr("Set Numbering Counters..."), this);
|
Chris@241
|
625 action->setStatusTip(tr("Set the counters used for counter-based labelling"));
|
Chris@241
|
626 connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
|
Chris@241
|
627 menu->addAction(action);
|
Chris@241
|
628
|
Chris@241
|
629 action = new QAction(tr("Renumber Selected Instants"), this);
|
Chris@241
|
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@219
|
803 action = new QAction(tr("Show La&yer Summary"), this);
|
Chris@219
|
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@232
|
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@232
|
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@224
|
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@231
|
903 const int paneMenuType = 0, layerMenuType = 1;
|
Chris@231
|
904
|
Chris@231
|
905 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) {
|
Chris@231
|
906
|
Chris@231
|
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@231
|
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@231
|
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@231
|
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@231
|
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@231
|
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@231
|
979 // if (menuType == paneMenuType) {
|
Chris@66
|
980 candidateModels = models;
|
Chris@231
|
981 // } else {
|
Chris@231
|
982 // candidateModels.push_back(0);
|
Chris@231
|
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@231
|
1008 // if (menuType == layerMenuType) {
|
Chris@231
|
1009 // if (isDefault) isOnly = true;
|
Chris@231
|
1010 // else continue;
|
Chris@231
|
1011 // }
|
Chris@231
|
1012
|
Chris@231
|
1013 if (isOnly && (!plural /*|| menuType == layerMenuType*/)) {
|
Chris@231
|
1014
|
Chris@231
|
1015 // if (menuType == layerMenuType && type != LayerFactory::Waveform) {
|
Chris@231
|
1016 // action = new QAction(mainText, this);
|
Chris@231
|
1017 // } else {
|
Chris@67
|
1018 action = new QAction(icon, mainText, this);
|
Chris@231
|
1019 // }
|
Chris@67
|
1020
|
Chris@66
|
1021 action->setShortcut(shortcutText);
|
Chris@66
|
1022 action->setStatusTip(tipText);
|
Chris@231
|
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@232
|
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@232
|
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@231
|
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@232
|
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@232
|
1090 m_layerActions[action] =
|
Chris@232
|
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@225
|
1102 menu->addSeparator();
|
Chris@225
|
1103
|
Chris@225
|
1104 action = new QAction(tr("Switch to Previous Pane"), this);
|
Chris@225
|
1105 action->setShortcut(tr("["));
|
Chris@225
|
1106 action->setStatusTip(tr("Make the next pane up in the pane stack current"));
|
Chris@225
|
1107 connect(action, SIGNAL(triggered()), this, SLOT(previousPane()));
|
Chris@225
|
1108 connect(this, SIGNAL(canSelectPreviousPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1109 m_keyReference->registerShortcut(action);
|
Chris@225
|
1110 menu->addAction(action);
|
Chris@225
|
1111
|
Chris@225
|
1112 action = new QAction(tr("Switch to Next Pane"), this);
|
Chris@225
|
1113 action->setShortcut(tr("]"));
|
Chris@225
|
1114 action->setStatusTip(tr("Make the next pane down in the pane stack current"));
|
Chris@225
|
1115 connect(action, SIGNAL(triggered()), this, SLOT(nextPane()));
|
Chris@225
|
1116 connect(this, SIGNAL(canSelectNextPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1117 m_keyReference->registerShortcut(action);
|
Chris@225
|
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@232
|
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@225
|
1151 /*!!! These don't work correctly -- fix or omit
|
Chris@225
|
1152 menu->addSeparator();
|
Chris@225
|
1153
|
Chris@225
|
1154 action = new QAction(tr("Switch to Previous Layer"), this);
|
Chris@225
|
1155 action->setShortcut(tr("{"));
|
Chris@225
|
1156 action->setStatusTip(tr("Make the previous layer in the pane current"));
|
Chris@225
|
1157 connect(action, SIGNAL(triggered()), this, SLOT(previousLayer()));
|
Chris@225
|
1158 connect(this, SIGNAL(canSelectPreviousLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1159 m_keyReference->registerShortcut(action);
|
Chris@225
|
1160 menu->addAction(action);
|
Chris@225
|
1161
|
Chris@225
|
1162 action = new QAction(tr("Switch to Next Layer"), this);
|
Chris@225
|
1163 action->setShortcut(tr("}"));
|
Chris@225
|
1164 action->setStatusTip(tr("Make the next layer in the pane current"));
|
Chris@225
|
1165 connect(action, SIGNAL(triggered()), this, SLOT(nextLayer()));
|
Chris@225
|
1166 connect(this, SIGNAL(canSelectNextLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1167 m_keyReference->registerShortcut(action);
|
Chris@225
|
1168 menu->addAction(action);
|
Chris@225
|
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@224
|
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@230
|
1312 // Names should only be duplicated here if they have the same
|
Chris@230
|
1313 // plugin name, output name and maker but are in different library
|
Chris@230
|
1314 // .so names -- that won't happen often I hope
|
Chris@230
|
1315 std::map<QString, QString> idNameSonameMap;
|
Chris@230
|
1316 std::set<QString> seenNames, duplicateNames;
|
Chris@230
|
1317 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@230
|
1318 QString name = transforms[i].name;
|
Chris@230
|
1319 if (seenNames.find(name) != seenNames.end()) {
|
Chris@230
|
1320 duplicateNames.insert(name);
|
Chris@230
|
1321 } else {
|
Chris@230
|
1322 seenNames.insert(name);
|
Chris@230
|
1323 }
|
Chris@230
|
1324 }
|
Chris@230
|
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@230
|
1345 if (duplicateNames.find(pluginName) != duplicateNames.end()) {
|
Chris@230
|
1346 pluginName = QString("%1 <%2>")
|
Chris@230
|
1347 .arg(pluginName)
|
Chris@230
|
1348 .arg(transforms[i].identifier.section(':', 1, 1));
|
Chris@230
|
1349 if (output == "") name = pluginName;
|
Chris@230
|
1350 else name = QString("%1: %2")
|
Chris@230
|
1351 .arg(pluginName)
|
Chris@230
|
1352 .arg(output);
|
Chris@230
|
1353 }
|
Chris@230
|
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@216
|
1495 } else {
|
Chris@216
|
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@217
|
1795 action = toolbar->addAction(il.load("erase"),
|
Chris@217
|
1796 tr("Erase"));
|
Chris@217
|
1797 action->setCheckable(true);
|
Chris@217
|
1798 action->setShortcut(tr("5"));
|
Chris@217
|
1799 action->setStatusTip(tr("Erase items from layer"));
|
Chris@217
|
1800 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected()));
|
Chris@217
|
1801 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@217
|
1802 group->addAction(action);
|
Chris@217
|
1803 m_keyReference->registerShortcut(action);
|
Chris@217
|
1804 m_toolActions[ViewManager::EraseMode] = action;
|
Chris@217
|
1805
|
Chris@168
|
1806 action = toolbar->addAction(il.load("measure"),
|
Chris@151
|
1807 tr("Measure"));
|
Chris@151
|
1808 action->setCheckable(true);
|
Chris@217
|
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@217
|
1959 MainWindow::toolEraseSelected()
|
Chris@217
|
1960 {
|
Chris@217
|
1961 m_viewManager->setToolMode(ViewManager::EraseMode);
|
Chris@217
|
1962 }
|
Chris@217
|
1963
|
Chris@217
|
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@247
|
1977 emit hideSplash();
|
Chris@0
|
1978 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
1979 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1980 }
|
Chris@0
|
1981 }
|
Chris@0
|
1982 }
|
Chris@0
|
1983
|
Chris@0
|
1984 void
|
Chris@0
|
1985 MainWindow::importMoreAudio()
|
Chris@0
|
1986 {
|
Chris@88
|
1987 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
1988
|
Chris@0
|
1989 if (path != "") {
|
Chris@197
|
1990 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) {
|
Chris@247
|
1991 emit hideSplash();
|
Chris@0
|
1992 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
1993 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
1994 }
|
Chris@0
|
1995 }
|
Chris@0
|
1996 }
|
Chris@0
|
1997
|
Chris@0
|
1998 void
|
Chris@0
|
1999 MainWindow::exportAudio()
|
Chris@0
|
2000 {
|
Chris@0
|
2001 if (!getMainModel()) return;
|
Chris@0
|
2002
|
Chris@88
|
2003 QString path = getSaveFileName(FileFinder::AudioFile);
|
Chris@0
|
2004
|
Chris@0
|
2005 if (path == "") return;
|
Chris@0
|
2006
|
Chris@0
|
2007 bool ok = false;
|
Chris@0
|
2008 QString error;
|
Chris@0
|
2009
|
Chris@0
|
2010 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
2011 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
2012
|
Chris@0
|
2013 bool multiple = false;
|
Chris@0
|
2014
|
Chris@38
|
2015 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
2016
|
Chris@38
|
2017 if (selections.size() == 1) {
|
Chris@0
|
2018
|
Chris@0
|
2019 QStringList items;
|
Chris@0
|
2020 items << tr("Export the selected region only")
|
Chris@0
|
2021 << tr("Export the whole audio file");
|
Chris@0
|
2022
|
Chris@0
|
2023 bool ok = false;
|
Chris@0
|
2024 QString item = ListInputDialog::getItem
|
Chris@0
|
2025 (this, tr("Select region to export"),
|
Chris@0
|
2026 tr("Which region from the original audio file do you want to export?"),
|
Chris@0
|
2027 items, 0, &ok);
|
Chris@0
|
2028
|
Chris@0
|
2029 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2030
|
Chris@38
|
2031 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2032
|
Chris@38
|
2033 } else if (selections.size() > 1) {
|
Chris@0
|
2034
|
Chris@0
|
2035 QStringList items;
|
Chris@0
|
2036 items << tr("Export the selected regions into a single audio file")
|
Chris@0
|
2037 << tr("Export the selected regions into separate files")
|
Chris@0
|
2038 << tr("Export the whole audio file");
|
Chris@0
|
2039
|
Chris@0
|
2040 QString item = ListInputDialog::getItem
|
Chris@0
|
2041 (this, tr("Select region to export"),
|
Chris@0
|
2042 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@0
|
2043 items, 0, &ok);
|
Chris@0
|
2044
|
Chris@0
|
2045 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2046
|
Chris@0
|
2047 if (item == items[0]) {
|
Chris@0
|
2048
|
Chris@38
|
2049 selectionToWrite = &ms;
|
Chris@38
|
2050
|
Chris@38
|
2051 } else if (item == items[1]) {
|
Chris@0
|
2052
|
Chris@0
|
2053 multiple = true;
|
Chris@0
|
2054
|
Chris@0
|
2055 int n = 1;
|
Chris@0
|
2056 QString base = path;
|
Chris@0
|
2057 base.replace(".wav", "");
|
Chris@0
|
2058
|
Chris@0
|
2059 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
2060 i != selections.end(); ++i) {
|
Chris@0
|
2061
|
Chris@0
|
2062 MultiSelection subms;
|
Chris@0
|
2063 subms.setSelection(*i);
|
Chris@0
|
2064
|
Chris@0
|
2065 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@0
|
2066 ++n;
|
Chris@0
|
2067
|
Chris@0
|
2068 if (QFileInfo(subpath).exists()) {
|
Chris@0
|
2069 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@0
|
2070 break;
|
Chris@0
|
2071 }
|
Chris@0
|
2072
|
Chris@38
|
2073 WavFileWriter subwriter(subpath,
|
Chris@38
|
2074 getMainModel()->getSampleRate(),
|
Chris@38
|
2075 getMainModel()->getChannelCount());
|
Chris@38
|
2076 subwriter.writeModel(getMainModel(), &subms);
|
Chris@0
|
2077 ok = subwriter.isOK();
|
Chris@0
|
2078
|
Chris@0
|
2079 if (!ok) {
|
Chris@0
|
2080 error = subwriter.getError();
|
Chris@0
|
2081 break;
|
Chris@0
|
2082 }
|
Chris@0
|
2083 }
|
Chris@0
|
2084 }
|
Chris@0
|
2085 }
|
Chris@0
|
2086
|
Chris@38
|
2087 if (!multiple) {
|
Chris@38
|
2088 WavFileWriter writer(path,
|
Chris@38
|
2089 getMainModel()->getSampleRate(),
|
Chris@38
|
2090 getMainModel()->getChannelCount());
|
Chris@38
|
2091 writer.writeModel(getMainModel(), selectionToWrite);
|
Chris@38
|
2092 ok = writer.isOK();
|
Chris@38
|
2093 error = writer.getError();
|
Chris@0
|
2094 }
|
Chris@0
|
2095
|
Chris@0
|
2096 if (ok) {
|
Chris@0
|
2097 if (!multiple) {
|
Chris@34
|
2098 m_recentFiles.addFile(path);
|
Chris@0
|
2099 }
|
Chris@0
|
2100 } else {
|
Chris@0
|
2101 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2102 }
|
Chris@0
|
2103 }
|
Chris@0
|
2104
|
Chris@0
|
2105 void
|
Chris@0
|
2106 MainWindow::importLayer()
|
Chris@0
|
2107 {
|
Chris@0
|
2108 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2109
|
Chris@0
|
2110 if (!pane) {
|
Chris@0
|
2111 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2112 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
|
Chris@0
|
2113 return;
|
Chris@0
|
2114 }
|
Chris@0
|
2115
|
Chris@0
|
2116 if (!getMainModel()) {
|
Chris@0
|
2117 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2118 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
|
Chris@0
|
2119 return;
|
Chris@0
|
2120 }
|
Chris@0
|
2121
|
Chris@88
|
2122 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2123
|
Chris@0
|
2124 if (path != "") {
|
Chris@0
|
2125
|
Chris@197
|
2126 FileOpenStatus status = openLayer(path);
|
Chris@193
|
2127
|
Chris@193
|
2128 if (status == FileOpenFailed) {
|
Chris@247
|
2129 emit hideSplash();
|
Chris@0
|
2130 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2131 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@0
|
2132 return;
|
Chris@193
|
2133 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2134 emit hideSplash();
|
Chris@193
|
2135 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2136 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
2137 }
|
Chris@0
|
2138 }
|
Chris@0
|
2139 }
|
Chris@0
|
2140
|
Chris@0
|
2141 void
|
Chris@0
|
2142 MainWindow::exportLayer()
|
Chris@0
|
2143 {
|
Chris@0
|
2144 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2145 if (!pane) return;
|
Chris@0
|
2146
|
Chris@0
|
2147 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2148 if (!layer) return;
|
Chris@0
|
2149
|
Chris@0
|
2150 Model *model = layer->getModel();
|
Chris@0
|
2151 if (!model) return;
|
Chris@0
|
2152
|
Chris@185
|
2153 FileFinder::FileType type = FileFinder::LayerFileNoMidi;
|
Chris@185
|
2154
|
Chris@185
|
2155 if (dynamic_cast<NoteModel *>(model)) type = FileFinder::LayerFile;
|
Chris@185
|
2156
|
Chris@185
|
2157 QString path = getSaveFileName(type);
|
Chris@0
|
2158
|
Chris@0
|
2159 if (path == "") return;
|
Chris@0
|
2160
|
Chris@0
|
2161 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
2162
|
Chris@185
|
2163 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@185
|
2164
|
Chris@0
|
2165 QString error;
|
Chris@0
|
2166
|
Chris@185
|
2167 if (suffix == "xml" || suffix == "svl") {
|
Chris@0
|
2168
|
Chris@0
|
2169 QFile file(path);
|
Chris@0
|
2170 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
2171 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
2172 } else {
|
Chris@0
|
2173 QTextStream out(&file);
|
Chris@0
|
2174 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
2175 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
2176 << "<sv>\n"
|
Chris@0
|
2177 << " <data>\n";
|
Chris@0
|
2178
|
Chris@0
|
2179 model->toXml(out, " ");
|
Chris@0
|
2180
|
Chris@0
|
2181 out << " </data>\n"
|
Chris@0
|
2182 << " <display>\n";
|
Chris@0
|
2183
|
Chris@0
|
2184 layer->toXml(out, " ");
|
Chris@0
|
2185
|
Chris@0
|
2186 out << " </display>\n"
|
Chris@0
|
2187 << "</sv>\n";
|
Chris@0
|
2188 }
|
Chris@0
|
2189
|
Chris@185
|
2190 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@185
|
2191
|
Chris@185
|
2192 NoteModel *nm = dynamic_cast<NoteModel *>(model);
|
Chris@185
|
2193
|
Chris@185
|
2194 if (!nm) {
|
Chris@185
|
2195 error = tr("Can't export non-note layers to MIDI");
|
Chris@185
|
2196 } else {
|
Chris@185
|
2197 MIDIFileWriter writer(path, nm);
|
Chris@185
|
2198 writer.write();
|
Chris@185
|
2199 if (!writer.isOK()) {
|
Chris@185
|
2200 error = writer.getError();
|
Chris@185
|
2201 }
|
Chris@185
|
2202 }
|
Chris@185
|
2203
|
Chris@0
|
2204 } else {
|
Chris@0
|
2205
|
Chris@0
|
2206 CSVFileWriter writer(path, model,
|
Chris@185
|
2207 ((suffix == "csv") ? "," : "\t"));
|
Chris@0
|
2208 writer.write();
|
Chris@0
|
2209
|
Chris@0
|
2210 if (!writer.isOK()) {
|
Chris@0
|
2211 error = writer.getError();
|
Chris@0
|
2212 }
|
Chris@0
|
2213 }
|
Chris@0
|
2214
|
Chris@0
|
2215 if (error != "") {
|
Chris@0
|
2216 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2217 } else {
|
Chris@34
|
2218 m_recentFiles.addFile(path);
|
Chris@0
|
2219 }
|
Chris@0
|
2220 }
|
Chris@0
|
2221
|
Chris@121
|
2222 void
|
Chris@121
|
2223 MainWindow::exportImage()
|
Chris@121
|
2224 {
|
Chris@121
|
2225 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@121
|
2226 if (!pane) return;
|
Chris@121
|
2227
|
Chris@121
|
2228 QString path = getSaveFileName(FileFinder::ImageFile);
|
Chris@121
|
2229
|
Chris@121
|
2230 if (path == "") return;
|
Chris@121
|
2231
|
Chris@121
|
2232 if (QFileInfo(path).suffix() == "") path += ".png";
|
Chris@121
|
2233
|
Chris@123
|
2234 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@123
|
2235
|
Chris@123
|
2236 QSize total, visible, selected;
|
Chris@123
|
2237 total = pane->getImageSize();
|
Chris@123
|
2238 visible = pane->getImageSize(pane->getFirstVisibleFrame(),
|
Chris@123
|
2239 pane->getLastVisibleFrame());
|
Chris@123
|
2240
|
Chris@123
|
2241 size_t sf0 = 0, sf1 = 0;
|
Chris@123
|
2242
|
Chris@123
|
2243 if (haveSelection) {
|
Chris@123
|
2244 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@123
|
2245 sf0 = selections.begin()->getStartFrame();
|
Chris@123
|
2246 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@123
|
2247 --e;
|
Chris@123
|
2248 sf1 = e->getEndFrame();
|
Chris@123
|
2249 selected = pane->getImageSize(sf0, sf1);
|
Chris@123
|
2250 }
|
Chris@123
|
2251
|
Chris@123
|
2252 QStringList items;
|
Chris@125
|
2253 items << tr("Export the whole pane (%1x%2 pixels)")
|
Chris@123
|
2254 .arg(total.width()).arg(total.height());
|
Chris@123
|
2255 items << tr("Export the visible area only (%1x%2 pixels)")
|
Chris@123
|
2256 .arg(visible.width()).arg(visible.height());
|
Chris@123
|
2257 if (haveSelection) {
|
Chris@123
|
2258 items << tr("Export the selection extent (%1x%2 pixels)")
|
Chris@123
|
2259 .arg(selected.width()).arg(selected.height());
|
Chris@124
|
2260 } else {
|
Chris@124
|
2261 items << tr("Export the selection extent");
|
Chris@123
|
2262 }
|
Chris@123
|
2263
|
Chris@123
|
2264 QSettings settings;
|
Chris@123
|
2265 settings.beginGroup("MainWindow");
|
Chris@123
|
2266 int deflt = settings.value("lastimageexportregion", 0).toInt();
|
Chris@123
|
2267 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@124
|
2268 if (deflt == 0 && total.width() > 32767) deflt = 1;
|
Chris@124
|
2269
|
Chris@124
|
2270 ListInputDialog *lid = new ListInputDialog
|
Chris@123
|
2271 (this, tr("Select region to export"),
|
Chris@123
|
2272 tr("Which region of the current pane do you want to export as an image?"),
|
Chris@124
|
2273 items, deflt);
|
Chris@124
|
2274
|
Chris@124
|
2275 if (!haveSelection) {
|
Chris@124
|
2276 lid->setItemAvailability(2, false);
|
Chris@124
|
2277 }
|
Chris@124
|
2278 if (total.width() > 32767) { // appears to be the limit of a QImage
|
Chris@124
|
2279 lid->setItemAvailability(0, false);
|
Chris@124
|
2280 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
|
Chris@124
|
2281 }
|
Chris@124
|
2282
|
Chris@124
|
2283 bool ok = lid->exec();
|
Chris@124
|
2284 QString item = lid->getCurrentString();
|
Chris@124
|
2285 delete lid;
|
Chris@123
|
2286
|
Chris@123
|
2287 if (!ok || item.isEmpty()) return;
|
Chris@123
|
2288
|
Chris@123
|
2289 settings.setValue("lastimageexportregion", deflt);
|
Chris@123
|
2290
|
Chris@123
|
2291 QImage *image = 0;
|
Chris@123
|
2292
|
Chris@123
|
2293 if (item == items[0]) {
|
Chris@123
|
2294 image = pane->toNewImage();
|
Chris@123
|
2295 } else if (item == items[1]) {
|
Chris@123
|
2296 image = pane->toNewImage(pane->getFirstVisibleFrame(),
|
Chris@123
|
2297 pane->getLastVisibleFrame());
|
Chris@123
|
2298 } else if (haveSelection) {
|
Chris@123
|
2299 image = pane->toNewImage(sf0, sf1);
|
Chris@123
|
2300 }
|
Chris@123
|
2301
|
Chris@121
|
2302 if (!image) return;
|
Chris@121
|
2303
|
Chris@121
|
2304 if (!image->save(path, "PNG")) {
|
Chris@121
|
2305 QMessageBox::critical(this, tr("Failed to save image file"),
|
Chris@121
|
2306 tr("Failed to save image file %1").arg(path));
|
Chris@121
|
2307 }
|
Chris@121
|
2308
|
Chris@121
|
2309 delete image;
|
Chris@121
|
2310 }
|
Chris@121
|
2311
|
Chris@0
|
2312 void
|
Chris@0
|
2313 MainWindow::newSession()
|
Chris@0
|
2314 {
|
Chris@0
|
2315 if (!checkSaveModified()) return;
|
Chris@0
|
2316
|
Chris@0
|
2317 closeSession();
|
Chris@0
|
2318 createDocument();
|
Chris@0
|
2319
|
Chris@0
|
2320 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
2321
|
Chris@90
|
2322 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
2323 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@90
|
2324
|
Chris@0
|
2325 if (!m_timeRulerLayer) {
|
Chris@0
|
2326 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2327 (LayerFactory::TimeRuler);
|
Chris@0
|
2328 }
|
Chris@0
|
2329
|
Chris@0
|
2330 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2331
|
Chris@0
|
2332 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
2333 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
2334
|
Chris@65
|
2335 m_overview->registerView(pane);
|
Chris@0
|
2336
|
Chris@0
|
2337 CommandHistory::getInstance()->clear();
|
Chris@0
|
2338 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2339 documentRestored();
|
Chris@0
|
2340 updateMenuStates();
|
Chris@0
|
2341 }
|
Chris@0
|
2342
|
Chris@0
|
2343 void
|
Chris@0
|
2344 MainWindow::closeSession()
|
Chris@0
|
2345 {
|
Chris@0
|
2346 if (!checkSaveModified()) return;
|
Chris@0
|
2347
|
Chris@0
|
2348 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
2349
|
Chris@0
|
2350 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
2351
|
Chris@0
|
2352 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2353 m_document->removeLayerFromView
|
Chris@0
|
2354 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2355 }
|
Chris@0
|
2356
|
Chris@65
|
2357 m_overview->unregisterView(pane);
|
Chris@0
|
2358 m_paneStack->deletePane(pane);
|
Chris@0
|
2359 }
|
Chris@0
|
2360
|
Chris@0
|
2361 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
2362
|
Chris@0
|
2363 Pane *pane = m_paneStack->getHiddenPane
|
Chris@0
|
2364 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
2365
|
Chris@0
|
2366 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2367 m_document->removeLayerFromView
|
Chris@0
|
2368 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2369 }
|
Chris@0
|
2370
|
Chris@65
|
2371 m_overview->unregisterView(pane);
|
Chris@0
|
2372 m_paneStack->deletePane(pane);
|
Chris@0
|
2373 }
|
Chris@0
|
2374
|
Chris@0
|
2375 delete m_document;
|
Chris@0
|
2376 m_document = 0;
|
Chris@0
|
2377 m_viewManager->clearSelections();
|
Chris@0
|
2378 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
2379
|
Chris@0
|
2380 m_sessionFile = "";
|
Chris@0
|
2381 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2382
|
Chris@0
|
2383 CommandHistory::getInstance()->clear();
|
Chris@0
|
2384 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2385 documentRestored();
|
Chris@0
|
2386 }
|
Chris@0
|
2387
|
Chris@0
|
2388 void
|
Chris@0
|
2389 MainWindow::openSession()
|
Chris@0
|
2390 {
|
Chris@0
|
2391 if (!checkSaveModified()) return;
|
Chris@0
|
2392
|
Chris@0
|
2393 QString orig = m_audioFile;
|
Chris@0
|
2394 if (orig == "") orig = ".";
|
Chris@0
|
2395 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2396
|
Chris@88
|
2397 QString path = getOpenFileName(FileFinder::SessionFile);
|
Chris@0
|
2398
|
Chris@0
|
2399 if (path.isEmpty()) return;
|
Chris@0
|
2400
|
Chris@200
|
2401 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@247
|
2402 emit hideSplash();
|
Chris@0
|
2403 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2404 tr("<b>File open failed</b><p>Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2405 }
|
Chris@0
|
2406 }
|
Chris@0
|
2407
|
Chris@0
|
2408 void
|
Chris@0
|
2409 MainWindow::openSomething()
|
Chris@0
|
2410 {
|
Chris@0
|
2411 QString orig = m_audioFile;
|
Chris@0
|
2412 if (orig == "") orig = ".";
|
Chris@0
|
2413 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2414
|
Chris@88
|
2415 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
2416
|
Chris@0
|
2417 if (path.isEmpty()) return;
|
Chris@0
|
2418
|
Chris@197
|
2419 FileOpenStatus status = open(path, AskUser);
|
Chris@193
|
2420
|
Chris@193
|
2421 if (status == FileOpenFailed) {
|
Chris@247
|
2422 emit hideSplash();
|
Chris@193
|
2423 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2424 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@193
|
2425 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2426 emit hideSplash();
|
Chris@193
|
2427 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2428 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
2429 }
|
Chris@0
|
2430 }
|
Chris@0
|
2431
|
Chris@0
|
2432 void
|
Chris@86
|
2433 MainWindow::openLocation()
|
Chris@86
|
2434 {
|
Chris@103
|
2435 QSettings settings;
|
Chris@103
|
2436 settings.beginGroup("MainWindow");
|
Chris@103
|
2437 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
2438
|
Chris@86
|
2439 bool ok = false;
|
Chris@86
|
2440 QString text = QInputDialog::getText
|
Chris@86
|
2441 (this, tr("Open Location"),
|
Chris@86
|
2442 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
2443 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
2444
|
Chris@103
|
2445 if (!ok) return;
|
Chris@103
|
2446
|
Chris@103
|
2447 settings.setValue("lastremote", text);
|
Chris@103
|
2448
|
Chris@103
|
2449 if (text.isEmpty()) return;
|
Chris@86
|
2450
|
Chris@197
|
2451 FileOpenStatus status = open(text);
|
Chris@193
|
2452
|
Chris@193
|
2453 if (status == FileOpenFailed) {
|
Chris@247
|
2454 emit hideSplash();
|
Chris@86
|
2455 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2456 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@193
|
2457 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2458 emit hideSplash();
|
Chris@193
|
2459 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2460 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@86
|
2461 }
|
Chris@86
|
2462 }
|
Chris@86
|
2463
|
Chris@86
|
2464 void
|
Chris@0
|
2465 MainWindow::openRecentFile()
|
Chris@0
|
2466 {
|
Chris@0
|
2467 QObject *obj = sender();
|
Chris@0
|
2468 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
2469
|
Chris@0
|
2470 if (!action) {
|
Chris@0
|
2471 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@0
|
2472 << std::endl;
|
Chris@0
|
2473 return;
|
Chris@0
|
2474 }
|
Chris@0
|
2475
|
Chris@0
|
2476 QString path = action->text();
|
Chris@0
|
2477 if (path == "") return;
|
Chris@0
|
2478
|
Chris@197
|
2479 FileOpenStatus status = open(path);
|
Chris@193
|
2480
|
Chris@193
|
2481 if (status == FileOpenFailed) {
|
Chris@247
|
2482 emit hideSplash();
|
Chris@193
|
2483 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2484 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@193
|
2485 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2486 emit hideSplash();
|
Chris@193
|
2487 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2488 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
2489 }
|
Chris@0
|
2490 }
|
Chris@0
|
2491
|
Chris@0
|
2492 void
|
Chris@200
|
2493 MainWindow::paneAdded(Pane *pane)
|
Chris@200
|
2494 {
|
Chris@200
|
2495 if (m_overview) m_overview->registerView(pane);
|
Chris@200
|
2496 }
|
Chris@200
|
2497
|
Chris@200
|
2498 void
|
Chris@200
|
2499 MainWindow::paneHidden(Pane *pane)
|
Chris@200
|
2500 {
|
Chris@200
|
2501 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2502 }
|
Chris@200
|
2503
|
Chris@200
|
2504 void
|
Chris@200
|
2505 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@200
|
2506 {
|
Chris@200
|
2507 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2508 }
|
Chris@200
|
2509
|
Chris@200
|
2510 void
|
Chris@193
|
2511 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@193
|
2512 {
|
Chris@193
|
2513 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2514
|
Chris@193
|
2515 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@193
|
2516
|
Chris@197
|
2517 FileOpenStatus status = open(*i, ReplaceCurrentPane);
|
Chris@193
|
2518
|
Chris@193
|
2519 if (status == FileOpenFailed) {
|
Chris@247
|
2520 emit hideSplash();
|
Chris@193
|
2521 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
2522 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@193
|
2523 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2524 emit hideSplash();
|
Chris@193
|
2525 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
2526 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@193
|
2527 }
|
Chris@193
|
2528 }
|
Chris@193
|
2529 }
|
Chris@193
|
2530
|
Chris@193
|
2531 void
|
Chris@193
|
2532 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@193
|
2533 {
|
Chris@193
|
2534 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2535
|
Chris@193
|
2536 QUrl testUrl(text);
|
Chris@193
|
2537 if (testUrl.scheme() == "file" ||
|
Chris@193
|
2538 testUrl.scheme() == "http" ||
|
Chris@193
|
2539 testUrl.scheme() == "ftp") {
|
Chris@193
|
2540 QStringList list;
|
Chris@193
|
2541 list.push_back(text);
|
Chris@193
|
2542 paneDropAccepted(pane, list);
|
Chris@193
|
2543 return;
|
Chris@193
|
2544 }
|
Chris@193
|
2545
|
Chris@193
|
2546 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@193
|
2547 //to a text layer?
|
Chris@193
|
2548 }
|
Chris@193
|
2549
|
Chris@193
|
2550 void
|
Chris@0
|
2551 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
2552 {
|
Chris@137
|
2553 // std::cerr << "MainWindow::closeEvent" << std::endl;
|
Chris@118
|
2554
|
Chris@136
|
2555 if (m_openingAudioFile) {
|
Chris@137
|
2556 // std::cerr << "Busy - ignoring close event" << std::endl;
|
Chris@136
|
2557 e->ignore();
|
Chris@136
|
2558 return;
|
Chris@136
|
2559 }
|
Chris@136
|
2560
|
Chris@70
|
2561 if (!m_abandoning && !checkSaveModified()) {
|
Chris@137
|
2562 // std::cerr << "Ignoring close event" << std::endl;
|
Chris@0
|
2563 e->ignore();
|
Chris@0
|
2564 return;
|
Chris@0
|
2565 }
|
Chris@0
|
2566
|
Chris@5
|
2567 QSettings settings;
|
Chris@5
|
2568 settings.beginGroup("MainWindow");
|
Chris@5
|
2569 settings.setValue("size", size());
|
Chris@5
|
2570 settings.setValue("position", pos());
|
Chris@5
|
2571 settings.endGroup();
|
Chris@5
|
2572
|
Chris@163
|
2573 delete m_keyReference;
|
Chris@163
|
2574 m_keyReference = 0;
|
Chris@163
|
2575
|
Chris@163
|
2576 if (m_preferencesDialog &&
|
Chris@163
|
2577 m_preferencesDialog->isVisible()) {
|
Chris@164
|
2578 closeSession(); // otherwise we'll have to wait for prefs changes
|
Chris@163
|
2579 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2580 }
|
Chris@163
|
2581
|
Chris@200
|
2582 closeSession();
|
Chris@200
|
2583
|
Chris@0
|
2584 e->accept();
|
Chris@0
|
2585 return;
|
Chris@0
|
2586 }
|
Chris@0
|
2587
|
Chris@0
|
2588 bool
|
Chris@11
|
2589 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
2590 {
|
Chris@11
|
2591 if (mayAskUser) {
|
Chris@163
|
2592 bool rv = checkSaveModified();
|
Chris@163
|
2593 if (rv) {
|
Chris@163
|
2594 if (m_preferencesDialog &&
|
Chris@163
|
2595 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2596 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2597 }
|
Chris@163
|
2598 }
|
Chris@163
|
2599 return rv;
|
Chris@11
|
2600 } else {
|
Chris@163
|
2601 if (m_preferencesDialog &&
|
Chris@163
|
2602 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2603 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
2604 }
|
Chris@11
|
2605 if (!m_documentModified) return true;
|
Chris@11
|
2606
|
Chris@11
|
2607 // If we can't check with the user first, then we can't save
|
Chris@11
|
2608 // to the original session file (even if we have it) -- have
|
Chris@11
|
2609 // to use a temporary file
|
Chris@11
|
2610
|
Chris@11
|
2611 QString svDirBase = ".sv1";
|
Chris@11
|
2612 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
2613
|
Chris@11
|
2614 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
2615 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
2616 } else {
|
Chris@11
|
2617 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
2618 }
|
Chris@11
|
2619
|
Chris@11
|
2620 // This name doesn't have to be unguessable
|
Chris@93
|
2621 #ifndef _WIN32
|
Chris@11
|
2622 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
2623 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
2624 .arg(QProcess().pid());
|
Chris@93
|
2625 #else
|
Chris@93
|
2626 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
2627 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
2628 #endif
|
Chris@11
|
2629 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
2630 if (saveSessionFile(fpath)) {
|
Chris@34
|
2631 m_recentFiles.addFile(fpath);
|
Chris@11
|
2632 return true;
|
Chris@11
|
2633 } else {
|
Chris@11
|
2634 return false;
|
Chris@11
|
2635 }
|
Chris@11
|
2636 }
|
Chris@11
|
2637 }
|
Chris@11
|
2638
|
Chris@11
|
2639 bool
|
Chris@0
|
2640 MainWindow::checkSaveModified()
|
Chris@0
|
2641 {
|
Chris@0
|
2642 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
2643 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
2644 // cancel.
|
Chris@0
|
2645
|
Chris@0
|
2646 if (!m_documentModified) return true;
|
Chris@0
|
2647
|
Chris@247
|
2648 emit hideSplash();
|
Chris@247
|
2649
|
Chris@0
|
2650 int button =
|
Chris@0
|
2651 QMessageBox::warning(this,
|
Chris@0
|
2652 tr("Session modified"),
|
Chris@207
|
2653 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
|
Chris@165
|
2654 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@165
|
2655 QMessageBox::Yes);
|
Chris@0
|
2656
|
Chris@0
|
2657 if (button == QMessageBox::Yes) {
|
Chris@0
|
2658 saveSession();
|
Chris@0
|
2659 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@0
|
2660 return false;
|
Chris@0
|
2661 } else {
|
Chris@0
|
2662 return true; // saved, so it's safe to continue now
|
Chris@0
|
2663 }
|
Chris@0
|
2664 } else if (button == QMessageBox::No) {
|
Chris@0
|
2665 m_documentModified = false; // so we know to abandon it
|
Chris@0
|
2666 return true;
|
Chris@0
|
2667 }
|
Chris@0
|
2668
|
Chris@0
|
2669 // else cancel
|
Chris@0
|
2670 return false;
|
Chris@0
|
2671 }
|
Chris@0
|
2672
|
Chris@0
|
2673 void
|
Chris@0
|
2674 MainWindow::saveSession()
|
Chris@0
|
2675 {
|
Chris@0
|
2676 if (m_sessionFile != "") {
|
Chris@0
|
2677 if (!saveSessionFile(m_sessionFile)) {
|
Chris@0
|
2678 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2679 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
2680 } else {
|
Chris@0
|
2681 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2682 documentRestored();
|
Chris@0
|
2683 }
|
Chris@0
|
2684 } else {
|
Chris@0
|
2685 saveSessionAs();
|
Chris@0
|
2686 }
|
Chris@0
|
2687 }
|
Chris@0
|
2688
|
Chris@0
|
2689 void
|
Chris@0
|
2690 MainWindow::saveSessionAs()
|
Chris@0
|
2691 {
|
Chris@0
|
2692 QString orig = m_audioFile;
|
Chris@0
|
2693 if (orig == "") orig = ".";
|
Chris@0
|
2694 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2695
|
Chris@88
|
2696 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
2697
|
Chris@81
|
2698 if (path == "") return;
|
Chris@0
|
2699
|
Chris@0
|
2700 if (!saveSessionFile(path)) {
|
Chris@0
|
2701 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2702 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
2703 } else {
|
Chris@0
|
2704 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@0
|
2705 .arg(QFileInfo(path).fileName()));
|
Chris@0
|
2706 m_sessionFile = path;
|
Chris@0
|
2707 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2708 documentRestored();
|
Chris@34
|
2709 m_recentFiles.addFile(path);
|
Chris@0
|
2710 }
|
Chris@0
|
2711 }
|
Chris@0
|
2712
|
Chris@90
|
2713 void
|
Chris@72
|
2714 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
2715 {
|
Chris@200
|
2716 MainWindowBase::preferenceChanged(name);
|
Chris@200
|
2717
|
Chris@200
|
2718 if (name == "Background Mode" && m_viewManager) {
|
Chris@180
|
2719 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@180
|
2720 m_panLayer->setBaseColour
|
Chris@180
|
2721 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@180
|
2722 } else {
|
Chris@180
|
2723 m_panLayer->setBaseColour
|
Chris@180
|
2724 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
|
Chris@180
|
2725 }
|
Chris@200
|
2726 }
|
Chris@0
|
2727 }
|
Chris@0
|
2728
|
Chris@0
|
2729 void
|
Chris@239
|
2730 MainWindow::propertyStacksResized(int width)
|
Chris@239
|
2731 {
|
Chris@251
|
2732 // std::cerr << "MainWindow::propertyStacksResized(" << width << ")" << std::endl;
|
Chris@239
|
2733
|
Chris@239
|
2734 if (!m_playControlsSpacer) return;
|
Chris@239
|
2735
|
Chris@239
|
2736 int spacerWidth = width - m_playControlsWidth - 4;
|
Chris@239
|
2737
|
Chris@251
|
2738 // std::cerr << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << std::endl;
|
Chris@239
|
2739
|
Chris@239
|
2740 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
|
Chris@239
|
2741 }
|
Chris@239
|
2742
|
Chris@239
|
2743 void
|
Chris@0
|
2744 MainWindow::addPane()
|
Chris@0
|
2745 {
|
Chris@0
|
2746 QObject *s = sender();
|
Chris@0
|
2747 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
2748
|
Chris@0
|
2749 if (!action) {
|
Chris@0
|
2750 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@0
|
2751 << std::endl;
|
Chris@0
|
2752 return;
|
Chris@0
|
2753 }
|
Chris@0
|
2754
|
Chris@0
|
2755 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
2756
|
Chris@0
|
2757 if (i == m_paneActions.end()) {
|
Chris@0
|
2758 std::cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@0
|
2759 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
2760 return;
|
Chris@0
|
2761 }
|
Chris@0
|
2762
|
Chris@69
|
2763 addPane(i->second, action->text());
|
Chris@69
|
2764 }
|
Chris@69
|
2765
|
Chris@69
|
2766 void
|
Chris@232
|
2767 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
|
Chris@69
|
2768 {
|
Chris@69
|
2769 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
2770
|
Chris@0
|
2771 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2772 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2773
|
Chris@0
|
2774 Pane *pane = command->getPane();
|
Chris@0
|
2775
|
Chris@69
|
2776 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
2777 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
2778 pane->setFollowGlobalZoom(false);
|
Chris@112
|
2779 pane->setZoomLevel(512);
|
Chris@7
|
2780 }
|
Chris@7
|
2781
|
Chris@69
|
2782 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
2783 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
2784
|
Chris@0
|
2785 if (!m_timeRulerLayer) {
|
Chris@0
|
2786 // std::cerr << "no time ruler layer, creating one" << std::endl;
|
Chris@0
|
2787 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2788 (LayerFactory::TimeRuler);
|
Chris@0
|
2789 }
|
Chris@0
|
2790
|
Chris@0
|
2791 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
|
Chris@0
|
2792
|
Chris@0
|
2793 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2794 }
|
Chris@0
|
2795
|
Chris@69
|
2796 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
2797
|
Chris@69
|
2798 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
2799 Model *model = 0;
|
Chris@66
|
2800
|
Chris@66
|
2801 if (suggestedModel) {
|
Chris@66
|
2802
|
Chris@66
|
2803 // check its validity
|
Chris@224
|
2804 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
2805 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
2806 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
2807 model = suggestedModel;
|
Chris@66
|
2808 break;
|
Chris@66
|
2809 }
|
Chris@66
|
2810 }
|
Chris@66
|
2811
|
Chris@66
|
2812 if (!model) {
|
Chris@66
|
2813 std::cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
2814 << " appears in pane action map, but is not reported "
|
Chris@66
|
2815 << "by document as a valid transform source" << std::endl;
|
Chris@66
|
2816 }
|
Chris@66
|
2817 }
|
Chris@66
|
2818
|
Chris@66
|
2819 if (!model) model = m_document->getMainModel();
|
Chris@66
|
2820
|
Chris@66
|
2821 m_document->setModel(newLayer, model);
|
Chris@66
|
2822
|
Chris@69
|
2823 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
2824 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2825
|
Chris@0
|
2826 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
2827 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
2828
|
Chris@130
|
2829 // std::cerr << "MainWindow::addPane: global centre frame is "
|
Chris@130
|
2830 // << m_viewManager->getGlobalCentreFrame() << std::endl;
|
Chris@130
|
2831 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
2832
|
Chris@0
|
2833 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
2834
|
Chris@0
|
2835 updateMenuStates();
|
Chris@0
|
2836 }
|
Chris@0
|
2837
|
Chris@0
|
2838 void
|
Chris@0
|
2839 MainWindow::addLayer()
|
Chris@0
|
2840 {
|
Chris@0
|
2841 QObject *s = sender();
|
Chris@0
|
2842 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
2843
|
Chris@0
|
2844 if (!action) {
|
Chris@0
|
2845 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@0
|
2846 << std::endl;
|
Chris@0
|
2847 return;
|
Chris@0
|
2848 }
|
Chris@0
|
2849
|
Chris@0
|
2850 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2851
|
Chris@0
|
2852 if (!pane) {
|
Chris@0
|
2853 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@0
|
2854 return;
|
Chris@0
|
2855 }
|
Chris@0
|
2856
|
Chris@0
|
2857 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
2858
|
Chris@0
|
2859 if (ei != m_existingLayerActions.end()) {
|
Chris@0
|
2860 Layer *newLayer = ei->second;
|
Chris@0
|
2861 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2862 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
2863 return;
|
Chris@0
|
2864 }
|
Chris@0
|
2865
|
Chris@95
|
2866 ei = m_sliceActions.find(action);
|
Chris@95
|
2867
|
Chris@95
|
2868 if (ei != m_sliceActions.end()) {
|
Chris@95
|
2869 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
2870 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
2871 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
2872 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
2873 if (source && dest) {
|
Chris@205
|
2874 //!!!???
|
Chris@95
|
2875 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
2876 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
2877 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
2878 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
2879 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
2880 }
|
Chris@95
|
2881 m_document->addLayerToView(pane, newLayer);
|
Chris@95
|
2882 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@95
|
2883 return;
|
Chris@95
|
2884 }
|
Chris@95
|
2885
|
Chris@211
|
2886 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
2887
|
Chris@34
|
2888 if (i == m_transformActions.end()) {
|
Chris@0
|
2889
|
Chris@0
|
2890 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@0
|
2891
|
Chris@0
|
2892 if (i == m_layerActions.end()) {
|
Chris@0
|
2893 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@0
|
2894 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
2895 return;
|
Chris@0
|
2896 }
|
Chris@0
|
2897
|
Chris@232
|
2898 LayerFactory::LayerType type = i->second.layer;
|
Chris@0
|
2899
|
Chris@0
|
2900 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@0
|
2901 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@0
|
2902
|
Chris@0
|
2903 Layer *newLayer;
|
Chris@0
|
2904
|
Chris@0
|
2905 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@0
|
2906
|
Chris@0
|
2907 newLayer = m_document->createEmptyLayer(type);
|
Chris@217
|
2908 if (newLayer) {
|
Chris@217
|
2909 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@217
|
2910 }
|
Chris@0
|
2911
|
Chris@0
|
2912 } else {
|
Chris@0
|
2913
|
Chris@238
|
2914 if (!i->second.sourceModel) {
|
Chris@238
|
2915 // e.g. time ruler
|
Chris@238
|
2916 newLayer = m_document->createMainModelLayer(type);
|
Chris@232
|
2917 } else {
|
Chris@238
|
2918 newLayer = m_document->createLayer(type);
|
Chris@238
|
2919 if (m_document->isKnownModel(i->second.sourceModel)) {
|
Chris@238
|
2920 m_document->setChannel(newLayer, i->second.channel);
|
Chris@238
|
2921 m_document->setModel(newLayer, i->second.sourceModel);
|
Chris@238
|
2922 } else {
|
Chris@238
|
2923 std::cerr << "WARNING: MainWindow::addLayer: unknown model "
|
Chris@238
|
2924 << i->second.sourceModel
|
Chris@238
|
2925 << " (\""
|
Chris@238
|
2926 << (i->second.sourceModel ? i->second.sourceModel->objectName().toStdString() : "")
|
Chris@238
|
2927 << "\") in layer action map"
|
Chris@238
|
2928 << std::endl;
|
Chris@238
|
2929 }
|
Chris@232
|
2930 }
|
Chris@238
|
2931 }
|
Chris@0
|
2932
|
Chris@217
|
2933 if (newLayer) {
|
Chris@217
|
2934 m_document->addLayerToView(pane, newLayer);
|
Chris@217
|
2935 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@217
|
2936 }
|
Chris@0
|
2937
|
Chris@0
|
2938 return;
|
Chris@0
|
2939 }
|
Chris@0
|
2940
|
Chris@224
|
2941 //!!! want to do something like this, but it's not supported in
|
Chris@224
|
2942 //ModelTransformerFactory yet
|
Chris@224
|
2943 /*
|
Chris@0
|
2944 int channel = -1;
|
Chris@0
|
2945 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
2946 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
2947 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@0
|
2948 if (c != -1) {
|
Chris@0
|
2949 channel = c;
|
Chris@0
|
2950 break;
|
Chris@0
|
2951 }
|
Chris@0
|
2952 }
|
Chris@224
|
2953 */
|
Chris@0
|
2954
|
Chris@33
|
2955 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
2956 // supposed to be configurable, because we need to let the user
|
Chris@33
|
2957 // change the execution context (block size etc).
|
Chris@0
|
2958
|
Chris@224
|
2959 QString transformId = i->second;
|
Chris@224
|
2960 Transform transform = TransformFactory::getInstance()->
|
Chris@224
|
2961 getDefaultTransformFor(transformId);
|
Chris@27
|
2962
|
Chris@66
|
2963 std::vector<Model *> candidateInputModels =
|
Chris@224
|
2964 m_document->getTransformInputModels();
|
Chris@53
|
2965
|
Chris@219
|
2966 Model *defaultInputModel = 0;
|
Chris@219
|
2967 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@219
|
2968 Layer *layer = pane->getLayer(j);
|
Chris@219
|
2969 if (!layer) continue;
|
Chris@243
|
2970 if (LayerFactory::getInstance()->getLayerType(layer) !=
|
Chris@243
|
2971 LayerFactory::Waveform &&
|
Chris@243
|
2972 !layer->isLayerOpaque()) continue;
|
Chris@219
|
2973 Model *model = layer->getModel();
|
Chris@219
|
2974 if (!model) continue;
|
Chris@219
|
2975 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
|
Chris@219
|
2976 if (candidateInputModels[k] == model) {
|
Chris@219
|
2977 defaultInputModel = model;
|
Chris@219
|
2978 break;
|
Chris@219
|
2979 }
|
Chris@219
|
2980 }
|
Chris@219
|
2981 if (defaultInputModel) break;
|
Chris@219
|
2982 }
|
Chris@219
|
2983
|
Chris@184
|
2984 size_t startFrame = 0, duration = 0;
|
Chris@184
|
2985 size_t endFrame = 0;
|
Chris@184
|
2986 m_viewManager->getSelection().getExtents(startFrame, endFrame);
|
Chris@184
|
2987 if (endFrame > startFrame) duration = endFrame - startFrame;
|
Chris@184
|
2988 else startFrame = 0;
|
Chris@184
|
2989
|
Chris@224
|
2990 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
Chris@224
|
2991 getConfigurationForTransform
|
Chris@211
|
2992 (transform,
|
Chris@211
|
2993 candidateInputModels,
|
Chris@219
|
2994 defaultInputModel,
|
Chris@211
|
2995 m_playSource,
|
Chris@211
|
2996 startFrame,
|
Chris@211
|
2997 duration);
|
Chris@211
|
2998
|
Chris@224
|
2999 if (!input.getModel()) return;
|
Chris@224
|
3000
|
Chris@224
|
3001 // std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl;
|
Chris@224
|
3002
|
Chris@224
|
3003 Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
Chris@0
|
3004
|
Chris@0
|
3005 if (newLayer) {
|
Chris@0
|
3006 m_document->addLayerToView(pane, newLayer);
|
Chris@224
|
3007 m_document->setChannel(newLayer, input.getChannel());
|
Chris@224
|
3008 m_recentTransforms.add(transformId);
|
Chris@70
|
3009 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3010 }
|
Chris@0
|
3011
|
Chris@0
|
3012 updateMenuStates();
|
Chris@0
|
3013 }
|
Chris@0
|
3014
|
Chris@0
|
3015 void
|
Chris@0
|
3016 MainWindow::renameCurrentLayer()
|
Chris@0
|
3017 {
|
Chris@0
|
3018 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3019 if (pane) {
|
Chris@0
|
3020 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3021 if (layer) {
|
Chris@0
|
3022 bool ok = false;
|
Chris@0
|
3023 QString newName = QInputDialog::getText
|
Chris@0
|
3024 (this, tr("Rename Layer"),
|
Chris@0
|
3025 tr("New name for this layer:"),
|
Chris@0
|
3026 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@0
|
3027 if (ok) {
|
Chris@239
|
3028 layer->setPresentationName(newName);
|
Chris@95
|
3029 setupExistingLayersMenus();
|
Chris@0
|
3030 }
|
Chris@0
|
3031 }
|
Chris@0
|
3032 }
|
Chris@0
|
3033 }
|
Chris@0
|
3034
|
Chris@0
|
3035 void
|
Chris@207
|
3036 MainWindow::playSoloToggled()
|
Chris@207
|
3037 {
|
Chris@207
|
3038 MainWindowBase::playSoloToggled();
|
Chris@207
|
3039 m_soloModified = true;
|
Chris@207
|
3040 }
|
Chris@207
|
3041
|
Chris@207
|
3042 void
|
Chris@206
|
3043 MainWindow::alignToggled()
|
Chris@206
|
3044 {
|
Chris@206
|
3045 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@206
|
3046
|
Chris@207
|
3047 if (!m_viewManager) return;
|
Chris@207
|
3048
|
Chris@206
|
3049 if (action) {
|
Chris@206
|
3050 m_viewManager->setAlignMode(action->isChecked());
|
Chris@206
|
3051 } else {
|
Chris@206
|
3052 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
|
Chris@206
|
3053 }
|
Chris@206
|
3054
|
Chris@206
|
3055 if (m_viewManager->getAlignMode()) {
|
Chris@207
|
3056 m_prevSolo = m_soloAction->isChecked();
|
Chris@208
|
3057 if (!m_soloAction->isChecked()) {
|
Chris@208
|
3058 m_soloAction->setChecked(true);
|
Chris@208
|
3059 MainWindowBase::playSoloToggled();
|
Chris@208
|
3060 }
|
Chris@207
|
3061 m_soloModified = false;
|
Chris@207
|
3062 emit canChangeSolo(false);
|
Chris@206
|
3063 m_document->alignModels();
|
Chris@206
|
3064 m_document->setAutoAlignment(true);
|
Chris@206
|
3065 } else {
|
Chris@207
|
3066 if (!m_soloModified) {
|
Chris@208
|
3067 if (m_soloAction->isChecked() != m_prevSolo) {
|
Chris@208
|
3068 m_soloAction->setChecked(m_prevSolo);
|
Chris@208
|
3069 MainWindowBase::playSoloToggled();
|
Chris@208
|
3070 }
|
Chris@207
|
3071 }
|
Chris@207
|
3072 emit canChangeSolo(true);
|
Chris@206
|
3073 m_document->setAutoAlignment(false);
|
Chris@206
|
3074 }
|
Chris@206
|
3075
|
Chris@206
|
3076 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@206
|
3077
|
Chris@206
|
3078 Pane *pane = m_paneStack->getPane(i);
|
Chris@206
|
3079 if (!pane) continue;
|
Chris@206
|
3080
|
Chris@206
|
3081 pane->update();
|
Chris@206
|
3082 }
|
Chris@206
|
3083 }
|
Chris@206
|
3084
|
Chris@206
|
3085 void
|
Chris@59
|
3086 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
3087 {
|
Chris@59
|
3088 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@60
|
3089
|
Chris@60
|
3090 float percent = m_playSpeed->mappedValue();
|
Chris@60
|
3091 float factor = mapper.getFactorForValue(percent);
|
Chris@60
|
3092
|
Chris@60
|
3093 std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
|
Chris@60
|
3094
|
Chris@59
|
3095 bool something = (position != 100);
|
Chris@155
|
3096
|
Chris@59
|
3097 int pc = lrintf(percent);
|
Chris@21
|
3098
|
Chris@155
|
3099 if (!something) {
|
Chris@155
|
3100 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@155
|
3101 } else {
|
Chris@155
|
3102 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@155
|
3103 .arg(position > 100 ? "+" : "")
|
Chris@155
|
3104 .arg(pc));
|
Chris@155
|
3105 }
|
Chris@155
|
3106
|
Chris@240
|
3107 m_playSource->setTimeStretch(factor);
|
Chris@155
|
3108
|
Chris@155
|
3109 updateMenuStates();
|
Chris@16
|
3110 }
|
Chris@16
|
3111
|
Chris@26
|
3112 void
|
Chris@155
|
3113 MainWindow::speedUpPlayback()
|
Chris@155
|
3114 {
|
Chris@155
|
3115 int value = m_playSpeed->value();
|
Chris@155
|
3116 value = value + m_playSpeed->pageStep();
|
Chris@155
|
3117 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@155
|
3118 m_playSpeed->setValue(value);
|
Chris@155
|
3119 }
|
Chris@155
|
3120
|
Chris@155
|
3121 void
|
Chris@155
|
3122 MainWindow::slowDownPlayback()
|
Chris@155
|
3123 {
|
Chris@155
|
3124 int value = m_playSpeed->value();
|
Chris@155
|
3125 value = value - m_playSpeed->pageStep();
|
Chris@155
|
3126 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@155
|
3127 m_playSpeed->setValue(value);
|
Chris@155
|
3128 }
|
Chris@155
|
3129
|
Chris@155
|
3130 void
|
Chris@155
|
3131 MainWindow::restoreNormalPlayback()
|
Chris@155
|
3132 {
|
Chris@155
|
3133 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@155
|
3134 }
|
Chris@155
|
3135
|
Chris@155
|
3136 void
|
Chris@227
|
3137 MainWindow::currentPaneChanged(Pane *pane)
|
Chris@227
|
3138 {
|
Chris@228
|
3139 MainWindowBase::currentPaneChanged(pane);
|
Chris@228
|
3140
|
Chris@227
|
3141 if (!pane || !m_panLayer) return;
|
Chris@227
|
3142 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@227
|
3143 --i;
|
Chris@227
|
3144 Layer *layer = pane->getLayer(i);
|
Chris@227
|
3145 if (LayerFactory::getInstance()->getLayerType(layer) ==
|
Chris@227
|
3146 LayerFactory::Waveform) {
|
Chris@227
|
3147 RangeSummarisableTimeValueModel *tvm =
|
Chris@227
|
3148 dynamic_cast<RangeSummarisableTimeValueModel *>(layer->getModel());
|
Chris@227
|
3149 if (tvm) {
|
Chris@227
|
3150 m_panLayer->setModel(tvm);
|
Chris@227
|
3151 return;
|
Chris@227
|
3152 }
|
Chris@227
|
3153 }
|
Chris@227
|
3154 }
|
Chris@227
|
3155 }
|
Chris@227
|
3156
|
Chris@227
|
3157 void
|
Chris@116
|
3158 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@116
|
3159 {
|
Chris@116
|
3160 if (!getMainModel() || !p) {
|
Chris@116
|
3161 return;
|
Chris@116
|
3162 }
|
Chris@116
|
3163
|
Chris@117
|
3164 bool haveSelection = false;
|
Chris@117
|
3165 size_t startFrame = 0, endFrame = 0;
|
Chris@117
|
3166
|
Chris@117
|
3167 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@117
|
3168
|
Chris@117
|
3169 bool exclusive = false;
|
Chris@117
|
3170 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@117
|
3171
|
Chris@117
|
3172 if (!s.isEmpty()) {
|
Chris@117
|
3173 haveSelection = true;
|
Chris@117
|
3174 startFrame = s.getStartFrame();
|
Chris@117
|
3175 endFrame = s.getEndFrame();
|
Chris@117
|
3176 }
|
Chris@117
|
3177 }
|
Chris@117
|
3178
|
Chris@117
|
3179 if (!haveSelection) {
|
Chris@117
|
3180 startFrame = p->getFirstVisibleFrame();
|
Chris@117
|
3181 endFrame = p->getLastVisibleFrame();
|
Chris@117
|
3182 }
|
Chris@117
|
3183
|
Chris@116
|
3184 RealTime start = RealTime::frame2RealTime
|
Chris@117
|
3185 (startFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3186
|
Chris@116
|
3187 RealTime end = RealTime::frame2RealTime
|
Chris@117
|
3188 (endFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3189
|
Chris@116
|
3190 RealTime duration = end - start;
|
Chris@116
|
3191
|
Chris@116
|
3192 QString startStr, endStr, durationStr;
|
Chris@116
|
3193 startStr = start.toText(true).c_str();
|
Chris@116
|
3194 endStr = end.toText(true).c_str();
|
Chris@116
|
3195 durationStr = duration.toText(true).c_str();
|
Chris@116
|
3196
|
Chris@117
|
3197 if (haveSelection) {
|
Chris@117
|
3198 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@117
|
3199 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3200 } else {
|
Chris@117
|
3201 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@117
|
3202 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3203 }
|
Chris@116
|
3204
|
Chris@116
|
3205 statusBar()->showMessage(m_myStatusMessage);
|
Chris@116
|
3206 }
|
Chris@116
|
3207
|
Chris@116
|
3208 void
|
Chris@0
|
3209 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
3210 {
|
Chris@0
|
3211 m_fader->setPeakLeft(left);
|
Chris@0
|
3212 m_fader->setPeakRight(right);
|
Chris@0
|
3213 }
|
Chris@0
|
3214
|
Chris@0
|
3215 void
|
Chris@0
|
3216 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
3217 bool willResample)
|
Chris@0
|
3218 {
|
Chris@0
|
3219 if (!willResample) {
|
Chris@247
|
3220 emit hideSplash();
|
Chris@0
|
3221 QMessageBox::information
|
Chris@0
|
3222 (this, tr("Sample rate mismatch"),
|
Chris@193
|
3223 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
|
3224 .arg(requested).arg(actual));
|
Chris@0
|
3225 }
|
Chris@0
|
3226
|
Chris@0
|
3227 updateDescriptionLabel();
|
Chris@0
|
3228 }
|
Chris@0
|
3229
|
Chris@0
|
3230 void
|
Chris@42
|
3231 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
3232 {
|
Chris@42
|
3233 QMessageBox::information
|
Chris@42
|
3234 (this, tr("Audio processing overload"),
|
Chris@193
|
3235 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@42
|
3236 }
|
Chris@42
|
3237
|
Chris@42
|
3238 void
|
Chris@200
|
3239 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
3240 {
|
Chris@95
|
3241 setupExistingLayersMenus();
|
Chris@200
|
3242 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
3243 }
|
Chris@0
|
3244
|
Chris@0
|
3245 void
|
Chris@0
|
3246 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
3247 {
|
Chris@95
|
3248 setupExistingLayersMenus();
|
Chris@200
|
3249 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
3250 }
|
Chris@0
|
3251
|
Chris@0
|
3252 void
|
Chris@0
|
3253 MainWindow::modelAdded(Model *model)
|
Chris@0
|
3254 {
|
Chris@200
|
3255 MainWindowBase::modelAdded(model);
|
Chris@66
|
3256 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
3257 setupPaneAndLayerMenus();
|
Chris@66
|
3258 }
|
Chris@0
|
3259 }
|
Chris@0
|
3260
|
Chris@0
|
3261 void
|
Chris@0
|
3262 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
3263 {
|
Chris@0
|
3264 m_panLayer->setModel(model);
|
Chris@200
|
3265
|
Chris@200
|
3266 MainWindowBase::mainModelChanged(model);
|
Chris@200
|
3267
|
Chris@200
|
3268 if (m_playTarget) {
|
Chris@200
|
3269 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@200
|
3270 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@200
|
3271 }
|
Chris@0
|
3272 }
|
Chris@0
|
3273
|
Chris@0
|
3274 void
|
Chris@200
|
3275 MainWindow::setInstantsNumbering()
|
Chris@0
|
3276 {
|
Chris@200
|
3277 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3278 if (!a) return;
|
Chris@200
|
3279
|
Chris@200
|
3280 int type = m_numberingActions[a];
|
Chris@200
|
3281
|
Chris@200
|
3282 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
|
Chris@200
|
3283
|
Chris@200
|
3284 QSettings settings;
|
Chris@200
|
3285 settings.beginGroup("MainWindow");
|
Chris@200
|
3286 settings.setValue("labellertype", type);
|
Chris@200
|
3287 settings.endGroup();
|
Chris@200
|
3288 }
|
Chris@200
|
3289
|
Chris@200
|
3290 void
|
Chris@200
|
3291 MainWindow::setInstantsCounterCycle()
|
Chris@200
|
3292 {
|
Chris@200
|
3293 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3294 if (!a) return;
|
Chris@200
|
3295
|
Chris@200
|
3296 int cycle = a->text().toInt();
|
Chris@200
|
3297 if (cycle == 0) return;
|
Chris@200
|
3298
|
Chris@200
|
3299 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
|
Chris@200
|
3300
|
Chris@200
|
3301 QSettings settings;
|
Chris@200
|
3302 settings.beginGroup("MainWindow");
|
Chris@200
|
3303 settings.setValue("labellercycle", cycle);
|
Chris@200
|
3304 settings.endGroup();
|
Chris@200
|
3305 }
|
Chris@200
|
3306
|
Chris@200
|
3307 void
|
Chris@200
|
3308 MainWindow::resetInstantsCounters()
|
Chris@200
|
3309 {
|
Chris@200
|
3310 LabelCounterInputDialog dialog(m_labeller, this);
|
Chris@241
|
3311 dialog.setWindowTitle(tr("Reset Counters"));
|
Chris@200
|
3312 dialog.exec();
|
Chris@0
|
3313 }
|
Chris@0
|
3314
|
Chris@0
|
3315 void
|
Chris@233
|
3316 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@233
|
3317 {
|
Chris@247
|
3318 emit hideSplash();
|
Chris@247
|
3319
|
Chris@233
|
3320 if (message != "") {
|
Chris@233
|
3321
|
Chris@233
|
3322 QMessageBox::warning
|
Chris@233
|
3323 (this,
|
Chris@233
|
3324 tr("Failed to generate layer"),
|
Chris@233
|
3325 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@233
|
3326 .arg(transformName).arg(message),
|
Chris@233
|
3327 QMessageBox::Ok);
|
Chris@233
|
3328 } else {
|
Chris@233
|
3329 QMessageBox::warning
|
Chris@233
|
3330 (this,
|
Chris@233
|
3331 tr("Failed to generate layer"),
|
Chris@233
|
3332 tr("<b>Layer generation failed</b><p>Failed to generate a derived layer.<p>The layer transform \"%1\" failed.<p>No error information is available.")
|
Chris@233
|
3333 .arg(transformName),
|
Chris@233
|
3334 QMessageBox::Ok);
|
Chris@233
|
3335 }
|
Chris@233
|
3336 }
|
Chris@233
|
3337
|
Chris@233
|
3338 void
|
Chris@233
|
3339 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@233
|
3340 {
|
Chris@247
|
3341 emit hideSplash();
|
Chris@247
|
3342
|
Chris@233
|
3343 QMessageBox::warning
|
Chris@233
|
3344 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@233
|
3345 }
|
Chris@233
|
3346
|
Chris@233
|
3347 void
|
Chris@233
|
3348 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@233
|
3349 QString transformName, QString message)
|
Chris@233
|
3350 {
|
Chris@247
|
3351 emit hideSplash();
|
Chris@247
|
3352
|
Chris@233
|
3353 if (message != "") {
|
Chris@233
|
3354
|
Chris@233
|
3355 QMessageBox::warning
|
Chris@233
|
3356 (this,
|
Chris@233
|
3357 tr("Failed to regenerate layer"),
|
Chris@233
|
3358 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed:<p>%3")
|
Chris@233
|
3359 .arg(layerName).arg(transformName).arg(message),
|
Chris@233
|
3360 QMessageBox::Ok);
|
Chris@233
|
3361 } else {
|
Chris@233
|
3362 QMessageBox::warning
|
Chris@233
|
3363 (this,
|
Chris@233
|
3364 tr("Failed to regenerate layer"),
|
Chris@233
|
3365 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed.<p>No error information is available.")
|
Chris@233
|
3366 .arg(layerName).arg(transformName),
|
Chris@233
|
3367 QMessageBox::Ok);
|
Chris@233
|
3368 }
|
Chris@233
|
3369 }
|
Chris@233
|
3370
|
Chris@233
|
3371 void
|
Chris@233
|
3372 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@233
|
3373 QString transformName, QString message)
|
Chris@233
|
3374 {
|
Chris@247
|
3375 emit hideSplash();
|
Chris@247
|
3376
|
Chris@233
|
3377 QMessageBox::warning
|
Chris@233
|
3378 (this, tr("Warning"), tr("<b>Warning when regenerating layer</b><p>When regenerating the derived layer \"%1\" using new data model as input:<p>%2").arg(layerName).arg(message), QMessageBox::Ok);
|
Chris@233
|
3379 }
|
Chris@233
|
3380
|
Chris@233
|
3381 void
|
Chris@233
|
3382 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
3383 {
|
Chris@247
|
3384 emit hideSplash();
|
Chris@247
|
3385
|
Chris@0
|
3386 QMessageBox::warning
|
Chris@0
|
3387 (this,
|
Chris@233
|
3388 tr("Failed to calculate alignment"),
|
Chris@233
|
3389 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@233
|
3390 .arg(transformName).arg(message),
|
Chris@165
|
3391 QMessageBox::Ok);
|
Chris@0
|
3392 }
|
Chris@0
|
3393
|
Chris@0
|
3394 void
|
Chris@0
|
3395 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
3396 {
|
Chris@0
|
3397 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
|
Chris@0
|
3398 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
3399 m_rightButtonMenu->popup(position);
|
Chris@0
|
3400 }
|
Chris@0
|
3401
|
Chris@0
|
3402 void
|
Chris@0
|
3403 MainWindow::showLayerTree()
|
Chris@0
|
3404 {
|
Chris@219
|
3405 if (!m_layerTreeDialog.isNull()) {
|
Chris@219
|
3406 m_layerTreeDialog->show();
|
Chris@219
|
3407 m_layerTreeDialog->raise();
|
Chris@177
|
3408 return;
|
Chris@177
|
3409 }
|
Chris@177
|
3410
|
Chris@219
|
3411 m_layerTreeDialog = new LayerTreeDialog(m_paneStack);
|
Chris@232
|
3412 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
|
Chris@219
|
3413 m_layerTreeDialog->show();
|
Chris@0
|
3414 }
|
Chris@0
|
3415
|
Chris@0
|
3416 void
|
Chris@0
|
3417 MainWindow::preferences()
|
Chris@0
|
3418 {
|
Chris@0
|
3419 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
3420 m_preferencesDialog->show();
|
Chris@0
|
3421 m_preferencesDialog->raise();
|
Chris@0
|
3422 return;
|
Chris@0
|
3423 }
|
Chris@0
|
3424
|
Chris@0
|
3425 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
3426
|
Chris@0
|
3427 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
3428 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
3429 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
3430 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
3431 // without resetting its own widgets, so its state will be
|
Chris@0
|
3432 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
3433 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
3434
|
Chris@0
|
3435 m_preferencesDialog->show();
|
Chris@0
|
3436 }
|
Chris@0
|
3437
|
Chris@0
|
3438 void
|
Chris@90
|
3439 MainWindow::mouseEnteredWidget()
|
Chris@90
|
3440 {
|
Chris@90
|
3441 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
3442 if (!w) return;
|
Chris@90
|
3443
|
Chris@90
|
3444 if (w == m_fader) {
|
Chris@116
|
3445 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@90
|
3446 } else if (w == m_playSpeed) {
|
Chris@116
|
3447 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@90
|
3448 }
|
Chris@90
|
3449 }
|
Chris@90
|
3450
|
Chris@90
|
3451 void
|
Chris@90
|
3452 MainWindow::mouseLeftWidget()
|
Chris@90
|
3453 {
|
Chris@116
|
3454 contextHelpChanged("");
|
Chris@116
|
3455 }
|
Chris@116
|
3456
|
Chris@116
|
3457 void
|
Chris@0
|
3458 MainWindow::website()
|
Chris@0
|
3459 {
|
Chris@0
|
3460 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
3461 }
|
Chris@0
|
3462
|
Chris@0
|
3463 void
|
Chris@0
|
3464 MainWindow::help()
|
Chris@0
|
3465 {
|
Chris@236
|
3466 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/1.2/en/"));
|
Chris@0
|
3467 }
|
Chris@0
|
3468
|
Chris@0
|
3469 void
|
Chris@0
|
3470 MainWindow::about()
|
Chris@0
|
3471 {
|
Chris@0
|
3472 bool debug = false;
|
Chris@0
|
3473 QString version = "(unknown version)";
|
Chris@0
|
3474
|
Chris@0
|
3475 #ifdef BUILD_DEBUG
|
Chris@0
|
3476 debug = true;
|
Chris@0
|
3477 #endif
|
Chris@0
|
3478 #ifdef SV_VERSION
|
Chris@0
|
3479 #ifdef SVNREV
|
Chris@0
|
3480 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@0
|
3481 #else
|
Chris@0
|
3482 version = tr("Release %1").arg(SV_VERSION);
|
Chris@0
|
3483 #endif
|
Chris@0
|
3484 #else
|
Chris@0
|
3485 #ifdef SVNREV
|
Chris@0
|
3486 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@0
|
3487 #endif
|
Chris@0
|
3488 #endif
|
Chris@0
|
3489
|
Chris@0
|
3490 QString aboutText;
|
Chris@0
|
3491
|
Chris@0
|
3492 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@231
|
3493 aboutText += tr("<p>Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p>");
|
Chris@111
|
3494 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
3495 .arg(version)
|
Chris@0
|
3496 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
3497
|
Chris@132
|
3498 #ifndef BUILD_STATIC
|
Chris@132
|
3499 aboutText += tr("<br>Using Qt v%1 © Trolltech AS").arg(QT_VERSION_STR);
|
Chris@132
|
3500 #else
|
Chris@132
|
3501 #ifdef QT_SHARED
|
Chris@132
|
3502 aboutText += tr("<br>Using Qt v%1 © Trolltech AS").arg(QT_VERSION_STR);
|
Chris@132
|
3503 #endif
|
Chris@132
|
3504 #endif
|
Chris@132
|
3505
|
Chris@0
|
3506 #ifdef BUILD_STATIC
|
Chris@0
|
3507 aboutText += tr("<p>Statically linked");
|
Chris@0
|
3508 #ifndef QT_SHARED
|
Chris@0
|
3509 aboutText += tr("<br>With Qt (v%1) © Trolltech AS").arg(QT_VERSION_STR);
|
Chris@0
|
3510 #endif
|
Chris@0
|
3511 #ifdef HAVE_JACK
|
Chris@93
|
3512 #ifdef JACK_VERSION
|
Chris@0
|
3513 aboutText += tr("<br>With JACK audio output (v%1) © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@93
|
3514 #else
|
Chris@93
|
3515 aboutText += tr("<br>With JACK audio output © Paul Davis and Jack O'Quin");
|
Chris@93
|
3516 #endif
|
Chris@0
|
3517 #endif
|
Chris@0
|
3518 #ifdef HAVE_PORTAUDIO
|
Chris@0
|
3519 aboutText += tr("<br>With PortAudio audio output © Ross Bencina and Phil Burk");
|
Chris@0
|
3520 #endif
|
Chris@0
|
3521 #ifdef HAVE_OGGZ
|
Chris@93
|
3522 #ifdef OGGZ_VERSION
|
Chris@0
|
3523 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@93
|
3524 #else
|
Chris@93
|
3525 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@93
|
3526 #endif
|
Chris@0
|
3527 #endif
|
Chris@0
|
3528 #ifdef HAVE_MAD
|
Chris@93
|
3529 #ifdef MAD_VERSION
|
Chris@0
|
3530 aboutText += tr("<br>With MAD mp3 decoder (v%1) © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@93
|
3531 #else
|
Chris@93
|
3532 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@93
|
3533 #endif
|
Chris@0
|
3534 #endif
|
Chris@0
|
3535 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
3536 #ifdef SAMPLERATE_VERSION
|
Chris@0
|
3537 aboutText += tr("<br>With libsamplerate (v%1) © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@93
|
3538 #else
|
Chris@93
|
3539 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@93
|
3540 #endif
|
Chris@0
|
3541 #endif
|
Chris@0
|
3542 #ifdef HAVE_SNDFILE
|
Chris@93
|
3543 #ifdef SNDFILE_VERSION
|
Chris@0
|
3544 aboutText += tr("<br>With libsndfile (v%1) © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@93
|
3545 #else
|
Chris@93
|
3546 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@93
|
3547 #endif
|
Chris@0
|
3548 #endif
|
Chris@127
|
3549 #ifdef HAVE_FFTW3F
|
Chris@93
|
3550 #ifdef FFTW3_VERSION
|
Chris@0
|
3551 aboutText += tr("<br>With FFTW3 (v%1) © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@93
|
3552 #else
|
Chris@93
|
3553 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@93
|
3554 #endif
|
Chris@0
|
3555 #endif
|
Chris@0
|
3556 #ifdef HAVE_VAMP
|
Chris@114
|
3557 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
|
3558 #endif
|
Chris@0
|
3559 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
3560 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@69
|
3561 #ifdef HAVE_LIBLO
|
Chris@93
|
3562 #ifdef LIBLO_VERSION
|
Chris@69
|
3563 aboutText += tr("<br>With liblo Lite OSC library (v%1) © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
3564 #else
|
Chris@93
|
3565 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris").arg(LIBLO_VERSION);
|
Chris@93
|
3566 #endif
|
Chris@70
|
3567 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@69
|
3568 aboutText += tr("<p>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@69
|
3569 }
|
Chris@69
|
3570 #endif
|
Chris@0
|
3571 aboutText += "</p>";
|
Chris@0
|
3572 #endif
|
Chris@0
|
3573
|
Chris@0
|
3574 aboutText +=
|
Chris@231
|
3575 "<p>Sonic Visualiser Copyright © 2005 - 2008 Chris Cannam and "
|
Chris@90
|
3576 "Queen Mary, University of London.</p>"
|
Chris@231
|
3577 "<p>This program is free software; you can redistribute it and/or "
|
Chris@231
|
3578 "modify it under the terms of the GNU General Public License as "
|
Chris@231
|
3579 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
3580 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
3581 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
3582
|
Chris@0
|
3583 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
|
Chris@0
|
3584 }
|
Chris@0
|
3585
|
Chris@162
|
3586 void
|
Chris@162
|
3587 MainWindow::keyReference()
|
Chris@162
|
3588 {
|
Chris@162
|
3589 m_keyReference->show();
|
Chris@162
|
3590 }
|
Chris@162
|
3591
|