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