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