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/XmlExportable.h"
|
Chris@248
|
80 #include "widgets/CommandHistory.h"
|
Chris@0
|
81 #include "base/Profiler.h"
|
Chris@0
|
82 #include "base/Clipboard.h"
|
Chris@165
|
83 #include "base/UnitDatabase.h"
|
Chris@248
|
84 #include "layer/ColourDatabase.h"
|
Chris@265
|
85 #include "widgets/ModelDataTableDialog.h"
|
Chris@2449
|
86 #include "widgets/CSVExportDialog.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@2475
|
129 #include <QWidgetAction>
|
Chris@0
|
130
|
Chris@0
|
131 #include <iostream>
|
Chris@0
|
132 #include <cstdio>
|
Chris@0
|
133 #include <errno.h>
|
Chris@0
|
134
|
Chris@33
|
135 using std::vector;
|
Chris@33
|
136 using std::map;
|
Chris@33
|
137 using std::set;
|
Chris@33
|
138
|
Chris@0
|
139
|
Chris@2375
|
140 MainWindow::MainWindow(AudioMode audioMode, MIDIMode midiMode, bool withOSCSupport) :
|
Chris@2375
|
141 MainWindowBase(audioMode, midiMode, int(PaneStack::Option::Default)),
|
Chris@2126
|
142 m_overview(nullptr),
|
Chris@0
|
143 m_mainMenusCreated(false),
|
Chris@2126
|
144 m_paneMenu(nullptr),
|
Chris@2126
|
145 m_layerMenu(nullptr),
|
Chris@2126
|
146 m_transformsMenu(nullptr),
|
Chris@2126
|
147 m_playbackMenu(nullptr),
|
Chris@2126
|
148 m_existingLayersMenu(nullptr),
|
Chris@2126
|
149 m_sliceMenu(nullptr),
|
Chris@2126
|
150 m_recentFilesMenu(nullptr),
|
Chris@2126
|
151 m_recentTransformsMenu(nullptr),
|
Chris@2126
|
152 m_templatesMenu(nullptr),
|
Chris@2126
|
153 m_rightButtonMenu(nullptr),
|
Chris@2126
|
154 m_rightButtonLayerMenu(nullptr),
|
Chris@2126
|
155 m_rightButtonTransformsMenu(nullptr),
|
Chris@2126
|
156 m_rightButtonPlaybackMenu(nullptr),
|
Chris@2475
|
157 m_lastRightButtonPropertyMenu(nullptr),
|
Chris@2126
|
158 m_soloAction(nullptr),
|
Chris@2126
|
159 m_rwdStartAction(nullptr),
|
Chris@2126
|
160 m_rwdSimilarAction(nullptr),
|
Chris@2126
|
161 m_rwdAction(nullptr),
|
Chris@2126
|
162 m_ffwdAction(nullptr),
|
Chris@2126
|
163 m_ffwdSimilarAction(nullptr),
|
Chris@2126
|
164 m_ffwdEndAction(nullptr),
|
Chris@2126
|
165 m_playAction(nullptr),
|
Chris@2126
|
166 m_recordAction(nullptr),
|
Chris@2126
|
167 m_playSelectionAction(nullptr),
|
Chris@2126
|
168 m_playLoopAction(nullptr),
|
Chris@705
|
169 m_soloModified(false),
|
Chris@705
|
170 m_prevSolo(false),
|
Chris@2126
|
171 m_playControlsSpacer(nullptr),
|
Chris@239
|
172 m_playControlsWidth(0),
|
Chris@2126
|
173 m_preferencesDialog(nullptr),
|
Chris@2126
|
174 m_layerTreeDialog(nullptr),
|
Chris@302
|
175 m_activityLog(new ActivityLog()),
|
Chris@891
|
176 m_unitConverter(new UnitConverter()),
|
Chris@426
|
177 m_keyReference(new KeyReference()),
|
Chris@2126
|
178 m_templateWatcher(nullptr)
|
Chris@0
|
179 {
|
Chris@253
|
180 Profiler profiler("MainWindow::MainWindow");
|
Chris@253
|
181
|
Chris@1610
|
182 SVDEBUG << "MainWindow: " << getReleaseText() << endl;
|
Chris@1610
|
183
|
Chris@518
|
184 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
185
|
Chris@165
|
186 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@165
|
187 udb->registerUnit("Hz");
|
Chris@165
|
188 udb->registerUnit("dB");
|
Chris@165
|
189 udb->registerUnit("s");
|
Chris@165
|
190
|
Chris@165
|
191 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@165
|
192 cdb->addColour(Qt::black, tr("Black"));
|
Chris@165
|
193 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@165
|
194 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@165
|
195 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@165
|
196 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@165
|
197 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@166
|
198 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@166
|
199 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@166
|
200 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@2466
|
201 cdb->setUseDarkBackground(cdb->addColour(QColor(20, 255, 90), tr("Bright Green")), true);
|
Chris@166
|
202 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@166
|
203 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
204
|
Chris@1639
|
205 SVDEBUG << "MainWindow: Creating main user interface layout" << endl;
|
Chris@1639
|
206
|
Chris@0
|
207 QFrame *frame = new QFrame;
|
Chris@0
|
208 setCentralWidget(frame);
|
Chris@0
|
209
|
Chris@0
|
210 QGridLayout *layout = new QGridLayout;
|
Chris@180
|
211
|
Chris@519
|
212 m_descriptionLabel = new QLabel;
|
Chris@0
|
213
|
Chris@489
|
214 m_mainScroll = new QScrollArea(frame);
|
Chris@489
|
215 m_mainScroll->setWidgetResizable(true);
|
Chris@489
|
216 m_mainScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@489
|
217 m_mainScroll->setFrameShape(QFrame::NoFrame);
|
Chris@489
|
218
|
Chris@489
|
219 m_mainScroll->setWidget(m_paneStack);
|
Chris@159
|
220
|
Chris@65
|
221 m_overview = new Overview(frame);
|
Chris@65
|
222 m_overview->setViewManager(m_viewManager);
|
Chris@1431
|
223 int overviewHeight = m_viewManager->scalePixelSize(35);
|
Chris@1431
|
224 if (overviewHeight < 40) overviewHeight = 40;
|
Chris@1431
|
225 m_overview->setFixedHeight(overviewHeight);
|
Chris@144
|
226 #ifndef _WIN32
|
Chris@144
|
227 // For some reason, the contents of the overview never appear if we
|
Chris@144
|
228 // make this setting on Windows. I have no inclination at the moment
|
Chris@144
|
229 // to track down the reason why.
|
Chris@129
|
230 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@144
|
231 #endif
|
Chris@90
|
232 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
233 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
234
|
Chris@0
|
235 m_panLayer = new WaveformLayer;
|
Chris@0
|
236 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
237 m_panLayer->setAggressiveCacheing(true);
|
Chris@65
|
238 m_overview->addLayer(m_panLayer);
|
Chris@174
|
239
|
Chris@1448
|
240 coloursChanged(); // sets pan layer colour from preferences
|
Chris@0
|
241
|
Chris@0
|
242 m_playSpeed = new AudioDial(frame);
|
Chris@12
|
243 m_playSpeed->setMinimum(0);
|
Chris@1031
|
244 m_playSpeed->setMaximum(120);
|
Chris@1031
|
245 m_playSpeed->setValue(60);
|
Chris@1431
|
246 m_playSpeed->setFixedWidth(overviewHeight);
|
Chris@1431
|
247 m_playSpeed->setFixedHeight(overviewHeight);
|
Chris@0
|
248 m_playSpeed->setNotchesVisible(true);
|
Chris@25
|
249 m_playSpeed->setPageStep(10);
|
Chris@1031
|
250 m_playSpeed->setObjectName(tr("Playback Speed"));
|
Chris@1031
|
251 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper);
|
Chris@1031
|
252 m_playSpeed->setDefaultValue(60);
|
Chris@60
|
253 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
254 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
Chris@1770
|
255 this, SLOT(playSpeedChanged(int)));
|
Chris@90
|
256 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
257 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
258
|
Chris@1431
|
259 m_mainLevelPan = new LevelPanToolButton(frame);
|
Chris@1386
|
260 connect(m_mainLevelPan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@1386
|
261 connect(m_mainLevelPan, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@1431
|
262 m_mainLevelPan->setFixedHeight(overviewHeight);
|
Chris@1431
|
263 m_mainLevelPan->setFixedWidth(overviewHeight);
|
Chris@1431
|
264 m_mainLevelPan->setImageSize((overviewHeight * 3) / 4);
|
Chris@1431
|
265 m_mainLevelPan->setBigImageSize(overviewHeight * 3);
|
Chris@168
|
266
|
Chris@239
|
267 m_playControlsSpacer = new QFrame;
|
Chris@239
|
268
|
Chris@1383
|
269 layout->setSpacing(m_viewManager->scalePixelSize(4));
|
Chris@1383
|
270 layout->addWidget(m_mainScroll, 0, 0, 1, 4);
|
Chris@1383
|
271 layout->addWidget(m_overview, 1, 0);
|
Chris@1431
|
272 layout->addWidget(m_playSpeed, 1, 1);
|
Chris@1431
|
273 layout->addWidget(m_playControlsSpacer, 1, 2);
|
Chris@1386
|
274 layout->addWidget(m_mainLevelPan, 1, 3);
|
Chris@239
|
275
|
Chris@239
|
276 m_playControlsWidth =
|
Chris@1386
|
277 m_mainLevelPan->width() + m_playSpeed->width() + layout->spacing() * 2;
|
Chris@239
|
278
|
Chris@239
|
279 m_paneStack->setPropertyStackMinWidth(m_playControlsWidth
|
Chris@239
|
280 + 2 + layout->spacing());
|
Chris@239
|
281 m_playControlsSpacer->setFixedSize(QSize(2, 2));
|
Chris@239
|
282
|
Chris@1383
|
283 layout->setColumnStretch(0, 10);
|
Chris@239
|
284
|
Chris@239
|
285 connect(m_paneStack, SIGNAL(propertyStacksResized(int)),
|
Chris@239
|
286 this, SLOT(propertyStacksResized(int)));
|
Chris@16
|
287
|
Chris@0
|
288 frame->setLayout(layout);
|
Chris@0
|
289
|
Chris@1639
|
290 SVDEBUG << "MainWindow: Creating menus and toolbars" << endl;
|
Chris@1639
|
291
|
cannam@1461
|
292 #ifdef Q_OS_MAC
|
cannam@1461
|
293 // Mac doesn't align menu labels when icons are shown: result is messy
|
cannam@1461
|
294 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
|
cannam@1461
|
295 setIconsVisibleInMenus(false);
|
cannam@1461
|
296 #endif
|
cannam@1461
|
297
|
Chris@0
|
298 setupMenus();
|
Chris@0
|
299 setupToolbars();
|
Chris@155
|
300 setupHelpMenu();
|
Chris@0
|
301
|
Chris@90
|
302 statusBar();
|
Chris@340
|
303 m_currentLabel = new QLabel;
|
Chris@340
|
304 statusBar()->addPermanentWidget(m_currentLabel);
|
Chris@0
|
305
|
Chris@728
|
306 finaliseMenus();
|
Chris@728
|
307
|
Chris@302
|
308 connect(m_viewManager, SIGNAL(activity(QString)),
|
Chris@302
|
309 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
310 connect(m_playSource, SIGNAL(activity(QString)),
|
Chris@302
|
311 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
312 connect(CommandHistory::getInstance(), SIGNAL(activity(QString)),
|
Chris@302
|
313 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@310
|
314 connect(this, SIGNAL(activity(QString)),
|
Chris@310
|
315 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
316 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
|
Chris@1087
|
317
|
Chris@306
|
318 m_activityLog->hide();
|
Chris@303
|
319
|
Chris@891
|
320 m_unitConverter->hide();
|
Chris@1056
|
321
|
Chris@1056
|
322 setAudioRecordMode(RecordCreateAdditionalModel);
|
Chris@1639
|
323
|
Chris@1639
|
324 SVDEBUG << "MainWindow: Creating new session" << endl;
|
Chris@1639
|
325
|
Chris@303
|
326 newSession();
|
Chris@303
|
327
|
Chris@304
|
328 connect(m_midiInput, SIGNAL(eventsAvailable()),
|
Chris@304
|
329 this, SLOT(midiEventsAvailable()));
|
Chris@663
|
330
|
Chris@1639
|
331 SVDEBUG << "MainWindow: Creating network permission tester" << endl;
|
Chris@1639
|
332
|
Chris@1613
|
333 NetworkPermissionTester tester(withOSCSupport);
|
Chris@663
|
334 bool networkPermission = tester.havePermission();
|
Chris@663
|
335 if (networkPermission) {
|
Chris@1639
|
336 SVDEBUG << "MainWindow: Starting transform population thread" << endl;
|
Chris@663
|
337 TransformFactory::getInstance()->startPopulationThread();
|
Chris@1639
|
338
|
Chris@1639
|
339 SVDEBUG << "MainWindow: Creating surveyer" << endl;
|
Chris@663
|
340 m_surveyer = new Surveyer
|
Chris@663
|
341 ("sonicvisualiser.org", "survey23-present.txt", "survey23.php");
|
Chris@1639
|
342
|
Chris@1639
|
343 SVDEBUG << "MainWindow: Creating version tester" << endl;
|
Chris@663
|
344 m_versionTester = new VersionTester
|
Chris@663
|
345 ("sonicvisualiser.org", "latest-version.txt", SV_VERSION);
|
Chris@663
|
346 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@663
|
347 this, SLOT(newerVersionAvailable(QString)));
|
Chris@663
|
348 } else {
|
Chris@2126
|
349 m_surveyer = nullptr;
|
Chris@2126
|
350 m_versionTester = nullptr;
|
Chris@663
|
351 }
|
Chris@1087
|
352
|
Chris@2240
|
353 if (withOSCSupport && networkPermission) {
|
Chris@2240
|
354 SVDEBUG << "MainWindow: Creating OSC queue with network port"
|
Chris@2240
|
355 << endl;
|
Chris@2240
|
356 startOSCQueue(true);
|
Chris@2240
|
357 } else {
|
Chris@2240
|
358 SVDEBUG << "MainWindow: Creating internal-only OSC queue without port"
|
Chris@2240
|
359 << endl;
|
Chris@2240
|
360 startOSCQueue(false);
|
Chris@2240
|
361 }
|
Chris@2240
|
362
|
Chris@2401
|
363 // QTimer::singleShot(500, this, SLOT(betaReleaseWarning()));
|
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@2446
|
3026 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@2454
|
3027 if (suffix == "") suffix = "csv";
|
Chris@2446
|
3028
|
Chris@2449
|
3029 bool canWriteSelection =
|
Chris@2449
|
3030 ! (suffix == "xml" || suffix == "svl" ||
|
Chris@2449
|
3031 suffix == "n3" || suffix == "ttl");
|
Chris@2449
|
3032
|
Chris@2449
|
3033 bool useCSVDialog =
|
Chris@2449
|
3034 ! (suffix == "xml" || suffix == "svl" ||
|
Chris@2449
|
3035 suffix == "mid" || suffix == "midi" ||
|
Chris@2449
|
3036 suffix == "n3" || suffix == "ttl");
|
Chris@2455
|
3037
|
Chris@2455
|
3038 if (!ModelById::isa<NoteModel>(modelId) &&
|
Chris@2455
|
3039 (suffix == "mid" || suffix == "midi")) {
|
Chris@2455
|
3040 QMessageBox::critical
|
Chris@2455
|
3041 (this, tr("Failed to export layer"),
|
Chris@2455
|
3042 tr("Only note layers may be exported to MIDI files."));
|
Chris@2455
|
3043 return;
|
Chris@2455
|
3044 }
|
Chris@2455
|
3045
|
Chris@2455
|
3046 if (ModelById::isa<DenseTimeValueModel>(modelId) &&
|
Chris@2455
|
3047 !useCSVDialog) {
|
Chris@2455
|
3048 // This is the case for spectrograms
|
Chris@2455
|
3049 QMessageBox::critical
|
Chris@2455
|
3050 (this, tr("Failed to export layer"),
|
Chris@2455
|
3051 tr("Cannot export this layer to this file type. Only delimited column formats such as CSV are supported."));
|
Chris@2455
|
3052 return;
|
Chris@2455
|
3053 }
|
Chris@2446
|
3054
|
Chris@2442
|
3055 MultiSelection ms = m_viewManager->getSelection();
|
Chris@2449
|
3056 bool haveSelection = !ms.getSelections().empty();
|
Chris@2449
|
3057
|
Chris@2442
|
3058 MultiSelection *selectionToWrite = nullptr;
|
Chris@2449
|
3059 LayerGeometryProvider *provider = pane;
|
Chris@2449
|
3060
|
Chris@2449
|
3061 DataExportOptions options = DataExportDefaults;
|
Chris@2449
|
3062 QString delimiter = ",";
|
Chris@2449
|
3063
|
Chris@2449
|
3064 if (useCSVDialog) {
|
Chris@2449
|
3065
|
Chris@2449
|
3066 CSVExportDialog::Configuration config;
|
Chris@2449
|
3067 config.layerName = layer->getLayerPresentationName();
|
Chris@2449
|
3068 config.fileExtension = suffix;
|
Chris@2449
|
3069 config.isDense = false;
|
Chris@2449
|
3070 if (auto m = ModelById::get(modelId)) {
|
Chris@2449
|
3071 config.isDense = !m->isSparse();
|
Chris@2449
|
3072 }
|
Chris@2449
|
3073 config.haveView = true;
|
Chris@2449
|
3074 config.haveSelection = canWriteSelection && haveSelection;
|
Chris@2449
|
3075
|
Chris@2449
|
3076 CSVExportDialog dialog(config, this);
|
Chris@2449
|
3077 if (dialog.exec() != QDialog::Accepted) {
|
Chris@2449
|
3078 return;
|
Chris@2449
|
3079 }
|
Chris@2449
|
3080
|
Chris@2449
|
3081 if (dialog.shouldConstrainToSelection()) {
|
Chris@2449
|
3082 selectionToWrite = &ms;
|
Chris@2449
|
3083 }
|
Chris@2449
|
3084
|
Chris@2449
|
3085 if (!dialog.shouldConstrainToViewHeight()) {
|
Chris@2449
|
3086 provider = nullptr;
|
Chris@2449
|
3087 }
|
Chris@2449
|
3088
|
Chris@2449
|
3089 delimiter = dialog.getDelimiter();
|
Chris@2449
|
3090
|
Chris@2449
|
3091 if (dialog.shouldIncludeHeader()) {
|
Chris@2449
|
3092 options |= DataExportIncludeHeader;
|
Chris@2449
|
3093 }
|
Chris@2449
|
3094
|
Chris@2449
|
3095 if (dialog.shouldIncludeTimestamps()) {
|
Chris@2449
|
3096 options |= DataExportAlwaysIncludeTimestamp;
|
Chris@2449
|
3097 }
|
Chris@2449
|
3098
|
Chris@2449
|
3099 if (dialog.shouldWriteTimeInFrames()) {
|
Chris@2449
|
3100 options |= DataExportWriteTimeInFrames;
|
Chris@2449
|
3101 }
|
Chris@2449
|
3102
|
Chris@2449
|
3103 } else if (canWriteSelection && haveSelection) {
|
Chris@2442
|
3104
|
Chris@2442
|
3105 QStringList items;
|
Chris@2442
|
3106 items << tr("Export the content of the selected area")
|
Chris@2442
|
3107 << tr("Export the whole layer");
|
Chris@2442
|
3108
|
Chris@2442
|
3109 bool ok = false;
|
Chris@2442
|
3110 QString item = ListInputDialog::getItem
|
Chris@2442
|
3111 (this, tr("Select region to export"),
|
Chris@2442
|
3112 tr("Which region of the layer do you want to export?"),
|
Chris@2442
|
3113 items, 0, &ok);
|
Chris@2442
|
3114
|
Chris@2449
|
3115 if (!ok || item.isEmpty()) {
|
Chris@2449
|
3116 return;
|
Chris@2449
|
3117 }
|
Chris@2442
|
3118
|
Chris@2449
|
3119 if (item == items[0]) {
|
Chris@2449
|
3120 selectionToWrite = &ms;
|
Chris@2449
|
3121 }
|
Chris@2442
|
3122 }
|
Chris@2442
|
3123
|
Chris@0
|
3124 QString error;
|
Chris@0
|
3125
|
Chris@2449
|
3126 bool result = false;
|
Chris@2449
|
3127
|
Chris@2449
|
3128 if (suffix == "xml" || suffix == "svl") {
|
Chris@2449
|
3129 result = exportLayerToSVL(layer, path, error);
|
Chris@2449
|
3130 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@2449
|
3131 result = exportLayerToMIDI(layer, selectionToWrite, path, error);
|
Chris@2449
|
3132 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@2449
|
3133 result = exportLayerToRDF(layer, path, error);
|
Chris@2449
|
3134 } else {
|
Chris@2449
|
3135 result = exportLayerToCSV(layer, provider, selectionToWrite,
|
Chris@2449
|
3136 delimiter, options, path, error);
|
Chris@2449
|
3137 }
|
Chris@2449
|
3138
|
Chris@2449
|
3139 if (!result) {
|
Chris@0
|
3140 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
3141 } else {
|
Chris@34
|
3142 m_recentFiles.addFile(path);
|
Chris@310
|
3143 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@0
|
3144 }
|
Chris@0
|
3145 }
|
Chris@0
|
3146
|
Chris@121
|
3147 void
|
Chris@121
|
3148 MainWindow::exportImage()
|
Chris@121
|
3149 {
|
Chris@121
|
3150 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@121
|
3151 if (!pane) return;
|
Chris@121
|
3152
|
Chris@121
|
3153 QString path = getSaveFileName(FileFinder::ImageFile);
|
Chris@121
|
3154 if (path == "") return;
|
Chris@1460
|
3155 if (QFileInfo(path).suffix() == "") path += ".png";
|
Chris@1451
|
3156
|
Chris@123
|
3157 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@123
|
3158
|
Chris@123
|
3159 QSize total, visible, selected;
|
Chris@1451
|
3160 total = pane->getRenderedImageSize();
|
Chris@1451
|
3161 visible = pane->getRenderedPartImageSize(pane->getFirstVisibleFrame(),
|
Chris@1451
|
3162 pane->getLastVisibleFrame());
|
Chris@123
|
3163
|
Chris@922
|
3164 sv_frame_t sf0 = 0, sf1 = 0;
|
Chris@123
|
3165
|
Chris@123
|
3166 if (haveSelection) {
|
Chris@123
|
3167 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@123
|
3168 sf0 = selections.begin()->getStartFrame();
|
Chris@123
|
3169 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@123
|
3170 --e;
|
Chris@123
|
3171 sf1 = e->getEndFrame();
|
Chris@1451
|
3172 selected = pane->getRenderedPartImageSize(sf0, sf1);
|
Chris@123
|
3173 }
|
Chris@123
|
3174
|
Chris@123
|
3175 QStringList items;
|
Chris@125
|
3176 items << tr("Export the whole pane (%1x%2 pixels)")
|
Chris@123
|
3177 .arg(total.width()).arg(total.height());
|
Chris@123
|
3178 items << tr("Export the visible area only (%1x%2 pixels)")
|
Chris@123
|
3179 .arg(visible.width()).arg(visible.height());
|
Chris@123
|
3180 if (haveSelection) {
|
Chris@123
|
3181 items << tr("Export the selection extent (%1x%2 pixels)")
|
Chris@123
|
3182 .arg(selected.width()).arg(selected.height());
|
Chris@124
|
3183 } else {
|
Chris@124
|
3184 items << tr("Export the selection extent");
|
Chris@123
|
3185 }
|
Chris@123
|
3186
|
Chris@123
|
3187 QSettings settings;
|
Chris@123
|
3188 settings.beginGroup("MainWindow");
|
Chris@123
|
3189 int deflt = settings.value("lastimageexportregion", 0).toInt();
|
Chris@123
|
3190 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@1460
|
3191 if (deflt == 0 && total.width() > 32767) deflt = 1;
|
Chris@124
|
3192
|
Chris@124
|
3193 ListInputDialog *lid = new ListInputDialog
|
Chris@123
|
3194 (this, tr("Select region to export"),
|
Chris@123
|
3195 tr("Which region of the current pane do you want to export as an image?"),
|
Chris@124
|
3196 items, deflt);
|
Chris@124
|
3197
|
Chris@124
|
3198 if (!haveSelection) {
|
Chris@124
|
3199 lid->setItemAvailability(2, false);
|
Chris@124
|
3200 }
|
Chris@1460
|
3201 if (total.width() > 32767) { // appears to be limit of a QImage
|
Chris@124
|
3202 lid->setItemAvailability(0, false);
|
Chris@124
|
3203 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
|
Chris@124
|
3204 }
|
Chris@124
|
3205
|
Chris@124
|
3206 bool ok = lid->exec();
|
Chris@124
|
3207 QString item = lid->getCurrentString();
|
Chris@124
|
3208 delete lid;
|
Chris@1770
|
3209
|
Chris@123
|
3210 if (!ok || item.isEmpty()) return;
|
Chris@123
|
3211
|
Chris@123
|
3212 settings.setValue("lastimageexportregion", deflt);
|
Chris@123
|
3213
|
Chris@2126
|
3214 QImage *image = nullptr;
|
Chris@1451
|
3215
|
Chris@1460
|
3216 if (item == items[0]) {
|
Chris@1460
|
3217 image = pane->renderToNewImage();
|
Chris@1460
|
3218 } else if (item == items[1]) {
|
Chris@1460
|
3219 image = pane->renderPartToNewImage(pane->getFirstVisibleFrame(),
|
Chris@1460
|
3220 pane->getLastVisibleFrame());
|
Chris@1460
|
3221 } else if (haveSelection) {
|
Chris@1460
|
3222 image = pane->renderPartToNewImage(sf0, sf1);
|
Chris@1451
|
3223 }
|
Chris@1460
|
3224
|
Chris@1460
|
3225 if (!image) return;
|
Chris@1460
|
3226
|
Chris@1460
|
3227 if (!image->save(path, "PNG")) {
|
Chris@1460
|
3228 QMessageBox::critical(this, tr("Failed to save image file"),
|
Chris@1460
|
3229 tr("Failed to save image file %1").arg(path));
|
Chris@1460
|
3230 }
|
Chris@1460
|
3231
|
Chris@1460
|
3232 delete image;
|
Chris@1451
|
3233 }
|
Chris@1451
|
3234
|
Chris@1451
|
3235 void
|
Chris@1451
|
3236 MainWindow::exportSVG()
|
Chris@1451
|
3237 {
|
Chris@1451
|
3238 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@1451
|
3239 if (!pane) return;
|
Chris@1451
|
3240
|
Chris@1451
|
3241 QString path = getSaveFileName(FileFinder::SVGFile);
|
Chris@1451
|
3242 if (path == "") return;
|
Chris@1451
|
3243 if (QFileInfo(path).suffix() == "") path += ".svg";
|
Chris@1451
|
3244
|
Chris@1451
|
3245 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@1451
|
3246
|
Chris@1451
|
3247 sv_frame_t sf0 = 0, sf1 = 0;
|
Chris@1451
|
3248
|
Chris@1451
|
3249 if (haveSelection) {
|
Chris@1451
|
3250 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@1451
|
3251 sf0 = selections.begin()->getStartFrame();
|
Chris@1451
|
3252 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@1451
|
3253 --e;
|
Chris@1451
|
3254 sf1 = e->getEndFrame();
|
Chris@1451
|
3255 }
|
Chris@1451
|
3256
|
Chris@1451
|
3257 QStringList items;
|
Chris@1451
|
3258 items << tr("Export the whole pane");
|
Chris@1451
|
3259 items << tr("Export the visible area only");
|
Chris@1451
|
3260 items << tr("Export the selection extent");
|
Chris@1451
|
3261
|
Chris@1451
|
3262 QSettings settings;
|
Chris@1451
|
3263 settings.beginGroup("MainWindow");
|
Chris@1451
|
3264 int deflt = settings.value("lastsvgexportregion", 0).toInt();
|
Chris@1451
|
3265 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@1451
|
3266
|
Chris@1451
|
3267 ListInputDialog *lid = new ListInputDialog
|
Chris@1451
|
3268 (this, tr("Select region to export"),
|
Chris@1451
|
3269 tr("Which region of the current pane do you want to export as a scalable SVG image?"),
|
Chris@1451
|
3270 items, deflt);
|
Chris@1451
|
3271
|
Chris@1451
|
3272 if (!haveSelection) {
|
Chris@1451
|
3273 lid->setItemAvailability(2, false);
|
Chris@1451
|
3274 }
|
Chris@1451
|
3275
|
Chris@1451
|
3276 bool ok = lid->exec();
|
Chris@1451
|
3277 QString item = lid->getCurrentString();
|
Chris@1451
|
3278 delete lid;
|
Chris@1770
|
3279
|
Chris@1451
|
3280 if (!ok || item.isEmpty()) return;
|
Chris@1451
|
3281
|
Chris@1451
|
3282 settings.setValue("lastsvgexportregion", deflt);
|
Chris@1451
|
3283
|
Chris@1451
|
3284 bool result = false;
|
Chris@1451
|
3285
|
Chris@123
|
3286 if (item == items[0]) {
|
Chris@1451
|
3287 result = pane->renderToSvgFile(path );
|
Chris@123
|
3288 } else if (item == items[1]) {
|
Chris@1451
|
3289 result = pane->renderPartToSvgFile(path,
|
Chris@1451
|
3290 pane->getFirstVisibleFrame(),
|
Chris@1451
|
3291 pane->getLastVisibleFrame());
|
Chris@123
|
3292 } else if (haveSelection) {
|
Chris@1451
|
3293 result = pane->renderPartToSvgFile(path, sf0, sf1);
|
Chris@121
|
3294 }
|
Chris@121
|
3295
|
Chris@1451
|
3296 if (!result) {
|
Chris@1451
|
3297 QMessageBox::critical(this, tr("Failed to save SVG file"),
|
Chris@1451
|
3298 tr("Failed to save SVG file %1").arg(path));
|
Chris@1451
|
3299 }
|
Chris@121
|
3300 }
|
Chris@121
|
3301
|
Chris@0
|
3302 void
|
Chris@1056
|
3303 MainWindow::browseRecordedAudio()
|
Chris@1056
|
3304 {
|
Chris@1995
|
3305 QString path = RecordDirectory::getRecordContainerDirectory();
|
Chris@1995
|
3306 if (path == "") path = RecordDirectory::getRecordDirectory();
|
Chris@1056
|
3307 if (path == "") return;
|
Chris@1056
|
3308
|
Chris@1056
|
3309 openLocalFolder(path);
|
Chris@1056
|
3310 }
|
Chris@1056
|
3311
|
Chris@1056
|
3312 void
|
Chris@0
|
3313 MainWindow::newSession()
|
Chris@0
|
3314 {
|
Chris@0
|
3315 if (!checkSaveModified()) return;
|
Chris@0
|
3316
|
Chris@0
|
3317 closeSession();
|
Chris@2062
|
3318 stop();
|
Chris@0
|
3319 createDocument();
|
Chris@0
|
3320
|
Chris@0
|
3321 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
3322
|
Chris@90
|
3323 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
3324 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@90
|
3325
|
Chris@0
|
3326 if (!m_timeRulerLayer) {
|
Chris@1770
|
3327 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@1770
|
3328 (LayerFactory::TimeRuler);
|
Chris@0
|
3329 }
|
Chris@0
|
3330
|
Chris@0
|
3331 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
3332
|
Chris@0
|
3333 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
3334 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
3335
|
Chris@65
|
3336 m_overview->registerView(pane);
|
Chris@0
|
3337
|
Chris@0
|
3338 CommandHistory::getInstance()->clear();
|
Chris@0
|
3339 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
3340 documentRestored();
|
Chris@0
|
3341 updateMenuStates();
|
Chris@0
|
3342 }
|
Chris@0
|
3343
|
Chris@0
|
3344 void
|
Chris@303
|
3345 MainWindow::documentReplaced()
|
Chris@303
|
3346 {
|
Chris@303
|
3347 if (m_document) {
|
Chris@303
|
3348 connect(m_document, SIGNAL(activity(QString)),
|
Chris@303
|
3349 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
3350 }
|
Chris@303
|
3351 }
|
Chris@303
|
3352
|
Chris@303
|
3353 void
|
Chris@0
|
3354 MainWindow::closeSession()
|
Chris@0
|
3355 {
|
Chris@0
|
3356 if (!checkSaveModified()) return;
|
Chris@0
|
3357
|
Chris@0
|
3358 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
3359
|
Chris@1770
|
3360 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@1770
|
3361
|
Chris@1770
|
3362 while (pane->getLayerCount() > 0) {
|
Chris@1770
|
3363 m_document->removeLayerFromView
|
Chris@1770
|
3364 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@1770
|
3365 }
|
Chris@1770
|
3366
|
Chris@1770
|
3367 m_overview->unregisterView(pane);
|
Chris@1770
|
3368 m_paneStack->deletePane(pane);
|
Chris@0
|
3369 }
|
Chris@0
|
3370
|
Chris@0
|
3371 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
3372
|
Chris@1770
|
3373 Pane *pane = m_paneStack->getHiddenPane
|
Chris@1770
|
3374 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@1770
|
3375
|
Chris@1770
|
3376 while (pane->getLayerCount() > 0) {
|
Chris@1770
|
3377 m_document->removeLayerFromView
|
Chris@1770
|
3378 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@1770
|
3379 }
|
Chris@1770
|
3380
|
Chris@1770
|
3381 m_overview->unregisterView(pane);
|
Chris@1770
|
3382 m_paneStack->deletePane(pane);
|
Chris@0
|
3383 }
|
Chris@0
|
3384
|
Chris@504
|
3385 delete m_layerTreeDialog.data();
|
Chris@504
|
3386 delete m_preferencesDialog.data();
|
Chris@504
|
3387
|
Chris@504
|
3388 m_activityLog->hide();
|
Chris@891
|
3389 m_unitConverter->hide();
|
Chris@504
|
3390 m_keyReference->hide();
|
Chris@504
|
3391
|
Chris@0
|
3392 delete m_document;
|
Chris@2126
|
3393 m_document = nullptr;
|
Chris@0
|
3394 m_viewManager->clearSelections();
|
Chris@2126
|
3395 m_timeRulerLayer = nullptr; // document owned this
|
Chris@0
|
3396
|
Chris@0
|
3397 m_sessionFile = "";
|
Chris@2350
|
3398 m_originalLocation = "";
|
Chris@518
|
3399 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
3400
|
Chris@0
|
3401 CommandHistory::getInstance()->clear();
|
Chris@0
|
3402 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
3403 documentRestored();
|
Chris@0
|
3404 }
|
Chris@0
|
3405
|
Chris@0
|
3406 void
|
Chris@0
|
3407 MainWindow::openSomething()
|
Chris@0
|
3408 {
|
Chris@0
|
3409 QString orig = m_audioFile;
|
Chris@0
|
3410 if (orig == "") orig = ".";
|
Chris@0
|
3411 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
3412
|
Chris@88
|
3413 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
3414
|
Chris@0
|
3415 if (path.isEmpty()) return;
|
Chris@0
|
3416
|
Chris@844
|
3417 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@193
|
3418
|
Chris@193
|
3419 if (status == FileOpenFailed) {
|
Chris@247
|
3420 emit hideSplash();
|
Chris@193
|
3421 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
3422 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@193
|
3423 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3424 emit hideSplash();
|
Chris@193
|
3425 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
3426 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
|
3427 }
|
Chris@0
|
3428 }
|
Chris@0
|
3429
|
Chris@0
|
3430 void
|
Chris@86
|
3431 MainWindow::openLocation()
|
Chris@86
|
3432 {
|
Chris@103
|
3433 QSettings settings;
|
Chris@103
|
3434 settings.beginGroup("MainWindow");
|
Chris@103
|
3435 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
3436
|
Chris@86
|
3437 bool ok = false;
|
Chris@86
|
3438 QString text = QInputDialog::getText
|
Chris@86
|
3439 (this, tr("Open Location"),
|
Chris@86
|
3440 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
3441 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
3442
|
Chris@103
|
3443 if (!ok) return;
|
Chris@103
|
3444
|
Chris@103
|
3445 settings.setValue("lastremote", text);
|
Chris@103
|
3446
|
Chris@103
|
3447 if (text.isEmpty()) return;
|
Chris@86
|
3448
|
Chris@844
|
3449 FileOpenStatus status = openPath(text, AskUser);
|
Chris@193
|
3450
|
Chris@193
|
3451 if (status == FileOpenFailed) {
|
Chris@247
|
3452 emit hideSplash();
|
Chris@86
|
3453 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
3454 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@193
|
3455 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3456 emit hideSplash();
|
Chris@193
|
3457 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
3458 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
|
3459 }
|
Chris@86
|
3460 }
|
Chris@86
|
3461
|
Chris@86
|
3462 void
|
Chris@2149
|
3463 MainWindow::openRecentFile()
|
Chris@0
|
3464 {
|
Chris@0
|
3465 QObject *obj = sender();
|
Chris@0
|
3466 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
3467
|
Chris@0
|
3468 if (!action) {
|
Chris@1770
|
3469 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@2149
|
3470 << endl;
|
Chris@1770
|
3471 return;
|
Chris@0
|
3472 }
|
Chris@0
|
3473
|
Chris@2149
|
3474 QString path = action->objectName();
|
Chris@2149
|
3475
|
Chris@2149
|
3476 if (path == "") {
|
Chris@2149
|
3477 cerr << "WARNING: MainWindow::openRecentFile: action incorrectly named"
|
Chris@2149
|
3478 << endl;
|
Chris@2149
|
3479 return;
|
Chris@2149
|
3480 }
|
Chris@0
|
3481
|
Chris@844
|
3482 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@193
|
3483
|
Chris@193
|
3484 if (status == FileOpenFailed) {
|
Chris@247
|
3485 emit hideSplash();
|
Chris@193
|
3486 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
3487 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@193
|
3488 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3489 emit hideSplash();
|
Chris@193
|
3490 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
3491 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
|
3492 }
|
Chris@0
|
3493 }
|
Chris@0
|
3494
|
Chris@0
|
3495 void
|
Chris@435
|
3496 MainWindow::applyTemplate()
|
Chris@435
|
3497 {
|
Chris@435
|
3498 QObject *s = sender();
|
Chris@435
|
3499 QAction *action = qobject_cast<QAction *>(s);
|
Chris@435
|
3500
|
Chris@435
|
3501 if (!action) {
|
Chris@1770
|
3502 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action"
|
Chris@1770
|
3503 << endl;
|
Chris@1770
|
3504 return;
|
Chris@435
|
3505 }
|
Chris@435
|
3506
|
Chris@435
|
3507 QString n = action->objectName();
|
Chris@435
|
3508 if (n == "") n = action->text();
|
Chris@435
|
3509
|
Chris@435
|
3510 if (n == "") {
|
Chris@665
|
3511 cerr << "WARNING: MainWindow::applyTemplate: sender has no name"
|
Chris@665
|
3512 << endl;
|
Chris@435
|
3513 return;
|
Chris@435
|
3514 }
|
Chris@435
|
3515
|
Chris@435
|
3516 QString mainModelLocation;
|
Chris@2300
|
3517 auto mm = getMainModel();
|
Chris@435
|
3518 if (mm) mainModelLocation = mm->getLocation();
|
Chris@435
|
3519 if (mainModelLocation != "") {
|
Chris@435
|
3520 openAudio(mainModelLocation, ReplaceSession, n);
|
Chris@435
|
3521 } else {
|
Chris@435
|
3522 openSessionTemplate(n);
|
Chris@435
|
3523 }
|
Chris@435
|
3524 }
|
Chris@435
|
3525
|
Chris@435
|
3526 void
|
Chris@425
|
3527 MainWindow::saveSessionAsTemplate()
|
Chris@425
|
3528 {
|
Chris@762
|
3529 QDialog *d = new QDialog(this);
|
Chris@483
|
3530 d->setWindowTitle(tr("Enter template name"));
|
Chris@483
|
3531
|
Chris@483
|
3532 QGridLayout *layout = new QGridLayout;
|
Chris@483
|
3533 d->setLayout(layout);
|
Chris@483
|
3534
|
Chris@483
|
3535 layout->addWidget(new QLabel(tr("Please enter a name for the saved template:")),
|
Chris@483
|
3536 0, 0);
|
Chris@483
|
3537 QLineEdit *lineEdit = new QLineEdit;
|
Chris@483
|
3538 layout->addWidget(lineEdit, 1, 0);
|
Chris@483
|
3539 QCheckBox *makeDefault = new QCheckBox(tr("Set as default template for future audio files"));
|
Chris@483
|
3540 layout->addWidget(makeDefault, 2, 0);
|
Chris@425
|
3541
|
Chris@483
|
3542 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
|
Chris@483
|
3543 QDialogButtonBox::Cancel);
|
Chris@483
|
3544 layout->addWidget(bb, 3, 0);
|
Chris@483
|
3545 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@483
|
3546 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@483
|
3547 connect(bb, SIGNAL(rejected()), d, SLOT(reject()));
|
Chris@483
|
3548
|
Chris@483
|
3549 if (d->exec() == QDialog::Accepted) {
|
Chris@483
|
3550
|
Chris@483
|
3551 QString name = lineEdit->text();
|
Chris@483
|
3552 name.replace(QRegExp("[^\\w\\s\\.\"'-]"), "_");
|
Chris@483
|
3553
|
Chris@483
|
3554 ResourceFinder rf;
|
Chris@483
|
3555 QString dir = rf.getResourceSaveDir("templates");
|
Chris@483
|
3556 QString filename = QString("%1/%2.svt").arg(dir).arg(name);
|
Chris@483
|
3557 if (QFile(filename).exists()) {
|
Chris@483
|
3558 if (QMessageBox::warning(this,
|
Chris@483
|
3559 tr("Template file exists"),
|
Chris@483
|
3560 tr("<b>Template file exists</b><p>The template \"%1\" already exists.<br>Overwrite it?").arg(name),
|
Chris@483
|
3561 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@483
|
3562 QMessageBox::Cancel) != QMessageBox::Ok) {
|
Chris@1516
|
3563 delete d;
|
Chris@483
|
3564 return;
|
Chris@483
|
3565 }
|
Chris@483
|
3566 }
|
Chris@483
|
3567
|
Chris@483
|
3568 if (saveSessionTemplate(filename)) {
|
Chris@483
|
3569 if (makeDefault->isChecked()) {
|
Chris@483
|
3570 setDefaultSessionTemplate(name);
|
Chris@483
|
3571 }
|
Chris@431
|
3572 }
|
Chris@431
|
3573 }
|
Chris@1516
|
3574
|
Chris@1516
|
3575 delete d;
|
Chris@425
|
3576 }
|
Chris@425
|
3577
|
Chris@425
|
3578 void
|
Chris@425
|
3579 MainWindow::manageSavedTemplates()
|
Chris@425
|
3580 {
|
Chris@425
|
3581 ResourceFinder rf;
|
Chris@1930
|
3582 openLocalFolder(rf.getResourceSaveDir("templates"));
|
Chris@423
|
3583 }
|
Chris@423
|
3584
|
Chris@423
|
3585 void
|
Chris@200
|
3586 MainWindow::paneAdded(Pane *pane)
|
Chris@200
|
3587 {
|
Chris@200
|
3588 if (m_overview) m_overview->registerView(pane);
|
Chris@2303
|
3589 if (pane) {
|
Chris@2303
|
3590 connect(pane, SIGNAL(cancelButtonPressed(Layer *)),
|
Chris@2303
|
3591 this, SLOT(paneCancelButtonPressed(Layer *)));
|
Chris@2303
|
3592 }
|
Chris@200
|
3593 }
|
Chris@200
|
3594
|
Chris@200
|
3595 void
|
Chris@200
|
3596 MainWindow::paneHidden(Pane *pane)
|
Chris@200
|
3597 {
|
Chris@200
|
3598 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
3599 }
|
Chris@200
|
3600
|
Chris@200
|
3601 void
|
Chris@200
|
3602 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@200
|
3603 {
|
Chris@200
|
3604 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
3605 }
|
Chris@200
|
3606
|
Chris@200
|
3607 void
|
Chris@2303
|
3608 MainWindow::paneCancelButtonPressed(Layer *layer)
|
Chris@2303
|
3609 {
|
Chris@2303
|
3610 Pane *pane = qobject_cast<Pane *>(sender());
|
Chris@2303
|
3611 bool found = false;
|
Chris@2303
|
3612 if (pane && layer) {
|
Chris@2303
|
3613 for (int i = 0; i < pane->getLayerCount(); ++i) {
|
Chris@2303
|
3614 if (pane->getLayer(i) == layer) {
|
Chris@2303
|
3615 found = true;
|
Chris@2303
|
3616 break;
|
Chris@2303
|
3617 }
|
Chris@2303
|
3618 }
|
Chris@2303
|
3619 }
|
Chris@2303
|
3620 if (!found) {
|
Chris@2303
|
3621 SVDEBUG << "MainWindow::paneCancelButtonPressed: Unknown layer in pane"
|
Chris@2303
|
3622 << endl;
|
Chris@2303
|
3623 return;
|
Chris@2303
|
3624 }
|
Chris@2303
|
3625
|
Chris@2303
|
3626 SVDEBUG << "MainWindow::paneCancelButtonPressed: Layer " << layer << endl;
|
Chris@2303
|
3627
|
Chris@2304
|
3628 // We need to ensure that the transform that is populating this
|
Chris@2304
|
3629 // layer's model is stopped - that is the main reason to use
|
Chris@2304
|
3630 // Cancel after all. It would also be a good idea to remove the
|
Chris@2304
|
3631 // incomplete layer from both the view and the undo/redo stack.
|
Chris@2304
|
3632
|
Chris@2304
|
3633 // Deleting the target model will ensure that the transform gets
|
Chris@2304
|
3634 // stopped, but removing the layer from the view is not enough to
|
Chris@2304
|
3635 // delete the model, because a reference to the layer remains on
|
Chris@2304
|
3636 // the undo/redo stack. If we also replace the model id with None
|
Chris@2304
|
3637 // in the layer, that does the trick.
|
Chris@2304
|
3638
|
Chris@2304
|
3639 m_document->setModel(layer, {});
|
Chris@2303
|
3640 m_document->removeLayerFromView(pane, layer);
|
Chris@2304
|
3641
|
Chris@2304
|
3642 // We still have a layer with no model on the undo/redo stack,
|
Chris@2304
|
3643 // which is a pity. I'm not sure we can easily remove it, since
|
Chris@2304
|
3644 // other commands may have been pushed on the stack since, so
|
Chris@2304
|
3645 // let's just leave that for now.
|
Chris@2304
|
3646
|
Chris@2303
|
3647 updateMenuStates();
|
Chris@2303
|
3648 }
|
Chris@2303
|
3649
|
Chris@2303
|
3650 void
|
Chris@193
|
3651 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@193
|
3652 {
|
Chris@193
|
3653 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
3654
|
Chris@193
|
3655 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@193
|
3656
|
Chris@295
|
3657 FileOpenStatus status;
|
Chris@295
|
3658
|
Chris@295
|
3659 if (i == uriList.begin()) {
|
Chris@844
|
3660 status = openPath(*i, ReplaceCurrentPane);
|
Chris@295
|
3661 } else {
|
Chris@844
|
3662 status = openPath(*i, CreateAdditionalModel);
|
Chris@295
|
3663 }
|
Chris@193
|
3664
|
Chris@193
|
3665 if (status == FileOpenFailed) {
|
Chris@247
|
3666 emit hideSplash();
|
Chris@193
|
3667 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
3668 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@295
|
3669 break;
|
Chris@193
|
3670 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
3671 emit hideSplash();
|
Chris@193
|
3672 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@294
|
3673 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
|
3674 break;
|
Chris@295
|
3675 } else if (status == FileOpenCancelled) {
|
Chris@295
|
3676 break;
|
Chris@193
|
3677 }
|
Chris@193
|
3678 }
|
Chris@193
|
3679 }
|
Chris@193
|
3680
|
Chris@193
|
3681 void
|
Chris@193
|
3682 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@193
|
3683 {
|
Chris@193
|
3684 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
3685
|
Chris@193
|
3686 QUrl testUrl(text);
|
Chris@193
|
3687 if (testUrl.scheme() == "file" ||
|
Chris@193
|
3688 testUrl.scheme() == "http" ||
|
Chris@193
|
3689 testUrl.scheme() == "ftp") {
|
Chris@193
|
3690 QStringList list;
|
Chris@193
|
3691 list.push_back(text);
|
Chris@193
|
3692 paneDropAccepted(pane, list);
|
Chris@193
|
3693 return;
|
Chris@193
|
3694 }
|
Chris@193
|
3695
|
Chris@193
|
3696 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@193
|
3697 //to a text layer?
|
Chris@193
|
3698 }
|
Chris@193
|
3699
|
Chris@193
|
3700 void
|
Chris@0
|
3701 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
3702 {
|
Chris@2027
|
3703 SVDEBUG << "MainWindow::closeEvent" << endl;
|
Chris@118
|
3704
|
Chris@136
|
3705 if (m_openingAudioFile) {
|
Chris@2027
|
3706 SVCERR << "Busy - ignoring close event" << endl;
|
Chris@1770
|
3707 e->ignore();
|
Chris@1770
|
3708 return;
|
Chris@136
|
3709 }
|
Chris@136
|
3710
|
Chris@2440
|
3711 if (!checkSaveModified()) {
|
Chris@2027
|
3712 SVCERR << "Close refused by user - ignoring close event" << endl;
|
Chris@1770
|
3713 e->ignore();
|
Chris@1770
|
3714 return;
|
Chris@0
|
3715 }
|
Chris@0
|
3716
|
Chris@5
|
3717 QSettings settings;
|
Chris@5
|
3718 settings.beginGroup("MainWindow");
|
Chris@624
|
3719 settings.setValue("maximised", isMaximized());
|
Chris@624
|
3720 if (!isMaximized()) {
|
Chris@624
|
3721 settings.setValue("size", size());
|
Chris@624
|
3722 settings.setValue("position", pos());
|
Chris@624
|
3723 }
|
Chris@5
|
3724 settings.endGroup();
|
Chris@5
|
3725
|
Chris@163
|
3726 if (m_preferencesDialog &&
|
Chris@163
|
3727 m_preferencesDialog->isVisible()) {
|
Chris@1434
|
3728 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
3729 }
|
Chris@163
|
3730
|
Chris@2172
|
3731 stop();
|
Chris@200
|
3732 closeSession();
|
Chris@200
|
3733
|
Chris@0
|
3734 e->accept();
|
Chris@489
|
3735
|
Chris@0
|
3736 return;
|
Chris@0
|
3737 }
|
Chris@0
|
3738
|
Chris@0
|
3739 bool
|
Chris@11
|
3740 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
3741 {
|
Chris@11
|
3742 if (mayAskUser) {
|
Chris@163
|
3743 bool rv = checkSaveModified();
|
Chris@163
|
3744 if (rv) {
|
Chris@163
|
3745 if (m_preferencesDialog &&
|
Chris@163
|
3746 m_preferencesDialog->isVisible()) {
|
Chris@163
|
3747 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
3748 }
|
Chris@163
|
3749 }
|
Chris@163
|
3750 return rv;
|
Chris@11
|
3751 } else {
|
Chris@163
|
3752 if (m_preferencesDialog &&
|
Chris@163
|
3753 m_preferencesDialog->isVisible()) {
|
Chris@163
|
3754 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
3755 }
|
Chris@11
|
3756 if (!m_documentModified) return true;
|
Chris@11
|
3757
|
Chris@11
|
3758 // If we can't check with the user first, then we can't save
|
Chris@11
|
3759 // to the original session file (even if we have it) -- have
|
Chris@11
|
3760 // to use a temporary file
|
Chris@11
|
3761
|
Chris@11
|
3762 QString svDirBase = ".sv1";
|
Chris@11
|
3763 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
3764
|
Chris@11
|
3765 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
3766 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
3767 } else {
|
Chris@11
|
3768 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
3769 }
|
Chris@11
|
3770
|
Chris@11
|
3771 // This name doesn't have to be unguessable
|
Chris@93
|
3772 #ifndef _WIN32
|
Chris@11
|
3773 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
3774 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
3775 .arg(QProcess().pid());
|
Chris@93
|
3776 #else
|
Chris@93
|
3777 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
3778 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
3779 #endif
|
Chris@11
|
3780 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
3781 if (saveSessionFile(fpath)) {
|
Chris@34
|
3782 m_recentFiles.addFile(fpath);
|
Chris@310
|
3783 emit activity(tr("Export image to \"%1\"").arg(fpath));
|
Chris@11
|
3784 return true;
|
Chris@11
|
3785 } else {
|
Chris@11
|
3786 return false;
|
Chris@11
|
3787 }
|
Chris@11
|
3788 }
|
Chris@11
|
3789 }
|
Chris@11
|
3790
|
Chris@11
|
3791 bool
|
Chris@0
|
3792 MainWindow::checkSaveModified()
|
Chris@0
|
3793 {
|
Chris@0
|
3794 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
3795 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
3796 // cancel.
|
Chris@0
|
3797
|
Chris@0
|
3798 if (!m_documentModified) return true;
|
Chris@0
|
3799
|
Chris@247
|
3800 emit hideSplash();
|
Chris@247
|
3801
|
Chris@0
|
3802 int button =
|
Chris@1770
|
3803 QMessageBox::warning(this,
|
Chris@1770
|
3804 tr("Session modified"),
|
Chris@1770
|
3805 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
|
Chris@1770
|
3806 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@165
|
3807 QMessageBox::Yes);
|
Chris@0
|
3808
|
Chris@0
|
3809 if (button == QMessageBox::Yes) {
|
Chris@1770
|
3810 saveSession();
|
Chris@1770
|
3811 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@1770
|
3812 return false;
|
Chris@1770
|
3813 } else {
|
Chris@0
|
3814 return true; // saved, so it's safe to continue now
|
Chris@0
|
3815 }
|
Chris@0
|
3816 } else if (button == QMessageBox::No) {
|
Chris@1770
|
3817 m_documentModified = false; // so we know to abandon it
|
Chris@1770
|
3818 return true;
|
Chris@0
|
3819 }
|
Chris@0
|
3820
|
Chris@0
|
3821 // else cancel
|
Chris@0
|
3822 return false;
|
Chris@0
|
3823 }
|
Chris@0
|
3824
|
Chris@290
|
3825 bool
|
Chris@294
|
3826 MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
|
Chris@290
|
3827 {
|
Chris@294
|
3828 //!!! This is very similar to part of MainWindowBase::openAudio --
|
Chris@294
|
3829 //!!! make them a bit more uniform
|
Chris@294
|
3830
|
Chris@294
|
3831 QSettings settings;
|
Chris@294
|
3832 settings.beginGroup("MainWindow");
|
Chris@294
|
3833 bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
|
Chris@294
|
3834 settings.endGroup();
|
Chris@294
|
3835 bool newSession = true;
|
Chris@294
|
3836
|
Chris@294
|
3837 QStringList items;
|
Chris@294
|
3838 items << tr("Close the current session and create a new one")
|
Chris@294
|
3839 << tr("Add this data to the current session");
|
Chris@294
|
3840
|
Chris@294
|
3841 bool ok = false;
|
Chris@294
|
3842 QString item = ListInputDialog::getItem
|
Chris@294
|
3843 (this, tr("Select target for import"),
|
Chris@294
|
3844 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
|
3845 items, prevNewSession ? 0 : 1, &ok);
|
Chris@294
|
3846
|
Chris@294
|
3847 if (!ok || item.isEmpty()) {
|
Chris@294
|
3848 *cancel = true;
|
Chris@290
|
3849 return false;
|
Chris@290
|
3850 }
|
Chris@294
|
3851
|
Chris@294
|
3852 newSession = (item == items[0]);
|
Chris@294
|
3853 settings.beginGroup("MainWindow");
|
Chris@294
|
3854 settings.setValue("newsessionforrdfaudio", newSession);
|
Chris@294
|
3855 settings.endGroup();
|
Chris@294
|
3856
|
Chris@294
|
3857 if (newSession) return true;
|
Chris@294
|
3858 else return false;
|
Chris@290
|
3859 }
|
Chris@290
|
3860
|
Chris@0
|
3861 void
|
Chris@0
|
3862 MainWindow::saveSession()
|
Chris@0
|
3863 {
|
Chris@0
|
3864 if (m_sessionFile != "") {
|
Chris@1770
|
3865 if (!saveSessionFile(m_sessionFile)) {
|
Chris@1770
|
3866 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@1770
|
3867 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@1770
|
3868 } else {
|
Chris@1770
|
3869 CommandHistory::getInstance()->documentSaved();
|
Chris@1770
|
3870 documentRestored();
|
Chris@1770
|
3871 }
|
Chris@0
|
3872 } else {
|
Chris@1770
|
3873 saveSessionAs();
|
Chris@0
|
3874 }
|
Chris@0
|
3875 }
|
Chris@0
|
3876
|
Chris@0
|
3877 void
|
Chris@0
|
3878 MainWindow::saveSessionAs()
|
Chris@0
|
3879 {
|
Chris@0
|
3880 QString orig = m_audioFile;
|
Chris@0
|
3881 if (orig == "") orig = ".";
|
Chris@0
|
3882 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
3883
|
Chris@88
|
3884 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
3885
|
Chris@81
|
3886 if (path == "") return;
|
Chris@0
|
3887
|
Chris@0
|
3888 if (!saveSessionFile(path)) {
|
Chris@1770
|
3889 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@1770
|
3890 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
3891 } else {
|
Chris@1770
|
3892 setWindowTitle(tr("%1: %2")
|
Chris@518
|
3893 .arg(QApplication::applicationName())
|
Chris@1770
|
3894 .arg(QFileInfo(path).fileName()));
|
Chris@1770
|
3895 m_sessionFile = path;
|
Chris@1770
|
3896 CommandHistory::getInstance()->documentSaved();
|
Chris@1770
|
3897 documentRestored();
|
Chris@34
|
3898 m_recentFiles.addFile(path);
|
Chris@310
|
3899 emit activity(tr("Save session as \"%1\"").arg(path));
|
Chris@0
|
3900 }
|
Chris@0
|
3901 }
|
Chris@0
|
3902
|
Chris@90
|
3903 void
|
Chris@72
|
3904 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
3905 {
|
Chris@200
|
3906 MainWindowBase::preferenceChanged(name);
|
Chris@200
|
3907
|
Chris@1448
|
3908 if (name == "Background Mode") {
|
Chris@1448
|
3909 coloursChanged();
|
Chris@200
|
3910 }
|
Chris@0
|
3911 }
|
Chris@0
|
3912
|
Chris@0
|
3913 void
|
Chris@1448
|
3914 MainWindow::coloursChanged()
|
Chris@1448
|
3915 {
|
Chris@1448
|
3916 QSettings settings;
|
Chris@1448
|
3917 settings.beginGroup("Preferences");
|
Chris@2466
|
3918
|
Chris@2466
|
3919 bool haveDarkBackground = (m_viewManager &&
|
Chris@2466
|
3920 m_viewManager->getGlobalDarkBackground());
|
Chris@2466
|
3921 QColor highlight = QApplication::palette().color(QPalette::Highlight);
|
Chris@1448
|
3922 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@2466
|
3923 int nearestIndex = cdb->getNearbyColourIndex
|
Chris@2466
|
3924 (highlight,
|
Chris@2466
|
3925 haveDarkBackground ?
|
Chris@2466
|
3926 ColourDatabase::WithDarkBackground :
|
Chris@2466
|
3927 ColourDatabase::WithLightBackground);
|
Chris@2466
|
3928 QString defaultColourName = cdb->getColourName(nearestIndex);
|
Chris@2466
|
3929
|
cannam@1463
|
3930 QColor colour = QColor
|
cannam@1463
|
3931 (settings.value("overview-colour",
|
cannam@1463
|
3932 cdb->getColour(defaultColourName).name()).toString());
|
Chris@1448
|
3933 settings.endGroup();
|
Chris@1448
|
3934
|
Chris@1448
|
3935 int index = cdb->getColourIndex(colour);
|
Chris@2466
|
3936
|
Chris@2466
|
3937 SVCERR << "MainWindow::coloursChanged: haveDarkBackground = " << haveDarkBackground << ", highlight = " << highlight.name() << ", nearestIndex = " << nearestIndex << ", defaultColourName = " << defaultColourName << ", colour = " << colour.name() << ", index = " << index << endl;
|
Chris@2466
|
3938
|
Chris@1448
|
3939 if (index >= 0) {
|
Chris@1448
|
3940 m_panLayer->setBaseColour(index);
|
Chris@1448
|
3941 }
|
Chris@1448
|
3942 }
|
Chris@1448
|
3943
|
Chris@1448
|
3944 void
|
Chris@239
|
3945 MainWindow::propertyStacksResized(int width)
|
Chris@239
|
3946 {
|
Chris@438
|
3947 // SVDEBUG << "MainWindow::propertyStacksResized(" << width << ")" << endl;
|
Chris@239
|
3948
|
Chris@239
|
3949 if (!m_playControlsSpacer) return;
|
Chris@239
|
3950
|
Chris@239
|
3951 int spacerWidth = width - m_playControlsWidth - 4;
|
Chris@239
|
3952
|
Chris@438
|
3953 // SVDEBUG << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << endl;
|
Chris@239
|
3954
|
Chris@239
|
3955 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
|
Chris@239
|
3956 }
|
Chris@239
|
3957
|
Chris@239
|
3958 void
|
Chris@0
|
3959 MainWindow::addPane()
|
Chris@0
|
3960 {
|
Chris@0
|
3961 QObject *s = sender();
|
Chris@0
|
3962 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@753
|
3963
|
Chris@753
|
3964 cerr << "addPane: sender is " << s << ", action is " << action << ", name " << action->text() << endl;
|
Chris@0
|
3965
|
Chris@0
|
3966 if (!action) {
|
Chris@1770
|
3967 cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@1770
|
3968 << endl;
|
Chris@1770
|
3969 return;
|
Chris@0
|
3970 }
|
Chris@0
|
3971
|
Chris@2093
|
3972 PaneActions::iterator i = m_paneActions.begin();
|
Chris@2093
|
3973 while (i != m_paneActions.end()) {
|
Chris@2093
|
3974 if (i->first == action) break;
|
Chris@2093
|
3975 ++i;
|
Chris@2093
|
3976 }
|
Chris@0
|
3977
|
Chris@0
|
3978 if (i == m_paneActions.end()) {
|
Chris@1770
|
3979 cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@2093
|
3980 << action->objectName() << endl;
|
Chris@753
|
3981 cerr << "known actions are:" << endl;
|
Chris@2093
|
3982 for (PaneActions::const_iterator i = m_paneActions.begin();
|
Chris@753
|
3983 i != m_paneActions.end(); ++i) {
|
Chris@753
|
3984 cerr << i->first << ", name " << i->first->text() << endl;
|
Chris@753
|
3985 }
|
Chris@1770
|
3986 return;
|
Chris@0
|
3987 }
|
Chris@0
|
3988
|
Chris@69
|
3989 addPane(i->second, action->text());
|
Chris@69
|
3990 }
|
Chris@69
|
3991
|
Chris@69
|
3992 void
|
Chris@232
|
3993 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
|
Chris@69
|
3994 {
|
Chris@69
|
3995 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
3996
|
Chris@0
|
3997 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
3998 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
3999
|
Chris@0
|
4000 Pane *pane = command->getPane();
|
Chris@0
|
4001
|
Chris@69
|
4002 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
4003 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
4004 pane->setFollowGlobalZoom(false);
|
Chris@2011
|
4005 pane->setZoomLevel(ZoomLevel(ZoomLevel::FramesPerPixel, 512));
|
Chris@7
|
4006 }
|
Chris@7
|
4007
|
Chris@69
|
4008 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
4009 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
4010
|
Chris@1770
|
4011 if (!m_timeRulerLayer) {
|
Chris@1770
|
4012 // cerr << "no time ruler layer, creating one" << endl;
|
Chris@1770
|
4013 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@1770
|
4014 (LayerFactory::TimeRuler);
|
Chris@1770
|
4015 }
|
Chris@1770
|
4016
|
Chris@1770
|
4017 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl;
|
Chris@1770
|
4018
|
Chris@1770
|
4019 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
4020 }
|
Chris@0
|
4021
|
Chris@69
|
4022 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
4023
|
Chris@2300
|
4024 ModelId suggestedModelId = configuration.sourceModel;
|
Chris@2300
|
4025 ModelId modelId;
|
Chris@2300
|
4026
|
Chris@2300
|
4027 if (!suggestedModelId.isNone()) {
|
Chris@66
|
4028
|
Chris@66
|
4029 // check its validity
|
Chris@2300
|
4030 std::vector<ModelId> inputModels = m_document->getTransformInputModels();
|
Chris@2300
|
4031 for (auto im: inputModels) {
|
Chris@2300
|
4032 if (im == suggestedModelId) {
|
Chris@2300
|
4033 modelId = suggestedModelId;
|
Chris@66
|
4034 }
|
Chris@66
|
4035 }
|
Chris@66
|
4036
|
Chris@2300
|
4037 if (modelId.isNone()) {
|
Chris@2300
|
4038 cerr << "WARNING: Model " << modelId
|
Chris@2300
|
4039 << " appears in pane action map, but is not reported "
|
Chris@2300
|
4040 << "by document as a valid transform source" << endl;
|
Chris@66
|
4041 }
|
Chris@66
|
4042 }
|
Chris@66
|
4043
|
Chris@2300
|
4044 if (modelId.isNone()) {
|
Chris@2300
|
4045 modelId = m_document->getMainModel();
|
Chris@346
|
4046 }
|
Chris@66
|
4047
|
Chris@2300
|
4048 m_document->setModel(newLayer, modelId);
|
Chris@66
|
4049
|
Chris@69
|
4050 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
4051 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
4052
|
Chris@0
|
4053 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
4054 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
4055
|
Chris@438
|
4056 // SVDEBUG << "MainWindow::addPane: global centre frame is "
|
Chris@433
|
4057 // << m_viewManager->getGlobalCentreFrame() << endl;
|
Chris@130
|
4058 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
4059
|
Chris@0
|
4060 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
4061
|
Chris@0
|
4062 updateMenuStates();
|
Chris@0
|
4063 }
|
Chris@0
|
4064
|
Chris@0
|
4065 void
|
Chris@0
|
4066 MainWindow::addLayer()
|
Chris@0
|
4067 {
|
Chris@0
|
4068 QObject *s = sender();
|
Chris@0
|
4069 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
4070
|
Chris@0
|
4071 if (!action) {
|
Chris@1770
|
4072 cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@1770
|
4073 << endl;
|
Chris@1770
|
4074 return;
|
Chris@0
|
4075 }
|
Chris@0
|
4076
|
Chris@0
|
4077 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
4078
|
Chris@0
|
4079 if (!pane) {
|
Chris@1770
|
4080 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
|
Chris@1770
|
4081 return;
|
Chris@0
|
4082 }
|
Chris@0
|
4083
|
Chris@2093
|
4084 ExistingLayerActions::iterator ei = m_existingLayerActions.begin();
|
Chris@2093
|
4085 while (ei != m_existingLayerActions.end()) {
|
Chris@2093
|
4086 if (ei->first == action) break;
|
Chris@2093
|
4087 ++ei;
|
Chris@2093
|
4088 }
|
Chris@0
|
4089
|
Chris@0
|
4090 if (ei != m_existingLayerActions.end()) {
|
Chris@1770
|
4091 Layer *newLayer = ei->second;
|
Chris@1770
|
4092 m_document->addLayerToView(pane, newLayer);
|
Chris@1770
|
4093 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1770
|
4094 return;
|
Chris@0
|
4095 }
|
Chris@0
|
4096
|
Chris@2093
|
4097 ei = m_sliceActions.begin();
|
Chris@2093
|
4098 while (ei != m_sliceActions.end()) {
|
Chris@2093
|
4099 if (ei->first == action) break;
|
Chris@2093
|
4100 ++ei;
|
Chris@2093
|
4101 }
|
Chris@95
|
4102
|
Chris@95
|
4103 if (ei != m_sliceActions.end()) {
|
Chris@95
|
4104 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
4105 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
4106 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
4107 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
4108 if (source && dest) {
|
Chris@205
|
4109 //!!!???
|
Chris@95
|
4110 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
4111 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
4112 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
4113 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
4114 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
4115 }
|
Chris@1770
|
4116 m_document->addLayerToView(pane, newLayer);
|
Chris@1770
|
4117 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1770
|
4118 return;
|
Chris@95
|
4119 }
|
Chris@95
|
4120
|
Chris@2093
|
4121 TransformActions::iterator i = m_transformActions.begin();
|
Chris@2093
|
4122 while (i != m_transformActions.end()) {
|
Chris@2093
|
4123 if (i->first == action) break;
|
Chris@2093
|
4124 ++i;
|
Chris@2093
|
4125 }
|
Chris@34
|
4126
|
Chris@34
|
4127 if (i == m_transformActions.end()) {
|
Chris@0
|
4128
|
Chris@2093
|
4129 LayerActions::iterator i = m_layerActions.begin();
|
Chris@2093
|
4130 while (i != m_layerActions.end()) {
|
Chris@2093
|
4131 if (i->first == action) break;
|
Chris@2093
|
4132 ++i;
|
Chris@2093
|
4133 }
|
Chris@1770
|
4134
|
Chris@1770
|
4135 if (i == m_layerActions.end()) {
|
Chris@1770
|
4136 cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@1770
|
4137 << action->objectName() << endl;
|
Chris@1770
|
4138 return;
|
Chris@1770
|
4139 }
|
Chris@1770
|
4140
|
Chris@1770
|
4141 LayerFactory::LayerType type = i->second.layer;
|
Chris@1770
|
4142
|
Chris@1770
|
4143 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@1770
|
4144 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@1770
|
4145
|
Chris@2126
|
4146 Layer *newLayer = nullptr;
|
Chris@1770
|
4147
|
Chris@2332
|
4148 bool isNewEmptyLayer = false;
|
Chris@2332
|
4149
|
Chris@1770
|
4150 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@1770
|
4151
|
Chris@1770
|
4152 newLayer = m_document->createEmptyLayer(type);
|
Chris@217
|
4153 if (newLayer) {
|
Chris@2332
|
4154 isNewEmptyLayer = true;
|
Chris@217
|
4155 }
|
Chris@0
|
4156
|
Chris@1770
|
4157 } else {
|
Chris@0
|
4158
|
Chris@2300
|
4159 ModelId modelId = i->second.sourceModel;
|
Chris@2300
|
4160
|
Chris@2300
|
4161 if (modelId.isNone()) {
|
Chris@346
|
4162 if (type == LayerFactory::TimeRuler) {
|
Chris@346
|
4163 newLayer = m_document->createMainModelLayer(type);
|
Chris@346
|
4164 } else {
|
Chris@346
|
4165 // if model is unspecified and this is not a
|
Chris@415
|
4166 // time-ruler layer, use any plausible model from
|
Chris@415
|
4167 // the current pane -- this is the case for
|
Chris@415
|
4168 // right-button menu layer additions
|
Chris@415
|
4169 Pane::ModelSet ms = pane->getModels();
|
Chris@2300
|
4170 for (ModelId m: ms) {
|
Chris@2300
|
4171 if (ModelById::isa<RangeSummarisableTimeValueModel>(m)) {
|
Chris@2300
|
4172 modelId = m;
|
Chris@2300
|
4173 }
|
Chris@346
|
4174 }
|
Chris@2300
|
4175 if (modelId.isNone()) {
|
Chris@2300
|
4176 modelId = getMainModelId();
|
Chris@2300
|
4177 }
|
Chris@346
|
4178 }
|
Chris@346
|
4179 }
|
Chris@346
|
4180
|
Chris@2300
|
4181 if (!modelId.isNone()) {
|
Chris@238
|
4182 newLayer = m_document->createLayer(type);
|
Chris@2300
|
4183 if (m_document->isKnownModel(modelId)) {
|
Chris@238
|
4184 m_document->setChannel(newLayer, i->second.channel);
|
Chris@2300
|
4185 m_document->setModel(newLayer, modelId);
|
Chris@238
|
4186 } else {
|
Chris@2300
|
4187 SVCERR << "WARNING: MainWindow::addLayer: unknown model "
|
Chris@2300
|
4188 << modelId << " in layer action map" << endl;
|
Chris@238
|
4189 }
|
Chris@232
|
4190 }
|
Chris@238
|
4191 }
|
Chris@0
|
4192
|
Chris@2332
|
4193 if (isNewEmptyLayer) {
|
Chris@2332
|
4194
|
Chris@2370
|
4195 double min, max;
|
Chris@2370
|
4196 bool log;
|
Chris@2332
|
4197 QString unit;
|
Chris@2370
|
4198 if (pane->getVisibleExtentsForAnyUnit(min, max, log, unit)) {
|
Chris@2370
|
4199 newLayer->adoptExtents(min, max, unit);
|
Chris@2332
|
4200 }
|
Chris@2332
|
4201
|
Chris@2332
|
4202 for (auto &a : m_toolActions) {
|
Chris@2332
|
4203 if (a.first == ViewManager::DrawMode) {
|
Chris@2332
|
4204 a.second->trigger();
|
Chris@2332
|
4205 break;
|
Chris@2332
|
4206 }
|
Chris@2332
|
4207 }
|
Chris@2332
|
4208 }
|
Chris@2332
|
4209
|
Chris@217
|
4210 if (newLayer) {
|
Chris@217
|
4211 m_document->addLayerToView(pane, newLayer);
|
Chris@217
|
4212 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@217
|
4213 }
|
Chris@0
|
4214
|
Chris@1770
|
4215 return;
|
Chris@0
|
4216 }
|
Chris@0
|
4217
|
Chris@224
|
4218 //!!! want to do something like this, but it's not supported in
|
Chris@224
|
4219 //ModelTransformerFactory yet
|
Chris@224
|
4220 /*
|
Chris@0
|
4221 int channel = -1;
|
Chris@0
|
4222 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
4223 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@1770
|
4224 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@1770
|
4225 if (c != -1) {
|
Chris@1770
|
4226 channel = c;
|
Chris@1770
|
4227 break;
|
Chris@1770
|
4228 }
|
Chris@0
|
4229 }
|
Chris@224
|
4230 */
|
Chris@0
|
4231
|
Chris@33
|
4232 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
4233 // supposed to be configurable, because we need to let the user
|
Chris@33
|
4234 // change the execution context (block size etc).
|
Chris@0
|
4235
|
Chris@224
|
4236 QString transformId = i->second;
|
Chris@274
|
4237
|
Chris@274
|
4238 addLayer(transformId);
|
Chris@274
|
4239 }
|
Chris@274
|
4240
|
Chris@274
|
4241 void
|
Chris@274
|
4242 MainWindow::addLayer(QString transformId)
|
Chris@274
|
4243 {
|
Chris@274
|
4244 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@274
|
4245 if (!pane) {
|
Chris@1770
|
4246 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
|
Chris@1770
|
4247 return;
|
Chris@274
|
4248 }
|
Chris@274
|
4249
|
Chris@1558
|
4250 Transform transform;
|
Chris@1558
|
4251 try {
|
Chris@1558
|
4252 transform = TransformFactory::getInstance()->
|
Chris@1558
|
4253 getDefaultTransformFor(transformId);
|
Chris@1558
|
4254 } catch (std::exception &e) { // e.g. Piper server failure
|
Chris@1558
|
4255 QMessageBox::critical
|
Chris@1558
|
4256 (this, tr("Failed to query transform attributes"),
|
Chris@1558
|
4257 tr("<b>Failed to query transform attributes</b><p>Plugin or server error: %1</p>")
|
Chris@1558
|
4258 .arg(e.what()));
|
Chris@1558
|
4259 return;
|
Chris@1558
|
4260 }
|
Chris@27
|
4261
|
Chris@2300
|
4262 std::vector<ModelId> candidateInputModels =
|
Chris@224
|
4263 m_document->getTransformInputModels();
|
Chris@53
|
4264
|
Chris@2300
|
4265 ModelId defaultInputModelId;
|
Chris@895
|
4266
|
Chris@219
|
4267 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@895
|
4268
|
Chris@219
|
4269 Layer *layer = pane->getLayer(j);
|
Chris@219
|
4270 if (!layer) continue;
|
Chris@895
|
4271
|
Chris@243
|
4272 if (LayerFactory::getInstance()->getLayerType(layer) !=
|
Chris@243
|
4273 LayerFactory::Waveform &&
|
Chris@2300
|
4274 !layer->isLayerOpaque()) {
|
Chris@2300
|
4275 continue;
|
Chris@2300
|
4276 }
|
Chris@2300
|
4277
|
Chris@2300
|
4278 ModelId modelId = layer->getModel();
|
Chris@2300
|
4279 if (modelId.isNone()) continue;
|
Chris@2300
|
4280
|
Chris@2300
|
4281 for (ModelId candidateId: candidateInputModels) {
|
Chris@2300
|
4282 if (candidateId == modelId) {
|
Chris@2300
|
4283 defaultInputModelId = modelId;
|
Chris@219
|
4284 break;
|
Chris@219
|
4285 }
|
Chris@219
|
4286 }
|
Chris@895
|
4287
|
Chris@2300
|
4288 if (!defaultInputModelId.isNone()) break;
|
Chris@219
|
4289 }
|
Chris@895
|
4290
|
Chris@2300
|
4291 ModelId aggregate;
|
Chris@1620
|
4292
|
Chris@895
|
4293 if (candidateInputModels.size() > 1) {
|
Chris@895
|
4294 // Add an aggregate model as another option
|
Chris@895
|
4295 AggregateWaveModel::ChannelSpecList sl;
|
Chris@2300
|
4296 for (ModelId mid: candidateInputModels) {
|
Chris@2300
|
4297 if (ModelById::isa<RangeSummarisableTimeValueModel>(mid)) {
|
Chris@2300
|
4298 sl.push_back(AggregateWaveModel::ModelChannelSpec(mid, -1));
|
Chris@895
|
4299 }
|
Chris@895
|
4300 }
|
Chris@895
|
4301 if (!sl.empty()) {
|
Chris@2300
|
4302 auto aggregate = std::make_shared<AggregateWaveModel>(sl);
|
Chris@895
|
4303 aggregate->setObjectName(tr("Multiplex all of the above"));
|
Chris@2300
|
4304 candidateInputModels.push_back(ModelById::add(aggregate));
|
Chris@895
|
4305 }
|
Chris@895
|
4306 }
|
Chris@219
|
4307
|
Chris@914
|
4308 sv_frame_t startFrame = 0, duration = 0;
|
Chris@914
|
4309 sv_frame_t endFrame = 0;
|
Chris@184
|
4310 m_viewManager->getSelection().getExtents(startFrame, endFrame);
|
Chris@184
|
4311 if (endFrame > startFrame) duration = endFrame - startFrame;
|
Chris@184
|
4312 else startFrame = 0;
|
Chris@184
|
4313
|
Chris@357
|
4314 TransformUserConfigurator configurator;
|
Chris@357
|
4315
|
Chris@224
|
4316 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
Chris@224
|
4317 getConfigurationForTransform
|
Chris@211
|
4318 (transform,
|
Chris@211
|
4319 candidateInputModels,
|
Chris@2300
|
4320 defaultInputModelId,
|
Chris@211
|
4321 m_playSource,
|
Chris@211
|
4322 startFrame,
|
Chris@357
|
4323 duration,
|
Chris@357
|
4324 &configurator);
|
Chris@211
|
4325
|
Chris@2300
|
4326 if (!aggregate.isNone()) {
|
Chris@1623
|
4327 if (input.getModel() == aggregate) {
|
Chris@2300
|
4328 if (auto aggregateModel = ModelById::get(aggregate)) {
|
Chris@2300
|
4329 aggregateModel->setObjectName(tr("Multiplexed audio"));
|
Chris@2300
|
4330 }
|
Chris@2303
|
4331 m_document->addNonDerivedModel(aggregate);
|
Chris@1623
|
4332 } else {
|
Chris@2300
|
4333 ModelById::release(aggregate);
|
Chris@1623
|
4334 }
|
Chris@1620
|
4335 }
|
Chris@1620
|
4336
|
Chris@2300
|
4337 if (input.getModel().isNone()) return;
|
Chris@224
|
4338
|
Chris@438
|
4339 // SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;
|
Chris@224
|
4340
|
Chris@1558
|
4341 try {
|
Chris@1558
|
4342 Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
Chris@1558
|
4343 if (newLayer) {
|
Chris@1558
|
4344 m_document->addLayerToView(pane, newLayer);
|
Chris@1558
|
4345 m_document->setChannel(newLayer, input.getChannel());
|
Chris@1558
|
4346 m_recentTransforms.add(transformId);
|
Chris@1558
|
4347 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@1558
|
4348 }
|
Chris@1558
|
4349 } catch (std::exception &e) { // e.g. Piper server failure
|
Chris@1558
|
4350 QMessageBox::critical
|
Chris@1558
|
4351 (this, tr("Transform failed"),
|
Chris@1558
|
4352 tr("<b>Failed to run transform</b><p>Plugin or server error: %1</p>")
|
Chris@1558
|
4353 .arg(e.what()));
|
Chris@1558
|
4354 return;
|
Chris@0
|
4355 }
|
Chris@1558
|
4356
|
Chris@0
|
4357 updateMenuStates();
|
Chris@0
|
4358 }
|
Chris@0
|
4359
|
Chris@0
|
4360 void
|
Chris@0
|
4361 MainWindow::renameCurrentLayer()
|
Chris@0
|
4362 {
|
Chris@0
|
4363 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
4364 if (pane) {
|
Chris@1770
|
4365 Layer *layer = pane->getSelectedLayer();
|
Chris@1770
|
4366 if (layer) {
|
Chris@1770
|
4367 bool ok = false;
|
Chris@1770
|
4368 QString newName = QInputDialog::getText
|
Chris@1770
|
4369 (this, tr("Rename Layer"),
|
Chris@1770
|
4370 tr("New name for this layer:"),
|
Chris@1770
|
4371 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@1770
|
4372 if (ok) {
|
Chris@1770
|
4373 layer->setPresentationName(newName);
|
Chris@1770
|
4374 setupExistingLayersMenus();
|
Chris@1770
|
4375 }
|
Chris@1770
|
4376 }
|
Chris@0
|
4377 }
|
Chris@0
|
4378 }
|
Chris@0
|
4379
|
Chris@0
|
4380 void
|
Chris@272
|
4381 MainWindow::findTransform()
|
Chris@272
|
4382 {
|
Chris@274
|
4383 TransformFinder *finder = new TransformFinder(this);
|
Chris@274
|
4384 if (!finder->exec()) {
|
Chris@274
|
4385 delete finder;
|
Chris@274
|
4386 return;
|
Chris@273
|
4387 }
|
Chris@274
|
4388 TransformId transform = finder->getTransform();
|
Chris@274
|
4389 delete finder;
|
Chris@287
|
4390
|
Chris@2126
|
4391 if (getMainModel() != nullptr && m_paneStack->getCurrentPane() != nullptr) {
|
Chris@287
|
4392 addLayer(transform);
|
Chris@287
|
4393 }
|
Chris@272
|
4394 }
|
Chris@272
|
4395
|
Chris@272
|
4396 void
|
Chris@207
|
4397 MainWindow::playSoloToggled()
|
Chris@207
|
4398 {
|
Chris@207
|
4399 MainWindowBase::playSoloToggled();
|
Chris@207
|
4400 m_soloModified = true;
|
Chris@207
|
4401 }
|
Chris@207
|
4402
|
Chris@207
|
4403 void
|
Chris@206
|
4404 MainWindow::alignToggled()
|
Chris@206
|
4405 {
|
Chris@206
|
4406 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@206
|
4407
|
Chris@207
|
4408 if (!m_viewManager) return;
|
Chris@207
|
4409
|
Chris@206
|
4410 if (action) {
|
Chris@1770
|
4411 m_viewManager->setAlignMode(action->isChecked());
|
Chris@206
|
4412 } else {
|
Chris@1770
|
4413 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
|
Chris@206
|
4414 }
|
Chris@206
|
4415
|
Chris@206
|
4416 if (m_viewManager->getAlignMode()) {
|
Chris@207
|
4417 m_prevSolo = m_soloAction->isChecked();
|
Chris@208
|
4418 if (!m_soloAction->isChecked()) {
|
Chris@208
|
4419 m_soloAction->setChecked(true);
|
Chris@208
|
4420 MainWindowBase::playSoloToggled();
|
Chris@208
|
4421 }
|
Chris@207
|
4422 m_soloModified = false;
|
Chris@207
|
4423 emit canChangeSolo(false);
|
Chris@206
|
4424 m_document->alignModels();
|
Chris@206
|
4425 m_document->setAutoAlignment(true);
|
Chris@206
|
4426 } else {
|
Chris@207
|
4427 if (!m_soloModified) {
|
Chris@208
|
4428 if (m_soloAction->isChecked() != m_prevSolo) {
|
Chris@208
|
4429 m_soloAction->setChecked(m_prevSolo);
|
Chris@208
|
4430 MainWindowBase::playSoloToggled();
|
Chris@208
|
4431 }
|
Chris@207
|
4432 }
|
Chris@207
|
4433 emit canChangeSolo(true);
|
Chris@206
|
4434 m_document->setAutoAlignment(false);
|
Chris@206
|
4435 }
|
Chris@206
|
4436
|
Chris@206
|
4437 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@206
|
4438
|
Chris@1770
|
4439 Pane *pane = m_paneStack->getPane(i);
|
Chris@1770
|
4440 if (!pane) continue;
|
Chris@206
|
4441
|
Chris@206
|
4442 pane->update();
|
Chris@206
|
4443 }
|
Chris@206
|
4444 }
|
Chris@206
|
4445
|
Chris@206
|
4446 void
|
Chris@59
|
4447 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
4448 {
|
Chris@1031
|
4449 PlaySpeedRangeMapper mapper;
|
Chris@60
|
4450
|
Chris@922
|
4451 double percent = m_playSpeed->mappedValue();
|
Chris@922
|
4452 double factor = mapper.getFactorForValue(percent);
|
Chris@60
|
4453
|
Chris@1031
|
4454 // cerr << "play speed position = " << position << " (range 0-120) percent = " << percent << " factor = " << factor << endl;
|
Chris@1031
|
4455
|
Chris@1031
|
4456 int centre = m_playSpeed->defaultValue();
|
Chris@1031
|
4457
|
Chris@1031
|
4458 // Percentage is shown to 0dp if >100, to 1dp if <100; factor is
|
Chris@1031
|
4459 // shown to 3sf
|
Chris@1031
|
4460
|
Chris@1031
|
4461 char pcbuf[30];
|
Chris@1031
|
4462 char facbuf[30];
|
Chris@1031
|
4463
|
Chris@1031
|
4464 if (position == centre) {
|
Chris@155
|
4465 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@1031
|
4466 } else if (position < centre) {
|
Chris@1031
|
4467 sprintf(pcbuf, "%.1f", percent);
|
Chris@1031
|
4468 sprintf(facbuf, "%.3g", 1.0 / factor);
|
Chris@1031
|
4469 contextHelpChanged(tr("Playback speed: %1% (%2x slower)")
|
Chris@1031
|
4470 .arg(pcbuf)
|
Chris@1031
|
4471 .arg(facbuf));
|
Chris@155
|
4472 } else {
|
Chris@1031
|
4473 sprintf(pcbuf, "%.0f", percent);
|
Chris@1031
|
4474 sprintf(facbuf, "%.3g", factor);
|
Chris@1031
|
4475 contextHelpChanged(tr("Playback speed: %1% (%2x faster)")
|
Chris@1031
|
4476 .arg(pcbuf)
|
Chris@1031
|
4477 .arg(facbuf));
|
Chris@155
|
4478 }
|
Chris@155
|
4479
|
Chris@1031
|
4480 m_playSource->setTimeStretch(1.0 / factor); // factor is a speedup
|
Chris@155
|
4481
|
Chris@155
|
4482 updateMenuStates();
|
Chris@16
|
4483 }
|
Chris@16
|
4484
|
Chris@26
|
4485 void
|
Chris@155
|
4486 MainWindow::speedUpPlayback()
|
Chris@155
|
4487 {
|
Chris@155
|
4488 int value = m_playSpeed->value();
|
Chris@155
|
4489 value = value + m_playSpeed->pageStep();
|
Chris@155
|
4490 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@155
|
4491 m_playSpeed->setValue(value);
|
Chris@155
|
4492 }
|
Chris@155
|
4493
|
Chris@155
|
4494 void
|
Chris@155
|
4495 MainWindow::slowDownPlayback()
|
Chris@155
|
4496 {
|
Chris@155
|
4497 int value = m_playSpeed->value();
|
Chris@155
|
4498 value = value - m_playSpeed->pageStep();
|
Chris@155
|
4499 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@155
|
4500 m_playSpeed->setValue(value);
|
Chris@155
|
4501 }
|
Chris@155
|
4502
|
Chris@155
|
4503 void
|
Chris@155
|
4504 MainWindow::restoreNormalPlayback()
|
Chris@155
|
4505 {
|
Chris@155
|
4506 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@155
|
4507 }
|
Chris@155
|
4508
|
Chris@155
|
4509 void
|
Chris@227
|
4510 MainWindow::currentPaneChanged(Pane *pane)
|
Chris@227
|
4511 {
|
Chris@228
|
4512 MainWindowBase::currentPaneChanged(pane);
|
Chris@228
|
4513
|
Chris@227
|
4514 if (!pane || !m_panLayer) return;
|
Chris@761
|
4515
|
Chris@761
|
4516 // If this pane contains the main model, it usually makes sense to
|
Chris@761
|
4517 // show the main model in the pan layer even if it isn't the top
|
Chris@761
|
4518 // layer in the pane (e.g. if the top layer is one derived from
|
Chris@761
|
4519 // the main model).
|
Chris@761
|
4520 bool containsMainModel = false;
|
Chris@761
|
4521 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@761
|
4522 --i;
|
Chris@761
|
4523 Layer *layer = pane->getLayer(i);
|
Chris@761
|
4524 if (layer &&
|
Chris@761
|
4525 LayerFactory::getInstance()->getLayerType(layer) ==
|
Chris@761
|
4526 LayerFactory::Waveform &&
|
Chris@2300
|
4527 layer->getModel() == getMainModelId()) {
|
Chris@761
|
4528 containsMainModel = true;
|
Chris@761
|
4529 break;
|
Chris@761
|
4530 }
|
Chris@761
|
4531 }
|
Chris@761
|
4532
|
Chris@1794
|
4533 bool panLayerSet = false;
|
Chris@1794
|
4534
|
Chris@227
|
4535 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@227
|
4536 --i;
|
Chris@227
|
4537 Layer *layer = pane->getLayer(i);
|
Chris@2300
|
4538 ModelId modelId = layer->getModel();
|
Chris@2300
|
4539 if (ModelById::isa<RangeSummarisableTimeValueModel>(modelId)) {
|
Chris@1794
|
4540 auto type = LayerFactory::getInstance()->getLayerType(layer);
|
Chris@1794
|
4541 if (type != LayerFactory::TimeRuler) {
|
Chris@2300
|
4542 updateLayerShortcutsFor(modelId);
|
Chris@1794
|
4543 }
|
Chris@1794
|
4544 if (type == LayerFactory::Waveform) {
|
Chris@2300
|
4545 m_panLayer->setModel(modelId);
|
Chris@1794
|
4546 panLayerSet = true;
|
Chris@1794
|
4547 break;
|
Chris@227
|
4548 }
|
Chris@227
|
4549 }
|
Chris@227
|
4550 }
|
Chris@1794
|
4551
|
Chris@1794
|
4552 if (containsMainModel && !panLayerSet) {
|
Chris@2300
|
4553 m_panLayer->setModel(getMainModelId());
|
Chris@1794
|
4554 }
|
Chris@227
|
4555 }
|
Chris@227
|
4556
|
Chris@227
|
4557 void
|
Chris@116
|
4558 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@116
|
4559 {
|
Chris@2300
|
4560 sv_samplerate_t sampleRate = 0;
|
Chris@2300
|
4561 if (auto mm = getMainModel()) {
|
Chris@2300
|
4562 sampleRate = mm->getSampleRate();
|
Chris@2300
|
4563 } else {
|
Chris@2300
|
4564 return;
|
Chris@2300
|
4565 }
|
Chris@2300
|
4566 if (!p) {
|
Chris@116
|
4567 return;
|
Chris@116
|
4568 }
|
Chris@116
|
4569
|
Chris@117
|
4570 bool haveSelection = false;
|
Chris@922
|
4571 sv_frame_t startFrame = 0, endFrame = 0;
|
Chris@117
|
4572
|
Chris@117
|
4573 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@117
|
4574
|
Chris@117
|
4575 bool exclusive = false;
|
Chris@117
|
4576 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@117
|
4577
|
Chris@117
|
4578 if (!s.isEmpty()) {
|
Chris@117
|
4579 haveSelection = true;
|
Chris@117
|
4580 startFrame = s.getStartFrame();
|
Chris@117
|
4581 endFrame = s.getEndFrame();
|
Chris@117
|
4582 }
|
Chris@117
|
4583 }
|
Chris@117
|
4584
|
Chris@117
|
4585 if (!haveSelection) {
|
Chris@117
|
4586 startFrame = p->getFirstVisibleFrame();
|
Chris@117
|
4587 endFrame = p->getLastVisibleFrame();
|
Chris@117
|
4588 }
|
Chris@117
|
4589
|
Chris@2300
|
4590 RealTime start = RealTime::frame2RealTime(startFrame, sampleRate);
|
Chris@2300
|
4591 RealTime end = RealTime::frame2RealTime(endFrame, sampleRate);
|
Chris@116
|
4592 RealTime duration = end - start;
|
Chris@116
|
4593
|
Chris@116
|
4594 QString startStr, endStr, durationStr;
|
Chris@116
|
4595 startStr = start.toText(true).c_str();
|
Chris@116
|
4596 endStr = end.toText(true).c_str();
|
Chris@116
|
4597 durationStr = duration.toText(true).c_str();
|
Chris@116
|
4598
|
Chris@117
|
4599 if (haveSelection) {
|
Chris@117
|
4600 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@117
|
4601 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
4602 } else {
|
Chris@117
|
4603 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@117
|
4604 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
4605 }
|
Chris@116
|
4606
|
Chris@739
|
4607 if (getStatusLabel()->text() != m_myStatusMessage) {
|
Chris@739
|
4608 getStatusLabel()->setText(m_myStatusMessage);
|
Chris@737
|
4609 }
|
Chris@340
|
4610
|
Chris@340
|
4611 updatePositionStatusDisplays();
|
Chris@340
|
4612 }
|
Chris@340
|
4613
|
Chris@340
|
4614 void
|
Chris@340
|
4615 MainWindow::updatePositionStatusDisplays() const
|
Chris@340
|
4616 {
|
Chris@340
|
4617 if (!statusBar()->isVisible()) return;
|
Chris@340
|
4618
|
Chris@2126
|
4619 Pane *pane = nullptr;
|
Chris@922
|
4620 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
Chris@340
|
4621
|
Chris@340
|
4622 if (m_paneStack) pane = m_paneStack->getCurrentPane();
|
Chris@340
|
4623 if (!pane) return;
|
Chris@340
|
4624
|
Chris@340
|
4625 int layers = pane->getLayerCount();
|
Chris@340
|
4626 if (layers == 0) m_currentLabel->setText("");
|
Chris@340
|
4627
|
Chris@340
|
4628 for (int i = layers-1; i >= 0; --i) {
|
Chris@340
|
4629 Layer *layer = pane->getLayer(i);
|
Chris@340
|
4630 if (!layer) continue;
|
Chris@340
|
4631 if (!layer->isLayerEditable()) continue;
|
Chris@340
|
4632 QString label = layer->getLabelPreceding
|
Chris@340
|
4633 (pane->alignFromReference(frame));
|
Chris@340
|
4634 m_currentLabel->setText(label);
|
Chris@340
|
4635 break;
|
Chris@340
|
4636 }
|
Chris@116
|
4637 }
|
Chris@116
|
4638
|
Chris@116
|
4639 void
|
Chris@1476
|
4640 MainWindow::monitoringLevelsChanged(float left, float right)
|
Chris@0
|
4641 {
|
Chris@1386
|
4642 m_mainLevelPan->setMonitoringLevels(left, right);
|
Chris@0
|
4643 }
|
Chris@0
|
4644
|
Chris@0
|
4645 void
|
Chris@921
|
4646 MainWindow::sampleRateMismatch(sv_samplerate_t requested,
|
Chris@921
|
4647 sv_samplerate_t actual,
|
Chris@0
|
4648 bool willResample)
|
Chris@0
|
4649 {
|
Chris@0
|
4650 if (!willResample) {
|
Chris@247
|
4651 emit hideSplash();
|
Chris@0
|
4652 QMessageBox::information
|
Chris@0
|
4653 (this, tr("Sample rate mismatch"),
|
Chris@193
|
4654 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
|
4655 .arg(requested).arg(actual));
|
Chris@0
|
4656 }
|
Chris@0
|
4657
|
Chris@0
|
4658 updateDescriptionLabel();
|
Chris@0
|
4659 }
|
Chris@0
|
4660
|
Chris@0
|
4661 void
|
Chris@42
|
4662 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
4663 {
|
Chris@42
|
4664 QMessageBox::information
|
Chris@42
|
4665 (this, tr("Audio processing overload"),
|
Chris@193
|
4666 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@42
|
4667 }
|
Chris@42
|
4668
|
Chris@42
|
4669 void
|
Chris@266
|
4670 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@266
|
4671 {
|
Chris@266
|
4672 static bool shownOnce = false;
|
Chris@266
|
4673 if (shownOnce) return;
|
Chris@266
|
4674 QMessageBox::information
|
Chris@266
|
4675 (this, tr("Audio processing overload"),
|
Chris@266
|
4676 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@266
|
4677 shownOnce = true;
|
Chris@266
|
4678 }
|
Chris@266
|
4679
|
Chris@266
|
4680 void
|
Chris@1521
|
4681 MainWindow::betaReleaseWarning()
|
Chris@1521
|
4682 {
|
Chris@1521
|
4683 QMessageBox::information
|
Chris@1521
|
4684 (this, tr("Beta release"),
|
Chris@2352
|
4685 tr("<b>This is a beta release of %1</b><p>Please see the \"What's New\" option in the Help menu for a list of changes since the last proper release.</p>").arg(QApplication::applicationName()));
|
Chris@1521
|
4686 }
|
Chris@1521
|
4687
|
Chris@1521
|
4688 void
|
Chris@1148
|
4689 MainWindow::pluginPopulationWarning()
|
Chris@1087
|
4690 {
|
Chris@1277
|
4691 QString scanWarning = PluginScan::getInstance()->getStartupFailureReport();
|
Chris@1277
|
4692 QString factWarning = TransformFactory::getInstance()->getStartupFailureReport();
|
Chris@1277
|
4693 QString warning;
|
Chris@1277
|
4694 if (factWarning != "") {
|
Chris@1277
|
4695 // The order of events on startup implies that, if scanWarning
|
Chris@1277
|
4696 // and factWarning are both present, then we have already been
|
Chris@1277
|
4697 // called once for scanWarning so don't want to report it again
|
Chris@1277
|
4698 warning = factWarning;
|
Chris@1277
|
4699 } else if (scanWarning != "") {
|
Chris@1277
|
4700 warning = scanWarning;
|
Chris@1277
|
4701 }
|
Chris@1277
|
4702 if (warning != "") {
|
Chris@1277
|
4703 emit hideSplash();
|
Chris@2067
|
4704 QMessageBox box;
|
Chris@2067
|
4705 box.setWindowTitle(tr("Problems loading plugins"));
|
Chris@2067
|
4706 box.setText(tr("<b>Failed to load plugins</b>"));
|
Chris@2067
|
4707 box.setInformativeText(warning);
|
Chris@2067
|
4708 box.setIcon(QMessageBox::Warning);
|
Chris@2067
|
4709 box.setStandardButtons(QMessageBox::Ok);
|
Chris@2067
|
4710 box.exec();
|
Chris@1277
|
4711 }
|
Chris@1087
|
4712 }
|
Chris@1087
|
4713
|
Chris@1087
|
4714 void
|
Chris@304
|
4715 MainWindow::midiEventsAvailable()
|
Chris@304
|
4716 {
|
Chris@2126
|
4717 Pane *currentPane = nullptr;
|
Chris@2126
|
4718 NoteLayer *currentNoteLayer = nullptr;
|
Chris@2126
|
4719 TimeValueLayer *currentTimeValueLayer = nullptr;
|
Chris@307
|
4720
|
Chris@793
|
4721 if (m_paneStack) {
|
Chris@793
|
4722 currentPane = m_paneStack->getCurrentPane();
|
Chris@793
|
4723 }
|
Chris@793
|
4724
|
Chris@307
|
4725 if (currentPane) {
|
Chris@307
|
4726 currentNoteLayer = dynamic_cast<NoteLayer *>
|
Chris@307
|
4727 (currentPane->getSelectedLayer());
|
Chris@309
|
4728 currentTimeValueLayer = dynamic_cast<TimeValueLayer *>
|
Chris@309
|
4729 (currentPane->getSelectedLayer());
|
Chris@838
|
4730 } else {
|
Chris@793
|
4731 // discard these events
|
Chris@793
|
4732 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@793
|
4733 (void)m_midiInput->readEvent();
|
Chris@793
|
4734 }
|
Chris@793
|
4735 return;
|
Chris@793
|
4736 }
|
Chris@793
|
4737
|
Chris@305
|
4738 // This is called through a serialised signal/slot invocation
|
Chris@305
|
4739 // (across threads). It could happen quite some time after the
|
Chris@305
|
4740 // event was actually received, which is why event timestamping
|
Chris@305
|
4741 // happens in the MIDI input class and not here.
|
Chris@307
|
4742
|
Chris@305
|
4743 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@308
|
4744
|
Chris@305
|
4745 MIDIEvent ev(m_midiInput->readEvent());
|
Chris@307
|
4746
|
Chris@922
|
4747 sv_frame_t frame = currentPane->alignFromReference(ev.getTime());
|
Chris@309
|
4748
|
Chris@308
|
4749 bool noteOn = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
4750 ev.getVelocity() > 0);
|
Chris@308
|
4751
|
Chris@308
|
4752 bool noteOff = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_OFF ||
|
Chris@308
|
4753 (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON &&
|
Chris@308
|
4754 ev.getVelocity() == 0));
|
Chris@308
|
4755
|
Chris@307
|
4756 if (currentNoteLayer) {
|
Chris@307
|
4757
|
Chris@310
|
4758 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
4759
|
Chris@308
|
4760 if (noteOn) {
|
Chris@307
|
4761
|
Chris@309
|
4762 currentNoteLayer->addNoteOn(frame,
|
Chris@307
|
4763 ev.getPitch(),
|
Chris@307
|
4764 ev.getVelocity());
|
Chris@307
|
4765
|
Chris@308
|
4766 } else if (noteOff) {
|
Chris@307
|
4767
|
Chris@309
|
4768 currentNoteLayer->addNoteOff(frame,
|
Chris@307
|
4769 ev.getPitch());
|
Chris@307
|
4770
|
Chris@307
|
4771 }
|
Chris@307
|
4772
|
Chris@309
|
4773 continue;
|
Chris@309
|
4774 }
|
Chris@309
|
4775
|
Chris@309
|
4776 if (currentTimeValueLayer) {
|
Chris@308
|
4777
|
Chris@308
|
4778 if (!noteOn) continue;
|
Chris@310
|
4779
|
Chris@310
|
4780 if (!m_playSource || !m_playSource->isPlaying()) continue;
|
Chris@310
|
4781
|
Chris@2300
|
4782 ModelId modelId = currentTimeValueLayer->getModel();
|
Chris@2300
|
4783 if (ModelById::isa<SparseTimeValueModel>(modelId)) {
|
Chris@2226
|
4784 Event point(frame, float(ev.getPitch() % 12), "");
|
Chris@2226
|
4785 AddEventCommand *command = new AddEventCommand
|
Chris@2300
|
4786 (modelId.untyped, point, tr("Add Point"));
|
Chris@309
|
4787 CommandHistory::getInstance()->addCommand(command);
|
Chris@309
|
4788 }
|
Chris@838
|
4789
|
Chris@309
|
4790 continue;
|
Chris@305
|
4791 }
|
Chris@309
|
4792
|
Chris@838
|
4793 // This is reached only if !currentNoteLayer and
|
Chris@838
|
4794 // !currentTimeValueLayer, i.e. there is some other sort of
|
Chris@838
|
4795 // layer that may be insertable-into
|
Chris@838
|
4796
|
Chris@309
|
4797 if (!noteOn) continue;
|
Chris@309
|
4798 insertInstantAt(ev.getTime());
|
Chris@304
|
4799 }
|
Chris@304
|
4800 }
|
Chris@304
|
4801
|
Chris@304
|
4802 void
|
Chris@730
|
4803 MainWindow::playStatusChanged(bool )
|
Chris@305
|
4804 {
|
Chris@2126
|
4805 Pane *currentPane = nullptr;
|
Chris@2126
|
4806 NoteLayer *currentNoteLayer = nullptr;
|
Chris@307
|
4807
|
Chris@307
|
4808 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@307
|
4809 if (currentPane) {
|
Chris@307
|
4810 currentNoteLayer = dynamic_cast<NoteLayer *>(currentPane->getSelectedLayer());
|
Chris@307
|
4811 }
|
Chris@307
|
4812
|
Chris@307
|
4813 if (currentNoteLayer) {
|
Chris@307
|
4814 currentNoteLayer->abandonNoteOns();
|
Chris@307
|
4815 }
|
Chris@305
|
4816 }
|
Chris@305
|
4817
|
Chris@305
|
4818 void
|
Chris@200
|
4819 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
4820 {
|
Chris@95
|
4821 setupExistingLayersMenus();
|
Chris@200
|
4822 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
4823 }
|
Chris@0
|
4824
|
Chris@0
|
4825 void
|
Chris@0
|
4826 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
4827 {
|
Chris@95
|
4828 setupExistingLayersMenus();
|
Chris@200
|
4829 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
4830 }
|
Chris@0
|
4831
|
Chris@0
|
4832 void
|
Chris@2300
|
4833 MainWindow::modelAdded(ModelId modelId)
|
Chris@0
|
4834 {
|
Chris@2300
|
4835 MainWindowBase::modelAdded(modelId);
|
Chris@2300
|
4836 if (ModelById::isa<DenseTimeValueModel>(modelId)) {
|
Chris@66
|
4837 setupPaneAndLayerMenus();
|
Chris@66
|
4838 }
|
Chris@0
|
4839 }
|
Chris@0
|
4840
|
Chris@0
|
4841 void
|
Chris@2300
|
4842 MainWindow::mainModelChanged(ModelId modelId)
|
Chris@0
|
4843 {
|
Chris@2300
|
4844 m_panLayer->setModel(modelId);
|
Chris@2300
|
4845
|
Chris@2300
|
4846 MainWindowBase::mainModelChanged(modelId);
|
Chris@200
|
4847
|
Chris@1055
|
4848 if (m_playTarget || m_audioIO) {
|
Chris@1386
|
4849 connect(m_mainLevelPan, SIGNAL(levelChanged(float)),
|
Chris@1035
|
4850 this, SLOT(mainModelGainChanged(float)));
|
Chris@1386
|
4851 connect(m_mainLevelPan, SIGNAL(panChanged(float)),
|
Chris@1386
|
4852 this, SLOT(mainModelPanChanged(float)));
|
Chris@1035
|
4853 }
|
Chris@1035
|
4854 }
|
Chris@1035
|
4855
|
Chris@1035
|
4856 void
|
Chris@1035
|
4857 MainWindow::mainModelGainChanged(float gain)
|
Chris@1035
|
4858 {
|
Chris@1035
|
4859 if (m_playTarget) {
|
Chris@1035
|
4860 m_playTarget->setOutputGain(gain);
|
Chris@1055
|
4861 } else if (m_audioIO) {
|
Chris@1055
|
4862 m_audioIO->setOutputGain(gain);
|
Chris@200
|
4863 }
|
Chris@0
|
4864 }
|
Chris@0
|
4865
|
Chris@0
|
4866 void
|
Chris@1386
|
4867 MainWindow::mainModelPanChanged(float balance)
|
Chris@1386
|
4868 {
|
Chris@1386
|
4869 // this is indeed stereo balance rather than pan
|
Chris@1386
|
4870 if (m_playTarget) {
|
Chris@1386
|
4871 m_playTarget->setOutputBalance(balance);
|
Chris@1386
|
4872 } else if (m_audioIO) {
|
Chris@1386
|
4873 m_audioIO->setOutputBalance(balance);
|
Chris@1386
|
4874 }
|
Chris@1386
|
4875 }
|
Chris@1386
|
4876
|
Chris@1386
|
4877 void
|
Chris@200
|
4878 MainWindow::setInstantsNumbering()
|
Chris@0
|
4879 {
|
Chris@200
|
4880 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
4881 if (!a) return;
|
Chris@200
|
4882
|
Chris@2093
|
4883 int type = 0;
|
Chris@2093
|
4884 for (auto &ai : m_numberingActions) {
|
Chris@2093
|
4885 if (ai.first == a) type = ai.second;
|
Chris@2093
|
4886 }
|
Chris@200
|
4887
|
Chris@200
|
4888 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
|
Chris@200
|
4889
|
Chris@200
|
4890 QSettings settings;
|
Chris@200
|
4891 settings.beginGroup("MainWindow");
|
Chris@200
|
4892 settings.setValue("labellertype", type);
|
Chris@200
|
4893 settings.endGroup();
|
Chris@200
|
4894 }
|
Chris@200
|
4895
|
Chris@200
|
4896 void
|
Chris@200
|
4897 MainWindow::setInstantsCounterCycle()
|
Chris@200
|
4898 {
|
Chris@200
|
4899 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
4900 if (!a) return;
|
Chris@200
|
4901
|
Chris@200
|
4902 int cycle = a->text().toInt();
|
Chris@200
|
4903 if (cycle == 0) return;
|
Chris@200
|
4904
|
Chris@200
|
4905 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
|
Chris@200
|
4906
|
Chris@200
|
4907 QSettings settings;
|
Chris@200
|
4908 settings.beginGroup("MainWindow");
|
Chris@200
|
4909 settings.setValue("labellercycle", cycle);
|
Chris@200
|
4910 settings.endGroup();
|
Chris@200
|
4911 }
|
Chris@200
|
4912
|
Chris@200
|
4913 void
|
Chris@597
|
4914 MainWindow::setInstantsCounters()
|
Chris@200
|
4915 {
|
Chris@200
|
4916 LabelCounterInputDialog dialog(m_labeller, this);
|
Chris@241
|
4917 dialog.setWindowTitle(tr("Reset Counters"));
|
Chris@200
|
4918 dialog.exec();
|
Chris@0
|
4919 }
|
Chris@0
|
4920
|
Chris@0
|
4921 void
|
Chris@597
|
4922 MainWindow::resetInstantsCounters()
|
Chris@597
|
4923 {
|
Chris@597
|
4924 if (m_labeller) m_labeller->resetCounters();
|
Chris@597
|
4925 }
|
Chris@597
|
4926
|
Chris@597
|
4927 void
|
Chris@1355
|
4928 MainWindow::subdivideInstants()
|
Chris@1355
|
4929 {
|
Chris@1355
|
4930 QSettings settings;
|
Chris@1355
|
4931 settings.beginGroup("MainWindow");
|
Chris@1355
|
4932 int n = settings.value("subdivisions", 4).toInt();
|
Chris@1355
|
4933
|
Chris@1355
|
4934 bool ok;
|
Chris@1355
|
4935
|
Chris@1355
|
4936 n = QInputDialog::getInt(this,
|
Chris@1355
|
4937 tr("Subdivide instants"),
|
Chris@1355
|
4938 tr("Number of subdivisions:"),
|
Chris@1355
|
4939 n, 2, 96, 1, &ok);
|
Chris@1355
|
4940
|
Chris@1355
|
4941 if (ok) {
|
Chris@1355
|
4942 settings.setValue("subdivisions", n);
|
Chris@1355
|
4943 subdivideInstantsBy(n);
|
Chris@1355
|
4944 }
|
Chris@1355
|
4945
|
Chris@1355
|
4946 settings.endGroup();
|
Chris@1355
|
4947 }
|
Chris@1355
|
4948
|
Chris@1355
|
4949 void
|
Chris@1356
|
4950 MainWindow::winnowInstants()
|
Chris@1356
|
4951 {
|
Chris@1356
|
4952 QSettings settings;
|
Chris@1356
|
4953 settings.beginGroup("MainWindow");
|
Chris@1356
|
4954 int n = settings.value("winnow-subdivisions", 4).toInt();
|
Chris@1356
|
4955
|
Chris@1356
|
4956 bool ok;
|
Chris@1356
|
4957
|
Chris@1356
|
4958 n = QInputDialog::getInt(this,
|
Chris@1356
|
4959 tr("Winnow instants"),
|
Chris@1356
|
4960 tr("Remove all instants apart from multiples of:"),
|
Chris@1356
|
4961 n, 2, 96, 1, &ok);
|
Chris@1356
|
4962
|
Chris@1356
|
4963 if (ok) {
|
Chris@1356
|
4964 settings.setValue("winnow-subdivisions", n);
|
Chris@1356
|
4965 winnowInstantsBy(n);
|
Chris@1356
|
4966 }
|
Chris@1356
|
4967
|
Chris@1356
|
4968 settings.endGroup();
|
Chris@1356
|
4969 }
|
Chris@1356
|
4970
|
Chris@1356
|
4971 void
|
Chris@233
|
4972 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@233
|
4973 {
|
Chris@247
|
4974 emit hideSplash();
|
Chris@247
|
4975
|
Chris@983
|
4976 QString quoted;
|
Chris@983
|
4977 if (transformName != "") {
|
Chris@983
|
4978 quoted = QString("\"%1\" ").arg(transformName);
|
Chris@983
|
4979 }
|
Chris@983
|
4980
|
Chris@233
|
4981 if (message != "") {
|
Chris@233
|
4982
|
Chris@233
|
4983 QMessageBox::warning
|
Chris@233
|
4984 (this,
|
Chris@233
|
4985 tr("Failed to generate layer"),
|
Chris@983
|
4986 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform %1failed:<p>%2")
|
Chris@983
|
4987 .arg(quoted).arg(message),
|
Chris@233
|
4988 QMessageBox::Ok);
|
Chris@233
|
4989 } else {
|
Chris@233
|
4990 QMessageBox::warning
|
Chris@233
|
4991 (this,
|
Chris@233
|
4992 tr("Failed to generate layer"),
|
Chris@983
|
4993 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
|
4994 .arg(quoted),
|
Chris@233
|
4995 QMessageBox::Ok);
|
Chris@233
|
4996 }
|
Chris@233
|
4997 }
|
Chris@233
|
4998
|
Chris@233
|
4999 void
|
Chris@730
|
5000 MainWindow::modelGenerationWarning(QString /* transformName */, QString message)
|
Chris@233
|
5001 {
|
Chris@247
|
5002 emit hideSplash();
|
Chris@247
|
5003
|
Chris@233
|
5004 QMessageBox::warning
|
Chris@233
|
5005 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@233
|
5006 }
|
Chris@233
|
5007
|
Chris@233
|
5008 void
|
Chris@233
|
5009 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@233
|
5010 QString transformName, QString message)
|
Chris@233
|
5011 {
|
Chris@247
|
5012 emit hideSplash();
|
Chris@247
|
5013
|
Chris@233
|
5014 if (message != "") {
|
Chris@233
|
5015
|
Chris@233
|
5016 QMessageBox::warning
|
Chris@233
|
5017 (this,
|
Chris@233
|
5018 tr("Failed to regenerate layer"),
|
Chris@233
|
5019 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
|
5020 .arg(layerName).arg(transformName).arg(message),
|
Chris@233
|
5021 QMessageBox::Ok);
|
Chris@233
|
5022 } else {
|
Chris@233
|
5023 QMessageBox::warning
|
Chris@233
|
5024 (this,
|
Chris@233
|
5025 tr("Failed to regenerate layer"),
|
Chris@233
|
5026 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
|
5027 .arg(layerName).arg(transformName),
|
Chris@233
|
5028 QMessageBox::Ok);
|
Chris@233
|
5029 }
|
Chris@233
|
5030 }
|
Chris@233
|
5031
|
Chris@233
|
5032 void
|
Chris@233
|
5033 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@730
|
5034 QString /* transformName */,
|
Chris@730
|
5035 QString message)
|
Chris@233
|
5036 {
|
Chris@247
|
5037 emit hideSplash();
|
Chris@247
|
5038
|
Chris@233
|
5039 QMessageBox::warning
|
Chris@233
|
5040 (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
|
5041 }
|
Chris@233
|
5042
|
Chris@233
|
5043 void
|
Chris@1151
|
5044 MainWindow::alignmentFailed(QString message)
|
Chris@0
|
5045 {
|
Chris@0
|
5046 QMessageBox::warning
|
Chris@0
|
5047 (this,
|
Chris@233
|
5048 tr("Failed to calculate alignment"),
|
Chris@1151
|
5049 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment:<p>%1")
|
Chris@1151
|
5050 .arg(message),
|
Chris@165
|
5051 QMessageBox::Ok);
|
Chris@0
|
5052 }
|
Chris@0
|
5053
|
Chris@0
|
5054 void
|
Chris@2475
|
5055 MainWindow::paneRightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
5056 {
|
Chris@0
|
5057 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
5058 m_rightButtonMenu->popup(position);
|
Chris@0
|
5059 }
|
Chris@0
|
5060
|
Chris@2477
|
5061 #ifdef Q_OS_LINUX
|
Chris@2477
|
5062 #define MENU_LEFT_INDENT \
|
Chris@2477
|
5063 (m_viewManager->scalePixelSize(5) + \
|
Chris@2477
|
5064 2 * qApp->style()->pixelMetric(QStyle::PM_SmallIconSize))
|
Chris@2477
|
5065 #else
|
Chris@2477
|
5066 #ifdef Q_OS_WIN
|
Chris@2477
|
5067 #define MENU_LEFT_INDENT \
|
Chris@2477
|
5068 (9 + qApp->style()->pixelMetric(QStyle::PM_SmallIconSize))
|
Chris@2477
|
5069 #else
|
Chris@2478
|
5070 #define MENU_LEFT_INDENT 16
|
Chris@2477
|
5071 #endif
|
Chris@2477
|
5072 #endif
|
Chris@2477
|
5073
|
Chris@0
|
5074 void
|
Chris@2475
|
5075 MainWindow::panePropertiesRightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@2475
|
5076 {
|
Chris@2475
|
5077 if (m_lastRightButtonPropertyMenu) {
|
Chris@2475
|
5078 delete m_lastRightButtonPropertyMenu;
|
Chris@2475
|
5079 }
|
Chris@2475
|
5080
|
Chris@2475
|
5081 m_paneStack->setCurrentLayer(pane, nullptr);
|
Chris@2475
|
5082
|
Chris@2475
|
5083 QMenu *m = new QMenu;
|
Chris@2475
|
5084 IconLoader il;
|
Chris@2475
|
5085
|
Chris@2475
|
5086 QWidgetAction *wa = new QWidgetAction(m);
|
Chris@2475
|
5087 QLabel *title = new QLabel;
|
Chris@2475
|
5088 title->setText(tr("<b>Pane</b>"));
|
Chris@2476
|
5089 title->setMargin(m_viewManager->scalePixelSize(3));
|
Chris@2477
|
5090 title->setIndent(MENU_LEFT_INDENT);
|
Chris@2475
|
5091 wa->setDefaultWidget(title);
|
Chris@2475
|
5092 m->addAction(wa);
|
Chris@2475
|
5093
|
Chris@2475
|
5094 m->addSeparator();
|
Chris@2475
|
5095
|
Chris@2475
|
5096 // We repeat the setCurrentLayer call here just in case some
|
Chris@2475
|
5097 // unexpected UI interaction (scripting?) changes it while the
|
Chris@2475
|
5098 // menu is visible
|
Chris@2475
|
5099
|
Chris@2475
|
5100 m->addAction(il.load("editdelete"),
|
Chris@2475
|
5101 tr("&Delete Pane"),
|
Chris@2475
|
5102 [=]() {
|
Chris@2475
|
5103 m_paneStack->setCurrentLayer(pane, nullptr);
|
Chris@2475
|
5104 deleteCurrentPane();
|
Chris@2475
|
5105 });
|
Chris@2475
|
5106
|
Chris@2475
|
5107 m->popup(position);
|
Chris@2475
|
5108 m_lastRightButtonPropertyMenu = m;
|
Chris@2475
|
5109 }
|
Chris@2475
|
5110
|
Chris@2475
|
5111 void
|
Chris@2475
|
5112 MainWindow::layerPropertiesRightButtonMenuRequested(Pane *pane, Layer *layer, QPoint position)
|
Chris@2475
|
5113 {
|
Chris@2475
|
5114 if (m_lastRightButtonPropertyMenu) {
|
Chris@2475
|
5115 delete m_lastRightButtonPropertyMenu;
|
Chris@2475
|
5116 }
|
Chris@2475
|
5117
|
Chris@2475
|
5118 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@2475
|
5119
|
Chris@2475
|
5120 QMenu *m = new QMenu;
|
Chris@2475
|
5121 IconLoader il;
|
Chris@2475
|
5122
|
Chris@2475
|
5123 QWidgetAction *wa = new QWidgetAction(m);
|
Chris@2475
|
5124 QLabel *title = new QLabel;
|
Chris@2475
|
5125 title->setText
|
Chris@2475
|
5126 (tr("<b>%2</b>")
|
Chris@2475
|
5127 .arg(XmlExportable::encodeEntities
|
Chris@2475
|
5128 (layer->getLayerPresentationName())));
|
Chris@2476
|
5129 title->setMargin(m_viewManager->scalePixelSize(3));
|
Chris@2477
|
5130 title->setIndent(MENU_LEFT_INDENT);
|
Chris@2475
|
5131 wa->setDefaultWidget(title);
|
Chris@2475
|
5132 m->addAction(wa);
|
Chris@2475
|
5133
|
Chris@2475
|
5134 m->addSeparator();
|
Chris@2475
|
5135
|
Chris@2475
|
5136 // We repeat the setCurrentLayer calls here just in case some
|
Chris@2475
|
5137 // unexpected UI interaction (scripting?) changes it while the
|
Chris@2475
|
5138 // menu is visible
|
Chris@2475
|
5139
|
Chris@2475
|
5140 m->addAction(tr("&Rename Layer..."),
|
Chris@2475
|
5141 [=]() {
|
Chris@2475
|
5142 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@2475
|
5143 renameCurrentLayer();
|
Chris@2475
|
5144 });
|
Chris@2475
|
5145
|
Chris@2475
|
5146 m->addAction(tr("Edit Layer Data"),
|
Chris@2475
|
5147 [=]() {
|
Chris@2475
|
5148 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@2475
|
5149 editCurrentLayer();
|
Chris@2475
|
5150 })
|
Chris@2475
|
5151 ->setEnabled(layer->isLayerEditable());
|
Chris@2475
|
5152
|
Chris@2475
|
5153 m->addAction(il.load("editdelete"),
|
Chris@2475
|
5154 tr("&Delete Layer"),
|
Chris@2475
|
5155 [=]() {
|
Chris@2475
|
5156 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@2475
|
5157 deleteCurrentLayer();
|
Chris@2475
|
5158 });
|
Chris@2475
|
5159
|
Chris@2475
|
5160 m->popup(position);
|
Chris@2475
|
5161 m_lastRightButtonPropertyMenu = m;
|
Chris@2475
|
5162 }
|
Chris@2475
|
5163
|
Chris@2475
|
5164 void
|
Chris@0
|
5165 MainWindow::showLayerTree()
|
Chris@0
|
5166 {
|
Chris@219
|
5167 if (!m_layerTreeDialog.isNull()) {
|
Chris@219
|
5168 m_layerTreeDialog->show();
|
Chris@219
|
5169 m_layerTreeDialog->raise();
|
Chris@177
|
5170 return;
|
Chris@177
|
5171 }
|
Chris@177
|
5172
|
Chris@762
|
5173 m_layerTreeDialog = new LayerTreeDialog(m_paneStack, this);
|
Chris@232
|
5174 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
|
Chris@219
|
5175 m_layerTreeDialog->show();
|
Chris@0
|
5176 }
|
Chris@0
|
5177
|
Chris@0
|
5178 void
|
Chris@306
|
5179 MainWindow::showActivityLog()
|
Chris@306
|
5180 {
|
Chris@306
|
5181 m_activityLog->show();
|
Chris@306
|
5182 m_activityLog->raise();
|
Chris@306
|
5183 m_activityLog->scrollToEnd();
|
Chris@306
|
5184 }
|
Chris@306
|
5185
|
Chris@306
|
5186 void
|
Chris@891
|
5187 MainWindow::showUnitConverter()
|
Chris@891
|
5188 {
|
Chris@891
|
5189 m_unitConverter->show();
|
Chris@891
|
5190 m_unitConverter->raise();
|
Chris@891
|
5191 }
|
Chris@891
|
5192
|
Chris@891
|
5193 void
|
Chris@0
|
5194 MainWindow::preferences()
|
Chris@0
|
5195 {
|
Chris@436
|
5196 bool goToTemplateTab =
|
Chris@436
|
5197 (sender() && sender()->objectName() == "set_default_template");
|
Chris@436
|
5198
|
Chris@0
|
5199 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
5200 m_preferencesDialog->show();
|
Chris@0
|
5201 m_preferencesDialog->raise();
|
Chris@436
|
5202 if (goToTemplateTab) {
|
Chris@436
|
5203 m_preferencesDialog->switchToTab(PreferencesDialog::TemplateTab);
|
Chris@436
|
5204 }
|
Chris@0
|
5205 return;
|
Chris@0
|
5206 }
|
Chris@0
|
5207
|
Chris@0
|
5208 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
5209
|
Chris@1413
|
5210 connect(m_preferencesDialog, SIGNAL(audioDeviceChanged()),
|
Chris@1413
|
5211 this, SLOT(recreateAudioIO()));
|
Chris@1448
|
5212 connect(m_preferencesDialog, SIGNAL(coloursChanged()),
|
Chris@1448
|
5213 this, SLOT(coloursChanged()));
|
Chris@1413
|
5214
|
Chris@0
|
5215 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
5216 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
5217 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
5218 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
5219 // without resetting its own widgets, so its state will be
|
Chris@0
|
5220 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
5221 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
5222
|
Chris@0
|
5223 m_preferencesDialog->show();
|
Chris@436
|
5224 if (goToTemplateTab) {
|
Chris@436
|
5225 m_preferencesDialog->switchToTab(PreferencesDialog::TemplateTab);
|
Chris@436
|
5226 }
|
Chris@0
|
5227 }
|
Chris@0
|
5228
|
Chris@0
|
5229 void
|
Chris@90
|
5230 MainWindow::mouseEnteredWidget()
|
Chris@90
|
5231 {
|
Chris@90
|
5232 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
5233 if (!w) return;
|
Chris@90
|
5234
|
Chris@2079
|
5235 QString mainText, editText;
|
Chris@2079
|
5236
|
Chris@1386
|
5237 if (w == m_mainLevelPan) {
|
Chris@2079
|
5238 mainText = tr("Adjust the master playback level and pan");
|
Chris@2079
|
5239 editText = tr("click then drag to adjust, ctrl+click to reset");
|
Chris@90
|
5240 } else if (w == m_playSpeed) {
|
Chris@2079
|
5241 mainText = tr("Adjust the master playback speed");
|
Chris@2079
|
5242 editText = tr("drag up/down to adjust, ctrl+click to reset");
|
Chris@2079
|
5243 }
|
Chris@2079
|
5244
|
Chris@2079
|
5245 if (mainText != "") {
|
Chris@2079
|
5246 contextHelpChanged(tr("%1: %2").arg(mainText).arg(editText));
|
Chris@90
|
5247 }
|
Chris@90
|
5248 }
|
Chris@90
|
5249
|
Chris@90
|
5250 void
|
Chris@90
|
5251 MainWindow::mouseLeftWidget()
|
Chris@90
|
5252 {
|
Chris@116
|
5253 contextHelpChanged("");
|
Chris@116
|
5254 }
|
Chris@116
|
5255
|
Chris@116
|
5256 void
|
Chris@0
|
5257 MainWindow::website()
|
Chris@0
|
5258 {
|
Chris@0
|
5259 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
5260 }
|
Chris@0
|
5261
|
Chris@0
|
5262 void
|
Chris@0
|
5263 MainWindow::help()
|
Chris@0
|
5264 {
|
Chris@318
|
5265 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/%1/en/").arg(SV_VERSION));
|
Chris@0
|
5266 }
|
Chris@0
|
5267
|
Chris@0
|
5268 void
|
Chris@1516
|
5269 MainWindow::whatsNew()
|
Chris@1516
|
5270 {
|
Chris@1516
|
5271 QFile changelog(":CHANGELOG");
|
Chris@1516
|
5272 changelog.open(QFile::ReadOnly);
|
Chris@1516
|
5273 QByteArray content = changelog.readAll();
|
Chris@1516
|
5274 QString text = QString::fromUtf8(content);
|
Chris@1516
|
5275
|
Chris@1516
|
5276 QDialog *d = new QDialog(this);
|
Chris@1516
|
5277 d->setWindowTitle(tr("What's New"));
|
Chris@1516
|
5278
|
Chris@1516
|
5279 QGridLayout *layout = new QGridLayout;
|
Chris@1516
|
5280 d->setLayout(layout);
|
Chris@1516
|
5281
|
Chris@1516
|
5282 int row = 0;
|
Chris@1516
|
5283
|
Chris@1516
|
5284 QLabel *iconLabel = new QLabel;
|
Chris@1516
|
5285 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64));
|
Chris@1516
|
5286 layout->addWidget(iconLabel, row, 0);
|
Chris@1516
|
5287
|
Chris@1516
|
5288 layout->addWidget
|
Chris@1516
|
5289 (new QLabel(tr("<h3>What's New in %1</h3>")
|
Chris@1516
|
5290 .arg(QApplication::applicationName())),
|
Chris@1516
|
5291 row++, 1);
|
Chris@1516
|
5292 layout->setColumnStretch(2, 10);
|
Chris@1516
|
5293
|
Chris@1516
|
5294 QTextEdit *textEdit = new QTextEdit;
|
Chris@1516
|
5295 layout->addWidget(textEdit, row++, 1, 1, 2);
|
Chris@1516
|
5296
|
Chris@1516
|
5297 if (m_newerVersionIs != "") {
|
Chris@1516
|
5298 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
|
5299 }
|
Chris@1516
|
5300
|
Chris@1516
|
5301 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@1516
|
5302 layout->addWidget(bb, row++, 0, 1, 3);
|
Chris@1516
|
5303 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@1516
|
5304
|
Chris@2340
|
5305 // Remove spurious linefeeds from DOS line endings
|
Chris@2312
|
5306 text.replace('\r', "");
|
Chris@2340
|
5307
|
Chris@2340
|
5308 // Un-wrap indented paragraphs (assume they are always preceded by
|
Chris@2340
|
5309 // an empty line, so don't get merged into prior para)
|
Chris@1516
|
5310 text.replace(QRegExp("(.)\n +(.)"), "\\1 \\2");
|
Chris@2340
|
5311
|
Chris@2340
|
5312 // Rest of para following a " - " at start becomes bulleted entry
|
Chris@1516
|
5313 text.replace(QRegExp("\n - ([^\n]+)"), "\n<li>\\1</li>");
|
Chris@2340
|
5314
|
Chris@2340
|
5315 // Line-ending ":" introduces the bulleted list
|
Chris@1516
|
5316 text.replace(QRegExp(": *\n"), ":\n<ul>\n");
|
Chris@2340
|
5317
|
Chris@2340
|
5318 // Blank line (after unwrapping) ends the bulleted list
|
Chris@1516
|
5319 text.replace(QRegExp("</li>\n\\s*\n"), "</li>\n</ul>\n\n");
|
Chris@2340
|
5320
|
Chris@2340
|
5321 // Text leading up to that line-ending ":" becomes bold heading
|
Chris@1516
|
5322 text.replace(QRegExp("\n(\\w[^:\n]+:)"), "\n<p><b>\\1</b></p>");
|
Chris@1516
|
5323
|
Chris@1516
|
5324 textEdit->setHtml(text);
|
Chris@1516
|
5325 textEdit->setReadOnly(true);
|
Chris@1516
|
5326
|
cannam@1517
|
5327 d->setMinimumSize(m_viewManager->scalePixelSize(520),
|
cannam@1517
|
5328 m_viewManager->scalePixelSize(450));
|
Chris@1516
|
5329
|
Chris@1516
|
5330 d->exec();
|
Chris@1516
|
5331
|
Chris@1516
|
5332 delete d;
|
Chris@1516
|
5333 }
|
Chris@1516
|
5334
|
Chris@1610
|
5335 QString
|
Chris@1610
|
5336 MainWindow::getReleaseText() const
|
Chris@0
|
5337 {
|
Chris@0
|
5338 bool debug = false;
|
Chris@0
|
5339 QString version = "(unknown version)";
|
Chris@0
|
5340
|
Chris@0
|
5341 #ifdef BUILD_DEBUG
|
Chris@0
|
5342 debug = true;
|
Chris@285
|
5343 #endif // BUILD_DEBUG
|
Chris@0
|
5344 #ifdef SV_VERSION
|
Chris@0
|
5345 #ifdef SVNREV
|
Chris@0
|
5346 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@285
|
5347 #else // !SVNREV
|
Chris@0
|
5348 version = tr("Release %1").arg(SV_VERSION);
|
Chris@285
|
5349 #endif // SVNREV
|
Chris@285
|
5350 #else // !SV_VERSION
|
Chris@0
|
5351 #ifdef SVNREV
|
Chris@0
|
5352 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@285
|
5353 #endif // SVNREV
|
Chris@285
|
5354 #endif // SV_VERSION
|
Chris@0
|
5355
|
Chris@1610
|
5356 return tr("%1 : %2 configuration, %3-bit build")
|
Chris@0
|
5357 .arg(version)
|
Chris@1264
|
5358 .arg(debug ? tr("Debug") : tr("Release"))
|
Chris@1264
|
5359 .arg(sizeof(void *) * 8);
|
Chris@1610
|
5360 }
|
Chris@1610
|
5361
|
Chris@1610
|
5362 void
|
Chris@1610
|
5363 MainWindow::about()
|
Chris@1610
|
5364 {
|
Chris@1610
|
5365 QString aboutText;
|
Chris@1610
|
5366
|
Chris@1610
|
5367 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@1610
|
5368 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
|
5369 aboutText += QString("<p><small>%1</small></p>").arg(getReleaseText());
|
Chris@0
|
5370
|
Chris@1516
|
5371 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@1516
|
5372 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@1516
|
5373 }
|
Chris@1516
|
5374
|
Chris@1516
|
5375 aboutText += "</small><p><small>";
|
Chris@285
|
5376
|
Chris@1155
|
5377 aboutText += tr("With Qt v%1 © The Qt Company").arg(QT_VERSION_STR);
|
Chris@285
|
5378
|
Chris@1516
|
5379 aboutText += "</small><small>";
|
Chris@1516
|
5380
|
Chris@0
|
5381 #ifdef HAVE_JACK
|
Chris@93
|
5382 #ifdef JACK_VERSION
|
Chris@285
|
5383 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@285
|
5384 #else // !JACK_VERSION
|
Chris@257
|
5385 aboutText += tr("<br>With JACK audio output library © Paul Davis and Jack O'Quin");
|
Chris@285
|
5386 #endif // JACK_VERSION
|
Chris@285
|
5387 #endif // HAVE_JACK
|
Chris@0
|
5388 #ifdef HAVE_PORTAUDIO
|
Chris@257
|
5389 aboutText += tr("<br>With PortAudio audio output library © Ross Bencina and Phil Burk");
|
Chris@285
|
5390 #endif // HAVE_PORTAUDIO
|
Chris@257
|
5391 #ifdef HAVE_LIBPULSE
|
Chris@285
|
5392 #ifdef LIBPULSE_VERSION
|
Chris@285
|
5393 aboutText += tr("<br>With PulseAudio audio output library v%1 © Lennart Poettering and Pierre Ossman").arg(LIBPULSE_VERSION);
|
Chris@285
|
5394 #else // !LIBPULSE_VERSION
|
Chris@257
|
5395 aboutText += tr("<br>With PulseAudio audio output library © Lennart Poettering and Pierre Ossman");
|
Chris@285
|
5396 #endif // LIBPULSE_VERSION
|
Chris@285
|
5397 #endif // HAVE_LIBPULSE
|
Chris@0
|
5398 #ifdef HAVE_OGGZ
|
Chris@93
|
5399 #ifdef OGGZ_VERSION
|
Chris@0
|
5400 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@285
|
5401 #else // !OGGZ_VERSION
|
Chris@93
|
5402 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@285
|
5403 #endif // OGGZ_VERSION
|
Chris@285
|
5404 #endif // HAVE_OGGZ
|
Chris@2311
|
5405 #ifdef HAVE_OPUS
|
Chris@2311
|
5406 aboutText += tr("<br>With Opus decoder © Xiph.Org Foundation");
|
Chris@2311
|
5407 #endif // HAVE_OPUS
|
Chris@0
|
5408 #ifdef HAVE_MAD
|
Chris@93
|
5409 #ifdef MAD_VERSION
|
Chris@285
|
5410 aboutText += tr("<br>With MAD mp3 decoder v%1 © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@285
|
5411 #else // !MAD_VERSION
|
Chris@93
|
5412 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@285
|
5413 #endif // MAD_VERSION
|
Chris@285
|
5414 #endif // HAVE_MAD
|
Chris@0
|
5415 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
5416 #ifdef SAMPLERATE_VERSION
|
Chris@285
|
5417 aboutText += tr("<br>With libsamplerate v%1 © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@285
|
5418 #else // !SAMPLERATE_VERSION
|
Chris@93
|
5419 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@285
|
5420 #endif // SAMPLERATE_VERSION
|
Chris@285
|
5421 #endif // HAVE_SAMPLERATE
|
Chris@0
|
5422 #ifdef HAVE_SNDFILE
|
Chris@93
|
5423 #ifdef SNDFILE_VERSION
|
Chris@285
|
5424 aboutText += tr("<br>With libsndfile v%1 © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@285
|
5425 #else // !SNDFILE_VERSION
|
Chris@93
|
5426 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@285
|
5427 #endif // SNDFILE_VERSION
|
Chris@285
|
5428 #endif // HAVE_SNDFILE
|
Chris@127
|
5429 #ifdef HAVE_FFTW3F
|
Chris@93
|
5430 #ifdef FFTW3_VERSION
|
Chris@285
|
5431 aboutText += tr("<br>With FFTW3 v%1 © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@285
|
5432 #else // !FFTW3_VERSION
|
Chris@93
|
5433 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@285
|
5434 #endif // FFTW3_VERSION
|
Chris@285
|
5435 #endif // HAVE_FFTW3F
|
Chris@267
|
5436 #ifdef HAVE_RUBBERBAND
|
Chris@267
|
5437 #ifdef RUBBERBAND_VERSION
|
Chris@1315
|
5438 aboutText += tr("<br>With Rubber Band Library v%1 © Particular Programs Ltd").arg(RUBBERBAND_VERSION);
|
Chris@285
|
5439 #else // !RUBBERBAND_VERSION
|
Chris@1315
|
5440 aboutText += tr("<br>With Rubber Band Library © Particular Programs Ltd");
|
Chris@285
|
5441 #endif // RUBBERBAND_VERSION
|
Chris@285
|
5442 #endif // HAVE_RUBBERBAND
|
Chris@1315
|
5443 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
|
5444 aboutText += tr("<br>With Piper Vamp protocol bridge © QMUL");
|
Chris@0
|
5445 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
5446 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@285
|
5447 #ifdef REDLAND_VERSION
|
Chris@285
|
5448 aboutText += tr("<br>With Redland RDF datastore v%1 © Dave Beckett and the University of Bristol").arg(REDLAND_VERSION);
|
Chris@285
|
5449 #else // !REDLAND_VERSION
|
Chris@285
|
5450 aboutText += tr("<br>With Redland RDF datastore © Dave Beckett and the University of Bristol");
|
Chris@285
|
5451 #endif // REDLAND_VERSION
|
Chris@523
|
5452 aboutText += tr("<br>With Serd and Sord RDF parser and store © David Robillard");
|
Chris@1315
|
5453 aboutText += tr("<br>With Dataquay Qt/RDF library © Particular Programs Ltd");
|
Chris@1315
|
5454 aboutText += tr("<br>With Cap'n Proto serialisation © Sandstorm Development Group");
|
Chris@300
|
5455 aboutText += tr("<br>With RtMidi © Gary P. Scavone");
|
Chris@300
|
5456
|
Chris@69
|
5457 #ifdef HAVE_LIBLO
|
Chris@93
|
5458 #ifdef LIBLO_VERSION
|
Chris@285
|
5459 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
5460 #else // !LIBLO_VERSION
|
Chris@327
|
5461 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris");
|
Chris@285
|
5462 #endif // LIBLO_VERSION
|
Chris@285
|
5463
|
Chris@285
|
5464 aboutText += "</small></p>";
|
Chris@285
|
5465 #endif // HAVE_LIBLO
|
Chris@285
|
5466
|
Chris@1667
|
5467 aboutText += "<p><small>";
|
Chris@1667
|
5468 aboutText += tr("Russian UI translation contributed by Alexandre Prokoudine.");
|
Chris@1667
|
5469 aboutText += "<br>";
|
Chris@1667
|
5470 aboutText += tr("Czech UI translation contributed by Pavel Fric.");
|
Chris@1667
|
5471 aboutText += "</small></p>";
|
Chris@1667
|
5472
|
Chris@0
|
5473 aboutText +=
|
Chris@2178
|
5474 "<p><small>Sonic Visualiser Copyright © 2005–2019 Chris Cannam and "
|
Chris@1667
|
5475 "Queen Mary, University of London.</small></p>";
|
Chris@1667
|
5476
|
Chris@1667
|
5477 aboutText +=
|
Chris@285
|
5478 "<p><small>This program is free software; you can redistribute it and/or "
|
Chris@231
|
5479 "modify it under the terms of the GNU General Public License as "
|
Chris@231
|
5480 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
5481 "License, or (at your option) any later version.<br>See the file "
|
Chris@285
|
5482 "COPYING included with this distribution for more information.</small></p>";
|
Chris@1516
|
5483
|
Chris@1516
|
5484 // use our own dialog so we can influence the size
|
Chris@1516
|
5485
|
Chris@1516
|
5486 QDialog *d = new QDialog(this);
|
Chris@1516
|
5487
|
Chris@1516
|
5488 d->setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
|
Chris@1516
|
5489
|
Chris@1516
|
5490 QGridLayout *layout = new QGridLayout;
|
Chris@1516
|
5491 d->setLayout(layout);
|
Chris@1516
|
5492
|
Chris@1516
|
5493 int row = 0;
|
Chris@0
|
5494
|
Chris@1516
|
5495 QLabel *iconLabel = new QLabel;
|
Chris@1516
|
5496 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64));
|
Chris@1516
|
5497 layout->addWidget(iconLabel, row, 0, Qt::AlignTop);
|
Chris@1516
|
5498
|
Chris@1516
|
5499 QLabel *mainText = new QLabel();
|
Chris@1516
|
5500 layout->addWidget(mainText, row, 1, 1, 2);
|
Chris@1516
|
5501
|
Chris@1516
|
5502 layout->setRowStretch(row, 10);
|
Chris@1516
|
5503 layout->setColumnStretch(1, 10);
|
Chris@1516
|
5504
|
Chris@1516
|
5505 ++row;
|
Chris@1516
|
5506
|
Chris@1516
|
5507 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@1516
|
5508 layout->addWidget(bb, row++, 0, 1, 3);
|
Chris@1516
|
5509 connect(bb, SIGNAL(accepted()), d, SLOT(accept()));
|
Chris@1516
|
5510
|
Chris@1516
|
5511 // mainText->setHtml(aboutText);
|
Chris@1516
|
5512 // mainText->setReadOnly(true);
|
Chris@1516
|
5513 mainText->setWordWrap(true);
|
Chris@1516
|
5514 mainText->setOpenExternalLinks(true);
|
Chris@1516
|
5515 mainText->setText(aboutText);
|
Chris@1516
|
5516
|
Chris@1516
|
5517 d->setMinimumSize(m_viewManager->scalePixelSize(420),
|
Chris@1516
|
5518 m_viewManager->scalePixelSize(200));
|
Chris@1516
|
5519
|
Chris@1516
|
5520 d->exec();
|
Chris@1516
|
5521
|
Chris@1516
|
5522 delete d;
|
Chris@1516
|
5523 /*
|
Chris@1516
|
5524 QMessageBox about(QMessageBox::Information,
|
Chris@1516
|
5525 tr("About Sonic Visualiser"),
|
Chris@1516
|
5526 aboutText,
|
Chris@1516
|
5527 QMessageBox::StandardButtons(QMessageBox::Ok),
|
Chris@1516
|
5528 this);
|
Chris@1516
|
5529
|
Chris@1516
|
5530 QIcon icon = QApplication::windowIcon();
|
Chris@1516
|
5531 QSize size = icon.actualSize(QSize(64, 64));
|
Chris@1516
|
5532 about.setIconPixmap(icon.pixmap(size));
|
Chris@1516
|
5533
|
Chris@1516
|
5534 about.setMinimumSize(m_viewManager->scalePixelSize(400),
|
Chris@1516
|
5535 m_viewManager->scalePixelSize(400));
|
Chris@1516
|
5536
|
Chris@1516
|
5537 about.exec();
|
Chris@1516
|
5538 */
|
Chris@0
|
5539 }
|
Chris@0
|
5540
|
Chris@162
|
5541 void
|
Chris@162
|
5542 MainWindow::keyReference()
|
Chris@162
|
5543 {
|
Chris@162
|
5544 m_keyReference->show();
|
Chris@162
|
5545 }
|
Chris@162
|
5546
|
Chris@333
|
5547 void
|
Chris@333
|
5548 MainWindow::newerVersionAvailable(QString version)
|
Chris@333
|
5549 {
|
Chris@1516
|
5550 m_newerVersionIs = version;
|
Chris@1516
|
5551
|
Chris@334
|
5552 QSettings settings;
|
Chris@334
|
5553 settings.beginGroup("NewerVersionWarning");
|
Chris@334
|
5554 QString tag = QString("version-%1-available-show").arg(version);
|
Chris@334
|
5555 if (settings.value(tag, true).toBool()) {
|
Chris@334
|
5556 QString title(tr("Newer version available"));
|
Chris@663
|
5557 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
|
5558 QMessageBox::information(this, title, text);
|
Chris@334
|
5559 settings.setValue(tag, false);
|
Chris@334
|
5560 }
|
Chris@334
|
5561 settings.endGroup();
|
Chris@333
|
5562 }
|
Chris@333
|
5563
|
Chris@333
|
5564
|