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