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