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