Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 Sonic Visualiser
|
Chris@0
|
5 An audio file viewer and annotation editor.
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@200
|
7 This file copyright 2006-2007 Chris Cannam and QMUL.
|
Chris@0
|
8
|
Chris@0
|
9 This program is free software; you can redistribute it and/or
|
Chris@0
|
10 modify it under the terms of the GNU General Public License as
|
Chris@0
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
12 License, or (at your option) any later version. See the file
|
Chris@0
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@144
|
16 #include "../version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@0
|
19 #include "PreferencesDialog.h"
|
Chris@0
|
20
|
Chris@1
|
21 #include "view/Pane.h"
|
Chris@1
|
22 #include "view/PaneStack.h"
|
Chris@1
|
23 #include "data/model/WaveFileModel.h"
|
Chris@1
|
24 #include "data/model/SparseOneDimensionalModel.h"
|
Chris@415
|
25 #include "data/model/RangeSummarisableTimeValueModel.h"
|
Chris@185
|
26 #include "data/model/NoteModel.h"
|
Chris@895
|
27 #include "data/model/AggregateWaveModel.h"
|
Chris@189
|
28 #include "data/model/Labeller.h"
|
Chris@222
|
29 #include "data/osc/OSCQueue.h"
|
Chris@216
|
30 #include "framework/Document.h"
|
Chris@357
|
31 #include "framework/TransformUserConfigurator.h"
|
Chris@1
|
32 #include "view/ViewManager.h"
|
Chris@0
|
33 #include "base/Preferences.h"
|
Chris@423
|
34 #include "base/ResourceFinder.h"
|
Chris@0
|
35 #include "layer/WaveformLayer.h"
|
Chris@0
|
36 #include "layer/TimeRulerLayer.h"
|
Chris@0
|
37 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
38 #include "layer/TimeValueLayer.h"
|
Chris@307
|
39 #include "layer/NoteLayer.h"
|
Chris@0
|
40 #include "layer/Colour3DPlotLayer.h"
|
Chris@95
|
41 #include "layer/SliceLayer.h"
|
Chris@95
|
42 #include "layer/SliceableLayer.h"
|
Chris@193
|
43 #include "layer/ImageLayer.h"
|
Chris@340
|
44 #include "layer/RegionLayer.h"
|
Chris@65
|
45 #include "view/Overview.h"
|
Chris@0
|
46 #include "widgets/PropertyBox.h"
|
Chris@0
|
47 #include "widgets/PropertyStack.h"
|
Chris@0
|
48 #include "widgets/AudioDial.h"
|
Chris@1386
|
49 #include "widgets/LevelPanWidget.h"
|
Chris@1431
|
50 #include "widgets/LevelPanToolButton.h"
|
Chris@168
|
51 #include "widgets/IconLoader.h"
|
Chris@219
|
52 #include "widgets/LayerTreeDialog.h"
|
Chris@0
|
53 #include "widgets/ListInputDialog.h"
|
Chris@36
|
54 #include "widgets/SubdividingMenu.h"
|
Chris@90
|
55 #include "widgets/NotifyingPushButton.h"
|
Chris@162
|
56 #include "widgets/KeyReference.h"
|
Chris@273
|
57 #include "widgets/TransformFinder.h"
|
Chris@192
|
58 #include "widgets/LabelCounterInputDialog.h"
|
Chris@302
|
59 #include "widgets/ActivityLog.h"
|
Chris@891
|
60 #include "widgets/UnitConverter.h"
|
Chris@1779
|
61 #include "widgets/ProgressDialog.h"
|
Chris@1987
|
62 #include "widgets/CSVFormatDialog.h"
|
Chris@1035
|
63 #include "audio/AudioCallbackPlaySource.h"
|
Chris@1476
|
64 #include "audio/AudioCallbackRecordTarget.h"
|
Chris@1035
|
65 #include "audio/PlaySpeedRangeMapper.h"
|
Chris@1
|
66 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@180
|
67 #include "data/fileio/PlaylistFileReader.h"
|
Chris@1
|
68 #include "data/fileio/WavFileWriter.h"
|
Chris@1
|
69 #include "data/fileio/CSVFileWriter.h"
|
Chris@185
|
70 #include "data/fileio/MIDIFileWriter.h"
|
Chris@1
|
71 #include "data/fileio/BZipFileDevice.h"
|
Chris@198
|
72 #include "data/fileio/FileSource.h"
|
Chris@304
|
73 #include "data/midi/MIDIInput.h"
|
Chris@1
|
74 #include "base/RecentFiles.h"
|
Chris@1145
|
75 #include "plugin/PluginScan.h"
|
Chris@249
|
76 #include "transform/TransformFactory.h"
|
Chris@249
|
77 #include "transform/ModelTransformerFactory.h"
|
Chris@0
|
78 #include "base/PlayParameterRepository.h"
|
Chris@0
|
79 #include "base/XmlExportable.h"
|
Chris@248
|
80 #include "widgets/CommandHistory.h"
|
Chris@0
|
81 #include "base/Profiler.h"
|
Chris@0
|
82 #include "base/Clipboard.h"
|
Chris@165
|
83 #include "base/UnitDatabase.h"
|
Chris@248
|
84 #include "layer/ColourDatabase.h"
|
Chris@265
|
85 #include "widgets/ModelDataTableDialog.h"
|
Chris@289
|
86 #include "rdf/PluginRDFIndexer.h"
|
Chris@291
|
87 #include "rdf/RDFExporter.h"
|
Chris@276
|
88
|
Chris@662
|
89 #include "Surveyer.h"
|
Chris@663
|
90 #include "NetworkPermissionTester.h"
|
Chris@334
|
91 #include "framework/VersionTester.h"
|
Chris@333
|
92
|
Chris@0
|
93 // For version information
|
Chris@280
|
94 #include <vamp/vamp.h>
|
Chris@280
|
95 #include <vamp-hostsdk/PluginBase.h>
|
Chris@0
|
96 #include "plugin/api/ladspa.h"
|
Chris@0
|
97 #include "plugin/api/dssi.h"
|
Chris@0
|
98
|
Chris@1035
|
99 #include <bqaudioio/SystemPlaybackTarget.h>
|
Chris@1055
|
100 #include <bqaudioio/SystemAudioIO.h>
|
Chris@1035
|
101
|
Chris@0
|
102 #include <QApplication>
|
Chris@0
|
103 #include <QMessageBox>
|
Chris@0
|
104 #include <QGridLayout>
|
Chris@0
|
105 #include <QLabel>
|
Chris@0
|
106 #include <QAction>
|
Chris@0
|
107 #include <QMenuBar>
|
Chris@0
|
108 #include <QToolBar>
|
Chris@0
|
109 #include <QInputDialog>
|
Chris@0
|
110 #include <QStatusBar>
|
Chris@0
|
111 #include <QTreeView>
|
Chris@0
|
112 #include <QFile>
|
Chris@88
|
113 #include <QFileInfo>
|
Chris@88
|
114 #include <QDir>
|
Chris@0
|
115 #include <QTextStream>
|
Chris@911
|
116 #include <QTextCodec>
|
Chris@0
|
117 #include <QProcess>
|
Chris@7
|
118 #include <QShortcut>
|
Chris@5
|
119 #include <QSettings>
|
Chris@11
|
120 #include <QDateTime>
|
Chris@11
|
121 #include <QProcess>
|
Chris@16
|
122 #include <QCheckBox>
|
Chris@55
|
123 #include <QRegExp>
|
Chris@158
|
124 #include <QScrollArea>
|
Chris@1432
|
125 #include <QCloseEvent>
|
Chris@483
|
126 #include <QDialogButtonBox>
|
Chris@426
|
127 #include <QFileSystemWatcher>
|
Chris@1516
|
128 #include <QTextEdit>
|
Chris@0
|
129
|
Chris@0
|
130 #include <iostream>
|
Chris@0
|
131 #include <cstdio>
|
Chris@0
|
132 #include <errno.h>
|
Chris@0
|
133
|
Chris@33
|
134 using std::vector;
|
Chris@33
|
135 using std::map;
|
Chris@33
|
136 using std::set;
|
Chris@33
|
137
|
Chris@0
|
138
|
Chris@1045
|
139 MainWindow::MainWindow(SoundOptions options, bool withOSCSupport) :
|
Chris@1045
|
140 MainWindowBase(options),
|
Chris@65
|
141 m_overview(0),
|
Chris@0
|
142 m_mainMenusCreated(false),
|
Chris@0
|
143 m_paneMenu(0),
|
Chris@0
|
144 m_layerMenu(0),
|
Chris@34
|
145 m_transformsMenu(0),
|
Chris@155
|
146 m_playbackMenu(0),
|
Chris@0
|
147 m_existingLayersMenu(0),
|
Chris@95
|
148 m_sliceMenu(0),
|
Chris@34
|
149 m_recentFilesMenu(0),
|
Chris@211
|
150 m_recentTransformsMenu(0),
|
Chris@426
|
151 m_templatesMenu(0),
|
Chris@0
|
152 m_rightButtonMenu(0),
|
Chris@0
|
153 m_rightButtonLayerMenu(0),
|
Chris@211
|
154 m_rightButtonTransformsMenu(0),
|
Chris@155
|
155 m_rightButtonPlaybackMenu(0),
|
Chris@207
|
156 m_soloAction(0),
|
Chris@265
|
157 m_rwdStartAction(0),
|
Chris@323
|
158 m_rwdSimilarAction(0),
|
Chris@265
|
159 m_rwdAction(0),
|
Chris@155
|
160 m_ffwdAction(0),
|
Chris@323
|
161 m_ffwdSimilarAction(0),
|
Chris@265
|
162 m_ffwdEndAction(0),
|
Chris@265
|
163 m_playAction(0),
|
Chris@1047
|
164 m_recordAction(0),
|
Chris@265
|
165 m_playSelectionAction(0),
|
Chris@265
|
166 m_playLoopAction(0),
|
Chris@705
|
167 m_soloModified(false),
|
Chris@705
|
168 m_prevSolo(false),
|
Chris@239
|
169 m_playControlsSpacer(0),
|
Chris@239
|
170 m_playControlsWidth(0),
|
Chris@162
|
171 m_preferencesDialog(0),
|
Chris@219
|
172 m_layerTreeDialog(0),
|
Chris@302
|
173 m_activityLog(new ActivityLog()),
|
Chris@891
|
174 m_unitConverter(new UnitConverter()),
|
Chris@426
|
175 m_keyReference(new KeyReference()),
|
Chris@426
|
176 m_templateWatcher(0)
|
Chris@0
|
177 {
|
Chris@253
|
178 Profiler profiler("MainWindow::MainWindow");
|
Chris@253
|
179
|
Chris@1610
|
180 SVDEBUG << "MainWindow: " << getReleaseText() << endl;
|
Chris@1610
|
181
|
Chris@518
|
182 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
183
|
Chris@165
|
184 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@165
|
185 udb->registerUnit("Hz");
|
Chris@165
|
186 udb->registerUnit("dB");
|
Chris@165
|
187 udb->registerUnit("s");
|
Chris@165
|
188
|
Chris@165
|
189 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@165
|
190 cdb->addColour(Qt::black, tr("Black"));
|
Chris@165
|
191 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@165
|
192 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@165
|
193 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@165
|
194 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@165
|
195 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@166
|
196 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@166
|
197 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@166
|
198 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@166
|
199 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@166
|
200 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@166
|
201 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
202
|
Chris@1639
|
203 SVDEBUG << "MainWindow: Creating main user interface layout" << endl;
|
Chris@1639
|
204
|
Chris@0
|
205 QFrame *frame = new QFrame;
|
Chris@0
|
206 setCentralWidget(frame);
|
Chris@0
|
207
|
Chris@0
|
208 QGridLayout *layout = new QGridLayout;
|
Chris@180
|
209
|
Chris@519
|
210 m_descriptionLabel = new QLabel;
|
Chris@0
|
211
|
Chris@489
|
212 m_mainScroll = new QScrollArea(frame);
|
Chris@489
|
213 m_mainScroll->setWidgetResizable(true);
|
Chris@489
|
214 m_mainScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@489
|
215 m_mainScroll->setFrameShape(QFrame::NoFrame);
|
Chris@489
|
216
|
Chris@489
|
217 m_mainScroll->setWidget(m_paneStack);
|
Chris@159
|
218
|
Chris@65
|
219 m_overview = new Overview(frame);
|
Chris@65
|
220 m_overview->setViewManager(m_viewManager);
|
Chris@1431
|
221 int overviewHeight = m_viewManager->scalePixelSize(35);
|
Chris@1431
|
222 if (overviewHeight < 40) overviewHeight = 40;
|
Chris@1431
|
223 m_overview->setFixedHeight(overviewHeight);
|
Chris@144
|
224 #ifndef _WIN32
|
Chris@144
|
225 // For some reason, the contents of the overview never appear if we
|
Chris@144
|
226 // make this setting on Windows. I have no inclination at the moment
|
Chris@144
|
227 // to track down the reason why.
|
Chris@129
|
228 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@144
|
229 #endif
|
Chris@90
|
230 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
231 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
232
|
Chris@0
|
233 m_panLayer = new WaveformLayer;
|
Chris@0
|
234 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
235 m_panLayer->setAggressiveCacheing(true);
|
Chris@65
|
236 m_overview->addLayer(m_panLayer);
|
Chris@174
|
237
|
Chris@1448
|
238 coloursChanged(); // sets pan layer colour from preferences
|
Chris@0
|
239
|
Chris@0
|
240 m_playSpeed = new AudioDial(frame);
|
Chris@12
|
241 m_playSpeed->setMinimum(0);
|
Chris@1031
|
242 m_playSpeed->setMaximum(120);
|
Chris@1031
|
243 m_playSpeed->setValue(60);
|
Chris@1431
|
244 m_playSpeed->setFixedWidth(overviewHeight);
|
Chris@1431
|
245 m_playSpeed->setFixedHeight(overviewHeight);
|
Chris@0
|
246 m_playSpeed->setNotchesVisible(true);
|
Chris@25
|
247 m_playSpeed->setPageStep(10);
|
Chris@1031
|
248 m_playSpeed->setObjectName(tr("Playback Speed"));
|
Chris@1031
|
249 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper);
|
Chris@1031
|
250 m_playSpeed->setDefaultValue(60);
|
Chris@60
|
251 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
252 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
Chris@1770
|
253 this, SLOT(playSpeedChanged(int)));
|
Chris@90
|
254 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
255 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
256
|
Chris@1431
|
257 m_mainLevelPan = new LevelPanToolButton(frame);
|
Chris@1386
|
258 connect(m_mainLevelPan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@1386
|
259 connect(m_mainLevelPan, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@1431
|
260 m_mainLevelPan->setFixedHeight(overviewHeight);
|
Chris@1431
|
261 m_mainLevelPan->setFixedWidth(overviewHeight);
|
Chris@1431
|
262 m_mainLevelPan->setImageSize((overviewHeight * 3) / 4);
|
Chris@1431
|
263 m_mainLevelPan->setBigImageSize(overviewHeight * 3);
|
Chris@168
|
264
|
Chris@239
|
265 m_playControlsSpacer = new QFrame;
|
Chris@239
|
266
|
Chris@1383
|
267 layout->setSpacing(m_viewManager->scalePixelSize(4));
|
Chris@1383
|
268 layout->addWidget(m_mainScroll, 0, 0, 1, 4);
|
Chris@1383
|
269 layout->addWidget(m_overview, 1, 0);
|
Chris@1431
|
270 layout->addWidget(m_playSpeed, 1, 1);
|
Chris@1431
|
271 layout->addWidget(m_playControlsSpacer, 1, 2);
|
Chris@1386
|
272 layout->addWidget(m_mainLevelPan, 1, 3);
|
Chris@239
|
273
|
Chris@239
|
274 m_playControlsWidth =
|
Chris@1386
|
275 m_mainLevelPan->width() + m_playSpeed->width() + layout->spacing() * 2;
|
Chris@239
|
276
|
Chris@239
|
277 m_paneStack->setPropertyStackMinWidth(m_playControlsWidth
|
Chris@239
|
278 + 2 + layout->spacing());
|
Chris@239
|
279 m_playControlsSpacer->setFixedSize(QSize(2, 2));
|
Chris@239
|
280
|
Chris@1383
|
281 layout->setColumnStretch(0, 10);
|
Chris@239
|
282
|
Chris@239
|
283 connect(m_paneStack, SIGNAL(propertyStacksResized(int)),
|
Chris@239
|
284 this, SLOT(propertyStacksResized(int)));
|
Chris@16
|
285
|
Chris@0
|
286 frame->setLayout(layout);
|
Chris@0
|
287
|
Chris@1639
|
288 SVDEBUG << "MainWindow: Creating menus and toolbars" << endl;
|
Chris@1639
|
289
|
cannam@1461
|
290 #ifdef Q_OS_MAC
|
cannam@1461
|
291 // Mac doesn't align menu labels when icons are shown: result is messy
|
cannam@1461
|
292 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
|
cannam@1461
|
293 setIconsVisibleInMenus(false);
|
cannam@1461
|
294 #endif
|
cannam@1461
|
295
|
Chris@0
|
296 setupMenus();
|
Chris@0
|
297 setupToolbars();
|
Chris@155
|
298 setupHelpMenu();
|
Chris@0
|
299
|
Chris@90
|
300 statusBar();
|
Chris@340
|
301 m_currentLabel = new QLabel;
|
Chris@340
|
302 statusBar()->addPermanentWidget(m_currentLabel);
|
Chris@0
|
303
|
Chris@728
|
304 finaliseMenus();
|
Chris@728
|
305
|
Chris@302
|
306 connect(m_viewManager, SIGNAL(activity(QString)),
|
Chris@302
|
307 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
308 connect(m_playSource, SIGNAL(activity(QString)),
|
Chris@302
|
309 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
310 connect(CommandHistory::getInstance(), SIGNAL(activity(QString)),
|
Chris@302
|
311 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@310
|
312 connect(this, SIGNAL(activity(QString)),
|
Chris@310
|
313 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
314 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
|
Chris@1087
|
315
|
Chris@306
|
316 m_activityLog->hide();
|
Chris@303
|
317
|
Chris@891
|
318 m_unitConverter->hide();
|
Chris@1056
|
319
|
Chris@1056
|
320 setAudioRecordMode(RecordCreateAdditionalModel);
|
Chris@1639
|
321
|
Chris@1639
|
322 SVDEBUG << "MainWindow: Creating new session" << endl;
|
Chris@1639
|
323
|
Chris@303
|
324 newSession();
|
Chris@303
|
325
|
Chris@304
|
326 connect(m_midiInput, SIGNAL(eventsAvailable()),
|
Chris@304
|
327 this, SLOT(midiEventsAvailable()));
|
Chris@663
|
328
|
Chris@1639
|
329 SVDEBUG << "MainWindow: Creating network permission tester" << endl;
|
Chris@1639
|
330
|
Chris@1613
|
331 NetworkPermissionTester tester(withOSCSupport);
|
Chris@663
|
332 bool networkPermission = tester.havePermission();
|
Chris@663
|
333 if (networkPermission) {
|
Chris@686
|
334 if (withOSCSupport) {
|
Chris@1639
|
335 SVDEBUG << "MainWindow: Creating OSC queue" << endl;
|
Chris@686
|
336 startOSCQueue();
|
Chris@686
|
337 }
|
Chris@1639
|
338
|
Chris@1639
|
339 SVDEBUG << "MainWindow: Starting transform population thread" << endl;
|
Chris@663
|
340 TransformFactory::getInstance()->startPopulationThread();
|
Chris@1639
|
341
|
Chris@1639
|
342 SVDEBUG << "MainWindow: Creating surveyer" << endl;
|
Chris@663
|
343 m_surveyer = new Surveyer
|
Chris@663
|
344 ("sonicvisualiser.org", "survey23-present.txt", "survey23.php");
|
Chris@1639
|
345
|
Chris@1639
|
346 SVDEBUG << "MainWindow: Creating version tester" << endl;
|
Chris@663
|
347 m_versionTester = new VersionTester
|
Chris@663
|
348 ("sonicvisualiser.org", "latest-version.txt", SV_VERSION);
|
Chris@663
|
349 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@663
|
350 this, SLOT(newerVersionAvailable(QString)));
|
Chris@663
|
351 } else {
|
Chris@663
|
352 m_surveyer = 0;
|
Chris@663
|
353 m_versionTester = 0;
|
Chris@663
|
354 }
|
Chris@1087
|
355
|
Chris@1630
|
356 /*
|
Chris@1521
|
357 QTimer::singleShot(500, this, SLOT(betaReleaseWarning()));
|
Chris@1630
|
358 */
|
Chris@1521
|
359
|
Chris@1145
|
360 QString warning = PluginScan::getInstance()->getStartupFailureReport();
|
Chris@1148
|
361 if (warning != "") {
|
Chris@1148
|
362 QTimer::singleShot(500, this, SLOT(pluginPopulationWarning()));
|
Chris@1148
|
363 }
|
Chris@1639
|
364
|
Chris@1639
|
365 SVDEBUG << "MainWindow: Constructor done" << endl;
|
Chris@0
|
366 }
|
Chris@0
|
367
|
Chris@0
|
368 MainWindow::~MainWindow()
|
Chris@0
|
369 {
|
Chris@438
|
370 // SVDEBUG << "MainWindow::~MainWindow" << endl;
|
Chris@162
|
371 delete m_keyReference;
|
Chris@504
|
372 delete m_activityLog;
|
Chris@891
|
373 delete m_unitConverter;
|
Chris@163
|
374 delete m_preferencesDialog;
|
Chris@219
|
375 delete m_layerTreeDialog;
|
Chris@573
|
376 delete m_versionTester;
|
Chris@662
|
377 delete m_surveyer;
|
Chris@0
|
378 Profiles::getInstance()->dump();
|
Chris@438
|
379 // SVDEBUG << "MainWindow::~MainWindow finishing" << endl;
|
Chris@0
|
380 }
|
Chris@0
|
381
|
Chris@81
|
382 void
|
Chris@0
|
383 MainWindow::setupMenus()
|
Chris@0
|
384 {
|
Chris@0
|
385 if (!m_mainMenusCreated) {
|
Chris@779
|
386
|
Chris@779
|
387 #ifdef Q_OS_LINUX
|
Chris@779
|
388 // In Ubuntu 14.04 the window's menu bar goes missing entirely
|
Chris@779
|
389 // if the user is running any desktop environment other than Unity
|
Chris@779
|
390 // (in which the faux single-menubar appears). The user has a
|
Chris@779
|
391 // workaround, to remove the appmenu-qt5 package, but that is
|
Chris@779
|
392 // awkward and the problem is so severe that it merits disabling
|
Chris@779
|
393 // the system menubar integration altogether. Like this:
|
Chris@1770
|
394 menuBar()->setNativeMenuBar(false); // fix #1039
|
Chris@779
|
395 #endif
|
Chris@1458
|
396
|
Chris@0
|
397 m_rightButtonMenu = new QMenu();
|
Chris@104
|
398
|
Chris@1458
|
399 // We don't want tear-off enabled on the right-button menu.
|
Chris@1458
|
400 // If it is enabled, then simply right-clicking and releasing
|
Chris@1458
|
401 // will pop up the menu, activate the tear-off, and leave the
|
Chris@1458
|
402 // torn-off menu window in front of the main window. That
|
Chris@1458
|
403 // isn't desirable.
|
Chris@1458
|
404 m_rightButtonMenu->setTearOffEnabled(false);
|
Chris@0
|
405 }
|
Chris@0
|
406
|
Chris@211
|
407 if (m_rightButtonTransformsMenu) {
|
Chris@211
|
408 m_rightButtonTransformsMenu->clear();
|
Chris@34
|
409 } else {
|
Chris@211
|
410 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform"));
|
Chris@211
|
411 m_rightButtonTransformsMenu->setTearOffEnabled(true);
|
Chris@34
|
412 m_rightButtonMenu->addSeparator();
|
Chris@34
|
413 }
|
Chris@34
|
414
|
Chris@346
|
415 // This will be created (if not found) or cleared (if found) in
|
Chris@346
|
416 // setupPaneAndLayerMenus, but we want to ensure it's created
|
Chris@346
|
417 // sooner so it can go nearer the top of the right button menu
|
Chris@346
|
418 if (m_rightButtonLayerMenu) {
|
Chris@346
|
419 m_rightButtonLayerMenu->clear();
|
Chris@346
|
420 } else {
|
Chris@346
|
421 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
|
Chris@346
|
422 m_rightButtonLayerMenu->setTearOffEnabled(true);
|
Chris@346
|
423 m_rightButtonMenu->addSeparator();
|
Chris@346
|
424 }
|
Chris@346
|
425
|
Chris@0
|
426 if (!m_mainMenusCreated) {
|
Chris@0
|
427 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
428 m_rightButtonMenu->addSeparator();
|
Chris@66
|
429 }
|
Chris@66
|
430
|
Chris@66
|
431 setupFileMenu();
|
Chris@66
|
432 setupEditMenu();
|
Chris@66
|
433 setupViewMenu();
|
Chris@66
|
434 setupPaneAndLayerMenus();
|
Chris@211
|
435 setupTransformsMenu();
|
Chris@66
|
436
|
Chris@66
|
437 m_mainMenusCreated = true;
|
Chris@66
|
438 }
|
Chris@66
|
439
|
Chris@66
|
440 void
|
Chris@489
|
441 MainWindow::goFullScreen()
|
Chris@489
|
442 {
|
Chris@588
|
443 if (m_viewManager->getZoomWheelsEnabled()) {
|
Chris@588
|
444 // The wheels seem to end up in the wrong place in full-screen mode
|
Chris@588
|
445 toggleZoomWheels();
|
Chris@588
|
446 }
|
Chris@588
|
447
|
Chris@492
|
448 QWidget *ps = m_mainScroll->takeWidget();
|
Chris@492
|
449 ps->setParent(0);
|
Chris@494
|
450
|
Chris@494
|
451 QShortcut *sc;
|
Chris@494
|
452
|
Chris@494
|
453 sc = new QShortcut(QKeySequence("Esc"), ps);
|
Chris@494
|
454 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen()));
|
Chris@494
|
455
|
Chris@494
|
456 sc = new QShortcut(QKeySequence("F11"), ps);
|
Chris@494
|
457 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen()));
|
Chris@494
|
458
|
Chris@494
|
459 QAction *acts[] = {
|
Chris@494
|
460 m_playAction, m_zoomInAction, m_zoomOutAction, m_zoomFitAction,
|
Chris@494
|
461 m_scrollLeftAction, m_scrollRightAction, m_showPropertyBoxesAction
|
Chris@494
|
462 };
|
Chris@494
|
463
|
Chris@705
|
464 for (int i = 0; i < int(sizeof(acts)/sizeof(acts[0])); ++i) {
|
Chris@494
|
465 sc = new QShortcut(acts[i]->shortcut(), ps);
|
Chris@494
|
466 connect(sc, SIGNAL(activated()), acts[i], SLOT(trigger()));
|
Chris@494
|
467 }
|
Chris@494
|
468
|
Chris@492
|
469 ps->showFullScreen();
|
Chris@492
|
470 }
|
Chris@492
|
471
|
Chris@492
|
472 void
|
Chris@492
|
473 MainWindow::endFullScreen()
|
Chris@492
|
474 {
|
Chris@494
|
475 // these were only created in goFullScreen:
|
Chris@494
|
476 QObjectList cl = m_paneStack->children();
|
Chris@494
|
477 foreach (QObject *o, cl) {
|
Chris@494
|
478 QShortcut *sc = qobject_cast<QShortcut *>(o);
|
Chris@494
|
479 if (sc) delete sc;
|
Chris@494
|
480 }
|
Chris@494
|
481
|
Chris@588
|
482 m_paneStack->showNormal();
|
Chris@492
|
483 m_mainScroll->setWidget(m_paneStack);
|
Chris@489
|
484 }
|
Chris@489
|
485
|
Chris@489
|
486 void
|
Chris@66
|
487 MainWindow::setupFileMenu()
|
Chris@66
|
488 {
|
Chris@66
|
489 if (m_mainMenusCreated) return;
|
Chris@66
|
490
|
Chris@66
|
491 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@97
|
492 menu->setTearOffEnabled(true);
|
Chris@66
|
493 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@66
|
494
|
Chris@162
|
495 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@162
|
496
|
Chris@168
|
497 IconLoader il;
|
Chris@168
|
498
|
Chris@168
|
499 QIcon icon = il.load("filenew");
|
Chris@66
|
500 QAction *action = new QAction(icon, tr("&New Session"), this);
|
Chris@66
|
501 action->setShortcut(tr("Ctrl+N"));
|
Chris@518
|
502 action->setStatusTip(tr("Abandon the current %1 session and start a new one").arg(QApplication::applicationName()));
|
Chris@66
|
503 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
|
Chris@162
|
504 m_keyReference->registerShortcut(action);
|
Chris@66
|
505 menu->addAction(action);
|
Chris@66
|
506 toolbar->addAction(action);
|
Chris@518
|
507
|
Chris@168
|
508 icon = il.load("fileopen");
|
Chris@66
|
509 action = new QAction(icon, tr("&Open..."), this);
|
Chris@418
|
510 action->setShortcut(tr("Ctrl+O"));
|
Chris@66
|
511 action->setStatusTip(tr("Open a session file, audio file, or layer"));
|
Chris@66
|
512 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
|
Chris@705
|
513 m_keyReference->registerShortcut(action);
|
Chris@66
|
514 toolbar->addAction(action);
|
Chris@418
|
515 menu->addAction(action);
|
Chris@418
|
516
|
Chris@418
|
517 // We want this one to go on the toolbar now, if we add it at all,
|
Chris@418
|
518 // but on the menu later
|
Chris@418
|
519 QAction *iaction = new QAction(tr("&Import More Audio..."), this);
|
Chris@418
|
520 iaction->setShortcut(tr("Ctrl+I"));
|
Chris@418
|
521 iaction->setStatusTip(tr("Import an extra audio file into a new pane"));
|
Chris@418
|
522 connect(iaction, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
|
Chris@418
|
523 connect(this, SIGNAL(canImportMoreAudio(bool)), iaction, SLOT(setEnabled(bool)));
|
Chris@418
|
524 m_keyReference->registerShortcut(iaction);
|
Chris@418
|
525
|
Chris@508
|
526 // We want this one to go on the toolbar now, if we add it at all,
|
Chris@508
|
527 // but on the menu later
|
Chris@508
|
528 QAction *raction = new QAction(tr("Replace &Main Audio..."), this);
|
Chris@508
|
529 raction->setStatusTip(tr("Replace the main audio file of the session with a different file"));
|
Chris@508
|
530 connect(raction, SIGNAL(triggered()), this, SLOT(replaceMainAudio()));
|
Chris@508
|
531 connect(this, SIGNAL(canReplaceMainAudio(bool)), raction, SLOT(setEnabled(bool)));
|
Chris@508
|
532
|
Chris@418
|
533 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@418
|
534 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@418
|
535 action->setStatusTip(tr("Open or import a file from a remote URL"));
|
Chris@418
|
536 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@418
|
537 m_keyReference->registerShortcut(action);
|
Chris@418
|
538 menu->addAction(action);
|
Chris@418
|
539
|
Chris@420
|
540 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@418
|
541 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@418
|
542 setupRecentFilesMenu();
|
Chris@418
|
543 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@418
|
544 this, SLOT(setupRecentFilesMenu()));
|
Chris@418
|
545
|
Chris@418
|
546 menu->addSeparator();
|
Chris@415
|
547
|
Chris@168
|
548 icon = il.load("filesave");
|
Chris@66
|
549 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@66
|
550 action->setShortcut(tr("Ctrl+S"));
|
Chris@518
|
551 action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName()));
|
Chris@66
|
552 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@66
|
553 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
554 m_keyReference->registerShortcut(action);
|
Chris@66
|
555 menu->addAction(action);
|
Chris@66
|
556 toolbar->addAction(action);
|
Chris@1770
|
557
|
Chris@168
|
558 icon = il.load("filesaveas");
|
Chris@66
|
559 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@336
|
560 action->setShortcut(tr("Ctrl+Shift+S"));
|
Chris@518
|
561 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName()));
|
Chris@66
|
562 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@66
|
563 menu->addAction(action);
|
Chris@66
|
564 toolbar->addAction(action);
|
Chris@66
|
565
|
Chris@66
|
566 menu->addSeparator();
|
Chris@66
|
567
|
Chris@418
|
568 /*
|
Chris@168
|
569 icon = il.load("fileopenaudio");
|
Chris@138
|
570 action = new QAction(icon, tr("&Import Audio File..."), this);
|
Chris@66
|
571 action->setShortcut(tr("Ctrl+I"));
|
Chris@66
|
572 action->setStatusTip(tr("Import an existing audio file"));
|
Chris@66
|
573 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
|
Chris@162
|
574 m_keyReference->registerShortcut(action);
|
Chris@66
|
575 menu->addAction(action);
|
Chris@418
|
576 */
|
Chris@418
|
577
|
Chris@508
|
578 // the Replace action we made earlier
|
Chris@508
|
579 menu->addAction(raction);
|
Chris@508
|
580
|
Chris@418
|
581 // the Import action we made earlier
|
Chris@418
|
582 menu->addAction(iaction);
|
Chris@66
|
583
|
Chris@66
|
584 action = new QAction(tr("&Export Audio File..."), this);
|
Chris@66
|
585 action->setStatusTip(tr("Export selection as an audio file"));
|
Chris@66
|
586 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
|
Chris@66
|
587 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
588 menu->addAction(action);
|
Chris@66
|
589
|
Chris@66
|
590 menu->addSeparator();
|
Chris@66
|
591
|
Chris@66
|
592 action = new QAction(tr("Import Annotation &Layer..."), this);
|
Chris@66
|
593 action->setShortcut(tr("Ctrl+L"));
|
Chris@66
|
594 action->setStatusTip(tr("Import layer data from an existing file"));
|
Chris@66
|
595 connect(action, SIGNAL(triggered()), this, SLOT(importLayer()));
|
Chris@66
|
596 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
597 m_keyReference->registerShortcut(action);
|
Chris@66
|
598 menu->addAction(action);
|
Chris@66
|
599
|
Chris@977
|
600 action = new QAction(tr("Export Annotation La&yer..."), this);
|
Chris@977
|
601 action->setShortcut(tr("Ctrl+Y"));
|
Chris@66
|
602 action->setStatusTip(tr("Export layer data to a file"));
|
Chris@66
|
603 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer()));
|
Chris@66
|
604 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@977
|
605 m_keyReference->registerShortcut(action);
|
Chris@66
|
606 menu->addAction(action);
|
Chris@66
|
607
|
Chris@66
|
608 menu->addSeparator();
|
Chris@1912
|
609
|
Chris@1987
|
610 action = new QAction(tr("Import Audio from Data File..."), this);
|
Chris@1912
|
611 action->setStatusTip(tr("Import audio sample values from a CSV data file"));
|
Chris@1912
|
612 connect(action, SIGNAL(triggered()), this, SLOT(importAudioData()));
|
Chris@1912
|
613 menu->addAction(action);
|
Chris@1912
|
614
|
Chris@1987
|
615 action = new QAction(tr("Export Audio to Data File..."), this);
|
Chris@1912
|
616 action->setStatusTip(tr("Export audio from selection into a CSV data file"));
|
Chris@1912
|
617 connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData()));
|
Chris@1912
|
618 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1912
|
619 menu->addAction(action);
|
Chris@1912
|
620
|
Chris@1912
|
621 menu->addSeparator();
|
Chris@86
|
622
|
Chris@121
|
623 action = new QAction(tr("Export Image File..."), this);
|
Chris@121
|
624 action->setStatusTip(tr("Export a single pane to an image file"));
|
Chris@121
|
625 connect(action, SIGNAL(triggered()), this, SLOT(exportImage()));
|
Chris@121
|
626 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
|
Chris@121
|
627 menu->addAction(action);
|
Chris@121
|
628
|
Chris@1451
|
629 action = new QAction(tr("Export SVG File..."), this);
|
Chris@1451
|
630 action->setStatusTip(tr("Export a single pane to a scalable SVG image file"));
|
Chris@1451
|
631 connect(action, SIGNAL(triggered()), this, SLOT(exportSVG()));
|
Chris@1451
|
632 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1451
|
633 menu->addAction(action);
|
Chris@1451
|
634
|
Chris@121
|
635 menu->addSeparator();
|
Chris@121
|
636
|
Chris@1056
|
637 action = new QAction(tr("Browse Recorded Audio Folder"), this);
|
Chris@1056
|
638 action->setStatusTip(tr("Open the Recorded Audio folder in the system file browser"));
|
Chris@1056
|
639 connect(action, SIGNAL(triggered()), this, SLOT(browseRecordedAudio()));
|
Chris@1056
|
640 menu->addAction(action);
|
Chris@1056
|
641
|
Chris@1056
|
642 menu->addSeparator();
|
Chris@1056
|
643
|
Chris@435
|
644 QString templatesMenuLabel = tr("Apply Session Template");
|
Chris@425
|
645 m_templatesMenu = menu->addMenu(templatesMenuLabel);
|
Chris@425
|
646 m_templatesMenu->setTearOffEnabled(true);
|
Chris@436
|
647 // We need to have a main model for this option to be useful:
|
Chris@436
|
648 // canExportAudio captures that
|
Chris@436
|
649 connect(this, SIGNAL(canExportAudio(bool)), m_templatesMenu, SLOT(setEnabled(bool)));
|
Chris@436
|
650
|
Chris@436
|
651 // Set up the menu in a moment, after m_manageTemplatesAction constructed
|
Chris@435
|
652
|
Chris@435
|
653 action = new QAction(tr("Export Session as Template..."), this);
|
Chris@435
|
654 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAsTemplate()));
|
Chris@436
|
655 // We need to have something in the session for this to be useful:
|
Chris@436
|
656 // canDeleteCurrentLayer captures that
|
Chris@436
|
657 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@435
|
658 menu->addAction(action);
|
Chris@435
|
659
|
Chris@436
|
660 m_manageTemplatesAction = new QAction(tr("Manage Exported Templates"), this);
|
Chris@436
|
661 connect(m_manageTemplatesAction, SIGNAL(triggered()), this, SLOT(manageSavedTemplates()));
|
Chris@436
|
662 menu->addAction(m_manageTemplatesAction);
|
Chris@436
|
663
|
Chris@436
|
664 setupTemplatesMenu();
|
Chris@425
|
665
|
Chris@66
|
666 action = new QAction(tr("&Preferences..."), this);
|
Chris@66
|
667 action->setStatusTip(tr("Adjust the application preferences"));
|
Chris@66
|
668 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
|
Chris@66
|
669 menu->addAction(action);
|
Chris@1770
|
670
|
Chris@66
|
671 menu->addSeparator();
|
Chris@168
|
672 action = new QAction(il.load("exit"),
|
Chris@66
|
673 tr("&Quit"), this);
|
Chris@66
|
674 action->setShortcut(tr("Ctrl+Q"));
|
Chris@518
|
675 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@500
|
676 connect(action, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
|
Chris@162
|
677 m_keyReference->registerShortcut(action);
|
Chris@66
|
678 menu->addAction(action);
|
Chris@66
|
679 }
|
Chris@66
|
680
|
Chris@66
|
681 void
|
Chris@66
|
682 MainWindow::setupEditMenu()
|
Chris@66
|
683 {
|
Chris@66
|
684 if (m_mainMenusCreated) return;
|
Chris@66
|
685
|
Chris@66
|
686 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@97
|
687 menu->setTearOffEnabled(true);
|
Chris@66
|
688 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@66
|
689
|
Chris@162
|
690 m_keyReference->setCategory(tr("Editing"));
|
Chris@162
|
691
|
Chris@66
|
692 menu->addSeparator();
|
Chris@66
|
693
|
Chris@168
|
694 IconLoader il;
|
Chris@168
|
695
|
Chris@168
|
696 QAction *action = new QAction(il.load("editcut"),
|
Chris@66
|
697 tr("Cu&t"), this);
|
Chris@66
|
698 action->setShortcut(tr("Ctrl+X"));
|
Chris@90
|
699 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard"));
|
Chris@66
|
700 connect(action, SIGNAL(triggered()), this, SLOT(cut()));
|
Chris@66
|
701 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
702 m_keyReference->registerShortcut(action);
|
Chris@66
|
703 menu->addAction(action);
|
Chris@66
|
704 m_rightButtonMenu->addAction(action);
|
Chris@66
|
705
|
Chris@168
|
706 action = new QAction(il.load("editcopy"),
|
Chris@66
|
707 tr("&Copy"), this);
|
Chris@66
|
708 action->setShortcut(tr("Ctrl+C"));
|
Chris@90
|
709 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard"));
|
Chris@66
|
710 connect(action, SIGNAL(triggered()), this, SLOT(copy()));
|
Chris@66
|
711 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
712 m_keyReference->registerShortcut(action);
|
Chris@66
|
713 menu->addAction(action);
|
Chris@66
|
714 m_rightButtonMenu->addAction(action);
|
Chris@66
|
715
|
Chris@168
|
716 action = new QAction(il.load("editpaste"),
|
Chris@66
|
717 tr("&Paste"), this);
|
Chris@66
|
718 action->setShortcut(tr("Ctrl+V"));
|
Chris@90
|
719 action->setStatusTip(tr("Paste from the clipboard to the current layer"));
|
Chris@66
|
720 connect(action, SIGNAL(triggered()), this, SLOT(paste()));
|
Chris@66
|
721 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
722 m_keyReference->registerShortcut(action);
|
Chris@66
|
723 menu->addAction(action);
|
Chris@66
|
724 m_rightButtonMenu->addAction(action);
|
Chris@66
|
725
|
Chris@395
|
726 action = new QAction(tr("Paste at Playback Position"), this);
|
Chris@395
|
727 action->setShortcut(tr("Ctrl+Shift+V"));
|
Chris@395
|
728 action->setStatusTip(tr("Paste from the clipboard to the current layer, placing the first item at the playback position"));
|
Chris@395
|
729 connect(action, SIGNAL(triggered()), this, SLOT(pasteAtPlaybackPosition()));
|
Chris@395
|
730 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
|
Chris@395
|
731 m_keyReference->registerShortcut(action);
|
Chris@395
|
732 menu->addAction(action);
|
Chris@395
|
733 m_rightButtonMenu->addAction(action);
|
Chris@395
|
734
|
Chris@164
|
735 m_deleteSelectedAction = new QAction(tr("&Delete Selected Items"), this);
|
Chris@164
|
736 m_deleteSelectedAction->setShortcut(tr("Del"));
|
Chris@164
|
737 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
|
Chris@164
|
738 connect(m_deleteSelectedAction, SIGNAL(triggered()), this, SLOT(deleteSelected()));
|
Chris@164
|
739 connect(this, SIGNAL(canDeleteSelection(bool)), m_deleteSelectedAction, SLOT(setEnabled(bool)));
|
Chris@164
|
740 m_keyReference->registerShortcut(m_deleteSelectedAction);
|
Chris@164
|
741 menu->addAction(m_deleteSelectedAction);
|
Chris@164
|
742 m_rightButtonMenu->addAction(m_deleteSelectedAction);
|
Chris@66
|
743
|
Chris@66
|
744 menu->addSeparator();
|
Chris@66
|
745 m_rightButtonMenu->addSeparator();
|
Chris@162
|
746
|
Chris@162
|
747 m_keyReference->setCategory(tr("Selection"));
|
Chris@162
|
748
|
Chris@66
|
749 action = new QAction(tr("Select &All"), this);
|
Chris@66
|
750 action->setShortcut(tr("Ctrl+A"));
|
Chris@90
|
751 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@66
|
752 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@66
|
753 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
754 m_keyReference->registerShortcut(action);
|
Chris@66
|
755 menu->addAction(action);
|
Chris@66
|
756 m_rightButtonMenu->addAction(action);
|
Chris@1770
|
757
|
Chris@66
|
758 action = new QAction(tr("Select &Visible Range"), this);
|
Chris@66
|
759 action->setShortcut(tr("Ctrl+Shift+A"));
|
Chris@90
|
760 action->setStatusTip(tr("Select the time range corresponding to the current window width"));
|
Chris@66
|
761 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible()));
|
Chris@66
|
762 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
763 m_keyReference->registerShortcut(action);
|
Chris@66
|
764 menu->addAction(action);
|
Chris@1770
|
765
|
Chris@66
|
766 action = new QAction(tr("Select to &Start"), this);
|
Chris@66
|
767 action->setShortcut(tr("Shift+Left"));
|
Chris@90
|
768 action->setStatusTip(tr("Select from the start of the session to the current playback position"));
|
Chris@66
|
769 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart()));
|
Chris@66
|
770 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
771 m_keyReference->registerShortcut(action);
|
Chris@66
|
772 menu->addAction(action);
|
Chris@1770
|
773
|
Chris@66
|
774 action = new QAction(tr("Select to &End"), this);
|
Chris@66
|
775 action->setShortcut(tr("Shift+Right"));
|
Chris@90
|
776 action->setStatusTip(tr("Select from the current playback position to the end of the session"));
|
Chris@66
|
777 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd()));
|
Chris@66
|
778 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
779 m_keyReference->registerShortcut(action);
|
Chris@66
|
780 menu->addAction(action);
|
Chris@66
|
781
|
Chris@66
|
782 action = new QAction(tr("C&lear Selection"), this);
|
Chris@66
|
783 action->setShortcut(tr("Esc"));
|
Chris@90
|
784 action->setStatusTip(tr("Clear the selection"));
|
Chris@66
|
785 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
Chris@66
|
786 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
787 m_keyReference->registerShortcut(action);
|
Chris@66
|
788 menu->addAction(action);
|
Chris@66
|
789 m_rightButtonMenu->addAction(action);
|
Chris@66
|
790
|
Chris@66
|
791 menu->addSeparator();
|
Chris@66
|
792
|
Chris@162
|
793 m_keyReference->setCategory(tr("Tapping Time Instants"));
|
Chris@162
|
794
|
Chris@66
|
795 action = new QAction(tr("&Insert Instant at Playback Position"), this);
|
Chris@1782
|
796 action->setShortcut(tr(";"));
|
Chris@90
|
797 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary"));
|
Chris@66
|
798 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
|
Chris@66
|
799 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
800 m_keyReference->registerShortcut(action);
|
Chris@66
|
801 menu->addAction(action);
|
Chris@66
|
802
|
Chris@1782
|
803 // Historically this was the main shortcut for "Insert Instant at
|
Chris@1782
|
804 // Playback Position". Note that Enter refers to the keypad key,
|
Chris@1782
|
805 // rather than the Return key, so this doesn't actually exist on
|
Chris@1782
|
806 // many keyboards now. Accordingly the alternative shortcut ";"
|
Chris@1782
|
807 // has been promoted to primary, listed above. Same goes for the
|
Chris@1782
|
808 // shifted version below
|
Chris@1782
|
809 QString shortcut(tr("Enter"));
|
Chris@162
|
810 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@162
|
811 this, SLOT(insertInstant()));
|
Chris@162
|
812 m_keyReference->registerAlternativeShortcut(action, shortcut);
|
Chris@162
|
813
|
Chris@81
|
814 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
|
Chris@1782
|
815 action->setShortcut(tr("Shift+;"));
|
Chris@163
|
816 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
|
817 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
|
Chris@81
|
818 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
819 m_keyReference->registerShortcut(action);
|
Chris@81
|
820 menu->addAction(action);
|
Chris@189
|
821
|
Chris@1782
|
822 shortcut = QString(tr("Shift+Enter"));
|
Chris@1782
|
823 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@1782
|
824 this, SLOT(insertInstantsAtBoundaries()));
|
Chris@1782
|
825 m_keyReference->registerAlternativeShortcut(action, shortcut);
|
Chris@1782
|
826
|
Chris@1782
|
827 // The previous two actions used shortcuts with the (keypad) Enter
|
Chris@1782
|
828 // key, while this one I (bizarrely) switched from Enter to Return
|
Chris@1782
|
829 // in September 2014. Let's make it consistent with the above by
|
Chris@1782
|
830 // making the primary shortcut for it Ctrl+Shift+; and keeping
|
Chris@1782
|
831 // both Return and Enter as synonyms for ;
|
Chris@338
|
832 action = new QAction(tr("Insert Item at Selection"), this);
|
Chris@1782
|
833 action->setShortcut(tr("Ctrl+Shift+;"));
|
Chris@338
|
834 action->setStatusTip(tr("Insert a new note or region item corresponding to the current selection"));
|
Chris@338
|
835 connect(action, SIGNAL(triggered()), this, SLOT(insertItemAtSelection()));
|
Chris@338
|
836 connect(this, SIGNAL(canInsertItemAtSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@338
|
837 m_keyReference->registerShortcut(action);
|
Chris@338
|
838 menu->addAction(action);
|
Chris@338
|
839
|
Chris@1782
|
840 shortcut = QString(tr("Ctrl+Shift+Enter"));
|
Chris@1782
|
841 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@1782
|
842 this, SLOT(insertItemAtSelection()));
|
Chris@1782
|
843 m_keyReference->registerAlternativeShortcut(action, shortcut);
|
Chris@1782
|
844
|
Chris@1782
|
845 shortcut = QString(tr("Ctrl+Shift+Return"));
|
Chris@1782
|
846 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@1782
|
847 this, SLOT(insertItemAtSelection()));
|
Chris@1782
|
848 // we had that one for historical compatibility, but let's not
|
Chris@1782
|
849 // register it publicly; having three shortcuts for such an
|
Chris@1782
|
850 // obscure function is really over-egging it
|
Chris@1782
|
851
|
Chris@338
|
852 menu->addSeparator();
|
Chris@338
|
853
|
Chris@190
|
854 QMenu *numberingMenu = menu->addMenu(tr("Number New Instants with"));
|
Chris@225
|
855 numberingMenu->setTearOffEnabled(true);
|
Chris@189
|
856 QActionGroup *numberingGroup = new QActionGroup(this);
|
Chris@189
|
857
|
Chris@189
|
858 Labeller::TypeNameMap types = m_labeller->getTypeNames();
|
Chris@189
|
859 for (Labeller::TypeNameMap::iterator i = types.begin(); i != types.end(); ++i) {
|
Chris@190
|
860
|
Chris@190
|
861 if (i->first == Labeller::ValueFromLabel ||
|
Chris@190
|
862 i->first == Labeller::ValueFromExistingNeighbour) continue;
|
Chris@190
|
863
|
Chris@189
|
864 action = new QAction(i->second, this);
|
Chris@189
|
865 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsNumbering()));
|
Chris@189
|
866 action->setCheckable(true);
|
Chris@189
|
867 action->setChecked(m_labeller->getType() == i->first);
|
Chris@189
|
868 numberingGroup->addAction(action);
|
Chris@189
|
869 numberingMenu->addAction(action);
|
Chris@189
|
870 m_numberingActions[action] = (int)i->first;
|
Chris@190
|
871
|
Chris@190
|
872 if (i->first == Labeller::ValueFromTwoLevelCounter) {
|
Chris@192
|
873
|
Chris@190
|
874 QMenu *cycleMenu = numberingMenu->addMenu(tr("Cycle size"));
|
Chris@190
|
875 QActionGroup *cycleGroup = new QActionGroup(this);
|
Chris@190
|
876
|
Chris@229
|
877 int cycles[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16 };
|
Chris@200
|
878 for (int i = 0; i < int(sizeof(cycles)/sizeof(cycles[0])); ++i) {
|
Chris@190
|
879 action = new QAction(QString("%1").arg(cycles[i]), this);
|
Chris@190
|
880 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounterCycle()));
|
Chris@190
|
881 action->setCheckable(true);
|
Chris@190
|
882 action->setChecked(cycles[i] == m_labeller->getCounterCycleSize());
|
Chris@190
|
883 cycleGroup->addAction(action);
|
Chris@190
|
884 cycleMenu->addAction(action);
|
Chris@190
|
885 }
|
Chris@190
|
886 }
|
Chris@190
|
887
|
Chris@190
|
888 if (i->first == Labeller::ValueNone ||
|
Chris@190
|
889 i->first == Labeller::ValueFromTwoLevelCounter ||
|
Chris@190
|
890 i->first == Labeller::ValueFromRealTime) {
|
Chris@190
|
891 numberingMenu->addSeparator();
|
Chris@190
|
892 }
|
Chris@189
|
893 }
|
Chris@189
|
894
|
Chris@597
|
895 action = new QAction(tr("Reset Numbering Counters"), this);
|
Chris@597
|
896 action->setStatusTip(tr("Reset to 1 all the counters used for counter-based labelling"));
|
Chris@597
|
897 connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
|
Chris@597
|
898 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@597
|
899 menu->addAction(action);
|
Chris@597
|
900
|
Chris@241
|
901 action = new QAction(tr("Set Numbering Counters..."), this);
|
Chris@241
|
902 action->setStatusTip(tr("Set the counters used for counter-based labelling"));
|
Chris@597
|
903 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounters()));
|
Chris@241
|
904 menu->addAction(action);
|
Chris@241
|
905
|
Chris@241
|
906 action = new QAction(tr("Renumber Selected Instants"), this);
|
Chris@241
|
907 action->setStatusTip(tr("Renumber the selected instants using the current labelling scheme"));
|
Chris@189
|
908 connect(action, SIGNAL(triggered()), this, SLOT(renumberInstants()));
|
Chris@189
|
909 connect(this, SIGNAL(canRenumberInstants(bool)), action, SLOT(setEnabled(bool)));
|
Chris@189
|
910 // m_keyReference->registerShortcut(action);
|
Chris@189
|
911 menu->addAction(action);
|
Chris@1356
|
912
|
Chris@1356
|
913 menu->addSeparator();
|
Chris@1356
|
914
|
Chris@1355
|
915 action = new QAction(tr("Subdivide Selected Instants..."), this);
|
Chris@1355
|
916 action->setStatusTip(tr("Add new instants at regular intervals between the selected instants"));
|
Chris@1355
|
917 connect(action, SIGNAL(triggered()), this, SLOT(subdivideInstants()));
|
Chris@1355
|
918 connect(this, SIGNAL(canSubdivideInstants(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1355
|
919 menu->addAction(action);
|
Chris@1356
|
920
|
Chris@1356
|
921 action = new QAction(tr("Winnow Selected Instants..."), this);
|
Chris@1356
|
922 action->setStatusTip(tr("Remove subdivisions, leaving only every Nth instant"));
|
Chris@1356
|
923 connect(action, SIGNAL(triggered()), this, SLOT(winnowInstants()));
|
Chris@1356
|
924 connect(this, SIGNAL(canWinnowInstants(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1356
|
925 menu->addAction(action);
|
Chris@66
|
926 }
|
Chris@66
|
927
|
Chris@66
|
928 void
|
Chris@66
|
929 MainWindow::setupViewMenu()
|
Chris@66
|
930 {
|
Chris@66
|
931 if (m_mainMenusCreated) return;
|
Chris@66
|
932
|
Chris@168
|
933 IconLoader il;
|
Chris@168
|
934
|
Chris@90
|
935 QAction *action = 0;
|
Chris@90
|
936
|
Chris@162
|
937 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@162
|
938
|
Chris@66
|
939 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@97
|
940 menu->setTearOffEnabled(true);
|
Chris@494
|
941 m_scrollLeftAction = new QAction(tr("Scroll &Left"), this);
|
Chris@494
|
942 m_scrollLeftAction->setShortcut(tr("Left"));
|
Chris@494
|
943 m_scrollLeftAction->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@494
|
944 connect(m_scrollLeftAction, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@494
|
945 connect(this, SIGNAL(canScroll(bool)), m_scrollLeftAction, SLOT(setEnabled(bool)));
|
Chris@494
|
946 m_keyReference->registerShortcut(m_scrollLeftAction);
|
Chris@494
|
947 menu->addAction(m_scrollLeftAction);
|
Chris@1770
|
948
|
Chris@494
|
949 m_scrollRightAction = new QAction(tr("Scroll &Right"), this);
|
Chris@494
|
950 m_scrollRightAction->setShortcut(tr("Right"));
|
Chris@494
|
951 m_scrollRightAction->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@494
|
952 connect(m_scrollRightAction, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@494
|
953 connect(this, SIGNAL(canScroll(bool)), m_scrollRightAction, SLOT(setEnabled(bool)));
|
Chris@494
|
954 m_keyReference->registerShortcut(m_scrollRightAction);
|
Chris@494
|
955 menu->addAction(m_scrollRightAction);
|
Chris@1770
|
956
|
Chris@90
|
957 action = new QAction(tr("&Jump Left"), this);
|
Chris@66
|
958 action->setShortcut(tr("Ctrl+Left"));
|
Chris@66
|
959 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@66
|
960 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@66
|
961 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
962 m_keyReference->registerShortcut(action);
|
Chris@66
|
963 menu->addAction(action);
|
Chris@1770
|
964
|
Chris@90
|
965 action = new QAction(tr("J&ump Right"), this);
|
Chris@66
|
966 action->setShortcut(tr("Ctrl+Right"));
|
Chris@66
|
967 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@66
|
968 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@66
|
969 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
970 m_keyReference->registerShortcut(action);
|
Chris@66
|
971 menu->addAction(action);
|
Chris@66
|
972
|
Chris@308
|
973 action = new QAction(tr("Peek Left"), this);
|
Chris@308
|
974 action->setShortcut(tr("Alt+Left"));
|
Chris@308
|
975 action->setStatusTip(tr("Scroll the current pane to the left without moving the playback cursor or other panes"));
|
Chris@308
|
976 connect(action, SIGNAL(triggered()), this, SLOT(peekLeft()));
|
Chris@308
|
977 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@308
|
978 m_keyReference->registerShortcut(action);
|
Chris@308
|
979 menu->addAction(action);
|
Chris@1770
|
980
|
Chris@308
|
981 action = new QAction(tr("Peek Right"), this);
|
Chris@308
|
982 action->setShortcut(tr("Alt+Right"));
|
Chris@308
|
983 action->setStatusTip(tr("Scroll the current pane to the right without moving the playback cursor or other panes"));
|
Chris@308
|
984 connect(action, SIGNAL(triggered()), this, SLOT(peekRight()));
|
Chris@308
|
985 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@308
|
986 m_keyReference->registerShortcut(action);
|
Chris@308
|
987 menu->addAction(action);
|
Chris@308
|
988
|
Chris@66
|
989 menu->addSeparator();
|
Chris@66
|
990
|
Chris@162
|
991 m_keyReference->setCategory(tr("Zoom"));
|
Chris@162
|
992
|
Chris@494
|
993 m_zoomInAction = new QAction(il.load("zoom-in"),
|
Chris@494
|
994 tr("Zoom &In"), this);
|
Chris@494
|
995 m_zoomInAction->setShortcut(tr("Up"));
|
Chris@494
|
996 m_zoomInAction->setStatusTip(tr("Increase the zoom level"));
|
Chris@494
|
997 connect(m_zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@494
|
998 connect(this, SIGNAL(canZoom(bool)), m_zoomInAction, SLOT(setEnabled(bool)));
|
Chris@494
|
999 m_keyReference->registerShortcut(m_zoomInAction);
|
Chris@494
|
1000 menu->addAction(m_zoomInAction);
|
Chris@1770
|
1001
|
Chris@494
|
1002 m_zoomOutAction = new QAction(il.load("zoom-out"),
|
Chris@494
|
1003 tr("Zoom &Out"), this);
|
Chris@494
|
1004 m_zoomOutAction->setShortcut(tr("Down"));
|
Chris@494
|
1005 m_zoomOutAction->setStatusTip(tr("Decrease the zoom level"));
|
Chris@494
|
1006 connect(m_zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@494
|
1007 connect(this, SIGNAL(canZoom(bool)), m_zoomOutAction, SLOT(setEnabled(bool)));
|
Chris@494
|
1008 m_keyReference->registerShortcut(m_zoomOutAction);
|
Chris@494
|
1009 menu->addAction(m_zoomOutAction);
|
Chris@1770
|
1010
|
Chris@66
|
1011 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@90
|
1012 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@66
|
1013 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@66
|
1014 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
1015 menu->addAction(action);
|
Chris@66
|
1016
|
Chris@494
|
1017 m_zoomFitAction = new QAction(il.load("zoom-fit"),
|
Chris@494
|
1018 tr("Zoom to &Fit"), this);
|
Chris@494
|
1019 m_zoomFitAction->setShortcut(tr("F"));
|
Chris@494
|
1020 m_zoomFitAction->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@494
|
1021 connect(m_zoomFitAction, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@494
|
1022 connect(this, SIGNAL(canZoom(bool)), m_zoomFitAction, SLOT(setEnabled(bool)));
|
Chris@494
|
1023 m_keyReference->registerShortcut(m_zoomFitAction);
|
Chris@494
|
1024 menu->addAction(m_zoomFitAction);
|
Chris@90
|
1025
|
Chris@90
|
1026 menu->addSeparator();
|
Chris@90
|
1027
|
Chris@162
|
1028 m_keyReference->setCategory(tr("Display Features"));
|
Chris@162
|
1029
|
Chris@497
|
1030 action = new QAction(tr("Show &Centre Line"), this);
|
Chris@497
|
1031 action->setShortcut(tr("'"));
|
Chris@497
|
1032 action->setStatusTip(tr("Show or hide the centre line"));
|
Chris@497
|
1033 connect(action, SIGNAL(triggered()), this, SLOT(toggleCentreLine()));
|
Chris@497
|
1034 action->setCheckable(true);
|
Chris@703
|
1035 action->setChecked(m_viewManager->shouldShowCentreLine());
|
Chris@497
|
1036 m_keyReference->registerShortcut(action);
|
Chris@497
|
1037 menu->addAction(action);
|
Chris@497
|
1038
|
Chris@497
|
1039 action = new QAction(tr("Toggle All Time Rulers"), this);
|
Chris@497
|
1040 action->setShortcut(tr("#"));
|
Chris@497
|
1041 action->setStatusTip(tr("Show or hide all time rulers"));
|
Chris@497
|
1042 connect(action, SIGNAL(triggered()), this, SLOT(toggleTimeRulers()));
|
Chris@497
|
1043 m_keyReference->registerShortcut(action);
|
Chris@497
|
1044 menu->addAction(action);
|
Chris@497
|
1045
|
Chris@497
|
1046 menu->addSeparator();
|
Chris@497
|
1047
|
Chris@90
|
1048 QActionGroup *overlayGroup = new QActionGroup(this);
|
Chris@90
|
1049
|
Chris@703
|
1050 ViewManager::OverlayMode mode = m_viewManager->getOverlayMode();
|
Chris@703
|
1051
|
Chris@90
|
1052 action = new QAction(tr("Show &No Overlays"), this);
|
Chris@90
|
1053 action->setShortcut(tr("0"));
|
Chris@497
|
1054 action->setStatusTip(tr("Hide times, layer names, and scale"));
|
Chris@90
|
1055 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays()));
|
Chris@90
|
1056 action->setCheckable(true);
|
Chris@703
|
1057 action->setChecked(mode == ViewManager::NoOverlays);
|
Chris@90
|
1058 overlayGroup->addAction(action);
|
Chris@162
|
1059 m_keyReference->registerShortcut(action);
|
Chris@90
|
1060 menu->addAction(action);
|
Chris@90
|
1061
|
Chris@90
|
1062 action = new QAction(tr("Show &Minimal Overlays"), this);
|
Chris@90
|
1063 action->setShortcut(tr("9"));
|
Chris@497
|
1064 action->setStatusTip(tr("Show times and basic scale"));
|
Chris@90
|
1065 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays()));
|
Chris@90
|
1066 action->setCheckable(true);
|
Chris@715
|
1067 action->setChecked(mode == ViewManager::StandardOverlays);
|
Chris@90
|
1068 overlayGroup->addAction(action);
|
Chris@162
|
1069 m_keyReference->registerShortcut(action);
|
Chris@90
|
1070 menu->addAction(action);
|
Chris@90
|
1071
|
Chris@90
|
1072 action = new QAction(tr("Show &All Overlays"), this);
|
Chris@497
|
1073 action->setShortcut(tr("8"));
|
Chris@497
|
1074 action->setStatusTip(tr("Show times, layer names, and scale"));
|
Chris@90
|
1075 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays()));
|
Chris@90
|
1076 action->setCheckable(true);
|
Chris@703
|
1077 action->setChecked(mode == ViewManager::AllOverlays);
|
Chris@90
|
1078 overlayGroup->addAction(action);
|
Chris@162
|
1079 m_keyReference->registerShortcut(action);
|
Chris@90
|
1080 menu->addAction(action);
|
Chris@387
|
1081
|
Chris@387
|
1082 menu->addSeparator();
|
Chris@497
|
1083
|
Chris@66
|
1084 action = new QAction(tr("Show &Zoom Wheels"), this);
|
Chris@66
|
1085 action->setShortcut(tr("Z"));
|
Chris@66
|
1086 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically"));
|
Chris@66
|
1087 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels()));
|
Chris@66
|
1088 action->setCheckable(true);
|
Chris@66
|
1089 action->setChecked(m_viewManager->getZoomWheelsEnabled());
|
Chris@162
|
1090 m_keyReference->registerShortcut(action);
|
Chris@66
|
1091 menu->addAction(action);
|
Chris@387
|
1092
|
Chris@494
|
1093 m_showPropertyBoxesAction = new QAction(tr("Show Property Bo&xes"), this);
|
Chris@494
|
1094 m_showPropertyBoxesAction->setShortcut(tr("X"));
|
Chris@494
|
1095 m_showPropertyBoxesAction->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
|
Chris@494
|
1096 connect(m_showPropertyBoxesAction, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
|
Chris@494
|
1097 m_showPropertyBoxesAction->setCheckable(true);
|
Chris@494
|
1098 m_showPropertyBoxesAction->setChecked(true);
|
Chris@494
|
1099 m_keyReference->registerShortcut(m_showPropertyBoxesAction);
|
Chris@494
|
1100 menu->addAction(m_showPropertyBoxesAction);
|
Chris@0
|
1101
|
Chris@90
|
1102 action = new QAction(tr("Show Status &Bar"), this);
|
Chris@90
|
1103 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
|
Chris@90
|
1104 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
|
Chris@90
|
1105 action->setCheckable(true);
|
Chris@90
|
1106 action->setChecked(true);
|
Chris@90
|
1107 menu->addAction(action);
|
Chris@90
|
1108
|
Chris@90
|
1109 QSettings settings;
|
Chris@90
|
1110 settings.beginGroup("MainWindow");
|
Chris@90
|
1111 bool sb = settings.value("showstatusbar", true).toBool();
|
Chris@90
|
1112 if (!sb) {
|
Chris@90
|
1113 action->setChecked(false);
|
Chris@90
|
1114 statusBar()->hide();
|
Chris@90
|
1115 }
|
Chris@90
|
1116 settings.endGroup();
|
Chris@90
|
1117
|
Chris@66
|
1118 menu->addSeparator();
|
Chris@66
|
1119
|
Chris@219
|
1120 action = new QAction(tr("Show La&yer Summary"), this);
|
Chris@219
|
1121 action->setShortcut(tr("Y"));
|
Chris@90
|
1122 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session"));
|
Chris@66
|
1123 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree()));
|
Chris@162
|
1124 m_keyReference->registerShortcut(action);
|
Chris@66
|
1125 menu->addAction(action);
|
Chris@306
|
1126
|
Chris@306
|
1127 action = new QAction(tr("Show Acti&vity Log"), this);
|
Chris@306
|
1128 action->setStatusTip(tr("Open a window listing interactions and other events"));
|
Chris@306
|
1129 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog()));
|
Chris@306
|
1130 menu->addAction(action);
|
Chris@493
|
1131
|
Chris@891
|
1132 action = new QAction(tr("Show &Unit Converter"), this);
|
Chris@891
|
1133 action->setStatusTip(tr("Open a window of pitch and timing conversion utilities"));
|
Chris@891
|
1134 connect(action, SIGNAL(triggered()), this, SLOT(showUnitConverter()));
|
Chris@891
|
1135 menu->addAction(action);
|
Chris@891
|
1136
|
Chris@494
|
1137 menu->addSeparator();
|
Chris@494
|
1138
|
Chris@1387
|
1139 #ifndef Q_OS_MAC
|
Chris@1387
|
1140 // Only on non-Mac platforms -- on the Mac this interacts very
|
Chris@1387
|
1141 // badly with the "native" full-screen mode
|
Chris@493
|
1142 action = new QAction(tr("Go Full-Screen"), this);
|
Chris@494
|
1143 action->setShortcut(tr("F11"));
|
Chris@494
|
1144 action->setStatusTip(tr("Expand the pane area to the whole screen"));
|
Chris@493
|
1145 connect(action, SIGNAL(triggered()), this, SLOT(goFullScreen()));
|
Chris@494
|
1146 m_keyReference->registerShortcut(action);
|
Chris@493
|
1147 menu->addAction(action);
|
Chris@1387
|
1148 #endif
|
Chris@66
|
1149 }
|
Chris@66
|
1150
|
Chris@1794
|
1151 QString
|
Chris@1794
|
1152 MainWindow::shortcutFor(LayerFactory::LayerType layer, bool isPaneMenu)
|
Chris@1794
|
1153 {
|
Chris@1794
|
1154 QString shortcutText;
|
Chris@1794
|
1155
|
Chris@1794
|
1156 #ifdef __GNUC__
|
Chris@1794
|
1157 #pragma GCC diagnostic ignored "-Wswitch-enum"
|
Chris@1794
|
1158 #endif
|
Chris@1794
|
1159
|
Chris@1794
|
1160 switch (layer) {
|
Chris@1794
|
1161 case LayerFactory::Waveform:
|
Chris@1794
|
1162 if (isPaneMenu) {
|
Chris@1794
|
1163 shortcutText = tr("W");
|
Chris@1794
|
1164 } else {
|
Chris@1794
|
1165 shortcutText = tr("Shift+W");
|
Chris@1794
|
1166 }
|
Chris@1794
|
1167 break;
|
Chris@1794
|
1168
|
Chris@1794
|
1169 case LayerFactory::Spectrogram:
|
Chris@1794
|
1170 if (isPaneMenu) {
|
Chris@1794
|
1171 shortcutText = tr("G");
|
Chris@1794
|
1172 } else {
|
Chris@1794
|
1173 shortcutText = tr("Shift+G");
|
Chris@1794
|
1174 }
|
Chris@1794
|
1175 break;
|
Chris@1794
|
1176
|
Chris@1794
|
1177 case LayerFactory::MelodicRangeSpectrogram:
|
Chris@1794
|
1178 if (isPaneMenu) {
|
Chris@1794
|
1179 shortcutText = tr("M");
|
Chris@1794
|
1180 } else {
|
Chris@1794
|
1181 shortcutText = tr("Shift+M");
|
Chris@1794
|
1182 }
|
Chris@1794
|
1183 break;
|
Chris@1794
|
1184
|
Chris@1794
|
1185 case LayerFactory::PeakFrequencySpectrogram:
|
Chris@1794
|
1186 if (isPaneMenu) {
|
Chris@1794
|
1187 shortcutText = tr("K");
|
Chris@1794
|
1188 } else {
|
Chris@1794
|
1189 shortcutText = tr("Shift+K");
|
Chris@1794
|
1190 }
|
Chris@1794
|
1191 break;
|
Chris@1794
|
1192
|
Chris@1794
|
1193 case LayerFactory::Spectrum:
|
Chris@1794
|
1194 if (isPaneMenu) {
|
Chris@1794
|
1195 shortcutText = tr("U");
|
Chris@1794
|
1196 } else {
|
Chris@1794
|
1197 shortcutText = tr("Shift+U");
|
Chris@1794
|
1198 }
|
Chris@1794
|
1199 break;
|
Chris@1794
|
1200
|
Chris@1794
|
1201 default:
|
Chris@1794
|
1202 break;
|
Chris@1794
|
1203 }
|
Chris@1794
|
1204
|
Chris@1794
|
1205 return shortcutText;
|
Chris@1794
|
1206 }
|
Chris@1794
|
1207
|
Chris@66
|
1208 void
|
Chris@66
|
1209 MainWindow::setupPaneAndLayerMenus()
|
Chris@66
|
1210 {
|
Chris@0
|
1211 if (m_paneMenu) {
|
Chris@1770
|
1212 m_paneActions.clear();
|
Chris@1770
|
1213 m_paneMenu->clear();
|
Chris@0
|
1214 } else {
|
Chris@1770
|
1215 m_paneMenu = menuBar()->addMenu(tr("&Pane"));
|
Chris@97
|
1216 m_paneMenu->setTearOffEnabled(true);
|
Chris@0
|
1217 }
|
Chris@0
|
1218
|
Chris@0
|
1219 if (m_layerMenu) {
|
Chris@1770
|
1220 m_layerActions.clear();
|
Chris@1770
|
1221 m_layerMenu->clear();
|
Chris@0
|
1222 } else {
|
Chris@1770
|
1223 m_layerMenu = menuBar()->addMenu(tr("&Layer"));
|
Chris@97
|
1224 m_layerMenu->setTearOffEnabled(true);
|
Chris@0
|
1225 }
|
Chris@0
|
1226
|
Chris@345
|
1227 if (m_rightButtonLayerMenu) {
|
Chris@345
|
1228 m_rightButtonLayerMenu->clear();
|
Chris@345
|
1229 } else {
|
Chris@345
|
1230 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
|
Chris@345
|
1231 m_rightButtonLayerMenu->setTearOffEnabled(true);
|
Chris@345
|
1232 m_rightButtonMenu->addSeparator();
|
Chris@345
|
1233 }
|
Chris@345
|
1234
|
Chris@66
|
1235 QMenu *menu = m_paneMenu;
|
Chris@66
|
1236
|
Chris@168
|
1237 IconLoader il;
|
Chris@168
|
1238
|
Chris@162
|
1239 m_keyReference->setCategory(tr("Managing Panes and Layers"));
|
Chris@162
|
1240
|
Chris@168
|
1241 QAction *action = new QAction(il.load("pane"), tr("Add &New Pane"), this);
|
Chris@155
|
1242 action->setShortcut(tr("N"));
|
Chris@66
|
1243 action->setStatusTip(tr("Add a new pane containing only a time ruler"));
|
Chris@66
|
1244 connect(action, SIGNAL(triggered()), this, SLOT(addPane()));
|
Chris@66
|
1245 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@232
|
1246 m_paneActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
|
Chris@162
|
1247 m_keyReference->registerShortcut(action);
|
Chris@66
|
1248 menu->addAction(action);
|
Chris@66
|
1249
|
Chris@66
|
1250 menu->addSeparator();
|
Chris@66
|
1251
|
Chris@66
|
1252 menu = m_layerMenu;
|
Chris@66
|
1253
|
Chris@66
|
1254 LayerFactory::LayerTypeSet emptyLayerTypes =
|
Chris@1770
|
1255 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@66
|
1256
|
Chris@66
|
1257 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin();
|
Chris@1770
|
1258 i != emptyLayerTypes.end(); ++i) {
|
Chris@1770
|
1259
|
Chris@1770
|
1260 QIcon icon;
|
Chris@1770
|
1261 QString mainText, tipText, channelText;
|
Chris@1770
|
1262 LayerFactory::LayerType type = *i;
|
Chris@1770
|
1263 QString name = LayerFactory::getInstance()->getLayerPresentationName(type);
|
Chris@1770
|
1264
|
Chris@1770
|
1265 icon = il.load(LayerFactory::getInstance()->getLayerIconName(type));
|
Chris@1770
|
1266
|
Chris@1770
|
1267 mainText = tr("Add New %1 Layer").arg(name);
|
Chris@1770
|
1268 tipText = tr("Add a new empty layer of type %1").arg(name);
|
Chris@1770
|
1269
|
Chris@1770
|
1270 action = new QAction(icon, mainText, this);
|
Chris@1770
|
1271 action->setStatusTip(tipText);
|
Chris@1770
|
1272
|
Chris@1770
|
1273 if (type == LayerFactory::Text) {
|
Chris@1770
|
1274 action->setShortcut(tr("T"));
|
Chris@162
|
1275 m_keyReference->registerShortcut(action);
|
Chris@1770
|
1276 }
|
Chris@1770
|
1277
|
Chris@1770
|
1278 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@1770
|
1279 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1770
|
1280 m_layerActions[action] = LayerConfiguration(type);
|
Chris@1770
|
1281 menu->addAction(action);
|
Chris@66
|
1282 m_rightButtonLayerMenu->addAction(action);
|
Chris@66
|
1283 }
|
Chris@66
|
1284
|
Chris@66
|
1285 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
1286 menu->addSeparator();
|
Chris@66
|
1287
|
Chris@66
|
1288 LayerFactory::LayerType backgroundTypes[] = {
|
Chris@1770
|
1289 LayerFactory::Waveform,
|
Chris@1770
|
1290 LayerFactory::Spectrogram,
|
Chris@1770
|
1291 LayerFactory::MelodicRangeSpectrogram,
|
Chris@1770
|
1292 LayerFactory::PeakFrequencySpectrogram,
|
Chris@66
|
1293 LayerFactory::Spectrum
|
Chris@66
|
1294 };
|
Chris@66
|
1295
|
Chris@66
|
1296 std::vector<Model *> models;
|
Chris@224
|
1297 if (m_document) models = m_document->getTransformInputModels();
|
Chris@66
|
1298 bool plural = (models.size() > 1);
|
Chris@66
|
1299 if (models.empty()) {
|
Chris@67
|
1300 models.push_back(getMainModel()); // probably 0
|
Chris@66
|
1301 }
|
Chris@66
|
1302
|
Chris@66
|
1303 for (unsigned int i = 0;
|
Chris@1770
|
1304 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
|
Chris@66
|
1305
|
Chris@231
|
1306 const int paneMenuType = 0, layerMenuType = 1;
|
Chris@231
|
1307
|
Chris@1770
|
1308 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) {
|
Chris@1770
|
1309
|
Chris@1770
|
1310 if (menuType == paneMenuType) menu = m_paneMenu;
|
Chris@1770
|
1311 else menu = m_layerMenu;
|
Chris@1770
|
1312
|
Chris@1770
|
1313 QMenu *submenu = 0;
|
Chris@66
|
1314
|
Chris@66
|
1315 QIcon icon;
|
Chris@1794
|
1316 QString mainText, tipText, channelText;
|
Chris@66
|
1317 LayerFactory::LayerType type = backgroundTypes[i];
|
Chris@66
|
1318 bool mono = true;
|
Chris@730
|
1319
|
Chris@1794
|
1320 QString shortcutText = shortcutFor(type, menuType == paneMenuType);
|
Chris@1794
|
1321
|
Chris@730
|
1322 // Avoid warnings/errors with -Wextra because we aren't explicitly
|
Chris@730
|
1323 // handling all layer types (-Wall is OK with this because of the
|
Chris@730
|
1324 // default but the stricter level insists)
|
Chris@1264
|
1325 #ifdef __GNUC__
|
Chris@730
|
1326 #pragma GCC diagnostic ignored "-Wswitch-enum"
|
Chris@1264
|
1327 #endif
|
Chris@66
|
1328
|
Chris@66
|
1329 switch (type) {
|
Chris@66
|
1330
|
Chris@66
|
1331 case LayerFactory::Waveform:
|
Chris@168
|
1332 icon = il.load("waveform");
|
Chris@66
|
1333 mainText = tr("Add &Waveform");
|
Chris@231
|
1334 if (menuType == paneMenuType) {
|
Chris@66
|
1335 tipText = tr("Add a new pane showing a waveform view");
|
Chris@66
|
1336 } else {
|
Chris@66
|
1337 tipText = tr("Add a new layer showing a waveform view");
|
Chris@66
|
1338 }
|
Chris@66
|
1339 mono = false;
|
Chris@66
|
1340 break;
|
Chris@1770
|
1341
|
Chris@66
|
1342 case LayerFactory::Spectrogram:
|
Chris@168
|
1343 icon = il.load("spectrogram");
|
Chris@161
|
1344 mainText = tr("Add Spectro&gram");
|
Chris@231
|
1345 if (menuType == paneMenuType) {
|
Chris@90
|
1346 tipText = tr("Add a new pane showing a spectrogram");
|
Chris@66
|
1347 } else {
|
Chris@90
|
1348 tipText = tr("Add a new layer showing a spectrogram");
|
Chris@66
|
1349 }
|
Chris@66
|
1350 break;
|
Chris@1770
|
1351
|
Chris@66
|
1352 case LayerFactory::MelodicRangeSpectrogram:
|
Chris@168
|
1353 icon = il.load("spectrogram");
|
Chris@66
|
1354 mainText = tr("Add &Melodic Range Spectrogram");
|
Chris@231
|
1355 if (menuType == paneMenuType) {
|
Chris@90
|
1356 tipText = tr("Add a new pane showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
1357 } else {
|
Chris@90
|
1358 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
1359 }
|
Chris@66
|
1360 break;
|
Chris@1770
|
1361
|
Chris@66
|
1362 case LayerFactory::PeakFrequencySpectrogram:
|
Chris@168
|
1363 icon = il.load("spectrogram");
|
Chris@155
|
1364 mainText = tr("Add Pea&k Frequency Spectrogram");
|
Chris@231
|
1365 if (menuType == paneMenuType) {
|
Chris@66
|
1366 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
1367 } else {
|
Chris@66
|
1368 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
1369 }
|
Chris@66
|
1370 break;
|
Chris@66
|
1371
|
Chris@66
|
1372 case LayerFactory::Spectrum:
|
Chris@168
|
1373 icon = il.load("spectrum");
|
Chris@66
|
1374 mainText = tr("Add Spectr&um");
|
Chris@231
|
1375 if (menuType == paneMenuType) {
|
Chris@66
|
1376 tipText = tr("Add a new pane showing a frequency spectrum");
|
Chris@66
|
1377 } else {
|
Chris@66
|
1378 tipText = tr("Add a new layer showing a frequency spectrum");
|
Chris@66
|
1379 }
|
Chris@66
|
1380 break;
|
Chris@66
|
1381
|
Chris@66
|
1382 default: break;
|
Chris@66
|
1383 }
|
Chris@66
|
1384
|
Chris@346
|
1385 std::vector<Model *> candidateModels = models;
|
Chris@66
|
1386
|
Chris@66
|
1387 for (std::vector<Model *>::iterator mi =
|
Chris@66
|
1388 candidateModels.begin();
|
Chris@66
|
1389 mi != candidateModels.end(); ++mi) {
|
Chris@66
|
1390
|
Chris@66
|
1391 Model *model = *mi;
|
Chris@66
|
1392
|
Chris@66
|
1393 int channels = 0;
|
Chris@66
|
1394 if (model) {
|
Chris@66
|
1395 DenseTimeValueModel *dtvm =
|
Chris@66
|
1396 dynamic_cast<DenseTimeValueModel *>(model);
|
Chris@66
|
1397 if (dtvm) channels = dtvm->getChannelCount();
|
Chris@66
|
1398 }
|
Chris@66
|
1399 if (channels < 1 && getMainModel()) {
|
Chris@66
|
1400 channels = getMainModel()->getChannelCount();
|
Chris@66
|
1401 }
|
Chris@66
|
1402 if (channels < 1) channels = 1;
|
Chris@66
|
1403
|
Chris@66
|
1404 for (int c = 0; c <= channels; ++c) {
|
Chris@66
|
1405
|
Chris@66
|
1406 if (c == 1 && channels == 1) continue;
|
Chris@66
|
1407 bool isDefault = (c == 0);
|
Chris@66
|
1408 bool isOnly = (isDefault && (channels == 1));
|
Chris@66
|
1409
|
Chris@346
|
1410 if (isOnly && !plural) {
|
Chris@346
|
1411
|
Chris@346
|
1412 action = new QAction(icon, mainText, this);
|
Chris@67
|
1413
|
Chris@66
|
1414 action->setShortcut(shortcutText);
|
Chris@66
|
1415 action->setStatusTip(tipText);
|
Chris@231
|
1416 if (menuType == paneMenuType) {
|
Chris@66
|
1417 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1418 this, SLOT(addPane()));
|
Chris@66
|
1419 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
1420 action, SLOT(setEnabled(bool)));
|
Chris@346
|
1421 m_paneActions[action] =
|
Chris@346
|
1422 LayerConfiguration(type, model);
|
Chris@66
|
1423 } else {
|
Chris@66
|
1424 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1425 this, SLOT(addLayer()));
|
Chris@66
|
1426 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
1427 action, SLOT(setEnabled(bool)));
|
Chris@346
|
1428 m_layerActions[action] =
|
Chris@346
|
1429 LayerConfiguration(type, model);
|
Chris@66
|
1430 }
|
Chris@162
|
1431 if (shortcutText != "") {
|
Chris@162
|
1432 m_keyReference->registerShortcut(action);
|
Chris@162
|
1433 }
|
Chris@66
|
1434 menu->addAction(action);
|
Chris@66
|
1435
|
Chris@66
|
1436 } else {
|
Chris@66
|
1437
|
Chris@66
|
1438 if (!submenu) {
|
Chris@66
|
1439 submenu = menu->addMenu(mainText);
|
Chris@97
|
1440 submenu->setTearOffEnabled(true);
|
Chris@67
|
1441 } else if (isDefault) {
|
Chris@67
|
1442 submenu->addSeparator();
|
Chris@66
|
1443 }
|
Chris@66
|
1444
|
Chris@66
|
1445 QString actionText;
|
Chris@66
|
1446 if (c == 0) {
|
Chris@66
|
1447 if (mono) {
|
Chris@66
|
1448 actionText = tr("&All Channels Mixed");
|
Chris@66
|
1449 } else {
|
Chris@66
|
1450 actionText = tr("&All Channels");
|
Chris@66
|
1451 }
|
Chris@66
|
1452 } else {
|
Chris@66
|
1453 actionText = tr("Channel &%1").arg(c);
|
Chris@66
|
1454 }
|
Chris@66
|
1455
|
Chris@66
|
1456 if (model) {
|
Chris@66
|
1457 actionText = tr("%1: %2")
|
Chris@66
|
1458 .arg(model->objectName())
|
Chris@66
|
1459 .arg(actionText);
|
Chris@66
|
1460 }
|
Chris@67
|
1461
|
Chris@67
|
1462 if (isDefault) {
|
Chris@67
|
1463 action = new QAction(icon, actionText, this);
|
Chris@67
|
1464 if (!model || model == getMainModel()) {
|
Chris@162
|
1465 action->setShortcut(shortcutText);
|
Chris@67
|
1466 }
|
Chris@67
|
1467 } else {
|
Chris@67
|
1468 action = new QAction(actionText, this);
|
Chris@67
|
1469 }
|
Chris@67
|
1470
|
Chris@66
|
1471 action->setStatusTip(tipText);
|
Chris@66
|
1472
|
Chris@231
|
1473 if (menuType == paneMenuType) {
|
Chris@66
|
1474 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1475 this, SLOT(addPane()));
|
Chris@66
|
1476 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
1477 action, SLOT(setEnabled(bool)));
|
Chris@66
|
1478 m_paneActions[action] =
|
Chris@232
|
1479 LayerConfiguration(type, model, c - 1);
|
Chris@66
|
1480 } else {
|
Chris@66
|
1481 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1482 this, SLOT(addLayer()));
|
Chris@66
|
1483 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
1484 action, SLOT(setEnabled(bool)));
|
Chris@232
|
1485 m_layerActions[action] =
|
Chris@232
|
1486 LayerConfiguration(type, model, c - 1);
|
Chris@66
|
1487 }
|
Chris@66
|
1488
|
Chris@66
|
1489 submenu->addAction(action);
|
Chris@66
|
1490 }
|
Chris@346
|
1491
|
Chris@415
|
1492 if (isDefault && menuType == layerMenuType &&
|
Chris@415
|
1493 mi == candidateModels.begin()) {
|
Chris@415
|
1494 // only add for one model, one channel, one menu on
|
Chris@415
|
1495 // right button -- the action itself will discover
|
Chris@415
|
1496 // which model is the correct one (based on pane)
|
Chris@346
|
1497 action = new QAction(icon, mainText, this);
|
Chris@346
|
1498 action->setStatusTip(tipText);
|
Chris@346
|
1499 connect(action, SIGNAL(triggered()),
|
Chris@346
|
1500 this, SLOT(addLayer()));
|
Chris@346
|
1501 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@346
|
1502 action, SLOT(setEnabled(bool)));
|
Chris@346
|
1503 m_layerActions[action] = LayerConfiguration(type, 0, 0);
|
Chris@346
|
1504 m_rightButtonLayerMenu->addAction(action);
|
Chris@346
|
1505 }
|
Chris@1770
|
1506 }
|
Chris@1770
|
1507 }
|
Chris@1770
|
1508 }
|
Chris@66
|
1509 }
|
Chris@66
|
1510
|
Chris@347
|
1511 m_rightButtonLayerMenu->addSeparator();
|
Chris@347
|
1512
|
Chris@66
|
1513 menu = m_paneMenu;
|
Chris@225
|
1514 menu->addSeparator();
|
Chris@225
|
1515
|
Chris@225
|
1516 action = new QAction(tr("Switch to Previous Pane"), this);
|
Chris@225
|
1517 action->setShortcut(tr("["));
|
Chris@225
|
1518 action->setStatusTip(tr("Make the next pane up in the pane stack current"));
|
Chris@225
|
1519 connect(action, SIGNAL(triggered()), this, SLOT(previousPane()));
|
Chris@225
|
1520 connect(this, SIGNAL(canSelectPreviousPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1521 m_keyReference->registerShortcut(action);
|
Chris@225
|
1522 menu->addAction(action);
|
Chris@225
|
1523
|
Chris@225
|
1524 action = new QAction(tr("Switch to Next Pane"), this);
|
Chris@225
|
1525 action->setShortcut(tr("]"));
|
Chris@225
|
1526 action->setStatusTip(tr("Make the next pane down in the pane stack current"));
|
Chris@225
|
1527 connect(action, SIGNAL(triggered()), this, SLOT(nextPane()));
|
Chris@225
|
1528 connect(this, SIGNAL(canSelectNextPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1529 m_keyReference->registerShortcut(action);
|
Chris@225
|
1530 menu->addAction(action);
|
Chris@66
|
1531
|
Chris@66
|
1532 menu->addSeparator();
|
Chris@66
|
1533
|
Chris@168
|
1534 action = new QAction(il.load("editdelete"), tr("&Delete Pane"), this);
|
Chris@155
|
1535 action->setShortcut(tr("Ctrl+Shift+D"));
|
Chris@90
|
1536 action->setStatusTip(tr("Delete the currently active pane"));
|
Chris@66
|
1537 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane()));
|
Chris@66
|
1538 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
1539 m_keyReference->registerShortcut(action);
|
Chris@66
|
1540 menu->addAction(action);
|
Chris@66
|
1541
|
Chris@66
|
1542 menu = m_layerMenu;
|
Chris@66
|
1543
|
Chris@168
|
1544 action = new QAction(il.load("timeruler"), tr("Add &Time Ruler"), this);
|
Chris@66
|
1545 action->setStatusTip(tr("Add a new layer showing a time ruler"));
|
Chris@66
|
1546 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@66
|
1547 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@232
|
1548 m_layerActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
|
Chris@66
|
1549 menu->addAction(action);
|
Chris@66
|
1550
|
Chris@66
|
1551 menu->addSeparator();
|
Chris@66
|
1552
|
Chris@66
|
1553 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer"));
|
Chris@97
|
1554 m_existingLayersMenu->setTearOffEnabled(true);
|
Chris@66
|
1555 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu);
|
Chris@95
|
1556
|
Chris@95
|
1557 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer"));
|
Chris@97
|
1558 m_sliceMenu->setTearOffEnabled(true);
|
Chris@95
|
1559 m_rightButtonLayerMenu->addMenu(m_sliceMenu);
|
Chris@95
|
1560
|
Chris@95
|
1561 setupExistingLayersMenus();
|
Chris@66
|
1562
|
Chris@225
|
1563 menu->addSeparator();
|
Chris@225
|
1564
|
Chris@225
|
1565 action = new QAction(tr("Switch to Previous Layer"), this);
|
Chris@225
|
1566 action->setShortcut(tr("{"));
|
Chris@225
|
1567 action->setStatusTip(tr("Make the previous layer in the pane current"));
|
Chris@225
|
1568 connect(action, SIGNAL(triggered()), this, SLOT(previousLayer()));
|
Chris@225
|
1569 connect(this, SIGNAL(canSelectPreviousLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1570 m_keyReference->registerShortcut(action);
|
Chris@225
|
1571 menu->addAction(action);
|
Chris@225
|
1572
|
Chris@225
|
1573 action = new QAction(tr("Switch to Next Layer"), this);
|
Chris@225
|
1574 action->setShortcut(tr("}"));
|
Chris@225
|
1575 action->setStatusTip(tr("Make the next layer in the pane current"));
|
Chris@225
|
1576 connect(action, SIGNAL(triggered()), this, SLOT(nextLayer()));
|
Chris@225
|
1577 connect(this, SIGNAL(canSelectNextLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1578 m_keyReference->registerShortcut(action);
|
Chris@225
|
1579 menu->addAction(action);
|
Chris@785
|
1580
|
Chris@66
|
1581 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
1582 menu->addSeparator();
|
Chris@66
|
1583
|
Chris@163
|
1584 QAction *raction = new QAction(tr("&Rename Layer..."), this);
|
Chris@163
|
1585 raction->setShortcut(tr("R"));
|
Chris@163
|
1586 raction->setStatusTip(tr("Rename the currently active layer"));
|
Chris@163
|
1587 connect(raction, SIGNAL(triggered()), this, SLOT(renameCurrentLayer()));
|
Chris@163
|
1588 connect(this, SIGNAL(canRenameLayer(bool)), raction, SLOT(setEnabled(bool)));
|
Chris@163
|
1589 menu->addAction(raction);
|
Chris@163
|
1590 m_rightButtonLayerMenu->addAction(raction);
|
Chris@66
|
1591
|
Chris@258
|
1592 QAction *eaction = new QAction(tr("Edit Layer Data"), this);
|
Chris@258
|
1593 eaction->setShortcut(tr("E"));
|
Chris@258
|
1594 eaction->setStatusTip(tr("Edit the currently active layer as a data grid"));
|
Chris@258
|
1595 connect(eaction, SIGNAL(triggered()), this, SLOT(editCurrentLayer()));
|
Chris@291
|
1596 connect(this, SIGNAL(canEditLayerTabular(bool)), eaction, SLOT(setEnabled(bool)));
|
Chris@258
|
1597 menu->addAction(eaction);
|
Chris@258
|
1598 m_rightButtonLayerMenu->addAction(eaction);
|
Chris@258
|
1599
|
Chris@168
|
1600 action = new QAction(il.load("editdelete"), tr("&Delete Layer"), this);
|
Chris@155
|
1601 action->setShortcut(tr("Ctrl+D"));
|
Chris@66
|
1602 action->setStatusTip(tr("Delete the currently active layer"));
|
Chris@66
|
1603 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer()));
|
Chris@66
|
1604 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
1605 m_keyReference->registerShortcut(action);
|
Chris@66
|
1606 menu->addAction(action);
|
Chris@66
|
1607 m_rightButtonLayerMenu->addAction(action);
|
Chris@163
|
1608
|
Chris@163
|
1609 m_keyReference->registerShortcut(raction); // rename after delete, so delete layer goes next to delete pane
|
Chris@258
|
1610 m_keyReference->registerShortcut(eaction); // edit also after delete
|
Chris@755
|
1611
|
Chris@755
|
1612 finaliseMenus();
|
Chris@66
|
1613 }
|
Chris@66
|
1614
|
Chris@66
|
1615 void
|
Chris@1794
|
1616 MainWindow::updateLayerShortcutsFor(Model *model)
|
Chris@1794
|
1617 {
|
Chris@1794
|
1618 set<LayerFactory::LayerType> seen;
|
Chris@1794
|
1619
|
Chris@1794
|
1620 for (auto &a : m_paneActions) {
|
Chris@1799
|
1621 if (!a.second.sourceModel) continue; // empty pane/layer shortcut
|
Chris@1794
|
1622 auto type = a.second.layer;
|
Chris@1794
|
1623 if (a.second.sourceModel == model && seen.find(type) == seen.end()) {
|
Chris@1794
|
1624 a.first->setShortcut(shortcutFor(type, true));
|
Chris@1794
|
1625 seen.insert(type);
|
Chris@1794
|
1626 } else {
|
Chris@1794
|
1627 a.first->setShortcut(QString());
|
Chris@1794
|
1628 }
|
Chris@1794
|
1629 }
|
Chris@1794
|
1630
|
Chris@1794
|
1631 seen.clear();
|
Chris@1794
|
1632
|
Chris@1794
|
1633 for (auto &a : m_layerActions) {
|
Chris@1799
|
1634 if (!a.second.sourceModel) continue; // empty pane/layer shortcut
|
Chris@1794
|
1635 auto type = a.second.layer;
|
Chris@1794
|
1636 if (a.second.sourceModel == model && seen.find(type) == seen.end()) {
|
Chris@1794
|
1637 a.first->setShortcut(shortcutFor(type, false));
|
Chris@1794
|
1638 seen.insert(type);
|
Chris@1794
|
1639 } else {
|
Chris@1794
|
1640 a.first->setShortcut(QString());
|
Chris@1794
|
1641 }
|
Chris@1794
|
1642 }
|
Chris@1794
|
1643 }
|
Chris@1794
|
1644
|
Chris@1794
|
1645 void
|
Chris@211
|
1646 MainWindow::setupTransformsMenu()
|
Chris@66
|
1647 {
|
Chris@34
|
1648 if (m_transformsMenu) {
|
Chris@34
|
1649 m_transformActions.clear();
|
Chris@34
|
1650 m_transformActionsReverse.clear();
|
Chris@34
|
1651 m_transformsMenu->clear();
|
Chris@34
|
1652 } else {
|
Chris@1770
|
1653 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
|
Chris@97
|
1654 m_transformsMenu->setTearOffEnabled(true);
|
Chris@286
|
1655 m_transformsMenu->setSeparatorsCollapsible(true);
|
Chris@272
|
1656 }
|
Chris@34
|
1657
|
Chris@288
|
1658 TransformFactory *factory = TransformFactory::getInstance();
|
Chris@288
|
1659
|
Chris@288
|
1660 TransformList transforms = factory->getAllTransformDescriptions();
|
Chris@1277
|
1661
|
Chris@1277
|
1662 if (factory->getStartupFailureReport() != "") {
|
Chris@1277
|
1663 pluginPopulationWarning();
|
Chris@1277
|
1664 }
|
Chris@1277
|
1665
|
Chris@288
|
1666 vector<TransformDescription::Type> types = factory->getAllTransformTypes();
|
Chris@288
|
1667
|
Chris@288
|
1668 map<TransformDescription::Type, map<QString, SubdividingMenu *> > categoryMenus;
|
Chris@288
|
1669 map<TransformDescription::Type, map<QString, SubdividingMenu *> > makerMenus;
|
Chris@288
|
1670
|
Chris@288
|
1671 map<TransformDescription::Type, SubdividingMenu *> byPluginNameMenus;
|
Chris@288
|
1672 map<TransformDescription::Type, map<QString, QMenu *> > pluginNameMenus;
|
Chris@33
|
1673
|
Chris@37
|
1674 set<SubdividingMenu *> pendingMenus;
|
Chris@37
|
1675
|
Chris@211
|
1676 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms"));
|
Chris@211
|
1677 m_recentTransformsMenu->setTearOffEnabled(true);
|
Chris@211
|
1678 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu);
|
Chris@211
|
1679 connect(&m_recentTransforms, SIGNAL(recentChanged()),
|
Chris@211
|
1680 this, SLOT(setupRecentTransformsMenu()));
|
Chris@34
|
1681
|
Chris@34
|
1682 m_transformsMenu->addSeparator();
|
Chris@211
|
1683 m_rightButtonTransformsMenu->addSeparator();
|
Chris@34
|
1684
|
Chris@288
|
1685 for (vector<TransformDescription::Type>::iterator i = types.begin();
|
Chris@288
|
1686 i != types.end(); ++i) {
|
Chris@33
|
1687
|
Chris@33
|
1688 if (i != types.begin()) {
|
Chris@34
|
1689 m_transformsMenu->addSeparator();
|
Chris@211
|
1690 m_rightButtonTransformsMenu->addSeparator();
|
Chris@33
|
1691 }
|
Chris@33
|
1692
|
Chris@288
|
1693 QString byCategoryLabel = tr("%1 by Category")
|
Chris@288
|
1694 .arg(factory->getTransformTypeName(*i));
|
Chris@37
|
1695 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel,
|
Chris@37
|
1696 20, 40);
|
Chris@97
|
1697 byCategoryMenu->setTearOffEnabled(true);
|
Chris@37
|
1698 m_transformsMenu->addMenu(byCategoryMenu);
|
Chris@211
|
1699 m_rightButtonTransformsMenu->addMenu(byCategoryMenu);
|
Chris@37
|
1700 pendingMenus.insert(byCategoryMenu);
|
Chris@33
|
1701
|
Chris@288
|
1702 vector<QString> categories = factory->getTransformCategories(*i);
|
Chris@33
|
1703
|
Chris@33
|
1704 for (vector<QString>::iterator j = categories.begin();
|
Chris@33
|
1705 j != categories.end(); ++j) {
|
Chris@33
|
1706
|
Chris@33
|
1707 QString category = *j;
|
Chris@33
|
1708 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1709
|
Chris@33
|
1710 if (categories.size() < 2) {
|
Chris@33
|
1711 categoryMenus[*i][category] = byCategoryMenu;
|
Chris@33
|
1712 continue;
|
Chris@33
|
1713 }
|
Chris@33
|
1714
|
Chris@33
|
1715 QStringList components = category.split(" > ");
|
Chris@33
|
1716 QString key;
|
Chris@33
|
1717
|
Chris@33
|
1718 for (QStringList::iterator k = components.begin();
|
Chris@33
|
1719 k != components.end(); ++k) {
|
Chris@33
|
1720
|
Chris@33
|
1721 QString parentKey = key;
|
Chris@33
|
1722 if (key != "") key += " > ";
|
Chris@33
|
1723 key += *k;
|
Chris@33
|
1724
|
Chris@33
|
1725 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) {
|
Chris@37
|
1726 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40);
|
Chris@97
|
1727 m->setTearOffEnabled(true);
|
Chris@37
|
1728 pendingMenus.insert(m);
|
Chris@37
|
1729 categoryMenus[*i][key] = m;
|
Chris@33
|
1730 if (parentKey == "") {
|
Chris@37
|
1731 byCategoryMenu->addMenu(m);
|
Chris@33
|
1732 } else {
|
Chris@37
|
1733 categoryMenus[*i][parentKey]->addMenu(m);
|
Chris@33
|
1734 }
|
Chris@33
|
1735 }
|
Chris@33
|
1736 }
|
Chris@33
|
1737 }
|
Chris@33
|
1738
|
Chris@288
|
1739 QString byPluginNameLabel = tr("%1 by Plugin Name")
|
Chris@288
|
1740 .arg(factory->getTransformTypeName(*i));
|
Chris@36
|
1741 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel);
|
Chris@97
|
1742 byPluginNameMenus[*i]->setTearOffEnabled(true);
|
Chris@36
|
1743 m_transformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@211
|
1744 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@37
|
1745 pendingMenus.insert(byPluginNameMenus[*i]);
|
Chris@34
|
1746
|
Chris@288
|
1747 QString byMakerLabel = tr("%1 by Maker")
|
Chris@288
|
1748 .arg(factory->getTransformTypeName(*i));
|
Chris@37
|
1749 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40);
|
Chris@97
|
1750 byMakerMenu->setTearOffEnabled(true);
|
Chris@37
|
1751 m_transformsMenu->addMenu(byMakerMenu);
|
Chris@211
|
1752 m_rightButtonTransformsMenu->addMenu(byMakerMenu);
|
Chris@37
|
1753 pendingMenus.insert(byMakerMenu);
|
Chris@33
|
1754
|
Chris@288
|
1755 vector<QString> makers = factory->getTransformMakers(*i);
|
Chris@37
|
1756
|
Chris@33
|
1757 for (vector<QString>::iterator j = makers.begin();
|
Chris@33
|
1758 j != makers.end(); ++j) {
|
Chris@33
|
1759
|
Chris@33
|
1760 QString maker = *j;
|
Chris@33
|
1761 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1762 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@55
|
1763
|
Chris@37
|
1764 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40);
|
Chris@97
|
1765 makerMenus[*i][maker]->setTearOffEnabled(true);
|
Chris@37
|
1766 byMakerMenu->addMenu(makerMenus[*i][maker]);
|
Chris@37
|
1767 pendingMenus.insert(makerMenus[*i][maker]);
|
Chris@33
|
1768 }
|
Chris@0
|
1769 }
|
Chris@0
|
1770
|
Chris@230
|
1771 // Names should only be duplicated here if they have the same
|
Chris@230
|
1772 // plugin name, output name and maker but are in different library
|
Chris@230
|
1773 // .so names -- that won't happen often I hope
|
Chris@230
|
1774 std::map<QString, QString> idNameSonameMap;
|
Chris@230
|
1775 std::set<QString> seenNames, duplicateNames;
|
Chris@230
|
1776 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@230
|
1777 QString name = transforms[i].name;
|
Chris@230
|
1778 if (seenNames.find(name) != seenNames.end()) {
|
Chris@230
|
1779 duplicateNames.insert(name);
|
Chris@230
|
1780 } else {
|
Chris@230
|
1781 seenNames.insert(name);
|
Chris@230
|
1782 }
|
Chris@230
|
1783 }
|
Chris@230
|
1784
|
Chris@0
|
1785 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@1770
|
1786
|
Chris@1770
|
1787 QString name = transforms[i].name;
|
Chris@1770
|
1788 if (name == "") name = transforms[i].identifier;
|
Chris@107
|
1789
|
Chris@665
|
1790 // cerr << "Plugin Name: " << name << endl;
|
Chris@80
|
1791
|
Chris@288
|
1792 TransformDescription::Type type = transforms[i].type;
|
Chris@288
|
1793 QString typeStr = factory->getTransformTypeName(type);
|
Chris@33
|
1794
|
Chris@33
|
1795 QString category = transforms[i].category;
|
Chris@33
|
1796 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1797
|
Chris@33
|
1798 QString maker = transforms[i].maker;
|
Chris@33
|
1799 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1800 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@33
|
1801
|
Chris@107
|
1802 QString pluginName = name.section(": ", 0, 0);
|
Chris@107
|
1803 QString output = name.section(": ", 1);
|
Chris@107
|
1804
|
Chris@230
|
1805 if (duplicateNames.find(pluginName) != duplicateNames.end()) {
|
Chris@230
|
1806 pluginName = QString("%1 <%2>")
|
Chris@230
|
1807 .arg(pluginName)
|
Chris@230
|
1808 .arg(transforms[i].identifier.section(':', 1, 1));
|
Chris@230
|
1809 if (output == "") name = pluginName;
|
Chris@230
|
1810 else name = QString("%1: %2")
|
Chris@230
|
1811 .arg(pluginName)
|
Chris@230
|
1812 .arg(output);
|
Chris@230
|
1813 }
|
Chris@230
|
1814
|
Chris@1770
|
1815 QAction *action = new QAction(tr("%1...").arg(name), this);
|
Chris@1770
|
1816 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@1770
|
1817 m_transformActions[action] = transforms[i].identifier;
|
Chris@107
|
1818 m_transformActionsReverse[transforms[i].identifier] = action;
|
Chris@1770
|
1819 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@33
|
1820
|
Chris@272
|
1821 action->setStatusTip(transforms[i].longDescription);
|
Chris@90
|
1822
|
Chris@33
|
1823 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
|
Chris@665
|
1824 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1825 << "No category menu for transform \""
|
Chris@432
|
1826 << name << "\" (category = \""
|
Chris@665
|
1827 << category << "\")" << endl;
|
Chris@33
|
1828 } else {
|
Chris@33
|
1829 categoryMenus[type][category]->addAction(action);
|
Chris@33
|
1830 }
|
Chris@33
|
1831
|
Chris@33
|
1832 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
|
Chris@665
|
1833 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1834 << "No maker menu for transform \""
|
Chris@432
|
1835 << name << "\" (maker = \""
|
Chris@665
|
1836 << maker << "\")" << endl;
|
Chris@33
|
1837 } else {
|
Chris@80
|
1838 makerMenus[type][maker]->addAction(action);
|
Chris@33
|
1839 }
|
Chris@33
|
1840
|
Chris@33
|
1841 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
|
Chris@33
|
1842 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1843 m_transformActions[action] = transforms[i].identifier;
|
Chris@33
|
1844 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@272
|
1845 action->setStatusTip(transforms[i].longDescription);
|
Chris@33
|
1846
|
Chris@432
|
1847 // cerr << "Transform: \"" << name << "\": plugin name \"" << pluginName << "\"" << endl;
|
Chris@34
|
1848
|
Chris@33
|
1849 if (pluginNameMenus[type].find(pluginName) ==
|
Chris@33
|
1850 pluginNameMenus[type].end()) {
|
Chris@33
|
1851
|
Chris@36
|
1852 SubdividingMenu *parentMenu = byPluginNameMenus[type];
|
Chris@97
|
1853 parentMenu->setTearOffEnabled(true);
|
Chris@34
|
1854
|
Chris@33
|
1855 if (output == "") {
|
Chris@36
|
1856 parentMenu->addAction(pluginName, action);
|
Chris@33
|
1857 } else {
|
Chris@34
|
1858 pluginNameMenus[type][pluginName] =
|
Chris@34
|
1859 parentMenu->addMenu(pluginName);
|
Chris@33
|
1860 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@33
|
1861 pluginNameMenus[type][pluginName],
|
Chris@33
|
1862 SLOT(setEnabled(bool)));
|
Chris@33
|
1863 }
|
Chris@33
|
1864 }
|
Chris@33
|
1865
|
Chris@33
|
1866 if (pluginNameMenus[type].find(pluginName) !=
|
Chris@33
|
1867 pluginNameMenus[type].end()) {
|
Chris@33
|
1868 pluginNameMenus[type][pluginName]->addAction(action);
|
Chris@33
|
1869 }
|
Chris@0
|
1870 }
|
Chris@0
|
1871
|
Chris@37
|
1872 for (set<SubdividingMenu *>::iterator i = pendingMenus.begin();
|
Chris@37
|
1873 i != pendingMenus.end(); ++i) {
|
Chris@37
|
1874 (*i)->entriesAdded();
|
Chris@37
|
1875 }
|
Chris@37
|
1876
|
Chris@273
|
1877 m_transformsMenu->addSeparator();
|
Chris@273
|
1878 m_rightButtonTransformsMenu->addSeparator();
|
Chris@273
|
1879
|
Chris@273
|
1880 QAction *action = new QAction(tr("Find a Transform..."), this);
|
Chris@273
|
1881 action->setStatusTip(tr("Search for a transform from the installed plugins, by name or description"));
|
Chris@275
|
1882 action->setShortcut(tr("Ctrl+M"));
|
Chris@273
|
1883 connect(action, SIGNAL(triggered()), this, SLOT(findTransform()));
|
Chris@287
|
1884 // connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@275
|
1885 m_keyReference->registerShortcut(action);
|
Chris@273
|
1886 m_transformsMenu->addAction(action);
|
Chris@273
|
1887 m_rightButtonTransformsMenu->addAction(action);
|
Chris@273
|
1888
|
Chris@211
|
1889 setupRecentTransformsMenu();
|
Chris@66
|
1890 }
|
Chris@66
|
1891
|
Chris@66
|
1892 void
|
Chris@66
|
1893 MainWindow::setupHelpMenu()
|
Chris@66
|
1894 {
|
Chris@66
|
1895 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@97
|
1896 menu->setTearOffEnabled(true);
|
Chris@66
|
1897
|
Chris@162
|
1898 m_keyReference->setCategory(tr("Help"));
|
Chris@162
|
1899
|
Chris@168
|
1900 IconLoader il;
|
Chris@168
|
1901
|
Chris@518
|
1902 QString name = QApplication::applicationName();
|
Chris@518
|
1903
|
Chris@168
|
1904 QAction *action = new QAction(il.load("help"),
|
Chris@138
|
1905 tr("&Help Reference"), this);
|
Chris@162
|
1906 action->setShortcut(tr("F1"));
|
Chris@518
|
1907 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
Chris@66
|
1908 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@162
|
1909 m_keyReference->registerShortcut(action);
|
Chris@0
|
1910 menu->addAction(action);
|
Chris@162
|
1911
|
Chris@163
|
1912 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@162
|
1913 action->setShortcut(tr("F2"));
|
Chris@518
|
1914 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@162
|
1915 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@162
|
1916 m_keyReference->registerShortcut(action);
|
Chris@162
|
1917 menu->addAction(action);
|
Chris@66
|
1918
|
Chris@518
|
1919 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@518
|
1920 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@164
|
1921 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@164
|
1922 menu->addAction(action);
|
Chris@164
|
1923
|
Chris@1526
|
1924 action = new QAction(tr("What's &New?"), this);
|
Chris@1516
|
1925 action->setStatusTip(tr("Show changes in this release of %1").arg(name));
|
Chris@1516
|
1926 connect(action, SIGNAL(triggered()), this, SLOT(whatsNew()));
|
Chris@1516
|
1927 menu->addAction(action);
|
Chris@1516
|
1928
|
Chris@518
|
1929 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@518
|
1930 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@66
|
1931 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
1932 menu->addAction(action);
|
Chris@0
|
1933 }
|
Chris@0
|
1934
|
Chris@0
|
1935 void
|
Chris@0
|
1936 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
1937 {
|
Chris@0
|
1938 m_recentFilesMenu->clear();
|
Chris@34
|
1939 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
1940 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@1253
|
1941 /* F. Nicol patch 13 Aug. 2016 */
|
Chris@1253
|
1942 const QString& path = files[i];
|
Chris@1253
|
1943 QAction *action = new QAction(path, this);
|
Chris@1253
|
1944 connect(action, &QAction::triggered, [this, path] { openRecentFile(path);});
|
Chris@1253
|
1945 /* end of patch */
|
Chris@162
|
1946 if (i == 0) {
|
Chris@162
|
1947 action->setShortcut(tr("Ctrl+R"));
|
Chris@162
|
1948 m_keyReference->registerShortcut
|
Chris@163
|
1949 (tr("Re-open"),
|
Chris@528
|
1950 action->shortcut().toString(),
|
Chris@163
|
1951 tr("Re-open the current or most recently opened file"));
|
Chris@162
|
1952 }
|
Chris@1770
|
1953 m_recentFilesMenu->addAction(action);
|
Chris@0
|
1954 }
|
Chris@0
|
1955 }
|
Chris@0
|
1956
|
Chris@0
|
1957 void
|
Chris@423
|
1958 MainWindow::setupTemplatesMenu()
|
Chris@423
|
1959 {
|
Chris@423
|
1960 m_templatesMenu->clear();
|
Chris@423
|
1961
|
Chris@455
|
1962 QAction *defaultAction = new QAction(tr("Standard Waveform"), this);
|
Chris@435
|
1963 defaultAction->setObjectName("default");
|
Chris@435
|
1964 connect(defaultAction, SIGNAL(triggered()), this, SLOT(applyTemplate()));
|
Chris@435
|
1965 m_templatesMenu->addAction(defaultAction);
|
Chris@435
|
1966
|
Chris@435
|
1967 m_templatesMenu->addSeparator();
|
Chris@435
|
1968
|
Chris@435
|
1969 QAction *action = 0;
|
Chris@435
|
1970
|
Chris@435
|
1971 QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
|
Chris@435
|
1972
|
Chris@436
|
1973 bool havePersonal = false;
|
Chris@436
|
1974
|
Chris@435
|
1975 // (ordered by name)
|
Chris@435
|
1976 std::set<QString> byName;
|
Chris@435
|
1977 foreach (QString t, templates) {
|
Chris@436
|
1978 if (!t.startsWith(":")) havePersonal = true;
|
Chris@435
|
1979 byName.insert(QFileInfo(t).baseName());
|
Chris@435
|
1980 }
|
Chris@435
|
1981
|
Chris@435
|
1982 foreach (QString t, byName) {
|
Chris@435
|
1983 if (t.toLower() == "default") continue;
|
Chris@435
|
1984 action = new QAction(t, this);
|
Chris@435
|
1985 connect(action, SIGNAL(triggered()), this, SLOT(applyTemplate()));
|
Chris@435
|
1986 m_templatesMenu->addAction(action);
|
Chris@435
|
1987 }
|
Chris@435
|
1988
|
Chris@435
|
1989 if (!templates.empty()) m_templatesMenu->addSeparator();
|
Chris@435
|
1990
|
Chris@435
|
1991 if (!m_templateWatcher) {
|
Chris@435
|
1992 m_templateWatcher = new QFileSystemWatcher(this);
|
Chris@435
|
1993 m_templateWatcher->addPath(ResourceFinder().getResourceSaveDir("templates"));
|
Chris@435
|
1994 connect(m_templateWatcher, SIGNAL(directoryChanged(const QString &)),
|
Chris@435
|
1995 this, SLOT(setupTemplatesMenu()));
|
Chris@435
|
1996 }
|
Chris@436
|
1997
|
Chris@436
|
1998 QAction *setDefaultAction = new QAction(tr("Choose Default Template..."), this);
|
Chris@436
|
1999 setDefaultAction->setObjectName("set_default_template");
|
Chris@436
|
2000 connect(setDefaultAction, SIGNAL(triggered()), this, SLOT(preferences()));
|
Chris@436
|
2001 m_templatesMenu->addSeparator();
|
Chris@436
|
2002 m_templatesMenu->addAction(setDefaultAction);
|
Chris@436
|
2003
|
Chris@436
|
2004 m_manageTemplatesAction->setEnabled(havePersonal);
|
Chris@435
|
2005 }
|
Chris@435
|
2006
|
Chris@423
|
2007
|
Chris@423
|
2008 void
|
Chris@211
|
2009 MainWindow::setupRecentTransformsMenu()
|
Chris@34
|
2010 {
|
Chris@211
|
2011 m_recentTransformsMenu->clear();
|
Chris@211
|
2012 vector<QString> transforms = m_recentTransforms.getRecent();
|
Chris@34
|
2013 for (size_t i = 0; i < transforms.size(); ++i) {
|
Chris@211
|
2014 TransformActionReverseMap::iterator ti =
|
Chris@34
|
2015 m_transformActionsReverse.find(transforms[i]);
|
Chris@34
|
2016 if (ti == m_transformActionsReverse.end()) {
|
Chris@665
|
2017 cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
|
Chris@665
|
2018 << "Unknown transform \"" << transforms[i]
|
Chris@665
|
2019 << "\" in recent transforms list" << endl;
|
Chris@34
|
2020 continue;
|
Chris@34
|
2021 }
|
Chris@162
|
2022 if (i == 0) {
|
Chris@162
|
2023 ti->second->setShortcut(tr("Ctrl+T"));
|
Chris@162
|
2024 m_keyReference->registerShortcut
|
Chris@211
|
2025 (tr("Repeat Transform"),
|
Chris@528
|
2026 ti->second->shortcut().toString(),
|
Chris@163
|
2027 tr("Re-select the most recently run transform"));
|
Chris@216
|
2028 } else {
|
Chris@216
|
2029 ti->second->setShortcut(QString(""));
|
Chris@162
|
2030 }
|
Chris@1770
|
2031 m_recentTransformsMenu->addAction(ti->second);
|
Chris@34
|
2032 }
|
Chris@34
|
2033 }
|
Chris@34
|
2034
|
Chris@34
|
2035 void
|
Chris@95
|
2036 MainWindow::setupExistingLayersMenus()
|
Chris@0
|
2037 {
|
Chris@0
|
2038 if (!m_existingLayersMenu) return; // should have been created by setupMenus
|
Chris@0
|
2039
|
Chris@438
|
2040 // SVDEBUG << "MainWindow::setupExistingLayersMenu" << endl;
|
Chris@0
|
2041
|
Chris@0
|
2042 m_existingLayersMenu->clear();
|
Chris@0
|
2043 m_existingLayerActions.clear();
|
Chris@0
|
2044
|
Chris@95
|
2045 m_sliceMenu->clear();
|
Chris@95
|
2046 m_sliceActions.clear();
|
Chris@95
|
2047
|
Chris@168
|
2048 IconLoader il;
|
Chris@168
|
2049
|
Chris@33
|
2050 vector<Layer *> orderedLayers;
|
Chris@33
|
2051 set<Layer *> observedLayers;
|
Chris@95
|
2052 set<Layer *> sliceableLayers;
|
Chris@95
|
2053
|
Chris@95
|
2054 LayerFactory *factory = LayerFactory::getInstance();
|
Chris@0
|
2055
|
Chris@0
|
2056 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
2057
|
Chris@1770
|
2058 Pane *pane = m_paneStack->getPane(i);
|
Chris@1770
|
2059 if (!pane) continue;
|
Chris@1770
|
2060
|
Chris@1770
|
2061 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@1770
|
2062
|
Chris@1770
|
2063 Layer *layer = pane->getLayer(j);
|
Chris@1770
|
2064 if (!layer) continue;
|
Chris@1770
|
2065 if (observedLayers.find(layer) != observedLayers.end()) {
|
Chris@1770
|
2066 // cerr << "found duplicate layer " << layer << endl;
|
Chris@1770
|
2067 continue;
|
Chris@1770
|
2068 }
|
Chris@1770
|
2069
|
Chris@1770
|
2070 // cerr << "found new layer " << layer << " (name = "
|
Chris@1770
|
2071 // << layer->getLayerPresentationName() << ")" << endl;
|
Chris@1770
|
2072
|
Chris@1770
|
2073 orderedLayers.push_back(layer);
|
Chris@1770
|
2074 observedLayers.insert(layer);
|
Chris@95
|
2075
|
Chris@95
|
2076 if (factory->isLayerSliceable(layer)) {
|
Chris@95
|
2077 sliceableLayers.insert(layer);
|
Chris@95
|
2078 }
|
Chris@1770
|
2079 }
|
Chris@0
|
2080 }
|
Chris@0
|
2081
|
Chris@33
|
2082 map<QString, int> observedNames;
|
Chris@0
|
2083
|
Chris@137
|
2084 for (size_t i = 0; i < orderedLayers.size(); ++i) {
|
Chris@1770
|
2085
|
Chris@95
|
2086 Layer *layer = orderedLayers[i];
|
Chris@95
|
2087
|
Chris@1770
|
2088 QString name = layer->getLayerPresentationName();
|
Chris@1770
|
2089 int n = ++observedNames[name];
|
Chris@1770
|
2090 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n);
|
Chris@1770
|
2091
|
Chris@1770
|
2092 QIcon icon = il.load(factory->getLayerIconName
|
Chris@168
|
2093 (factory->getLayerType(layer)));
|
Chris@95
|
2094
|
Chris@1770
|
2095 QAction *action = new QAction(icon, name, this);
|
Chris@1770
|
2096 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@1770
|
2097 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@1770
|
2098 m_existingLayerActions[action] = layer;
|
Chris@1770
|
2099
|
Chris@1770
|
2100 m_existingLayersMenu->addAction(action);
|
Chris@95
|
2101
|
Chris@95
|
2102 if (sliceableLayers.find(layer) != sliceableLayers.end()) {
|
Chris@95
|
2103 action = new QAction(icon, name, this);
|
Chris@95
|
2104 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@95
|
2105 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
2106 m_sliceActions[action] = layer;
|
Chris@95
|
2107 m_sliceMenu->addAction(action);
|
Chris@95
|
2108 }
|
Chris@0
|
2109 }
|
Chris@95
|
2110
|
Chris@95
|
2111 m_sliceMenu->setEnabled(!m_sliceActions.empty());
|
Chris@0
|
2112 }
|
Chris@0
|
2113
|
Chris@0
|
2114 void
|
Chris@0
|
2115 MainWindow::setupToolbars()
|
Chris@0
|
2116 {
|
Chris@162
|
2117 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@162
|
2118
|
Chris@168
|
2119 IconLoader il;
|
Chris@168
|
2120
|
Chris@155
|
2121 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@155
|
2122 menu->setTearOffEnabled(true);
|
Chris@155
|
2123 m_rightButtonMenu->addSeparator();
|
Chris@155
|
2124 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@155
|
2125
|
Chris@155
|
2126 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@155
|
2127
|
Chris@265
|
2128 m_rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@265
|
2129 tr("Rewind to Start"));
|
Chris@265
|
2130 m_rwdStartAction->setShortcut(tr("Home"));
|
Chris@265
|
2131 m_rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@265
|
2132 connect(m_rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@265
|
2133 connect(this, SIGNAL(canPlay(bool)), m_rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@265
|
2134
|
Chris@265
|
2135 m_rwdAction = toolbar->addAction(il.load("rewind"), tr("Rewind"));
|
Chris@155
|
2136 m_rwdAction->setShortcut(tr("PgUp"));
|
Chris@163
|
2137 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@155
|
2138 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@155
|
2139 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2140
|
Chris@323
|
2141 m_rwdSimilarAction = new QAction(tr("Rewind to Similar Point"), this);
|
Chris@323
|
2142 m_rwdSimilarAction->setShortcut(tr("Shift+PgUp"));
|
Chris@323
|
2143 m_rwdSimilarAction->setStatusTip(tr("Rewind to the previous similarly valued time instant"));
|
Chris@323
|
2144 connect(m_rwdSimilarAction, SIGNAL(triggered()), this, SLOT(rewindSimilar()));
|
Chris@323
|
2145 connect(this, SIGNAL(canRewind(bool)), m_rwdSimilarAction, SLOT(setEnabled(bool)));
|
Chris@323
|
2146
|
Chris@265
|
2147 m_playAction = toolbar->addAction(il.load("playpause"),
|
Chris@265
|
2148 tr("Play / Pause"));
|
Chris@265
|
2149 m_playAction->setCheckable(true);
|
Chris@1790
|
2150
|
Chris@1790
|
2151 /*: This text is a shortcut label referring to the space-bar on
|
Chris@1790
|
2152 the keyboard. It probably should not be translated, and
|
Chris@1790
|
2153 certainly should not be translated as if referring to an empty
|
Chris@1790
|
2154 void or to the extra-terrestrial universe.
|
Chris@1790
|
2155 */
|
Chris@265
|
2156 m_playAction->setShortcut(tr("Space"));
|
Chris@1790
|
2157
|
Chris@265
|
2158 m_playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@265
|
2159 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
2160 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@1770
|
2161 m_playAction, SLOT(setChecked(bool)));
|
Chris@305
|
2162 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@305
|
2163 this, SLOT(playStatusChanged(bool)));
|
Chris@265
|
2164 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2165
|
Chris@168
|
2166 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@286
|
2167 tr("Fast Forward"));
|
Chris@155
|
2168 m_ffwdAction->setShortcut(tr("PgDown"));
|
Chris@163
|
2169 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@155
|
2170 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@155
|
2171 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2172
|
Chris@323
|
2173 m_ffwdSimilarAction = new QAction(tr("Fast Forward to Similar Point"), this);
|
Chris@323
|
2174 m_ffwdSimilarAction->setShortcut(tr("Shift+PgDown"));
|
Chris@323
|
2175 m_ffwdSimilarAction->setStatusTip(tr("Fast-forward to the next similarly valued time instant"));
|
Chris@323
|
2176 connect(m_ffwdSimilarAction, SIGNAL(triggered()), this, SLOT(ffwdSimilar()));
|
Chris@323
|
2177 connect(this, SIGNAL(canFfwd(bool)), m_ffwdSimilarAction, SLOT(setEnabled(bool)));
|
Chris@323
|
2178
|
Chris@265
|
2179 m_ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@265
|
2180 tr("Fast Forward to End"));
|
Chris@265
|
2181 m_ffwdEndAction->setShortcut(tr("End"));
|
Chris@265
|
2182 m_ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@265
|
2183 connect(m_ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@265
|
2184 connect(this, SIGNAL(canPlay(bool)), m_ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@0
|
2185
|
Chris@1047
|
2186 m_recordAction = toolbar->addAction(il.load("record"),
|
Chris@1047
|
2187 tr("Record"));
|
Chris@1047
|
2188 m_recordAction->setCheckable(true);
|
Chris@1047
|
2189 m_recordAction->setShortcut(tr("Ctrl+Space"));
|
Chris@1047
|
2190 m_recordAction->setStatusTip(tr("Record a new audio file"));
|
Chris@1047
|
2191 connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record()));
|
Chris@1047
|
2192 connect(m_recordTarget, SIGNAL(recordStatusChanged(bool)),
|
Chris@1770
|
2193 m_recordAction, SLOT(setChecked(bool)));
|
Chris@1047
|
2194 connect(this, SIGNAL(canRecord(bool)),
|
Chris@1047
|
2195 m_recordAction, SLOT(setEnabled(bool)));
|
Chris@1047
|
2196
|
Chris@0
|
2197 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
2198
|
Chris@265
|
2199 m_playSelectionAction = toolbar->addAction(il.load("playselection"),
|
Chris@265
|
2200 tr("Constrain Playback to Selection"));
|
Chris@265
|
2201 m_playSelectionAction->setCheckable(true);
|
Chris@265
|
2202 m_playSelectionAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@265
|
2203 m_playSelectionAction->setShortcut(tr("s"));
|
Chris@265
|
2204 m_playSelectionAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@69
|
2205 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@265
|
2206 m_playSelectionAction, SLOT(setChecked(bool)));
|
Chris@265
|
2207 connect(m_playSelectionAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@265
|
2208 connect(this, SIGNAL(canPlaySelection(bool)), m_playSelectionAction, SLOT(setEnabled(bool)));
|
Chris@265
|
2209
|
Chris@265
|
2210 m_playLoopAction = toolbar->addAction(il.load("playloop"),
|
Chris@265
|
2211 tr("Loop Playback"));
|
Chris@265
|
2212 m_playLoopAction->setCheckable(true);
|
Chris@265
|
2213 m_playLoopAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@265
|
2214 m_playLoopAction->setShortcut(tr("l"));
|
Chris@265
|
2215 m_playLoopAction->setStatusTip(tr("Loop playback"));
|
Chris@69
|
2216 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@265
|
2217 m_playLoopAction, SLOT(setChecked(bool)));
|
Chris@265
|
2218 connect(m_playLoopAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@265
|
2219 connect(this, SIGNAL(canPlay(bool)), m_playLoopAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2220
|
Chris@207
|
2221 m_soloAction = toolbar->addAction(il.load("solo"),
|
Chris@323
|
2222 tr("Solo Current Pane"));
|
Chris@207
|
2223 m_soloAction->setCheckable(true);
|
Chris@207
|
2224 m_soloAction->setChecked(m_viewManager->getPlaySoloMode());
|
Chris@207
|
2225 m_prevSolo = m_viewManager->getPlaySoloMode();
|
Chris@207
|
2226 m_soloAction->setShortcut(tr("o"));
|
Chris@207
|
2227 m_soloAction->setStatusTip(tr("Solo the current pane during playback"));
|
Chris@180
|
2228 connect(m_viewManager, SIGNAL(playSoloModeChanged(bool)),
|
Chris@207
|
2229 m_soloAction, SLOT(setChecked(bool)));
|
Chris@207
|
2230 connect(m_soloAction, SIGNAL(triggered()), this, SLOT(playSoloToggled()));
|
Chris@207
|
2231 connect(this, SIGNAL(canChangeSolo(bool)), m_soloAction, SLOT(setEnabled(bool)));
|
Chris@180
|
2232
|
Chris@208
|
2233 QAction *alAction = 0;
|
Chris@208
|
2234 if (Document::canAlign()) {
|
Chris@208
|
2235 alAction = toolbar->addAction(il.load("align"),
|
Chris@208
|
2236 tr("Align File Timelines"));
|
Chris@208
|
2237 alAction->setCheckable(true);
|
Chris@208
|
2238 alAction->setChecked(m_viewManager->getAlignMode());
|
Chris@208
|
2239 alAction->setStatusTip(tr("Treat multiple audio files as versions of the same work, and align their timelines"));
|
Chris@208
|
2240 connect(m_viewManager, SIGNAL(alignModeChanged(bool)),
|
Chris@208
|
2241 alAction, SLOT(setChecked(bool)));
|
Chris@208
|
2242 connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled()));
|
Chris@208
|
2243 connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool)));
|
Chris@208
|
2244 }
|
Chris@206
|
2245
|
Chris@265
|
2246 m_keyReference->registerShortcut(m_playAction);
|
Chris@1056
|
2247 m_keyReference->registerShortcut(m_recordAction);
|
Chris@265
|
2248 m_keyReference->registerShortcut(m_playSelectionAction);
|
Chris@265
|
2249 m_keyReference->registerShortcut(m_playLoopAction);
|
Chris@207
|
2250 m_keyReference->registerShortcut(m_soloAction);
|
Chris@208
|
2251 if (alAction) m_keyReference->registerShortcut(alAction);
|
Chris@162
|
2252 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@162
|
2253 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@323
|
2254 m_keyReference->registerShortcut(m_rwdSimilarAction);
|
Chris@323
|
2255 m_keyReference->registerShortcut(m_ffwdSimilarAction);
|
Chris@265
|
2256 m_keyReference->registerShortcut(m_rwdStartAction);
|
Chris@265
|
2257 m_keyReference->registerShortcut(m_ffwdEndAction);
|
Chris@265
|
2258
|
Chris@265
|
2259 menu->addAction(m_playAction);
|
Chris@1056
|
2260 menu->addAction(m_recordAction);
|
Chris@265
|
2261 menu->addAction(m_playSelectionAction);
|
Chris@265
|
2262 menu->addAction(m_playLoopAction);
|
Chris@207
|
2263 menu->addAction(m_soloAction);
|
Chris@208
|
2264 if (alAction) menu->addAction(alAction);
|
Chris@155
|
2265 menu->addSeparator();
|
Chris@155
|
2266 menu->addAction(m_rwdAction);
|
Chris@155
|
2267 menu->addAction(m_ffwdAction);
|
Chris@155
|
2268 menu->addSeparator();
|
Chris@323
|
2269 menu->addAction(m_rwdSimilarAction);
|
Chris@323
|
2270 menu->addAction(m_ffwdSimilarAction);
|
Chris@323
|
2271 menu->addSeparator();
|
Chris@265
|
2272 menu->addAction(m_rwdStartAction);
|
Chris@265
|
2273 menu->addAction(m_ffwdEndAction);
|
Chris@155
|
2274 menu->addSeparator();
|
Chris@1055
|
2275 menu->addAction(m_recordAction);
|
Chris@1055
|
2276 menu->addSeparator();
|
Chris@155
|
2277
|
Chris@265
|
2278 m_rightButtonPlaybackMenu->addAction(m_playAction);
|
Chris@265
|
2279 m_rightButtonPlaybackMenu->addAction(m_playSelectionAction);
|
Chris@265
|
2280 m_rightButtonPlaybackMenu->addAction(m_playLoopAction);
|
Chris@207
|
2281 m_rightButtonPlaybackMenu->addAction(m_soloAction);
|
Chris@208
|
2282 if (alAction) m_rightButtonPlaybackMenu->addAction(alAction);
|
Chris@155
|
2283 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@155
|
2284 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@155
|
2285 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@155
|
2286 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@265
|
2287 m_rightButtonPlaybackMenu->addAction(m_rwdStartAction);
|
Chris@265
|
2288 m_rightButtonPlaybackMenu->addAction(m_ffwdEndAction);
|
Chris@155
|
2289 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@1055
|
2290 m_rightButtonPlaybackMenu->addAction(m_recordAction);
|
Chris@1055
|
2291 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@155
|
2292
|
Chris@155
|
2293 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@155
|
2294 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@163
|
2295 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@155
|
2296 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@155
|
2297 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2298
|
Chris@155
|
2299 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@155
|
2300 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@163
|
2301 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@155
|
2302 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@155
|
2303 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2304
|
Chris@155
|
2305 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@155
|
2306 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@163
|
2307 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@155
|
2308 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@155
|
2309 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@155
|
2310
|
Chris@162
|
2311 m_keyReference->registerShortcut(fastAction);
|
Chris@162
|
2312 m_keyReference->registerShortcut(slowAction);
|
Chris@162
|
2313 m_keyReference->registerShortcut(normalAction);
|
Chris@162
|
2314
|
Chris@155
|
2315 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@155
|
2316 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@155
|
2317 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@0
|
2318
|
Chris@0
|
2319 toolbar = addToolBar(tr("Edit Toolbar"));
|
Chris@0
|
2320 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@0
|
2321
|
Chris@0
|
2322 toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@0
|
2323 QActionGroup *group = new QActionGroup(this);
|
Chris@0
|
2324
|
Chris@705
|
2325 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@168
|
2326 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@155
|
2327 tr("Navigate"));
|
Chris@0
|
2328 action->setCheckable(true);
|
Chris@0
|
2329 action->setChecked(true);
|
Chris@0
|
2330 action->setShortcut(tr("1"));
|
Chris@90
|
2331 action->setStatusTip(tr("Navigate"));
|
Chris@0
|
2332 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@596
|
2333 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@0
|
2334 group->addAction(action);
|
Chris@162
|
2335 m_keyReference->registerShortcut(action);
|
Chris@0
|
2336 m_toolActions[ViewManager::NavigateMode] = action;
|
Chris@705
|
2337
|
Chris@705
|
2338 m_keyReference->setCategory
|
Chris@705
|
2339 (tr("Navigate Tool Mouse Actions"));
|
Chris@705
|
2340 m_keyReference->registerShortcut
|
Chris@705
|
2341 (tr("Navigate"), tr("Left"),
|
Chris@705
|
2342 tr("Click left button and drag to move around"));
|
Chris@705
|
2343 m_keyReference->registerShortcut
|
Chris@705
|
2344 (tr("Zoom to Area"), tr("Shift+Left"),
|
Chris@705
|
2345 tr("Shift-click left button and drag to zoom to a rectangular area"));
|
Chris@705
|
2346 m_keyReference->registerShortcut
|
Chris@705
|
2347 (tr("Relocate"), tr("Double-Click Left"),
|
Chris@705
|
2348 tr("Double-click left button to jump to clicked location"));
|
Chris@705
|
2349 m_keyReference->registerShortcut
|
Chris@705
|
2350 (tr("Edit"), tr("Double-Click Left"),
|
Chris@705
|
2351 tr("Double-click left button on an item to edit it"));
|
Chris@705
|
2352
|
Chris@705
|
2353 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@168
|
2354 action = toolbar->addAction(il.load("select"),
|
Chris@1770
|
2355 tr("Select"));
|
Chris@0
|
2356 action->setCheckable(true);
|
Chris@0
|
2357 action->setShortcut(tr("2"));
|
Chris@90
|
2358 action->setStatusTip(tr("Select ranges"));
|
Chris@0
|
2359 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected()));
|
Chris@0
|
2360 group->addAction(action);
|
Chris@162
|
2361 m_keyReference->registerShortcut(action);
|
Chris@0
|
2362 m_toolActions[ViewManager::SelectMode] = action;
|
Chris@705
|
2363
|
Chris@705
|
2364 m_keyReference->setCategory
|
Chris@705
|
2365 (tr("Select Tool Mouse Actions"));
|
Chris@705
|
2366 m_keyReference->registerShortcut
|
Chris@705
|
2367 (tr("Select"), tr("Left"),
|
Chris@705
|
2368 tr("Click left button and drag to select region; drag region edge to resize"));
|
Chris@705
|
2369 #ifdef Q_OS_MAC
|
Chris@705
|
2370 m_keyReference->registerShortcut
|
Chris@705
|
2371 (tr("Multi Select"), tr("Ctrl+Left"),
|
Chris@705
|
2372 tr("Cmd-click left button and drag to select an additional region"));
|
Chris@705
|
2373 #else
|
Chris@705
|
2374 m_keyReference->registerShortcut
|
Chris@705
|
2375 (tr("Multi Select"), tr("Ctrl+Left"),
|
Chris@705
|
2376 tr("Ctrl-click left button and drag to select an additional region"));
|
Chris@705
|
2377 #endif
|
Chris@705
|
2378 m_keyReference->registerShortcut
|
Chris@705
|
2379 (tr("Fine Select"), tr("Shift+Left"),
|
Chris@705
|
2380 tr("Shift-click left button and drag to select without snapping to items or grid"));
|
Chris@705
|
2381
|
Chris@705
|
2382 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@168
|
2383 action = toolbar->addAction(il.load("move"),
|
Chris@1770
|
2384 tr("Edit"));
|
Chris@0
|
2385 action->setCheckable(true);
|
Chris@0
|
2386 action->setShortcut(tr("3"));
|
Chris@90
|
2387 action->setStatusTip(tr("Edit items in layer"));
|
Chris@0
|
2388 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@0
|
2389 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
2390 group->addAction(action);
|
Chris@162
|
2391 m_keyReference->registerShortcut(action);
|
Chris@0
|
2392 m_toolActions[ViewManager::EditMode] = action;
|
Chris@705
|
2393
|
Chris@705
|
2394 m_keyReference->setCategory
|
Chris@705
|
2395 (tr("Edit Tool Mouse Actions"));
|
Chris@705
|
2396 m_keyReference->registerShortcut
|
Chris@705
|
2397 (tr("Move"), tr("Left"),
|
Chris@705
|
2398 tr("Click left button on an item or selected region and drag to move"));
|
Chris@705
|
2399 m_keyReference->registerShortcut
|
Chris@705
|
2400 (tr("Edit"), tr("Double-Click Left"),
|
Chris@705
|
2401 tr("Double-click left button on an item to edit it"));
|
Chris@705
|
2402
|
Chris@705
|
2403 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@168
|
2404 action = toolbar->addAction(il.load("draw"),
|
Chris@1770
|
2405 tr("Draw"));
|
Chris@0
|
2406 action->setCheckable(true);
|
Chris@0
|
2407 action->setShortcut(tr("4"));
|
Chris@90
|
2408 action->setStatusTip(tr("Draw new items in layer"));
|
Chris@0
|
2409 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected()));
|
Chris@0
|
2410 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
2411 group->addAction(action);
|
Chris@162
|
2412 m_keyReference->registerShortcut(action);
|
Chris@0
|
2413 m_toolActions[ViewManager::DrawMode] = action;
|
Chris@0
|
2414
|
Chris@705
|
2415 m_keyReference->setCategory
|
Chris@705
|
2416 (tr("Draw Tool Mouse Actions"));
|
Chris@705
|
2417 m_keyReference->registerShortcut
|
Chris@705
|
2418 (tr("Draw"), tr("Left"),
|
Chris@705
|
2419 tr("Click left button and drag to create new item"));
|
Chris@705
|
2420
|
Chris@705
|
2421 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@217
|
2422 action = toolbar->addAction(il.load("erase"),
|
Chris@1770
|
2423 tr("Erase"));
|
Chris@217
|
2424 action->setCheckable(true);
|
Chris@217
|
2425 action->setShortcut(tr("5"));
|
Chris@217
|
2426 action->setStatusTip(tr("Erase items from layer"));
|
Chris@217
|
2427 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected()));
|
Chris@217
|
2428 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@217
|
2429 group->addAction(action);
|
Chris@217
|
2430 m_keyReference->registerShortcut(action);
|
Chris@217
|
2431 m_toolActions[ViewManager::EraseMode] = action;
|
Chris@217
|
2432
|
Chris@705
|
2433 m_keyReference->setCategory
|
Chris@705
|
2434 (tr("Erase Tool Mouse Actions"));
|
Chris@705
|
2435 m_keyReference->registerShortcut
|
Chris@705
|
2436 (tr("Erase"), tr("Left"),
|
Chris@705
|
2437 tr("Click left button on an item to remove it from the layer"));
|
Chris@705
|
2438
|
Chris@705
|
2439 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@265
|
2440 action = toolbar->addAction(il.load("measure"), tr("Measure"));
|
Chris@151
|
2441 action->setCheckable(true);
|
Chris@217
|
2442 action->setShortcut(tr("6"));
|
Chris@151
|
2443 action->setStatusTip(tr("Make measurements in layer"));
|
Chris@151
|
2444 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected()));
|
Chris@169
|
2445 connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@151
|
2446 group->addAction(action);
|
Chris@162
|
2447 m_keyReference->registerShortcut(action);
|
Chris@151
|
2448 m_toolActions[ViewManager::MeasureMode] = action;
|
Chris@151
|
2449
|
Chris@705
|
2450 m_keyReference->setCategory
|
Chris@705
|
2451 (tr("Measure Tool Mouse Actions"));
|
Chris@705
|
2452 m_keyReference->registerShortcut
|
Chris@705
|
2453 (tr("Measure Area"), tr("Left"),
|
Chris@705
|
2454 tr("Click left button and drag to measure a rectangular area"));
|
Chris@705
|
2455 m_keyReference->registerShortcut
|
Chris@705
|
2456 (tr("Measure Item"), tr("Double-Click Left"),
|
Chris@705
|
2457 tr("Click left button and drag to measure extents of an item or shape"));
|
Chris@705
|
2458 m_keyReference->registerShortcut
|
Chris@705
|
2459 (tr("Zoom to Area"), tr("Shift+Left"),
|
Chris@705
|
2460 tr("Shift-click left button and drag to zoom to a rectangular area"));
|
Chris@705
|
2461
|
Chris@0
|
2462 toolNavigateSelected();
|
Chris@163
|
2463
|
Chris@163
|
2464 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
2465 }
|
Chris@0
|
2466
|
Chris@0
|
2467 void
|
Chris@265
|
2468 MainWindow::connectLayerEditDialog(ModelDataTableDialog *dialog)
|
Chris@265
|
2469 {
|
Chris@265
|
2470 MainWindowBase::connectLayerEditDialog(dialog);
|
Chris@265
|
2471 QToolBar *toolbar = dialog->getPlayToolbar();
|
Chris@265
|
2472 if (toolbar) {
|
Chris@265
|
2473 toolbar->addAction(m_rwdStartAction);
|
Chris@265
|
2474 toolbar->addAction(m_rwdAction);
|
Chris@265
|
2475 toolbar->addAction(m_playAction);
|
Chris@265
|
2476 toolbar->addAction(m_ffwdAction);
|
Chris@265
|
2477 toolbar->addAction(m_ffwdEndAction);
|
Chris@265
|
2478 }
|
Chris@265
|
2479 }
|
Chris@265
|
2480
|
Chris@265
|
2481 void
|
Chris@0
|
2482 MainWindow::updateMenuStates()
|
Chris@0
|
2483 {
|
Chris@200
|
2484 MainWindowBase::updateMenuStates();
|
Chris@200
|
2485
|
Chris@117
|
2486 Pane *currentPane = 0;
|
Chris@117
|
2487 Layer *currentLayer = 0;
|
Chris@117
|
2488
|
Chris@117
|
2489 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@117
|
2490 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@117
|
2491
|
Chris@0
|
2492 bool haveCurrentPane =
|
Chris@117
|
2493 (currentPane != 0);
|
Chris@0
|
2494 bool haveCurrentLayer =
|
Chris@117
|
2495 (haveCurrentPane &&
|
Chris@117
|
2496 (currentLayer != 0));
|
Chris@206
|
2497 bool havePlayTarget =
|
Chris@1770
|
2498 (m_playTarget != 0 || m_audioIO != 0);
|
Chris@0
|
2499 bool haveSelection =
|
Chris@1770
|
2500 (m_viewManager &&
|
Chris@1770
|
2501 !m_viewManager->getSelections().empty());
|
Chris@0
|
2502 bool haveCurrentEditableLayer =
|
Chris@1770
|
2503 (haveCurrentLayer &&
|
Chris@1770
|
2504 currentLayer->isLayerEditable());
|
Chris@0
|
2505 bool haveCurrentTimeInstantsLayer =
|
Chris@1770
|
2506 (haveCurrentLayer &&
|
Chris@1770
|
2507 dynamic_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
2508 bool haveCurrentTimeValueLayer =
|
Chris@1770
|
2509 (haveCurrentLayer &&
|
Chris@1770
|
2510 dynamic_cast<TimeValueLayer *>(currentLayer));
|
Chris@207
|
2511
|
Chris@314
|
2512 bool alignMode = m_viewManager && m_viewManager->getAlignMode();
|
Chris@314
|
2513 emit canChangeSolo(havePlayTarget && !alignMode);
|
Chris@207
|
2514 emit canAlign(havePlayTarget && m_document && m_document->canAlign());
|
Chris@206
|
2515
|
Chris@200
|
2516 emit canChangePlaybackSpeed(true);
|
Chris@200
|
2517 int v = m_playSpeed->value();
|
Chris@200
|
2518 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@200
|
2519 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@155
|
2520
|
Chris@164
|
2521 if (m_viewManager &&
|
Chris@164
|
2522 (m_viewManager->getToolMode() == ViewManager::MeasureMode)) {
|
Chris@164
|
2523 emit canDeleteSelection(haveCurrentLayer);
|
Chris@164
|
2524 m_deleteSelectedAction->setText(tr("&Delete Current Measurement"));
|
Chris@164
|
2525 m_deleteSelectedAction->setStatusTip(tr("Delete the measurement currently under the mouse pointer"));
|
Chris@164
|
2526 } else {
|
Chris@164
|
2527 emit canDeleteSelection(haveSelection && haveCurrentEditableLayer);
|
Chris@164
|
2528 m_deleteSelectedAction->setText(tr("&Delete Selected Items"));
|
Chris@164
|
2529 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
|
Chris@164
|
2530 }
|
Chris@164
|
2531
|
Chris@155
|
2532 if (m_ffwdAction && m_rwdAction) {
|
Chris@155
|
2533 if (haveCurrentTimeInstantsLayer) {
|
Chris@155
|
2534 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@155
|
2535 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@155
|
2536 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@155
|
2537 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@155
|
2538 } else if (haveCurrentTimeValueLayer) {
|
Chris@155
|
2539 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@155
|
2540 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@155
|
2541 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@155
|
2542 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@155
|
2543 } else {
|
Chris@155
|
2544 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@155
|
2545 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@155
|
2546 m_rwdAction->setText(tr("Rewind"));
|
Chris@155
|
2547 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@155
|
2548 }
|
Chris@155
|
2549 }
|
Chris@0
|
2550 }
|
Chris@0
|
2551
|
Chris@0
|
2552 void
|
Chris@0
|
2553 MainWindow::updateDescriptionLabel()
|
Chris@0
|
2554 {
|
Chris@0
|
2555 if (!getMainModel()) {
|
Chris@1770
|
2556 m_descriptionLabel->setText(tr("No audio file loaded."));
|
Chris@1770
|
2557 return;
|
Chris@0
|
2558 }
|
Chris@0
|
2559
|
Chris@0
|
2560 QString description;
|
Chris@0
|
2561
|
Chris@1404
|
2562 //!!!???
|
Chris@1404
|
2563
|
Chris@922
|
2564 sv_samplerate_t ssr = getMainModel()->getSampleRate();
|
Chris@922
|
2565 sv_samplerate_t tsr = ssr;
|
Chris@1405
|
2566 if (m_playSource) tsr = m_playSource->getDeviceSampleRate();
|
Chris@0
|
2567
|
Chris@0
|
2568 if (ssr != tsr) {
|
Chris@1770
|
2569 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
|
Chris@0
|
2570 } else {
|
Chris@1770
|
2571 description = QString("%1Hz").arg(ssr);
|
Chris@0
|
2572 }
|
Chris@0
|
2573
|
Chris@0
|
2574 description = QString("%1 - %2")
|
Chris@1770
|
2575 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr)
|
Chris@1770
|
2576 .toText(false).c_str())
|
Chris@1770
|
2577 .arg(description);
|
Chris@0
|
2578
|
Chris@0
|
2579 m_descriptionLabel->setText(description);
|
Chris@0
|
2580 }
|
Chris@0
|
2581
|
Chris@0
|
2582 void
|
Chris@0
|
2583 MainWindow::documentModified()
|
Chris@0
|
2584 {
|
Chris@200
|
2585 //!!!
|
Chris@200
|
2586 MainWindowBase::documentModified();
|
Chris@0
|
2587 }
|
Chris@0
|
2588
|
Chris@0
|
2589 void
|
Chris@0
|
2590 MainWindow::documentRestored()
|
Chris@0
|
2591 {
|
Chris@200
|
2592 //!!!
|
Chris@200
|
2593 MainWindowBase::documentRestored();
|
Chris@0
|
2594 }
|
Chris@0
|
2595
|
Chris@0
|
2596 void
|
Chris@0
|
2597 MainWindow::toolNavigateSelected()
|
Chris@0
|
2598 {
|
Chris@0
|
2599 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
2600 }
|
Chris@0
|
2601
|
Chris@0
|
2602 void
|
Chris@0
|
2603 MainWindow::toolSelectSelected()
|
Chris@0
|
2604 {
|
Chris@0
|
2605 m_viewManager->setToolMode(ViewManager::SelectMode);
|
Chris@0
|
2606 }
|
Chris@0
|
2607
|
Chris@0
|
2608 void
|
Chris@0
|
2609 MainWindow::toolEditSelected()
|
Chris@0
|
2610 {
|
Chris@0
|
2611 m_viewManager->setToolMode(ViewManager::EditMode);
|
Chris@0
|
2612 }
|
Chris@0
|
2613
|
Chris@0
|
2614 void
|
Chris@0
|
2615 MainWindow::toolDrawSelected()
|
Chris@0
|
2616 {
|
Chris@0
|
2617 m_viewManager->setToolMode(ViewManager::DrawMode);
|
Chris@0
|
2618 }
|
Chris@0
|
2619
|
Chris@151
|
2620 void
|
Chris@217
|
2621 MainWindow::toolEraseSelected()
|
Chris@217
|
2622 {
|
Chris@217
|
2623 m_viewManager->setToolMode(ViewManager::EraseMode);
|
Chris@217
|
2624 }
|
Chris@217
|
2625
|
Chris@217
|
2626 void
|
Chris@151
|
2627 MainWindow::toolMeasureSelected()
|
Chris@151
|
2628 {
|
Chris@151
|
2629 m_viewManager->setToolMode(ViewManager::MeasureMode);
|
Chris@151
|
2630 }
|
Chris@151
|
2631
|
Chris@0
|
2632 void
|
Chris@0
|
2633 MainWindow::importAudio()
|
Chris@0
|
2634 {
|
Chris@88
|
2635 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
2636
|
Chris@0
|
2637 if (path != "") {
|
Chris@1770
|
2638 if (openAudio(path, ReplaceSession) == FileOpenFailed) {
|
Chris@247
|
2639 emit hideSplash();
|
Chris@1770
|
2640 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@1770
|
2641 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@1770
|
2642 }
|
Chris@0
|
2643 }
|
Chris@0
|
2644 }
|
Chris@0
|
2645
|
Chris@0
|
2646 void
|
Chris@0
|
2647 MainWindow::importMoreAudio()
|
Chris@0
|
2648 {
|
Chris@88
|
2649 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
2650
|
Chris@0
|
2651 if (path != "") {
|
Chris@1770
|
2652 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) {
|
Chris@247
|
2653 emit hideSplash();
|
Chris@1770
|
2654 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@1770
|
2655 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@1770
|
2656 }
|
Chris@0
|
2657 }
|
Chris@0
|
2658 }
|
Chris@0
|
2659
|
Chris@0
|
2660 void
|
Chris@508
|
2661 MainWindow::replaceMainAudio()
|
Chris@508
|
2662 {
|
Chris@508
|
2663 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@508
|
2664
|
Chris@508
|
2665 if (path != "") {
|
Chris@1770
|
2666 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) {
|
Chris@508
|
2667 emit hideSplash();
|
Chris@1770
|
2668 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@1770
|
2669 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@1770
|
2670 }
|
Chris@508
|
2671 }
|
Chris@508
|
2672 }
|
Chris@508
|
2673
|
Chris@508
|
2674 void
|
Chris@0
|
2675 MainWindow::exportAudio()
|
Chris@0
|
2676 {
|
Chris@631
|
2677 exportAudio(false);
|
Chris@631
|
2678 }
|
Chris@631
|
2679
|
Chris@631
|
2680 void
|
Chris@631
|
2681 MainWindow::exportAudioData()
|
Chris@631
|
2682 {
|
Chris@631
|
2683 exportAudio(true);
|
Chris@631
|
2684 }
|
Chris@631
|
2685
|
Chris@631
|
2686 void
|
Chris@631
|
2687 MainWindow::exportAudio(bool asData)
|
Chris@631
|
2688 {
|
Chris@0
|
2689 if (!getMainModel()) return;
|
Chris@0
|
2690
|
Chris@320
|
2691 RangeSummarisableTimeValueModel *model = getMainModel();
|
Chris@320
|
2692 std::set<RangeSummarisableTimeValueModel *> otherModels;
|
Chris@320
|
2693 RangeSummarisableTimeValueModel *current = model;
|
Chris@320
|
2694 if (m_paneStack) {
|
Chris@320
|
2695 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@320
|
2696 Pane *pane = m_paneStack->getPane(i);
|
Chris@320
|
2697 if (!pane) continue;
|
Chris@320
|
2698 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@320
|
2699 Layer *layer = pane->getLayer(j);
|
Chris@320
|
2700 if (!layer) continue;
|
Chris@432
|
2701 cerr << "layer = " << layer->objectName() << endl;
|
Chris@320
|
2702 Model *m = layer->getModel();
|
Chris@320
|
2703 RangeSummarisableTimeValueModel *wm =
|
Chris@320
|
2704 dynamic_cast<RangeSummarisableTimeValueModel *>(m);
|
Chris@320
|
2705 if (wm) {
|
Chris@432
|
2706 cerr << "found: " << wm->objectName() << endl;
|
Chris@320
|
2707 otherModels.insert(wm);
|
Chris@320
|
2708 if (pane == m_paneStack->getCurrentPane()) {
|
Chris@320
|
2709 current = wm;
|
Chris@320
|
2710 }
|
Chris@320
|
2711 }
|
Chris@320
|
2712 }
|
Chris@320
|
2713 }
|
Chris@320
|
2714 }
|
Chris@320
|
2715 if (!otherModels.empty()) {
|
Chris@320
|
2716 std::map<QString, RangeSummarisableTimeValueModel *> m;
|
Chris@320
|
2717 m[tr("1. %2").arg(model->objectName())] = model;
|
Chris@320
|
2718 int n = 2;
|
Chris@320
|
2719 int c = 0;
|
Chris@320
|
2720 for (std::set<RangeSummarisableTimeValueModel *>::const_iterator i
|
Chris@320
|
2721 = otherModels.begin();
|
Chris@320
|
2722 i != otherModels.end(); ++i) {
|
Chris@320
|
2723 if (*i == model) continue;
|
Chris@320
|
2724 m[tr("%1. %2").arg(n).arg((*i)->objectName())] = *i;
|
Chris@320
|
2725 ++n;
|
Chris@320
|
2726 if (*i == current) c = n-1;
|
Chris@320
|
2727 }
|
Chris@320
|
2728 QStringList items;
|
Chris@320
|
2729 for (std::map<QString, RangeSummarisableTimeValueModel *>
|
Chris@320
|
2730 ::const_iterator i = m.begin();
|
Chris@320
|
2731 i != m.end(); ++i) {
|
Chris@320
|
2732 items << i->first;
|
Chris@320
|
2733 }
|
Chris@325
|
2734 if (items.size() > 1) {
|
Chris@325
|
2735 bool ok = false;
|
Chris@325
|
2736 QString item = QInputDialog::getItem
|
Chris@325
|
2737 (this, tr("Select audio file to export"),
|
Chris@325
|
2738 tr("Which audio file do you want to export from?"),
|
Chris@325
|
2739 items, c, false, &ok);
|
Chris@325
|
2740 if (!ok || item.isEmpty()) return;
|
Chris@325
|
2741 if (m.find(item) == m.end()) {
|
Chris@665
|
2742 cerr << "WARNING: Model " << item
|
Chris@325
|
2743 << " not found in list!" << endl;
|
Chris@325
|
2744 } else {
|
Chris@325
|
2745 model = m[item];
|
Chris@325
|
2746 }
|
Chris@320
|
2747 }
|
Chris@320
|
2748 }
|
Chris@320
|
2749
|
Chris@631
|
2750 QString path;
|
Chris@631
|
2751 if (asData) {
|
Chris@631
|
2752 path = getSaveFileName(FileFinder::CSVFile);
|
Chris@631
|
2753 } else {
|
Chris@631
|
2754 path = getSaveFileName(FileFinder::AudioFile);
|
Chris@631
|
2755 }
|
Chris@0
|
2756 if (path == "") return;
|
Chris@0
|
2757
|
Chris@0
|
2758 bool ok = false;
|
Chris@0
|
2759 QString error;
|
Chris@0
|
2760
|
Chris@0
|
2761 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
2762 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
2763
|
Chris@0
|
2764 bool multiple = false;
|
Chris@0
|
2765
|
Chris@38
|
2766 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
2767
|
Chris@38
|
2768 if (selections.size() == 1) {
|
Chris@0
|
2769
|
Chris@1770
|
2770 QStringList items;
|
Chris@1770
|
2771 items << tr("Export the selected region only")
|
Chris@1770
|
2772 << tr("Export the whole audio file");
|
Chris@1770
|
2773
|
Chris@1770
|
2774 bool ok = false;
|
Chris@1770
|
2775 QString item = ListInputDialog::getItem
|
Chris@1770
|
2776 (this, tr("Select region to export"),
|
Chris@1770
|
2777 tr("Which region from the original audio file do you want to export?"),
|
Chris@1770
|
2778 items, 0, &ok);
|
Chris@1770
|
2779
|
Chris@1770
|
2780 if (!ok || item.isEmpty()) return;
|
Chris@1770
|
2781
|
Chris@1770
|
2782 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2783
|
Chris@38
|
2784 } else if (selections.size() > 1) {
|
Chris@0
|
2785
|
Chris@631
|
2786 if (!asData) { // Multi-file export not supported for data
|
Chris@631
|
2787
|
Chris@631
|
2788 QStringList items;
|
Chris@631
|
2789 items << tr("Export the selected regions into a single file")
|
Chris@631
|
2790 << tr("Export the selected regions into separate files")
|
Chris@631
|
2791 << tr("Export the whole file");
|
Chris@631
|
2792
|
Chris@631
|
2793 QString item = ListInputDialog::getItem
|
Chris@631
|
2794 (this, tr("Select region to export"),
|
Chris@631
|
2795 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@631
|
2796 items, 0, &ok);
|
Chris@1770
|
2797
|
Chris@631
|
2798 if (!ok || item.isEmpty()) return;
|
Chris@631
|
2799
|
Chris@631
|
2800 if (item == items[0]) {
|
Chris@631
|
2801 selectionToWrite = &ms;
|
Chris@631
|
2802 } else if (item == items[1]) {
|
Chris@631
|
2803 multiple = true;
|
Chris@631
|
2804 }
|
Chris@631
|
2805
|
Chris@631
|
2806 } else { // asData
|
Chris@38
|
2807 selectionToWrite = &ms;
|
Chris@631
|
2808 }
|
Chris@631
|
2809
|
Chris@631
|
2810 if (multiple) { // Can only happen when asData false
|
Chris@0
|
2811
|
Chris@1770
|
2812 int n = 1;
|
Chris@1770
|
2813 QString base = path;
|
Chris@1770
|
2814 base.replace(".wav", "");
|
Chris@1770
|
2815
|
Chris@1770
|
2816 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@1770
|
2817 i != selections.end(); ++i) {
|
Chris@1770
|
2818
|
Chris@1770
|
2819 MultiSelection subms;
|
Chris@1770
|
2820 subms.setSelection(*i);
|
Chris@1770
|
2821
|
Chris@1770
|
2822 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@1770
|
2823 ++n;
|
Chris@1770
|
2824
|
Chris@1770
|
2825 if (QFileInfo(subpath).exists()) {
|
Chris@1770
|
2826 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@1770
|
2827 break;
|
Chris@1770
|
2828 }
|
Chris@1770
|
2829
|
Chris@1770
|
2830 WavFileWriter subwriter(subpath,
|
Chris@320
|
2831 model->getSampleRate(),
|
Chris@428
|
2832 model->getChannelCount(),
|
Chris@428
|
2833 WavFileWriter::WriteToTemporary);
|
Chris@320
|
2834 subwriter.writeModel(model, &subms);
|
Chris@1770
|
2835 ok = subwriter.isOK();
|
Chris@1770
|
2836
|
Chris@1770
|
2837 if (!ok) {
|
Chris@1770
|
2838 error = subwriter.getError();
|
Chris@1770
|
2839 break;
|
Chris@1770
|
2840 }
|
Chris@1770
|
2841 }
|
Chris@1770
|
2842 }
|
Chris@0
|
2843 }
|
Chris@0
|
2844
|
Chris@38
|
2845 if (!multiple) {
|
Chris@631
|
2846 if (asData) {
|
Chris@1779
|
2847 stop();
|
Chris@1779
|
2848 ProgressDialog dialog {
|
Chris@1779
|
2849 QObject::tr("Exporting audio data..."),
|
Chris@1779
|
2850 true,
|
Chris@1779
|
2851 0,
|
Chris@1779
|
2852 this,
|
Chris@1779
|
2853 Qt::ApplicationModal
|
Chris@1779
|
2854 };
|
Chris@1779
|
2855 CSVFileWriter writer(path, model, &dialog,
|
Chris@631
|
2856 ((QFileInfo(path).suffix() == "csv") ?
|
Chris@631
|
2857 "," : "\t"));
|
Chris@631
|
2858 if (selectionToWrite) {
|
Chris@1779
|
2859 writer.writeSelection(*selectionToWrite);
|
Chris@631
|
2860 } else {
|
Chris@631
|
2861 writer.write();
|
Chris@631
|
2862 }
|
Chris@631
|
2863 ok = writer.isOK();
|
Chris@631
|
2864 error = writer.getError();
|
Chris@631
|
2865 } else {
|
Chris@631
|
2866 WavFileWriter writer(path,
|
Chris@631
|
2867 model->getSampleRate(),
|
Chris@631
|
2868 model->getChannelCount(),
|
Chris@631
|
2869 WavFileWriter::WriteToTemporary);
|
Chris@631
|
2870 writer.writeModel(model, selectionToWrite);
|
Chris@631
|
2871 ok = writer.isOK();
|
Chris@631
|
2872 error = writer.getError();
|
Chris@631
|
2873 }
|
Chris@0
|
2874 }
|
Chris@0
|
2875
|
Chris@0
|
2876 if (ok) {
|
Chris@310
|
2877 if (multiple) {
|
Chris@310
|
2878 emit activity(tr("Export multiple audio files"));
|
Chris@310
|
2879 } else {
|
Chris@310
|
2880 emit activity(tr("Export audio to \"%1\"").arg(path));
|
Chris@34
|
2881 m_recentFiles.addFile(path);
|
Chris@0
|
2882 }
|
Chris@0
|
2883 } else {
|
Chris@1770
|
2884 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2885 }
|
Chris@0
|
2886 }
|
Chris@0
|
2887
|
Chris@0
|
2888 void
|
Chris@1902
|
2889 MainWindow::importAudioData()
|
Chris@1902
|
2890 {
|
Chris@1902
|
2891 QString path = getOpenFileName(FileFinder::CSVFile);
|
Chris@1902
|
2892 if (path == "") return;
|
Chris@1902
|
2893
|
Chris@1902
|
2894 sv_samplerate_t rate = 44100; //!!!
|
Chris@1902
|
2895
|
Chris@1902
|
2896 CSVFormat format(path);
|
Chris@1902
|
2897 format.setModelType(CSVFormat::WaveFileModel);
|
Chris@1902
|
2898 format.setSampleRate(rate);
|
Chris@1902
|
2899 format.setTimingType(CSVFormat::ImplicitTiming);
|
Chris@1902
|
2900 format.setTimeUnits(CSVFormat::TimeAudioFrames);
|
Chris@1986
|
2901 for (int i = 0; i < format.getColumnCount(); ++i) {
|
Chris@1987
|
2902 if (format.isColumnNumeric(CSVFormat::ColumnNumeric)) {
|
Chris@1986
|
2903 format.setColumnPurpose(i, CSVFormat::ColumnValue);
|
Chris@1986
|
2904 }
|
Chris@1986
|
2905 }
|
Chris@1902
|
2906
|
Chris@1987
|
2907 {
|
Chris@1987
|
2908 CSVFormatDialog *dialog = new CSVFormatDialog(this, format);
|
Chris@1987
|
2909 if (dialog->exec() != QDialog::Accepted) {
|
Chris@1987
|
2910 delete dialog;
|
Chris@1987
|
2911 return;
|
Chris@1987
|
2912 }
|
Chris@1987
|
2913 format = dialog->getFormat();
|
Chris@1987
|
2914 delete dialog;
|
Chris@1987
|
2915 }
|
Chris@1987
|
2916
|
Chris@1902
|
2917 FileOpenStatus status = FileOpenSucceeded;
|
Chris@1911
|
2918
|
Chris@1987
|
2919 ProgressDialog *progress = new ProgressDialog
|
Chris@1987
|
2920 (tr("Importing audio data..."), true, 0, this, Qt::ApplicationModal);
|
Chris@1902
|
2921
|
Chris@1902
|
2922 WaveFileModel *model = qobject_cast<WaveFileModel *>
|
Chris@1902
|
2923 (DataFileReaderFactory::loadCSV
|
Chris@1902
|
2924 (path, format,
|
Chris@1911
|
2925 getMainModel() ? getMainModel()->getSampleRate() : rate,
|
Chris@1987
|
2926 progress));
|
Chris@1987
|
2927
|
Chris@1987
|
2928 if (progress->wasCancelled()) {
|
Chris@1911
|
2929
|
Chris@1911
|
2930 delete model;
|
Chris@1911
|
2931 status = FileOpenCancelled;
|
Chris@1911
|
2932
|
Chris@1911
|
2933 } else if (!model || !model->isOK()) {
|
Chris@1902
|
2934
|
Chris@1902
|
2935 delete model;
|
Chris@1902
|
2936 status = FileOpenFailed;
|
Chris@1902
|
2937
|
Chris@1902
|
2938 } else {
|
Chris@1902
|
2939
|
Chris@1902
|
2940 status = addOpenedAudioModel(path,
|
Chris@1902
|
2941 model,
|
Chris@1902
|
2942 CreateAdditionalModel,
|
Chris@1902
|
2943 getDefaultSessionTemplate(),
|
Chris@1902
|
2944 false);
|
Chris@1902
|
2945 }
|
Chris@1902
|
2946
|
Chris@1987
|
2947 delete progress;
|
Chris@1911
|
2948
|
Chris@1902
|
2949 if (status == FileOpenFailed) {
|
Chris@1902
|
2950 emit hideSplash();
|
Chris@1902
|
2951 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@1902
|
2952 tr("<b>File open failed</b><p>Audio data file %1 could not be opened.").arg(path));
|
Chris@1902
|
2953 }
|
Chris@1902
|
2954 }
|
Chris@1902
|
2955
|
Chris@1902
|
2956 void
|
Chris@0
|
2957 MainWindow::importLayer()
|
Chris@0
|
2958 {
|
Chris@0
|
2959 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2960
|
Chris@0
|
2961 if (!pane) {
|
Chris@1770
|
2962 // shouldn't happen, as the menu action should have been disabled
|
Chris@1770
|
2963 cerr << "WARNING: MainWindow::importLayer: no current pane" << endl;
|
Chris@1770
|
2964 return;
|
Chris@0
|
2965 }
|
Chris@0
|
2966
|
Chris@0
|
2967 if (!getMainModel()) {
|
Chris@1770
|
2968 // shouldn't happen, as the menu action should have been disabled
|
Chris@1770
|
2969 cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << endl;
|
Chris@1770
|
2970 return;
|
Chris@0
|
2971 }
|
Chris@0
|
2972
|
Chris@88
|
2973 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2974
|
Chris@0
|
2975 if (path != "") {
|
Chris@0
|
2976
|
Chris@197
|
2977 FileOpenStatus status = openLayer(path);
|
Chris@193
|
2978
|
Chris@193
|
2979 if (status == FileOpenFailed) {
|
Chris@247
|
2980 emit hideSplash();
|
Chris@0
|
2981 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2982 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@0
|
2983 return;
|
Chris@193
|
2984 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2985 emit hideSplash();
|
Chris@193
|
2986 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
2987 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
|
2988 }
|
Chris@0
|
2989 }
|
Chris@0
|
2990 }
|
Chris@0
|
2991
|
Chris@0
|
2992 void
|
Chris@0
|
2993 MainWindow::exportLayer()
|
Chris@0
|
2994 {
|
Chris@0
|
2995 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2996 if (!pane) return;
|
Chris@0
|
2997
|
Chris@0
|
2998 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2999 if (!layer) return;
|
Chris@0
|
3000
|
Chris@0
|
3001 Model *model = layer->getModel();
|
Chris@0
|
3002 if (!model) return;
|
Chris@0
|
3003
|
Chris@185
|
3004 FileFinder::FileType type = FileFinder::LayerFileNoMidi;
|
Chris@185
|
3005
|
Chris@185
|
3006 if (dynamic_cast<NoteModel *>(model)) type = FileFinder::LayerFile;
|
Chris@185
|
3007
|
Chris@185
|
3008 QString path = getSaveFileName(type);
|
Chris@0
|
3009
|
Chris@0
|
3010 if (path == "") return;
|
Chris@0
|
3011
|
Chris@0
|
3012 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
3013
|
Chris@185
|
3014 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@185
|
3015
|
Chris@0
|
3016 QString error;
|
Chris@0
|
3017
|
Chris@185
|
3018 if (suffix == "xml" || suffix == "svl") {
|
Chris@0
|
3019
|
Chris@0
|
3020 QFile file(path);
|
Chris@0
|
3021 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
3022 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
3023 } else {
|
Chris@0
|
3024 QTextStream out(&file);
|
Chris@911
|
3025 out.setCodec(QTextCodec::codecForName("UTF-8"));
|
Chris@0
|
3026 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
3027 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
3028 << "<sv>\n"
|
Chris@0
|
3029 << " <data>\n";
|
Chris@0
|
3030
|
Chris@0
|
3031 model->toXml(out, " ");
|
Chris@0
|
3032
|
Chris@0
|
3033 out << " </data>\n"
|
Chris@0
|
3034 << " <display>\n";
|
Chris@0
|
3035
|
Chris@0
|
3036 layer->toXml(out, " ");
|
Chris@0
|
3037
|
Chris@0
|
3038 out << " </display>\n"
|
Chris@0
|
3039 << "</sv>\n";
|
Chris@0
|
3040 }
|
Chris@0
|
3041
|
Chris@185
|
3042 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@185
|
3043
|
Chris@185
|
3044 NoteModel *nm = dynamic_cast<NoteModel *>(model);
|
Chris@185
|
3045
|
Chris@185
|
3046 if (!nm) {
|
Chris@185
|
3047 error = tr("Can't export non-note layers to MIDI");
|
Chris@185
|
3048 } else {
|
Chris@694
|
3049 MIDIFileWriter writer(path, nm, nm->getSampleRate());
|
Chris@185
|
3050 writer.write();
|
Chris@185
|
3051 if (!writer.isOK()) {
|
Chris@185
|
3052 error = writer.getError();
|
Chris@185
|
3053 }
|
Chris@185
|
3054 }
|
Chris@185
|
3055
|
Chris@291
|
3056 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@291
|
3057
|
Chris@522
|
3058 if (!RDFExporter::canExportModel(model)) {
|
Chris@522
|
3059 error = tr("Sorry, cannot export this layer type to RDF (supported types are: region, note, text, time instants, time values)");
|
Chris@522
|
3060 } else {
|
Chris@522
|
3061 RDFExporter exporter(path, model);
|
Chris@522
|
3062 exporter.write();
|
Chris@522
|
3063 if (!exporter.isOK()) {
|
Chris@522
|
3064 error = exporter.getError();
|
Chris@522
|
3065 }
|
Chris@291
|
3066 }
|
Chris@291
|
3067
|
Chris@0
|
3068 } else {
|
Chris@0
|
3069
|
Chris@0
|
3070 CSVFileWriter writer(path, model,
|
Chris@185
|
3071 ((suffix == "csv") ? "," : "\t"));
|
Chris@0
|
3072 writer.write();
|
Chris@0
|
3073
|
Chris@0
|
3074 if (!writer.isOK()) {
|
Chris@0
|
3075 error = writer.getError();
|
Chris@0
|
3076 }
|
Chris@0
|
3077 }
|
Chris@0
|
3078
|
Chris@0
|
3079 if (error != "") {
|
Chris@0
|
3080 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
3081 } else {
|
Chris@34
|
3082 m_recentFiles.addFile(path);
|
Chris@310
|
3083 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@0
|
3084 }
|
Chris@0
|
3085 }
|
Chris@0
|
3086
|
Chris@121
|
3087 void
|
Chris@121
|
3088 MainWindow::exportImage()
|
Chris@121
|
3089 {
|
Chris@121
|
3090 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@121
|
3091 if (!pane) return;
|
Chris@121
|
3092
|
Chris@121
|
3093 QString path = getSaveFileName(FileFinder::ImageFile);
|
Chris@121
|
3094 if (path == "") return;
|
Chris@1460
|
3095 if (QFileInfo(path).suffix() == "") path += ".png";
|
Chris@1451
|
3096
|
Chris@123
|
3097 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@123
|
3098
|
Chris@123
|
3099 QSize total, visible, selected;
|
Chris@1451
|
3100 total = pane->getRenderedImageSize();
|
Chris@1451
|
3101 visible = pane->getRenderedPartImageSize(pane->getFirstVisibleFrame(),
|
Chris@1451
|
3102 pane->getLastVisibleFrame());
|
Chris@123
|
3103
|
Chris@922
|
3104 sv_frame_t sf0 = 0, sf1 = 0;
|
Chris@123
|
3105
|
Chris@123
|
3106 if (haveSelection) {
|
Chris@123
|
3107 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@123
|
3108 sf0 = selections.begin()->getStartFrame();
|
Chris@123
|
3109 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@123
|
3110 --e;
|
Chris@123
|
3111 sf1 = e->getEndFrame();
|
Chris@1451
|
3112 selected = pane->getRenderedPartImageSize(sf0, sf1);
|
Chris@123
|
3113 }
|
Chris@123
|
3114
|
Chris@123
|
3115 QStringList items;
|
Chris@125
|
3116 items << tr("Export the whole pane (%1x%2 pixels)")
|
Chris@123
|
3117 .arg(total.width()).arg(total.height());
|
Chris@123
|
3118 items << tr("Export the visible area only (%1x%2 pixels)")
|
Chris@123
|
3119 .arg(visible.width()).arg(visible.height());
|
Chris@123
|
3120 if (haveSelection) {
|
Chris@123
|
3121 items << tr("Export the selection extent (%1x%2 pixels)")
|
Chris@123
|
3122 .arg(selected.width()).arg(selected.height());
|
Chris@124
|
3123 } else {
|
Chris@124
|
3124 items << tr("Export the selection extent");
|
Chris@123
|
3125 }
|
Chris@123
|
3126
|
Chris@123
|
3127 QSettings settings;
|
Chris@123
|
3128 settings.beginGroup("MainWindow");
|
Chris@123
|
3129 int deflt = settings.value("lastimageexportregion", 0).toInt();
|
Chris@123
|
3130 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@1460
|
3131 if (deflt == 0 && total.width() > 32767) deflt = 1;
|
Chris@124
|
3132
|
Chris@124
|
3133 ListInputDialog *lid = new ListInputDialog
|
Chris@123
|
3134 (this, tr("Select region to export"),
|
Chris@123
|
3135 tr("Which region of the current pane do you want to export as an image?"),
|
Chris@124
|
3136 items, deflt);
|
Chris@124
|
3137
|
Chris@124
|
3138 if (!haveSelection) {
|
Chris@124
|
3139 lid->setItemAvailability(2, false);
|
Chris@124
|
3140 }
|
Chris@1460
|
3141 if (total.width() > 32767) { // appears to be limit of a QImage
|
Chris@124
|
3142 lid->setItemAvailability(0, false);
|
Chris@124
|
3143 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
|
Chris@124
|
3144 }
|
Chris@124
|
3145
|
Chris@124
|
3146 bool ok = lid->exec();
|
Chris@124
|
3147 QString item = lid->getCurrentString();
|
Chris@124
|
3148 delete lid;
|
Chris@1770
|
3149
|
Chris@123
|
3150 if (!ok || item.isEmpty()) return;
|
Chris@123
|
3151
|
Chris@123
|
3152 settings.setValue("lastimageexportregion", deflt);
|
Chris@123
|
3153
|
Chris@1460
|
3154 QImage *image = 0;
|
Chris@1451
|
3155
|
Chris@1460
|
3156 if (item == items[0]) {
|
Chris@1460
|
3157 image = pane->renderToNewImage();
|
Chris@1460
|
3158 } else if (item == items[1]) {
|
Chris@1460
|
3159 image = pane->renderPartToNewImage(pane->getFirstVisibleFrame(),
|
Chris@1460
|
3160 pane->getLastVisibleFrame());
|
Chris@1460
|
3161 } else if (haveSelection) {
|
Chris@1460
|
3162 image = pane->renderPartToNewImage(sf0, sf1);
|
Chris@1451
|
3163 }
|
Chris@1460
|
3164
|
Chris@1460
|
3165 if (!image) return;
|
Chris@1460
|
3166
|
Chris@1460
|
3167 if (!image->save(path, "PNG")) {
|
Chris@1460
|
3168 QMessageBox::critical(this, tr("Failed to save image file"),
|
Chris@1460
|
3169 tr("Failed to save image file %1").arg(path));
|
Chris@1460
|
3170 }
|
Chris@1460
|
3171
|
Chris@1460
|
3172 delete image;
|
Chris@1451
|
3173 }
|
Chris@1451
|
3174
|
Chris@1451
|
3175 void
|
Chris@1451
|
3176 MainWindow::exportSVG()
|
Chris@1451
|
3177 {
|
Chris@1451
|
3178 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@1451
|
3179 if (!pane) return;
|
Chris@1451
|
3180
|
Chris@1451
|
3181 QString path = getSaveFileName(FileFinder::SVGFile);
|
Chris@1451
|
3182 if (path == "") return;
|
Chris@1451
|
3183 if (QFileInfo(path).suffix() == "") path += ".svg";
|
Chris@1451
|
3184
|
Chris@1451
|
3185 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@1451
|
3186
|
Chris@1451
|
3187 sv_frame_t sf0 = 0, sf1 = 0;
|
Chris@1451
|
3188
|
Chris@1451
|
3189 if (haveSelection) {
|
Chris@1451
|
3190 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@1451
|
3191 sf0 = selections.begin()->getStartFrame();
|
Chris@1451
|
3192 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@1451
|
3193 --e;
|
Chris@1451
|
3194 sf1 = e->getEndFrame();
|
Chris@1451
|
3195 }
|
Chris@1451
|
3196
|
Chris@1451
|
3197 QStringList items;
|
Chris@1451
|
3198 items << tr("Export the whole pane");
|
Chris@1451
|
3199 items << tr("Export the visible area only");
|
Chris@1451
|
3200 items << tr("Export the selection extent");
|
Chris@1451
|
3201
|
Chris@1451
|
3202 QSettings settings;
|
Chris@1451
|
3203 settings.beginGroup("MainWindow");
|
Chris@1451
|
3204 int deflt = settings.value("lastsvgexportregion", 0).toInt();
|
Chris@1451
|
3205 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@1451
|
3206
|
Chris@1451
|
3207 ListInputDialog *lid = new ListInputDialog
|
Chris@1451
|
3208 (this, tr("Select region to export"),
|
Chris@1451
|
3209 tr("Which region of the current pane do you want to export as a scalable SVG image?"),
|
Chris@1451
|
3210 items, deflt);
|
Chris@1451
|
3211
|
Chris@1451
|
3212 if (!haveSelection) {
|
Chris@1451
|
3213 lid->setItemAvailability(2, false);
|
Chris@1451
|
3214 }
|
Chris@1451
|
3215
|
Chris@1451
|
3216 bool ok = lid->exec();
|
Chris@1451
|
3217 QString item = lid->getCurrentString();
|
Chris@1451
|
3218 delete lid;
|
Chris@1770
|
3219
|
Chris@1451
|
3220 if (!ok || item.isEmpty()) return;
|
Chris@1451
|
3221
|
Chris@1451
|
3222 settings.setValue("lastsvgexportregion", deflt);
|
Chris@1451
|
3223
|
Chris@1451
|
3224 bool result = false;
|
Chris@1451
|
3225
|
Chris@123
|
3226 if (item == items[0]) {
|
Chris@1451
|
3227 result = pane->renderToSvgFile(path );
|
Chris@123
|
3228 } else if (item == items[1]) {
|
Chris@1451
|
3229 result = pane->renderPartToSvgFile(path,
|
Chris@1451
|
3230 pane->getFirstVisibleFrame(),
|
Chris@1451
|
3231 pane->getLastVisibleFrame());
|
Chris@123
|
3232 } else if (haveSelection) {
|
Chris@1451
|
3233 result = pane->renderPartToSvgFile(path, sf0, sf1);
|
Chris@121
|
3234 }
|
Chris@121
|
3235
|
Chris@1451
|
3236 if (!result) {
|
Chris@1451
|
3237 QMessageBox::critical(this, tr("Failed to save SVG file"),
|
Chris@1451
|
3238 tr("Failed to save SVG file %1").arg(path));
|
Chris@1451
|
3239 }
|
Chris@121
|
3240 }
|
Chris@121
|
3241
|
Chris@0
|
3242 void
|
Chris@1056
|
3243 MainWindow::browseRecordedAudio()
|
Chris@1056
|
3244 {
|
Chris@1056
|
3245 if (!m_recordTarget) return;
|
Chris@1056
|
3246
|
Chris@1418
|
3247 QString path = m_recordTarget->getRecordContainerFolder();
|
Chris@1418
|
3248 if (path == "") path = m_recordTarget->getRecordFolder();
|
Chris@1056
|
3249 if (path == "") return;
|
Chris@1056
|
3250
|
Chris@1056
|
3251 openLocalFolder(path);
|
Chris@1056
|
3252 }
|
Chris@1056
|
3253
|
Chris@1056
|
3254 void
|
Chris@0
|
3255 MainWindow::newSession()
|
Chris@0
|
3256 {
|
Chris@0
|
3257 if (!checkSaveModified()) return;
|
Chris@0
|
3258
|
Chris@0
|
3259 closeSession();
|
Chris@0
|
3260 createDocument();
|
Chris@0
|
3261
|
Chris@0
|
3262 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
3263
|
Chris@90
|
3264 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
3265 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@90
|
3266
|
Chris@0
|
3267 if (!m_timeRulerLayer) {
|
Chris@1770
|
3268 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@1770
|
3269 (LayerFactory::TimeRuler);
|
Chris@0
|
3270 }
|
Chris@0
|
3271
|
Chris@0
|
3272 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3273
|
Chris@0
|
3274 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
3275 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
3276
|
Chris@65
|
3277 m_overview->registerView(pane);
|
Chris@0
|
3278
|
Chris@0
|
3279 CommandHistory::getInstance()->clear();
|
Chris@0
|
3280 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
3281 documentRestored();
|
Chris@0
|
3282 updateMenuStates();
|
Chris@0
|
3283 }
|
Chris@0
|
3284
|
Chris@0
|
3285 void
|
Chris@303
|
3286 MainWindow::documentReplaced()
|
Chris@303
|
3287 {
|
Chris@303
|
3288 if (m_document) {
|
Chris@303
|
3289 connect(m_document, SIGNAL(activity(QString)),
|
Chris@303
|
3290 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
3291 }
|
Chris@303
|
3292 }
|
Chris@303
|
3293
|
Chris@303
|
3294 void
|
Chris@0
|
3295 MainWindow::closeSession()
|
Chris@0
|
3296 {
|
Chris@0
|
3297 if (!checkSaveModified()) return;
|
Chris@0
|
3298
|
Chris@0
|
3299 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
3300
|
Chris@1770
|
3301 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@1770
|
3302
|
Chris@1770
|
3303 while (pane->getLayerCount() > 0) {
|
Chris@1770
|
3304 m_document->removeLayerFromView
|
Chris@1770
|
3305 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@1770
|
3306 }
|
Chris@1770
|
3307
|
Chris@1770
|
3308 m_overview->unregisterView(pane);
|
Chris@1770
|
3309 m_paneStack->deletePane(pane);
|
Chris@0
|
3310 }
|
Chris@0
|
3311
|
Chris@0
|
3312 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
3313
|
Chris@1770
|
3314 Pane *pane = m_paneStack->getHiddenPane
|
Chris@1770
|
3315 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@1770
|
3316
|
Chris@1770
|
3317 while (pane->getLayerCount() > 0) {
|
Chris@1770
|
3318 m_document->removeLayerFromView
|
Chris@1770
|
3319 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@1770
|
3320 }
|
Chris@1770
|
3321
|
Chris@1770
|
3322 m_overview->unregisterView(pane);
|
Chris@1770
|
3323 m_paneStack->deletePane(pane);
|
Chris@0
|
3324 }
|
Chris@0
|
3325
|
Chris@504
|
3326 delete m_layerTreeDialog.data();
|
Chris@504
|
3327 delete m_preferencesDialog.data();
|
Chris@504
|
3328
|
Chris@504
|
3329 m_activityLog->hide();
|
Chris@891
|
3330 m_unitConverter->hide();
|
Chris@504
|
3331 m_keyReference->hide();
|
Chris@504
|
3332
|
Chris@0
|
3333 delete m_document;
|
Chris@0
|
3334 m_document = 0;
|
Chris@0
|
3335 m_viewManager->clearSelections();
|
Chris@0
|
3336 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
3337
|
Chris@0
|
3338 m_sessionFile = "";
|
Chris@518
|
3339 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
3340
|
Chris@0
|
3341 CommandHistory::getInstance()->clear();
|
Chris@0
|
3342 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
3343 documentRestored();
|
Chris@0
|
3344 }
|
Chris@0
|
3345
|
Chris@0
|
3346 void
|
Chris@0
|
3347 MainWindow::openSomething()
|
Chris@0
|
3348 {
|
Chris@0
|
3349 QString orig = m_audioFile;
|
Chris@0
|
3350 if (orig == "") orig = ".";
|
Chris@0
|
3351 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
3352
|
Chris@88
|
3353 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
3354
|
Chris@0
|
3355 if (path.isEmpty()) return;
|
Chris@0
|
3356
|
Chris@844
|
3357 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@193
|
3358
|
Chris@193
|
3359 if (status == FileOpenFailed) {
|
Chris@247
|
3360 emit hideSplash();
|
Chris@193
|
3361 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
3362 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@193
|
3363 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3364 emit hideSplash();
|
Chris@193
|
3365 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
3366 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
|
3367 }
|
Chris@0
|
3368 }
|
Chris@0
|
3369
|
Chris@0
|
3370 void
|
Chris@86
|
3371 MainWindow::openLocation()
|
Chris@86
|
3372 {
|
Chris@103
|
3373 QSettings settings;
|
Chris@103
|
3374 settings.beginGroup("MainWindow");
|
Chris@103
|
3375 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
3376
|
Chris@86
|
3377 bool ok = false;
|
Chris@86
|
3378 QString text = QInputDialog::getText
|
Chris@86
|
3379 (this, tr("Open Location"),
|
Chris@86
|
3380 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
3381 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
3382
|
Chris@103
|
3383 if (!ok) return;
|
Chris@103
|
3384
|
Chris@103
|
3385 settings.setValue("lastremote", text);
|
Chris@103
|
3386
|
Chris@103
|
3387 if (text.isEmpty()) return;
|
Chris@86
|
3388
|
Chris@844
|
3389 FileOpenStatus status = openPath(text, AskUser);
|
Chris@193
|
3390
|
Chris@193
|
3391 if (status == FileOpenFailed) {
|
Chris@247
|
3392 emit hideSplash();
|
Chris@86
|
3393 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
3394 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@193
|
3395 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3396 emit hideSplash();
|
Chris@193
|
3397 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
3398 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
|
3399 }
|
Chris@86
|
3400 }
|
Chris@86
|
3401
|
Chris@86
|
3402 void
|
Chris@1253
|
3403 MainWindow::openRecentFile(const QString& path)
|
Chris@0
|
3404 {
|
Chris@1253
|
3405 /* F. Nicol patch 13 Aug. 2016 */
|
Chris@1253
|
3406 #if 0
|
Chris@0
|
3407 QObject *obj = sender();
|
Chris@0
|
3408 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
3409
|
Chris@0
|
3410 if (!action) {
|
Chris@1770
|
3411 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@1770
|
3412 << endl;
|
Chris@1770
|
3413 return;
|
Chris@0
|
3414 }
|
Chris@0
|
3415
|
Chris@0
|
3416 QString path = action->text();
|
Chris@1253
|
3417 #endif
|
Chris@1253
|
3418 /* End of F. Nicol patch 13 Aug. 2016 */
|
Chris@1253
|
3419
|
Chris@0
|
3420 if (path == "") return;
|
Chris@0
|
3421
|
Chris@844
|
3422 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@193
|
3423
|
Chris@193
|
3424 if (status == FileOpenFailed) {
|
Chris@247
|
3425 emit hideSplash();
|
Chris@193
|
3426 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
3427 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@193
|
3428 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3429 emit hideSplash();
|
Chris@193
|
3430 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
3431 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
|
3432 }
|
Chris@0
|
3433 }
|
Chris@0
|
3434
|
Chris@0
|
3435 void
|
Chris@435
|
3436 MainWindow::applyTemplate()
|
Chris@435
|
3437 {
|
Chris@435
|
3438 QObject *s = sender();
|
Chris@435
|
3439 QAction *action = qobject_cast<QAction *>(s);
|
Chris@435
|
3440
|
Chris@435
|
3441 if (!action) {
|
Chris@1770
|
3442 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action"
|
Chris@1770
|
3443 << endl;
|
Chris@1770
|
3444 return;
|
Chris@435
|
3445 }
|
Chris@435
|
3446
|
Chris@435
|
3447 QString n = action->objectName();
|
Chris@435
|
3448 if (n == "") n = action->text();
|
Chris@435
|
3449
|
Chris@435
|
3450 if (n == "") {
|
Chris@665
|
3451 cerr << "WARNING: MainWindow::applyTemplate: sender has no name"
|
Chris@665
|
3452 << endl;
|
Chris@435
|
3453 return;
|
Chris@435
|
3454 }
|
Chris@435
|
3455
|
Chris@435
|
3456 QString mainModelLocation;
|
Chris@435
|
3457 WaveFileModel *mm = getMainModel();
|
Chris@435
|
3458 if (mm) mainModelLocation = mm->getLocation();
|
Chris@435
|
3459 if (mainModelLocation != "") {
|
Chris@435
|
3460 openAudio(mainModelLocation, ReplaceSession, n);
|
Chris@435
|
3461 } else {
|
Chris@435
|
3462 openSessionTemplate(n);
|
Chris@435
|
3463 }
|
Chris@435
|
3464 }
|
Chris@435
|
3465
|
Chris@435
|
3466 void
|
Chris@425
|
3467 MainWindow::saveSessionAsTemplate()
|
Chris@425
|
3468 {
|
Chris@762
|
3469 QDialog *d = new QDialog(this);
|
Chris@483
|
3470 d->setWindowTitle(tr("Enter template name"));
|
Chris@483
|
3471
|
Chris@483
|
3472 QGridLayout *layout = new QGridLayout;
|
Chris@483
|
3473 d->setLayout(layout);
|
Chris@483
|
3474
|
Chris@483
|
3475 layout->addWidget(new QLabel(tr("Please enter a name for the saved template:")),
|
Chris@483
|
3476 0, 0);
|
Chris@483
|
3477 QLineEdit *lineEdit = new QLineEdit;
|
Chris@483
|
3478 layout->addWidget(lineEdit, 1, 0);
|
Chris@483
|
3479 QCheckBox *makeDefault = new QCheckBox(tr("Set as default template for future audio files"));
|
Chris@483
|
3480 layout->addWidget(makeDefault, 2, 0);
|
Chris@425
|
3481
|
Chris@483
|
3482 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
|
Chris@483
|
3483 QDialogButtonBox::Cancel);
|
Chris@483
|
3484 layout->addWidget(bb, 3, 0);
|
Chris@483
|
3485 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@483
|
3486 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@483
|
3487 connect(bb, SIGNAL(rejected()), d, SLOT(reject()));
|
Chris@483
|
3488
|
Chris@483
|
3489 if (d->exec() == QDialog::Accepted) {
|
Chris@483
|
3490
|
Chris@483
|
3491 QString name = lineEdit->text();
|
Chris@483
|
3492 name.replace(QRegExp("[^\\w\\s\\.\"'-]"), "_");
|
Chris@483
|
3493
|
Chris@483
|
3494 ResourceFinder rf;
|
Chris@483
|
3495 QString dir = rf.getResourceSaveDir("templates");
|
Chris@483
|
3496 QString filename = QString("%1/%2.svt").arg(dir).arg(name);
|
Chris@483
|
3497 if (QFile(filename).exists()) {
|
Chris@483
|
3498 if (QMessageBox::warning(this,
|
Chris@483
|
3499 tr("Template file exists"),
|
Chris@483
|
3500 tr("<b>Template file exists</b><p>The template \"%1\" already exists.<br>Overwrite it?").arg(name),
|
Chris@483
|
3501 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@483
|
3502 QMessageBox::Cancel) != QMessageBox::Ok) {
|
Chris@1516
|
3503 delete d;
|
Chris@483
|
3504 return;
|
Chris@483
|
3505 }
|
Chris@483
|
3506 }
|
Chris@483
|
3507
|
Chris@483
|
3508 if (saveSessionTemplate(filename)) {
|
Chris@483
|
3509 if (makeDefault->isChecked()) {
|
Chris@483
|
3510 setDefaultSessionTemplate(name);
|
Chris@483
|
3511 }
|
Chris@431
|
3512 }
|
Chris@431
|
3513 }
|
Chris@1516
|
3514
|
Chris@1516
|
3515 delete d;
|
Chris@425
|
3516 }
|
Chris@425
|
3517
|
Chris@425
|
3518 void
|
Chris@425
|
3519 MainWindow::manageSavedTemplates()
|
Chris@425
|
3520 {
|
Chris@425
|
3521 ResourceFinder rf;
|
Chris@1930
|
3522 openLocalFolder(rf.getResourceSaveDir("templates"));
|
Chris@423
|
3523 }
|
Chris@423
|
3524
|
Chris@423
|
3525 void
|
Chris@200
|
3526 MainWindow::paneAdded(Pane *pane)
|
Chris@200
|
3527 {
|
Chris@200
|
3528 if (m_overview) m_overview->registerView(pane);
|
Chris@200
|
3529 }
|
Chris@200
|
3530
|
Chris@200
|
3531 void
|
Chris@200
|
3532 MainWindow::paneHidden(Pane *pane)
|
Chris@200
|
3533 {
|
Chris@200
|
3534 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
3535 }
|
Chris@200
|
3536
|
Chris@200
|
3537 void
|
Chris@200
|
3538 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@200
|
3539 {
|
Chris@200
|
3540 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
3541 }
|
Chris@200
|
3542
|
Chris@200
|
3543 void
|
Chris@193
|
3544 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@193
|
3545 {
|
Chris@193
|
3546 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
3547
|
Chris@193
|
3548 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@193
|
3549
|
Chris@295
|
3550 FileOpenStatus status;
|
Chris@295
|
3551
|
Chris@295
|
3552 if (i == uriList.begin()) {
|
Chris@844
|
3553 status = openPath(*i, ReplaceCurrentPane);
|
Chris@295
|
3554 } else {
|
Chris@844
|
3555 status = openPath(*i, CreateAdditionalModel);
|
Chris@295
|
3556 }
|
Chris@193
|
3557
|
Chris@193
|
3558 if (status == FileOpenFailed) {
|
Chris@247
|
3559 emit hideSplash();
|
Chris@193
|
3560 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
3561 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@295
|
3562 break;
|
Chris@193
|
3563 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3564 emit hideSplash();
|
Chris@193
|
3565 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@294
|
3566 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
|
3567 break;
|
Chris@295
|
3568 } else if (status == FileOpenCancelled) {
|
Chris@295
|
3569 break;
|
Chris@193
|
3570 }
|
Chris@193
|
3571 }
|
Chris@193
|
3572 }
|
Chris@193
|
3573
|
Chris@193
|
3574 void
|
Chris@193
|
3575 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@193
|
3576 {
|
Chris@193
|
3577 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
3578
|
Chris@193
|
3579 QUrl testUrl(text);
|
Chris@193
|
3580 if (testUrl.scheme() == "file" ||
|
Chris@193
|
3581 testUrl.scheme() == "http" ||
|
Chris@193
|
3582 testUrl.scheme() == "ftp") {
|
Chris@193
|
3583 QStringList list;
|
Chris@193
|
3584 list.push_back(text);
|
Chris@193
|
3585 paneDropAccepted(pane, list);
|
Chris@193
|
3586 return;
|
Chris@193
|
3587 }
|
Chris@193
|
3588
|
Chris@193
|
3589 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@193
|
3590 //to a text layer?
|
Chris@193
|
3591 }
|
Chris@193
|
3592
|
Chris@193
|
3593 void
|
Chris@0
|
3594 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
3595 {
|
Chris@665
|
3596 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@118
|
3597
|
Chris@136
|
3598 if (m_openingAudioFile) {
|
Chris@665
|
3599 // cerr << "Busy - ignoring close event" << endl;
|
Chris@1770
|
3600 e->ignore();
|
Chris@1770
|
3601 return;
|
Chris@136
|
3602 }
|
Chris@136
|
3603
|
Chris@70
|
3604 if (!m_abandoning && !checkSaveModified()) {
|
Chris@665
|
3605 // cerr << "Close refused by user - ignoring close event" << endl;
|
Chris@1770
|
3606 e->ignore();
|
Chris@1770
|
3607 return;
|
Chris@0
|
3608 }
|
Chris@0
|
3609
|
Chris@5
|
3610 QSettings settings;
|
Chris@5
|
3611 settings.beginGroup("MainWindow");
|
Chris@624
|
3612 settings.setValue("maximised", isMaximized());
|
Chris@624
|
3613 if (!isMaximized()) {
|
Chris@624
|
3614 settings.setValue("size", size());
|
Chris@624
|
3615 settings.setValue("position", pos());
|
Chris@624
|
3616 }
|
Chris@5
|
3617 settings.endGroup();
|
Chris@5
|
3618
|
Chris@163
|
3619 if (m_preferencesDialog &&
|
Chris@163
|
3620 m_preferencesDialog->isVisible()) {
|
Chris@1434
|
3621 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
3622 }
|
Chris@163
|
3623
|
Chris@200
|
3624 closeSession();
|
Chris@200
|
3625
|
Chris@0
|
3626 e->accept();
|
Chris@489
|
3627
|
Chris@0
|
3628 return;
|
Chris@0
|
3629 }
|
Chris@0
|
3630
|
Chris@0
|
3631 bool
|
Chris@11
|
3632 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
3633 {
|
Chris@11
|
3634 if (mayAskUser) {
|
Chris@163
|
3635 bool rv = checkSaveModified();
|
Chris@163
|
3636 if (rv) {
|
Chris@163
|
3637 if (m_preferencesDialog &&
|
Chris@163
|
3638 m_preferencesDialog->isVisible()) {
|
Chris@163
|
3639 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
3640 }
|
Chris@163
|
3641 }
|
Chris@163
|
3642 return rv;
|
Chris@11
|
3643 } else {
|
Chris@163
|
3644 if (m_preferencesDialog &&
|
Chris@163
|
3645 m_preferencesDialog->isVisible()) {
|
Chris@163
|
3646 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
3647 }
|
Chris@11
|
3648 if (!m_documentModified) return true;
|
Chris@11
|
3649
|
Chris@11
|
3650 // If we can't check with the user first, then we can't save
|
Chris@11
|
3651 // to the original session file (even if we have it) -- have
|
Chris@11
|
3652 // to use a temporary file
|
Chris@11
|
3653
|
Chris@11
|
3654 QString svDirBase = ".sv1";
|
Chris@11
|
3655 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
3656
|
Chris@11
|
3657 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
3658 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
3659 } else {
|
Chris@11
|
3660 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
3661 }
|
Chris@11
|
3662
|
Chris@11
|
3663 // This name doesn't have to be unguessable
|
Chris@93
|
3664 #ifndef _WIN32
|
Chris@11
|
3665 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
3666 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
3667 .arg(QProcess().pid());
|
Chris@93
|
3668 #else
|
Chris@93
|
3669 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
3670 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
3671 #endif
|
Chris@11
|
3672 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
3673 if (saveSessionFile(fpath)) {
|
Chris@34
|
3674 m_recentFiles.addFile(fpath);
|
Chris@310
|
3675 emit activity(tr("Export image to \"%1\"").arg(fpath));
|
Chris@11
|
3676 return true;
|
Chris@11
|
3677 } else {
|
Chris@11
|
3678 return false;
|
Chris@11
|
3679 }
|
Chris@11
|
3680 }
|
Chris@11
|
3681 }
|
Chris@11
|
3682
|
Chris@11
|
3683 bool
|
Chris@0
|
3684 MainWindow::checkSaveModified()
|
Chris@0
|
3685 {
|
Chris@0
|
3686 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
3687 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
3688 // cancel.
|
Chris@0
|
3689
|
Chris@0
|
3690 if (!m_documentModified) return true;
|
Chris@0
|
3691
|
Chris@247
|
3692 emit hideSplash();
|
Chris@247
|
3693
|
Chris@0
|
3694 int button =
|
Chris@1770
|
3695 QMessageBox::warning(this,
|
Chris@1770
|
3696 tr("Session modified"),
|
Chris@1770
|
3697 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
|
Chris@1770
|
3698 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@165
|
3699 QMessageBox::Yes);
|
Chris@0
|
3700
|
Chris@0
|
3701 if (button == QMessageBox::Yes) {
|
Chris@1770
|
3702 saveSession();
|
Chris@1770
|
3703 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@1770
|
3704 return false;
|
Chris@1770
|
3705 } else {
|
Chris@0
|
3706 return true; // saved, so it's safe to continue now
|
Chris@0
|
3707 }
|
Chris@0
|
3708 } else if (button == QMessageBox::No) {
|
Chris@1770
|
3709 m_documentModified = false; // so we know to abandon it
|
Chris@1770
|
3710 return true;
|
Chris@0
|
3711 }
|
Chris@0
|
3712
|
Chris@0
|
3713 // else cancel
|
Chris@0
|
3714 return false;
|
Chris@0
|
3715 }
|
Chris@0
|
3716
|
Chris@290
|
3717 bool
|
Chris@294
|
3718 MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
|
Chris@290
|
3719 {
|
Chris@294
|
3720 //!!! This is very similar to part of MainWindowBase::openAudio --
|
Chris@294
|
3721 //!!! make them a bit more uniform
|
Chris@294
|
3722
|
Chris@294
|
3723 QSettings settings;
|
Chris@294
|
3724 settings.beginGroup("MainWindow");
|
Chris@294
|
3725 bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
|
Chris@294
|
3726 settings.endGroup();
|
Chris@294
|
3727 bool newSession = true;
|
Chris@294
|
3728
|
Chris@294
|
3729 QStringList items;
|
Chris@294
|
3730 items << tr("Close the current session and create a new one")
|
Chris@294
|
3731 << tr("Add this data to the current session");
|
Chris@294
|
3732
|
Chris@294
|
3733 bool ok = false;
|
Chris@294
|
3734 QString item = ListInputDialog::getItem
|
Chris@294
|
3735 (this, tr("Select target for import"),
|
Chris@294
|
3736 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
|
3737 items, prevNewSession ? 0 : 1, &ok);
|
Chris@294
|
3738
|
Chris@294
|
3739 if (!ok || item.isEmpty()) {
|
Chris@294
|
3740 *cancel = true;
|
Chris@290
|
3741 return false;
|
Chris@290
|
3742 }
|
Chris@294
|
3743
|
Chris@294
|
3744 newSession = (item == items[0]);
|
Chris@294
|
3745 settings.beginGroup("MainWindow");
|
Chris@294
|
3746 settings.setValue("newsessionforrdfaudio", newSession);
|
Chris@294
|
3747 settings.endGroup();
|
Chris@294
|
3748
|
Chris@294
|
3749 if (newSession) return true;
|
Chris@294
|
3750 else return false;
|
Chris@290
|
3751 }
|
Chris@290
|
3752
|
Chris@0
|
3753 void
|
Chris@0
|
3754 MainWindow::saveSession()
|
Chris@0
|
3755 {
|
Chris@0
|
3756 if (m_sessionFile != "") {
|
Chris@1770
|
3757 if (!saveSessionFile(m_sessionFile)) {
|
Chris@1770
|
3758 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@1770
|
3759 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@1770
|
3760 } else {
|
Chris@1770
|
3761 CommandHistory::getInstance()->documentSaved();
|
Chris@1770
|
3762 documentRestored();
|
Chris@1770
|
3763 }
|
Chris@0
|
3764 } else {
|
Chris@1770
|
3765 saveSessionAs();
|
Chris@0
|
3766 }
|
Chris@0
|
3767 }
|
Chris@0
|
3768
|
Chris@0
|
3769 void
|
Chris@0
|
3770 MainWindow::saveSessionAs()
|
Chris@0
|
3771 {
|
Chris@0
|
3772 QString orig = m_audioFile;
|
Chris@0
|
3773 if (orig == "") orig = ".";
|
Chris@0
|
3774 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
3775
|
Chris@88
|
3776 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
3777
|
Chris@81
|
3778 if (path == "") return;
|
Chris@0
|
3779
|
Chris@0
|
3780 if (!saveSessionFile(path)) {
|
Chris@1770
|
3781 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@1770
|
3782 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
3783 } else {
|
Chris@1770
|
3784 setWindowTitle(tr("%1: %2")
|
Chris@518
|
3785 .arg(QApplication::applicationName())
|
Chris@1770
|
3786 .arg(QFileInfo(path).fileName()));
|
Chris@1770
|
3787 m_sessionFile = path;
|
Chris@1770
|
3788 CommandHistory::getInstance()->documentSaved();
|
Chris@1770
|
3789 documentRestored();
|
Chris@34
|
3790 m_recentFiles.addFile(path);
|
Chris@310
|
3791 emit activity(tr("Save session as \"%1\"").arg(path));
|
Chris@0
|
3792 }
|
Chris@0
|
3793 }
|
Chris@0
|
3794
|
Chris@90
|
3795 void
|
Chris@72
|
3796 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
3797 {
|
Chris@200
|
3798 MainWindowBase::preferenceChanged(name);
|
Chris@200
|
3799
|
Chris@1448
|
3800 if (name == "Background Mode") {
|
Chris@1448
|
3801 coloursChanged();
|
Chris@200
|
3802 }
|
Chris@0
|
3803 }
|
Chris@0
|
3804
|
Chris@0
|
3805 void
|
Chris@1448
|
3806 MainWindow::coloursChanged()
|
Chris@1448
|
3807 {
|
Chris@1448
|
3808 QSettings settings;
|
Chris@1448
|
3809 settings.beginGroup("Preferences");
|
Chris@1448
|
3810 QString defaultColourName(tr("Green"));
|
Chris@1448
|
3811 if (m_viewManager && m_viewManager->getGlobalDarkBackground()) {
|
Chris@1448
|
3812 defaultColourName = tr("Bright Green");
|
Chris@1448
|
3813 }
|
Chris@1448
|
3814 ColourDatabase *cdb = ColourDatabase::getInstance();
|
cannam@1463
|
3815 QColor colour = QColor
|
cannam@1463
|
3816 (settings.value("overview-colour",
|
cannam@1463
|
3817 cdb->getColour(defaultColourName).name()).toString());
|
Chris@1448
|
3818 settings.endGroup();
|
Chris@1448
|
3819
|
Chris@1448
|
3820 int index = cdb->getColourIndex(colour);
|
Chris@1448
|
3821 if (index >= 0) {
|
Chris@1448
|
3822 m_panLayer->setBaseColour(index);
|
Chris@1448
|
3823 }
|
Chris@1448
|
3824 }
|
Chris@1448
|
3825
|
Chris@1448
|
3826 void
|
Chris@239
|
3827 MainWindow::propertyStacksResized(int width)
|
Chris@239
|
3828 {
|
Chris@438
|
3829 // SVDEBUG << "MainWindow::propertyStacksResized(" << width << ")" << endl;
|
Chris@239
|
3830
|
Chris@239
|
3831 if (!m_playControlsSpacer) return;
|
Chris@239
|
3832
|
Chris@239
|
3833 int spacerWidth = width - m_playControlsWidth - 4;
|
Chris@239
|
3834
|
Chris@438
|
3835 // SVDEBUG << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << endl;
|
Chris@239
|
3836
|
Chris@239
|
3837 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
|
Chris@239
|
3838 }
|
Chris@239
|
3839
|
Chris@239
|
3840 void
|
Chris@0
|
3841 MainWindow::addPane()
|
Chris@0
|
3842 {
|
Chris@0
|
3843 QObject *s = sender();
|
Chris@0
|
3844 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@753
|
3845
|
Chris@753
|
3846 cerr << "addPane: sender is " << s << ", action is " << action << ", name " << action->text() << endl;
|
Chris@0
|
3847
|
Chris@0
|
3848 if (!action) {
|
Chris@1770
|
3849 cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@1770
|
3850 << endl;
|
Chris@1770
|
3851 return;
|
Chris@0
|
3852 }
|
Chris@0
|
3853
|
Chris@0
|
3854 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
3855
|
Chris@0
|
3856 if (i == m_paneActions.end()) {
|
Chris@1770
|
3857 cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@1770
|
3858 << action->objectName() << endl;
|
Chris@753
|
3859 cerr << "known actions are:" << endl;
|
Chris@753
|
3860 for (PaneActionMap::const_iterator i = m_paneActions.begin();
|
Chris@753
|
3861 i != m_paneActions.end(); ++i) {
|
Chris@753
|
3862 cerr << i->first << ", name " << i->first->text() << endl;
|
Chris@753
|
3863 }
|
Chris@1770
|
3864 return;
|
Chris@0
|
3865 }
|
Chris@0
|
3866
|
Chris@69
|
3867 addPane(i->second, action->text());
|
Chris@69
|
3868 }
|
Chris@69
|
3869
|
Chris@69
|
3870 void
|
Chris@232
|
3871 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
|
Chris@69
|
3872 {
|
Chris@69
|
3873 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
3874
|
Chris@0
|
3875 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
3876 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3877
|
Chris@0
|
3878 Pane *pane = command->getPane();
|
Chris@0
|
3879
|
Chris@69
|
3880 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
3881 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
3882 pane->setFollowGlobalZoom(false);
|
Chris@112
|
3883 pane->setZoomLevel(512);
|
Chris@7
|
3884 }
|
Chris@7
|
3885
|
Chris@69
|
3886 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
3887 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
3888
|
Chris@1770
|
3889 if (!m_timeRulerLayer) {
|
Chris@1770
|
3890 // cerr << "no time ruler layer, creating one" << endl;
|
Chris@1770
|
3891 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@1770
|
3892 (LayerFactory::TimeRuler);
|
Chris@1770
|
3893 }
|
Chris@1770
|
3894
|
Chris@1770
|
3895 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl;
|
Chris@1770
|
3896
|
Chris@1770
|
3897 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3898 }
|
Chris@0
|
3899
|
Chris@69
|
3900 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
3901
|
Chris@69
|
3902 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
3903 Model *model = 0;
|
Chris@66
|
3904
|
Chris@66
|
3905 if (suggestedModel) {
|
Chris@66
|
3906
|
Chris@66
|
3907 // check its validity
|
Chris@224
|
3908 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
3909 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
3910 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
3911 model = suggestedModel;
|
Chris@66
|
3912 break;
|
Chris@66
|
3913 }
|
Chris@66
|
3914 }
|
Chris@66
|
3915
|
Chris@66
|
3916 if (!model) {
|
Chris@665
|
3917 cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
3918 << " appears in pane action map, but is not reported "
|
Chris@665
|
3919 << "by document as a valid transform source" << endl;
|
Chris@66
|
3920 }
|
Chris@66
|
3921 }
|
Chris@66
|
3922
|
Chris@346
|
3923 if (!model) {
|
Chris@346
|
3924 model = m_document->getMainModel();
|
Chris@346
|
3925 }
|
Chris@66
|
3926
|
Chris@66
|
3927 m_document->setModel(newLayer, model);
|
Chris@66
|
3928
|
Chris@69
|
3929 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
3930 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
3931
|
Chris@0
|
3932 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
3933 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3934
|
Chris@438
|
3935 // SVDEBUG << "MainWindow::addPane: global centre frame is "
|
Chris@433
|
3936 // << m_viewManager->getGlobalCentreFrame() << endl;
|
Chris@130
|
3937 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
3938
|
Chris@0
|
3939 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
3940
|
Chris@0
|
3941 updateMenuStates();
|
Chris@0
|
3942 }
|
Chris@0
|
3943
|
Chris@0
|
3944 void
|
Chris@0
|
3945 MainWindow::addLayer()
|
Chris@0
|
3946 {
|
Chris@0
|
3947 QObject *s = sender();
|
Chris@0
|
3948 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
3949
|
Chris@0
|
3950 if (!action) {
|
Chris@1770
|
3951 cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@1770
|
3952 << endl;
|
Chris@1770
|
3953 return;
|
Chris@0
|
3954 }
|
Chris@0
|
3955
|
Chris@0
|
3956 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3957
|
Chris@0
|
3958 if (!pane) {
|
Chris@1770
|
3959 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
|
Chris@1770
|
3960 return;
|
Chris@0
|
3961 }
|
Chris@0
|
3962
|
Chris@0
|
3963 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
3964
|
Chris@0
|
3965 if (ei != m_existingLayerActions.end()) {
|
Chris@1770
|
3966 Layer *newLayer = ei->second;
|
Chris@1770
|
3967 m_document->addLayerToView(pane, newLayer);
|
Chris@1770
|
3968 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1770
|
3969 return;
|
Chris@0
|
3970 }
|
Chris@0
|
3971
|
Chris@95
|
3972 ei = m_sliceActions.find(action);
|
Chris@95
|
3973
|
Chris@95
|
3974 if (ei != m_sliceActions.end()) {
|
Chris@95
|
3975 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
3976 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
3977 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
3978 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
3979 if (source && dest) {
|
Chris@205
|
3980 //!!!???
|
Chris@95
|
3981 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
3982 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
3983 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
3984 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
3985 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
3986 }
|
Chris@1770
|
3987 m_document->addLayerToView(pane, newLayer);
|
Chris@1770
|
3988 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1770
|
3989 return;
|
Chris@95
|
3990 }
|
Chris@95
|
3991
|
Chris@211
|
3992 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
3993
|
Chris@34
|
3994 if (i == m_transformActions.end()) {
|
Chris@0
|
3995
|
Chris@1770
|
3996 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@1770
|
3997
|
Chris@1770
|
3998 if (i == m_layerActions.end()) {
|
Chris@1770
|
3999 cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@1770
|
4000 << action->objectName() << endl;
|
Chris@1770
|
4001 return;
|
Chris@1770
|
4002 }
|
Chris@1770
|
4003
|
Chris@1770
|
4004 LayerFactory::LayerType type = i->second.layer;
|
Chris@1770
|
4005
|
Chris@1770
|
4006 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@1770
|
4007 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@1770
|
4008
|
Chris@1770
|
4009 Layer *newLayer = 0;
|
Chris@1770
|
4010
|
Chris@1770
|
4011 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@1770
|
4012
|
Chris@1770
|
4013 newLayer = m_document->createEmptyLayer(type);
|
Chris@217
|
4014 if (newLayer) {
|
Chris@217
|
4015 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@217
|
4016 }
|
Chris@0
|
4017
|
Chris@1770
|
4018 } else {
|
Chris@0
|
4019
|
Chris@346
|
4020 Model *model = i->second.sourceModel;
|
Chris@346
|
4021
|
Chris@415
|
4022 cerr << "model = "<< model << endl;
|
Chris@415
|
4023
|
Chris@346
|
4024 if (!model) {
|
Chris@346
|
4025 if (type == LayerFactory::TimeRuler) {
|
Chris@346
|
4026 newLayer = m_document->createMainModelLayer(type);
|
Chris@346
|
4027 } else {
|
Chris@346
|
4028 // if model is unspecified and this is not a
|
Chris@415
|
4029 // time-ruler layer, use any plausible model from
|
Chris@415
|
4030 // the current pane -- this is the case for
|
Chris@415
|
4031 // right-button menu layer additions
|
Chris@415
|
4032 Pane::ModelSet ms = pane->getModels();
|
Chris@415
|
4033 foreach (Model *m, ms) {
|
Chris@415
|
4034 RangeSummarisableTimeValueModel *r =
|
Chris@415
|
4035 dynamic_cast<RangeSummarisableTimeValueModel *>(m);
|
Chris@415
|
4036 if (r) model = m;
|
Chris@346
|
4037 }
|
Chris@346
|
4038 if (!model) model = getMainModel();
|
Chris@346
|
4039 }
|
Chris@346
|
4040 }
|
Chris@346
|
4041
|
Chris@346
|
4042 if (model) {
|
Chris@238
|
4043 newLayer = m_document->createLayer(type);
|
Chris@346
|
4044 if (m_document->isKnownModel(model)) {
|
Chris@238
|
4045 m_document->setChannel(newLayer, i->second.channel);
|
Chris@346
|
4046 m_document->setModel(newLayer, model);
|
Chris@238
|
4047 } else {
|
Chris@665
|
4048 cerr << "WARNING: MainWindow::addLayer: unknown model "
|
Chris@346
|
4049 << model
|
Chris@238
|
4050 << " (\""
|
Chris@838
|
4051 << model->objectName()
|
Chris@238
|
4052 << "\") in layer action map"
|
Chris@665
|
4053 << endl;
|
Chris@238
|
4054 }
|
Chris@232
|
4055 }
|
Chris@238
|
4056 }
|
Chris@0
|
4057
|
Chris@217
|
4058 if (newLayer) {
|
Chris@217
|
4059 m_document->addLayerToView(pane, newLayer);
|
Chris@217
|
4060 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@217
|
4061 }
|
Chris@0
|
4062
|
Chris@1770
|
4063 return;
|
Chris@0
|
4064 }
|
Chris@0
|
4065
|
Chris@224
|
4066 //!!! want to do something like this, but it's not supported in
|
Chris@224
|
4067 //ModelTransformerFactory yet
|
Chris@224
|
4068 /*
|
Chris@0
|
4069 int channel = -1;
|
Chris@0
|
4070 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
4071 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@1770
|
4072 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@1770
|
4073 if (c != -1) {
|
Chris@1770
|
4074 channel = c;
|
Chris@1770
|
4075 break;
|
Chris@1770
|
4076 }
|
Chris@0
|
4077 }
|
Chris@224
|
4078 */
|
Chris@0
|
4079
|
Chris@33
|
4080 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
4081 // supposed to be configurable, because we need to let the user
|
Chris@33
|
4082 // change the execution context (block size etc).
|
Chris@0
|
4083
|
Chris@224
|
4084 QString transformId = i->second;
|
Chris@274
|
4085
|
Chris@274
|
4086 addLayer(transformId);
|
Chris@274
|
4087 }
|
Chris@274
|
4088
|
Chris@274
|
4089 void
|
Chris@274
|
4090 MainWindow::addLayer(QString transformId)
|
Chris@274
|
4091 {
|
Chris@274
|
4092 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@274
|
4093 if (!pane) {
|
Chris@1770
|
4094 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
|
Chris@1770
|
4095 return;
|
Chris@274
|
4096 }
|
Chris@274
|
4097
|
Chris@1558
|
4098 Transform transform;
|
Chris@1558
|
4099 try {
|
Chris@1558
|
4100 transform = TransformFactory::getInstance()->
|
Chris@1558
|
4101 getDefaultTransformFor(transformId);
|
Chris@1558
|
4102 } catch (std::exception &e) { // e.g. Piper server failure
|
Chris@1558
|
4103 QMessageBox::critical
|
Chris@1558
|
4104 (this, tr("Failed to query transform attributes"),
|
Chris@1558
|
4105 tr("<b>Failed to query transform attributes</b><p>Plugin or server error: %1</p>")
|
Chris@1558
|
4106 .arg(e.what()));
|
Chris@1558
|
4107 return;
|
Chris@1558
|
4108 }
|
Chris@27
|
4109
|
Chris@66
|
4110 std::vector<Model *> candidateInputModels =
|
Chris@224
|
4111 m_document->getTransformInputModels();
|
Chris@53
|
4112
|
Chris@219
|
4113 Model *defaultInputModel = 0;
|
Chris@895
|
4114
|
Chris@219
|
4115 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@895
|
4116
|
Chris@219
|
4117 Layer *layer = pane->getLayer(j);
|
Chris@219
|
4118 if (!layer) continue;
|
Chris@895
|
4119
|
Chris@243
|
4120 if (LayerFactory::getInstance()->getLayerType(layer) !=
|
Chris@243
|
4121 LayerFactory::Waveform &&
|
Chris@243
|
4122 !layer->isLayerOpaque()) continue;
|
Chris@895
|
4123
|
Chris@219
|
4124 Model *model = layer->getModel();
|
Chris@219
|
4125 if (!model) continue;
|
Chris@895
|
4126
|
Chris@219
|
4127 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
|
Chris@219
|
4128 if (candidateInputModels[k] == model) {
|
Chris@219
|
4129 defaultInputModel = model;
|
Chris@219
|
4130 break;
|
Chris@219
|
4131 }
|
Chris@219
|
4132 }
|
Chris@895
|
4133
|
Chris@219
|
4134 if (defaultInputModel) break;
|
Chris@219
|
4135 }
|
Chris@895
|
4136
|
Chris@1620
|
4137 AggregateWaveModel *aggregate = 0;
|
Chris@1620
|
4138
|
Chris@895
|
4139 if (candidateInputModels.size() > 1) {
|
Chris@895
|
4140 // Add an aggregate model as another option
|
Chris@895
|
4141 AggregateWaveModel::ChannelSpecList sl;
|
Chris@895
|
4142 foreach (Model *m, candidateInputModels) {
|
Chris@895
|
4143 RangeSummarisableTimeValueModel *r =
|
Chris@895
|
4144 qobject_cast<RangeSummarisableTimeValueModel *>(m);
|
Chris@895
|
4145 if (r) {
|
Chris@895
|
4146 sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1));
|
Chris@895
|
4147 }
|
Chris@895
|
4148 }
|
Chris@895
|
4149 if (!sl.empty()) {
|
Chris@1620
|
4150 aggregate = new AggregateWaveModel(sl);
|
Chris@895
|
4151 aggregate->setObjectName(tr("Multiplex all of the above"));
|
Chris@895
|
4152 candidateInputModels.push_back(aggregate);
|
Chris@895
|
4153 }
|
Chris@895
|
4154 }
|
Chris@219
|
4155
|
Chris@914
|
4156 sv_frame_t startFrame = 0, duration = 0;
|
Chris@914
|
4157 sv_frame_t endFrame = 0;
|
Chris@184
|
4158 m_viewManager->getSelection().getExtents(startFrame, endFrame);
|
Chris@184
|
4159 if (endFrame > startFrame) duration = endFrame - startFrame;
|
Chris@184
|
4160 else startFrame = 0;
|
Chris@184
|
4161
|
Chris@357
|
4162 TransformUserConfigurator configurator;
|
Chris@357
|
4163
|
Chris@224
|
4164 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
Chris@224
|
4165 getConfigurationForTransform
|
Chris@211
|
4166 (transform,
|
Chris@211
|
4167 candidateInputModels,
|
Chris@219
|
4168 defaultInputModel,
|
Chris@211
|
4169 m_playSource,
|
Chris@211
|
4170 startFrame,
|
Chris@357
|
4171 duration,
|
Chris@357
|
4172 &configurator);
|
Chris@211
|
4173
|
Chris@1623
|
4174 if (aggregate) {
|
Chris@1623
|
4175 if (input.getModel() == aggregate) {
|
Chris@1623
|
4176 aggregate->setObjectName(tr("Multiplexed audio"));
|
Chris@1623
|
4177 m_document->addAggregateModel(aggregate);
|
Chris@1623
|
4178 } else {
|
Chris@1623
|
4179 aggregate->aboutToDelete();
|
Chris@1623
|
4180 delete aggregate;
|
Chris@1623
|
4181 }
|
Chris@1620
|
4182 }
|
Chris@1620
|
4183
|
Chris@224
|
4184 if (!input.getModel()) return;
|
Chris@224
|
4185
|
Chris@438
|
4186 // SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;
|
Chris@224
|
4187
|
Chris@1558
|
4188 try {
|
Chris@1558
|
4189 Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
Chris@1558
|
4190 if (newLayer) {
|
Chris@1558
|
4191 m_document->addLayerToView(pane, newLayer);
|
Chris@1558
|
4192 m_document->setChannel(newLayer, input.getChannel());
|
Chris@1558
|
4193 m_recentTransforms.add(transformId);
|
Chris@1558
|
4194 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1558
|
4195 }
|
Chris@1558
|
4196 } catch (std::exception &e) { // e.g. Piper server failure
|
Chris@1558
|
4197 QMessageBox::critical
|
Chris@1558
|
4198 (this, tr("Transform failed"),
|
Chris@1558
|
4199 tr("<b>Failed to run transform</b><p>Plugin or server error: %1</p>")
|
Chris@1558
|
4200 .arg(e.what()));
|
Chris@1558
|
4201 return;
|
Chris@0
|
4202 }
|
Chris@1558
|
4203
|
Chris@0
|
4204 updateMenuStates();
|
Chris@0
|
4205 }
|
Chris@0
|
4206
|
Chris@0
|
4207 void
|
Chris@0
|
4208 MainWindow::renameCurrentLayer()
|
Chris@0
|
4209 {
|
Chris@0
|
4210 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
4211 if (pane) {
|
Chris@1770
|
4212 Layer *layer = pane->getSelectedLayer();
|
Chris@1770
|
4213 if (layer) {
|
Chris@1770
|
4214 bool ok = false;
|
Chris@1770
|
4215 QString newName = QInputDialog::getText
|
Chris@1770
|
4216 (this, tr("Rename Layer"),
|
Chris@1770
|
4217 tr("New name for this layer:"),
|
Chris@1770
|
4218 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@1770
|
4219 if (ok) {
|
Chris@1770
|
4220 layer->setPresentationName(newName);
|
Chris@1770
|
4221 setupExistingLayersMenus();
|
Chris@1770
|
4222 }
|
Chris@1770
|
4223 }
|
Chris@0
|
4224 }
|
Chris@0
|
4225 }
|
Chris@0
|
4226
|
Chris@0
|
4227 void
|
Chris@272
|
4228 MainWindow::findTransform()
|
Chris@272
|
4229 {
|
Chris@274
|
4230 TransformFinder *finder = new TransformFinder(this);
|
Chris@274
|
4231 if (!finder->exec()) {
|
Chris@274
|
4232 delete finder;
|
Chris@274
|
4233 return;
|
Chris@273
|
4234 }
|
Chris@274
|
4235 TransformId transform = finder->getTransform();
|
Chris@274
|
4236 delete finder;
|
Chris@287
|
4237
|
Chris@287
|
4238 if (getMainModel() != 0 && m_paneStack->getCurrentPane() != 0) {
|
Chris@287
|
4239 addLayer(transform);
|
Chris@287
|
4240 }
|
Chris@272
|
4241 }
|
Chris@272
|
4242
|
Chris@272
|
4243 void
|
Chris@207
|
4244 MainWindow::playSoloToggled()
|
Chris@207
|
4245 {
|
Chris@207
|
4246 MainWindowBase::playSoloToggled();
|
Chris@207
|
4247 m_soloModified = true;
|
Chris@207
|
4248 }
|
Chris@207
|
4249
|
Chris@207
|
4250 void
|
Chris@206
|
4251 MainWindow::alignToggled()
|
Chris@206
|
4252 {
|
Chris@206
|
4253 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@206
|
4254
|
Chris@207
|
4255 if (!m_viewManager) return;
|
Chris@207
|
4256
|
Chris@206
|
4257 if (action) {
|
Chris@1770
|
4258 m_viewManager->setAlignMode(action->isChecked());
|
Chris@206
|
4259 } else {
|
Chris@1770
|
4260 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
|
Chris@206
|
4261 }
|
Chris@206
|
4262
|
Chris@206
|
4263 if (m_viewManager->getAlignMode()) {
|
Chris@207
|
4264 m_prevSolo = m_soloAction->isChecked();
|
Chris@208
|
4265 if (!m_soloAction->isChecked()) {
|
Chris@208
|
4266 m_soloAction->setChecked(true);
|
Chris@208
|
4267 MainWindowBase::playSoloToggled();
|
Chris@208
|
4268 }
|
Chris@207
|
4269 m_soloModified = false;
|
Chris@207
|
4270 emit canChangeSolo(false);
|
Chris@206
|
4271 m_document->alignModels();
|
Chris@206
|
4272 m_document->setAutoAlignment(true);
|
Chris@206
|
4273 } else {
|
Chris@207
|
4274 if (!m_soloModified) {
|
Chris@208
|
4275 if (m_soloAction->isChecked() != m_prevSolo) {
|
Chris@208
|
4276 m_soloAction->setChecked(m_prevSolo);
|
Chris@208
|
4277 MainWindowBase::playSoloToggled();
|
Chris@208
|
4278 }
|
Chris@207
|
4279 }
|
Chris@207
|
4280 emit canChangeSolo(true);
|
Chris@206
|
4281 m_document->setAutoAlignment(false);
|
Chris@206
|
4282 }
|
Chris@206
|
4283
|
Chris@206
|
4284 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@206
|
4285
|
Chris@1770
|
4286 Pane *pane = m_paneStack->getPane(i);
|
Chris@1770
|
4287 if (!pane) continue;
|
Chris@206
|
4288
|
Chris@206
|
4289 pane->update();
|
Chris@206
|
4290 }
|
Chris@206
|
4291 }
|
Chris@206
|
4292
|
Chris@206
|
4293 void
|
Chris@59
|
4294 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
4295 {
|
Chris@1031
|
4296 PlaySpeedRangeMapper mapper;
|
Chris@60
|
4297
|
Chris@922
|
4298 double percent = m_playSpeed->mappedValue();
|
Chris@922
|
4299 double factor = mapper.getFactorForValue(percent);
|
Chris@60
|
4300
|
Chris@1031
|
4301 // cerr << "play speed position = " << position << " (range 0-120) percent = " << percent << " factor = " << factor << endl;
|
Chris@1031
|
4302
|
Chris@1031
|
4303 int centre = m_playSpeed->defaultValue();
|
Chris@1031
|
4304
|
Chris@1031
|
4305 // Percentage is shown to 0dp if >100, to 1dp if <100; factor is
|
Chris@1031
|
4306 // shown to 3sf
|
Chris@1031
|
4307
|
Chris@1031
|
4308 char pcbuf[30];
|
Chris@1031
|
4309 char facbuf[30];
|
Chris@1031
|
4310
|
Chris@1031
|
4311 if (position == centre) {
|
Chris@155
|
4312 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@1031
|
4313 } else if (position < centre) {
|
Chris@1031
|
4314 sprintf(pcbuf, "%.1f", percent);
|
Chris@1031
|
4315 sprintf(facbuf, "%.3g", 1.0 / factor);
|
Chris@1031
|
4316 contextHelpChanged(tr("Playback speed: %1% (%2x slower)")
|
Chris@1031
|
4317 .arg(pcbuf)
|
Chris@1031
|
4318 .arg(facbuf));
|
Chris@155
|
4319 } else {
|
Chris@1031
|
4320 sprintf(pcbuf, "%.0f", percent);
|
Chris@1031
|
4321 sprintf(facbuf, "%.3g", factor);
|
Chris@1031
|
4322 contextHelpChanged(tr("Playback speed: %1% (%2x faster)")
|
Chris@1031
|
4323 .arg(pcbuf)
|
Chris@1031
|
4324 .arg(facbuf));
|
Chris@155
|
4325 }
|
Chris@155
|
4326
|
Chris@1031
|
4327 m_playSource->setTimeStretch(1.0 / factor); // factor is a speedup
|
Chris@155
|
4328
|
Chris@155
|
4329 updateMenuStates();
|
Chris@16
|
4330 }
|
Chris@16
|
4331
|
Chris@26
|
4332 void
|
Chris@155
|
4333 MainWindow::speedUpPlayback()
|
Chris@155
|
4334 {
|
Chris@155
|
4335 int value = m_playSpeed->value();
|
Chris@155
|
4336 value = value + m_playSpeed->pageStep();
|
Chris@155
|
4337 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@155
|
4338 m_playSpeed->setValue(value);
|
Chris@155
|
4339 }
|
Chris@155
|
4340
|
Chris@155
|
4341 void
|
Chris@155
|
4342 MainWindow::slowDownPlayback()
|
Chris@155
|
4343 {
|
Chris@155
|
4344 int value = m_playSpeed->value();
|
Chris@155
|
4345 value = value - m_playSpeed->pageStep();
|
Chris@155
|
4346 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@155
|
4347 m_playSpeed->setValue(value);
|
Chris@155
|
4348 }
|
Chris@155
|
4349
|
Chris@155
|
4350 void
|
Chris@155
|
4351 MainWindow::restoreNormalPlayback()
|
Chris@155
|
4352 {
|
Chris@155
|
4353 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@155
|
4354 }
|
Chris@155
|
4355
|
Chris@155
|
4356 void
|
Chris@227
|
4357 MainWindow::currentPaneChanged(Pane *pane)
|
Chris@227
|
4358 {
|
Chris@228
|
4359 MainWindowBase::currentPaneChanged(pane);
|
Chris@228
|
4360
|
Chris@227
|
4361 if (!pane || !m_panLayer) return;
|
Chris@761
|
4362
|
Chris@761
|
4363 // If this pane contains the main model, it usually makes sense to
|
Chris@761
|
4364 // show the main model in the pan layer even if it isn't the top
|
Chris@761
|
4365 // layer in the pane (e.g. if the top layer is one derived from
|
Chris@761
|
4366 // the main model).
|
Chris@761
|
4367 bool containsMainModel = false;
|
Chris@761
|
4368 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@761
|
4369 --i;
|
Chris@761
|
4370 Layer *layer = pane->getLayer(i);
|
Chris@761
|
4371 if (layer &&
|
Chris@761
|
4372 LayerFactory::getInstance()->getLayerType(layer) ==
|
Chris@761
|
4373 LayerFactory::Waveform &&
|
Chris@761
|
4374 layer->getModel() == getMainModel()) {
|
Chris@761
|
4375 containsMainModel = true;
|
Chris@761
|
4376 break;
|
Chris@761
|
4377 }
|
Chris@761
|
4378 }
|
Chris@761
|
4379
|
Chris@1794
|
4380 bool panLayerSet = false;
|
Chris@1794
|
4381
|
Chris@227
|
4382 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@227
|
4383 --i;
|
Chris@227
|
4384 Layer *layer = pane->getLayer(i);
|
Chris@1794
|
4385 RangeSummarisableTimeValueModel *tvm =
|
Chris@1794
|
4386 qobject_cast<RangeSummarisableTimeValueModel *>(layer->getModel());
|
Chris@1794
|
4387 if (tvm) {
|
Chris@1794
|
4388 auto type = LayerFactory::getInstance()->getLayerType(layer);
|
Chris@1794
|
4389 if (type != LayerFactory::TimeRuler) {
|
Chris@1794
|
4390 updateLayerShortcutsFor(tvm);
|
Chris@1794
|
4391 }
|
Chris@1794
|
4392 if (type == LayerFactory::Waveform) {
|
Chris@227
|
4393 m_panLayer->setModel(tvm);
|
Chris@1794
|
4394 panLayerSet = true;
|
Chris@1794
|
4395 break;
|
Chris@227
|
4396 }
|
Chris@227
|
4397 }
|
Chris@227
|
4398 }
|
Chris@1794
|
4399
|
Chris@1794
|
4400 if (containsMainModel && !panLayerSet) {
|
Chris@1794
|
4401 m_panLayer->setModel(getMainModel());
|
Chris@1794
|
4402 }
|
Chris@227
|
4403 }
|
Chris@227
|
4404
|
Chris@227
|
4405 void
|
Chris@116
|
4406 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@116
|
4407 {
|
Chris@116
|
4408 if (!getMainModel() || !p) {
|
Chris@116
|
4409 return;
|
Chris@116
|
4410 }
|
Chris@116
|
4411
|
Chris@117
|
4412 bool haveSelection = false;
|
Chris@922
|
4413 sv_frame_t startFrame = 0, endFrame = 0;
|
Chris@117
|
4414
|
Chris@117
|
4415 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@117
|
4416
|
Chris@117
|
4417 bool exclusive = false;
|
Chris@117
|
4418 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@117
|
4419
|
Chris@117
|
4420 if (!s.isEmpty()) {
|
Chris@117
|
4421 haveSelection = true;
|
Chris@117
|
4422 startFrame = s.getStartFrame();
|
Chris@117
|
4423 endFrame = s.getEndFrame();
|
Chris@117
|
4424 }
|
Chris@117
|
4425 }
|
Chris@117
|
4426
|
Chris@117
|
4427 if (!haveSelection) {
|
Chris@117
|
4428 startFrame = p->getFirstVisibleFrame();
|
Chris@117
|
4429 endFrame = p->getLastVisibleFrame();
|
Chris@117
|
4430 }
|
Chris@117
|
4431
|
Chris@116
|
4432 RealTime start = RealTime::frame2RealTime
|
Chris@117
|
4433 (startFrame, getMainModel()->getSampleRate());
|
Chris@116
|
4434
|
Chris@116
|
4435 RealTime end = RealTime::frame2RealTime
|
Chris@117
|
4436 (endFrame, getMainModel()->getSampleRate());
|
Chris@116
|
4437
|
Chris@116
|
4438 RealTime duration = end - start;
|
Chris@116
|
4439
|
Chris@116
|
4440 QString startStr, endStr, durationStr;
|
Chris@116
|
4441 startStr = start.toText(true).c_str();
|
Chris@116
|
4442 endStr = end.toText(true).c_str();
|
Chris@116
|
4443 durationStr = duration.toText(true).c_str();
|
Chris@116
|
4444
|
Chris@117
|
4445 if (haveSelection) {
|
Chris@117
|
4446 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@117
|
4447 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
4448 } else {
|
Chris@117
|
4449 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@117
|
4450 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
4451 }
|
Chris@116
|
4452
|
Chris@739
|
4453 if (getStatusLabel()->text() != m_myStatusMessage) {
|
Chris@739
|
4454 getStatusLabel()->setText(m_myStatusMessage);
|
Chris@737
|
4455 }
|
Chris@340
|
4456
|
Chris@340
|
4457 updatePositionStatusDisplays();
|
Chris@340
|
4458 }
|
Chris@340
|
4459
|
Chris@340
|
4460 void
|
Chris@340
|
4461 MainWindow::updatePositionStatusDisplays() const
|
Chris@340
|
4462 {
|
Chris@340
|
4463 if (!statusBar()->isVisible()) return;
|
Chris@340
|
4464
|
Chris@340
|
4465 Pane *pane = 0;
|
Chris@922
|
4466 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
Chris@340
|
4467
|
Chris@340
|
4468 if (m_paneStack) pane = m_paneStack->getCurrentPane();
|
Chris@340
|
4469 if (!pane) return;
|
Chris@340
|
4470
|
Chris@340
|
4471 int layers = pane->getLayerCount();
|
Chris@340
|
4472 if (layers == 0) m_currentLabel->setText("");
|
Chris@340
|
4473
|
Chris@340
|
4474 for (int i = layers-1; i >= 0; --i) {
|
Chris@340
|
4475 Layer *layer = pane->getLayer(i);
|
Chris@340
|
4476 if (!layer) continue;
|
Chris@340
|
4477 if (!layer->isLayerEditable()) continue;
|
Chris@340
|
4478 QString label = layer->getLabelPreceding
|
Chris@340
|
4479 (pane->alignFromReference(frame));
|
Chris@340
|
4480 m_currentLabel->setText(label);
|
Chris@340
|
4481 break;
|
Chris@340
|
4482 }
|
Chris@116
|
4483 }
|
Chris@116
|
4484
|
Chris@116
|
4485 void
|
Chris@1476
|
4486 MainWindow::monitoringLevelsChanged(float left, float right)
|
Chris@0
|
4487 {
|
Chris@1386
|
4488 m_mainLevelPan->setMonitoringLevels(left, right);
|
Chris@0
|
4489 }
|
Chris@0
|
4490
|
Chris@0
|
4491 void
|
Chris@921
|
4492 MainWindow::sampleRateMismatch(sv_samplerate_t requested,
|
Chris@921
|
4493 sv_samplerate_t actual,
|
Chris@0
|
4494 bool willResample)
|
Chris@0
|
4495 {
|
Chris@0
|
4496 if (!willResample) {
|
Chris@247
|
4497 emit hideSplash();
|
Chris@0
|
4498 QMessageBox::information
|
Chris@0
|
4499 (this, tr("Sample rate mismatch"),
|
Chris@193
|
4500 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
|
4501 .arg(requested).arg(actual));
|
Chris@0
|
4502 }
|
Chris@0
|
4503
|
Chris@0
|
4504 updateDescriptionLabel();
|
Chris@0
|
4505 }
|
Chris@0
|
4506
|
Chris@0
|
4507 void
|
Chris@42
|
4508 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
4509 {
|
Chris@42
|
4510 QMessageBox::information
|
Chris@42
|
4511 (this, tr("Audio processing overload"),
|
Chris@193
|
4512 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@42
|
4513 }
|
Chris@42
|
4514
|
Chris@42
|
4515 void
|
Chris@266
|
4516 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@266
|
4517 {
|
Chris@266
|
4518 static bool shownOnce = false;
|
Chris@266
|
4519 if (shownOnce) return;
|
Chris@266
|
4520 QMessageBox::information
|
Chris@266
|
4521 (this, tr("Audio processing overload"),
|
Chris@266
|
4522 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@266
|
4523 shownOnce = true;
|
Chris@266
|
4524 }
|
Chris@266
|
4525
|
Chris@1630
|
4526 /*
|
Chris@266
|
4527 void
|
Chris@1521
|
4528 MainWindow::betaReleaseWarning()
|
Chris@1521
|
4529 {
|
Chris@1521
|
4530 QMessageBox::information
|
Chris@1521
|
4531 (this, tr("Beta release"),
|
Chris@1521
|
4532 tr("<b>This is a beta release of Sonic Visualiser</b><p>Please see the \"What's New\" option in the Help menu for a list of changes since the last proper release.</p>"));
|
Chris@1521
|
4533 }
|
Chris@1630
|
4534 */
|
Chris@1521
|
4535
|
Chris@1521
|
4536 void
|
Chris@1148
|
4537 MainWindow::pluginPopulationWarning()
|
Chris@1087
|
4538 {
|
Chris@1277
|
4539 QString scanWarning = PluginScan::getInstance()->getStartupFailureReport();
|
Chris@1277
|
4540 QString factWarning = TransformFactory::getInstance()->getStartupFailureReport();
|
Chris@1277
|
4541 QString warning;
|
Chris@1277
|
4542 if (factWarning != "") {
|
Chris@1277
|
4543 // The order of events on startup implies that, if scanWarning
|
Chris@1277
|
4544 // and factWarning are both present, then we have already been
|
Chris@1277
|
4545 // called once for scanWarning so don't want to report it again
|
Chris@1277
|
4546 warning = factWarning;
|
Chris@1277
|
4547 } else if (scanWarning != "") {
|
Chris@1277
|
4548 warning = scanWarning;
|
Chris@1277
|
4549 }
|
Chris@1277
|
4550 if (warning != "") {
|
Chris@1277
|
4551 emit hideSplash();
|
Chris@1277
|
4552 QMessageBox::warning(this, tr("Problems loading plugins"), warning);
|
Chris@1277
|
4553 }
|
Chris@1087
|
4554 }
|
Chris@1087
|
4555
|
Chris@1087
|
4556 void
|
Chris@304
|
4557 MainWindow::midiEventsAvailable()
|
Chris@304
|
4558 {
|
Chris@307
|
4559 Pane *currentPane = 0;
|
Chris@307
|
4560 NoteLayer *currentNoteLayer = 0;
|
Chris@309
|
4561 TimeValueLayer *currentTimeValueLayer = 0;
|
Chris@307
|
4562
|
Chris@793
|
4563 if (m_paneStack) {
|
Chris@793
|
4564 currentPane = m_paneStack->getCurrentPane();
|
Chris@793
|
4565 }
|
Chris@793
|
4566
|
Chris@307
|
4567 if (currentPane) {
|
Chris@307
|
4568 currentNoteLayer = dynamic_cast<NoteLayer *>
|
Chris@307
|
4569 (currentPane->getSelectedLayer());
|
Chris@309
|
4570 currentTimeValueLayer = dynamic_cast<TimeValueLayer *>
|
Chris@309
|
4571 (currentPane->getSelectedLayer());
|
Chris@838
|
4572 } else {
|
Chris@793
|
4573 // discard these events
|
Chris@793
|
4574 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@793
|
4575 (void)m_midiInput->readEvent();
|
Chris@793
|
4576 }
|
Chris@793
|
4577 return;
|
Chris@793
|
4578 }
|
Chris@793
|
4579
|
Chris@305
|
4580 // This is called through a serialised signal/slot invocation
|
Chris@305
|
4581 // (across threads). It could happen quite some time after the
|
Chris@305
|
4582 // event was actually received, which is why event timestamping
|
Chris@305
|
4583 // happens in the MIDI input class and not here.
|
Chris@307
|
4584
|
Chris@305
|
4585 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@308
|
4586
|
Chris@305
|
4587 MIDIEvent ev(m_midiInput->readEvent());
|
Chris@307
|
4588
|
Chris@922
|
4589 sv_frame_t frame = currentPane->alignFromReference(ev.getTime());
|
Chris@309
|
4590
|
Chris@308
|
4591 bool noteOn = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
4592 ev.getVelocity() > 0);
|
Chris@308
|
4593
|
Chris@308
|
4594 bool noteOff = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_OFF ||
|
Chris@308
|
4595 (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
4596 ev.getVelocity() == 0));
|
Chris@308
|
4597
|
Chris@307
|
4598 if (currentNoteLayer) {
|
Chris@307
|
4599
|
Chris@310
|
4600 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
4601
|
Chris@308
|
4602 if (noteOn) {
|
Chris@307
|
4603
|
Chris@309
|
4604 currentNoteLayer->addNoteOn(frame,
|
Chris@307
|
4605 ev.getPitch(),
|
Chris@307
|
4606 ev.getVelocity());
|
Chris@307
|
4607
|
Chris@308
|
4608 } else if (noteOff) {
|
Chris@307
|
4609
|
Chris@309
|
4610 currentNoteLayer->addNoteOff(frame,
|
Chris@307
|
4611 ev.getPitch());
|
Chris@307
|
4612
|
Chris@307
|
4613 }
|
Chris@307
|
4614
|
Chris@309
|
4615 continue;
|
Chris@309
|
4616 }
|
Chris@309
|
4617
|
Chris@309
|
4618 if (currentTimeValueLayer) {
|
Chris@308
|
4619
|
Chris@308
|
4620 if (!noteOn) continue;
|
Chris@310
|
4621
|
Chris@310
|
4622 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
4623
|
Chris@309
|
4624 Model *model = static_cast<Layer *>(currentTimeValueLayer)->getModel();
|
Chris@309
|
4625 SparseTimeValueModel *tvm =
|
Chris@309
|
4626 dynamic_cast<SparseTimeValueModel *>(model);
|
Chris@309
|
4627 if (tvm) {
|
Chris@1754
|
4628 SparseTimeValueModel::Point point(frame,
|
Chris@1754
|
4629 float(ev.getPitch() % 12),
|
Chris@1754
|
4630 "");
|
Chris@309
|
4631 SparseTimeValueModel::AddPointCommand *command =
|
Chris@309
|
4632 new SparseTimeValueModel::AddPointCommand
|
Chris@309
|
4633 (tvm, point, tr("Add Point"));
|
Chris@309
|
4634 CommandHistory::getInstance()->addCommand(command);
|
Chris@309
|
4635 }
|
Chris@838
|
4636
|
Chris@309
|
4637 continue;
|
Chris@305
|
4638 }
|
Chris@309
|
4639
|
Chris@838
|
4640 // This is reached only if !currentNoteLayer and
|
Chris@838
|
4641 // !currentTimeValueLayer, i.e. there is some other sort of
|
Chris@838
|
4642 // layer that may be insertable-into
|
Chris@838
|
4643
|
Chris@309
|
4644 if (!noteOn) continue;
|
Chris@309
|
4645 insertInstantAt(ev.getTime());
|
Chris@304
|
4646 }
|
Chris@304
|
4647 }
|
Chris@304
|
4648
|
Chris@304
|
4649 void
|
Chris@730
|
4650 MainWindow::playStatusChanged(bool )
|
Chris@305
|
4651 {
|
Chris@307
|
4652 Pane *currentPane = 0;
|
Chris@307
|
4653 NoteLayer *currentNoteLayer = 0;
|
Chris@307
|
4654
|
Chris@307
|
4655 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@307
|
4656 if (currentPane) {
|
Chris@307
|
4657 currentNoteLayer = dynamic_cast<NoteLayer *>(currentPane->getSelectedLayer());
|
Chris@307
|
4658 }
|
Chris@307
|
4659
|
Chris@307
|
4660 if (currentNoteLayer) {
|
Chris@307
|
4661 currentNoteLayer->abandonNoteOns();
|
Chris@307
|
4662 }
|
Chris@305
|
4663 }
|
Chris@305
|
4664
|
Chris@305
|
4665 void
|
Chris@200
|
4666 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
4667 {
|
Chris@95
|
4668 setupExistingLayersMenus();
|
Chris@200
|
4669 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
4670 }
|
Chris@0
|
4671
|
Chris@0
|
4672 void
|
Chris@0
|
4673 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
4674 {
|
Chris@95
|
4675 setupExistingLayersMenus();
|
Chris@200
|
4676 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
4677 }
|
Chris@0
|
4678
|
Chris@0
|
4679 void
|
Chris@0
|
4680 MainWindow::modelAdded(Model *model)
|
Chris@0
|
4681 {
|
Chris@200
|
4682 MainWindowBase::modelAdded(model);
|
Chris@66
|
4683 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
4684 setupPaneAndLayerMenus();
|
Chris@66
|
4685 }
|
Chris@0
|
4686 }
|
Chris@0
|
4687
|
Chris@0
|
4688 void
|
Chris@0
|
4689 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
4690 {
|
Chris@0
|
4691 m_panLayer->setModel(model);
|
Chris@200
|
4692
|
Chris@200
|
4693 MainWindowBase::mainModelChanged(model);
|
Chris@200
|
4694
|
Chris@1055
|
4695 if (m_playTarget || m_audioIO) {
|
Chris@1386
|
4696 connect(m_mainLevelPan, SIGNAL(levelChanged(float)),
|
Chris@1035
|
4697 this, SLOT(mainModelGainChanged(float)));
|
Chris@1386
|
4698 connect(m_mainLevelPan, SIGNAL(panChanged(float)),
|
Chris@1386
|
4699 this, SLOT(mainModelPanChanged(float)));
|
Chris@1035
|
4700 }
|
Chris@1035
|
4701 }
|
Chris@1035
|
4702
|
Chris@1035
|
4703 void
|
Chris@1035
|
4704 MainWindow::mainModelGainChanged(float gain)
|
Chris@1035
|
4705 {
|
Chris@1035
|
4706 if (m_playTarget) {
|
Chris@1035
|
4707 m_playTarget->setOutputGain(gain);
|
Chris@1055
|
4708 } else if (m_audioIO) {
|
Chris@1055
|
4709 m_audioIO->setOutputGain(gain);
|
Chris@200
|
4710 }
|
Chris@0
|
4711 }
|
Chris@0
|
4712
|
Chris@0
|
4713 void
|
Chris@1386
|
4714 MainWindow::mainModelPanChanged(float balance)
|
Chris@1386
|
4715 {
|
Chris@1386
|
4716 // this is indeed stereo balance rather than pan
|
Chris@1386
|
4717 if (m_playTarget) {
|
Chris@1386
|
4718 m_playTarget->setOutputBalance(balance);
|
Chris@1386
|
4719 } else if (m_audioIO) {
|
Chris@1386
|
4720 m_audioIO->setOutputBalance(balance);
|
Chris@1386
|
4721 }
|
Chris@1386
|
4722 }
|
Chris@1386
|
4723
|
Chris@1386
|
4724 void
|
Chris@760
|
4725 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@760
|
4726 {
|
Chris@760
|
4727 if (model == m_panLayer->getModel()) {
|
Chris@760
|
4728 if (model == getMainModel()) {
|
Chris@760
|
4729 m_panLayer->setModel(0);
|
Chris@760
|
4730 } else {
|
Chris@760
|
4731 m_panLayer->setModel(getMainModel());
|
Chris@760
|
4732 }
|
Chris@760
|
4733 }
|
Chris@760
|
4734 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@760
|
4735 }
|
Chris@760
|
4736
|
Chris@760
|
4737 void
|
Chris@200
|
4738 MainWindow::setInstantsNumbering()
|
Chris@0
|
4739 {
|
Chris@200
|
4740 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
4741 if (!a) return;
|
Chris@200
|
4742
|
Chris@200
|
4743 int type = m_numberingActions[a];
|
Chris@200
|
4744
|
Chris@200
|
4745 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
|
Chris@200
|
4746
|
Chris@200
|
4747 QSettings settings;
|
Chris@200
|
4748 settings.beginGroup("MainWindow");
|
Chris@200
|
4749 settings.setValue("labellertype", type);
|
Chris@200
|
4750 settings.endGroup();
|
Chris@200
|
4751 }
|
Chris@200
|
4752
|
Chris@200
|
4753 void
|
Chris@200
|
4754 MainWindow::setInstantsCounterCycle()
|
Chris@200
|
4755 {
|
Chris@200
|
4756 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
4757 if (!a) return;
|
Chris@200
|
4758
|
Chris@200
|
4759 int cycle = a->text().toInt();
|
Chris@200
|
4760 if (cycle == 0) return;
|
Chris@200
|
4761
|
Chris@200
|
4762 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
|
Chris@200
|
4763
|
Chris@200
|
4764 QSettings settings;
|
Chris@200
|
4765 settings.beginGroup("MainWindow");
|
Chris@200
|
4766 settings.setValue("labellercycle", cycle);
|
Chris@200
|
4767 settings.endGroup();
|
Chris@200
|
4768 }
|
Chris@200
|
4769
|
Chris@200
|
4770 void
|
Chris@597
|
4771 MainWindow::setInstantsCounters()
|
Chris@200
|
4772 {
|
Chris@200
|
4773 LabelCounterInputDialog dialog(m_labeller, this);
|
Chris@241
|
4774 dialog.setWindowTitle(tr("Reset Counters"));
|
Chris@200
|
4775 dialog.exec();
|
Chris@0
|
4776 }
|
Chris@0
|
4777
|
Chris@0
|
4778 void
|
Chris@597
|
4779 MainWindow::resetInstantsCounters()
|
Chris@597
|
4780 {
|
Chris@597
|
4781 if (m_labeller) m_labeller->resetCounters();
|
Chris@597
|
4782 }
|
Chris@597
|
4783
|
Chris@597
|
4784 void
|
Chris@1355
|
4785 MainWindow::subdivideInstants()
|
Chris@1355
|
4786 {
|
Chris@1355
|
4787 QSettings settings;
|
Chris@1355
|
4788 settings.beginGroup("MainWindow");
|
Chris@1355
|
4789 int n = settings.value("subdivisions", 4).toInt();
|
Chris@1355
|
4790
|
Chris@1355
|
4791 bool ok;
|
Chris@1355
|
4792
|
Chris@1355
|
4793 n = QInputDialog::getInt(this,
|
Chris@1355
|
4794 tr("Subdivide instants"),
|
Chris@1355
|
4795 tr("Number of subdivisions:"),
|
Chris@1355
|
4796 n, 2, 96, 1, &ok);
|
Chris@1355
|
4797
|
Chris@1355
|
4798 if (ok) {
|
Chris@1355
|
4799 settings.setValue("subdivisions", n);
|
Chris@1355
|
4800 subdivideInstantsBy(n);
|
Chris@1355
|
4801 }
|
Chris@1355
|
4802
|
Chris@1355
|
4803 settings.endGroup();
|
Chris@1355
|
4804 }
|
Chris@1355
|
4805
|
Chris@1355
|
4806 void
|
Chris@1356
|
4807 MainWindow::winnowInstants()
|
Chris@1356
|
4808 {
|
Chris@1356
|
4809 QSettings settings;
|
Chris@1356
|
4810 settings.beginGroup("MainWindow");
|
Chris@1356
|
4811 int n = settings.value("winnow-subdivisions", 4).toInt();
|
Chris@1356
|
4812
|
Chris@1356
|
4813 bool ok;
|
Chris@1356
|
4814
|
Chris@1356
|
4815 n = QInputDialog::getInt(this,
|
Chris@1356
|
4816 tr("Winnow instants"),
|
Chris@1356
|
4817 tr("Remove all instants apart from multiples of:"),
|
Chris@1356
|
4818 n, 2, 96, 1, &ok);
|
Chris@1356
|
4819
|
Chris@1356
|
4820 if (ok) {
|
Chris@1356
|
4821 settings.setValue("winnow-subdivisions", n);
|
Chris@1356
|
4822 winnowInstantsBy(n);
|
Chris@1356
|
4823 }
|
Chris@1356
|
4824
|
Chris@1356
|
4825 settings.endGroup();
|
Chris@1356
|
4826 }
|
Chris@1356
|
4827
|
Chris@1356
|
4828 void
|
Chris@233
|
4829 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@233
|
4830 {
|
Chris@247
|
4831 emit hideSplash();
|
Chris@247
|
4832
|
Chris@983
|
4833 QString quoted;
|
Chris@983
|
4834 if (transformName != "") {
|
Chris@983
|
4835 quoted = QString("\"%1\" ").arg(transformName);
|
Chris@983
|
4836 }
|
Chris@983
|
4837
|
Chris@233
|
4838 if (message != "") {
|
Chris@233
|
4839
|
Chris@233
|
4840 QMessageBox::warning
|
Chris@233
|
4841 (this,
|
Chris@233
|
4842 tr("Failed to generate layer"),
|
Chris@983
|
4843 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform %1failed:<p>%2")
|
Chris@983
|
4844 .arg(quoted).arg(message),
|
Chris@233
|
4845 QMessageBox::Ok);
|
Chris@233
|
4846 } else {
|
Chris@233
|
4847 QMessageBox::warning
|
Chris@233
|
4848 (this,
|
Chris@233
|
4849 tr("Failed to generate layer"),
|
Chris@983
|
4850 tr("<b>Layer generation failed</b><p>Failed to generate a derived layer.<p>The layer transform %1failed.<p>No error information is available.")
|
Chris@983
|
4851 .arg(quoted),
|
Chris@233
|
4852 QMessageBox::Ok);
|
Chris@233
|
4853 }
|
Chris@233
|
4854 }
|
Chris@233
|
4855
|
Chris@233
|
4856 void
|
Chris@730
|
4857 MainWindow::modelGenerationWarning(QString /* transformName */, QString message)
|
Chris@233
|
4858 {
|
Chris@247
|
4859 emit hideSplash();
|
Chris@247
|
4860
|
Chris@233
|
4861 QMessageBox::warning
|
Chris@233
|
4862 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@233
|
4863 }
|
Chris@233
|
4864
|
Chris@233
|
4865 void
|
Chris@233
|
4866 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@233
|
4867 QString transformName, QString message)
|
Chris@233
|
4868 {
|
Chris@247
|
4869 emit hideSplash();
|
Chris@247
|
4870
|
Chris@233
|
4871 if (message != "") {
|
Chris@233
|
4872
|
Chris@233
|
4873 QMessageBox::warning
|
Chris@233
|
4874 (this,
|
Chris@233
|
4875 tr("Failed to regenerate layer"),
|
Chris@233
|
4876 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
|
4877 .arg(layerName).arg(transformName).arg(message),
|
Chris@233
|
4878 QMessageBox::Ok);
|
Chris@233
|
4879 } else {
|
Chris@233
|
4880 QMessageBox::warning
|
Chris@233
|
4881 (this,
|
Chris@233
|
4882 tr("Failed to regenerate layer"),
|
Chris@233
|
4883 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
|
4884 .arg(layerName).arg(transformName),
|
Chris@233
|
4885 QMessageBox::Ok);
|
Chris@233
|
4886 }
|
Chris@233
|
4887 }
|
Chris@233
|
4888
|
Chris@233
|
4889 void
|
Chris@233
|
4890 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@730
|
4891 QString /* transformName */,
|
Chris@730
|
4892 QString message)
|
Chris@233
|
4893 {
|
Chris@247
|
4894 emit hideSplash();
|
Chris@247
|
4895
|
Chris@233
|
4896 QMessageBox::warning
|
Chris@233
|
4897 (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
|
4898 }
|
Chris@233
|
4899
|
Chris@233
|
4900 void
|
Chris@1151
|
4901 MainWindow::alignmentFailed(QString message)
|
Chris@0
|
4902 {
|
Chris@0
|
4903 QMessageBox::warning
|
Chris@0
|
4904 (this,
|
Chris@233
|
4905 tr("Failed to calculate alignment"),
|
Chris@1151
|
4906 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment:<p>%1")
|
Chris@1151
|
4907 .arg(message),
|
Chris@165
|
4908 QMessageBox::Ok);
|
Chris@0
|
4909 }
|
Chris@0
|
4910
|
Chris@0
|
4911 void
|
Chris@0
|
4912 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
4913 {
|
Chris@438
|
4914 // SVDEBUG << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
4915 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
4916 m_rightButtonMenu->popup(position);
|
Chris@0
|
4917 }
|
Chris@0
|
4918
|
Chris@0
|
4919 void
|
Chris@0
|
4920 MainWindow::showLayerTree()
|
Chris@0
|
4921 {
|
Chris@219
|
4922 if (!m_layerTreeDialog.isNull()) {
|
Chris@219
|
4923 m_layerTreeDialog->show();
|
Chris@219
|
4924 m_layerTreeDialog->raise();
|
Chris@177
|
4925 return;
|
Chris@177
|
4926 }
|
Chris@177
|
4927
|
Chris@762
|
4928 m_layerTreeDialog = new LayerTreeDialog(m_paneStack, this);
|
Chris@232
|
4929 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
|
Chris@219
|
4930 m_layerTreeDialog->show();
|
Chris@0
|
4931 }
|
Chris@0
|
4932
|
Chris@0
|
4933 void
|
Chris@306
|
4934 MainWindow::showActivityLog()
|
Chris@306
|
4935 {
|
Chris@306
|
4936 m_activityLog->show();
|
Chris@306
|
4937 m_activityLog->raise();
|
Chris@306
|
4938 m_activityLog->scrollToEnd();
|
Chris@306
|
4939 }
|
Chris@306
|
4940
|
Chris@306
|
4941 void
|
Chris@891
|
4942 MainWindow::showUnitConverter()
|
Chris@891
|
4943 {
|
Chris@891
|
4944 m_unitConverter->show();
|
Chris@891
|
4945 m_unitConverter->raise();
|
Chris@891
|
4946 }
|
Chris@891
|
4947
|
Chris@891
|
4948 void
|
Chris@0
|
4949 MainWindow::preferences()
|
Chris@0
|
4950 {
|
Chris@436
|
4951 bool goToTemplateTab =
|
Chris@436
|
4952 (sender() && sender()->objectName() == "set_default_template");
|
Chris@436
|
4953
|
Chris@0
|
4954 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
4955 m_preferencesDialog->show();
|
Chris@0
|
4956 m_preferencesDialog->raise();
|
Chris@436
|
4957 if (goToTemplateTab) {
|
Chris@436
|
4958 m_preferencesDialog->switchToTab(PreferencesDialog::TemplateTab);
|
Chris@436
|
4959 }
|
Chris@0
|
4960 return;
|
Chris@0
|
4961 }
|
Chris@0
|
4962
|
Chris@0
|
4963 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
4964
|
Chris@1413
|
4965 connect(m_preferencesDialog, SIGNAL(audioDeviceChanged()),
|
Chris@1413
|
4966 this, SLOT(recreateAudioIO()));
|
Chris@1448
|
4967 connect(m_preferencesDialog, SIGNAL(coloursChanged()),
|
Chris@1448
|
4968 this, SLOT(coloursChanged()));
|
Chris@1413
|
4969
|
Chris@0
|
4970 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
4971 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
4972 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
4973 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
4974 // without resetting its own widgets, so its state will be
|
Chris@0
|
4975 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
4976 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
4977
|
Chris@0
|
4978 m_preferencesDialog->show();
|
Chris@436
|
4979 if (goToTemplateTab) {
|
Chris@436
|
4980 m_preferencesDialog->switchToTab(PreferencesDialog::TemplateTab);
|
Chris@436
|
4981 }
|
Chris@0
|
4982 }
|
Chris@0
|
4983
|
Chris@0
|
4984 void
|
Chris@90
|
4985 MainWindow::mouseEnteredWidget()
|
Chris@90
|
4986 {
|
Chris@90
|
4987 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
4988 if (!w) return;
|
Chris@90
|
4989
|
Chris@1386
|
4990 if (w == m_mainLevelPan) {
|
Chris@1386
|
4991 contextHelpChanged(tr("Adjust the master playback level and pan"));
|
Chris@90
|
4992 } else if (w == m_playSpeed) {
|
Chris@116
|
4993 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@90
|
4994 }
|
Chris@90
|
4995 }
|
Chris@90
|
4996
|
Chris@90
|
4997 void
|
Chris@90
|
4998 MainWindow::mouseLeftWidget()
|
Chris@90
|
4999 {
|
Chris@116
|
5000 contextHelpChanged("");
|
Chris@116
|
5001 }
|
Chris@116
|
5002
|
Chris@116
|
5003 void
|
Chris@0
|
5004 MainWindow::website()
|
Chris@0
|
5005 {
|
Chris@0
|
5006 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
5007 }
|
Chris@0
|
5008
|
Chris@0
|
5009 void
|
Chris@0
|
5010 MainWindow::help()
|
Chris@0
|
5011 {
|
Chris@318
|
5012 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/%1/en/").arg(SV_VERSION));
|
Chris@0
|
5013 }
|
Chris@0
|
5014
|
Chris@0
|
5015 void
|
Chris@1516
|
5016 MainWindow::whatsNew()
|
Chris@1516
|
5017 {
|
Chris@1516
|
5018 QFile changelog(":CHANGELOG");
|
Chris@1516
|
5019 changelog.open(QFile::ReadOnly);
|
Chris@1516
|
5020 QByteArray content = changelog.readAll();
|
Chris@1516
|
5021 QString text = QString::fromUtf8(content);
|
Chris@1516
|
5022
|
Chris@1516
|
5023 QDialog *d = new QDialog(this);
|
Chris@1516
|
5024 d->setWindowTitle(tr("What's New"));
|
Chris@1516
|
5025
|
Chris@1516
|
5026 QGridLayout *layout = new QGridLayout;
|
Chris@1516
|
5027 d->setLayout(layout);
|
Chris@1516
|
5028
|
Chris@1516
|
5029 int row = 0;
|
Chris@1516
|
5030
|
Chris@1516
|
5031 QLabel *iconLabel = new QLabel;
|
Chris@1516
|
5032 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64));
|
Chris@1516
|
5033 layout->addWidget(iconLabel, row, 0);
|
Chris@1516
|
5034
|
Chris@1516
|
5035 layout->addWidget
|
Chris@1516
|
5036 (new QLabel(tr("<h3>What's New in %1</h3>")
|
Chris@1516
|
5037 .arg(QApplication::applicationName())),
|
Chris@1516
|
5038 row++, 1);
|
Chris@1516
|
5039 layout->setColumnStretch(2, 10);
|
Chris@1516
|
5040
|
Chris@1516
|
5041 QTextEdit *textEdit = new QTextEdit;
|
Chris@1516
|
5042 layout->addWidget(textEdit, row++, 1, 1, 2);
|
Chris@1516
|
5043
|
Chris@1516
|
5044 if (m_newerVersionIs != "") {
|
Chris@1516
|
5045 layout->addWidget(new QLabel(tr("<b>Note:</b> A newer version of Sonic Visualiser is available.<br>(Version %1 is available; you are using version %2)").arg(m_newerVersionIs).arg(SV_VERSION)), row++, 1, 1, 2);
|
Chris@1516
|
5046 }
|
Chris@1516
|
5047
|
Chris@1516
|
5048 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@1516
|
5049 layout->addWidget(bb, row++, 0, 1, 3);
|
Chris@1516
|
5050 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@1516
|
5051
|
Chris@1516
|
5052 text.replace(QRegExp("(.)\n +(.)"), "\\1 \\2");
|
Chris@1516
|
5053 text.replace(QRegExp("\n - ([^\n]+)"), "\n<li>\\1</li>");
|
Chris@1516
|
5054 text.replace(QRegExp(": *\n"), ":\n<ul>\n");
|
Chris@1516
|
5055 text.replace(QRegExp("</li>\n\\s*\n"), "</li>\n</ul>\n\n");
|
Chris@1516
|
5056 text.replace(QRegExp("\n(\\w[^:\n]+:)"), "\n<p><b>\\1</b></p>");
|
Chris@1516
|
5057 // text.replace(QRegExp("<li>([^,.\n]+)([,.] +\\w)"), "<li><b>\\1</b>\\2");
|
Chris@1516
|
5058
|
Chris@1516
|
5059 textEdit->setHtml(text);
|
Chris@1516
|
5060 textEdit->setReadOnly(true);
|
Chris@1516
|
5061
|
cannam@1517
|
5062 d->setMinimumSize(m_viewManager->scalePixelSize(520),
|
cannam@1517
|
5063 m_viewManager->scalePixelSize(450));
|
Chris@1516
|
5064
|
Chris@1516
|
5065 d->exec();
|
Chris@1516
|
5066
|
Chris@1516
|
5067 delete d;
|
Chris@1516
|
5068 }
|
Chris@1516
|
5069
|
Chris@1610
|
5070 QString
|
Chris@1610
|
5071 MainWindow::getReleaseText() const
|
Chris@0
|
5072 {
|
Chris@0
|
5073 bool debug = false;
|
Chris@0
|
5074 QString version = "(unknown version)";
|
Chris@0
|
5075
|
Chris@0
|
5076 #ifdef BUILD_DEBUG
|
Chris@0
|
5077 debug = true;
|
Chris@285
|
5078 #endif // BUILD_DEBUG
|
Chris@0
|
5079 #ifdef SV_VERSION
|
Chris@0
|
5080 #ifdef SVNREV
|
Chris@0
|
5081 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@285
|
5082 #else // !SVNREV
|
Chris@0
|
5083 version = tr("Release %1").arg(SV_VERSION);
|
Chris@285
|
5084 #endif // SVNREV
|
Chris@285
|
5085 #else // !SV_VERSION
|
Chris@0
|
5086 #ifdef SVNREV
|
Chris@0
|
5087 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@285
|
5088 #endif // SVNREV
|
Chris@285
|
5089 #endif // SV_VERSION
|
Chris@0
|
5090
|
Chris@1610
|
5091 return tr("%1 : %2 configuration, %3-bit build")
|
Chris@0
|
5092 .arg(version)
|
Chris@1264
|
5093 .arg(debug ? tr("Debug") : tr("Release"))
|
Chris@1264
|
5094 .arg(sizeof(void *) * 8);
|
Chris@1610
|
5095 }
|
Chris@1610
|
5096
|
Chris@1610
|
5097 void
|
Chris@1610
|
5098 MainWindow::about()
|
Chris@1610
|
5099 {
|
Chris@1610
|
5100 QString aboutText;
|
Chris@1610
|
5101
|
Chris@1610
|
5102 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@1610
|
5103 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@1610
|
5104 aboutText += QString("<p><small>%1</small></p>").arg(getReleaseText());
|
Chris@0
|
5105
|
Chris@1516
|
5106 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@1516
|
5107 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@1516
|
5108 }
|
Chris@1516
|
5109
|
Chris@1516
|
5110 aboutText += "</small><p><small>";
|
Chris@285
|
5111
|
Chris@1155
|
5112 aboutText += tr("With Qt v%1 © The Qt Company").arg(QT_VERSION_STR);
|
Chris@285
|
5113
|
Chris@1516
|
5114 aboutText += "</small><small>";
|
Chris@1516
|
5115
|
Chris@0
|
5116 #ifdef HAVE_JACK
|
Chris@93
|
5117 #ifdef JACK_VERSION
|
Chris@285
|
5118 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@285
|
5119 #else // !JACK_VERSION
|
Chris@257
|
5120 aboutText += tr("<br>With JACK audio output library © Paul Davis and Jack O'Quin");
|
Chris@285
|
5121 #endif // JACK_VERSION
|
Chris@285
|
5122 #endif // HAVE_JACK
|
Chris@0
|
5123 #ifdef HAVE_PORTAUDIO
|
Chris@257
|
5124 aboutText += tr("<br>With PortAudio audio output library © Ross Bencina and Phil Burk");
|
Chris@285
|
5125 #endif // HAVE_PORTAUDIO
|
Chris@257
|
5126 #ifdef HAVE_LIBPULSE
|
Chris@285
|
5127 #ifdef LIBPULSE_VERSION
|
Chris@285
|
5128 aboutText += tr("<br>With PulseAudio audio output library v%1 © Lennart Poettering and Pierre Ossman").arg(LIBPULSE_VERSION);
|
Chris@285
|
5129 #else // !LIBPULSE_VERSION
|
Chris@257
|
5130 aboutText += tr("<br>With PulseAudio audio output library © Lennart Poettering and Pierre Ossman");
|
Chris@285
|
5131 #endif // LIBPULSE_VERSION
|
Chris@285
|
5132 #endif // HAVE_LIBPULSE
|
Chris@0
|
5133 #ifdef HAVE_OGGZ
|
Chris@93
|
5134 #ifdef OGGZ_VERSION
|
Chris@0
|
5135 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@285
|
5136 #else // !OGGZ_VERSION
|
Chris@93
|
5137 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@285
|
5138 #endif // OGGZ_VERSION
|
Chris@285
|
5139 #endif // HAVE_OGGZ
|
Chris@0
|
5140 #ifdef HAVE_MAD
|
Chris@93
|
5141 #ifdef MAD_VERSION
|
Chris@285
|
5142 aboutText += tr("<br>With MAD mp3 decoder v%1 © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@285
|
5143 #else // !MAD_VERSION
|
Chris@93
|
5144 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@285
|
5145 #endif // MAD_VERSION
|
Chris@285
|
5146 #endif // HAVE_MAD
|
Chris@0
|
5147 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
5148 #ifdef SAMPLERATE_VERSION
|
Chris@285
|
5149 aboutText += tr("<br>With libsamplerate v%1 © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@285
|
5150 #else // !SAMPLERATE_VERSION
|
Chris@93
|
5151 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@285
|
5152 #endif // SAMPLERATE_VERSION
|
Chris@285
|
5153 #endif // HAVE_SAMPLERATE
|
Chris@0
|
5154 #ifdef HAVE_SNDFILE
|
Chris@93
|
5155 #ifdef SNDFILE_VERSION
|
Chris@285
|
5156 aboutText += tr("<br>With libsndfile v%1 © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@285
|
5157 #else // !SNDFILE_VERSION
|
Chris@93
|
5158 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@285
|
5159 #endif // SNDFILE_VERSION
|
Chris@285
|
5160 #endif // HAVE_SNDFILE
|
Chris@127
|
5161 #ifdef HAVE_FFTW3F
|
Chris@93
|
5162 #ifdef FFTW3_VERSION
|
Chris@285
|
5163 aboutText += tr("<br>With FFTW3 v%1 © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@285
|
5164 #else // !FFTW3_VERSION
|
Chris@93
|
5165 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@285
|
5166 #endif // FFTW3_VERSION
|
Chris@285
|
5167 #endif // HAVE_FFTW3F
|
Chris@267
|
5168 #ifdef HAVE_RUBBERBAND
|
Chris@267
|
5169 #ifdef RUBBERBAND_VERSION
|
Chris@1315
|
5170 aboutText += tr("<br>With Rubber Band Library v%1 © Particular Programs Ltd").arg(RUBBERBAND_VERSION);
|
Chris@285
|
5171 #else // !RUBBERBAND_VERSION
|
Chris@1315
|
5172 aboutText += tr("<br>With Rubber Band Library © Particular Programs Ltd");
|
Chris@285
|
5173 #endif // RUBBERBAND_VERSION
|
Chris@285
|
5174 #endif // HAVE_RUBBERBAND
|
Chris@1315
|
5175 aboutText += tr("<br>With Vamp plugin support (API v%1, host SDK v%2) © Chris Cannam and QMUL").arg(VAMP_API_VERSION).arg(VAMP_SDK_VERSION);
|
Chris@1636
|
5176 aboutText += tr("<br>With Piper Vamp protocol bridge © QMUL");
|
Chris@0
|
5177 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
5178 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@285
|
5179 #ifdef REDLAND_VERSION
|
Chris@285
|
5180 aboutText += tr("<br>With Redland RDF datastore v%1 © Dave Beckett and the University of Bristol").arg(REDLAND_VERSION);
|
Chris@285
|
5181 #else // !REDLAND_VERSION
|
Chris@285
|
5182 aboutText += tr("<br>With Redland RDF datastore © Dave Beckett and the University of Bristol");
|
Chris@285
|
5183 #endif // REDLAND_VERSION
|
Chris@523
|
5184 aboutText += tr("<br>With Serd and Sord RDF parser and store © David Robillard");
|
Chris@1315
|
5185 aboutText += tr("<br>With Dataquay Qt/RDF library © Particular Programs Ltd");
|
Chris@1315
|
5186 aboutText += tr("<br>With Cap'n Proto serialisation © Sandstorm Development Group");
|
Chris@300
|
5187 aboutText += tr("<br>With RtMidi © Gary P. Scavone");
|
Chris@300
|
5188
|
Chris@69
|
5189 #ifdef HAVE_LIBLO
|
Chris@93
|
5190 #ifdef LIBLO_VERSION
|
Chris@285
|
5191 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
5192 #else // !LIBLO_VERSION
|
Chris@327
|
5193 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris");
|
Chris@285
|
5194 #endif // LIBLO_VERSION
|
Chris@285
|
5195
|
Chris@285
|
5196 aboutText += "</small></p>";
|
Chris@285
|
5197 #endif // HAVE_LIBLO
|
Chris@285
|
5198
|
Chris@1667
|
5199 aboutText += "<p><small>";
|
Chris@1667
|
5200 aboutText += tr("Russian UI translation contributed by Alexandre Prokoudine.");
|
Chris@1667
|
5201 aboutText += "<br>";
|
Chris@1667
|
5202 aboutText += tr("Czech UI translation contributed by Pavel Fric.");
|
Chris@1667
|
5203 aboutText += "</small></p>";
|
Chris@1667
|
5204
|
Chris@0
|
5205 aboutText +=
|
Chris@1960
|
5206 "<p><small>Sonic Visualiser Copyright © 2005–2018 Chris Cannam and "
|
Chris@1667
|
5207 "Queen Mary, University of London.</small></p>";
|
Chris@1667
|
5208
|
Chris@1667
|
5209 aboutText +=
|
Chris@285
|
5210 "<p><small>This program is free software; you can redistribute it and/or "
|
Chris@231
|
5211 "modify it under the terms of the GNU General Public License as "
|
Chris@231
|
5212 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
5213 "License, or (at your option) any later version.<br>See the file "
|
Chris@285
|
5214 "COPYING included with this distribution for more information.</small></p>";
|
Chris@1516
|
5215
|
Chris@1516
|
5216 // use our own dialog so we can influence the size
|
Chris@1516
|
5217
|
Chris@1516
|
5218 QDialog *d = new QDialog(this);
|
Chris@1516
|
5219
|
Chris@1516
|
5220 d->setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
|
Chris@1516
|
5221
|
Chris@1516
|
5222 QGridLayout *layout = new QGridLayout;
|
Chris@1516
|
5223 d->setLayout(layout);
|
Chris@1516
|
5224
|
Chris@1516
|
5225 int row = 0;
|
Chris@0
|
5226
|
Chris@1516
|
5227 QLabel *iconLabel = new QLabel;
|
Chris@1516
|
5228 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64));
|
Chris@1516
|
5229 layout->addWidget(iconLabel, row, 0, Qt::AlignTop);
|
Chris@1516
|
5230
|
Chris@1516
|
5231 QLabel *mainText = new QLabel();
|
Chris@1516
|
5232 layout->addWidget(mainText, row, 1, 1, 2);
|
Chris@1516
|
5233
|
Chris@1516
|
5234 layout->setRowStretch(row, 10);
|
Chris@1516
|
5235 layout->setColumnStretch(1, 10);
|
Chris@1516
|
5236
|
Chris@1516
|
5237 ++row;
|
Chris@1516
|
5238
|
Chris@1516
|
5239 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@1516
|
5240 layout->addWidget(bb, row++, 0, 1, 3);
|
Chris@1516
|
5241 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@1516
|
5242
|
Chris@1516
|
5243 // mainText->setHtml(aboutText);
|
Chris@1516
|
5244 // mainText->setReadOnly(true);
|
Chris@1516
|
5245 mainText->setWordWrap(true);
|
Chris@1516
|
5246 mainText->setOpenExternalLinks(true);
|
Chris@1516
|
5247 mainText->setText(aboutText);
|
Chris@1516
|
5248
|
Chris@1516
|
5249 d->setMinimumSize(m_viewManager->scalePixelSize(420),
|
Chris@1516
|
5250 m_viewManager->scalePixelSize(200));
|
Chris@1516
|
5251
|
Chris@1516
|
5252 d->exec();
|
Chris@1516
|
5253
|
Chris@1516
|
5254 delete d;
|
Chris@1516
|
5255 /*
|
Chris@1516
|
5256 QMessageBox about(QMessageBox::Information,
|
Chris@1516
|
5257 tr("About Sonic Visualiser"),
|
Chris@1516
|
5258 aboutText,
|
Chris@1516
|
5259 QMessageBox::StandardButtons(QMessageBox::Ok),
|
Chris@1516
|
5260 this);
|
Chris@1516
|
5261
|
Chris@1516
|
5262 QIcon icon = QApplication::windowIcon();
|
Chris@1516
|
5263 QSize size = icon.actualSize(QSize(64, 64));
|
Chris@1516
|
5264 about.setIconPixmap(icon.pixmap(size));
|
Chris@1516
|
5265
|
Chris@1516
|
5266 about.setMinimumSize(m_viewManager->scalePixelSize(400),
|
Chris@1516
|
5267 m_viewManager->scalePixelSize(400));
|
Chris@1516
|
5268
|
Chris@1516
|
5269 about.exec();
|
Chris@1516
|
5270 */
|
Chris@0
|
5271 }
|
Chris@0
|
5272
|
Chris@162
|
5273 void
|
Chris@162
|
5274 MainWindow::keyReference()
|
Chris@162
|
5275 {
|
Chris@162
|
5276 m_keyReference->show();
|
Chris@162
|
5277 }
|
Chris@162
|
5278
|
Chris@333
|
5279 void
|
Chris@333
|
5280 MainWindow::newerVersionAvailable(QString version)
|
Chris@333
|
5281 {
|
Chris@1516
|
5282 m_newerVersionIs = version;
|
Chris@1516
|
5283
|
Chris@334
|
5284 QSettings settings;
|
Chris@334
|
5285 settings.beginGroup("NewerVersionWarning");
|
Chris@334
|
5286 QString tag = QString("version-%1-available-show").arg(version);
|
Chris@334
|
5287 if (settings.value(tag, true).toBool()) {
|
Chris@334
|
5288 QString title(tr("Newer version available"));
|
Chris@663
|
5289 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser, but version %2 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
|
5290 QMessageBox::information(this, title, text);
|
Chris@334
|
5291 settings.setValue(tag, false);
|
Chris@334
|
5292 }
|
Chris@334
|
5293 settings.endGroup();
|
Chris@333
|
5294 }
|
Chris@333
|
5295
|
Chris@333
|
5296
|