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