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