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@185
|
25 #include "data/model/NoteModel.h"
|
Chris@189
|
26 #include "data/model/Labeller.h"
|
Chris@222
|
27 #include "data/osc/OSCQueue.h"
|
Chris@216
|
28 #include "framework/Document.h"
|
Chris@1
|
29 #include "view/ViewManager.h"
|
Chris@0
|
30 #include "base/Preferences.h"
|
Chris@0
|
31 #include "layer/WaveformLayer.h"
|
Chris@0
|
32 #include "layer/TimeRulerLayer.h"
|
Chris@0
|
33 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
34 #include "layer/TimeValueLayer.h"
|
Chris@0
|
35 #include "layer/Colour3DPlotLayer.h"
|
Chris@95
|
36 #include "layer/SliceLayer.h"
|
Chris@95
|
37 #include "layer/SliceableLayer.h"
|
Chris@193
|
38 #include "layer/ImageLayer.h"
|
Chris@0
|
39 #include "widgets/Fader.h"
|
Chris@65
|
40 #include "view/Overview.h"
|
Chris@0
|
41 #include "widgets/PropertyBox.h"
|
Chris@0
|
42 #include "widgets/PropertyStack.h"
|
Chris@0
|
43 #include "widgets/AudioDial.h"
|
Chris@168
|
44 #include "widgets/IconLoader.h"
|
Chris@219
|
45 #include "widgets/LayerTreeDialog.h"
|
Chris@0
|
46 #include "widgets/ListInputDialog.h"
|
Chris@36
|
47 #include "widgets/SubdividingMenu.h"
|
Chris@90
|
48 #include "widgets/NotifyingPushButton.h"
|
Chris@162
|
49 #include "widgets/KeyReference.h"
|
Chris@273
|
50 #include "widgets/TransformFinder.h"
|
Chris@192
|
51 #include "widgets/LabelCounterInputDialog.h"
|
Chris@302
|
52 #include "widgets/ActivityLog.h"
|
Chris@0
|
53 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
54 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
55 #include "audioio/AudioTargetFactory.h"
|
Chris@59
|
56 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@1
|
57 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@180
|
58 #include "data/fileio/PlaylistFileReader.h"
|
Chris@1
|
59 #include "data/fileio/WavFileWriter.h"
|
Chris@1
|
60 #include "data/fileio/CSVFileWriter.h"
|
Chris@185
|
61 #include "data/fileio/MIDIFileWriter.h"
|
Chris@1
|
62 #include "data/fileio/BZipFileDevice.h"
|
Chris@198
|
63 #include "data/fileio/FileSource.h"
|
Chris@91
|
64 #include "data/fft/FFTDataServer.h"
|
Chris@304
|
65 #include "data/midi/MIDIInput.h"
|
Chris@1
|
66 #include "base/RecentFiles.h"
|
Chris@249
|
67 #include "transform/TransformFactory.h"
|
Chris@249
|
68 #include "transform/ModelTransformerFactory.h"
|
Chris@0
|
69 #include "base/PlayParameterRepository.h"
|
Chris@0
|
70 #include "base/XmlExportable.h"
|
Chris@248
|
71 #include "widgets/CommandHistory.h"
|
Chris@0
|
72 #include "base/Profiler.h"
|
Chris@0
|
73 #include "base/Clipboard.h"
|
Chris@165
|
74 #include "base/UnitDatabase.h"
|
Chris@248
|
75 #include "layer/ColourDatabase.h"
|
Chris@265
|
76 #include "widgets/ModelDataTableDialog.h"
|
Chris@289
|
77 #include "rdf/PluginRDFIndexer.h"
|
Chris@291
|
78 #include "rdf/RDFExporter.h"
|
Chris@276
|
79
|
Chris@0
|
80 // For version information
|
Chris@280
|
81 #include <vamp/vamp.h>
|
Chris@280
|
82 #include <vamp-hostsdk/PluginBase.h>
|
Chris@0
|
83 #include "plugin/api/ladspa.h"
|
Chris@0
|
84 #include "plugin/api/dssi.h"
|
Chris@0
|
85
|
Chris@0
|
86 #include <QApplication>
|
Chris@0
|
87 #include <QMessageBox>
|
Chris@0
|
88 #include <QGridLayout>
|
Chris@0
|
89 #include <QLabel>
|
Chris@0
|
90 #include <QAction>
|
Chris@0
|
91 #include <QMenuBar>
|
Chris@0
|
92 #include <QToolBar>
|
Chris@0
|
93 #include <QInputDialog>
|
Chris@0
|
94 #include <QStatusBar>
|
Chris@0
|
95 #include <QTreeView>
|
Chris@0
|
96 #include <QFile>
|
Chris@88
|
97 #include <QFileInfo>
|
Chris@88
|
98 #include <QDir>
|
Chris@0
|
99 #include <QTextStream>
|
Chris@0
|
100 #include <QProcess>
|
Chris@7
|
101 #include <QShortcut>
|
Chris@5
|
102 #include <QSettings>
|
Chris@11
|
103 #include <QDateTime>
|
Chris@11
|
104 #include <QProcess>
|
Chris@16
|
105 #include <QCheckBox>
|
Chris@55
|
106 #include <QRegExp>
|
Chris@158
|
107 #include <QScrollArea>
|
Chris@0
|
108
|
Chris@0
|
109 #include <iostream>
|
Chris@0
|
110 #include <cstdio>
|
Chris@0
|
111 #include <errno.h>
|
Chris@0
|
112
|
Chris@0
|
113 using std::cerr;
|
Chris@0
|
114 using std::endl;
|
Chris@0
|
115
|
Chris@33
|
116 using std::vector;
|
Chris@33
|
117 using std::map;
|
Chris@33
|
118 using std::set;
|
Chris@33
|
119
|
Chris@0
|
120
|
Chris@70
|
121 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@305
|
122 MainWindowBase(withAudioOutput, withOSCSupport, true),
|
Chris@65
|
123 m_overview(0),
|
Chris@0
|
124 m_mainMenusCreated(false),
|
Chris@0
|
125 m_paneMenu(0),
|
Chris@0
|
126 m_layerMenu(0),
|
Chris@34
|
127 m_transformsMenu(0),
|
Chris@155
|
128 m_playbackMenu(0),
|
Chris@0
|
129 m_existingLayersMenu(0),
|
Chris@95
|
130 m_sliceMenu(0),
|
Chris@34
|
131 m_recentFilesMenu(0),
|
Chris@211
|
132 m_recentTransformsMenu(0),
|
Chris@0
|
133 m_rightButtonMenu(0),
|
Chris@0
|
134 m_rightButtonLayerMenu(0),
|
Chris@211
|
135 m_rightButtonTransformsMenu(0),
|
Chris@155
|
136 m_rightButtonPlaybackMenu(0),
|
Chris@207
|
137 m_soloAction(0),
|
Chris@207
|
138 m_soloModified(false),
|
Chris@207
|
139 m_prevSolo(false),
|
Chris@305
|
140 m_lastInsertedMIDITime(0),
|
Chris@265
|
141 m_rwdStartAction(0),
|
Chris@265
|
142 m_rwdAction(0),
|
Chris@155
|
143 m_ffwdAction(0),
|
Chris@265
|
144 m_ffwdEndAction(0),
|
Chris@265
|
145 m_playAction(0),
|
Chris@265
|
146 m_playSelectionAction(0),
|
Chris@265
|
147 m_playLoopAction(0),
|
Chris@239
|
148 m_playControlsSpacer(0),
|
Chris@239
|
149 m_playControlsWidth(0),
|
Chris@162
|
150 m_preferencesDialog(0),
|
Chris@219
|
151 m_layerTreeDialog(0),
|
Chris@302
|
152 m_activityLog(new ActivityLog()),
|
Chris@162
|
153 m_keyReference(new KeyReference())
|
Chris@0
|
154 {
|
Chris@253
|
155 Profiler profiler("MainWindow::MainWindow");
|
Chris@253
|
156
|
Chris@0
|
157 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
158
|
Chris@165
|
159 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@165
|
160 udb->registerUnit("Hz");
|
Chris@165
|
161 udb->registerUnit("dB");
|
Chris@165
|
162 udb->registerUnit("s");
|
Chris@165
|
163
|
Chris@165
|
164 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@165
|
165 cdb->addColour(Qt::black, tr("Black"));
|
Chris@165
|
166 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@165
|
167 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@165
|
168 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@165
|
169 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@165
|
170 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@166
|
171 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@166
|
172 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@166
|
173 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@166
|
174 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@166
|
175 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@166
|
176 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
177
|
Chris@0
|
178 QFrame *frame = new QFrame;
|
Chris@0
|
179 setCentralWidget(frame);
|
Chris@0
|
180
|
Chris@0
|
181 QGridLayout *layout = new QGridLayout;
|
Chris@180
|
182
|
Chris@205
|
183 m_descriptionLabel = new QLabel; //!!! hang on, this is declared in base class -- should be declared and initialised by same class
|
Chris@0
|
184
|
Chris@158
|
185 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@158
|
186 scroll->setWidgetResizable(true);
|
Chris@158
|
187 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@159
|
188 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@159
|
189
|
Chris@159
|
190 scroll->setWidget(m_paneStack);
|
Chris@159
|
191
|
Chris@65
|
192 m_overview = new Overview(frame);
|
Chris@65
|
193 m_overview->setViewManager(m_viewManager);
|
Chris@65
|
194 m_overview->setFixedHeight(40);
|
Chris@144
|
195 #ifndef _WIN32
|
Chris@144
|
196 // For some reason, the contents of the overview never appear if we
|
Chris@144
|
197 // make this setting on Windows. I have no inclination at the moment
|
Chris@144
|
198 // to track down the reason why.
|
Chris@129
|
199 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@144
|
200 #endif
|
Chris@90
|
201 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
202 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
203
|
Chris@0
|
204 m_panLayer = new WaveformLayer;
|
Chris@0
|
205 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
206 m_panLayer->setAggressiveCacheing(true);
|
Chris@65
|
207 m_overview->addLayer(m_panLayer);
|
Chris@174
|
208
|
Chris@174
|
209 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@174
|
210 m_panLayer->setBaseColour
|
Chris@174
|
211 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@174
|
212 } else {
|
Chris@174
|
213 m_panLayer->setBaseColour
|
Chris@174
|
214 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
|
Chris@200
|
215 }
|
Chris@0
|
216
|
Chris@0
|
217 m_fader = new Fader(frame, false);
|
Chris@90
|
218 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
219 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
220
|
Chris@0
|
221 m_playSpeed = new AudioDial(frame);
|
Chris@12
|
222 m_playSpeed->setMinimum(0);
|
Chris@48
|
223 m_playSpeed->setMaximum(200);
|
Chris@25
|
224 m_playSpeed->setValue(100);
|
Chris@261
|
225 m_playSpeed->setFixedWidth(32);
|
Chris@261
|
226 m_playSpeed->setFixedHeight(32);
|
Chris@0
|
227 m_playSpeed->setNotchesVisible(true);
|
Chris@25
|
228 m_playSpeed->setPageStep(10);
|
Chris@60
|
229 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@25
|
230 m_playSpeed->setDefaultValue(100);
|
Chris@59
|
231 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@60
|
232 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
233 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
Chris@0
|
234 this, SLOT(playSpeedChanged(int)));
|
Chris@90
|
235 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@90
|
236 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@90
|
237
|
Chris@168
|
238 IconLoader il;
|
Chris@168
|
239
|
Chris@21
|
240 QSettings settings;
|
Chris@21
|
241 settings.beginGroup("MainWindow");
|
Chris@21
|
242 settings.endGroup();
|
Chris@21
|
243
|
Chris@239
|
244 m_playControlsSpacer = new QFrame;
|
Chris@239
|
245
|
Chris@129
|
246 layout->setSpacing(4);
|
Chris@159
|
247 layout->addWidget(scroll, 0, 0, 1, 5);
|
Chris@239
|
248 layout->addWidget(m_overview, 1, 1);
|
Chris@239
|
249 layout->addWidget(m_playControlsSpacer, 1, 2);
|
Chris@239
|
250 layout->addWidget(m_playSpeed, 1, 3);
|
Chris@239
|
251 layout->addWidget(m_fader, 1, 4);
|
Chris@239
|
252
|
Chris@239
|
253 m_playControlsWidth =
|
Chris@240
|
254 m_fader->width() + m_playSpeed->width() + layout->spacing() * 2;
|
Chris@239
|
255
|
Chris@239
|
256 layout->setColumnMinimumWidth(0, 14);
|
Chris@239
|
257 layout->setColumnStretch(0, 0);
|
Chris@239
|
258
|
Chris@239
|
259 m_paneStack->setPropertyStackMinWidth(m_playControlsWidth
|
Chris@239
|
260 + 2 + layout->spacing());
|
Chris@239
|
261 m_playControlsSpacer->setFixedSize(QSize(2, 2));
|
Chris@239
|
262
|
Chris@239
|
263 layout->setColumnStretch(1, 10);
|
Chris@239
|
264
|
Chris@239
|
265 connect(m_paneStack, SIGNAL(propertyStacksResized(int)),
|
Chris@239
|
266 this, SLOT(propertyStacksResized(int)));
|
Chris@16
|
267
|
Chris@0
|
268 frame->setLayout(layout);
|
Chris@0
|
269
|
Chris@0
|
270 setupMenus();
|
Chris@0
|
271 setupToolbars();
|
Chris@155
|
272 setupHelpMenu();
|
Chris@0
|
273
|
Chris@90
|
274 statusBar();
|
Chris@0
|
275
|
Chris@302
|
276 connect(m_viewManager, SIGNAL(activity(QString)),
|
Chris@302
|
277 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
278 connect(m_playSource, SIGNAL(activity(QString)),
|
Chris@302
|
279 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@302
|
280 connect(CommandHistory::getInstance(), SIGNAL(activity(QString)),
|
Chris@302
|
281 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
282 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
|
Chris@303
|
283
|
Chris@303
|
284 newSession();
|
Chris@303
|
285
|
Chris@302
|
286 m_activityLog->show();
|
Chris@304
|
287
|
Chris@304
|
288 connect(m_midiInput, SIGNAL(eventsAvailable()),
|
Chris@304
|
289 this, SLOT(midiEventsAvailable()));
|
Chris@281
|
290
|
Chris@283
|
291 TransformFactory::getInstance()->startPopulationThread();
|
Chris@0
|
292 }
|
Chris@0
|
293
|
Chris@0
|
294 MainWindow::~MainWindow()
|
Chris@0
|
295 {
|
Chris@162
|
296 delete m_keyReference;
|
Chris@163
|
297 delete m_preferencesDialog;
|
Chris@219
|
298 delete m_layerTreeDialog;
|
Chris@0
|
299 Profiles::getInstance()->dump();
|
Chris@0
|
300 }
|
Chris@0
|
301
|
Chris@81
|
302 void
|
Chris@0
|
303 MainWindow::setupMenus()
|
Chris@0
|
304 {
|
Chris@0
|
305 if (!m_mainMenusCreated) {
|
Chris@0
|
306 m_rightButtonMenu = new QMenu();
|
Chris@104
|
307
|
Chris@104
|
308 // No -- we don't want tear-off enabled on the right-button
|
Chris@104
|
309 // menu. If it is enabled, then simply right-clicking and
|
Chris@104
|
310 // releasing will pop up the menu, activate the tear-off, and
|
Chris@104
|
311 // leave the torn-off menu window in front of the main window.
|
Chris@104
|
312 // That isn't desirable. I'm not sure it ever would be, in a
|
Chris@104
|
313 // context menu -- perhaps technically a Qt bug?
|
Chris@104
|
314 // m_rightButtonMenu->setTearOffEnabled(true);
|
Chris@0
|
315 }
|
Chris@0
|
316
|
Chris@0
|
317 if (m_rightButtonLayerMenu) {
|
Chris@0
|
318 m_rightButtonLayerMenu->clear();
|
Chris@0
|
319 } else {
|
Chris@0
|
320 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
|
Chris@97
|
321 m_rightButtonLayerMenu->setTearOffEnabled(true);
|
Chris@0
|
322 m_rightButtonMenu->addSeparator();
|
Chris@0
|
323 }
|
Chris@0
|
324
|
Chris@211
|
325 if (m_rightButtonTransformsMenu) {
|
Chris@211
|
326 m_rightButtonTransformsMenu->clear();
|
Chris@34
|
327 } else {
|
Chris@211
|
328 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform"));
|
Chris@211
|
329 m_rightButtonTransformsMenu->setTearOffEnabled(true);
|
Chris@34
|
330 m_rightButtonMenu->addSeparator();
|
Chris@34
|
331 }
|
Chris@34
|
332
|
Chris@0
|
333 if (!m_mainMenusCreated) {
|
Chris@0
|
334 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
335 m_rightButtonMenu->addSeparator();
|
Chris@66
|
336 }
|
Chris@66
|
337
|
Chris@66
|
338 setupFileMenu();
|
Chris@66
|
339 setupEditMenu();
|
Chris@66
|
340 setupViewMenu();
|
Chris@66
|
341 setupPaneAndLayerMenus();
|
Chris@211
|
342 setupTransformsMenu();
|
Chris@66
|
343
|
Chris@66
|
344 m_mainMenusCreated = true;
|
Chris@66
|
345 }
|
Chris@66
|
346
|
Chris@66
|
347 void
|
Chris@66
|
348 MainWindow::setupFileMenu()
|
Chris@66
|
349 {
|
Chris@66
|
350 if (m_mainMenusCreated) return;
|
Chris@66
|
351
|
Chris@66
|
352 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@97
|
353 menu->setTearOffEnabled(true);
|
Chris@66
|
354 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@66
|
355
|
Chris@162
|
356 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@162
|
357
|
Chris@168
|
358 IconLoader il;
|
Chris@168
|
359
|
Chris@168
|
360 QIcon icon = il.load("filenew");
|
Chris@168
|
361 icon.addPixmap(il.loadPixmap("filenew-22"));
|
Chris@66
|
362 QAction *action = new QAction(icon, tr("&New Session"), this);
|
Chris@66
|
363 action->setShortcut(tr("Ctrl+N"));
|
Chris@90
|
364 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one"));
|
Chris@66
|
365 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
|
Chris@162
|
366 m_keyReference->registerShortcut(action);
|
Chris@66
|
367 menu->addAction(action);
|
Chris@66
|
368 toolbar->addAction(action);
|
Chris@138
|
369
|
Chris@168
|
370 icon = il.load("fileopensession");
|
Chris@66
|
371 action = new QAction(icon, tr("&Open Session..."), this);
|
Chris@66
|
372 action->setShortcut(tr("Ctrl+O"));
|
Chris@66
|
373 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file"));
|
Chris@66
|
374 connect(action, SIGNAL(triggered()), this, SLOT(openSession()));
|
Chris@162
|
375 m_keyReference->registerShortcut(action);
|
Chris@66
|
376 menu->addAction(action);
|
Chris@66
|
377
|
Chris@168
|
378 icon = il.load("fileopen");
|
Chris@168
|
379 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@138
|
380
|
Chris@66
|
381 action = new QAction(icon, tr("&Open..."), this);
|
Chris@66
|
382 action->setStatusTip(tr("Open a session file, audio file, or layer"));
|
Chris@66
|
383 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
|
Chris@66
|
384 toolbar->addAction(action);
|
Chris@66
|
385
|
Chris@168
|
386 icon = il.load("filesave");
|
Chris@168
|
387 icon.addPixmap(il.loadPixmap("filesave-22"));
|
Chris@66
|
388 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@66
|
389 action->setShortcut(tr("Ctrl+S"));
|
Chris@66
|
390 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file"));
|
Chris@66
|
391 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@66
|
392 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
393 m_keyReference->registerShortcut(action);
|
Chris@66
|
394 menu->addAction(action);
|
Chris@66
|
395 toolbar->addAction(action);
|
Chris@0
|
396
|
Chris@168
|
397 icon = il.load("filesaveas");
|
Chris@168
|
398 icon.addPixmap(il.loadPixmap("filesaveas-22"));
|
Chris@66
|
399 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@66
|
400 action->setStatusTip(tr("Save the current session into a new Sonic Visualiser session file"));
|
Chris@66
|
401 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@66
|
402 menu->addAction(action);
|
Chris@66
|
403 toolbar->addAction(action);
|
Chris@66
|
404
|
Chris@66
|
405 menu->addSeparator();
|
Chris@66
|
406
|
Chris@168
|
407 icon = il.load("fileopenaudio");
|
Chris@138
|
408 action = new QAction(icon, tr("&Import Audio File..."), this);
|
Chris@66
|
409 action->setShortcut(tr("Ctrl+I"));
|
Chris@66
|
410 action->setStatusTip(tr("Import an existing audio file"));
|
Chris@66
|
411 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
|
Chris@162
|
412 m_keyReference->registerShortcut(action);
|
Chris@66
|
413 menu->addAction(action);
|
Chris@66
|
414
|
Chris@66
|
415 action = new QAction(tr("Import Secondary Audio File..."), this);
|
Chris@66
|
416 action->setShortcut(tr("Ctrl+Shift+I"));
|
Chris@66
|
417 action->setStatusTip(tr("Import an extra audio file as a separate layer"));
|
Chris@66
|
418 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
|
Chris@66
|
419 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
420 m_keyReference->registerShortcut(action);
|
Chris@66
|
421 menu->addAction(action);
|
Chris@66
|
422
|
Chris@66
|
423 action = new QAction(tr("&Export Audio File..."), this);
|
Chris@66
|
424 action->setStatusTip(tr("Export selection as an audio file"));
|
Chris@66
|
425 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
|
Chris@66
|
426 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
427 menu->addAction(action);
|
Chris@66
|
428
|
Chris@66
|
429 menu->addSeparator();
|
Chris@66
|
430
|
Chris@66
|
431 action = new QAction(tr("Import Annotation &Layer..."), this);
|
Chris@66
|
432 action->setShortcut(tr("Ctrl+L"));
|
Chris@66
|
433 action->setStatusTip(tr("Import layer data from an existing file"));
|
Chris@66
|
434 connect(action, SIGNAL(triggered()), this, SLOT(importLayer()));
|
Chris@66
|
435 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
436 m_keyReference->registerShortcut(action);
|
Chris@66
|
437 menu->addAction(action);
|
Chris@66
|
438
|
Chris@66
|
439 action = new QAction(tr("Export Annotation Layer..."), this);
|
Chris@66
|
440 action->setStatusTip(tr("Export layer data to a file"));
|
Chris@66
|
441 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer()));
|
Chris@66
|
442 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
443 menu->addAction(action);
|
Chris@66
|
444
|
Chris@66
|
445 menu->addSeparator();
|
Chris@86
|
446
|
Chris@121
|
447 action = new QAction(tr("Export Image File..."), this);
|
Chris@121
|
448 action->setStatusTip(tr("Export a single pane to an image file"));
|
Chris@121
|
449 connect(action, SIGNAL(triggered()), this, SLOT(exportImage()));
|
Chris@121
|
450 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
|
Chris@121
|
451 menu->addAction(action);
|
Chris@121
|
452
|
Chris@121
|
453 menu->addSeparator();
|
Chris@121
|
454
|
Chris@86
|
455 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@86
|
456 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@86
|
457 action->setStatusTip(tr("Open or import a file from a remote URL"));
|
Chris@86
|
458 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@162
|
459 m_keyReference->registerShortcut(action);
|
Chris@86
|
460 menu->addAction(action);
|
Chris@86
|
461
|
Chris@86
|
462 menu->addSeparator();
|
Chris@86
|
463
|
Chris@66
|
464 m_recentFilesMenu = menu->addMenu(tr("&Recent Files"));
|
Chris@97
|
465 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@66
|
466 setupRecentFilesMenu();
|
Chris@66
|
467 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@66
|
468 this, SLOT(setupRecentFilesMenu()));
|
Chris@66
|
469
|
Chris@66
|
470 menu->addSeparator();
|
Chris@66
|
471 action = new QAction(tr("&Preferences..."), this);
|
Chris@66
|
472 action->setStatusTip(tr("Adjust the application preferences"));
|
Chris@66
|
473 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
|
Chris@66
|
474 menu->addAction(action);
|
Chris@0
|
475
|
Chris@66
|
476 menu->addSeparator();
|
Chris@168
|
477 action = new QAction(il.load("exit"),
|
Chris@66
|
478 tr("&Quit"), this);
|
Chris@66
|
479 action->setShortcut(tr("Ctrl+Q"));
|
Chris@90
|
480 action->setStatusTip(tr("Exit Sonic Visualiser"));
|
Chris@66
|
481 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@162
|
482 m_keyReference->registerShortcut(action);
|
Chris@66
|
483 menu->addAction(action);
|
Chris@66
|
484 }
|
Chris@66
|
485
|
Chris@66
|
486 void
|
Chris@66
|
487 MainWindow::setupEditMenu()
|
Chris@66
|
488 {
|
Chris@66
|
489 if (m_mainMenusCreated) return;
|
Chris@66
|
490
|
Chris@66
|
491 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@97
|
492 menu->setTearOffEnabled(true);
|
Chris@66
|
493 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@66
|
494
|
Chris@162
|
495 m_keyReference->setCategory(tr("Editing"));
|
Chris@162
|
496
|
Chris@66
|
497 menu->addSeparator();
|
Chris@66
|
498
|
Chris@168
|
499 IconLoader il;
|
Chris@168
|
500
|
Chris@168
|
501 QAction *action = new QAction(il.load("editcut"),
|
Chris@66
|
502 tr("Cu&t"), this);
|
Chris@66
|
503 action->setShortcut(tr("Ctrl+X"));
|
Chris@90
|
504 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard"));
|
Chris@66
|
505 connect(action, SIGNAL(triggered()), this, SLOT(cut()));
|
Chris@66
|
506 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
507 m_keyReference->registerShortcut(action);
|
Chris@66
|
508 menu->addAction(action);
|
Chris@66
|
509 m_rightButtonMenu->addAction(action);
|
Chris@66
|
510
|
Chris@168
|
511 action = new QAction(il.load("editcopy"),
|
Chris@66
|
512 tr("&Copy"), this);
|
Chris@66
|
513 action->setShortcut(tr("Ctrl+C"));
|
Chris@90
|
514 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard"));
|
Chris@66
|
515 connect(action, SIGNAL(triggered()), this, SLOT(copy()));
|
Chris@66
|
516 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
517 m_keyReference->registerShortcut(action);
|
Chris@66
|
518 menu->addAction(action);
|
Chris@66
|
519 m_rightButtonMenu->addAction(action);
|
Chris@66
|
520
|
Chris@168
|
521 action = new QAction(il.load("editpaste"),
|
Chris@66
|
522 tr("&Paste"), this);
|
Chris@66
|
523 action->setShortcut(tr("Ctrl+V"));
|
Chris@90
|
524 action->setStatusTip(tr("Paste from the clipboard to the current layer"));
|
Chris@66
|
525 connect(action, SIGNAL(triggered()), this, SLOT(paste()));
|
Chris@66
|
526 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
527 m_keyReference->registerShortcut(action);
|
Chris@66
|
528 menu->addAction(action);
|
Chris@66
|
529 m_rightButtonMenu->addAction(action);
|
Chris@66
|
530
|
Chris@164
|
531 m_deleteSelectedAction = new QAction(tr("&Delete Selected Items"), this);
|
Chris@164
|
532 m_deleteSelectedAction->setShortcut(tr("Del"));
|
Chris@164
|
533 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
|
Chris@164
|
534 connect(m_deleteSelectedAction, SIGNAL(triggered()), this, SLOT(deleteSelected()));
|
Chris@164
|
535 connect(this, SIGNAL(canDeleteSelection(bool)), m_deleteSelectedAction, SLOT(setEnabled(bool)));
|
Chris@164
|
536 m_keyReference->registerShortcut(m_deleteSelectedAction);
|
Chris@164
|
537 menu->addAction(m_deleteSelectedAction);
|
Chris@164
|
538 m_rightButtonMenu->addAction(m_deleteSelectedAction);
|
Chris@66
|
539
|
Chris@66
|
540 menu->addSeparator();
|
Chris@66
|
541 m_rightButtonMenu->addSeparator();
|
Chris@162
|
542
|
Chris@162
|
543 m_keyReference->setCategory(tr("Selection"));
|
Chris@162
|
544
|
Chris@66
|
545 action = new QAction(tr("Select &All"), this);
|
Chris@66
|
546 action->setShortcut(tr("Ctrl+A"));
|
Chris@90
|
547 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@66
|
548 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@66
|
549 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
550 m_keyReference->registerShortcut(action);
|
Chris@66
|
551 menu->addAction(action);
|
Chris@66
|
552 m_rightButtonMenu->addAction(action);
|
Chris@0
|
553
|
Chris@66
|
554 action = new QAction(tr("Select &Visible Range"), this);
|
Chris@66
|
555 action->setShortcut(tr("Ctrl+Shift+A"));
|
Chris@90
|
556 action->setStatusTip(tr("Select the time range corresponding to the current window width"));
|
Chris@66
|
557 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible()));
|
Chris@66
|
558 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
559 m_keyReference->registerShortcut(action);
|
Chris@66
|
560 menu->addAction(action);
|
Chris@0
|
561
|
Chris@66
|
562 action = new QAction(tr("Select to &Start"), this);
|
Chris@66
|
563 action->setShortcut(tr("Shift+Left"));
|
Chris@90
|
564 action->setStatusTip(tr("Select from the start of the session to the current playback position"));
|
Chris@66
|
565 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart()));
|
Chris@66
|
566 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
567 m_keyReference->registerShortcut(action);
|
Chris@66
|
568 menu->addAction(action);
|
Chris@0
|
569
|
Chris@66
|
570 action = new QAction(tr("Select to &End"), this);
|
Chris@66
|
571 action->setShortcut(tr("Shift+Right"));
|
Chris@90
|
572 action->setStatusTip(tr("Select from the current playback position to the end of the session"));
|
Chris@66
|
573 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd()));
|
Chris@66
|
574 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
575 m_keyReference->registerShortcut(action);
|
Chris@66
|
576 menu->addAction(action);
|
Chris@66
|
577
|
Chris@66
|
578 action = new QAction(tr("C&lear Selection"), this);
|
Chris@66
|
579 action->setShortcut(tr("Esc"));
|
Chris@90
|
580 action->setStatusTip(tr("Clear the selection"));
|
Chris@66
|
581 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
Chris@66
|
582 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
583 m_keyReference->registerShortcut(action);
|
Chris@66
|
584 menu->addAction(action);
|
Chris@66
|
585 m_rightButtonMenu->addAction(action);
|
Chris@66
|
586
|
Chris@66
|
587 menu->addSeparator();
|
Chris@66
|
588
|
Chris@162
|
589 m_keyReference->setCategory(tr("Tapping Time Instants"));
|
Chris@162
|
590
|
Chris@66
|
591 action = new QAction(tr("&Insert Instant at Playback Position"), this);
|
Chris@66
|
592 action->setShortcut(tr("Enter"));
|
Chris@90
|
593 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary"));
|
Chris@66
|
594 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
|
Chris@66
|
595 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
596 m_keyReference->registerShortcut(action);
|
Chris@66
|
597 menu->addAction(action);
|
Chris@66
|
598
|
Chris@162
|
599 // Laptop shortcut (no keypad Enter key)
|
Chris@162
|
600 QString shortcut(tr(";"));
|
Chris@162
|
601 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
|
Chris@162
|
602 this, SLOT(insertInstant()));
|
Chris@162
|
603 m_keyReference->registerAlternativeShortcut(action, shortcut);
|
Chris@162
|
604
|
Chris@81
|
605 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
|
Chris@81
|
606 action->setShortcut(tr("Shift+Enter"));
|
Chris@163
|
607 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
|
608 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
|
Chris@81
|
609 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
610 m_keyReference->registerShortcut(action);
|
Chris@81
|
611 menu->addAction(action);
|
Chris@189
|
612
|
Chris@190
|
613 QMenu *numberingMenu = menu->addMenu(tr("Number New Instants with"));
|
Chris@225
|
614 numberingMenu->setTearOffEnabled(true);
|
Chris@189
|
615 QActionGroup *numberingGroup = new QActionGroup(this);
|
Chris@189
|
616
|
Chris@189
|
617 Labeller::TypeNameMap types = m_labeller->getTypeNames();
|
Chris@189
|
618 for (Labeller::TypeNameMap::iterator i = types.begin(); i != types.end(); ++i) {
|
Chris@190
|
619
|
Chris@190
|
620 if (i->first == Labeller::ValueFromLabel ||
|
Chris@190
|
621 i->first == Labeller::ValueFromExistingNeighbour) continue;
|
Chris@190
|
622
|
Chris@189
|
623 action = new QAction(i->second, this);
|
Chris@189
|
624 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsNumbering()));
|
Chris@189
|
625 action->setCheckable(true);
|
Chris@189
|
626 action->setChecked(m_labeller->getType() == i->first);
|
Chris@189
|
627 numberingGroup->addAction(action);
|
Chris@189
|
628 numberingMenu->addAction(action);
|
Chris@189
|
629 m_numberingActions[action] = (int)i->first;
|
Chris@190
|
630
|
Chris@190
|
631 if (i->first == Labeller::ValueFromTwoLevelCounter) {
|
Chris@192
|
632
|
Chris@190
|
633 QMenu *cycleMenu = numberingMenu->addMenu(tr("Cycle size"));
|
Chris@190
|
634 QActionGroup *cycleGroup = new QActionGroup(this);
|
Chris@190
|
635
|
Chris@229
|
636 int cycles[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16 };
|
Chris@200
|
637 for (int i = 0; i < int(sizeof(cycles)/sizeof(cycles[0])); ++i) {
|
Chris@190
|
638 action = new QAction(QString("%1").arg(cycles[i]), this);
|
Chris@190
|
639 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounterCycle()));
|
Chris@190
|
640 action->setCheckable(true);
|
Chris@190
|
641 action->setChecked(cycles[i] == m_labeller->getCounterCycleSize());
|
Chris@190
|
642 cycleGroup->addAction(action);
|
Chris@190
|
643 cycleMenu->addAction(action);
|
Chris@190
|
644 }
|
Chris@190
|
645 }
|
Chris@190
|
646
|
Chris@190
|
647 if (i->first == Labeller::ValueNone ||
|
Chris@190
|
648 i->first == Labeller::ValueFromTwoLevelCounter ||
|
Chris@190
|
649 i->first == Labeller::ValueFromRealTime) {
|
Chris@190
|
650 numberingMenu->addSeparator();
|
Chris@190
|
651 }
|
Chris@189
|
652 }
|
Chris@189
|
653
|
Chris@241
|
654 action = new QAction(tr("Set Numbering Counters..."), this);
|
Chris@241
|
655 action->setStatusTip(tr("Set the counters used for counter-based labelling"));
|
Chris@241
|
656 connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
|
Chris@241
|
657 menu->addAction(action);
|
Chris@241
|
658
|
Chris@241
|
659 action = new QAction(tr("Renumber Selected Instants"), this);
|
Chris@241
|
660 action->setStatusTip(tr("Renumber the selected instants using the current labelling scheme"));
|
Chris@189
|
661 connect(action, SIGNAL(triggered()), this, SLOT(renumberInstants()));
|
Chris@189
|
662 connect(this, SIGNAL(canRenumberInstants(bool)), action, SLOT(setEnabled(bool)));
|
Chris@189
|
663 // m_keyReference->registerShortcut(action);
|
Chris@189
|
664 menu->addAction(action);
|
Chris@66
|
665 }
|
Chris@66
|
666
|
Chris@66
|
667 void
|
Chris@66
|
668 MainWindow::setupViewMenu()
|
Chris@66
|
669 {
|
Chris@66
|
670 if (m_mainMenusCreated) return;
|
Chris@66
|
671
|
Chris@168
|
672 IconLoader il;
|
Chris@168
|
673
|
Chris@90
|
674 QAction *action = 0;
|
Chris@90
|
675
|
Chris@162
|
676 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@162
|
677
|
Chris@66
|
678 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@97
|
679 menu->setTearOffEnabled(true);
|
Chris@66
|
680 action = new QAction(tr("Scroll &Left"), this);
|
Chris@66
|
681 action->setShortcut(tr("Left"));
|
Chris@66
|
682 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@66
|
683 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@66
|
684 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
685 m_keyReference->registerShortcut(action);
|
Chris@66
|
686 menu->addAction(action);
|
Chris@0
|
687
|
Chris@66
|
688 action = new QAction(tr("Scroll &Right"), this);
|
Chris@66
|
689 action->setShortcut(tr("Right"));
|
Chris@66
|
690 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@66
|
691 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@66
|
692 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
693 m_keyReference->registerShortcut(action);
|
Chris@66
|
694 menu->addAction(action);
|
Chris@0
|
695
|
Chris@90
|
696 action = new QAction(tr("&Jump Left"), this);
|
Chris@66
|
697 action->setShortcut(tr("Ctrl+Left"));
|
Chris@66
|
698 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@66
|
699 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@66
|
700 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
701 m_keyReference->registerShortcut(action);
|
Chris@66
|
702 menu->addAction(action);
|
Chris@0
|
703
|
Chris@90
|
704 action = new QAction(tr("J&ump Right"), this);
|
Chris@66
|
705 action->setShortcut(tr("Ctrl+Right"));
|
Chris@66
|
706 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@66
|
707 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@66
|
708 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
709 m_keyReference->registerShortcut(action);
|
Chris@66
|
710 menu->addAction(action);
|
Chris@66
|
711
|
Chris@66
|
712 menu->addSeparator();
|
Chris@66
|
713
|
Chris@162
|
714 m_keyReference->setCategory(tr("Zoom"));
|
Chris@162
|
715
|
Chris@168
|
716 action = new QAction(il.load("zoom-in"),
|
Chris@66
|
717 tr("Zoom &In"), this);
|
Chris@66
|
718 action->setShortcut(tr("Up"));
|
Chris@66
|
719 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@66
|
720 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@66
|
721 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
722 m_keyReference->registerShortcut(action);
|
Chris@66
|
723 menu->addAction(action);
|
Chris@0
|
724
|
Chris@168
|
725 action = new QAction(il.load("zoom-out"),
|
Chris@66
|
726 tr("Zoom &Out"), this);
|
Chris@66
|
727 action->setShortcut(tr("Down"));
|
Chris@66
|
728 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@66
|
729 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@66
|
730 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
731 m_keyReference->registerShortcut(action);
|
Chris@66
|
732 menu->addAction(action);
|
Chris@0
|
733
|
Chris@66
|
734 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@90
|
735 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@66
|
736 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@66
|
737 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@66
|
738 menu->addAction(action);
|
Chris@66
|
739
|
Chris@168
|
740 action = new QAction(il.load("zoom-fit"),
|
Chris@138
|
741 tr("Zoom to &Fit"), this);
|
Chris@155
|
742 action->setShortcut(tr("F"));
|
Chris@66
|
743 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@66
|
744 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@66
|
745 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
746 m_keyReference->registerShortcut(action);
|
Chris@66
|
747 menu->addAction(action);
|
Chris@90
|
748
|
Chris@90
|
749 menu->addSeparator();
|
Chris@90
|
750
|
Chris@162
|
751 m_keyReference->setCategory(tr("Display Features"));
|
Chris@162
|
752
|
Chris@90
|
753 QActionGroup *overlayGroup = new QActionGroup(this);
|
Chris@90
|
754
|
Chris@90
|
755 action = new QAction(tr("Show &No Overlays"), this);
|
Chris@90
|
756 action->setShortcut(tr("0"));
|
Chris@90
|
757 action->setStatusTip(tr("Hide centre indicator, frame times, layer names and scale"));
|
Chris@90
|
758 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays()));
|
Chris@90
|
759 action->setCheckable(true);
|
Chris@90
|
760 action->setChecked(false);
|
Chris@90
|
761 overlayGroup->addAction(action);
|
Chris@162
|
762 m_keyReference->registerShortcut(action);
|
Chris@90
|
763 menu->addAction(action);
|
Chris@90
|
764
|
Chris@90
|
765 action = new QAction(tr("Show &Minimal Overlays"), this);
|
Chris@90
|
766 action->setShortcut(tr("9"));
|
Chris@90
|
767 action->setStatusTip(tr("Show centre indicator only"));
|
Chris@90
|
768 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays()));
|
Chris@90
|
769 action->setCheckable(true);
|
Chris@90
|
770 action->setChecked(false);
|
Chris@90
|
771 overlayGroup->addAction(action);
|
Chris@162
|
772 m_keyReference->registerShortcut(action);
|
Chris@90
|
773 menu->addAction(action);
|
Chris@90
|
774
|
Chris@90
|
775 action = new QAction(tr("Show &Standard Overlays"), this);
|
Chris@90
|
776 action->setShortcut(tr("8"));
|
Chris@90
|
777 action->setStatusTip(tr("Show centre indicator, frame times and scale"));
|
Chris@90
|
778 connect(action, SIGNAL(triggered()), this, SLOT(showStandardOverlays()));
|
Chris@90
|
779 action->setCheckable(true);
|
Chris@90
|
780 action->setChecked(true);
|
Chris@90
|
781 overlayGroup->addAction(action);
|
Chris@162
|
782 m_keyReference->registerShortcut(action);
|
Chris@90
|
783 menu->addAction(action);
|
Chris@90
|
784
|
Chris@90
|
785 action = new QAction(tr("Show &All Overlays"), this);
|
Chris@90
|
786 action->setShortcut(tr("7"));
|
Chris@90
|
787 action->setStatusTip(tr("Show all texts and scale"));
|
Chris@90
|
788 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays()));
|
Chris@90
|
789 action->setCheckable(true);
|
Chris@90
|
790 action->setChecked(false);
|
Chris@90
|
791 overlayGroup->addAction(action);
|
Chris@162
|
792 m_keyReference->registerShortcut(action);
|
Chris@90
|
793 menu->addAction(action);
|
Chris@7
|
794
|
Chris@72
|
795 menu->addSeparator();
|
Chris@72
|
796
|
Chris@66
|
797 action = new QAction(tr("Show &Zoom Wheels"), this);
|
Chris@66
|
798 action->setShortcut(tr("Z"));
|
Chris@66
|
799 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically"));
|
Chris@66
|
800 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels()));
|
Chris@66
|
801 action->setCheckable(true);
|
Chris@66
|
802 action->setChecked(m_viewManager->getZoomWheelsEnabled());
|
Chris@162
|
803 m_keyReference->registerShortcut(action);
|
Chris@66
|
804 menu->addAction(action);
|
Chris@72
|
805
|
Chris@72
|
806 action = new QAction(tr("Show Property Bo&xes"), this);
|
Chris@72
|
807 action->setShortcut(tr("X"));
|
Chris@72
|
808 action->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
|
Chris@72
|
809 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
|
Chris@72
|
810 action->setCheckable(true);
|
Chris@72
|
811 action->setChecked(true);
|
Chris@162
|
812 m_keyReference->registerShortcut(action);
|
Chris@72
|
813 menu->addAction(action);
|
Chris@0
|
814
|
Chris@90
|
815 action = new QAction(tr("Show Status &Bar"), this);
|
Chris@90
|
816 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
|
Chris@90
|
817 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
|
Chris@90
|
818 action->setCheckable(true);
|
Chris@90
|
819 action->setChecked(true);
|
Chris@90
|
820 menu->addAction(action);
|
Chris@90
|
821
|
Chris@90
|
822 QSettings settings;
|
Chris@90
|
823 settings.beginGroup("MainWindow");
|
Chris@90
|
824 bool sb = settings.value("showstatusbar", true).toBool();
|
Chris@90
|
825 if (!sb) {
|
Chris@90
|
826 action->setChecked(false);
|
Chris@90
|
827 statusBar()->hide();
|
Chris@90
|
828 }
|
Chris@90
|
829 settings.endGroup();
|
Chris@90
|
830
|
Chris@66
|
831 menu->addSeparator();
|
Chris@66
|
832
|
Chris@219
|
833 action = new QAction(tr("Show La&yer Summary"), this);
|
Chris@219
|
834 action->setShortcut(tr("Y"));
|
Chris@90
|
835 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session"));
|
Chris@66
|
836 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree()));
|
Chris@162
|
837 m_keyReference->registerShortcut(action);
|
Chris@66
|
838 menu->addAction(action);
|
Chris@66
|
839 }
|
Chris@66
|
840
|
Chris@66
|
841 void
|
Chris@66
|
842 MainWindow::setupPaneAndLayerMenus()
|
Chris@66
|
843 {
|
Chris@0
|
844 if (m_paneMenu) {
|
Chris@0
|
845 m_paneActions.clear();
|
Chris@0
|
846 m_paneMenu->clear();
|
Chris@0
|
847 } else {
|
Chris@0
|
848 m_paneMenu = menuBar()->addMenu(tr("&Pane"));
|
Chris@97
|
849 m_paneMenu->setTearOffEnabled(true);
|
Chris@0
|
850 }
|
Chris@0
|
851
|
Chris@0
|
852 if (m_layerMenu) {
|
Chris@0
|
853 m_layerActions.clear();
|
Chris@0
|
854 m_layerMenu->clear();
|
Chris@0
|
855 } else {
|
Chris@0
|
856 m_layerMenu = menuBar()->addMenu(tr("&Layer"));
|
Chris@97
|
857 m_layerMenu->setTearOffEnabled(true);
|
Chris@0
|
858 }
|
Chris@0
|
859
|
Chris@66
|
860 QMenu *menu = m_paneMenu;
|
Chris@66
|
861
|
Chris@168
|
862 IconLoader il;
|
Chris@168
|
863
|
Chris@162
|
864 m_keyReference->setCategory(tr("Managing Panes and Layers"));
|
Chris@162
|
865
|
Chris@168
|
866 QAction *action = new QAction(il.load("pane"), tr("Add &New Pane"), this);
|
Chris@155
|
867 action->setShortcut(tr("N"));
|
Chris@66
|
868 action->setStatusTip(tr("Add a new pane containing only a time ruler"));
|
Chris@66
|
869 connect(action, SIGNAL(triggered()), this, SLOT(addPane()));
|
Chris@66
|
870 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@232
|
871 m_paneActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
|
Chris@162
|
872 m_keyReference->registerShortcut(action);
|
Chris@66
|
873 menu->addAction(action);
|
Chris@66
|
874
|
Chris@66
|
875 menu->addSeparator();
|
Chris@66
|
876
|
Chris@66
|
877 menu = m_layerMenu;
|
Chris@66
|
878
|
Chris@66
|
879 // menu->addSeparator();
|
Chris@66
|
880
|
Chris@66
|
881 LayerFactory::LayerTypeSet emptyLayerTypes =
|
Chris@66
|
882 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@66
|
883
|
Chris@66
|
884 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin();
|
Chris@66
|
885 i != emptyLayerTypes.end(); ++i) {
|
Chris@66
|
886
|
Chris@66
|
887 QIcon icon;
|
Chris@66
|
888 QString mainText, tipText, channelText;
|
Chris@66
|
889 LayerFactory::LayerType type = *i;
|
Chris@66
|
890 QString name = LayerFactory::getInstance()->getLayerPresentationName(type);
|
Chris@66
|
891
|
Chris@168
|
892 icon = il.load(LayerFactory::getInstance()->getLayerIconName(type));
|
Chris@66
|
893
|
Chris@66
|
894 mainText = tr("Add New %1 Layer").arg(name);
|
Chris@66
|
895 tipText = tr("Add a new empty layer of type %1").arg(name);
|
Chris@66
|
896
|
Chris@66
|
897 action = new QAction(icon, mainText, this);
|
Chris@66
|
898 action->setStatusTip(tipText);
|
Chris@66
|
899
|
Chris@66
|
900 if (type == LayerFactory::Text) {
|
Chris@155
|
901 action->setShortcut(tr("T"));
|
Chris@162
|
902 m_keyReference->registerShortcut(action);
|
Chris@66
|
903 }
|
Chris@66
|
904
|
Chris@66
|
905 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@66
|
906 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@232
|
907 m_layerActions[action] = LayerConfiguration(type);
|
Chris@66
|
908 menu->addAction(action);
|
Chris@66
|
909 m_rightButtonLayerMenu->addAction(action);
|
Chris@66
|
910 }
|
Chris@66
|
911
|
Chris@66
|
912 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
913 menu->addSeparator();
|
Chris@66
|
914
|
Chris@66
|
915 LayerFactory::LayerType backgroundTypes[] = {
|
Chris@66
|
916 LayerFactory::Waveform,
|
Chris@66
|
917 LayerFactory::Spectrogram,
|
Chris@66
|
918 LayerFactory::MelodicRangeSpectrogram,
|
Chris@66
|
919 LayerFactory::PeakFrequencySpectrogram,
|
Chris@66
|
920 LayerFactory::Spectrum
|
Chris@66
|
921 };
|
Chris@66
|
922
|
Chris@66
|
923 std::vector<Model *> models;
|
Chris@224
|
924 if (m_document) models = m_document->getTransformInputModels();
|
Chris@66
|
925 bool plural = (models.size() > 1);
|
Chris@66
|
926 if (models.empty()) {
|
Chris@67
|
927 models.push_back(getMainModel()); // probably 0
|
Chris@66
|
928 }
|
Chris@66
|
929
|
Chris@66
|
930 for (unsigned int i = 0;
|
Chris@66
|
931 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
|
Chris@66
|
932
|
Chris@231
|
933 const int paneMenuType = 0, layerMenuType = 1;
|
Chris@231
|
934
|
Chris@231
|
935 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) {
|
Chris@231
|
936
|
Chris@231
|
937 if (menuType == paneMenuType) menu = m_paneMenu;
|
Chris@66
|
938 else menu = m_layerMenu;
|
Chris@66
|
939
|
Chris@66
|
940 QMenu *submenu = 0;
|
Chris@66
|
941
|
Chris@66
|
942 QIcon icon;
|
Chris@66
|
943 QString mainText, shortcutText, tipText, channelText;
|
Chris@66
|
944 LayerFactory::LayerType type = backgroundTypes[i];
|
Chris@66
|
945 bool mono = true;
|
Chris@66
|
946
|
Chris@66
|
947 switch (type) {
|
Chris@66
|
948
|
Chris@66
|
949 case LayerFactory::Waveform:
|
Chris@168
|
950 icon = il.load("waveform");
|
Chris@66
|
951 mainText = tr("Add &Waveform");
|
Chris@231
|
952 if (menuType == paneMenuType) {
|
Chris@155
|
953 shortcutText = tr("W");
|
Chris@66
|
954 tipText = tr("Add a new pane showing a waveform view");
|
Chris@66
|
955 } else {
|
Chris@66
|
956 tipText = tr("Add a new layer showing a waveform view");
|
Chris@66
|
957 }
|
Chris@66
|
958 mono = false;
|
Chris@66
|
959 break;
|
Chris@66
|
960
|
Chris@66
|
961 case LayerFactory::Spectrogram:
|
Chris@168
|
962 icon = il.load("spectrogram");
|
Chris@161
|
963 mainText = tr("Add Spectro&gram");
|
Chris@231
|
964 if (menuType == paneMenuType) {
|
Chris@155
|
965 shortcutText = tr("G");
|
Chris@90
|
966 tipText = tr("Add a new pane showing a spectrogram");
|
Chris@66
|
967 } else {
|
Chris@90
|
968 tipText = tr("Add a new layer showing a spectrogram");
|
Chris@66
|
969 }
|
Chris@66
|
970 break;
|
Chris@66
|
971
|
Chris@66
|
972 case LayerFactory::MelodicRangeSpectrogram:
|
Chris@168
|
973 icon = il.load("spectrogram");
|
Chris@66
|
974 mainText = tr("Add &Melodic Range Spectrogram");
|
Chris@231
|
975 if (menuType == paneMenuType) {
|
Chris@155
|
976 shortcutText = tr("M");
|
Chris@90
|
977 tipText = tr("Add a new pane showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
978 } else {
|
Chris@90
|
979 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches");
|
Chris@66
|
980 }
|
Chris@66
|
981 break;
|
Chris@66
|
982
|
Chris@66
|
983 case LayerFactory::PeakFrequencySpectrogram:
|
Chris@168
|
984 icon = il.load("spectrogram");
|
Chris@155
|
985 mainText = tr("Add Pea&k Frequency Spectrogram");
|
Chris@231
|
986 if (menuType == paneMenuType) {
|
Chris@155
|
987 shortcutText = tr("K");
|
Chris@66
|
988 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
989 } else {
|
Chris@66
|
990 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
|
Chris@66
|
991 }
|
Chris@66
|
992 break;
|
Chris@66
|
993
|
Chris@66
|
994 case LayerFactory::Spectrum:
|
Chris@168
|
995 icon = il.load("spectrum");
|
Chris@66
|
996 mainText = tr("Add Spectr&um");
|
Chris@231
|
997 if (menuType == paneMenuType) {
|
Chris@155
|
998 shortcutText = tr("U");
|
Chris@66
|
999 tipText = tr("Add a new pane showing a frequency spectrum");
|
Chris@66
|
1000 } else {
|
Chris@66
|
1001 tipText = tr("Add a new layer showing a frequency spectrum");
|
Chris@66
|
1002 }
|
Chris@66
|
1003 break;
|
Chris@66
|
1004
|
Chris@66
|
1005 default: break;
|
Chris@66
|
1006 }
|
Chris@66
|
1007
|
Chris@66
|
1008 std::vector<Model *> candidateModels;
|
Chris@231
|
1009 // if (menuType == paneMenuType) {
|
Chris@66
|
1010 candidateModels = models;
|
Chris@231
|
1011 // } else {
|
Chris@231
|
1012 // candidateModels.push_back(0);
|
Chris@231
|
1013 // }
|
Chris@66
|
1014
|
Chris@66
|
1015 for (std::vector<Model *>::iterator mi =
|
Chris@66
|
1016 candidateModels.begin();
|
Chris@66
|
1017 mi != candidateModels.end(); ++mi) {
|
Chris@66
|
1018
|
Chris@66
|
1019 Model *model = *mi;
|
Chris@66
|
1020
|
Chris@66
|
1021 int channels = 0;
|
Chris@66
|
1022 if (model) {
|
Chris@66
|
1023 DenseTimeValueModel *dtvm =
|
Chris@66
|
1024 dynamic_cast<DenseTimeValueModel *>(model);
|
Chris@66
|
1025 if (dtvm) channels = dtvm->getChannelCount();
|
Chris@66
|
1026 }
|
Chris@66
|
1027 if (channels < 1 && getMainModel()) {
|
Chris@66
|
1028 channels = getMainModel()->getChannelCount();
|
Chris@66
|
1029 }
|
Chris@66
|
1030 if (channels < 1) channels = 1;
|
Chris@66
|
1031
|
Chris@66
|
1032 for (int c = 0; c <= channels; ++c) {
|
Chris@66
|
1033
|
Chris@66
|
1034 if (c == 1 && channels == 1) continue;
|
Chris@66
|
1035 bool isDefault = (c == 0);
|
Chris@66
|
1036 bool isOnly = (isDefault && (channels == 1));
|
Chris@66
|
1037
|
Chris@231
|
1038 // if (menuType == layerMenuType) {
|
Chris@231
|
1039 // if (isDefault) isOnly = true;
|
Chris@231
|
1040 // else continue;
|
Chris@231
|
1041 // }
|
Chris@231
|
1042
|
Chris@231
|
1043 if (isOnly && (!plural /*|| menuType == layerMenuType*/)) {
|
Chris@231
|
1044
|
Chris@231
|
1045 // if (menuType == layerMenuType && type != LayerFactory::Waveform) {
|
Chris@231
|
1046 // action = new QAction(mainText, this);
|
Chris@231
|
1047 // } else {
|
Chris@67
|
1048 action = new QAction(icon, mainText, this);
|
Chris@231
|
1049 // }
|
Chris@67
|
1050
|
Chris@66
|
1051 action->setShortcut(shortcutText);
|
Chris@66
|
1052 action->setStatusTip(tipText);
|
Chris@231
|
1053 if (menuType == paneMenuType) {
|
Chris@66
|
1054 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1055 this, SLOT(addPane()));
|
Chris@66
|
1056 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
1057 action, SLOT(setEnabled(bool)));
|
Chris@232
|
1058 m_paneActions[action] = LayerConfiguration(type);
|
Chris@66
|
1059 } else {
|
Chris@66
|
1060 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1061 this, SLOT(addLayer()));
|
Chris@66
|
1062 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
1063 action, SLOT(setEnabled(bool)));
|
Chris@232
|
1064 m_layerActions[action] = LayerConfiguration(type);
|
Chris@66
|
1065 }
|
Chris@162
|
1066 if (shortcutText != "") {
|
Chris@162
|
1067 m_keyReference->registerShortcut(action);
|
Chris@162
|
1068 }
|
Chris@66
|
1069 menu->addAction(action);
|
Chris@66
|
1070
|
Chris@66
|
1071 } else {
|
Chris@66
|
1072
|
Chris@66
|
1073 if (!submenu) {
|
Chris@66
|
1074 submenu = menu->addMenu(mainText);
|
Chris@97
|
1075 submenu->setTearOffEnabled(true);
|
Chris@67
|
1076 } else if (isDefault) {
|
Chris@67
|
1077 submenu->addSeparator();
|
Chris@66
|
1078 }
|
Chris@66
|
1079
|
Chris@66
|
1080 QString actionText;
|
Chris@66
|
1081 if (c == 0) {
|
Chris@66
|
1082 if (mono) {
|
Chris@66
|
1083 actionText = tr("&All Channels Mixed");
|
Chris@66
|
1084 } else {
|
Chris@66
|
1085 actionText = tr("&All Channels");
|
Chris@66
|
1086 }
|
Chris@66
|
1087 } else {
|
Chris@66
|
1088 actionText = tr("Channel &%1").arg(c);
|
Chris@66
|
1089 }
|
Chris@66
|
1090
|
Chris@66
|
1091 if (model) {
|
Chris@66
|
1092 actionText = tr("%1: %2")
|
Chris@66
|
1093 .arg(model->objectName())
|
Chris@66
|
1094 .arg(actionText);
|
Chris@66
|
1095 }
|
Chris@67
|
1096
|
Chris@67
|
1097 if (isDefault) {
|
Chris@67
|
1098 action = new QAction(icon, actionText, this);
|
Chris@67
|
1099 if (!model || model == getMainModel()) {
|
Chris@162
|
1100 action->setShortcut(shortcutText);
|
Chris@67
|
1101 }
|
Chris@67
|
1102 } else {
|
Chris@67
|
1103 action = new QAction(actionText, this);
|
Chris@67
|
1104 }
|
Chris@67
|
1105
|
Chris@66
|
1106 action->setStatusTip(tipText);
|
Chris@66
|
1107
|
Chris@231
|
1108 if (menuType == paneMenuType) {
|
Chris@66
|
1109 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1110 this, SLOT(addPane()));
|
Chris@66
|
1111 connect(this, SIGNAL(canAddPane(bool)),
|
Chris@66
|
1112 action, SLOT(setEnabled(bool)));
|
Chris@66
|
1113 m_paneActions[action] =
|
Chris@232
|
1114 LayerConfiguration(type, model, c - 1);
|
Chris@66
|
1115 } else {
|
Chris@66
|
1116 connect(action, SIGNAL(triggered()),
|
Chris@66
|
1117 this, SLOT(addLayer()));
|
Chris@66
|
1118 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@66
|
1119 action, SLOT(setEnabled(bool)));
|
Chris@232
|
1120 m_layerActions[action] =
|
Chris@232
|
1121 LayerConfiguration(type, model, c - 1);
|
Chris@66
|
1122 }
|
Chris@66
|
1123
|
Chris@66
|
1124 submenu->addAction(action);
|
Chris@66
|
1125 }
|
Chris@66
|
1126 }
|
Chris@66
|
1127 }
|
Chris@66
|
1128 }
|
Chris@66
|
1129 }
|
Chris@66
|
1130
|
Chris@66
|
1131 menu = m_paneMenu;
|
Chris@225
|
1132 menu->addSeparator();
|
Chris@225
|
1133
|
Chris@225
|
1134 action = new QAction(tr("Switch to Previous Pane"), this);
|
Chris@225
|
1135 action->setShortcut(tr("["));
|
Chris@225
|
1136 action->setStatusTip(tr("Make the next pane up in the pane stack current"));
|
Chris@225
|
1137 connect(action, SIGNAL(triggered()), this, SLOT(previousPane()));
|
Chris@225
|
1138 connect(this, SIGNAL(canSelectPreviousPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1139 m_keyReference->registerShortcut(action);
|
Chris@225
|
1140 menu->addAction(action);
|
Chris@225
|
1141
|
Chris@225
|
1142 action = new QAction(tr("Switch to Next Pane"), this);
|
Chris@225
|
1143 action->setShortcut(tr("]"));
|
Chris@225
|
1144 action->setStatusTip(tr("Make the next pane down in the pane stack current"));
|
Chris@225
|
1145 connect(action, SIGNAL(triggered()), this, SLOT(nextPane()));
|
Chris@225
|
1146 connect(this, SIGNAL(canSelectNextPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1147 m_keyReference->registerShortcut(action);
|
Chris@225
|
1148 menu->addAction(action);
|
Chris@66
|
1149
|
Chris@66
|
1150 menu->addSeparator();
|
Chris@66
|
1151
|
Chris@168
|
1152 action = new QAction(il.load("editdelete"), tr("&Delete Pane"), this);
|
Chris@155
|
1153 action->setShortcut(tr("Ctrl+Shift+D"));
|
Chris@90
|
1154 action->setStatusTip(tr("Delete the currently active pane"));
|
Chris@66
|
1155 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane()));
|
Chris@66
|
1156 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
1157 m_keyReference->registerShortcut(action);
|
Chris@66
|
1158 menu->addAction(action);
|
Chris@66
|
1159
|
Chris@66
|
1160 menu = m_layerMenu;
|
Chris@66
|
1161
|
Chris@168
|
1162 action = new QAction(il.load("timeruler"), tr("Add &Time Ruler"), this);
|
Chris@66
|
1163 action->setStatusTip(tr("Add a new layer showing a time ruler"));
|
Chris@66
|
1164 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@66
|
1165 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@232
|
1166 m_layerActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
|
Chris@66
|
1167 menu->addAction(action);
|
Chris@66
|
1168
|
Chris@66
|
1169 menu->addSeparator();
|
Chris@66
|
1170
|
Chris@66
|
1171 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer"));
|
Chris@97
|
1172 m_existingLayersMenu->setTearOffEnabled(true);
|
Chris@66
|
1173 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu);
|
Chris@95
|
1174
|
Chris@95
|
1175 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer"));
|
Chris@97
|
1176 m_sliceMenu->setTearOffEnabled(true);
|
Chris@95
|
1177 m_rightButtonLayerMenu->addMenu(m_sliceMenu);
|
Chris@95
|
1178
|
Chris@95
|
1179 setupExistingLayersMenus();
|
Chris@66
|
1180
|
Chris@225
|
1181 /*!!! These don't work correctly -- fix or omit
|
Chris@225
|
1182 menu->addSeparator();
|
Chris@225
|
1183
|
Chris@225
|
1184 action = new QAction(tr("Switch to Previous Layer"), this);
|
Chris@225
|
1185 action->setShortcut(tr("{"));
|
Chris@225
|
1186 action->setStatusTip(tr("Make the previous layer in the pane current"));
|
Chris@225
|
1187 connect(action, SIGNAL(triggered()), this, SLOT(previousLayer()));
|
Chris@225
|
1188 connect(this, SIGNAL(canSelectPreviousLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1189 m_keyReference->registerShortcut(action);
|
Chris@225
|
1190 menu->addAction(action);
|
Chris@225
|
1191
|
Chris@225
|
1192 action = new QAction(tr("Switch to Next Layer"), this);
|
Chris@225
|
1193 action->setShortcut(tr("}"));
|
Chris@225
|
1194 action->setStatusTip(tr("Make the next layer in the pane current"));
|
Chris@225
|
1195 connect(action, SIGNAL(triggered()), this, SLOT(nextLayer()));
|
Chris@225
|
1196 connect(this, SIGNAL(canSelectNextLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@225
|
1197 m_keyReference->registerShortcut(action);
|
Chris@225
|
1198 menu->addAction(action);
|
Chris@225
|
1199 */
|
Chris@66
|
1200 m_rightButtonLayerMenu->addSeparator();
|
Chris@66
|
1201 menu->addSeparator();
|
Chris@66
|
1202
|
Chris@163
|
1203 QAction *raction = new QAction(tr("&Rename Layer..."), this);
|
Chris@163
|
1204 raction->setShortcut(tr("R"));
|
Chris@163
|
1205 raction->setStatusTip(tr("Rename the currently active layer"));
|
Chris@163
|
1206 connect(raction, SIGNAL(triggered()), this, SLOT(renameCurrentLayer()));
|
Chris@163
|
1207 connect(this, SIGNAL(canRenameLayer(bool)), raction, SLOT(setEnabled(bool)));
|
Chris@163
|
1208 menu->addAction(raction);
|
Chris@163
|
1209 m_rightButtonLayerMenu->addAction(raction);
|
Chris@66
|
1210
|
Chris@258
|
1211 QAction *eaction = new QAction(tr("Edit Layer Data"), this);
|
Chris@258
|
1212 eaction->setShortcut(tr("E"));
|
Chris@258
|
1213 eaction->setStatusTip(tr("Edit the currently active layer as a data grid"));
|
Chris@258
|
1214 connect(eaction, SIGNAL(triggered()), this, SLOT(editCurrentLayer()));
|
Chris@291
|
1215 connect(this, SIGNAL(canEditLayerTabular(bool)), eaction, SLOT(setEnabled(bool)));
|
Chris@258
|
1216 menu->addAction(eaction);
|
Chris@258
|
1217 m_rightButtonLayerMenu->addAction(eaction);
|
Chris@258
|
1218
|
Chris@168
|
1219 action = new QAction(il.load("editdelete"), tr("&Delete Layer"), this);
|
Chris@155
|
1220 action->setShortcut(tr("Ctrl+D"));
|
Chris@66
|
1221 action->setStatusTip(tr("Delete the currently active layer"));
|
Chris@66
|
1222 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer()));
|
Chris@66
|
1223 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@162
|
1224 m_keyReference->registerShortcut(action);
|
Chris@66
|
1225 menu->addAction(action);
|
Chris@66
|
1226 m_rightButtonLayerMenu->addAction(action);
|
Chris@163
|
1227
|
Chris@163
|
1228 m_keyReference->registerShortcut(raction); // rename after delete, so delete layer goes next to delete pane
|
Chris@258
|
1229 m_keyReference->registerShortcut(eaction); // edit also after delete
|
Chris@66
|
1230 }
|
Chris@66
|
1231
|
Chris@66
|
1232 void
|
Chris@211
|
1233 MainWindow::setupTransformsMenu()
|
Chris@66
|
1234 {
|
Chris@34
|
1235 if (m_transformsMenu) {
|
Chris@34
|
1236 m_transformActions.clear();
|
Chris@34
|
1237 m_transformActionsReverse.clear();
|
Chris@34
|
1238 m_transformsMenu->clear();
|
Chris@34
|
1239 } else {
|
Chris@97
|
1240 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
|
Chris@97
|
1241 m_transformsMenu->setTearOffEnabled(true);
|
Chris@286
|
1242 m_transformsMenu->setSeparatorsCollapsible(true);
|
Chris@272
|
1243 }
|
Chris@34
|
1244
|
Chris@288
|
1245 TransformFactory *factory = TransformFactory::getInstance();
|
Chris@288
|
1246
|
Chris@288
|
1247 TransformList transforms = factory->getAllTransformDescriptions();
|
Chris@288
|
1248 vector<TransformDescription::Type> types = factory->getAllTransformTypes();
|
Chris@288
|
1249
|
Chris@288
|
1250 map<TransformDescription::Type, map<QString, SubdividingMenu *> > categoryMenus;
|
Chris@288
|
1251 map<TransformDescription::Type, map<QString, SubdividingMenu *> > makerMenus;
|
Chris@288
|
1252
|
Chris@288
|
1253 map<TransformDescription::Type, SubdividingMenu *> byPluginNameMenus;
|
Chris@288
|
1254 map<TransformDescription::Type, map<QString, QMenu *> > pluginNameMenus;
|
Chris@33
|
1255
|
Chris@37
|
1256 set<SubdividingMenu *> pendingMenus;
|
Chris@37
|
1257
|
Chris@211
|
1258 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms"));
|
Chris@211
|
1259 m_recentTransformsMenu->setTearOffEnabled(true);
|
Chris@211
|
1260 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu);
|
Chris@211
|
1261 connect(&m_recentTransforms, SIGNAL(recentChanged()),
|
Chris@211
|
1262 this, SLOT(setupRecentTransformsMenu()));
|
Chris@34
|
1263
|
Chris@34
|
1264 m_transformsMenu->addSeparator();
|
Chris@211
|
1265 m_rightButtonTransformsMenu->addSeparator();
|
Chris@34
|
1266
|
Chris@288
|
1267 for (vector<TransformDescription::Type>::iterator i = types.begin();
|
Chris@288
|
1268 i != types.end(); ++i) {
|
Chris@33
|
1269
|
Chris@33
|
1270 if (i != types.begin()) {
|
Chris@34
|
1271 m_transformsMenu->addSeparator();
|
Chris@211
|
1272 m_rightButtonTransformsMenu->addSeparator();
|
Chris@33
|
1273 }
|
Chris@33
|
1274
|
Chris@288
|
1275 QString byCategoryLabel = tr("%1 by Category")
|
Chris@288
|
1276 .arg(factory->getTransformTypeName(*i));
|
Chris@37
|
1277 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel,
|
Chris@37
|
1278 20, 40);
|
Chris@97
|
1279 byCategoryMenu->setTearOffEnabled(true);
|
Chris@37
|
1280 m_transformsMenu->addMenu(byCategoryMenu);
|
Chris@211
|
1281 m_rightButtonTransformsMenu->addMenu(byCategoryMenu);
|
Chris@37
|
1282 pendingMenus.insert(byCategoryMenu);
|
Chris@33
|
1283
|
Chris@288
|
1284 vector<QString> categories = factory->getTransformCategories(*i);
|
Chris@33
|
1285
|
Chris@33
|
1286 for (vector<QString>::iterator j = categories.begin();
|
Chris@33
|
1287 j != categories.end(); ++j) {
|
Chris@33
|
1288
|
Chris@33
|
1289 QString category = *j;
|
Chris@33
|
1290 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1291
|
Chris@33
|
1292 if (categories.size() < 2) {
|
Chris@33
|
1293 categoryMenus[*i][category] = byCategoryMenu;
|
Chris@33
|
1294 continue;
|
Chris@33
|
1295 }
|
Chris@33
|
1296
|
Chris@33
|
1297 QStringList components = category.split(" > ");
|
Chris@33
|
1298 QString key;
|
Chris@33
|
1299
|
Chris@33
|
1300 for (QStringList::iterator k = components.begin();
|
Chris@33
|
1301 k != components.end(); ++k) {
|
Chris@33
|
1302
|
Chris@33
|
1303 QString parentKey = key;
|
Chris@33
|
1304 if (key != "") key += " > ";
|
Chris@33
|
1305 key += *k;
|
Chris@33
|
1306
|
Chris@33
|
1307 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) {
|
Chris@37
|
1308 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40);
|
Chris@97
|
1309 m->setTearOffEnabled(true);
|
Chris@37
|
1310 pendingMenus.insert(m);
|
Chris@37
|
1311 categoryMenus[*i][key] = m;
|
Chris@33
|
1312 if (parentKey == "") {
|
Chris@37
|
1313 byCategoryMenu->addMenu(m);
|
Chris@33
|
1314 } else {
|
Chris@37
|
1315 categoryMenus[*i][parentKey]->addMenu(m);
|
Chris@33
|
1316 }
|
Chris@33
|
1317 }
|
Chris@33
|
1318 }
|
Chris@33
|
1319 }
|
Chris@33
|
1320
|
Chris@288
|
1321 QString byPluginNameLabel = tr("%1 by Plugin Name")
|
Chris@288
|
1322 .arg(factory->getTransformTypeName(*i));
|
Chris@36
|
1323 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel);
|
Chris@97
|
1324 byPluginNameMenus[*i]->setTearOffEnabled(true);
|
Chris@36
|
1325 m_transformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@211
|
1326 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]);
|
Chris@37
|
1327 pendingMenus.insert(byPluginNameMenus[*i]);
|
Chris@34
|
1328
|
Chris@288
|
1329 QString byMakerLabel = tr("%1 by Maker")
|
Chris@288
|
1330 .arg(factory->getTransformTypeName(*i));
|
Chris@37
|
1331 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40);
|
Chris@97
|
1332 byMakerMenu->setTearOffEnabled(true);
|
Chris@37
|
1333 m_transformsMenu->addMenu(byMakerMenu);
|
Chris@211
|
1334 m_rightButtonTransformsMenu->addMenu(byMakerMenu);
|
Chris@37
|
1335 pendingMenus.insert(byMakerMenu);
|
Chris@33
|
1336
|
Chris@288
|
1337 vector<QString> makers = factory->getTransformMakers(*i);
|
Chris@37
|
1338
|
Chris@33
|
1339 for (vector<QString>::iterator j = makers.begin();
|
Chris@33
|
1340 j != makers.end(); ++j) {
|
Chris@33
|
1341
|
Chris@33
|
1342 QString maker = *j;
|
Chris@33
|
1343 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1344 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@55
|
1345
|
Chris@37
|
1346 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40);
|
Chris@97
|
1347 makerMenus[*i][maker]->setTearOffEnabled(true);
|
Chris@37
|
1348 byMakerMenu->addMenu(makerMenus[*i][maker]);
|
Chris@37
|
1349 pendingMenus.insert(makerMenus[*i][maker]);
|
Chris@33
|
1350 }
|
Chris@0
|
1351 }
|
Chris@0
|
1352
|
Chris@230
|
1353 // Names should only be duplicated here if they have the same
|
Chris@230
|
1354 // plugin name, output name and maker but are in different library
|
Chris@230
|
1355 // .so names -- that won't happen often I hope
|
Chris@230
|
1356 std::map<QString, QString> idNameSonameMap;
|
Chris@230
|
1357 std::set<QString> seenNames, duplicateNames;
|
Chris@230
|
1358 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@230
|
1359 QString name = transforms[i].name;
|
Chris@230
|
1360 if (seenNames.find(name) != seenNames.end()) {
|
Chris@230
|
1361 duplicateNames.insert(name);
|
Chris@230
|
1362 } else {
|
Chris@230
|
1363 seenNames.insert(name);
|
Chris@230
|
1364 }
|
Chris@230
|
1365 }
|
Chris@230
|
1366
|
Chris@0
|
1367 for (unsigned int i = 0; i < transforms.size(); ++i) {
|
Chris@0
|
1368
|
Chris@107
|
1369 QString name = transforms[i].name;
|
Chris@107
|
1370 if (name == "") name = transforms[i].identifier;
|
Chris@107
|
1371
|
Chris@107
|
1372 // std::cerr << "Plugin Name: " << name.toStdString() << std::endl;
|
Chris@80
|
1373
|
Chris@288
|
1374 TransformDescription::Type type = transforms[i].type;
|
Chris@288
|
1375 QString typeStr = factory->getTransformTypeName(type);
|
Chris@33
|
1376
|
Chris@33
|
1377 QString category = transforms[i].category;
|
Chris@33
|
1378 if (category == "") category = tr("Unclassified");
|
Chris@33
|
1379
|
Chris@33
|
1380 QString maker = transforms[i].maker;
|
Chris@33
|
1381 if (maker == "") maker = tr("Unknown");
|
Chris@55
|
1382 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
Chris@33
|
1383
|
Chris@107
|
1384 QString pluginName = name.section(": ", 0, 0);
|
Chris@107
|
1385 QString output = name.section(": ", 1);
|
Chris@107
|
1386
|
Chris@230
|
1387 if (duplicateNames.find(pluginName) != duplicateNames.end()) {
|
Chris@230
|
1388 pluginName = QString("%1 <%2>")
|
Chris@230
|
1389 .arg(pluginName)
|
Chris@230
|
1390 .arg(transforms[i].identifier.section(':', 1, 1));
|
Chris@230
|
1391 if (output == "") name = pluginName;
|
Chris@230
|
1392 else name = QString("%1: %2")
|
Chris@230
|
1393 .arg(pluginName)
|
Chris@230
|
1394 .arg(output);
|
Chris@230
|
1395 }
|
Chris@230
|
1396
|
Chris@107
|
1397 QAction *action = new QAction(tr("%1...").arg(name), this);
|
Chris@0
|
1398 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1399 m_transformActions[action] = transforms[i].identifier;
|
Chris@107
|
1400 m_transformActionsReverse[transforms[i].identifier] = action;
|
Chris@0
|
1401 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@33
|
1402
|
Chris@272
|
1403 action->setStatusTip(transforms[i].longDescription);
|
Chris@90
|
1404
|
Chris@33
|
1405 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
|
Chris@33
|
1406 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1407 << "No category menu for transform \""
|
Chris@107
|
1408 << name.toStdString() << "\" (category = \""
|
Chris@33
|
1409 << category.toStdString() << "\")" << std::endl;
|
Chris@33
|
1410 } else {
|
Chris@33
|
1411 categoryMenus[type][category]->addAction(action);
|
Chris@33
|
1412 }
|
Chris@33
|
1413
|
Chris@33
|
1414 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
|
Chris@33
|
1415 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
|
Chris@33
|
1416 << "No maker menu for transform \""
|
Chris@107
|
1417 << name.toStdString() << "\" (maker = \""
|
Chris@33
|
1418 << maker.toStdString() << "\")" << std::endl;
|
Chris@33
|
1419 } else {
|
Chris@80
|
1420 makerMenus[type][maker]->addAction(action);
|
Chris@33
|
1421 }
|
Chris@33
|
1422
|
Chris@33
|
1423 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
|
Chris@33
|
1424 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@107
|
1425 m_transformActions[action] = transforms[i].identifier;
|
Chris@33
|
1426 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@272
|
1427 action->setStatusTip(transforms[i].longDescription);
|
Chris@33
|
1428
|
Chris@211
|
1429 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl;
|
Chris@34
|
1430
|
Chris@33
|
1431 if (pluginNameMenus[type].find(pluginName) ==
|
Chris@33
|
1432 pluginNameMenus[type].end()) {
|
Chris@33
|
1433
|
Chris@36
|
1434 SubdividingMenu *parentMenu = byPluginNameMenus[type];
|
Chris@97
|
1435 parentMenu->setTearOffEnabled(true);
|
Chris@34
|
1436
|
Chris@33
|
1437 if (output == "") {
|
Chris@36
|
1438 parentMenu->addAction(pluginName, action);
|
Chris@33
|
1439 } else {
|
Chris@34
|
1440 pluginNameMenus[type][pluginName] =
|
Chris@34
|
1441 parentMenu->addMenu(pluginName);
|
Chris@33
|
1442 connect(this, SIGNAL(canAddLayer(bool)),
|
Chris@33
|
1443 pluginNameMenus[type][pluginName],
|
Chris@33
|
1444 SLOT(setEnabled(bool)));
|
Chris@33
|
1445 }
|
Chris@33
|
1446 }
|
Chris@33
|
1447
|
Chris@33
|
1448 if (pluginNameMenus[type].find(pluginName) !=
|
Chris@33
|
1449 pluginNameMenus[type].end()) {
|
Chris@33
|
1450 pluginNameMenus[type][pluginName]->addAction(action);
|
Chris@33
|
1451 }
|
Chris@0
|
1452 }
|
Chris@0
|
1453
|
Chris@37
|
1454 for (set<SubdividingMenu *>::iterator i = pendingMenus.begin();
|
Chris@37
|
1455 i != pendingMenus.end(); ++i) {
|
Chris@37
|
1456 (*i)->entriesAdded();
|
Chris@37
|
1457 }
|
Chris@37
|
1458
|
Chris@273
|
1459 m_transformsMenu->addSeparator();
|
Chris@273
|
1460 m_rightButtonTransformsMenu->addSeparator();
|
Chris@273
|
1461
|
Chris@273
|
1462 QAction *action = new QAction(tr("Find a Transform..."), this);
|
Chris@273
|
1463 action->setStatusTip(tr("Search for a transform from the installed plugins, by name or description"));
|
Chris@275
|
1464 action->setShortcut(tr("Ctrl+M"));
|
Chris@273
|
1465 connect(action, SIGNAL(triggered()), this, SLOT(findTransform()));
|
Chris@287
|
1466 // connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@275
|
1467 m_keyReference->registerShortcut(action);
|
Chris@273
|
1468 m_transformsMenu->addAction(action);
|
Chris@273
|
1469 m_rightButtonTransformsMenu->addAction(action);
|
Chris@273
|
1470
|
Chris@211
|
1471 setupRecentTransformsMenu();
|
Chris@66
|
1472 }
|
Chris@66
|
1473
|
Chris@66
|
1474 void
|
Chris@66
|
1475 MainWindow::setupHelpMenu()
|
Chris@66
|
1476 {
|
Chris@66
|
1477 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@97
|
1478 menu->setTearOffEnabled(true);
|
Chris@66
|
1479
|
Chris@162
|
1480 m_keyReference->setCategory(tr("Help"));
|
Chris@162
|
1481
|
Chris@168
|
1482 IconLoader il;
|
Chris@168
|
1483
|
Chris@168
|
1484 QAction *action = new QAction(il.load("help"),
|
Chris@138
|
1485 tr("&Help Reference"), this);
|
Chris@162
|
1486 action->setShortcut(tr("F1"));
|
Chris@66
|
1487 action->setStatusTip(tr("Open the Sonic Visualiser reference manual"));
|
Chris@66
|
1488 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@162
|
1489 m_keyReference->registerShortcut(action);
|
Chris@0
|
1490 menu->addAction(action);
|
Chris@162
|
1491
|
Chris@163
|
1492 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@162
|
1493 action->setShortcut(tr("F2"));
|
Chris@162
|
1494 action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser"));
|
Chris@162
|
1495 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@162
|
1496 m_keyReference->registerShortcut(action);
|
Chris@162
|
1497 menu->addAction(action);
|
Chris@66
|
1498
|
Chris@164
|
1499 action = new QAction(tr("Sonic Visualiser on the &Web"), this);
|
Chris@164
|
1500 action->setStatusTip(tr("Open the Sonic Visualiser website"));
|
Chris@164
|
1501 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@164
|
1502 menu->addAction(action);
|
Chris@164
|
1503
|
Chris@66
|
1504 action = new QAction(tr("&About Sonic Visualiser"), this);
|
Chris@66
|
1505 action->setStatusTip(tr("Show information about Sonic Visualiser"));
|
Chris@66
|
1506 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
1507 menu->addAction(action);
|
Chris@0
|
1508 }
|
Chris@0
|
1509
|
Chris@0
|
1510 void
|
Chris@0
|
1511 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
1512 {
|
Chris@0
|
1513 m_recentFilesMenu->clear();
|
Chris@34
|
1514 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
1515 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@0
|
1516 QAction *action = new QAction(files[i], this);
|
Chris@0
|
1517 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@162
|
1518 if (i == 0) {
|
Chris@162
|
1519 action->setShortcut(tr("Ctrl+R"));
|
Chris@162
|
1520 m_keyReference->registerShortcut
|
Chris@163
|
1521 (tr("Re-open"),
|
Chris@163
|
1522 action->shortcut(),
|
Chris@163
|
1523 tr("Re-open the current or most recently opened file"));
|
Chris@162
|
1524 }
|
Chris@0
|
1525 m_recentFilesMenu->addAction(action);
|
Chris@0
|
1526 }
|
Chris@0
|
1527 }
|
Chris@0
|
1528
|
Chris@0
|
1529 void
|
Chris@211
|
1530 MainWindow::setupRecentTransformsMenu()
|
Chris@34
|
1531 {
|
Chris@211
|
1532 m_recentTransformsMenu->clear();
|
Chris@211
|
1533 vector<QString> transforms = m_recentTransforms.getRecent();
|
Chris@34
|
1534 for (size_t i = 0; i < transforms.size(); ++i) {
|
Chris@211
|
1535 TransformActionReverseMap::iterator ti =
|
Chris@34
|
1536 m_transformActionsReverse.find(transforms[i]);
|
Chris@34
|
1537 if (ti == m_transformActionsReverse.end()) {
|
Chris@211
|
1538 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
|
Chris@34
|
1539 << "Unknown transform \"" << transforms[i].toStdString()
|
Chris@34
|
1540 << "\" in recent transforms list" << std::endl;
|
Chris@34
|
1541 continue;
|
Chris@34
|
1542 }
|
Chris@162
|
1543 if (i == 0) {
|
Chris@162
|
1544 ti->second->setShortcut(tr("Ctrl+T"));
|
Chris@162
|
1545 m_keyReference->registerShortcut
|
Chris@211
|
1546 (tr("Repeat Transform"),
|
Chris@162
|
1547 ti->second->shortcut(),
|
Chris@163
|
1548 tr("Re-select the most recently run transform"));
|
Chris@216
|
1549 } else {
|
Chris@216
|
1550 ti->second->setShortcut(QString(""));
|
Chris@162
|
1551 }
|
Chris@211
|
1552 m_recentTransformsMenu->addAction(ti->second);
|
Chris@34
|
1553 }
|
Chris@34
|
1554 }
|
Chris@34
|
1555
|
Chris@34
|
1556 void
|
Chris@95
|
1557 MainWindow::setupExistingLayersMenus()
|
Chris@0
|
1558 {
|
Chris@0
|
1559 if (!m_existingLayersMenu) return; // should have been created by setupMenus
|
Chris@0
|
1560
|
Chris@0
|
1561 // std::cerr << "MainWindow::setupExistingLayersMenu" << std::endl;
|
Chris@0
|
1562
|
Chris@0
|
1563 m_existingLayersMenu->clear();
|
Chris@0
|
1564 m_existingLayerActions.clear();
|
Chris@0
|
1565
|
Chris@95
|
1566 m_sliceMenu->clear();
|
Chris@95
|
1567 m_sliceActions.clear();
|
Chris@95
|
1568
|
Chris@168
|
1569 IconLoader il;
|
Chris@168
|
1570
|
Chris@33
|
1571 vector<Layer *> orderedLayers;
|
Chris@33
|
1572 set<Layer *> observedLayers;
|
Chris@95
|
1573 set<Layer *> sliceableLayers;
|
Chris@95
|
1574
|
Chris@95
|
1575 LayerFactory *factory = LayerFactory::getInstance();
|
Chris@0
|
1576
|
Chris@0
|
1577 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@0
|
1578
|
Chris@0
|
1579 Pane *pane = m_paneStack->getPane(i);
|
Chris@0
|
1580 if (!pane) continue;
|
Chris@0
|
1581
|
Chris@0
|
1582 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
1583
|
Chris@0
|
1584 Layer *layer = pane->getLayer(j);
|
Chris@0
|
1585 if (!layer) continue;
|
Chris@0
|
1586 if (observedLayers.find(layer) != observedLayers.end()) {
|
Chris@137
|
1587 // std::cerr << "found duplicate layer " << layer << std::endl;
|
Chris@0
|
1588 continue;
|
Chris@0
|
1589 }
|
Chris@0
|
1590
|
Chris@0
|
1591 // std::cerr << "found new layer " << layer << " (name = "
|
Chris@0
|
1592 // << layer->getLayerPresentationName().toStdString() << ")" << std::endl;
|
Chris@0
|
1593
|
Chris@0
|
1594 orderedLayers.push_back(layer);
|
Chris@0
|
1595 observedLayers.insert(layer);
|
Chris@95
|
1596
|
Chris@95
|
1597 if (factory->isLayerSliceable(layer)) {
|
Chris@95
|
1598 sliceableLayers.insert(layer);
|
Chris@95
|
1599 }
|
Chris@0
|
1600 }
|
Chris@0
|
1601 }
|
Chris@0
|
1602
|
Chris@33
|
1603 map<QString, int> observedNames;
|
Chris@0
|
1604
|
Chris@137
|
1605 for (size_t i = 0; i < orderedLayers.size(); ++i) {
|
Chris@0
|
1606
|
Chris@95
|
1607 Layer *layer = orderedLayers[i];
|
Chris@95
|
1608
|
Chris@95
|
1609 QString name = layer->getLayerPresentationName();
|
Chris@0
|
1610 int n = ++observedNames[name];
|
Chris@0
|
1611 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n);
|
Chris@0
|
1612
|
Chris@168
|
1613 QIcon icon = il.load(factory->getLayerIconName
|
Chris@168
|
1614 (factory->getLayerType(layer)));
|
Chris@95
|
1615
|
Chris@95
|
1616 QAction *action = new QAction(icon, name, this);
|
Chris@0
|
1617 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@0
|
1618 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1619 m_existingLayerActions[action] = layer;
|
Chris@0
|
1620
|
Chris@0
|
1621 m_existingLayersMenu->addAction(action);
|
Chris@95
|
1622
|
Chris@95
|
1623 if (sliceableLayers.find(layer) != sliceableLayers.end()) {
|
Chris@95
|
1624 action = new QAction(icon, name, this);
|
Chris@95
|
1625 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
|
Chris@95
|
1626 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@95
|
1627 m_sliceActions[action] = layer;
|
Chris@95
|
1628 m_sliceMenu->addAction(action);
|
Chris@95
|
1629 }
|
Chris@0
|
1630 }
|
Chris@95
|
1631
|
Chris@95
|
1632 m_sliceMenu->setEnabled(!m_sliceActions.empty());
|
Chris@0
|
1633 }
|
Chris@0
|
1634
|
Chris@0
|
1635 void
|
Chris@0
|
1636 MainWindow::setupToolbars()
|
Chris@0
|
1637 {
|
Chris@162
|
1638 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@162
|
1639
|
Chris@168
|
1640 IconLoader il;
|
Chris@168
|
1641
|
Chris@155
|
1642 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@155
|
1643 menu->setTearOffEnabled(true);
|
Chris@155
|
1644 m_rightButtonMenu->addSeparator();
|
Chris@155
|
1645 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@155
|
1646
|
Chris@155
|
1647 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@155
|
1648
|
Chris@265
|
1649 m_rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@265
|
1650 tr("Rewind to Start"));
|
Chris@265
|
1651 m_rwdStartAction->setShortcut(tr("Home"));
|
Chris@265
|
1652 m_rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@265
|
1653 connect(m_rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@265
|
1654 connect(this, SIGNAL(canPlay(bool)), m_rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@265
|
1655
|
Chris@265
|
1656 m_rwdAction = toolbar->addAction(il.load("rewind"), tr("Rewind"));
|
Chris@155
|
1657 m_rwdAction->setShortcut(tr("PgUp"));
|
Chris@163
|
1658 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@155
|
1659 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@155
|
1660 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1661
|
Chris@265
|
1662 m_playAction = toolbar->addAction(il.load("playpause"),
|
Chris@265
|
1663 tr("Play / Pause"));
|
Chris@265
|
1664 m_playAction->setCheckable(true);
|
Chris@265
|
1665 m_playAction->setShortcut(tr("Space"));
|
Chris@265
|
1666 m_playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@265
|
1667 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
1668 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@265
|
1669 m_playAction, SLOT(setChecked(bool)));
|
Chris@305
|
1670 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
Chris@305
|
1671 this, SLOT(playStatusChanged(bool)));
|
Chris@265
|
1672 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1673
|
Chris@168
|
1674 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@286
|
1675 tr("Fast Forward"));
|
Chris@155
|
1676 m_ffwdAction->setShortcut(tr("PgDown"));
|
Chris@163
|
1677 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@155
|
1678 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@155
|
1679 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1680
|
Chris@265
|
1681 m_ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@265
|
1682 tr("Fast Forward to End"));
|
Chris@265
|
1683 m_ffwdEndAction->setShortcut(tr("End"));
|
Chris@265
|
1684 m_ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@265
|
1685 connect(m_ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@265
|
1686 connect(this, SIGNAL(canPlay(bool)), m_ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@0
|
1687
|
Chris@0
|
1688 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
1689
|
Chris@265
|
1690 m_playSelectionAction = toolbar->addAction(il.load("playselection"),
|
Chris@265
|
1691 tr("Constrain Playback to Selection"));
|
Chris@265
|
1692 m_playSelectionAction->setCheckable(true);
|
Chris@265
|
1693 m_playSelectionAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@265
|
1694 m_playSelectionAction->setShortcut(tr("s"));
|
Chris@265
|
1695 m_playSelectionAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@69
|
1696 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@265
|
1697 m_playSelectionAction, SLOT(setChecked(bool)));
|
Chris@265
|
1698 connect(m_playSelectionAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@265
|
1699 connect(this, SIGNAL(canPlaySelection(bool)), m_playSelectionAction, SLOT(setEnabled(bool)));
|
Chris@265
|
1700
|
Chris@265
|
1701 m_playLoopAction = toolbar->addAction(il.load("playloop"),
|
Chris@265
|
1702 tr("Loop Playback"));
|
Chris@265
|
1703 m_playLoopAction->setCheckable(true);
|
Chris@265
|
1704 m_playLoopAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@265
|
1705 m_playLoopAction->setShortcut(tr("l"));
|
Chris@265
|
1706 m_playLoopAction->setStatusTip(tr("Loop playback"));
|
Chris@69
|
1707 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@265
|
1708 m_playLoopAction, SLOT(setChecked(bool)));
|
Chris@265
|
1709 connect(m_playLoopAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@265
|
1710 connect(this, SIGNAL(canPlay(bool)), m_playLoopAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1711
|
Chris@207
|
1712 m_soloAction = toolbar->addAction(il.load("solo"),
|
Chris@180
|
1713 tr("Solo Current Pane"));
|
Chris@207
|
1714 m_soloAction->setCheckable(true);
|
Chris@207
|
1715 m_soloAction->setChecked(m_viewManager->getPlaySoloMode());
|
Chris@207
|
1716 m_prevSolo = m_viewManager->getPlaySoloMode();
|
Chris@207
|
1717 m_soloAction->setShortcut(tr("o"));
|
Chris@207
|
1718 m_soloAction->setStatusTip(tr("Solo the current pane during playback"));
|
Chris@180
|
1719 connect(m_viewManager, SIGNAL(playSoloModeChanged(bool)),
|
Chris@207
|
1720 m_soloAction, SLOT(setChecked(bool)));
|
Chris@207
|
1721 connect(m_soloAction, SIGNAL(triggered()), this, SLOT(playSoloToggled()));
|
Chris@207
|
1722 connect(this, SIGNAL(canChangeSolo(bool)), m_soloAction, SLOT(setEnabled(bool)));
|
Chris@180
|
1723
|
Chris@208
|
1724 QAction *alAction = 0;
|
Chris@208
|
1725 if (Document::canAlign()) {
|
Chris@208
|
1726 alAction = toolbar->addAction(il.load("align"),
|
Chris@208
|
1727 tr("Align File Timelines"));
|
Chris@208
|
1728 alAction->setCheckable(true);
|
Chris@208
|
1729 alAction->setChecked(m_viewManager->getAlignMode());
|
Chris@208
|
1730 alAction->setStatusTip(tr("Treat multiple audio files as versions of the same work, and align their timelines"));
|
Chris@208
|
1731 connect(m_viewManager, SIGNAL(alignModeChanged(bool)),
|
Chris@208
|
1732 alAction, SLOT(setChecked(bool)));
|
Chris@208
|
1733 connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled()));
|
Chris@208
|
1734 connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool)));
|
Chris@208
|
1735 }
|
Chris@206
|
1736
|
Chris@265
|
1737 m_keyReference->registerShortcut(m_playAction);
|
Chris@265
|
1738 m_keyReference->registerShortcut(m_playSelectionAction);
|
Chris@265
|
1739 m_keyReference->registerShortcut(m_playLoopAction);
|
Chris@207
|
1740 m_keyReference->registerShortcut(m_soloAction);
|
Chris@208
|
1741 if (alAction) m_keyReference->registerShortcut(alAction);
|
Chris@162
|
1742 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@162
|
1743 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@265
|
1744 m_keyReference->registerShortcut(m_rwdStartAction);
|
Chris@265
|
1745 m_keyReference->registerShortcut(m_ffwdEndAction);
|
Chris@265
|
1746
|
Chris@265
|
1747 menu->addAction(m_playAction);
|
Chris@265
|
1748 menu->addAction(m_playSelectionAction);
|
Chris@265
|
1749 menu->addAction(m_playLoopAction);
|
Chris@207
|
1750 menu->addAction(m_soloAction);
|
Chris@208
|
1751 if (alAction) menu->addAction(alAction);
|
Chris@155
|
1752 menu->addSeparator();
|
Chris@155
|
1753 menu->addAction(m_rwdAction);
|
Chris@155
|
1754 menu->addAction(m_ffwdAction);
|
Chris@155
|
1755 menu->addSeparator();
|
Chris@265
|
1756 menu->addAction(m_rwdStartAction);
|
Chris@265
|
1757 menu->addAction(m_ffwdEndAction);
|
Chris@155
|
1758 menu->addSeparator();
|
Chris@155
|
1759
|
Chris@265
|
1760 m_rightButtonPlaybackMenu->addAction(m_playAction);
|
Chris@265
|
1761 m_rightButtonPlaybackMenu->addAction(m_playSelectionAction);
|
Chris@265
|
1762 m_rightButtonPlaybackMenu->addAction(m_playLoopAction);
|
Chris@207
|
1763 m_rightButtonPlaybackMenu->addAction(m_soloAction);
|
Chris@208
|
1764 if (alAction) m_rightButtonPlaybackMenu->addAction(alAction);
|
Chris@155
|
1765 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@155
|
1766 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@155
|
1767 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@155
|
1768 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@265
|
1769 m_rightButtonPlaybackMenu->addAction(m_rwdStartAction);
|
Chris@265
|
1770 m_rightButtonPlaybackMenu->addAction(m_ffwdEndAction);
|
Chris@155
|
1771 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@155
|
1772
|
Chris@155
|
1773 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@155
|
1774 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@163
|
1775 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@155
|
1776 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@155
|
1777 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1778
|
Chris@155
|
1779 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@155
|
1780 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@163
|
1781 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@155
|
1782 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@155
|
1783 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1784
|
Chris@155
|
1785 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@155
|
1786 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@163
|
1787 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@155
|
1788 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@155
|
1789 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@155
|
1790
|
Chris@162
|
1791 m_keyReference->registerShortcut(fastAction);
|
Chris@162
|
1792 m_keyReference->registerShortcut(slowAction);
|
Chris@162
|
1793 m_keyReference->registerShortcut(normalAction);
|
Chris@162
|
1794
|
Chris@155
|
1795 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@155
|
1796 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@155
|
1797 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@0
|
1798
|
Chris@0
|
1799 toolbar = addToolBar(tr("Edit Toolbar"));
|
Chris@0
|
1800 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@0
|
1801
|
Chris@162
|
1802 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@162
|
1803
|
Chris@0
|
1804 toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@0
|
1805 QActionGroup *group = new QActionGroup(this);
|
Chris@0
|
1806
|
Chris@168
|
1807 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@155
|
1808 tr("Navigate"));
|
Chris@0
|
1809 action->setCheckable(true);
|
Chris@0
|
1810 action->setChecked(true);
|
Chris@0
|
1811 action->setShortcut(tr("1"));
|
Chris@90
|
1812 action->setStatusTip(tr("Navigate"));
|
Chris@0
|
1813 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@0
|
1814 group->addAction(action);
|
Chris@162
|
1815 m_keyReference->registerShortcut(action);
|
Chris@0
|
1816 m_toolActions[ViewManager::NavigateMode] = action;
|
Chris@0
|
1817
|
Chris@168
|
1818 action = toolbar->addAction(il.load("select"),
|
Chris@0
|
1819 tr("Select"));
|
Chris@0
|
1820 action->setCheckable(true);
|
Chris@0
|
1821 action->setShortcut(tr("2"));
|
Chris@90
|
1822 action->setStatusTip(tr("Select ranges"));
|
Chris@0
|
1823 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected()));
|
Chris@0
|
1824 group->addAction(action);
|
Chris@162
|
1825 m_keyReference->registerShortcut(action);
|
Chris@0
|
1826 m_toolActions[ViewManager::SelectMode] = action;
|
Chris@0
|
1827
|
Chris@168
|
1828 action = toolbar->addAction(il.load("move"),
|
Chris@0
|
1829 tr("Edit"));
|
Chris@0
|
1830 action->setCheckable(true);
|
Chris@0
|
1831 action->setShortcut(tr("3"));
|
Chris@90
|
1832 action->setStatusTip(tr("Edit items in layer"));
|
Chris@0
|
1833 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@0
|
1834 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1835 group->addAction(action);
|
Chris@162
|
1836 m_keyReference->registerShortcut(action);
|
Chris@0
|
1837 m_toolActions[ViewManager::EditMode] = action;
|
Chris@0
|
1838
|
Chris@168
|
1839 action = toolbar->addAction(il.load("draw"),
|
Chris@0
|
1840 tr("Draw"));
|
Chris@0
|
1841 action->setCheckable(true);
|
Chris@0
|
1842 action->setShortcut(tr("4"));
|
Chris@90
|
1843 action->setStatusTip(tr("Draw new items in layer"));
|
Chris@0
|
1844 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected()));
|
Chris@0
|
1845 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
1846 group->addAction(action);
|
Chris@162
|
1847 m_keyReference->registerShortcut(action);
|
Chris@0
|
1848 m_toolActions[ViewManager::DrawMode] = action;
|
Chris@0
|
1849
|
Chris@217
|
1850 action = toolbar->addAction(il.load("erase"),
|
Chris@217
|
1851 tr("Erase"));
|
Chris@217
|
1852 action->setCheckable(true);
|
Chris@217
|
1853 action->setShortcut(tr("5"));
|
Chris@217
|
1854 action->setStatusTip(tr("Erase items from layer"));
|
Chris@217
|
1855 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected()));
|
Chris@217
|
1856 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@217
|
1857 group->addAction(action);
|
Chris@217
|
1858 m_keyReference->registerShortcut(action);
|
Chris@217
|
1859 m_toolActions[ViewManager::EraseMode] = action;
|
Chris@217
|
1860
|
Chris@265
|
1861 action = toolbar->addAction(il.load("measure"), tr("Measure"));
|
Chris@151
|
1862 action->setCheckable(true);
|
Chris@217
|
1863 action->setShortcut(tr("6"));
|
Chris@151
|
1864 action->setStatusTip(tr("Make measurements in layer"));
|
Chris@151
|
1865 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected()));
|
Chris@169
|
1866 connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@151
|
1867 group->addAction(action);
|
Chris@162
|
1868 m_keyReference->registerShortcut(action);
|
Chris@151
|
1869 m_toolActions[ViewManager::MeasureMode] = action;
|
Chris@151
|
1870
|
Chris@0
|
1871 toolNavigateSelected();
|
Chris@163
|
1872
|
Chris@163
|
1873 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
1874 }
|
Chris@0
|
1875
|
Chris@0
|
1876 void
|
Chris@265
|
1877 MainWindow::connectLayerEditDialog(ModelDataTableDialog *dialog)
|
Chris@265
|
1878 {
|
Chris@265
|
1879 MainWindowBase::connectLayerEditDialog(dialog);
|
Chris@265
|
1880 QToolBar *toolbar = dialog->getPlayToolbar();
|
Chris@265
|
1881 if (toolbar) {
|
Chris@265
|
1882 toolbar->addAction(m_rwdStartAction);
|
Chris@265
|
1883 toolbar->addAction(m_rwdAction);
|
Chris@265
|
1884 toolbar->addAction(m_playAction);
|
Chris@265
|
1885 toolbar->addAction(m_ffwdAction);
|
Chris@265
|
1886 toolbar->addAction(m_ffwdEndAction);
|
Chris@265
|
1887 }
|
Chris@265
|
1888 }
|
Chris@265
|
1889
|
Chris@265
|
1890 void
|
Chris@0
|
1891 MainWindow::updateMenuStates()
|
Chris@0
|
1892 {
|
Chris@200
|
1893 MainWindowBase::updateMenuStates();
|
Chris@200
|
1894
|
Chris@117
|
1895 Pane *currentPane = 0;
|
Chris@117
|
1896 Layer *currentLayer = 0;
|
Chris@117
|
1897
|
Chris@117
|
1898 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@117
|
1899 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@117
|
1900
|
Chris@0
|
1901 bool haveCurrentPane =
|
Chris@117
|
1902 (currentPane != 0);
|
Chris@0
|
1903 bool haveCurrentLayer =
|
Chris@117
|
1904 (haveCurrentPane &&
|
Chris@117
|
1905 (currentLayer != 0));
|
Chris@206
|
1906 bool havePlayTarget =
|
Chris@206
|
1907 (m_playTarget != 0);
|
Chris@0
|
1908 bool haveSelection =
|
Chris@0
|
1909 (m_viewManager &&
|
Chris@0
|
1910 !m_viewManager->getSelections().empty());
|
Chris@0
|
1911 bool haveCurrentEditableLayer =
|
Chris@0
|
1912 (haveCurrentLayer &&
|
Chris@117
|
1913 currentLayer->isLayerEditable());
|
Chris@0
|
1914 bool haveCurrentTimeInstantsLayer =
|
Chris@0
|
1915 (haveCurrentLayer &&
|
Chris@117
|
1916 dynamic_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
1917 bool haveCurrentTimeValueLayer =
|
Chris@0
|
1918 (haveCurrentLayer &&
|
Chris@117
|
1919 dynamic_cast<TimeValueLayer *>(currentLayer));
|
Chris@207
|
1920
|
Chris@207
|
1921 emit canChangeSolo(havePlayTarget);
|
Chris@207
|
1922 emit canAlign(havePlayTarget && m_document && m_document->canAlign());
|
Chris@206
|
1923
|
Chris@200
|
1924 emit canChangePlaybackSpeed(true);
|
Chris@200
|
1925 int v = m_playSpeed->value();
|
Chris@200
|
1926 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@200
|
1927 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@155
|
1928
|
Chris@164
|
1929 if (m_viewManager &&
|
Chris@164
|
1930 (m_viewManager->getToolMode() == ViewManager::MeasureMode)) {
|
Chris@164
|
1931 emit canDeleteSelection(haveCurrentLayer);
|
Chris@164
|
1932 m_deleteSelectedAction->setText(tr("&Delete Current Measurement"));
|
Chris@164
|
1933 m_deleteSelectedAction->setStatusTip(tr("Delete the measurement currently under the mouse pointer"));
|
Chris@164
|
1934 } else {
|
Chris@164
|
1935 emit canDeleteSelection(haveSelection && haveCurrentEditableLayer);
|
Chris@164
|
1936 m_deleteSelectedAction->setText(tr("&Delete Selected Items"));
|
Chris@164
|
1937 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
|
Chris@164
|
1938 }
|
Chris@164
|
1939
|
Chris@155
|
1940 if (m_ffwdAction && m_rwdAction) {
|
Chris@155
|
1941 if (haveCurrentTimeInstantsLayer) {
|
Chris@155
|
1942 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@155
|
1943 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@155
|
1944 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@155
|
1945 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@155
|
1946 } else if (haveCurrentTimeValueLayer) {
|
Chris@155
|
1947 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@155
|
1948 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@155
|
1949 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@155
|
1950 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@155
|
1951 } else {
|
Chris@155
|
1952 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@155
|
1953 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@155
|
1954 m_rwdAction->setText(tr("Rewind"));
|
Chris@155
|
1955 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@155
|
1956 }
|
Chris@155
|
1957 }
|
Chris@0
|
1958 }
|
Chris@0
|
1959
|
Chris@0
|
1960 void
|
Chris@0
|
1961 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1962 {
|
Chris@0
|
1963 if (!getMainModel()) {
|
Chris@0
|
1964 m_descriptionLabel->setText(tr("No audio file loaded."));
|
Chris@0
|
1965 return;
|
Chris@0
|
1966 }
|
Chris@0
|
1967
|
Chris@0
|
1968 QString description;
|
Chris@0
|
1969
|
Chris@0
|
1970 size_t ssr = getMainModel()->getSampleRate();
|
Chris@0
|
1971 size_t tsr = ssr;
|
Chris@0
|
1972 if (m_playSource) tsr = m_playSource->getTargetSampleRate();
|
Chris@0
|
1973
|
Chris@0
|
1974 if (ssr != tsr) {
|
Chris@0
|
1975 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
|
Chris@0
|
1976 } else {
|
Chris@0
|
1977 description = QString("%1Hz").arg(ssr);
|
Chris@0
|
1978 }
|
Chris@0
|
1979
|
Chris@0
|
1980 description = QString("%1 - %2")
|
Chris@0
|
1981 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr)
|
Chris@0
|
1982 .toText(false).c_str())
|
Chris@0
|
1983 .arg(description);
|
Chris@0
|
1984
|
Chris@0
|
1985 m_descriptionLabel->setText(description);
|
Chris@0
|
1986 }
|
Chris@0
|
1987
|
Chris@0
|
1988 void
|
Chris@0
|
1989 MainWindow::documentModified()
|
Chris@0
|
1990 {
|
Chris@200
|
1991 //!!!
|
Chris@200
|
1992 MainWindowBase::documentModified();
|
Chris@0
|
1993 }
|
Chris@0
|
1994
|
Chris@0
|
1995 void
|
Chris@0
|
1996 MainWindow::documentRestored()
|
Chris@0
|
1997 {
|
Chris@200
|
1998 //!!!
|
Chris@200
|
1999 MainWindowBase::documentRestored();
|
Chris@0
|
2000 }
|
Chris@0
|
2001
|
Chris@0
|
2002 void
|
Chris@0
|
2003 MainWindow::toolNavigateSelected()
|
Chris@0
|
2004 {
|
Chris@0
|
2005 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
2006 }
|
Chris@0
|
2007
|
Chris@0
|
2008 void
|
Chris@0
|
2009 MainWindow::toolSelectSelected()
|
Chris@0
|
2010 {
|
Chris@0
|
2011 m_viewManager->setToolMode(ViewManager::SelectMode);
|
Chris@0
|
2012 }
|
Chris@0
|
2013
|
Chris@0
|
2014 void
|
Chris@0
|
2015 MainWindow::toolEditSelected()
|
Chris@0
|
2016 {
|
Chris@0
|
2017 m_viewManager->setToolMode(ViewManager::EditMode);
|
Chris@0
|
2018 }
|
Chris@0
|
2019
|
Chris@0
|
2020 void
|
Chris@0
|
2021 MainWindow::toolDrawSelected()
|
Chris@0
|
2022 {
|
Chris@0
|
2023 m_viewManager->setToolMode(ViewManager::DrawMode);
|
Chris@0
|
2024 }
|
Chris@0
|
2025
|
Chris@151
|
2026 void
|
Chris@217
|
2027 MainWindow::toolEraseSelected()
|
Chris@217
|
2028 {
|
Chris@217
|
2029 m_viewManager->setToolMode(ViewManager::EraseMode);
|
Chris@217
|
2030 }
|
Chris@217
|
2031
|
Chris@217
|
2032 void
|
Chris@151
|
2033 MainWindow::toolMeasureSelected()
|
Chris@151
|
2034 {
|
Chris@151
|
2035 m_viewManager->setToolMode(ViewManager::MeasureMode);
|
Chris@151
|
2036 }
|
Chris@151
|
2037
|
Chris@0
|
2038 void
|
Chris@0
|
2039 MainWindow::importAudio()
|
Chris@0
|
2040 {
|
Chris@88
|
2041 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
2042
|
Chris@0
|
2043 if (path != "") {
|
Chris@197
|
2044 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) {
|
Chris@247
|
2045 emit hideSplash();
|
Chris@0
|
2046 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2047 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2048 }
|
Chris@0
|
2049 }
|
Chris@0
|
2050 }
|
Chris@0
|
2051
|
Chris@0
|
2052 void
|
Chris@0
|
2053 MainWindow::importMoreAudio()
|
Chris@0
|
2054 {
|
Chris@88
|
2055 QString path = getOpenFileName(FileFinder::AudioFile);
|
Chris@0
|
2056
|
Chris@0
|
2057 if (path != "") {
|
Chris@197
|
2058 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) {
|
Chris@247
|
2059 emit hideSplash();
|
Chris@0
|
2060 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2061 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2062 }
|
Chris@0
|
2063 }
|
Chris@0
|
2064 }
|
Chris@0
|
2065
|
Chris@0
|
2066 void
|
Chris@0
|
2067 MainWindow::exportAudio()
|
Chris@0
|
2068 {
|
Chris@0
|
2069 if (!getMainModel()) return;
|
Chris@0
|
2070
|
Chris@88
|
2071 QString path = getSaveFileName(FileFinder::AudioFile);
|
Chris@0
|
2072
|
Chris@0
|
2073 if (path == "") return;
|
Chris@0
|
2074
|
Chris@0
|
2075 bool ok = false;
|
Chris@0
|
2076 QString error;
|
Chris@0
|
2077
|
Chris@0
|
2078 MultiSelection ms = m_viewManager->getSelection();
|
Chris@0
|
2079 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@0
|
2080
|
Chris@0
|
2081 bool multiple = false;
|
Chris@0
|
2082
|
Chris@38
|
2083 MultiSelection *selectionToWrite = 0;
|
Chris@38
|
2084
|
Chris@38
|
2085 if (selections.size() == 1) {
|
Chris@0
|
2086
|
Chris@0
|
2087 QStringList items;
|
Chris@0
|
2088 items << tr("Export the selected region only")
|
Chris@0
|
2089 << tr("Export the whole audio file");
|
Chris@0
|
2090
|
Chris@0
|
2091 bool ok = false;
|
Chris@0
|
2092 QString item = ListInputDialog::getItem
|
Chris@0
|
2093 (this, tr("Select region to export"),
|
Chris@0
|
2094 tr("Which region from the original audio file do you want to export?"),
|
Chris@0
|
2095 items, 0, &ok);
|
Chris@0
|
2096
|
Chris@0
|
2097 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2098
|
Chris@38
|
2099 if (item == items[0]) selectionToWrite = &ms;
|
Chris@38
|
2100
|
Chris@38
|
2101 } else if (selections.size() > 1) {
|
Chris@0
|
2102
|
Chris@0
|
2103 QStringList items;
|
Chris@0
|
2104 items << tr("Export the selected regions into a single audio file")
|
Chris@0
|
2105 << tr("Export the selected regions into separate files")
|
Chris@0
|
2106 << tr("Export the whole audio file");
|
Chris@0
|
2107
|
Chris@0
|
2108 QString item = ListInputDialog::getItem
|
Chris@0
|
2109 (this, tr("Select region to export"),
|
Chris@0
|
2110 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
|
Chris@0
|
2111 items, 0, &ok);
|
Chris@0
|
2112
|
Chris@0
|
2113 if (!ok || item.isEmpty()) return;
|
Chris@0
|
2114
|
Chris@0
|
2115 if (item == items[0]) {
|
Chris@0
|
2116
|
Chris@38
|
2117 selectionToWrite = &ms;
|
Chris@38
|
2118
|
Chris@38
|
2119 } else if (item == items[1]) {
|
Chris@0
|
2120
|
Chris@0
|
2121 multiple = true;
|
Chris@0
|
2122
|
Chris@0
|
2123 int n = 1;
|
Chris@0
|
2124 QString base = path;
|
Chris@0
|
2125 base.replace(".wav", "");
|
Chris@0
|
2126
|
Chris@0
|
2127 for (MultiSelection::SelectionList::iterator i = selections.begin();
|
Chris@0
|
2128 i != selections.end(); ++i) {
|
Chris@0
|
2129
|
Chris@0
|
2130 MultiSelection subms;
|
Chris@0
|
2131 subms.setSelection(*i);
|
Chris@0
|
2132
|
Chris@0
|
2133 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
|
Chris@0
|
2134 ++n;
|
Chris@0
|
2135
|
Chris@0
|
2136 if (QFileInfo(subpath).exists()) {
|
Chris@0
|
2137 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
|
Chris@0
|
2138 break;
|
Chris@0
|
2139 }
|
Chris@0
|
2140
|
Chris@38
|
2141 WavFileWriter subwriter(subpath,
|
Chris@38
|
2142 getMainModel()->getSampleRate(),
|
Chris@38
|
2143 getMainModel()->getChannelCount());
|
Chris@38
|
2144 subwriter.writeModel(getMainModel(), &subms);
|
Chris@0
|
2145 ok = subwriter.isOK();
|
Chris@0
|
2146
|
Chris@0
|
2147 if (!ok) {
|
Chris@0
|
2148 error = subwriter.getError();
|
Chris@0
|
2149 break;
|
Chris@0
|
2150 }
|
Chris@0
|
2151 }
|
Chris@0
|
2152 }
|
Chris@0
|
2153 }
|
Chris@0
|
2154
|
Chris@38
|
2155 if (!multiple) {
|
Chris@38
|
2156 WavFileWriter writer(path,
|
Chris@38
|
2157 getMainModel()->getSampleRate(),
|
Chris@38
|
2158 getMainModel()->getChannelCount());
|
Chris@38
|
2159 writer.writeModel(getMainModel(), selectionToWrite);
|
Chris@38
|
2160 ok = writer.isOK();
|
Chris@38
|
2161 error = writer.getError();
|
Chris@0
|
2162 }
|
Chris@0
|
2163
|
Chris@0
|
2164 if (ok) {
|
Chris@0
|
2165 if (!multiple) {
|
Chris@34
|
2166 m_recentFiles.addFile(path);
|
Chris@0
|
2167 }
|
Chris@0
|
2168 } else {
|
Chris@0
|
2169 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2170 }
|
Chris@0
|
2171 }
|
Chris@0
|
2172
|
Chris@0
|
2173 void
|
Chris@0
|
2174 MainWindow::importLayer()
|
Chris@0
|
2175 {
|
Chris@0
|
2176 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2177
|
Chris@0
|
2178 if (!pane) {
|
Chris@0
|
2179 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2180 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
|
Chris@0
|
2181 return;
|
Chris@0
|
2182 }
|
Chris@0
|
2183
|
Chris@0
|
2184 if (!getMainModel()) {
|
Chris@0
|
2185 // shouldn't happen, as the menu action should have been disabled
|
Chris@0
|
2186 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
|
Chris@0
|
2187 return;
|
Chris@0
|
2188 }
|
Chris@0
|
2189
|
Chris@88
|
2190 QString path = getOpenFileName(FileFinder::LayerFile);
|
Chris@0
|
2191
|
Chris@0
|
2192 if (path != "") {
|
Chris@0
|
2193
|
Chris@197
|
2194 FileOpenStatus status = openLayer(path);
|
Chris@193
|
2195
|
Chris@193
|
2196 if (status == FileOpenFailed) {
|
Chris@247
|
2197 emit hideSplash();
|
Chris@0
|
2198 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2199 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@0
|
2200 return;
|
Chris@193
|
2201 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2202 emit hideSplash();
|
Chris@193
|
2203 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
2204 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
|
2205 }
|
Chris@0
|
2206 }
|
Chris@0
|
2207 }
|
Chris@0
|
2208
|
Chris@0
|
2209 void
|
Chris@0
|
2210 MainWindow::exportLayer()
|
Chris@0
|
2211 {
|
Chris@0
|
2212 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2213 if (!pane) return;
|
Chris@0
|
2214
|
Chris@0
|
2215 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
2216 if (!layer) return;
|
Chris@0
|
2217
|
Chris@0
|
2218 Model *model = layer->getModel();
|
Chris@0
|
2219 if (!model) return;
|
Chris@0
|
2220
|
Chris@185
|
2221 FileFinder::FileType type = FileFinder::LayerFileNoMidi;
|
Chris@185
|
2222
|
Chris@185
|
2223 if (dynamic_cast<NoteModel *>(model)) type = FileFinder::LayerFile;
|
Chris@185
|
2224
|
Chris@185
|
2225 QString path = getSaveFileName(type);
|
Chris@0
|
2226
|
Chris@0
|
2227 if (path == "") return;
|
Chris@0
|
2228
|
Chris@0
|
2229 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@0
|
2230
|
Chris@185
|
2231 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@185
|
2232
|
Chris@0
|
2233 QString error;
|
Chris@0
|
2234
|
Chris@185
|
2235 if (suffix == "xml" || suffix == "svl") {
|
Chris@0
|
2236
|
Chris@0
|
2237 QFile file(path);
|
Chris@0
|
2238 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@0
|
2239 error = tr("Failed to open file %1 for writing").arg(path);
|
Chris@0
|
2240 } else {
|
Chris@0
|
2241 QTextStream out(&file);
|
Chris@0
|
2242 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@0
|
2243 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@0
|
2244 << "<sv>\n"
|
Chris@0
|
2245 << " <data>\n";
|
Chris@0
|
2246
|
Chris@0
|
2247 model->toXml(out, " ");
|
Chris@0
|
2248
|
Chris@0
|
2249 out << " </data>\n"
|
Chris@0
|
2250 << " <display>\n";
|
Chris@0
|
2251
|
Chris@0
|
2252 layer->toXml(out, " ");
|
Chris@0
|
2253
|
Chris@0
|
2254 out << " </display>\n"
|
Chris@0
|
2255 << "</sv>\n";
|
Chris@0
|
2256 }
|
Chris@0
|
2257
|
Chris@185
|
2258 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@185
|
2259
|
Chris@185
|
2260 NoteModel *nm = dynamic_cast<NoteModel *>(model);
|
Chris@185
|
2261
|
Chris@185
|
2262 if (!nm) {
|
Chris@185
|
2263 error = tr("Can't export non-note layers to MIDI");
|
Chris@185
|
2264 } else {
|
Chris@185
|
2265 MIDIFileWriter writer(path, nm);
|
Chris@185
|
2266 writer.write();
|
Chris@185
|
2267 if (!writer.isOK()) {
|
Chris@185
|
2268 error = writer.getError();
|
Chris@185
|
2269 }
|
Chris@185
|
2270 }
|
Chris@185
|
2271
|
Chris@291
|
2272 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@291
|
2273
|
Chris@291
|
2274 RDFExporter exporter(path, model);
|
Chris@291
|
2275 exporter.write();
|
Chris@291
|
2276 if (!exporter.isOK()) {
|
Chris@291
|
2277 error = exporter.getError();
|
Chris@291
|
2278 }
|
Chris@291
|
2279
|
Chris@0
|
2280 } else {
|
Chris@0
|
2281
|
Chris@0
|
2282 CSVFileWriter writer(path, model,
|
Chris@185
|
2283 ((suffix == "csv") ? "," : "\t"));
|
Chris@0
|
2284 writer.write();
|
Chris@0
|
2285
|
Chris@0
|
2286 if (!writer.isOK()) {
|
Chris@0
|
2287 error = writer.getError();
|
Chris@0
|
2288 }
|
Chris@0
|
2289 }
|
Chris@0
|
2290
|
Chris@0
|
2291 if (error != "") {
|
Chris@0
|
2292 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@0
|
2293 } else {
|
Chris@34
|
2294 m_recentFiles.addFile(path);
|
Chris@0
|
2295 }
|
Chris@0
|
2296 }
|
Chris@0
|
2297
|
Chris@121
|
2298 void
|
Chris@121
|
2299 MainWindow::exportImage()
|
Chris@121
|
2300 {
|
Chris@121
|
2301 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@121
|
2302 if (!pane) return;
|
Chris@121
|
2303
|
Chris@121
|
2304 QString path = getSaveFileName(FileFinder::ImageFile);
|
Chris@121
|
2305
|
Chris@121
|
2306 if (path == "") return;
|
Chris@121
|
2307
|
Chris@121
|
2308 if (QFileInfo(path).suffix() == "") path += ".png";
|
Chris@121
|
2309
|
Chris@123
|
2310 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
|
Chris@123
|
2311
|
Chris@123
|
2312 QSize total, visible, selected;
|
Chris@123
|
2313 total = pane->getImageSize();
|
Chris@123
|
2314 visible = pane->getImageSize(pane->getFirstVisibleFrame(),
|
Chris@123
|
2315 pane->getLastVisibleFrame());
|
Chris@123
|
2316
|
Chris@123
|
2317 size_t sf0 = 0, sf1 = 0;
|
Chris@123
|
2318
|
Chris@123
|
2319 if (haveSelection) {
|
Chris@123
|
2320 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@123
|
2321 sf0 = selections.begin()->getStartFrame();
|
Chris@123
|
2322 MultiSelection::SelectionList::iterator e = selections.end();
|
Chris@123
|
2323 --e;
|
Chris@123
|
2324 sf1 = e->getEndFrame();
|
Chris@123
|
2325 selected = pane->getImageSize(sf0, sf1);
|
Chris@123
|
2326 }
|
Chris@123
|
2327
|
Chris@123
|
2328 QStringList items;
|
Chris@125
|
2329 items << tr("Export the whole pane (%1x%2 pixels)")
|
Chris@123
|
2330 .arg(total.width()).arg(total.height());
|
Chris@123
|
2331 items << tr("Export the visible area only (%1x%2 pixels)")
|
Chris@123
|
2332 .arg(visible.width()).arg(visible.height());
|
Chris@123
|
2333 if (haveSelection) {
|
Chris@123
|
2334 items << tr("Export the selection extent (%1x%2 pixels)")
|
Chris@123
|
2335 .arg(selected.width()).arg(selected.height());
|
Chris@124
|
2336 } else {
|
Chris@124
|
2337 items << tr("Export the selection extent");
|
Chris@123
|
2338 }
|
Chris@123
|
2339
|
Chris@123
|
2340 QSettings settings;
|
Chris@123
|
2341 settings.beginGroup("MainWindow");
|
Chris@123
|
2342 int deflt = settings.value("lastimageexportregion", 0).toInt();
|
Chris@123
|
2343 if (deflt == 2 && !haveSelection) deflt = 1;
|
Chris@124
|
2344 if (deflt == 0 && total.width() > 32767) deflt = 1;
|
Chris@124
|
2345
|
Chris@124
|
2346 ListInputDialog *lid = new ListInputDialog
|
Chris@123
|
2347 (this, tr("Select region to export"),
|
Chris@123
|
2348 tr("Which region of the current pane do you want to export as an image?"),
|
Chris@124
|
2349 items, deflt);
|
Chris@124
|
2350
|
Chris@124
|
2351 if (!haveSelection) {
|
Chris@124
|
2352 lid->setItemAvailability(2, false);
|
Chris@124
|
2353 }
|
Chris@124
|
2354 if (total.width() > 32767) { // appears to be the limit of a QImage
|
Chris@124
|
2355 lid->setItemAvailability(0, false);
|
Chris@124
|
2356 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
|
Chris@124
|
2357 }
|
Chris@124
|
2358
|
Chris@124
|
2359 bool ok = lid->exec();
|
Chris@124
|
2360 QString item = lid->getCurrentString();
|
Chris@124
|
2361 delete lid;
|
Chris@123
|
2362
|
Chris@123
|
2363 if (!ok || item.isEmpty()) return;
|
Chris@123
|
2364
|
Chris@123
|
2365 settings.setValue("lastimageexportregion", deflt);
|
Chris@123
|
2366
|
Chris@123
|
2367 QImage *image = 0;
|
Chris@123
|
2368
|
Chris@123
|
2369 if (item == items[0]) {
|
Chris@123
|
2370 image = pane->toNewImage();
|
Chris@123
|
2371 } else if (item == items[1]) {
|
Chris@123
|
2372 image = pane->toNewImage(pane->getFirstVisibleFrame(),
|
Chris@123
|
2373 pane->getLastVisibleFrame());
|
Chris@123
|
2374 } else if (haveSelection) {
|
Chris@123
|
2375 image = pane->toNewImage(sf0, sf1);
|
Chris@123
|
2376 }
|
Chris@123
|
2377
|
Chris@121
|
2378 if (!image) return;
|
Chris@121
|
2379
|
Chris@121
|
2380 if (!image->save(path, "PNG")) {
|
Chris@121
|
2381 QMessageBox::critical(this, tr("Failed to save image file"),
|
Chris@121
|
2382 tr("Failed to save image file %1").arg(path));
|
Chris@121
|
2383 }
|
Chris@121
|
2384
|
Chris@121
|
2385 delete image;
|
Chris@121
|
2386 }
|
Chris@121
|
2387
|
Chris@0
|
2388 void
|
Chris@0
|
2389 MainWindow::newSession()
|
Chris@0
|
2390 {
|
Chris@0
|
2391 if (!checkSaveModified()) return;
|
Chris@0
|
2392
|
Chris@0
|
2393 closeSession();
|
Chris@0
|
2394 createDocument();
|
Chris@0
|
2395
|
Chris@0
|
2396 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
2397
|
Chris@90
|
2398 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@116
|
2399 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@90
|
2400
|
Chris@0
|
2401 if (!m_timeRulerLayer) {
|
Chris@0
|
2402 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2403 (LayerFactory::TimeRuler);
|
Chris@0
|
2404 }
|
Chris@0
|
2405
|
Chris@0
|
2406 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2407
|
Chris@0
|
2408 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@0
|
2409 m_document->addLayerToView(pane, waveform);
|
Chris@0
|
2410
|
Chris@65
|
2411 m_overview->registerView(pane);
|
Chris@0
|
2412
|
Chris@0
|
2413 CommandHistory::getInstance()->clear();
|
Chris@0
|
2414 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2415 documentRestored();
|
Chris@0
|
2416 updateMenuStates();
|
Chris@0
|
2417 }
|
Chris@0
|
2418
|
Chris@0
|
2419 void
|
Chris@303
|
2420 MainWindow::documentReplaced()
|
Chris@303
|
2421 {
|
Chris@303
|
2422 if (m_document) {
|
Chris@303
|
2423 connect(m_document, SIGNAL(activity(QString)),
|
Chris@303
|
2424 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@303
|
2425 }
|
Chris@303
|
2426 }
|
Chris@303
|
2427
|
Chris@303
|
2428 void
|
Chris@0
|
2429 MainWindow::closeSession()
|
Chris@0
|
2430 {
|
Chris@0
|
2431 if (!checkSaveModified()) return;
|
Chris@0
|
2432
|
Chris@0
|
2433 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
2434
|
Chris@0
|
2435 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
2436
|
Chris@0
|
2437 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2438 m_document->removeLayerFromView
|
Chris@0
|
2439 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2440 }
|
Chris@0
|
2441
|
Chris@65
|
2442 m_overview->unregisterView(pane);
|
Chris@0
|
2443 m_paneStack->deletePane(pane);
|
Chris@0
|
2444 }
|
Chris@0
|
2445
|
Chris@0
|
2446 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
2447
|
Chris@0
|
2448 Pane *pane = m_paneStack->getHiddenPane
|
Chris@0
|
2449 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@0
|
2450
|
Chris@0
|
2451 while (pane->getLayerCount() > 0) {
|
Chris@0
|
2452 m_document->removeLayerFromView
|
Chris@0
|
2453 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@0
|
2454 }
|
Chris@0
|
2455
|
Chris@65
|
2456 m_overview->unregisterView(pane);
|
Chris@0
|
2457 m_paneStack->deletePane(pane);
|
Chris@0
|
2458 }
|
Chris@0
|
2459
|
Chris@0
|
2460 delete m_document;
|
Chris@0
|
2461 m_document = 0;
|
Chris@0
|
2462 m_viewManager->clearSelections();
|
Chris@0
|
2463 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
2464
|
Chris@0
|
2465 m_sessionFile = "";
|
Chris@0
|
2466 setWindowTitle(tr("Sonic Visualiser"));
|
Chris@0
|
2467
|
Chris@0
|
2468 CommandHistory::getInstance()->clear();
|
Chris@0
|
2469 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2470 documentRestored();
|
Chris@0
|
2471 }
|
Chris@0
|
2472
|
Chris@0
|
2473 void
|
Chris@0
|
2474 MainWindow::openSession()
|
Chris@0
|
2475 {
|
Chris@0
|
2476 if (!checkSaveModified()) return;
|
Chris@0
|
2477
|
Chris@0
|
2478 QString orig = m_audioFile;
|
Chris@0
|
2479 if (orig == "") orig = ".";
|
Chris@0
|
2480 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2481
|
Chris@88
|
2482 QString path = getOpenFileName(FileFinder::SessionFile);
|
Chris@0
|
2483
|
Chris@0
|
2484 if (path.isEmpty()) return;
|
Chris@0
|
2485
|
Chris@200
|
2486 if (openSessionFile(path) == FileOpenFailed) {
|
Chris@247
|
2487 emit hideSplash();
|
Chris@0
|
2488 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2489 tr("<b>File open failed</b><p>Session file \"%1\" could not be opened").arg(path));
|
Chris@0
|
2490 }
|
Chris@0
|
2491 }
|
Chris@0
|
2492
|
Chris@0
|
2493 void
|
Chris@0
|
2494 MainWindow::openSomething()
|
Chris@0
|
2495 {
|
Chris@0
|
2496 QString orig = m_audioFile;
|
Chris@0
|
2497 if (orig == "") orig = ".";
|
Chris@0
|
2498 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2499
|
Chris@88
|
2500 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
2501
|
Chris@0
|
2502 if (path.isEmpty()) return;
|
Chris@0
|
2503
|
Chris@197
|
2504 FileOpenStatus status = open(path, AskUser);
|
Chris@193
|
2505
|
Chris@193
|
2506 if (status == FileOpenFailed) {
|
Chris@247
|
2507 emit hideSplash();
|
Chris@193
|
2508 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@193
|
2509 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@193
|
2510 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2511 emit hideSplash();
|
Chris@193
|
2512 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@294
|
2513 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
|
2514 }
|
Chris@0
|
2515 }
|
Chris@0
|
2516
|
Chris@0
|
2517 void
|
Chris@86
|
2518 MainWindow::openLocation()
|
Chris@86
|
2519 {
|
Chris@103
|
2520 QSettings settings;
|
Chris@103
|
2521 settings.beginGroup("MainWindow");
|
Chris@103
|
2522 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@103
|
2523
|
Chris@86
|
2524 bool ok = false;
|
Chris@86
|
2525 QString text = QInputDialog::getText
|
Chris@86
|
2526 (this, tr("Open Location"),
|
Chris@86
|
2527 tr("Please enter the URL of the location to open:"),
|
Chris@103
|
2528 QLineEdit::Normal, lastLocation, &ok);
|
Chris@103
|
2529
|
Chris@103
|
2530 if (!ok) return;
|
Chris@103
|
2531
|
Chris@103
|
2532 settings.setValue("lastremote", text);
|
Chris@103
|
2533
|
Chris@103
|
2534 if (text.isEmpty()) return;
|
Chris@86
|
2535
|
Chris@197
|
2536 FileOpenStatus status = open(text);
|
Chris@193
|
2537
|
Chris@193
|
2538 if (status == FileOpenFailed) {
|
Chris@247
|
2539 emit hideSplash();
|
Chris@86
|
2540 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2541 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@193
|
2542 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2543 emit hideSplash();
|
Chris@193
|
2544 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
2545 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
|
2546 }
|
Chris@86
|
2547 }
|
Chris@86
|
2548
|
Chris@86
|
2549 void
|
Chris@0
|
2550 MainWindow::openRecentFile()
|
Chris@0
|
2551 {
|
Chris@0
|
2552 QObject *obj = sender();
|
Chris@0
|
2553 QAction *action = dynamic_cast<QAction *>(obj);
|
Chris@0
|
2554
|
Chris@0
|
2555 if (!action) {
|
Chris@0
|
2556 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@0
|
2557 << std::endl;
|
Chris@0
|
2558 return;
|
Chris@0
|
2559 }
|
Chris@0
|
2560
|
Chris@0
|
2561 QString path = action->text();
|
Chris@0
|
2562 if (path == "") return;
|
Chris@0
|
2563
|
Chris@197
|
2564 FileOpenStatus status = open(path);
|
Chris@193
|
2565
|
Chris@193
|
2566 if (status == FileOpenFailed) {
|
Chris@247
|
2567 emit hideSplash();
|
Chris@193
|
2568 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@193
|
2569 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@193
|
2570 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2571 emit hideSplash();
|
Chris@193
|
2572 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@294
|
2573 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
|
2574 }
|
Chris@0
|
2575 }
|
Chris@0
|
2576
|
Chris@0
|
2577 void
|
Chris@200
|
2578 MainWindow::paneAdded(Pane *pane)
|
Chris@200
|
2579 {
|
Chris@200
|
2580 if (m_overview) m_overview->registerView(pane);
|
Chris@200
|
2581 }
|
Chris@200
|
2582
|
Chris@200
|
2583 void
|
Chris@200
|
2584 MainWindow::paneHidden(Pane *pane)
|
Chris@200
|
2585 {
|
Chris@200
|
2586 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2587 }
|
Chris@200
|
2588
|
Chris@200
|
2589 void
|
Chris@200
|
2590 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@200
|
2591 {
|
Chris@200
|
2592 if (m_overview) m_overview->unregisterView(pane);
|
Chris@200
|
2593 }
|
Chris@200
|
2594
|
Chris@200
|
2595 void
|
Chris@193
|
2596 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@193
|
2597 {
|
Chris@193
|
2598 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2599
|
Chris@193
|
2600 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@193
|
2601
|
Chris@295
|
2602 FileOpenStatus status;
|
Chris@295
|
2603
|
Chris@295
|
2604 if (i == uriList.begin()) {
|
Chris@295
|
2605 status = open(*i, ReplaceCurrentPane);
|
Chris@295
|
2606 } else {
|
Chris@295
|
2607 status = open(*i, CreateAdditionalModel);
|
Chris@295
|
2608 }
|
Chris@193
|
2609
|
Chris@193
|
2610 if (status == FileOpenFailed) {
|
Chris@247
|
2611 emit hideSplash();
|
Chris@193
|
2612 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@193
|
2613 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@295
|
2614 break;
|
Chris@193
|
2615 } else if (status == FileOpenWrongMode) {
|
Chris@247
|
2616 emit hideSplash();
|
Chris@193
|
2617 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@294
|
2618 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
|
2619 break;
|
Chris@295
|
2620 } else if (status == FileOpenCancelled) {
|
Chris@295
|
2621 break;
|
Chris@193
|
2622 }
|
Chris@193
|
2623 }
|
Chris@193
|
2624 }
|
Chris@193
|
2625
|
Chris@193
|
2626 void
|
Chris@193
|
2627 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@193
|
2628 {
|
Chris@193
|
2629 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@193
|
2630
|
Chris@193
|
2631 QUrl testUrl(text);
|
Chris@193
|
2632 if (testUrl.scheme() == "file" ||
|
Chris@193
|
2633 testUrl.scheme() == "http" ||
|
Chris@193
|
2634 testUrl.scheme() == "ftp") {
|
Chris@193
|
2635 QStringList list;
|
Chris@193
|
2636 list.push_back(text);
|
Chris@193
|
2637 paneDropAccepted(pane, list);
|
Chris@193
|
2638 return;
|
Chris@193
|
2639 }
|
Chris@193
|
2640
|
Chris@193
|
2641 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@193
|
2642 //to a text layer?
|
Chris@193
|
2643 }
|
Chris@193
|
2644
|
Chris@193
|
2645 void
|
Chris@0
|
2646 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
2647 {
|
Chris@137
|
2648 // std::cerr << "MainWindow::closeEvent" << std::endl;
|
Chris@118
|
2649
|
Chris@136
|
2650 if (m_openingAudioFile) {
|
Chris@137
|
2651 // std::cerr << "Busy - ignoring close event" << std::endl;
|
Chris@136
|
2652 e->ignore();
|
Chris@136
|
2653 return;
|
Chris@136
|
2654 }
|
Chris@136
|
2655
|
Chris@70
|
2656 if (!m_abandoning && !checkSaveModified()) {
|
Chris@137
|
2657 // std::cerr << "Ignoring close event" << std::endl;
|
Chris@0
|
2658 e->ignore();
|
Chris@0
|
2659 return;
|
Chris@0
|
2660 }
|
Chris@0
|
2661
|
Chris@5
|
2662 QSettings settings;
|
Chris@5
|
2663 settings.beginGroup("MainWindow");
|
Chris@5
|
2664 settings.setValue("size", size());
|
Chris@5
|
2665 settings.setValue("position", pos());
|
Chris@5
|
2666 settings.endGroup();
|
Chris@5
|
2667
|
Chris@163
|
2668 delete m_keyReference;
|
Chris@163
|
2669 m_keyReference = 0;
|
Chris@163
|
2670
|
Chris@163
|
2671 if (m_preferencesDialog &&
|
Chris@163
|
2672 m_preferencesDialog->isVisible()) {
|
Chris@164
|
2673 closeSession(); // otherwise we'll have to wait for prefs changes
|
Chris@163
|
2674 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2675 }
|
Chris@163
|
2676
|
Chris@200
|
2677 closeSession();
|
Chris@200
|
2678
|
Chris@0
|
2679 e->accept();
|
Chris@0
|
2680 return;
|
Chris@0
|
2681 }
|
Chris@0
|
2682
|
Chris@0
|
2683 bool
|
Chris@11
|
2684 MainWindow::commitData(bool mayAskUser)
|
Chris@11
|
2685 {
|
Chris@11
|
2686 if (mayAskUser) {
|
Chris@163
|
2687 bool rv = checkSaveModified();
|
Chris@163
|
2688 if (rv) {
|
Chris@163
|
2689 if (m_preferencesDialog &&
|
Chris@163
|
2690 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2691 m_preferencesDialog->applicationClosing(false);
|
Chris@163
|
2692 }
|
Chris@163
|
2693 }
|
Chris@163
|
2694 return rv;
|
Chris@11
|
2695 } else {
|
Chris@163
|
2696 if (m_preferencesDialog &&
|
Chris@163
|
2697 m_preferencesDialog->isVisible()) {
|
Chris@163
|
2698 m_preferencesDialog->applicationClosing(true);
|
Chris@163
|
2699 }
|
Chris@11
|
2700 if (!m_documentModified) return true;
|
Chris@11
|
2701
|
Chris@11
|
2702 // If we can't check with the user first, then we can't save
|
Chris@11
|
2703 // to the original session file (even if we have it) -- have
|
Chris@11
|
2704 // to use a temporary file
|
Chris@11
|
2705
|
Chris@11
|
2706 QString svDirBase = ".sv1";
|
Chris@11
|
2707 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@11
|
2708
|
Chris@11
|
2709 if (!QFileInfo(svDir).exists()) {
|
Chris@11
|
2710 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@11
|
2711 } else {
|
Chris@11
|
2712 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@11
|
2713 }
|
Chris@11
|
2714
|
Chris@11
|
2715 // This name doesn't have to be unguessable
|
Chris@93
|
2716 #ifndef _WIN32
|
Chris@11
|
2717 QString fname = QString("tmp-%1-%2.sv")
|
Chris@11
|
2718 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@11
|
2719 .arg(QProcess().pid());
|
Chris@93
|
2720 #else
|
Chris@93
|
2721 QString fname = QString("tmp-%1.sv")
|
Chris@93
|
2722 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@93
|
2723 #endif
|
Chris@11
|
2724 QString fpath = QDir(svDir).filePath(fname);
|
Chris@11
|
2725 if (saveSessionFile(fpath)) {
|
Chris@34
|
2726 m_recentFiles.addFile(fpath);
|
Chris@11
|
2727 return true;
|
Chris@11
|
2728 } else {
|
Chris@11
|
2729 return false;
|
Chris@11
|
2730 }
|
Chris@11
|
2731 }
|
Chris@11
|
2732 }
|
Chris@11
|
2733
|
Chris@11
|
2734 bool
|
Chris@0
|
2735 MainWindow::checkSaveModified()
|
Chris@0
|
2736 {
|
Chris@0
|
2737 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
2738 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
2739 // cancel.
|
Chris@0
|
2740
|
Chris@0
|
2741 if (!m_documentModified) return true;
|
Chris@0
|
2742
|
Chris@247
|
2743 emit hideSplash();
|
Chris@247
|
2744
|
Chris@0
|
2745 int button =
|
Chris@0
|
2746 QMessageBox::warning(this,
|
Chris@0
|
2747 tr("Session modified"),
|
Chris@207
|
2748 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
|
Chris@165
|
2749 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@165
|
2750 QMessageBox::Yes);
|
Chris@0
|
2751
|
Chris@0
|
2752 if (button == QMessageBox::Yes) {
|
Chris@0
|
2753 saveSession();
|
Chris@0
|
2754 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@0
|
2755 return false;
|
Chris@0
|
2756 } else {
|
Chris@0
|
2757 return true; // saved, so it's safe to continue now
|
Chris@0
|
2758 }
|
Chris@0
|
2759 } else if (button == QMessageBox::No) {
|
Chris@0
|
2760 m_documentModified = false; // so we know to abandon it
|
Chris@0
|
2761 return true;
|
Chris@0
|
2762 }
|
Chris@0
|
2763
|
Chris@0
|
2764 // else cancel
|
Chris@0
|
2765 return false;
|
Chris@0
|
2766 }
|
Chris@0
|
2767
|
Chris@290
|
2768 bool
|
Chris@294
|
2769 MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
|
Chris@290
|
2770 {
|
Chris@294
|
2771 //!!! This is very similar to part of MainWindowBase::openAudio --
|
Chris@294
|
2772 //!!! make them a bit more uniform
|
Chris@294
|
2773
|
Chris@294
|
2774 QSettings settings;
|
Chris@294
|
2775 settings.beginGroup("MainWindow");
|
Chris@294
|
2776 bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
|
Chris@294
|
2777 settings.endGroup();
|
Chris@294
|
2778 bool newSession = true;
|
Chris@294
|
2779
|
Chris@294
|
2780 QStringList items;
|
Chris@294
|
2781 items << tr("Close the current session and create a new one")
|
Chris@294
|
2782 << tr("Add this data to the current session");
|
Chris@294
|
2783
|
Chris@294
|
2784 bool ok = false;
|
Chris@294
|
2785 QString item = ListInputDialog::getItem
|
Chris@294
|
2786 (this, tr("Select target for import"),
|
Chris@294
|
2787 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
|
2788 items, prevNewSession ? 0 : 1, &ok);
|
Chris@294
|
2789
|
Chris@294
|
2790 if (!ok || item.isEmpty()) {
|
Chris@294
|
2791 *cancel = true;
|
Chris@290
|
2792 return false;
|
Chris@290
|
2793 }
|
Chris@294
|
2794
|
Chris@294
|
2795 newSession = (item == items[0]);
|
Chris@294
|
2796 settings.beginGroup("MainWindow");
|
Chris@294
|
2797 settings.setValue("newsessionforrdfaudio", newSession);
|
Chris@294
|
2798 settings.endGroup();
|
Chris@294
|
2799
|
Chris@294
|
2800 if (newSession) return true;
|
Chris@294
|
2801 else return false;
|
Chris@290
|
2802 }
|
Chris@290
|
2803
|
Chris@0
|
2804 void
|
Chris@0
|
2805 MainWindow::saveSession()
|
Chris@0
|
2806 {
|
Chris@0
|
2807 if (m_sessionFile != "") {
|
Chris@0
|
2808 if (!saveSessionFile(m_sessionFile)) {
|
Chris@0
|
2809 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2810 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@0
|
2811 } else {
|
Chris@0
|
2812 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2813 documentRestored();
|
Chris@0
|
2814 }
|
Chris@0
|
2815 } else {
|
Chris@0
|
2816 saveSessionAs();
|
Chris@0
|
2817 }
|
Chris@0
|
2818 }
|
Chris@0
|
2819
|
Chris@0
|
2820 void
|
Chris@0
|
2821 MainWindow::saveSessionAs()
|
Chris@0
|
2822 {
|
Chris@0
|
2823 QString orig = m_audioFile;
|
Chris@0
|
2824 if (orig == "") orig = ".";
|
Chris@0
|
2825 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
2826
|
Chris@88
|
2827 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@81
|
2828
|
Chris@81
|
2829 if (path == "") return;
|
Chris@0
|
2830
|
Chris@0
|
2831 if (!saveSessionFile(path)) {
|
Chris@0
|
2832 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@193
|
2833 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
2834 } else {
|
Chris@0
|
2835 setWindowTitle(tr("Sonic Visualiser: %1")
|
Chris@0
|
2836 .arg(QFileInfo(path).fileName()));
|
Chris@0
|
2837 m_sessionFile = path;
|
Chris@0
|
2838 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
2839 documentRestored();
|
Chris@34
|
2840 m_recentFiles.addFile(path);
|
Chris@0
|
2841 }
|
Chris@0
|
2842 }
|
Chris@0
|
2843
|
Chris@90
|
2844 void
|
Chris@72
|
2845 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
|
Chris@72
|
2846 {
|
Chris@200
|
2847 MainWindowBase::preferenceChanged(name);
|
Chris@200
|
2848
|
Chris@200
|
2849 if (name == "Background Mode" && m_viewManager) {
|
Chris@180
|
2850 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@180
|
2851 m_panLayer->setBaseColour
|
Chris@180
|
2852 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@180
|
2853 } else {
|
Chris@180
|
2854 m_panLayer->setBaseColour
|
Chris@180
|
2855 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
|
Chris@180
|
2856 }
|
Chris@200
|
2857 }
|
Chris@0
|
2858 }
|
Chris@0
|
2859
|
Chris@0
|
2860 void
|
Chris@239
|
2861 MainWindow::propertyStacksResized(int width)
|
Chris@239
|
2862 {
|
Chris@251
|
2863 // std::cerr << "MainWindow::propertyStacksResized(" << width << ")" << std::endl;
|
Chris@239
|
2864
|
Chris@239
|
2865 if (!m_playControlsSpacer) return;
|
Chris@239
|
2866
|
Chris@239
|
2867 int spacerWidth = width - m_playControlsWidth - 4;
|
Chris@239
|
2868
|
Chris@251
|
2869 // std::cerr << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << std::endl;
|
Chris@239
|
2870
|
Chris@239
|
2871 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
|
Chris@239
|
2872 }
|
Chris@239
|
2873
|
Chris@239
|
2874 void
|
Chris@0
|
2875 MainWindow::addPane()
|
Chris@0
|
2876 {
|
Chris@0
|
2877 QObject *s = sender();
|
Chris@0
|
2878 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
2879
|
Chris@0
|
2880 if (!action) {
|
Chris@0
|
2881 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
|
Chris@0
|
2882 << std::endl;
|
Chris@0
|
2883 return;
|
Chris@0
|
2884 }
|
Chris@0
|
2885
|
Chris@0
|
2886 PaneActionMap::iterator i = m_paneActions.find(action);
|
Chris@0
|
2887
|
Chris@0
|
2888 if (i == m_paneActions.end()) {
|
Chris@0
|
2889 std::cerr << "WARNING: MainWindow::addPane: unknown action "
|
Chris@0
|
2890 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
2891 return;
|
Chris@0
|
2892 }
|
Chris@0
|
2893
|
Chris@69
|
2894 addPane(i->second, action->text());
|
Chris@69
|
2895 }
|
Chris@69
|
2896
|
Chris@69
|
2897 void
|
Chris@232
|
2898 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
|
Chris@69
|
2899 {
|
Chris@69
|
2900 CommandHistory::getInstance()->startCompoundOperation(text, true);
|
Chris@0
|
2901
|
Chris@0
|
2902 AddPaneCommand *command = new AddPaneCommand(this);
|
Chris@0
|
2903 CommandHistory::getInstance()->addCommand(command);
|
Chris@0
|
2904
|
Chris@0
|
2905 Pane *pane = command->getPane();
|
Chris@0
|
2906
|
Chris@69
|
2907 if (configuration.layer == LayerFactory::Spectrum) {
|
Chris@109
|
2908 pane->setPlaybackFollow(PlaybackScrollContinuous);
|
Chris@110
|
2909 pane->setFollowGlobalZoom(false);
|
Chris@112
|
2910 pane->setZoomLevel(512);
|
Chris@7
|
2911 }
|
Chris@7
|
2912
|
Chris@69
|
2913 if (configuration.layer != LayerFactory::TimeRuler &&
|
Chris@69
|
2914 configuration.layer != LayerFactory::Spectrum) {
|
Chris@8
|
2915
|
Chris@0
|
2916 if (!m_timeRulerLayer) {
|
Chris@0
|
2917 // std::cerr << "no time ruler layer, creating one" << std::endl;
|
Chris@0
|
2918 m_timeRulerLayer = m_document->createMainModelLayer
|
Chris@0
|
2919 (LayerFactory::TimeRuler);
|
Chris@0
|
2920 }
|
Chris@0
|
2921
|
Chris@0
|
2922 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
|
Chris@0
|
2923
|
Chris@0
|
2924 m_document->addLayerToView(pane, m_timeRulerLayer);
|
Chris@0
|
2925 }
|
Chris@0
|
2926
|
Chris@69
|
2927 Layer *newLayer = m_document->createLayer(configuration.layer);
|
Chris@69
|
2928
|
Chris@69
|
2929 Model *suggestedModel = configuration.sourceModel;
|
Chris@66
|
2930 Model *model = 0;
|
Chris@66
|
2931
|
Chris@66
|
2932 if (suggestedModel) {
|
Chris@66
|
2933
|
Chris@66
|
2934 // check its validity
|
Chris@224
|
2935 std::vector<Model *> inputModels = m_document->getTransformInputModels();
|
Chris@66
|
2936 for (size_t j = 0; j < inputModels.size(); ++j) {
|
Chris@66
|
2937 if (inputModels[j] == suggestedModel) {
|
Chris@66
|
2938 model = suggestedModel;
|
Chris@66
|
2939 break;
|
Chris@66
|
2940 }
|
Chris@66
|
2941 }
|
Chris@66
|
2942
|
Chris@66
|
2943 if (!model) {
|
Chris@66
|
2944 std::cerr << "WARNING: Model " << (void *)suggestedModel
|
Chris@66
|
2945 << " appears in pane action map, but is not reported "
|
Chris@66
|
2946 << "by document as a valid transform source" << std::endl;
|
Chris@66
|
2947 }
|
Chris@66
|
2948 }
|
Chris@66
|
2949
|
Chris@66
|
2950 if (!model) model = m_document->getMainModel();
|
Chris@66
|
2951
|
Chris@66
|
2952 m_document->setModel(newLayer, model);
|
Chris@66
|
2953
|
Chris@69
|
2954 m_document->setChannel(newLayer, configuration.channel);
|
Chris@0
|
2955 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2956
|
Chris@0
|
2957 m_paneStack->setCurrentPane(pane);
|
Chris@70
|
2958 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
2959
|
Chris@130
|
2960 // std::cerr << "MainWindow::addPane: global centre frame is "
|
Chris@130
|
2961 // << m_viewManager->getGlobalCentreFrame() << std::endl;
|
Chris@130
|
2962 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
|
Chris@73
|
2963
|
Chris@0
|
2964 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@0
|
2965
|
Chris@0
|
2966 updateMenuStates();
|
Chris@0
|
2967 }
|
Chris@0
|
2968
|
Chris@0
|
2969 void
|
Chris@0
|
2970 MainWindow::addLayer()
|
Chris@0
|
2971 {
|
Chris@0
|
2972 QObject *s = sender();
|
Chris@0
|
2973 QAction *action = dynamic_cast<QAction *>(s);
|
Chris@0
|
2974
|
Chris@0
|
2975 if (!action) {
|
Chris@0
|
2976 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
|
Chris@0
|
2977 << std::endl;
|
Chris@0
|
2978 return;
|
Chris@0
|
2979 }
|
Chris@0
|
2980
|
Chris@0
|
2981 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
2982
|
Chris@0
|
2983 if (!pane) {
|
Chris@0
|
2984 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@0
|
2985 return;
|
Chris@0
|
2986 }
|
Chris@0
|
2987
|
Chris@0
|
2988 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
|
Chris@0
|
2989
|
Chris@0
|
2990 if (ei != m_existingLayerActions.end()) {
|
Chris@0
|
2991 Layer *newLayer = ei->second;
|
Chris@0
|
2992 m_document->addLayerToView(pane, newLayer);
|
Chris@0
|
2993 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
2994 return;
|
Chris@0
|
2995 }
|
Chris@0
|
2996
|
Chris@95
|
2997 ei = m_sliceActions.find(action);
|
Chris@95
|
2998
|
Chris@95
|
2999 if (ei != m_sliceActions.end()) {
|
Chris@95
|
3000 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
|
Chris@95
|
3001 // document->setModel(newLayer, ei->second->getModel());
|
Chris@95
|
3002 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
|
Chris@95
|
3003 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
|
Chris@95
|
3004 if (source && dest) {
|
Chris@205
|
3005 //!!!???
|
Chris@95
|
3006 dest->setSliceableModel(source->getSliceableModel());
|
Chris@95
|
3007 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
|
Chris@95
|
3008 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
|
Chris@95
|
3009 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
|
Chris@95
|
3010 dest, SLOT(modelAboutToBeDeleted(Model *)));
|
Chris@95
|
3011 }
|
Chris@95
|
3012 m_document->addLayerToView(pane, newLayer);
|
Chris@95
|
3013 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@95
|
3014 return;
|
Chris@95
|
3015 }
|
Chris@95
|
3016
|
Chris@211
|
3017 TransformActionMap::iterator i = m_transformActions.find(action);
|
Chris@34
|
3018
|
Chris@34
|
3019 if (i == m_transformActions.end()) {
|
Chris@0
|
3020
|
Chris@0
|
3021 LayerActionMap::iterator i = m_layerActions.find(action);
|
Chris@0
|
3022
|
Chris@0
|
3023 if (i == m_layerActions.end()) {
|
Chris@0
|
3024 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
|
Chris@0
|
3025 << action->objectName().toStdString() << std::endl;
|
Chris@0
|
3026 return;
|
Chris@0
|
3027 }
|
Chris@0
|
3028
|
Chris@232
|
3029 LayerFactory::LayerType type = i->second.layer;
|
Chris@0
|
3030
|
Chris@0
|
3031 LayerFactory::LayerTypeSet emptyTypes =
|
Chris@0
|
3032 LayerFactory::getInstance()->getValidEmptyLayerTypes();
|
Chris@0
|
3033
|
Chris@0
|
3034 Layer *newLayer;
|
Chris@0
|
3035
|
Chris@0
|
3036 if (emptyTypes.find(type) != emptyTypes.end()) {
|
Chris@0
|
3037
|
Chris@0
|
3038 newLayer = m_document->createEmptyLayer(type);
|
Chris@217
|
3039 if (newLayer) {
|
Chris@217
|
3040 m_toolActions[ViewManager::DrawMode]->trigger();
|
Chris@217
|
3041 }
|
Chris@0
|
3042
|
Chris@0
|
3043 } else {
|
Chris@0
|
3044
|
Chris@238
|
3045 if (!i->second.sourceModel) {
|
Chris@238
|
3046 // e.g. time ruler
|
Chris@238
|
3047 newLayer = m_document->createMainModelLayer(type);
|
Chris@232
|
3048 } else {
|
Chris@238
|
3049 newLayer = m_document->createLayer(type);
|
Chris@238
|
3050 if (m_document->isKnownModel(i->second.sourceModel)) {
|
Chris@238
|
3051 m_document->setChannel(newLayer, i->second.channel);
|
Chris@238
|
3052 m_document->setModel(newLayer, i->second.sourceModel);
|
Chris@238
|
3053 } else {
|
Chris@238
|
3054 std::cerr << "WARNING: MainWindow::addLayer: unknown model "
|
Chris@238
|
3055 << i->second.sourceModel
|
Chris@238
|
3056 << " (\""
|
Chris@238
|
3057 << (i->second.sourceModel ? i->second.sourceModel->objectName().toStdString() : "")
|
Chris@238
|
3058 << "\") in layer action map"
|
Chris@238
|
3059 << std::endl;
|
Chris@238
|
3060 }
|
Chris@232
|
3061 }
|
Chris@238
|
3062 }
|
Chris@0
|
3063
|
Chris@217
|
3064 if (newLayer) {
|
Chris@217
|
3065 m_document->addLayerToView(pane, newLayer);
|
Chris@217
|
3066 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@217
|
3067 }
|
Chris@0
|
3068
|
Chris@0
|
3069 return;
|
Chris@0
|
3070 }
|
Chris@0
|
3071
|
Chris@224
|
3072 //!!! want to do something like this, but it's not supported in
|
Chris@224
|
3073 //ModelTransformerFactory yet
|
Chris@224
|
3074 /*
|
Chris@0
|
3075 int channel = -1;
|
Chris@0
|
3076 // pick up the default channel from any existing layers on the same pane
|
Chris@0
|
3077 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@0
|
3078 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
|
Chris@0
|
3079 if (c != -1) {
|
Chris@0
|
3080 channel = c;
|
Chris@0
|
3081 break;
|
Chris@0
|
3082 }
|
Chris@0
|
3083 }
|
Chris@224
|
3084 */
|
Chris@0
|
3085
|
Chris@33
|
3086 // We always ask for configuration, even if the plugin isn't
|
Chris@33
|
3087 // supposed to be configurable, because we need to let the user
|
Chris@33
|
3088 // change the execution context (block size etc).
|
Chris@0
|
3089
|
Chris@224
|
3090 QString transformId = i->second;
|
Chris@274
|
3091
|
Chris@274
|
3092 addLayer(transformId);
|
Chris@274
|
3093 }
|
Chris@274
|
3094
|
Chris@274
|
3095 void
|
Chris@274
|
3096 MainWindow::addLayer(QString transformId)
|
Chris@274
|
3097 {
|
Chris@274
|
3098 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@274
|
3099 if (!pane) {
|
Chris@274
|
3100 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
|
Chris@274
|
3101 return;
|
Chris@274
|
3102 }
|
Chris@274
|
3103
|
Chris@224
|
3104 Transform transform = TransformFactory::getInstance()->
|
Chris@224
|
3105 getDefaultTransformFor(transformId);
|
Chris@27
|
3106
|
Chris@66
|
3107 std::vector<Model *> candidateInputModels =
|
Chris@224
|
3108 m_document->getTransformInputModels();
|
Chris@53
|
3109
|
Chris@219
|
3110 Model *defaultInputModel = 0;
|
Chris@219
|
3111 for (int j = 0; j < pane->getLayerCount(); ++j) {
|
Chris@219
|
3112 Layer *layer = pane->getLayer(j);
|
Chris@219
|
3113 if (!layer) continue;
|
Chris@243
|
3114 if (LayerFactory::getInstance()->getLayerType(layer) !=
|
Chris@243
|
3115 LayerFactory::Waveform &&
|
Chris@243
|
3116 !layer->isLayerOpaque()) continue;
|
Chris@219
|
3117 Model *model = layer->getModel();
|
Chris@219
|
3118 if (!model) continue;
|
Chris@219
|
3119 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
|
Chris@219
|
3120 if (candidateInputModels[k] == model) {
|
Chris@219
|
3121 defaultInputModel = model;
|
Chris@219
|
3122 break;
|
Chris@219
|
3123 }
|
Chris@219
|
3124 }
|
Chris@219
|
3125 if (defaultInputModel) break;
|
Chris@219
|
3126 }
|
Chris@219
|
3127
|
Chris@184
|
3128 size_t startFrame = 0, duration = 0;
|
Chris@184
|
3129 size_t endFrame = 0;
|
Chris@184
|
3130 m_viewManager->getSelection().getExtents(startFrame, endFrame);
|
Chris@184
|
3131 if (endFrame > startFrame) duration = endFrame - startFrame;
|
Chris@184
|
3132 else startFrame = 0;
|
Chris@184
|
3133
|
Chris@224
|
3134 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
Chris@224
|
3135 getConfigurationForTransform
|
Chris@211
|
3136 (transform,
|
Chris@211
|
3137 candidateInputModels,
|
Chris@219
|
3138 defaultInputModel,
|
Chris@211
|
3139 m_playSource,
|
Chris@211
|
3140 startFrame,
|
Chris@211
|
3141 duration);
|
Chris@211
|
3142
|
Chris@224
|
3143 if (!input.getModel()) return;
|
Chris@224
|
3144
|
Chris@224
|
3145 // std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl;
|
Chris@224
|
3146
|
Chris@224
|
3147 Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
Chris@0
|
3148
|
Chris@0
|
3149 if (newLayer) {
|
Chris@0
|
3150 m_document->addLayerToView(pane, newLayer);
|
Chris@224
|
3151 m_document->setChannel(newLayer, input.getChannel());
|
Chris@224
|
3152 m_recentTransforms.add(transformId);
|
Chris@70
|
3153 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@0
|
3154 }
|
Chris@0
|
3155
|
Chris@0
|
3156 updateMenuStates();
|
Chris@0
|
3157 }
|
Chris@0
|
3158
|
Chris@0
|
3159 void
|
Chris@0
|
3160 MainWindow::renameCurrentLayer()
|
Chris@0
|
3161 {
|
Chris@0
|
3162 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@0
|
3163 if (pane) {
|
Chris@0
|
3164 Layer *layer = pane->getSelectedLayer();
|
Chris@0
|
3165 if (layer) {
|
Chris@0
|
3166 bool ok = false;
|
Chris@0
|
3167 QString newName = QInputDialog::getText
|
Chris@0
|
3168 (this, tr("Rename Layer"),
|
Chris@0
|
3169 tr("New name for this layer:"),
|
Chris@0
|
3170 QLineEdit::Normal, layer->objectName(), &ok);
|
Chris@0
|
3171 if (ok) {
|
Chris@239
|
3172 layer->setPresentationName(newName);
|
Chris@95
|
3173 setupExistingLayersMenus();
|
Chris@0
|
3174 }
|
Chris@0
|
3175 }
|
Chris@0
|
3176 }
|
Chris@0
|
3177 }
|
Chris@0
|
3178
|
Chris@0
|
3179 void
|
Chris@272
|
3180 MainWindow::findTransform()
|
Chris@272
|
3181 {
|
Chris@274
|
3182 TransformFinder *finder = new TransformFinder(this);
|
Chris@274
|
3183 if (!finder->exec()) {
|
Chris@274
|
3184 delete finder;
|
Chris@274
|
3185 return;
|
Chris@273
|
3186 }
|
Chris@274
|
3187 TransformId transform = finder->getTransform();
|
Chris@274
|
3188 delete finder;
|
Chris@287
|
3189
|
Chris@287
|
3190 if (getMainModel() != 0 && m_paneStack->getCurrentPane() != 0) {
|
Chris@287
|
3191 addLayer(transform);
|
Chris@287
|
3192 }
|
Chris@272
|
3193 }
|
Chris@272
|
3194
|
Chris@272
|
3195 void
|
Chris@207
|
3196 MainWindow::playSoloToggled()
|
Chris@207
|
3197 {
|
Chris@207
|
3198 MainWindowBase::playSoloToggled();
|
Chris@207
|
3199 m_soloModified = true;
|
Chris@207
|
3200 }
|
Chris@207
|
3201
|
Chris@207
|
3202 void
|
Chris@206
|
3203 MainWindow::alignToggled()
|
Chris@206
|
3204 {
|
Chris@206
|
3205 QAction *action = dynamic_cast<QAction *>(sender());
|
Chris@206
|
3206
|
Chris@207
|
3207 if (!m_viewManager) return;
|
Chris@207
|
3208
|
Chris@206
|
3209 if (action) {
|
Chris@206
|
3210 m_viewManager->setAlignMode(action->isChecked());
|
Chris@206
|
3211 } else {
|
Chris@206
|
3212 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
|
Chris@206
|
3213 }
|
Chris@206
|
3214
|
Chris@206
|
3215 if (m_viewManager->getAlignMode()) {
|
Chris@207
|
3216 m_prevSolo = m_soloAction->isChecked();
|
Chris@208
|
3217 if (!m_soloAction->isChecked()) {
|
Chris@208
|
3218 m_soloAction->setChecked(true);
|
Chris@208
|
3219 MainWindowBase::playSoloToggled();
|
Chris@208
|
3220 }
|
Chris@207
|
3221 m_soloModified = false;
|
Chris@207
|
3222 emit canChangeSolo(false);
|
Chris@206
|
3223 m_document->alignModels();
|
Chris@206
|
3224 m_document->setAutoAlignment(true);
|
Chris@206
|
3225 } else {
|
Chris@207
|
3226 if (!m_soloModified) {
|
Chris@208
|
3227 if (m_soloAction->isChecked() != m_prevSolo) {
|
Chris@208
|
3228 m_soloAction->setChecked(m_prevSolo);
|
Chris@208
|
3229 MainWindowBase::playSoloToggled();
|
Chris@208
|
3230 }
|
Chris@207
|
3231 }
|
Chris@207
|
3232 emit canChangeSolo(true);
|
Chris@206
|
3233 m_document->setAutoAlignment(false);
|
Chris@206
|
3234 }
|
Chris@206
|
3235
|
Chris@206
|
3236 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
|
Chris@206
|
3237
|
Chris@206
|
3238 Pane *pane = m_paneStack->getPane(i);
|
Chris@206
|
3239 if (!pane) continue;
|
Chris@206
|
3240
|
Chris@206
|
3241 pane->update();
|
Chris@206
|
3242 }
|
Chris@206
|
3243 }
|
Chris@206
|
3244
|
Chris@206
|
3245 void
|
Chris@59
|
3246 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
3247 {
|
Chris@59
|
3248 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@60
|
3249
|
Chris@60
|
3250 float percent = m_playSpeed->mappedValue();
|
Chris@60
|
3251 float factor = mapper.getFactorForValue(percent);
|
Chris@60
|
3252
|
Chris@267
|
3253 // std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
|
Chris@60
|
3254
|
Chris@59
|
3255 bool something = (position != 100);
|
Chris@155
|
3256
|
Chris@59
|
3257 int pc = lrintf(percent);
|
Chris@21
|
3258
|
Chris@155
|
3259 if (!something) {
|
Chris@155
|
3260 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@155
|
3261 } else {
|
Chris@155
|
3262 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@155
|
3263 .arg(position > 100 ? "+" : "")
|
Chris@155
|
3264 .arg(pc));
|
Chris@155
|
3265 }
|
Chris@155
|
3266
|
Chris@240
|
3267 m_playSource->setTimeStretch(factor);
|
Chris@155
|
3268
|
Chris@155
|
3269 updateMenuStates();
|
Chris@16
|
3270 }
|
Chris@16
|
3271
|
Chris@26
|
3272 void
|
Chris@155
|
3273 MainWindow::speedUpPlayback()
|
Chris@155
|
3274 {
|
Chris@155
|
3275 int value = m_playSpeed->value();
|
Chris@155
|
3276 value = value + m_playSpeed->pageStep();
|
Chris@155
|
3277 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@155
|
3278 m_playSpeed->setValue(value);
|
Chris@155
|
3279 }
|
Chris@155
|
3280
|
Chris@155
|
3281 void
|
Chris@155
|
3282 MainWindow::slowDownPlayback()
|
Chris@155
|
3283 {
|
Chris@155
|
3284 int value = m_playSpeed->value();
|
Chris@155
|
3285 value = value - m_playSpeed->pageStep();
|
Chris@155
|
3286 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@155
|
3287 m_playSpeed->setValue(value);
|
Chris@155
|
3288 }
|
Chris@155
|
3289
|
Chris@155
|
3290 void
|
Chris@155
|
3291 MainWindow::restoreNormalPlayback()
|
Chris@155
|
3292 {
|
Chris@155
|
3293 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@155
|
3294 }
|
Chris@155
|
3295
|
Chris@155
|
3296 void
|
Chris@227
|
3297 MainWindow::currentPaneChanged(Pane *pane)
|
Chris@227
|
3298 {
|
Chris@228
|
3299 MainWindowBase::currentPaneChanged(pane);
|
Chris@228
|
3300
|
Chris@227
|
3301 if (!pane || !m_panLayer) return;
|
Chris@227
|
3302 for (int i = pane->getLayerCount(); i > 0; ) {
|
Chris@227
|
3303 --i;
|
Chris@227
|
3304 Layer *layer = pane->getLayer(i);
|
Chris@227
|
3305 if (LayerFactory::getInstance()->getLayerType(layer) ==
|
Chris@227
|
3306 LayerFactory::Waveform) {
|
Chris@227
|
3307 RangeSummarisableTimeValueModel *tvm =
|
Chris@227
|
3308 dynamic_cast<RangeSummarisableTimeValueModel *>(layer->getModel());
|
Chris@227
|
3309 if (tvm) {
|
Chris@227
|
3310 m_panLayer->setModel(tvm);
|
Chris@227
|
3311 return;
|
Chris@227
|
3312 }
|
Chris@227
|
3313 }
|
Chris@227
|
3314 }
|
Chris@227
|
3315 }
|
Chris@227
|
3316
|
Chris@227
|
3317 void
|
Chris@116
|
3318 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@116
|
3319 {
|
Chris@116
|
3320 if (!getMainModel() || !p) {
|
Chris@116
|
3321 return;
|
Chris@116
|
3322 }
|
Chris@116
|
3323
|
Chris@117
|
3324 bool haveSelection = false;
|
Chris@117
|
3325 size_t startFrame = 0, endFrame = 0;
|
Chris@117
|
3326
|
Chris@117
|
3327 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@117
|
3328
|
Chris@117
|
3329 bool exclusive = false;
|
Chris@117
|
3330 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@117
|
3331
|
Chris@117
|
3332 if (!s.isEmpty()) {
|
Chris@117
|
3333 haveSelection = true;
|
Chris@117
|
3334 startFrame = s.getStartFrame();
|
Chris@117
|
3335 endFrame = s.getEndFrame();
|
Chris@117
|
3336 }
|
Chris@117
|
3337 }
|
Chris@117
|
3338
|
Chris@117
|
3339 if (!haveSelection) {
|
Chris@117
|
3340 startFrame = p->getFirstVisibleFrame();
|
Chris@117
|
3341 endFrame = p->getLastVisibleFrame();
|
Chris@117
|
3342 }
|
Chris@117
|
3343
|
Chris@116
|
3344 RealTime start = RealTime::frame2RealTime
|
Chris@117
|
3345 (startFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3346
|
Chris@116
|
3347 RealTime end = RealTime::frame2RealTime
|
Chris@117
|
3348 (endFrame, getMainModel()->getSampleRate());
|
Chris@116
|
3349
|
Chris@116
|
3350 RealTime duration = end - start;
|
Chris@116
|
3351
|
Chris@116
|
3352 QString startStr, endStr, durationStr;
|
Chris@116
|
3353 startStr = start.toText(true).c_str();
|
Chris@116
|
3354 endStr = end.toText(true).c_str();
|
Chris@116
|
3355 durationStr = duration.toText(true).c_str();
|
Chris@116
|
3356
|
Chris@117
|
3357 if (haveSelection) {
|
Chris@117
|
3358 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@117
|
3359 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3360 } else {
|
Chris@117
|
3361 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@117
|
3362 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@117
|
3363 }
|
Chris@116
|
3364
|
Chris@116
|
3365 statusBar()->showMessage(m_myStatusMessage);
|
Chris@116
|
3366 }
|
Chris@116
|
3367
|
Chris@116
|
3368 void
|
Chris@0
|
3369 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
3370 {
|
Chris@0
|
3371 m_fader->setPeakLeft(left);
|
Chris@0
|
3372 m_fader->setPeakRight(right);
|
Chris@0
|
3373 }
|
Chris@0
|
3374
|
Chris@0
|
3375 void
|
Chris@0
|
3376 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
3377 bool willResample)
|
Chris@0
|
3378 {
|
Chris@0
|
3379 if (!willResample) {
|
Chris@247
|
3380 emit hideSplash();
|
Chris@0
|
3381 QMessageBox::information
|
Chris@0
|
3382 (this, tr("Sample rate mismatch"),
|
Chris@193
|
3383 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
|
3384 .arg(requested).arg(actual));
|
Chris@0
|
3385 }
|
Chris@0
|
3386
|
Chris@0
|
3387 updateDescriptionLabel();
|
Chris@0
|
3388 }
|
Chris@0
|
3389
|
Chris@0
|
3390 void
|
Chris@42
|
3391 MainWindow::audioOverloadPluginDisabled()
|
Chris@42
|
3392 {
|
Chris@42
|
3393 QMessageBox::information
|
Chris@42
|
3394 (this, tr("Audio processing overload"),
|
Chris@193
|
3395 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@42
|
3396 }
|
Chris@42
|
3397
|
Chris@42
|
3398 void
|
Chris@266
|
3399 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@266
|
3400 {
|
Chris@266
|
3401 static bool shownOnce = false;
|
Chris@266
|
3402 if (shownOnce) return;
|
Chris@266
|
3403 QMessageBox::information
|
Chris@266
|
3404 (this, tr("Audio processing overload"),
|
Chris@266
|
3405 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@266
|
3406 shownOnce = true;
|
Chris@266
|
3407 }
|
Chris@266
|
3408
|
Chris@266
|
3409 void
|
Chris@304
|
3410 MainWindow::midiEventsAvailable()
|
Chris@304
|
3411 {
|
Chris@305
|
3412 // This is called through a serialised signal/slot invocation
|
Chris@305
|
3413 // (across threads). It could happen quite some time after the
|
Chris@305
|
3414 // event was actually received, which is why event timestamping
|
Chris@305
|
3415 // happens in the MIDI input class and not here.
|
Chris@305
|
3416 while (m_midiInput->getEventsAvailable() > 0) {
|
Chris@305
|
3417 MIDIEvent ev(m_midiInput->readEvent());
|
Chris@305
|
3418 if (ev.getMessageType() != MIDIConstants::MIDI_NOTE_ON) {
|
Chris@305
|
3419 continue;
|
Chris@305
|
3420 }
|
Chris@305
|
3421 insertInstantAt(ev.getTime());
|
Chris@304
|
3422 }
|
Chris@304
|
3423 }
|
Chris@304
|
3424
|
Chris@304
|
3425 void
|
Chris@305
|
3426 MainWindow::playStatusChanged(bool playing)
|
Chris@305
|
3427 {
|
Chris@305
|
3428 m_lastInsertedMIDITime = -1.0; // <0 means "never during this playback"
|
Chris@305
|
3429 }
|
Chris@305
|
3430
|
Chris@305
|
3431 void
|
Chris@200
|
3432 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
3433 {
|
Chris@95
|
3434 setupExistingLayersMenus();
|
Chris@200
|
3435 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
3436 }
|
Chris@0
|
3437
|
Chris@0
|
3438 void
|
Chris@0
|
3439 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
3440 {
|
Chris@95
|
3441 setupExistingLayersMenus();
|
Chris@200
|
3442 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
3443 }
|
Chris@0
|
3444
|
Chris@0
|
3445 void
|
Chris@0
|
3446 MainWindow::modelAdded(Model *model)
|
Chris@0
|
3447 {
|
Chris@200
|
3448 MainWindowBase::modelAdded(model);
|
Chris@66
|
3449 if (dynamic_cast<DenseTimeValueModel *>(model)) {
|
Chris@66
|
3450 setupPaneAndLayerMenus();
|
Chris@66
|
3451 }
|
Chris@0
|
3452 }
|
Chris@0
|
3453
|
Chris@0
|
3454 void
|
Chris@0
|
3455 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
3456 {
|
Chris@0
|
3457 m_panLayer->setModel(model);
|
Chris@200
|
3458
|
Chris@200
|
3459 MainWindowBase::mainModelChanged(model);
|
Chris@200
|
3460
|
Chris@200
|
3461 if (m_playTarget) {
|
Chris@200
|
3462 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@200
|
3463 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@200
|
3464 }
|
Chris@0
|
3465 }
|
Chris@0
|
3466
|
Chris@0
|
3467 void
|
Chris@200
|
3468 MainWindow::setInstantsNumbering()
|
Chris@0
|
3469 {
|
Chris@200
|
3470 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3471 if (!a) return;
|
Chris@200
|
3472
|
Chris@200
|
3473 int type = m_numberingActions[a];
|
Chris@200
|
3474
|
Chris@200
|
3475 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
|
Chris@200
|
3476
|
Chris@200
|
3477 QSettings settings;
|
Chris@200
|
3478 settings.beginGroup("MainWindow");
|
Chris@200
|
3479 settings.setValue("labellertype", type);
|
Chris@200
|
3480 settings.endGroup();
|
Chris@200
|
3481 }
|
Chris@200
|
3482
|
Chris@200
|
3483 void
|
Chris@200
|
3484 MainWindow::setInstantsCounterCycle()
|
Chris@200
|
3485 {
|
Chris@200
|
3486 QAction *a = dynamic_cast<QAction *>(sender());
|
Chris@200
|
3487 if (!a) return;
|
Chris@200
|
3488
|
Chris@200
|
3489 int cycle = a->text().toInt();
|
Chris@200
|
3490 if (cycle == 0) return;
|
Chris@200
|
3491
|
Chris@200
|
3492 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
|
Chris@200
|
3493
|
Chris@200
|
3494 QSettings settings;
|
Chris@200
|
3495 settings.beginGroup("MainWindow");
|
Chris@200
|
3496 settings.setValue("labellercycle", cycle);
|
Chris@200
|
3497 settings.endGroup();
|
Chris@200
|
3498 }
|
Chris@200
|
3499
|
Chris@200
|
3500 void
|
Chris@200
|
3501 MainWindow::resetInstantsCounters()
|
Chris@200
|
3502 {
|
Chris@200
|
3503 LabelCounterInputDialog dialog(m_labeller, this);
|
Chris@241
|
3504 dialog.setWindowTitle(tr("Reset Counters"));
|
Chris@200
|
3505 dialog.exec();
|
Chris@0
|
3506 }
|
Chris@0
|
3507
|
Chris@0
|
3508 void
|
Chris@233
|
3509 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@233
|
3510 {
|
Chris@247
|
3511 emit hideSplash();
|
Chris@247
|
3512
|
Chris@233
|
3513 if (message != "") {
|
Chris@233
|
3514
|
Chris@233
|
3515 QMessageBox::warning
|
Chris@233
|
3516 (this,
|
Chris@233
|
3517 tr("Failed to generate layer"),
|
Chris@233
|
3518 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@233
|
3519 .arg(transformName).arg(message),
|
Chris@233
|
3520 QMessageBox::Ok);
|
Chris@233
|
3521 } else {
|
Chris@233
|
3522 QMessageBox::warning
|
Chris@233
|
3523 (this,
|
Chris@233
|
3524 tr("Failed to generate layer"),
|
Chris@233
|
3525 tr("<b>Layer generation failed</b><p>Failed to generate a derived layer.<p>The layer transform \"%1\" failed.<p>No error information is available.")
|
Chris@233
|
3526 .arg(transformName),
|
Chris@233
|
3527 QMessageBox::Ok);
|
Chris@233
|
3528 }
|
Chris@233
|
3529 }
|
Chris@233
|
3530
|
Chris@233
|
3531 void
|
Chris@233
|
3532 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@233
|
3533 {
|
Chris@247
|
3534 emit hideSplash();
|
Chris@247
|
3535
|
Chris@233
|
3536 QMessageBox::warning
|
Chris@233
|
3537 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@233
|
3538 }
|
Chris@233
|
3539
|
Chris@233
|
3540 void
|
Chris@233
|
3541 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@233
|
3542 QString transformName, QString message)
|
Chris@233
|
3543 {
|
Chris@247
|
3544 emit hideSplash();
|
Chris@247
|
3545
|
Chris@233
|
3546 if (message != "") {
|
Chris@233
|
3547
|
Chris@233
|
3548 QMessageBox::warning
|
Chris@233
|
3549 (this,
|
Chris@233
|
3550 tr("Failed to regenerate layer"),
|
Chris@233
|
3551 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
|
3552 .arg(layerName).arg(transformName).arg(message),
|
Chris@233
|
3553 QMessageBox::Ok);
|
Chris@233
|
3554 } else {
|
Chris@233
|
3555 QMessageBox::warning
|
Chris@233
|
3556 (this,
|
Chris@233
|
3557 tr("Failed to regenerate layer"),
|
Chris@233
|
3558 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
|
3559 .arg(layerName).arg(transformName),
|
Chris@233
|
3560 QMessageBox::Ok);
|
Chris@233
|
3561 }
|
Chris@233
|
3562 }
|
Chris@233
|
3563
|
Chris@233
|
3564 void
|
Chris@233
|
3565 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@233
|
3566 QString transformName, QString message)
|
Chris@233
|
3567 {
|
Chris@247
|
3568 emit hideSplash();
|
Chris@247
|
3569
|
Chris@233
|
3570 QMessageBox::warning
|
Chris@233
|
3571 (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
|
3572 }
|
Chris@233
|
3573
|
Chris@233
|
3574 void
|
Chris@233
|
3575 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
3576 {
|
Chris@247
|
3577 emit hideSplash();
|
Chris@247
|
3578
|
Chris@0
|
3579 QMessageBox::warning
|
Chris@0
|
3580 (this,
|
Chris@233
|
3581 tr("Failed to calculate alignment"),
|
Chris@233
|
3582 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@233
|
3583 .arg(transformName).arg(message),
|
Chris@165
|
3584 QMessageBox::Ok);
|
Chris@0
|
3585 }
|
Chris@0
|
3586
|
Chris@0
|
3587 void
|
Chris@0
|
3588 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
3589 {
|
Chris@0
|
3590 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
|
Chris@0
|
3591 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
3592 m_rightButtonMenu->popup(position);
|
Chris@0
|
3593 }
|
Chris@0
|
3594
|
Chris@0
|
3595 void
|
Chris@0
|
3596 MainWindow::showLayerTree()
|
Chris@0
|
3597 {
|
Chris@219
|
3598 if (!m_layerTreeDialog.isNull()) {
|
Chris@219
|
3599 m_layerTreeDialog->show();
|
Chris@219
|
3600 m_layerTreeDialog->raise();
|
Chris@177
|
3601 return;
|
Chris@177
|
3602 }
|
Chris@177
|
3603
|
Chris@219
|
3604 m_layerTreeDialog = new LayerTreeDialog(m_paneStack);
|
Chris@232
|
3605 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
|
Chris@219
|
3606 m_layerTreeDialog->show();
|
Chris@0
|
3607 }
|
Chris@0
|
3608
|
Chris@0
|
3609 void
|
Chris@0
|
3610 MainWindow::preferences()
|
Chris@0
|
3611 {
|
Chris@0
|
3612 if (!m_preferencesDialog.isNull()) {
|
Chris@0
|
3613 m_preferencesDialog->show();
|
Chris@0
|
3614 m_preferencesDialog->raise();
|
Chris@0
|
3615 return;
|
Chris@0
|
3616 }
|
Chris@0
|
3617
|
Chris@0
|
3618 m_preferencesDialog = new PreferencesDialog(this);
|
Chris@0
|
3619
|
Chris@0
|
3620 // DeleteOnClose is safe here, because m_preferencesDialog is a
|
Chris@0
|
3621 // QPointer that will be zeroed when the dialog is deleted. We
|
Chris@0
|
3622 // use it in preference to leaving the dialog lying around because
|
Chris@0
|
3623 // if you Cancel the dialog, it resets the preferences state
|
Chris@0
|
3624 // without resetting its own widgets, so its state will be
|
Chris@0
|
3625 // incorrect when next shown unless we construct it afresh
|
Chris@0
|
3626 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
|
Chris@0
|
3627
|
Chris@0
|
3628 m_preferencesDialog->show();
|
Chris@0
|
3629 }
|
Chris@0
|
3630
|
Chris@0
|
3631 void
|
Chris@90
|
3632 MainWindow::mouseEnteredWidget()
|
Chris@90
|
3633 {
|
Chris@90
|
3634 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@90
|
3635 if (!w) return;
|
Chris@90
|
3636
|
Chris@90
|
3637 if (w == m_fader) {
|
Chris@116
|
3638 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@90
|
3639 } else if (w == m_playSpeed) {
|
Chris@116
|
3640 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@90
|
3641 }
|
Chris@90
|
3642 }
|
Chris@90
|
3643
|
Chris@90
|
3644 void
|
Chris@90
|
3645 MainWindow::mouseLeftWidget()
|
Chris@90
|
3646 {
|
Chris@116
|
3647 contextHelpChanged("");
|
Chris@116
|
3648 }
|
Chris@116
|
3649
|
Chris@116
|
3650 void
|
Chris@0
|
3651 MainWindow::website()
|
Chris@0
|
3652 {
|
Chris@0
|
3653 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
|
Chris@0
|
3654 }
|
Chris@0
|
3655
|
Chris@0
|
3656 void
|
Chris@0
|
3657 MainWindow::help()
|
Chris@0
|
3658 {
|
Chris@285
|
3659 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/1.4/en/"));
|
Chris@0
|
3660 }
|
Chris@0
|
3661
|
Chris@0
|
3662 void
|
Chris@0
|
3663 MainWindow::about()
|
Chris@0
|
3664 {
|
Chris@0
|
3665 bool debug = false;
|
Chris@0
|
3666 QString version = "(unknown version)";
|
Chris@0
|
3667
|
Chris@0
|
3668 #ifdef BUILD_DEBUG
|
Chris@0
|
3669 debug = true;
|
Chris@285
|
3670 #endif // BUILD_DEBUG
|
Chris@0
|
3671 #ifdef SV_VERSION
|
Chris@0
|
3672 #ifdef SVNREV
|
Chris@0
|
3673 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
|
Chris@285
|
3674 #else // !SVNREV
|
Chris@0
|
3675 version = tr("Release %1").arg(SV_VERSION);
|
Chris@285
|
3676 #endif // SVNREV
|
Chris@285
|
3677 #else // !SV_VERSION
|
Chris@0
|
3678 #ifdef SVNREV
|
Chris@0
|
3679 version = tr("Unreleased : Revision %1").arg(SVNREV);
|
Chris@285
|
3680 #endif // SVNREV
|
Chris@285
|
3681 #endif // SV_VERSION
|
Chris@0
|
3682
|
Chris@0
|
3683 QString aboutText;
|
Chris@0
|
3684
|
Chris@0
|
3685 aboutText += tr("<h3>About Sonic Visualiser</h3>");
|
Chris@285
|
3686 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@285
|
3687 aboutText += tr("<p><small>%1 : %2 configuration</small></p>")
|
Chris@0
|
3688 .arg(version)
|
Chris@0
|
3689 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@0
|
3690
|
Chris@285
|
3691 aboutText += "<small>";
|
Chris@285
|
3692
|
Chris@285
|
3693 aboutText += tr("With Qt v%1 © Nokia Corporation").arg(QT_VERSION_STR);
|
Chris@285
|
3694
|
Chris@0
|
3695 #ifdef HAVE_JACK
|
Chris@93
|
3696 #ifdef JACK_VERSION
|
Chris@285
|
3697 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION);
|
Chris@285
|
3698 #else // !JACK_VERSION
|
Chris@257
|
3699 aboutText += tr("<br>With JACK audio output library © Paul Davis and Jack O'Quin");
|
Chris@285
|
3700 #endif // JACK_VERSION
|
Chris@285
|
3701 #endif // HAVE_JACK
|
Chris@0
|
3702 #ifdef HAVE_PORTAUDIO
|
Chris@257
|
3703 aboutText += tr("<br>With PortAudio audio output library © Ross Bencina and Phil Burk");
|
Chris@285
|
3704 #endif // HAVE_PORTAUDIO
|
Chris@257
|
3705 #ifdef HAVE_LIBPULSE
|
Chris@285
|
3706 #ifdef LIBPULSE_VERSION
|
Chris@285
|
3707 aboutText += tr("<br>With PulseAudio audio output library v%1 © Lennart Poettering and Pierre Ossman").arg(LIBPULSE_VERSION);
|
Chris@285
|
3708 #else // !LIBPULSE_VERSION
|
Chris@257
|
3709 aboutText += tr("<br>With PulseAudio audio output library © Lennart Poettering and Pierre Ossman");
|
Chris@285
|
3710 #endif // LIBPULSE_VERSION
|
Chris@285
|
3711 #endif // HAVE_LIBPULSE
|
Chris@0
|
3712 #ifdef HAVE_OGGZ
|
Chris@93
|
3713 #ifdef OGGZ_VERSION
|
Chris@0
|
3714 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) © CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
|
Chris@285
|
3715 #else // !OGGZ_VERSION
|
Chris@93
|
3716 aboutText += tr("<br>With Ogg file decoder © CSIRO Australia");
|
Chris@285
|
3717 #endif // OGGZ_VERSION
|
Chris@285
|
3718 #endif // HAVE_OGGZ
|
Chris@0
|
3719 #ifdef HAVE_MAD
|
Chris@93
|
3720 #ifdef MAD_VERSION
|
Chris@285
|
3721 aboutText += tr("<br>With MAD mp3 decoder v%1 © Underbit Technologies Inc").arg(MAD_VERSION);
|
Chris@285
|
3722 #else // !MAD_VERSION
|
Chris@93
|
3723 aboutText += tr("<br>With MAD mp3 decoder © Underbit Technologies Inc");
|
Chris@285
|
3724 #endif // MAD_VERSION
|
Chris@285
|
3725 #endif // HAVE_MAD
|
Chris@0
|
3726 #ifdef HAVE_SAMPLERATE
|
Chris@93
|
3727 #ifdef SAMPLERATE_VERSION
|
Chris@285
|
3728 aboutText += tr("<br>With libsamplerate v%1 © Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
|
Chris@285
|
3729 #else // !SAMPLERATE_VERSION
|
Chris@93
|
3730 aboutText += tr("<br>With libsamplerate © Erik de Castro Lopo");
|
Chris@285
|
3731 #endif // SAMPLERATE_VERSION
|
Chris@285
|
3732 #endif // HAVE_SAMPLERATE
|
Chris@0
|
3733 #ifdef HAVE_SNDFILE
|
Chris@93
|
3734 #ifdef SNDFILE_VERSION
|
Chris@285
|
3735 aboutText += tr("<br>With libsndfile v%1 © Erik de Castro Lopo").arg(SNDFILE_VERSION);
|
Chris@285
|
3736 #else // !SNDFILE_VERSION
|
Chris@93
|
3737 aboutText += tr("<br>With libsndfile © Erik de Castro Lopo");
|
Chris@285
|
3738 #endif // SNDFILE_VERSION
|
Chris@285
|
3739 #endif // HAVE_SNDFILE
|
Chris@127
|
3740 #ifdef HAVE_FFTW3F
|
Chris@93
|
3741 #ifdef FFTW3_VERSION
|
Chris@285
|
3742 aboutText += tr("<br>With FFTW3 v%1 © Matteo Frigo and MIT").arg(FFTW3_VERSION);
|
Chris@285
|
3743 #else // !FFTW3_VERSION
|
Chris@93
|
3744 aboutText += tr("<br>With FFTW3 © Matteo Frigo and MIT");
|
Chris@285
|
3745 #endif // FFTW3_VERSION
|
Chris@285
|
3746 #endif // HAVE_FFTW3F
|
Chris@267
|
3747 #ifdef HAVE_RUBBERBAND
|
Chris@267
|
3748 #ifdef RUBBERBAND_VERSION
|
Chris@285
|
3749 aboutText += tr("<br>With Rubber Band v%1 © Chris Cannam").arg(RUBBERBAND_VERSION);
|
Chris@285
|
3750 #else // !RUBBERBAND_VERSION
|
Chris@267
|
3751 aboutText += tr("<br>With Rubber Band © Chris Cannam");
|
Chris@285
|
3752 #endif // RUBBERBAND_VERSION
|
Chris@285
|
3753 #endif // HAVE_RUBBERBAND
|
Chris@0
|
3754 #ifdef HAVE_VAMP
|
Chris@114
|
3755 aboutText += tr("<br>With Vamp plugin support (API v%1, host SDK v%2) © Chris Cannam").arg(VAMP_API_VERSION).arg(VAMP_SDK_VERSION);
|
Chris@285
|
3756 #endif // !HAVE_VAMP
|
Chris@0
|
3757 aboutText += tr("<br>With LADSPA plugin support (API v%1) © Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
|
Chris@0
|
3758 aboutText += tr("<br>With DSSI plugin support (API v%1) © Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
|
Chris@285
|
3759 #ifdef RAPTOR_VERSION
|
Chris@285
|
3760 aboutText += tr("<br>With Raptor RDF parser v%1 © Dave Beckett and the University of Bristol").arg(RAPTOR_VERSION);
|
Chris@285
|
3761 #else // !RAPTOR_VERSION
|
Chris@285
|
3762 aboutText += tr("<br>With Raptor RDF parser © Dave Beckett and the University of Bristol");
|
Chris@285
|
3763 #endif // RAPTOR_VERSION
|
Chris@285
|
3764 #ifdef RASQAL_VERSION
|
Chris@285
|
3765 aboutText += tr("<br>With Rasqal RDF query engine v%1 © Dave Beckett and the University of Bristol").arg(RASQAL_VERSION);
|
Chris@285
|
3766 #else // !RASQAL_VERSION
|
Chris@285
|
3767 aboutText += tr("<br>With Rasqal RDF query engine © Dave Beckett and the University of Bristol");
|
Chris@285
|
3768 #endif // RASQAL_VERSION
|
Chris@285
|
3769 #ifdef HAVE_REDLAND
|
Chris@285
|
3770 #ifdef REDLAND_VERSION
|
Chris@285
|
3771 aboutText += tr("<br>With Redland RDF datastore v%1 © Dave Beckett and the University of Bristol").arg(REDLAND_VERSION);
|
Chris@285
|
3772 #else // !REDLAND_VERSION
|
Chris@285
|
3773 aboutText += tr("<br>With Redland RDF datastore © Dave Beckett and the University of Bristol");
|
Chris@285
|
3774 #endif // REDLAND_VERSION
|
Chris@285
|
3775 #endif // HAVE_REDLAND
|
Chris@285
|
3776
|
Chris@300
|
3777 aboutText += tr("<br>With RtMidi © Gary P. Scavone");
|
Chris@300
|
3778
|
Chris@69
|
3779 #ifdef HAVE_LIBLO
|
Chris@93
|
3780 #ifdef LIBLO_VERSION
|
Chris@285
|
3781 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
3782 #else // !LIBLO_VERSION
|
Chris@93
|
3783 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris").arg(LIBLO_VERSION);
|
Chris@285
|
3784 #endif // LIBLO_VERSION
|
Chris@285
|
3785
|
Chris@285
|
3786 if (m_oscQueue && m_oscQueue->isOK()) {
|
Chris@285
|
3787 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
|
Chris@285
|
3788 }
|
Chris@285
|
3789
|
Chris@285
|
3790 aboutText += "</small></p>";
|
Chris@285
|
3791 #endif // HAVE_LIBLO
|
Chris@285
|
3792
|
Chris@285
|
3793 #ifndef BUILD_STATIC
|
Chris@285
|
3794 aboutText.replace(tr("With "), tr("Using "));
|
Chris@93
|
3795 #endif
|
Chris@0
|
3796
|
Chris@0
|
3797 aboutText +=
|
Chris@300
|
3798 "<p><small>Sonic Visualiser Copyright © 2005–2009 Chris Cannam and "
|
Chris@285
|
3799 "Queen Mary, University of London.</small></p>"
|
Chris@285
|
3800 "<p><small>This program is free software; you can redistribute it and/or "
|
Chris@231
|
3801 "modify it under the terms of the GNU General Public License as "
|
Chris@231
|
3802 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
3803 "License, or (at your option) any later version.<br>See the file "
|
Chris@285
|
3804 "COPYING included with this distribution for more information.</small></p>";
|
Chris@0
|
3805
|
Chris@0
|
3806 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
|
Chris@0
|
3807 }
|
Chris@0
|
3808
|
Chris@162
|
3809 void
|
Chris@162
|
3810 MainWindow::keyReference()
|
Chris@162
|
3811 {
|
Chris@162
|
3812 m_keyReference->show();
|
Chris@162
|
3813 }
|
Chris@162
|
3814
|
Chris@294
|
3815
|