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