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