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