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