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