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 Tony
|
Chris@0
|
5 An intonation analysis and annotation tool
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7 This file copyright 2006-2012 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@0
|
16 #include "../version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@95
|
19 #include "NetworkPermissionTester.h"
|
Chris@6
|
20 #include "Analyser.h"
|
Chris@6
|
21
|
Chris@0
|
22 #include "framework/Document.h"
|
Chris@95
|
23 #include "framework/VersionTester.h"
|
Chris@0
|
24
|
Chris@0
|
25 #include "view/Pane.h"
|
Chris@0
|
26 #include "view/PaneStack.h"
|
Chris@0
|
27 #include "data/model/WaveFileModel.h"
|
matthiasm@26
|
28 #include "data/model/NoteModel.h"
|
matthiasm@26
|
29 #include "data/model/FlexiNoteModel.h"
|
matthiasm@42
|
30 #include "layer/FlexiNoteLayer.h"
|
matthiasm@26
|
31 #include "data/model/NoteModel.h"
|
Chris@0
|
32 #include "view/ViewManager.h"
|
Chris@0
|
33 #include "base/Preferences.h"
|
Chris@0
|
34 #include "layer/WaveformLayer.h"
|
Chris@0
|
35 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
36 #include "layer/TimeValueLayer.h"
|
Chris@192
|
37 #include "layer/SpectrogramLayer.h"
|
Chris@0
|
38 #include "widgets/Fader.h"
|
Chris@0
|
39 #include "view/Overview.h"
|
Chris@0
|
40 #include "widgets/AudioDial.h"
|
Chris@0
|
41 #include "widgets/IconLoader.h"
|
Chris@0
|
42 #include "widgets/KeyReference.h"
|
Chris@0
|
43 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
44 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
45 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@0
|
46 #include "base/Profiler.h"
|
Chris@0
|
47 #include "base/UnitDatabase.h"
|
Chris@0
|
48 #include "layer/ColourDatabase.h"
|
Chris@139
|
49 #include "base/Selection.h"
|
Chris@0
|
50
|
Chris@174
|
51 #include "rdf/RDFImporter.h"
|
Chris@174
|
52 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@174
|
53 #include "data/fileio/CSVFormat.h"
|
matthiasm@26
|
54 #include "data/fileio/CSVFileWriter.h"
|
matthiasm@26
|
55 #include "data/fileio/MIDIFileWriter.h"
|
matthiasm@26
|
56 #include "rdf/RDFExporter.h"
|
matthiasm@26
|
57
|
Chris@227
|
58 #include "widgets/RangeInputDialog.h"
|
Chris@244
|
59 #include "widgets/ActivityLog.h"
|
Chris@227
|
60
|
Chris@0
|
61 // For version information
|
Chris@0
|
62 #include "vamp/vamp.h"
|
Chris@0
|
63 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
64 #include "plugin/api/ladspa.h"
|
Chris@0
|
65 #include "plugin/api/dssi.h"
|
Chris@0
|
66
|
Chris@0
|
67 #include <QApplication>
|
Chris@0
|
68 #include <QMessageBox>
|
Chris@0
|
69 #include <QGridLayout>
|
Chris@0
|
70 #include <QLabel>
|
Chris@0
|
71 #include <QMenuBar>
|
Chris@0
|
72 #include <QToolBar>
|
Chris@0
|
73 #include <QToolButton>
|
Chris@0
|
74 #include <QInputDialog>
|
Chris@0
|
75 #include <QStatusBar>
|
Chris@0
|
76 #include <QFileInfo>
|
Chris@0
|
77 #include <QDir>
|
Chris@0
|
78 #include <QProcess>
|
Chris@2
|
79 #include <QPushButton>
|
Chris@0
|
80 #include <QSettings>
|
Chris@0
|
81 #include <QScrollArea>
|
Chris@128
|
82 #include <QPainter>
|
Chris@0
|
83
|
Chris@0
|
84 #include <iostream>
|
Chris@0
|
85 #include <cstdio>
|
Chris@0
|
86 #include <errno.h>
|
Chris@0
|
87
|
Chris@0
|
88 using std::vector;
|
Chris@0
|
89
|
Chris@0
|
90
|
Chris@0
|
91 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
|
Chris@0
|
92 MainWindowBase(withAudioOutput, withOSCSupport, false),
|
Chris@0
|
93 m_overview(0),
|
Chris@0
|
94 m_mainMenusCreated(false),
|
Chris@0
|
95 m_playbackMenu(0),
|
gyorgyf@45
|
96 m_recentFilesMenu(0),
|
Chris@0
|
97 m_rightButtonMenu(0),
|
Chris@0
|
98 m_rightButtonPlaybackMenu(0),
|
Chris@0
|
99 m_deleteSelectedAction(0),
|
Chris@0
|
100 m_ffwdAction(0),
|
Chris@0
|
101 m_rwdAction(0),
|
Chris@168
|
102 m_intelligentActionOn(true), //GF: !!! temporary
|
Chris@244
|
103 m_activityLog(new ActivityLog()),
|
Chris@0
|
104 m_keyReference(new KeyReference())
|
Chris@0
|
105 {
|
Chris@0
|
106 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
107
|
Chris@206
|
108 #ifdef Q_OS_MAC
|
Chris@206
|
109 #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
|
Chris@206
|
110 setUnifiedTitleAndToolBarOnMac(true);
|
Chris@206
|
111 #endif
|
Chris@206
|
112 #endif
|
Chris@206
|
113
|
Chris@0
|
114 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@0
|
115 udb->registerUnit("Hz");
|
Chris@0
|
116 udb->registerUnit("dB");
|
Chris@0
|
117 udb->registerUnit("s");
|
Chris@0
|
118
|
Chris@0
|
119 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@0
|
120 cdb->addColour(Qt::black, tr("Black"));
|
Chris@0
|
121 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@0
|
122 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@0
|
123 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@0
|
124 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@0
|
125 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@120
|
126 cdb->addColour(QColor(180, 180, 180), tr("Grey"));
|
Chris@0
|
127 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@0
|
128 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@0
|
129 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@0
|
130 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@0
|
131 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@0
|
132 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
133
|
Chris@0
|
134 Preferences::getInstance()->setResampleOnLoad(true);
|
Chris@0
|
135 Preferences::getInstance()->setSpectrogramSmoothing
|
Chris@0
|
136 (Preferences::SpectrogramInterpolated);
|
Chris@0
|
137
|
Chris@0
|
138 QSettings settings;
|
Chris@0
|
139
|
Chris@0
|
140 settings.beginGroup("MainWindow");
|
Chris@0
|
141 settings.setValue("showstatusbar", false);
|
Chris@0
|
142 settings.endGroup();
|
Chris@0
|
143
|
Chris@96
|
144 settings.beginGroup("Transformer");
|
Chris@96
|
145 settings.setValue("use-flexi-note-model", true);
|
Chris@96
|
146 settings.endGroup();
|
Chris@96
|
147
|
Chris@73
|
148 settings.beginGroup("LayerDefaults");
|
Chris@73
|
149 settings.setValue("waveform",
|
Chris@73
|
150 QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
Chris@73
|
151 .arg(int(WaveformLayer::LinearScale))
|
Chris@73
|
152 .arg(int(WaveformLayer::MixChannels)));
|
Chris@73
|
153 settings.endGroup();
|
Chris@73
|
154
|
Chris@6
|
155 m_viewManager->setAlignMode(false);
|
Chris@6
|
156 m_viewManager->setPlaySoloMode(false);
|
Chris@0
|
157 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
158 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@6
|
159 m_viewManager->setIlluminateLocalFeatures(true);
|
Chris@0
|
160 m_viewManager->setShowWorkTitle(true);
|
Chris@6
|
161 m_viewManager->setShowCentreLine(false);
|
Chris@213
|
162 m_viewManager->setOverlayMode(ViewManager::GlobalOverlays);
|
Chris@0
|
163
|
Chris@192
|
164 connect(m_viewManager, SIGNAL(selectionChangedByUser()),
|
Chris@192
|
165 this, SLOT(selectionChangedByUser()));
|
Chris@164
|
166
|
Chris@0
|
167 QFrame *frame = new QFrame;
|
Chris@0
|
168 setCentralWidget(frame);
|
Chris@0
|
169
|
Chris@0
|
170 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
171
|
Chris@0
|
172 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@0
|
173 scroll->setWidgetResizable(true);
|
Chris@0
|
174 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@0
|
175 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@0
|
176
|
Chris@6
|
177 // We have a pane stack: it comes with the territory. However, we
|
Chris@120
|
178 // have a fixed and known number of panes in it -- it isn't
|
Chris@120
|
179 // variable
|
Chris@0
|
180 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@137
|
181 m_paneStack->setShowPaneAccessories(false);
|
Chris@139
|
182 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(size_t)),
|
Chris@139
|
183 this, SLOT(doubleClickSelectInvoked(size_t)));
|
Chris@0
|
184 scroll->setWidget(m_paneStack);
|
Chris@6
|
185
|
Chris@0
|
186 m_overview = new Overview(frame);
|
Chris@0
|
187 m_overview->setViewManager(m_viewManager);
|
Chris@0
|
188 m_overview->setFixedHeight(40);
|
Chris@0
|
189 #ifndef _WIN32
|
Chris@0
|
190 // For some reason, the contents of the overview never appear if we
|
Chris@0
|
191 // make this setting on Windows. I have no inclination at the moment
|
Chris@0
|
192 // to track down the reason why.
|
Chris@0
|
193 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@0
|
194 #endif
|
Chris@0
|
195 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
196 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
197
|
Chris@0
|
198 m_panLayer = new WaveformLayer;
|
Chris@0
|
199 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
200 m_panLayer->setAggressiveCacheing(true);
|
Chris@0
|
201 m_overview->addLayer(m_panLayer);
|
Chris@0
|
202
|
Chris@0
|
203 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@0
|
204 m_panLayer->setBaseColour
|
Chris@0
|
205 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@0
|
206 } else {
|
Chris@0
|
207 m_panLayer->setBaseColour
|
matthiasm@13
|
208 (ColourDatabase::getInstance()->getColourIndex(tr("Blue")));
|
Chris@0
|
209 }
|
Chris@0
|
210
|
Chris@0
|
211 m_fader = new Fader(frame, false);
|
Chris@0
|
212 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
213 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
214
|
Chris@0
|
215 m_playSpeed = new AudioDial(frame);
|
Chris@0
|
216 m_playSpeed->setMinimum(0);
|
Chris@0
|
217 m_playSpeed->setMaximum(200);
|
Chris@0
|
218 m_playSpeed->setValue(100);
|
Chris@0
|
219 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
220 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
221 m_playSpeed->setNotchesVisible(true);
|
Chris@0
|
222 m_playSpeed->setPageStep(10);
|
Chris@0
|
223 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@0
|
224 m_playSpeed->setDefaultValue(100);
|
Chris@0
|
225 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@0
|
226 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
227 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
gyorgyf@27
|
228 this, SLOT(playSpeedChanged(int)));
|
Chris@0
|
229 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
230 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
231
|
justin@159
|
232 // Gain controls
|
justin@159
|
233 m_gainAudio = new AudioDial(frame);
|
justin@159
|
234 m_gainAudio->setMinimum(-50);
|
justin@159
|
235 m_gainAudio->setMaximum(50);
|
justin@159
|
236 m_gainAudio->setValue(0);
|
justin@159
|
237 m_gainAudio->setDefaultValue(0);
|
justin@220
|
238 //m_gainAudio->setFixedWidth(40);
|
justin@159
|
239 m_gainAudio->setFixedWidth(24);
|
justin@159
|
240 m_gainAudio->setFixedHeight(24);
|
justin@159
|
241 m_gainAudio->setNotchesVisible(true);
|
justin@159
|
242 m_gainAudio->setPageStep(10);
|
justin@159
|
243 m_gainAudio->setObjectName(tr("Audio Track Gain"));
|
justin@159
|
244 m_gainAudio->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
245 m_gainAudio->setShowToolTip(true);
|
justin@159
|
246 connect(m_gainAudio, SIGNAL(valueChanged(int)),
|
justin@159
|
247 this, SLOT(audioGainChanged(int)));
|
justin@159
|
248 connect(m_gainAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
249 connect(m_gainAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
250
|
justin@157
|
251 m_gainPitch = new AudioDial(frame);
|
Chris@158
|
252 m_gainPitch->setMinimum(-50);
|
Chris@158
|
253 m_gainPitch->setMaximum(50);
|
Chris@158
|
254 m_gainPitch->setValue(0);
|
Chris@158
|
255 m_gainPitch->setDefaultValue(0);
|
justin@157
|
256 m_gainPitch->setFixedWidth(24);
|
justin@157
|
257 m_gainPitch->setFixedHeight(24);
|
justin@157
|
258 m_gainPitch->setNotchesVisible(true);
|
justin@157
|
259 m_gainPitch->setPageStep(10);
|
Chris@158
|
260 m_gainPitch->setObjectName(tr("Pitch Track Gain"));
|
Chris@158
|
261 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@157
|
262 m_gainPitch->setShowToolTip(true);
|
justin@157
|
263 connect(m_gainPitch, SIGNAL(valueChanged(int)),
|
Chris@158
|
264 this, SLOT(pitchGainChanged(int)));
|
justin@157
|
265 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@157
|
266 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@157
|
267
|
justin@159
|
268 m_gainNotes = new AudioDial(frame);
|
justin@159
|
269 m_gainNotes->setMinimum(-50);
|
justin@159
|
270 m_gainNotes->setMaximum(50);
|
justin@159
|
271 m_gainNotes->setValue(0);
|
justin@159
|
272 m_gainNotes->setDefaultValue(0);
|
justin@159
|
273 m_gainNotes->setFixedWidth(24);
|
justin@159
|
274 m_gainNotes->setFixedHeight(24);
|
justin@159
|
275 m_gainNotes->setNotchesVisible(true);
|
justin@159
|
276 m_gainNotes->setPageStep(10);
|
justin@159
|
277 m_gainNotes->setObjectName(tr("Pitch Track Gain"));
|
justin@159
|
278 m_gainNotes->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
|
justin@159
|
279 m_gainNotes->setShowToolTip(true);
|
justin@159
|
280 connect(m_gainNotes, SIGNAL(valueChanged(int)),
|
justin@159
|
281 this, SLOT(notesGainChanged(int)));
|
justin@159
|
282 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@159
|
283 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@159
|
284 // End of Gain controls
|
justin@159
|
285
|
justin@160
|
286 // Pan controls
|
justin@160
|
287 m_panAudio = new AudioDial(frame);
|
justin@160
|
288 m_panAudio->setMinimum(-100);
|
justin@160
|
289 m_panAudio->setMaximum(100);
|
justin@160
|
290 m_panAudio->setValue(-100);
|
justin@160
|
291 m_panAudio->setDefaultValue(-100);
|
justin@160
|
292 m_panAudio->setFixedWidth(24);
|
justin@220
|
293 //m_panAudio->setFixedWidth(40);
|
justin@160
|
294 m_panAudio->setFixedHeight(24);
|
justin@160
|
295 m_panAudio->setNotchesVisible(true);
|
justin@160
|
296 m_panAudio->setPageStep(10);
|
justin@160
|
297 m_panAudio->setObjectName(tr("Audio Track Pan"));
|
justin@160
|
298 m_panAudio->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
299 m_panAudio->setShowToolTip(true);
|
justin@160
|
300 connect(m_panAudio, SIGNAL(valueChanged(int)),
|
justin@160
|
301 this, SLOT(audioPanChanged(int)));
|
justin@160
|
302 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
303 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
304
|
justin@160
|
305 m_panPitch = new AudioDial(frame);
|
justin@160
|
306 m_panPitch->setMinimum(-100);
|
justin@160
|
307 m_panPitch->setMaximum(100);
|
justin@160
|
308 m_panPitch->setValue(100);
|
justin@160
|
309 m_panPitch->setDefaultValue(100);
|
justin@160
|
310 m_panPitch->setFixedWidth(24);
|
justin@160
|
311 m_panPitch->setFixedHeight(24);
|
justin@160
|
312 m_panPitch->setNotchesVisible(true);
|
justin@160
|
313 m_panPitch->setPageStep(10);
|
justin@160
|
314 m_panPitch->setObjectName(tr("Pitch Track Pan"));
|
justin@160
|
315 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
316 m_panPitch->setShowToolTip(true);
|
justin@160
|
317 connect(m_panPitch, SIGNAL(valueChanged(int)),
|
justin@160
|
318 this, SLOT(pitchPanChanged(int)));
|
justin@160
|
319 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
320 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
321
|
justin@160
|
322 m_panNotes = new AudioDial(frame);
|
justin@160
|
323 m_panNotes->setMinimum(-100);
|
justin@160
|
324 m_panNotes->setMaximum(100);
|
justin@160
|
325 m_panNotes->setValue(100);
|
justin@160
|
326 m_panNotes->setDefaultValue(100);
|
justin@160
|
327 m_panNotes->setFixedWidth(24);
|
justin@160
|
328 m_panNotes->setFixedHeight(24);
|
justin@160
|
329 m_panNotes->setNotchesVisible(true);
|
justin@160
|
330 m_panNotes->setPageStep(10);
|
justin@160
|
331 m_panNotes->setObjectName(tr("Notes Track Pan"));
|
justin@160
|
332 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr("")));
|
justin@160
|
333 m_panNotes->setShowToolTip(true);
|
justin@160
|
334 connect(m_panNotes, SIGNAL(valueChanged(int)),
|
justin@160
|
335 this, SLOT(notesPanChanged(int)));
|
justin@160
|
336 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
justin@160
|
337 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
justin@160
|
338 // End of Pan controls
|
justin@160
|
339
|
Chris@0
|
340 layout->setSpacing(4);
|
Chris@6
|
341 layout->addWidget(m_overview, 0, 1);
|
Chris@6
|
342 layout->addWidget(scroll, 1, 1);
|
Chris@0
|
343
|
Chris@0
|
344 layout->setColumnStretch(1, 10);
|
Chris@0
|
345
|
Chris@0
|
346 frame->setLayout(layout);
|
Chris@0
|
347
|
gyorgyf@21
|
348 m_analyser = new Analyser();
|
Chris@128
|
349 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@128
|
350 this, SLOT(updateLayerStatuses()));
|
Chris@187
|
351 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@187
|
352 this, SLOT(updateMenuStates()));
|
gyorgyf@21
|
353
|
Chris@0
|
354 setupMenus();
|
Chris@0
|
355 setupToolbars();
|
Chris@0
|
356 setupHelpMenu();
|
Chris@0
|
357
|
Chris@0
|
358 statusBar();
|
Chris@0
|
359
|
Chris@244
|
360 connect(m_viewManager, SIGNAL(activity(QString)),
|
Chris@244
|
361 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
362 connect(m_playSource, SIGNAL(activity(QString)),
|
Chris@244
|
363 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
364 connect(CommandHistory::getInstance(), SIGNAL(activity(QString)),
|
Chris@244
|
365 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
366 connect(this, SIGNAL(activity(QString)),
|
Chris@244
|
367 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
368 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
|
Chris@244
|
369 m_activityLog->hide();
|
Chris@244
|
370
|
Chris@95
|
371 newSession();
|
Chris@6
|
372
|
Chris@95
|
373 settings.beginGroup("MainWindow");
|
Chris@95
|
374 settings.setValue("zoom-default", 512);
|
Chris@95
|
375 settings.endGroup();
|
Chris@95
|
376 zoomDefault();
|
Chris@95
|
377
|
Chris@95
|
378 NetworkPermissionTester tester;
|
Chris@95
|
379 bool networkPermission = tester.havePermission();
|
Chris@95
|
380 if (networkPermission) {
|
Chris@95
|
381 m_versionTester = new VersionTester
|
Chris@95
|
382 ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
|
Chris@95
|
383 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@95
|
384 this, SLOT(newerVersionAvailable(QString)));
|
Chris@95
|
385 } else {
|
Chris@95
|
386 m_versionTester = 0;
|
Chris@95
|
387 }
|
Chris@0
|
388 }
|
Chris@0
|
389
|
Chris@0
|
390 MainWindow::~MainWindow()
|
Chris@0
|
391 {
|
Chris@6
|
392 delete m_analyser;
|
Chris@0
|
393 delete m_keyReference;
|
Chris@0
|
394 Profiles::getInstance()->dump();
|
Chris@0
|
395 }
|
Chris@0
|
396
|
Chris@0
|
397 void
|
Chris@0
|
398 MainWindow::setupMenus()
|
Chris@0
|
399 {
|
Chris@0
|
400 if (!m_mainMenusCreated) {
|
Chris@0
|
401 m_rightButtonMenu = new QMenu();
|
Chris@0
|
402 }
|
Chris@0
|
403
|
Chris@0
|
404 if (!m_mainMenusCreated) {
|
Chris@0
|
405 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
406 m_rightButtonMenu->addSeparator();
|
Chris@0
|
407 }
|
Chris@0
|
408
|
Chris@0
|
409 setupFileMenu();
|
Chris@0
|
410 setupEditMenu();
|
Chris@0
|
411 setupViewMenu();
|
Chris@0
|
412
|
Chris@0
|
413 m_mainMenusCreated = true;
|
Chris@0
|
414 }
|
Chris@0
|
415
|
Chris@0
|
416 void
|
Chris@0
|
417 MainWindow::setupFileMenu()
|
Chris@0
|
418 {
|
Chris@0
|
419 if (m_mainMenusCreated) return;
|
Chris@0
|
420
|
Chris@0
|
421 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@0
|
422 menu->setTearOffEnabled(true);
|
Chris@0
|
423 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@0
|
424
|
Chris@0
|
425 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@0
|
426
|
Chris@0
|
427 IconLoader il;
|
Chris@1
|
428 QIcon icon;
|
Chris@1
|
429 QAction *action;
|
Chris@0
|
430
|
Chris@0
|
431 icon = il.load("fileopen");
|
Chris@0
|
432 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@1
|
433 action = new QAction(icon, tr("&Open..."), this);
|
Chris@0
|
434 action->setShortcut(tr("Ctrl+O"));
|
Chris@257
|
435 action->setStatusTip(tr("Open a session or audio file"));
|
Chris@0
|
436 connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
|
Chris@0
|
437 m_keyReference->registerShortcut(action);
|
Chris@0
|
438 menu->addAction(action);
|
Chris@0
|
439 toolbar->addAction(action);
|
Chris@0
|
440
|
Chris@1
|
441 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@0
|
442 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@1
|
443 action->setStatusTip(tr("Open a file from a remote URL"));
|
Chris@0
|
444 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@0
|
445 m_keyReference->registerShortcut(action);
|
Chris@0
|
446 menu->addAction(action);
|
Chris@0
|
447
|
Chris@1
|
448 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@0
|
449 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@0
|
450 setupRecentFilesMenu();
|
Chris@0
|
451 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@0
|
452 this, SLOT(setupRecentFilesMenu()));
|
Chris@0
|
453
|
Chris@0
|
454 menu->addSeparator();
|
Chris@257
|
455
|
Chris@257
|
456 icon = il.load("filesave");
|
Chris@257
|
457 icon.addPixmap(il.loadPixmap("filesave-22"));
|
Chris@257
|
458 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@257
|
459 action->setShortcut(tr("Ctrl+S"));
|
Chris@257
|
460 action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName()));
|
Chris@257
|
461 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@257
|
462 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@257
|
463 m_keyReference->registerShortcut(action);
|
Chris@257
|
464 menu->addAction(action);
|
Chris@257
|
465 toolbar->addAction(action);
|
Chris@257
|
466
|
Chris@257
|
467 icon = il.load("filesaveas");
|
Chris@257
|
468 icon.addPixmap(il.loadPixmap("filesaveas-22"));
|
Chris@257
|
469 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@257
|
470 action->setShortcut(tr("Ctrl+Shift+S"));
|
Chris@257
|
471 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName()));
|
Chris@257
|
472 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@257
|
473 menu->addAction(action);
|
Chris@257
|
474 toolbar->addAction(action);
|
Chris@257
|
475
|
Chris@257
|
476 menu->addSeparator();
|
Chris@257
|
477
|
Chris@253
|
478 action = new QAction(tr("I&mport Pitch Track Data..."), this);
|
Chris@253
|
479 action->setStatusTip(tr("Import pitch-track data from a CSV, RDF, or layer XML file"));
|
Chris@174
|
480 connect(action, SIGNAL(triggered()), this, SLOT(importPitchLayer()));
|
Chris@174
|
481 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@174
|
482 menu->addAction(action);
|
Chris@174
|
483
|
Chris@253
|
484 action = new QAction(tr("E&xport Pitch Track Data..."), this);
|
Chris@253
|
485 action->setStatusTip(tr("Export pitch-track data to a CSV, RDF, or layer XML file"));
|
Chris@85
|
486 connect(action, SIGNAL(triggered()), this, SLOT(exportPitchLayer()));
|
Chris@224
|
487 connect(this, SIGNAL(canExportPitchTrack(bool)), action, SLOT(setEnabled(bool)));
|
Chris@85
|
488 menu->addAction(action);
|
Chris@85
|
489
|
Chris@253
|
490 action = new QAction(tr("&Export Note Data..."), this);
|
Chris@253
|
491 action->setStatusTip(tr("Export note data to a CSV, RDF, layer XML, or MIDI file"));
|
Chris@85
|
492 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
|
Chris@224
|
493 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@26
|
494 menu->addAction(action);
|
matthiasm@26
|
495
|
matthiasm@26
|
496 menu->addSeparator();
|
Chris@0
|
497 action = new QAction(il.load("exit"), tr("&Quit"), this);
|
Chris@0
|
498 action->setShortcut(tr("Ctrl+Q"));
|
Chris@0
|
499 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@0
|
500 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@0
|
501 m_keyReference->registerShortcut(action);
|
Chris@0
|
502 menu->addAction(action);
|
Chris@0
|
503 }
|
Chris@0
|
504
|
Chris@0
|
505 void
|
Chris@0
|
506 MainWindow::setupEditMenu()
|
Chris@0
|
507 {
|
Chris@0
|
508 if (m_mainMenusCreated) return;
|
Chris@0
|
509
|
Chris@0
|
510 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@0
|
511 menu->setTearOffEnabled(true);
|
Chris@0
|
512 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@126
|
513 menu->addSeparator();
|
Chris@126
|
514
|
Chris@254
|
515 m_keyReference->setCategory
|
Chris@254
|
516 (tr("Selection Strip Mouse Actions"));
|
Chris@254
|
517 m_keyReference->registerShortcut
|
Chris@254
|
518 (tr("Jump"), tr("Left"),
|
Chris@254
|
519 tr("Click left button to move the playback position to a time"));
|
Chris@254
|
520 m_keyReference->registerShortcut
|
Chris@254
|
521 (tr("Select"), tr("Left"),
|
Chris@254
|
522 tr("Click left button and drag to select a region of time"));
|
Chris@254
|
523 m_keyReference->registerShortcut
|
Chris@254
|
524 (tr("Select Note Duration"), tr("Double-Click Left"),
|
Chris@254
|
525 tr("Double-click left button to select the region of time corresponding to a note"));
|
Chris@254
|
526
|
Chris@126
|
527 QToolBar *toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@126
|
528
|
Chris@126
|
529 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@126
|
530
|
Chris@250
|
531 QActionGroup *group = new QActionGroup(this);
|
Chris@250
|
532
|
Chris@250
|
533 IconLoader il;
|
Chris@250
|
534
|
Chris@126
|
535 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
536 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@126
|
537 tr("Navigate"));
|
Chris@126
|
538 action->setCheckable(true);
|
Chris@126
|
539 action->setChecked(true);
|
Chris@126
|
540 action->setShortcut(tr("1"));
|
Chris@126
|
541 action->setStatusTip(tr("Navigate"));
|
Chris@126
|
542 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@126
|
543 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@126
|
544 group->addAction(action);
|
Chris@126
|
545 menu->addAction(action);
|
Chris@126
|
546 m_keyReference->registerShortcut(action);
|
Chris@126
|
547
|
Chris@250
|
548 m_keyReference->setCategory
|
Chris@250
|
549 (tr("Navigate Tool Mouse Actions"));
|
Chris@250
|
550 m_keyReference->registerShortcut
|
Chris@250
|
551 (tr("Navigate"), tr("Left"),
|
Chris@250
|
552 tr("Click left button and drag to move around"));
|
Chris@250
|
553 m_keyReference->registerShortcut
|
Chris@250
|
554 (tr("Re-Analyse Area"), tr("Shift+Left"),
|
Chris@250
|
555 tr("Shift-click left button and drag to define a specific pitch and time range to re-analyse"));
|
Chris@250
|
556 m_keyReference->registerShortcut
|
Chris@250
|
557 (tr("Edit"), tr("Double-Click Left"),
|
Chris@250
|
558 tr("Double-click left button on an item to edit it"));
|
Chris@250
|
559
|
Chris@250
|
560 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
561 action = toolbar->addAction(il.load("move"),
|
Chris@126
|
562 tr("Edit"));
|
Chris@126
|
563 action->setCheckable(true);
|
Chris@126
|
564 action->setShortcut(tr("2"));
|
Chris@126
|
565 action->setStatusTip(tr("Edit with Note Intelligence"));
|
Chris@126
|
566 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@126
|
567 group->addAction(action);
|
Chris@126
|
568 menu->addAction(action);
|
Chris@126
|
569 m_keyReference->registerShortcut(action);
|
Chris@126
|
570
|
Chris@250
|
571 m_keyReference->setCategory
|
Chris@250
|
572 (tr("Note Edit Tool Mouse Actions"));
|
Chris@250
|
573 m_keyReference->registerShortcut
|
Chris@250
|
574 (tr("Adjust Pitch"), tr("Left"),
|
Chris@250
|
575 tr("Click left button on the main part of a note and drag to move it up or down"));
|
Chris@250
|
576 m_keyReference->registerShortcut
|
Chris@250
|
577 (tr("Split"), tr("Left"),
|
Chris@250
|
578 tr("Click left button on the bottom edge of a note to split it at the click point"));
|
Chris@250
|
579 m_keyReference->registerShortcut
|
Chris@250
|
580 (tr("Resize"), tr("Left"),
|
Chris@250
|
581 tr("Click left button on the left or right edge of a note and drag to change the time or duration of the note"));
|
Chris@250
|
582 m_keyReference->registerShortcut
|
Chris@250
|
583 (tr("Erase"), tr("Shift+Left"),
|
Chris@250
|
584 tr("Shift-click left button on a note to remove it"));
|
Chris@250
|
585
|
Chris@250
|
586
|
Chris@126
|
587 /* Remove for now...
|
Chris@126
|
588
|
Chris@250
|
589 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
590 action = toolbar->addAction(il.load("notes"),
|
Chris@126
|
591 tr("Free Edit"));
|
Chris@126
|
592 action->setCheckable(true);
|
Chris@126
|
593 action->setShortcut(tr("3"));
|
Chris@126
|
594 action->setStatusTip(tr("Free Edit"));
|
Chris@126
|
595 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
|
Chris@126
|
596 group->addAction(action);
|
Chris@126
|
597 m_keyReference->registerShortcut(action);
|
Chris@126
|
598 */
|
Chris@142
|
599
|
Chris@142
|
600 menu->addSeparator();
|
Chris@142
|
601
|
Chris@143
|
602 m_keyReference->setCategory(tr("Selection"));
|
Chris@143
|
603
|
Chris@143
|
604 action = new QAction(tr("Select &All"), this);
|
Chris@143
|
605 action->setShortcut(tr("Ctrl+A"));
|
Chris@143
|
606 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@143
|
607 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@143
|
608 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
609 m_keyReference->registerShortcut(action);
|
Chris@143
|
610 menu->addAction(action);
|
Chris@143
|
611 m_rightButtonMenu->addAction(action);
|
Chris@143
|
612
|
Chris@143
|
613 action = new QAction(tr("C&lear Selection"), this);
|
Chris@211
|
614 action->setShortcuts(QList<QKeySequence>()
|
Chris@211
|
615 << QKeySequence(tr("Esc"))
|
Chris@211
|
616 << QKeySequence(tr("Ctrl+Esc")));
|
Chris@211
|
617 action->setStatusTip(tr("Clear the selection and abandon any pending pitch choices in it"));
|
Chris@194
|
618 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection()));
|
Chris@143
|
619 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
620 m_keyReference->registerShortcut(action);
|
Chris@211
|
621 m_keyReference->registerAlternativeShortcut(action, QKeySequence(tr("Ctrl+Esc")));
|
Chris@143
|
622 menu->addAction(action);
|
Chris@143
|
623 m_rightButtonMenu->addAction(action);
|
Chris@143
|
624
|
Chris@143
|
625 menu->addSeparator();
|
Chris@189
|
626 m_rightButtonMenu->addSeparator();
|
Chris@143
|
627
|
Chris@189
|
628 m_keyReference->setCategory(tr("Pitch Track"));
|
Chris@211
|
629
|
Chris@211
|
630 action = new QAction(tr("Choose Higher Pitch"), this);
|
Chris@211
|
631 action->setShortcut(tr("Ctrl+Up"));
|
Chris@211
|
632 action->setStatusTip(tr("Move pitches up an octave, or to the next higher pitch candidate"));
|
Chris@211
|
633 m_keyReference->registerShortcut(action);
|
Chris@211
|
634 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
|
Chris@211
|
635 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@211
|
636 menu->addAction(action);
|
Chris@211
|
637 m_rightButtonMenu->addAction(action);
|
Chris@211
|
638
|
Chris@211
|
639 action = new QAction(tr("Choose Lower Pitch"), this);
|
Chris@211
|
640 action->setShortcut(tr("Ctrl+Down"));
|
Chris@211
|
641 action->setStatusTip(tr("Move pitches down an octave, or to the next lower pitch candidate"));
|
Chris@211
|
642 m_keyReference->registerShortcut(action);
|
Chris@211
|
643 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown()));
|
Chris@211
|
644 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@211
|
645 menu->addAction(action);
|
Chris@211
|
646 m_rightButtonMenu->addAction(action);
|
Chris@189
|
647
|
Chris@187
|
648 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this);
|
Chris@187
|
649 m_showCandidatesAction->setShortcut(tr("Ctrl+Return"));
|
Chris@189
|
650 m_showCandidatesAction->setStatusTip(tr("Toggle the display of alternative pitch candidates for the selected region"));
|
Chris@189
|
651 m_keyReference->registerShortcut(m_showCandidatesAction);
|
Chris@187
|
652 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates()));
|
Chris@187
|
653 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
|
Chris@187
|
654 menu->addAction(m_showCandidatesAction);
|
Chris@189
|
655 m_rightButtonMenu->addAction(m_showCandidatesAction);
|
Chris@187
|
656
|
Chris@187
|
657 action = new QAction(tr("Remove Pitches"), this);
|
Chris@187
|
658 action->setShortcut(tr("Ctrl+Backspace"));
|
Chris@211
|
659 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced"));
|
Chris@189
|
660 m_keyReference->registerShortcut(action);
|
Chris@187
|
661 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
|
Chris@167
|
662 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@167
|
663 menu->addAction(action);
|
Chris@189
|
664 m_rightButtonMenu->addAction(action);
|
Chris@237
|
665
|
Chris@237
|
666 menu->addSeparator();
|
Chris@237
|
667 m_rightButtonMenu->addSeparator();
|
Chris@237
|
668
|
Chris@240
|
669 action = new QAction(tr("Split Note"), this);
|
Chris@237
|
670 action->setShortcut(tr("Ctrl+/"));
|
Chris@240
|
671 action->setStatusTip(tr("Split the note at the current playback position into two"));
|
Chris@237
|
672 m_keyReference->registerShortcut(action);
|
Chris@240
|
673 connect(action, SIGNAL(triggered()), this, SLOT(splitNote()));
|
Chris@240
|
674 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@237
|
675 menu->addAction(action);
|
Chris@237
|
676 m_rightButtonMenu->addAction(action);
|
Chris@238
|
677
|
Chris@238
|
678 action = new QAction(tr("Merge Notes"), this);
|
Chris@255
|
679 action->setShortcut(tr("Ctrl+\\"));
|
Chris@238
|
680 action->setStatusTip(tr("Merge all notes within the selected region into a single note"));
|
Chris@238
|
681 m_keyReference->registerShortcut(action);
|
Chris@238
|
682 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes()));
|
Chris@238
|
683 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@238
|
684 menu->addAction(action);
|
Chris@238
|
685 m_rightButtonMenu->addAction(action);
|
Chris@238
|
686
|
Chris@240
|
687 action = new QAction(tr("Form Note from Selection"), this);
|
Chris@255
|
688 action->setShortcut(tr("Ctrl+="));
|
Chris@240
|
689 action->setStatusTip(tr("Form a note spanning the selected region, splitting any existing notes at its boundaries"));
|
Chris@240
|
690 m_keyReference->registerShortcut(action);
|
Chris@240
|
691 connect(action, SIGNAL(triggered()), this, SLOT(formNoteFromSelection()));
|
Chris@240
|
692 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@240
|
693 menu->addAction(action);
|
Chris@240
|
694 m_rightButtonMenu->addAction(action);
|
Chris@247
|
695
|
Chris@238
|
696 action = new QAction(tr("Snap Notes to Pitch Track"), this);
|
Chris@238
|
697 action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches"));
|
Chris@238
|
698 m_keyReference->registerShortcut(action);
|
Chris@238
|
699 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches()));
|
Chris@238
|
700 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@238
|
701 menu->addAction(action);
|
Chris@238
|
702 m_rightButtonMenu->addAction(action);
|
Chris@0
|
703 }
|
Chris@0
|
704
|
Chris@0
|
705 void
|
Chris@0
|
706 MainWindow::setupViewMenu()
|
Chris@0
|
707 {
|
Chris@0
|
708 if (m_mainMenusCreated) return;
|
Chris@0
|
709
|
Chris@0
|
710 IconLoader il;
|
Chris@0
|
711
|
Chris@0
|
712 QAction *action = 0;
|
Chris@0
|
713
|
Chris@0
|
714 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@0
|
715
|
Chris@0
|
716 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@0
|
717 menu->setTearOffEnabled(true);
|
Chris@0
|
718 action = new QAction(tr("Scroll &Left"), this);
|
Chris@0
|
719 action->setShortcut(tr("Left"));
|
Chris@0
|
720 action->setStatusTip(tr("Scroll the current pane to the left"));
|
Chris@0
|
721 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@0
|
722 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
723 m_keyReference->registerShortcut(action);
|
Chris@0
|
724 menu->addAction(action);
|
gyorgyf@27
|
725
|
Chris@0
|
726 action = new QAction(tr("Scroll &Right"), this);
|
Chris@0
|
727 action->setShortcut(tr("Right"));
|
Chris@0
|
728 action->setStatusTip(tr("Scroll the current pane to the right"));
|
Chris@0
|
729 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@0
|
730 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
731 m_keyReference->registerShortcut(action);
|
Chris@0
|
732 menu->addAction(action);
|
gyorgyf@27
|
733
|
Chris@0
|
734 action = new QAction(tr("&Jump Left"), this);
|
Chris@0
|
735 action->setShortcut(tr("Ctrl+Left"));
|
Chris@0
|
736 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
|
Chris@0
|
737 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
|
Chris@0
|
738 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
739 m_keyReference->registerShortcut(action);
|
Chris@0
|
740 menu->addAction(action);
|
gyorgyf@27
|
741
|
Chris@0
|
742 action = new QAction(tr("J&ump Right"), this);
|
Chris@0
|
743 action->setShortcut(tr("Ctrl+Right"));
|
Chris@0
|
744 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
|
Chris@0
|
745 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
|
Chris@0
|
746 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
747 m_keyReference->registerShortcut(action);
|
Chris@0
|
748 menu->addAction(action);
|
Chris@0
|
749
|
Chris@0
|
750 menu->addSeparator();
|
Chris@0
|
751
|
Chris@0
|
752 m_keyReference->setCategory(tr("Zoom"));
|
Chris@0
|
753
|
Chris@0
|
754 action = new QAction(il.load("zoom-in"),
|
Chris@0
|
755 tr("Zoom &In"), this);
|
Chris@0
|
756 action->setShortcut(tr("Up"));
|
Chris@0
|
757 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@0
|
758 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@0
|
759 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
760 m_keyReference->registerShortcut(action);
|
Chris@0
|
761 menu->addAction(action);
|
gyorgyf@27
|
762
|
Chris@0
|
763 action = new QAction(il.load("zoom-out"),
|
Chris@0
|
764 tr("Zoom &Out"), this);
|
Chris@0
|
765 action->setShortcut(tr("Down"));
|
Chris@0
|
766 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@0
|
767 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@0
|
768 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
769 m_keyReference->registerShortcut(action);
|
Chris@0
|
770 menu->addAction(action);
|
gyorgyf@27
|
771
|
Chris@0
|
772 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@0
|
773 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@0
|
774 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@0
|
775 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
776 menu->addAction(action);
|
Chris@0
|
777
|
Chris@0
|
778 action = new QAction(il.load("zoom-fit"),
|
Chris@0
|
779 tr("Zoom to &Fit"), this);
|
Chris@0
|
780 action->setShortcut(tr("F"));
|
Chris@0
|
781 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@0
|
782 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@0
|
783 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
784 m_keyReference->registerShortcut(action);
|
Chris@0
|
785 menu->addAction(action);
|
Chris@227
|
786
|
Chris@227
|
787 menu->addSeparator();
|
Chris@227
|
788
|
Chris@227
|
789 action = new QAction(tr("Set Displayed Fre&quency Range..."), this);
|
Chris@227
|
790 action->setStatusTip(tr("Set the minimum and maximum frequencies in the visible display"));
|
Chris@227
|
791 connect(action, SIGNAL(triggered()), this, SLOT(editDisplayExtents()));
|
Chris@227
|
792 menu->addAction(action);
|
Chris@0
|
793 }
|
Chris@0
|
794
|
Chris@0
|
795 void
|
Chris@0
|
796 MainWindow::setupHelpMenu()
|
Chris@0
|
797 {
|
Chris@0
|
798 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@0
|
799 menu->setTearOffEnabled(true);
|
Chris@0
|
800
|
Chris@0
|
801 m_keyReference->setCategory(tr("Help"));
|
Chris@0
|
802
|
Chris@0
|
803 IconLoader il;
|
Chris@0
|
804
|
Chris@1
|
805 QString name = QApplication::applicationName();
|
Chris@1
|
806
|
Chris@0
|
807 QAction *action = new QAction(il.load("help"),
|
Chris@0
|
808 tr("&Help Reference"), this);
|
Chris@0
|
809 action->setShortcut(tr("F1"));
|
Chris@1
|
810 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
Chris@0
|
811 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@0
|
812 m_keyReference->registerShortcut(action);
|
Chris@0
|
813 menu->addAction(action);
|
Chris@0
|
814
|
Chris@0
|
815 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@0
|
816 action->setShortcut(tr("F2"));
|
Chris@1
|
817 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@0
|
818 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@0
|
819 m_keyReference->registerShortcut(action);
|
Chris@0
|
820 menu->addAction(action);
|
Chris@0
|
821
|
Chris@1
|
822 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@1
|
823 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@0
|
824 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
825 menu->addAction(action);
|
Chris@0
|
826
|
Chris@1
|
827 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@1
|
828 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@0
|
829 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
830 menu->addAction(action);
|
Chris@0
|
831 }
|
Chris@0
|
832
|
Chris@0
|
833 void
|
Chris@0
|
834 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
835 {
|
Chris@0
|
836 m_recentFilesMenu->clear();
|
Chris@0
|
837 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
838 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@50
|
839 QAction *action = new QAction(files[i], this);
|
Chris@50
|
840 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
841 if (i == 0) {
|
Chris@0
|
842 action->setShortcut(tr("Ctrl+R"));
|
Chris@0
|
843 m_keyReference->registerShortcut
|
Chris@0
|
844 (tr("Re-open"),
|
Chris@50
|
845 action->shortcut().toString(),
|
Chris@0
|
846 tr("Re-open the current or most recently opened file"));
|
Chris@0
|
847 }
|
Chris@50
|
848 m_recentFilesMenu->addAction(action);
|
Chris@0
|
849 }
|
Chris@0
|
850 }
|
Chris@0
|
851
|
Chris@0
|
852 void
|
Chris@0
|
853 MainWindow::setupToolbars()
|
Chris@0
|
854 {
|
Chris@0
|
855 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@0
|
856
|
Chris@0
|
857 IconLoader il;
|
Chris@0
|
858
|
Chris@0
|
859 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@0
|
860 menu->setTearOffEnabled(true);
|
Chris@0
|
861 m_rightButtonMenu->addSeparator();
|
Chris@0
|
862 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@0
|
863
|
Chris@0
|
864 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@0
|
865
|
Chris@0
|
866 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@0
|
867 tr("Rewind to Start"));
|
Chris@0
|
868 rwdStartAction->setShortcut(tr("Home"));
|
Chris@0
|
869 rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
870 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
871 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@0
|
872
|
Chris@0
|
873 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
|
Chris@0
|
874 tr("Rewind"));
|
Chris@0
|
875 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
|
Chris@0
|
876 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
877 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
878
|
Chris@0
|
879 QAction *playAction = toolbar->addAction(il.load("playpause"),
|
Chris@0
|
880 tr("Play / Pause"));
|
Chris@0
|
881 playAction->setCheckable(true);
|
Chris@0
|
882 playAction->setShortcut(tr("Space"));
|
Chris@0
|
883 playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
884 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
885 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
gyorgyf@27
|
886 playAction, SLOT(setChecked(bool)));
|
Chris@0
|
887 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
|
Chris@0
|
888
|
Chris@0
|
889 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@0
|
890 tr("Fast Forward"));
|
Chris@0
|
891 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
|
Chris@0
|
892 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
893 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
894
|
Chris@0
|
895 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@0
|
896 tr("Fast Forward to End"));
|
Chris@0
|
897 ffwdEndAction->setShortcut(tr("End"));
|
Chris@0
|
898 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
899 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
900 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@6
|
901
|
Chris@0
|
902 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
903
|
Chris@0
|
904 QAction *psAction = toolbar->addAction(il.load("playselection"),
|
Chris@0
|
905 tr("Constrain Playback to Selection"));
|
Chris@0
|
906 psAction->setCheckable(true);
|
Chris@0
|
907 psAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
908 psAction->setShortcut(tr("s"));
|
Chris@0
|
909 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@0
|
910 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@0
|
911 psAction, SLOT(setChecked(bool)));
|
Chris@0
|
912 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
913 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
|
Chris@0
|
914
|
Chris@0
|
915 QAction *plAction = toolbar->addAction(il.load("playloop"),
|
Chris@0
|
916 tr("Loop Playback"));
|
Chris@0
|
917 plAction->setCheckable(true);
|
Chris@0
|
918 plAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
919 plAction->setShortcut(tr("l"));
|
Chris@0
|
920 plAction->setStatusTip(tr("Loop playback"));
|
Chris@0
|
921 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@0
|
922 plAction, SLOT(setChecked(bool)));
|
Chris@0
|
923 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
924 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
|
Chris@0
|
925
|
Chris@0
|
926 m_keyReference->registerShortcut(psAction);
|
Chris@0
|
927 m_keyReference->registerShortcut(plAction);
|
Chris@0
|
928 m_keyReference->registerShortcut(playAction);
|
Chris@0
|
929 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@0
|
930 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@0
|
931 m_keyReference->registerShortcut(rwdStartAction);
|
Chris@0
|
932 m_keyReference->registerShortcut(ffwdEndAction);
|
Chris@0
|
933
|
Chris@6
|
934 menu->addAction(playAction);
|
Chris@0
|
935 menu->addAction(psAction);
|
Chris@0
|
936 menu->addAction(plAction);
|
Chris@0
|
937 menu->addSeparator();
|
Chris@0
|
938 menu->addAction(m_rwdAction);
|
Chris@0
|
939 menu->addAction(m_ffwdAction);
|
Chris@0
|
940 menu->addSeparator();
|
Chris@0
|
941 menu->addAction(rwdStartAction);
|
Chris@0
|
942 menu->addAction(ffwdEndAction);
|
Chris@0
|
943 menu->addSeparator();
|
Chris@0
|
944
|
Chris@0
|
945 m_rightButtonPlaybackMenu->addAction(playAction);
|
Chris@0
|
946 m_rightButtonPlaybackMenu->addAction(psAction);
|
Chris@0
|
947 m_rightButtonPlaybackMenu->addAction(plAction);
|
Chris@0
|
948 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
949 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@0
|
950 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@0
|
951 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
952 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
|
Chris@0
|
953 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
|
Chris@0
|
954 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
955
|
Chris@0
|
956 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@0
|
957 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@0
|
958 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@0
|
959 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@0
|
960 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@0
|
961
|
Chris@0
|
962 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@0
|
963 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@0
|
964 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@0
|
965 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@0
|
966 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@0
|
967
|
Chris@0
|
968 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@0
|
969 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@0
|
970 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@0
|
971 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@0
|
972 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@0
|
973
|
Chris@0
|
974 m_keyReference->registerShortcut(fastAction);
|
Chris@0
|
975 m_keyReference->registerShortcut(slowAction);
|
Chris@0
|
976 m_keyReference->registerShortcut(normalAction);
|
Chris@0
|
977
|
Chris@0
|
978 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@0
|
979 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@0
|
980 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@6
|
981
|
Chris@195
|
982 toolbar = new QToolBar(tr("Playback Controls"));
|
Chris@195
|
983 addToolBar(Qt::BottomToolBarArea, toolbar);
|
Chris@195
|
984
|
Chris@6
|
985 toolbar->addWidget(m_playSpeed);
|
Chris@6
|
986 toolbar->addWidget(m_fader);
|
Chris@0
|
987
|
Chris@128
|
988 toolbar = addToolBar(tr("Show and Play"));
|
matthiasm@258
|
989 addToolBar(Qt::BottomToolBarArea, toolbar);
|
matthiasm@258
|
990
|
justin@156
|
991 /* ORIGINAL DESIGN
|
Chris@144
|
992 QLabel *eye = new QLabel;
|
Chris@144
|
993 eye->setFixedWidth(40);
|
Chris@144
|
994 eye->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
995 eye->setPixmap(il.loadPixmap("eye"));
|
Chris@144
|
996 toolbar->addWidget(eye);
|
Chris@144
|
997
|
Chris@144
|
998 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
|
Chris@144
|
999 m_showAudio->setCheckable(true);
|
Chris@144
|
1000 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
Chris@144
|
1001 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
Chris@144
|
1002
|
Chris@145
|
1003 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
|
Chris@145
|
1004 m_showSpect->setCheckable(true);
|
Chris@145
|
1005 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
Chris@145
|
1006 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@145
|
1007
|
Chris@144
|
1008 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
|
Chris@144
|
1009 m_showPitch->setCheckable(true);
|
Chris@144
|
1010 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
Chris@144
|
1011 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
Chris@144
|
1012
|
Chris@144
|
1013 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
|
Chris@144
|
1014 m_showNotes->setCheckable(true);
|
Chris@144
|
1015 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
Chris@144
|
1016 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
Chris@144
|
1017
|
Chris@144
|
1018 QLabel *speaker = new QLabel;
|
Chris@144
|
1019 speaker->setFixedWidth(40);
|
Chris@144
|
1020 speaker->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
Chris@144
|
1021 speaker->setPixmap(il.loadPixmap("speaker"));
|
Chris@144
|
1022 toolbar->addWidget(speaker);
|
Chris@128
|
1023
|
Chris@144
|
1024 m_playAudio = toolbar->addAction(il.load("waveform"), tr("Play Audio"));
|
Chris@144
|
1025 m_playAudio->setCheckable(true);
|
Chris@144
|
1026 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
Chris@144
|
1027 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
Chris@128
|
1028
|
Chris@144
|
1029 m_playPitch = toolbar->addAction(il.load("values"), tr("Play Pitch Track"));
|
Chris@144
|
1030 m_playPitch->setCheckable(true);
|
Chris@144
|
1031 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
Chris@144
|
1032 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
|
Chris@128
|
1033
|
Chris@144
|
1034 m_playNotes = toolbar->addAction(il.load("notes"), tr("Play Notes"));
|
Chris@144
|
1035 m_playNotes->setCheckable(true);
|
Chris@144
|
1036 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
Chris@144
|
1037 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
1038 */
|
justin@156
|
1039
|
justin@156
|
1040 // Audio
|
justin@220
|
1041 /*
|
justin@156
|
1042 QLabel *icon_audio = new QLabel;
|
justin@156
|
1043 icon_audio->setFixedWidth(40);
|
justin@156
|
1044 icon_audio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@156
|
1045 icon_audio->setPixmap(il.loadPixmap("waveform"));
|
justin@156
|
1046 toolbar->addWidget(icon_audio);
|
justin@220
|
1047 */
|
justin@220
|
1048
|
justin@220
|
1049 //m_showAudio = toolbar->addAction(il.load("eye"), tr("Show Audio"))
|
justin@220
|
1050 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
|
justin@156
|
1051 m_showAudio->setCheckable(true);
|
justin@156
|
1052 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
justin@156
|
1053 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
justin@156
|
1054
|
justin@156
|
1055 m_playAudio = toolbar->addAction(il.load("speaker"), tr("Play Audio"));
|
justin@156
|
1056 m_playAudio->setCheckable(true);
|
justin@156
|
1057 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
justin@156
|
1058 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
justin@156
|
1059
|
justin@159
|
1060 toolbar->addWidget(m_gainAudio);
|
justin@160
|
1061 toolbar->addWidget(m_panAudio);
|
justin@159
|
1062
|
justin@156
|
1063 // Pitch (f0)
|
justin@156
|
1064 QLabel *icon_pitch = new QLabel;
|
justin@156
|
1065 icon_pitch->setFixedWidth(40);
|
justin@156
|
1066 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@220
|
1067 //icon_pitch->setPixmap(il.loadPixmap("values"));
|
justin@156
|
1068 toolbar->addWidget(icon_pitch);
|
justin@156
|
1069
|
justin@220
|
1070 // m_showPitch = toolbar->addAction(il.load("eye"), tr("Show Pitch Track"));
|
justin@220
|
1071 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
|
justin@156
|
1072 m_showPitch->setCheckable(true);
|
justin@156
|
1073 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
justin@156
|
1074 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
justin@156
|
1075
|
justin@156
|
1076 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
|
justin@156
|
1077 m_playPitch->setCheckable(true);
|
justin@156
|
1078 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
justin@186
|
1079 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); // JTEST: this resets the enabled state of m_playPitch.
|
justin@156
|
1080
|
Chris@158
|
1081 toolbar->addWidget(m_gainPitch);
|
justin@160
|
1082 toolbar->addWidget(m_panPitch);
|
justin@156
|
1083
|
justin@156
|
1084 // Notes
|
justin@156
|
1085 QLabel *icon_notes = new QLabel;
|
justin@156
|
1086 icon_notes->setFixedWidth(40);
|
justin@156
|
1087 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@220
|
1088 //icon_notes->setPixmap(il.loadPixmap("notes"));
|
justin@156
|
1089 toolbar->addWidget(icon_notes);
|
justin@156
|
1090
|
justin@220
|
1091
|
justin@220
|
1092 //m_showNotes = toolbar->addAction(il.load("eye"), tr("Show Notes"));
|
justin@220
|
1093 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
|
justin@156
|
1094 m_showNotes->setCheckable(true);
|
justin@156
|
1095 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
justin@156
|
1096 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
justin@156
|
1097
|
justin@156
|
1098 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes"));
|
justin@156
|
1099 m_playNotes->setCheckable(true);
|
justin@156
|
1100 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
justin@156
|
1101 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
1102
|
justin@159
|
1103 toolbar->addWidget(m_gainNotes);
|
justin@160
|
1104 toolbar->addWidget(m_panNotes);
|
justin@159
|
1105
|
justin@156
|
1106 // Spectrogram
|
justin@156
|
1107 QLabel *icon_spectrogram = new QLabel;
|
justin@156
|
1108 icon_spectrogram->setFixedWidth(40);
|
justin@156
|
1109 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
justin@220
|
1110 //icon_spectrogram->setPixmap(il.loadPixmap("spectrogram"));
|
justin@156
|
1111 toolbar->addWidget(icon_spectrogram);
|
justin@156
|
1112
|
justin@220
|
1113 //m_showSpect = toolbar->addAction(il.load("eye"), tr("Show Spectrogram"));
|
justin@220
|
1114 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
|
justin@156
|
1115 m_showSpect->setCheckable(true);
|
justin@156
|
1116 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
justin@156
|
1117 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@128
|
1118
|
Chris@0
|
1119 Pane::registerShortcuts(*m_keyReference);
|
Chris@0
|
1120 }
|
Chris@0
|
1121
|
Chris@0
|
1122 void
|
Chris@70
|
1123 MainWindow::toolNavigateSelected()
|
Chris@70
|
1124 {
|
Chris@70
|
1125 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@70
|
1126 m_intelligentActionOn = true;
|
Chris@70
|
1127 }
|
Chris@70
|
1128
|
Chris@70
|
1129 void
|
Chris@70
|
1130 MainWindow::toolEditSelected()
|
Chris@70
|
1131 {
|
Chris@77
|
1132 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1133 m_intelligentActionOn = true;
|
Chris@70
|
1134 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1135 }
|
Chris@70
|
1136
|
Chris@70
|
1137 void
|
Chris@70
|
1138 MainWindow::toolFreeEditSelected()
|
Chris@70
|
1139 {
|
Chris@77
|
1140 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1141 m_intelligentActionOn = false;
|
Chris@70
|
1142 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1143 }
|
Chris@70
|
1144
|
gyorgyf@21
|
1145 void
|
Chris@0
|
1146 MainWindow::updateMenuStates()
|
Chris@0
|
1147 {
|
Chris@0
|
1148 MainWindowBase::updateMenuStates();
|
Chris@0
|
1149
|
Chris@0
|
1150 Pane *currentPane = 0;
|
Chris@0
|
1151 Layer *currentLayer = 0;
|
Chris@0
|
1152
|
Chris@0
|
1153 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1154 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@0
|
1155
|
Chris@0
|
1156 bool haveCurrentPane =
|
Chris@0
|
1157 (currentPane != 0);
|
Chris@0
|
1158 bool haveCurrentLayer =
|
Chris@0
|
1159 (haveCurrentPane &&
|
Chris@0
|
1160 (currentLayer != 0));
|
Chris@0
|
1161 bool haveSelection =
|
Chris@187
|
1162 (m_viewManager &&
|
Chris@187
|
1163 !m_viewManager->getSelections().empty());
|
Chris@0
|
1164 bool haveCurrentEditableLayer =
|
Chris@187
|
1165 (haveCurrentLayer &&
|
Chris@187
|
1166 currentLayer->isLayerEditable());
|
Chris@0
|
1167 bool haveCurrentTimeInstantsLayer =
|
Chris@187
|
1168 (haveCurrentLayer &&
|
Chris@187
|
1169 qobject_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
1170 bool haveCurrentTimeValueLayer =
|
Chris@187
|
1171 (haveCurrentLayer &&
|
Chris@187
|
1172 qobject_cast<TimeValueLayer *>(currentLayer));
|
Chris@187
|
1173 bool pitchCandidatesVisible =
|
Chris@187
|
1174 m_analyser->arePitchCandidatesShown();
|
Chris@198
|
1175 bool haveHigher =
|
Chris@198
|
1176 m_analyser->haveHigherPitchCandidate();
|
Chris@198
|
1177 bool haveLower =
|
Chris@198
|
1178 m_analyser->haveLowerPitchCandidate();
|
Chris@0
|
1179
|
Chris@0
|
1180 emit canChangePlaybackSpeed(true);
|
Chris@0
|
1181 int v = m_playSpeed->value();
|
Chris@0
|
1182 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@0
|
1183 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@0
|
1184
|
Chris@237
|
1185 bool havePitchTrack =
|
Chris@237
|
1186 m_analyser->isVisible(Analyser::PitchTrack) &&
|
Chris@237
|
1187 m_analyser->getLayer(Analyser::PitchTrack);
|
Chris@237
|
1188
|
Chris@237
|
1189 bool haveNotes =
|
Chris@237
|
1190 m_analyser->isVisible(Analyser::Notes) &&
|
Chris@237
|
1191 m_analyser->getLayer(Analyser::Notes);
|
Chris@237
|
1192
|
Chris@237
|
1193 emit canExportPitchTrack(havePitchTrack);
|
Chris@237
|
1194 emit canExportNotes(haveNotes);
|
Chris@237
|
1195 emit canSnapNotes(haveSelection && haveNotes);
|
Chris@224
|
1196
|
Chris@187
|
1197 if (pitchCandidatesVisible) {
|
Chris@187
|
1198 m_showCandidatesAction->setText(tr("Hide Pitch Candidates"));
|
Chris@187
|
1199 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region"));
|
Chris@187
|
1200 } else {
|
Chris@187
|
1201 m_showCandidatesAction->setText(tr("Show Pitch Candidates"));
|
Chris@187
|
1202 m_showCandidatesAction->setStatusTip(tr("Show alternate pitch candidates for the selected region"));
|
Chris@187
|
1203 }
|
Chris@187
|
1204
|
Chris@0
|
1205 if (m_ffwdAction && m_rwdAction) {
|
Chris@0
|
1206 if (haveCurrentTimeInstantsLayer) {
|
Chris@0
|
1207 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@0
|
1208 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1209 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@0
|
1210 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1211 } else if (haveCurrentTimeValueLayer) {
|
Chris@0
|
1212 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@0
|
1213 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@0
|
1214 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@0
|
1215 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@0
|
1216 } else {
|
Chris@0
|
1217 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@0
|
1218 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@0
|
1219 m_rwdAction->setText(tr("Rewind"));
|
Chris@0
|
1220 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@0
|
1221 }
|
Chris@0
|
1222 }
|
Chris@0
|
1223 }
|
Chris@0
|
1224
|
Chris@0
|
1225 void
|
Chris@144
|
1226 MainWindow::showAudioToggled()
|
Chris@128
|
1227 {
|
Chris@144
|
1228 m_analyser->toggleVisible(Analyser::Audio);
|
justin@220
|
1229
|
justin@220
|
1230 // JTEST
|
justin@220
|
1231 if (!m_analyser->isVisible(Analyser::Audio))
|
justin@220
|
1232 {
|
justin@220
|
1233 m_analyser->setAudible(Analyser::Audio,false);
|
justin@220
|
1234 m_playAudio->setChecked(false);
|
justin@220
|
1235 m_playAudio->setEnabled(false);
|
justin@220
|
1236 }
|
justin@220
|
1237 else
|
justin@220
|
1238 {
|
justin@220
|
1239 m_playAudio->setEnabled(true);
|
justin@220
|
1240 }
|
Chris@128
|
1241 }
|
Chris@128
|
1242
|
Chris@128
|
1243 void
|
Chris@144
|
1244 MainWindow::showPitchToggled()
|
Chris@128
|
1245 {
|
Chris@144
|
1246 m_analyser->toggleVisible(Analyser::PitchTrack);
|
justin@185
|
1247
|
justin@186
|
1248 // JTEST
|
justin@185
|
1249 if (!m_analyser->isVisible(Analyser::PitchTrack))
|
justin@185
|
1250 {
|
justin@185
|
1251 m_analyser->setAudible(Analyser::PitchTrack,false);
|
justin@185
|
1252 m_playPitch->setChecked(false);
|
justin@185
|
1253 m_playPitch->setEnabled(false);
|
justin@185
|
1254 }
|
justin@185
|
1255 else
|
justin@185
|
1256 {
|
justin@185
|
1257 m_playPitch->setEnabled(true);
|
justin@185
|
1258 }
|
Chris@128
|
1259 }
|
Chris@128
|
1260
|
Chris@128
|
1261 void
|
Chris@145
|
1262 MainWindow::showSpectToggled()
|
Chris@145
|
1263 {
|
Chris@145
|
1264 m_analyser->toggleVisible(Analyser::Spectrogram);
|
Chris@145
|
1265 }
|
Chris@145
|
1266
|
Chris@145
|
1267 void
|
Chris@144
|
1268 MainWindow::showNotesToggled()
|
Chris@128
|
1269 {
|
Chris@144
|
1270 m_analyser->toggleVisible(Analyser::Notes);
|
justin@220
|
1271
|
justin@220
|
1272 // JTEST
|
justin@220
|
1273 if (!m_analyser->isVisible(Analyser::Notes))
|
justin@220
|
1274 {
|
justin@220
|
1275 m_analyser->setAudible(Analyser::Notes,false);
|
justin@220
|
1276 m_playNotes->setChecked(false);
|
justin@220
|
1277 m_playNotes->setEnabled(false);
|
justin@220
|
1278 }
|
justin@220
|
1279 else
|
justin@220
|
1280 {
|
justin@220
|
1281 m_playNotes->setEnabled(true);
|
justin@220
|
1282 }
|
Chris@144
|
1283 }
|
Chris@144
|
1284
|
Chris@144
|
1285 void
|
Chris@144
|
1286 MainWindow::playAudioToggled()
|
Chris@144
|
1287 {
|
Chris@144
|
1288 m_analyser->toggleAudible(Analyser::Audio);
|
Chris@144
|
1289 }
|
Chris@144
|
1290
|
Chris@144
|
1291 void
|
Chris@144
|
1292 MainWindow::playPitchToggled()
|
Chris@144
|
1293 {
|
Chris@144
|
1294 m_analyser->toggleAudible(Analyser::PitchTrack);
|
Chris@144
|
1295 }
|
Chris@144
|
1296
|
Chris@144
|
1297 void
|
Chris@144
|
1298 MainWindow::playNotesToggled()
|
Chris@144
|
1299 {
|
Chris@144
|
1300 m_analyser->toggleAudible(Analyser::Notes);
|
Chris@144
|
1301 }
|
Chris@144
|
1302
|
Chris@144
|
1303 void
|
Chris@144
|
1304 MainWindow::updateLayerStatuses()
|
Chris@144
|
1305 {
|
Chris@144
|
1306 m_showAudio->setChecked(m_analyser->isVisible(Analyser::Audio));
|
Chris@145
|
1307 m_showSpect->setChecked(m_analyser->isVisible(Analyser::Spectrogram));
|
Chris@144
|
1308 m_showPitch->setChecked(m_analyser->isVisible(Analyser::PitchTrack));
|
Chris@144
|
1309 m_showNotes->setChecked(m_analyser->isVisible(Analyser::Notes));
|
Chris@144
|
1310 m_playAudio->setChecked(m_analyser->isAudible(Analyser::Audio));
|
Chris@144
|
1311 m_playPitch->setChecked(m_analyser->isAudible(Analyser::PitchTrack));
|
Chris@144
|
1312 m_playNotes->setChecked(m_analyser->isAudible(Analyser::Notes));
|
Chris@128
|
1313 }
|
Chris@128
|
1314
|
Chris@128
|
1315 void
|
Chris@227
|
1316 MainWindow::editDisplayExtents()
|
Chris@227
|
1317 {
|
Chris@227
|
1318 float min, max;
|
Chris@227
|
1319 float vmin = 0;
|
Chris@227
|
1320 float vmax = getMainModel()->getSampleRate() /2;
|
Chris@227
|
1321
|
Chris@227
|
1322 if (!m_analyser->getDisplayFrequencyExtents(min, max)) {
|
Chris@227
|
1323 //!!!
|
Chris@227
|
1324 return;
|
Chris@227
|
1325 }
|
Chris@227
|
1326
|
Chris@227
|
1327 RangeInputDialog dialog(tr("Set frequency range"),
|
Chris@227
|
1328 tr("Enter new frequency range, from %1 to %2 Hz.\nThese values will be rounded to the nearest spectrogram bin.")
|
Chris@227
|
1329 .arg(vmin).arg(vmax),
|
Chris@227
|
1330 "Hz", vmin, vmax, this);
|
Chris@227
|
1331 dialog.setRange(min, max);
|
Chris@227
|
1332
|
Chris@227
|
1333 if (dialog.exec() == QDialog::Accepted) {
|
Chris@227
|
1334 dialog.getRange(min, max);
|
Chris@227
|
1335 if (min > max) {
|
Chris@227
|
1336 float tmp = max;
|
Chris@227
|
1337 max = min;
|
Chris@227
|
1338 min = tmp;
|
Chris@227
|
1339 }
|
Chris@227
|
1340 m_analyser->setDisplayFrequencyExtents(min, max);
|
Chris@227
|
1341 }
|
Chris@227
|
1342 }
|
Chris@227
|
1343
|
Chris@227
|
1344 void
|
Chris@0
|
1345 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1346 {
|
Chris@6
|
1347 // Nothing, we don't have one
|
Chris@0
|
1348 }
|
Chris@0
|
1349
|
Chris@0
|
1350 void
|
Chris@0
|
1351 MainWindow::documentModified()
|
Chris@0
|
1352 {
|
Chris@0
|
1353 MainWindowBase::documentModified();
|
Chris@0
|
1354 }
|
Chris@0
|
1355
|
Chris@0
|
1356 void
|
Chris@0
|
1357 MainWindow::documentRestored()
|
Chris@0
|
1358 {
|
Chris@0
|
1359 MainWindowBase::documentRestored();
|
Chris@0
|
1360 }
|
Chris@0
|
1361
|
Chris@0
|
1362 void
|
Chris@0
|
1363 MainWindow::newSession()
|
Chris@0
|
1364 {
|
Chris@0
|
1365 if (!checkSaveModified()) return;
|
Chris@0
|
1366
|
Chris@0
|
1367 closeSession();
|
Chris@0
|
1368 createDocument();
|
Chris@0
|
1369 m_document->setAutoAlignment(true);
|
Chris@0
|
1370
|
Chris@0
|
1371 Pane *pane = m_paneStack->addPane();
|
Chris@0
|
1372
|
Chris@0
|
1373 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
1374 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
1375
|
Chris@6
|
1376 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@6
|
1377 // m_document->addLayerToView(pane, waveform);
|
Chris@0
|
1378
|
Chris@0
|
1379 m_overview->registerView(pane);
|
Chris@0
|
1380
|
Chris@0
|
1381 CommandHistory::getInstance()->clear();
|
Chris@0
|
1382 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1383 documentRestored();
|
Chris@0
|
1384 updateMenuStates();
|
Chris@0
|
1385 }
|
Chris@0
|
1386
|
Chris@0
|
1387 void
|
Chris@244
|
1388 MainWindow::documentReplaced()
|
Chris@244
|
1389 {
|
Chris@244
|
1390 if (m_document) {
|
Chris@244
|
1391 connect(m_document, SIGNAL(activity(QString)),
|
Chris@244
|
1392 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
1393 }
|
Chris@244
|
1394 }
|
Chris@244
|
1395
|
Chris@244
|
1396 void
|
Chris@0
|
1397 MainWindow::closeSession()
|
Chris@0
|
1398 {
|
Chris@0
|
1399 if (!checkSaveModified()) return;
|
Chris@0
|
1400
|
Chris@226
|
1401 m_analyser->fileClosed();
|
Chris@226
|
1402
|
Chris@0
|
1403 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
1404
|
Chris@167
|
1405 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
1406
|
Chris@167
|
1407 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1408 m_document->removeLayerFromView
|
Chris@167
|
1409 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1410 }
|
Chris@167
|
1411
|
Chris@167
|
1412 m_overview->unregisterView(pane);
|
Chris@167
|
1413 m_paneStack->deletePane(pane);
|
Chris@0
|
1414 }
|
Chris@0
|
1415
|
Chris@0
|
1416 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
1417
|
Chris@167
|
1418 Pane *pane = m_paneStack->getHiddenPane
|
Chris@167
|
1419 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@167
|
1420
|
Chris@167
|
1421 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1422 m_document->removeLayerFromView
|
Chris@167
|
1423 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1424 }
|
Chris@167
|
1425
|
Chris@167
|
1426 m_overview->unregisterView(pane);
|
Chris@167
|
1427 m_paneStack->deletePane(pane);
|
Chris@0
|
1428 }
|
Chris@0
|
1429
|
Chris@0
|
1430 delete m_document;
|
Chris@0
|
1431 m_document = 0;
|
Chris@0
|
1432 m_viewManager->clearSelections();
|
Chris@0
|
1433 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
1434
|
Chris@0
|
1435 m_sessionFile = "";
|
Chris@0
|
1436
|
Chris@0
|
1437 CommandHistory::getInstance()->clear();
|
Chris@0
|
1438 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1439 documentRestored();
|
Chris@0
|
1440 }
|
Chris@0
|
1441
|
Chris@0
|
1442 void
|
Chris@0
|
1443 MainWindow::openFile()
|
Chris@0
|
1444 {
|
Chris@0
|
1445 QString orig = m_audioFile;
|
Chris@0
|
1446 if (orig == "") orig = ".";
|
Chris@0
|
1447 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1448
|
Chris@0
|
1449 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
1450
|
Chris@0
|
1451 if (path.isEmpty()) return;
|
Chris@0
|
1452
|
Chris@1
|
1453 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1454
|
Chris@0
|
1455 if (status == FileOpenFailed) {
|
Chris@0
|
1456 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1457 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@0
|
1458 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1459 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1460 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1461 }
|
Chris@0
|
1462 }
|
Chris@0
|
1463
|
Chris@0
|
1464 void
|
Chris@0
|
1465 MainWindow::openLocation()
|
Chris@0
|
1466 {
|
Chris@0
|
1467 QSettings settings;
|
Chris@0
|
1468 settings.beginGroup("MainWindow");
|
Chris@0
|
1469 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@0
|
1470
|
Chris@0
|
1471 bool ok = false;
|
Chris@0
|
1472 QString text = QInputDialog::getText
|
Chris@0
|
1473 (this, tr("Open Location"),
|
Chris@0
|
1474 tr("Please enter the URL of the location to open:"),
|
Chris@0
|
1475 QLineEdit::Normal, lastLocation, &ok);
|
Chris@0
|
1476
|
Chris@0
|
1477 if (!ok) return;
|
Chris@0
|
1478
|
Chris@0
|
1479 settings.setValue("lastremote", text);
|
Chris@0
|
1480
|
Chris@0
|
1481 if (text.isEmpty()) return;
|
Chris@0
|
1482
|
Chris@1
|
1483 FileOpenStatus status = open(text, ReplaceSession);
|
Chris@0
|
1484
|
Chris@0
|
1485 if (status == FileOpenFailed) {
|
Chris@0
|
1486 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1487 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@0
|
1488 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1489 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1490 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1491 }
|
Chris@0
|
1492 }
|
Chris@0
|
1493
|
Chris@0
|
1494 void
|
Chris@0
|
1495 MainWindow::openRecentFile()
|
Chris@0
|
1496 {
|
Chris@0
|
1497 QObject *obj = sender();
|
Chris@3
|
1498 QAction *action = qobject_cast<QAction *>(obj);
|
Chris@0
|
1499
|
Chris@0
|
1500 if (!action) {
|
Chris@188
|
1501 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@188
|
1502 << endl;
|
Chris@188
|
1503 return;
|
Chris@0
|
1504 }
|
Chris@0
|
1505
|
Chris@0
|
1506 QString path = action->text();
|
Chris@0
|
1507 if (path == "") return;
|
Chris@0
|
1508
|
Chris@1
|
1509 FileOpenStatus status = open(path, ReplaceSession);
|
Chris@0
|
1510
|
Chris@0
|
1511 if (status == FileOpenFailed) {
|
Chris@0
|
1512 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1513 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@0
|
1514 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1515 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1516 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1517 }
|
Chris@0
|
1518 }
|
Chris@0
|
1519
|
Chris@0
|
1520 void
|
Chris@0
|
1521 MainWindow::paneAdded(Pane *pane)
|
Chris@0
|
1522 {
|
Chris@6
|
1523 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
1524 m_paneStack->sizePanesEqually();
|
Chris@0
|
1525 if (m_overview) m_overview->registerView(pane);
|
Chris@0
|
1526 }
|
Chris@0
|
1527
|
Chris@0
|
1528 void
|
Chris@0
|
1529 MainWindow::paneHidden(Pane *pane)
|
Chris@0
|
1530 {
|
Chris@0
|
1531 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1532 }
|
Chris@0
|
1533
|
Chris@0
|
1534 void
|
Chris@0
|
1535 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@0
|
1536 {
|
Chris@0
|
1537 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1538 }
|
Chris@0
|
1539
|
Chris@0
|
1540 void
|
Chris@0
|
1541 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@0
|
1542 {
|
Chris@4
|
1543 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1544
|
Chris@0
|
1545 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@0
|
1546
|
Chris@1
|
1547 FileOpenStatus status = open(*i, ReplaceSession);
|
Chris@0
|
1548
|
Chris@0
|
1549 if (status == FileOpenFailed) {
|
Chris@0
|
1550 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1551 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@0
|
1552 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1553 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1554 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1555 }
|
Chris@0
|
1556 }
|
Chris@0
|
1557 }
|
Chris@0
|
1558
|
Chris@0
|
1559 void
|
Chris@0
|
1560 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@0
|
1561 {
|
Chris@0
|
1562 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1563
|
Chris@0
|
1564 QUrl testUrl(text);
|
Chris@0
|
1565 if (testUrl.scheme() == "file" ||
|
Chris@0
|
1566 testUrl.scheme() == "http" ||
|
Chris@0
|
1567 testUrl.scheme() == "ftp") {
|
Chris@0
|
1568 QStringList list;
|
Chris@0
|
1569 list.push_back(text);
|
Chris@0
|
1570 paneDropAccepted(pane, list);
|
Chris@0
|
1571 return;
|
Chris@0
|
1572 }
|
Chris@0
|
1573
|
Chris@0
|
1574 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@0
|
1575 //to a text layer?
|
Chris@0
|
1576 }
|
Chris@0
|
1577
|
Chris@0
|
1578 void
|
Chris@0
|
1579 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
1580 {
|
Chris@70
|
1581 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@0
|
1582
|
Chris@0
|
1583 if (m_openingAudioFile) {
|
Chris@70
|
1584 // cerr << "Busy - ignoring close event" << endl;
|
Chris@257
|
1585 e->ignore();
|
Chris@257
|
1586 return;
|
Chris@0
|
1587 }
|
Chris@0
|
1588
|
Chris@0
|
1589 if (!m_abandoning && !checkSaveModified()) {
|
Chris@70
|
1590 // cerr << "Ignoring close event" << endl;
|
Chris@257
|
1591 e->ignore();
|
Chris@257
|
1592 return;
|
Chris@0
|
1593 }
|
Chris@0
|
1594
|
Chris@0
|
1595 QSettings settings;
|
Chris@0
|
1596 settings.beginGroup("MainWindow");
|
Chris@0
|
1597 settings.setValue("size", size());
|
Chris@0
|
1598 settings.setValue("position", pos());
|
Chris@0
|
1599 settings.endGroup();
|
Chris@0
|
1600
|
Chris@0
|
1601 delete m_keyReference;
|
Chris@0
|
1602 m_keyReference = 0;
|
Chris@0
|
1603
|
Chris@0
|
1604 closeSession();
|
Chris@0
|
1605
|
Chris@0
|
1606 e->accept();
|
Chris@0
|
1607 return;
|
Chris@0
|
1608 }
|
Chris@0
|
1609
|
Chris@0
|
1610 bool
|
Chris@0
|
1611 MainWindow::commitData(bool mayAskUser)
|
Chris@0
|
1612 {
|
Chris@0
|
1613 if (mayAskUser) {
|
Chris@0
|
1614 bool rv = checkSaveModified();
|
Chris@0
|
1615 return rv;
|
Chris@0
|
1616 } else {
|
Chris@0
|
1617 if (!m_documentModified) return true;
|
Chris@0
|
1618
|
Chris@0
|
1619 // If we can't check with the user first, then we can't save
|
Chris@0
|
1620 // to the original session file (even if we have it) -- have
|
Chris@0
|
1621 // to use a temporary file
|
Chris@0
|
1622
|
Chris@0
|
1623 QString svDirBase = ".sv1";
|
Chris@0
|
1624 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@0
|
1625
|
Chris@0
|
1626 if (!QFileInfo(svDir).exists()) {
|
Chris@0
|
1627 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@0
|
1628 } else {
|
Chris@0
|
1629 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@0
|
1630 }
|
Chris@0
|
1631
|
Chris@0
|
1632 // This name doesn't have to be unguessable
|
Chris@0
|
1633 #ifndef _WIN32
|
Chris@0
|
1634 QString fname = QString("tmp-%1-%2.sv")
|
Chris@0
|
1635 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@0
|
1636 .arg(QProcess().pid());
|
Chris@0
|
1637 #else
|
Chris@0
|
1638 QString fname = QString("tmp-%1.sv")
|
Chris@0
|
1639 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@0
|
1640 #endif
|
Chris@0
|
1641 QString fpath = QDir(svDir).filePath(fname);
|
Chris@0
|
1642 if (saveSessionFile(fpath)) {
|
Chris@0
|
1643 m_recentFiles.addFile(fpath);
|
Chris@0
|
1644 return true;
|
Chris@0
|
1645 } else {
|
Chris@0
|
1646 return false;
|
Chris@0
|
1647 }
|
Chris@0
|
1648 }
|
Chris@0
|
1649 }
|
Chris@0
|
1650
|
Chris@0
|
1651 bool
|
Chris@0
|
1652 MainWindow::checkSaveModified()
|
Chris@0
|
1653 {
|
Chris@0
|
1654 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
1655 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
1656 // cancel.
|
Chris@0
|
1657
|
Chris@0
|
1658 if (!m_documentModified) return true;
|
Chris@0
|
1659
|
Chris@0
|
1660 int button =
|
Chris@257
|
1661 QMessageBox::warning(this,
|
Chris@257
|
1662 tr("Session modified"),
|
Chris@257
|
1663 tr("The current session has been modified.\nDo you want to save it?"),
|
Chris@257
|
1664 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@0
|
1665 QMessageBox::Yes);
|
Chris@0
|
1666
|
Chris@0
|
1667 if (button == QMessageBox::Yes) {
|
Chris@257
|
1668 saveSession();
|
Chris@257
|
1669 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@257
|
1670 return false;
|
Chris@257
|
1671 } else {
|
Chris@0
|
1672 return true; // saved, so it's safe to continue now
|
Chris@0
|
1673 }
|
Chris@0
|
1674 } else if (button == QMessageBox::No) {
|
Chris@257
|
1675 m_documentModified = false; // so we know to abandon it
|
Chris@257
|
1676 return true;
|
Chris@0
|
1677 }
|
Chris@0
|
1678
|
Chris@0
|
1679 // else cancel
|
Chris@0
|
1680 return false;
|
Chris@0
|
1681 }
|
Chris@0
|
1682
|
Chris@0
|
1683 void
|
Chris@0
|
1684 MainWindow::saveSession()
|
Chris@0
|
1685 {
|
Chris@0
|
1686 if (m_sessionFile != "") {
|
Chris@257
|
1687 if (!saveSessionFile(m_sessionFile)) {
|
Chris@257
|
1688 QMessageBox::critical
|
Chris@257
|
1689 (this, tr("Failed to save file"),
|
Chris@257
|
1690 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@257
|
1691 } else {
|
Chris@257
|
1692 CommandHistory::getInstance()->documentSaved();
|
Chris@257
|
1693 documentRestored();
|
Chris@257
|
1694 }
|
Chris@0
|
1695 } else {
|
Chris@257
|
1696 saveSessionAs();
|
Chris@0
|
1697 }
|
Chris@0
|
1698 }
|
Chris@0
|
1699
|
Chris@0
|
1700 void
|
Chris@0
|
1701 MainWindow::saveSessionAs()
|
Chris@0
|
1702 {
|
Chris@0
|
1703 QString orig = m_audioFile;
|
Chris@0
|
1704 if (orig == "") orig = ".";
|
Chris@0
|
1705 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1706
|
Chris@0
|
1707 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@0
|
1708
|
Chris@0
|
1709 if (path == "") return;
|
Chris@0
|
1710
|
Chris@0
|
1711 if (!saveSessionFile(path)) {
|
Chris@85
|
1712 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@85
|
1713 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
1714 } else {
|
Chris@85
|
1715 setWindowTitle(tr("%1: %2")
|
Chris@0
|
1716 .arg(QApplication::applicationName())
|
Chris@85
|
1717 .arg(QFileInfo(path).fileName()));
|
Chris@85
|
1718 m_sessionFile = path;
|
Chris@85
|
1719 CommandHistory::getInstance()->documentSaved();
|
Chris@85
|
1720 documentRestored();
|
Chris@0
|
1721 m_recentFiles.addFile(path);
|
Chris@0
|
1722 }
|
Chris@0
|
1723 }
|
Chris@0
|
1724
|
Chris@85
|
1725 QString
|
Chris@85
|
1726 MainWindow::exportToSVL(QString path, Layer *layer)
|
Chris@85
|
1727 {
|
Chris@85
|
1728 Model *model = layer->getModel();
|
Chris@85
|
1729
|
Chris@85
|
1730 QFile file(path);
|
Chris@85
|
1731 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@85
|
1732 return tr("Failed to open file %1 for writing").arg(path);
|
Chris@85
|
1733 } else {
|
Chris@85
|
1734 QTextStream out(&file);
|
Chris@85
|
1735 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@85
|
1736 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@85
|
1737 << "<sv>\n"
|
Chris@85
|
1738 << " <data>\n";
|
Chris@85
|
1739
|
Chris@85
|
1740 model->toXml(out, " ");
|
Chris@85
|
1741
|
Chris@85
|
1742 out << " </data>\n"
|
Chris@85
|
1743 << " <display>\n";
|
Chris@85
|
1744
|
Chris@85
|
1745 layer->toXml(out, " ");
|
Chris@85
|
1746
|
Chris@85
|
1747 out << " </display>\n"
|
Chris@85
|
1748 << "</sv>\n";
|
Chris@85
|
1749
|
Chris@85
|
1750 return "";
|
Chris@85
|
1751 }
|
Chris@85
|
1752 }
|
Chris@85
|
1753
|
Chris@0
|
1754 void
|
Chris@174
|
1755 MainWindow::importPitchLayer()
|
Chris@174
|
1756 {
|
Chris@174
|
1757 QString path = getOpenFileName(FileFinder::LayerFileNoMidiNonSV);
|
Chris@174
|
1758 if (path == "") return;
|
Chris@174
|
1759
|
Chris@174
|
1760 FileOpenStatus status = importPitchLayer(path);
|
Chris@174
|
1761
|
Chris@174
|
1762 if (status == FileOpenFailed) {
|
Chris@174
|
1763 emit hideSplash();
|
Chris@174
|
1764 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1765 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@174
|
1766 return;
|
Chris@174
|
1767 } else if (status == FileOpenWrongMode) {
|
Chris@174
|
1768 emit hideSplash();
|
Chris@174
|
1769 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
1770 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@174
|
1771 }
|
Chris@174
|
1772 }
|
Chris@174
|
1773
|
Chris@174
|
1774 MainWindow::FileOpenStatus
|
Chris@174
|
1775 MainWindow::importPitchLayer(FileSource source)
|
Chris@174
|
1776 {
|
Chris@174
|
1777 if (!source.isAvailable()) return FileOpenFailed;
|
Chris@174
|
1778 source.waitForData();
|
Chris@174
|
1779
|
Chris@174
|
1780 QString path = source.getLocalFilename();
|
Chris@174
|
1781
|
Chris@174
|
1782 RDFImporter::RDFDocumentType rdfType =
|
Chris@174
|
1783 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString());
|
Chris@174
|
1784
|
Chris@174
|
1785 if (rdfType != RDFImporter::NotRDF) {
|
Chris@174
|
1786
|
Chris@174
|
1787 //!!!
|
Chris@174
|
1788 return FileOpenFailed;
|
Chris@174
|
1789
|
Chris@174
|
1790 } else if (source.getExtension().toLower() == "svl" ||
|
Chris@174
|
1791 (source.getExtension().toLower() == "xml" &&
|
Chris@174
|
1792 (SVFileReader::identifyXmlFile(source.getLocalFilename())
|
Chris@174
|
1793 == SVFileReader::SVLayerFile))) {
|
Chris@174
|
1794
|
Chris@174
|
1795 //!!!
|
Chris@174
|
1796 return FileOpenFailed;
|
Chris@174
|
1797
|
Chris@174
|
1798 } else {
|
Chris@174
|
1799
|
Chris@174
|
1800 try {
|
Chris@174
|
1801
|
Chris@174
|
1802 CSVFormat format(path);
|
Chris@174
|
1803 format.setSampleRate(getMainModel()->getSampleRate());
|
Chris@174
|
1804
|
Chris@174
|
1805 if (format.getModelType() != CSVFormat::TwoDimensionalModel) {
|
Chris@174
|
1806 //!!! error report
|
Chris@174
|
1807 return FileOpenFailed;
|
Chris@174
|
1808 }
|
Chris@174
|
1809
|
Chris@174
|
1810 Model *model = DataFileReaderFactory::loadCSV
|
Chris@174
|
1811 (path, format, getMainModel()->getSampleRate());
|
Chris@174
|
1812
|
Chris@174
|
1813 if (model) {
|
Chris@174
|
1814
|
Chris@174
|
1815 SVDEBUG << "MainWindow::importPitchLayer: Have model" << endl;
|
Chris@174
|
1816
|
Chris@174
|
1817 CommandHistory::getInstance()->startCompoundOperation
|
Chris@174
|
1818 (tr("Import Pitch Track"), true);
|
Chris@174
|
1819
|
Chris@174
|
1820 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@174
|
1821
|
Chris@174
|
1822 m_analyser->takePitchTrackFrom(newLayer);
|
Chris@174
|
1823
|
Chris@174
|
1824 m_document->deleteLayer(newLayer);
|
Chris@174
|
1825
|
Chris@174
|
1826 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@174
|
1827
|
Chris@174
|
1828 //!!! swap all data in to existing layer instead of this
|
Chris@174
|
1829
|
Chris@174
|
1830 if (!source.isRemote()) {
|
Chris@174
|
1831 registerLastOpenedFilePath
|
Chris@174
|
1832 (FileFinder::LayerFile,
|
Chris@174
|
1833 path); // for file dialog
|
Chris@174
|
1834 }
|
Chris@174
|
1835
|
Chris@174
|
1836 return FileOpenSucceeded;
|
Chris@174
|
1837 }
|
Chris@174
|
1838 } catch (DataFileReaderFactory::Exception e) {
|
Chris@174
|
1839 if (e == DataFileReaderFactory::ImportCancelled) {
|
Chris@174
|
1840 return FileOpenCancelled;
|
Chris@174
|
1841 }
|
Chris@174
|
1842 }
|
Chris@174
|
1843 }
|
Chris@174
|
1844
|
Chris@174
|
1845 return FileOpenFailed;
|
Chris@174
|
1846 }
|
Chris@174
|
1847
|
Chris@174
|
1848 void
|
Chris@85
|
1849 MainWindow::exportPitchLayer()
|
matthiasm@26
|
1850 {
|
Chris@174
|
1851 Layer *layer = m_analyser->getLayer(Analyser::PitchTrack);
|
matthiasm@26
|
1852 if (!layer) return;
|
matthiasm@26
|
1853
|
Chris@85
|
1854 SparseTimeValueModel *model =
|
Chris@85
|
1855 qobject_cast<SparseTimeValueModel *>(layer->getModel());
|
matthiasm@26
|
1856 if (!model) return;
|
matthiasm@26
|
1857
|
Chris@96
|
1858 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
|
matthiasm@26
|
1859
|
matthiasm@26
|
1860 QString path = getSaveFileName(type);
|
matthiasm@26
|
1861
|
matthiasm@26
|
1862 if (path == "") return;
|
matthiasm@26
|
1863
|
matthiasm@26
|
1864 if (QFileInfo(path).suffix() == "") path += ".svl";
|
matthiasm@26
|
1865
|
matthiasm@26
|
1866 QString suffix = QFileInfo(path).suffix().toLower();
|
matthiasm@26
|
1867
|
matthiasm@26
|
1868 QString error;
|
matthiasm@26
|
1869
|
matthiasm@26
|
1870 if (suffix == "xml" || suffix == "svl") {
|
matthiasm@26
|
1871
|
Chris@85
|
1872 error = exportToSVL(path, layer);
|
matthiasm@26
|
1873
|
matthiasm@26
|
1874 } else if (suffix == "ttl" || suffix == "n3") {
|
matthiasm@26
|
1875
|
Chris@85
|
1876 RDFExporter exporter(path, model);
|
Chris@85
|
1877 exporter.write();
|
Chris@85
|
1878 if (!exporter.isOK()) {
|
Chris@85
|
1879 error = exporter.getError();
|
Chris@85
|
1880 }
|
Chris@85
|
1881
|
Chris@85
|
1882 } else {
|
Chris@85
|
1883
|
Chris@85
|
1884 CSVFileWriter writer(path, model,
|
Chris@85
|
1885 ((suffix == "csv") ? "," : "\t"));
|
Chris@85
|
1886 writer.write();
|
Chris@85
|
1887
|
Chris@85
|
1888 if (!writer.isOK()) {
|
Chris@85
|
1889 error = writer.getError();
|
Chris@85
|
1890 }
|
Chris@85
|
1891 }
|
Chris@85
|
1892
|
Chris@85
|
1893 if (error != "") {
|
Chris@85
|
1894 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@85
|
1895 } else {
|
Chris@85
|
1896 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@85
|
1897 }
|
Chris@85
|
1898 }
|
Chris@85
|
1899
|
Chris@85
|
1900 void
|
Chris@85
|
1901 MainWindow::exportNoteLayer()
|
Chris@85
|
1902 {
|
Chris@174
|
1903 Layer *layer = m_analyser->getLayer(Analyser::Notes);
|
Chris@85
|
1904 if (!layer) return;
|
Chris@85
|
1905
|
Chris@85
|
1906 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
Chris@85
|
1907 if (!model) return;
|
Chris@85
|
1908
|
Chris@96
|
1909 FileFinder::FileType type = FileFinder::LayerFileNonSV;
|
Chris@85
|
1910
|
Chris@85
|
1911 QString path = getSaveFileName(type);
|
Chris@85
|
1912
|
Chris@85
|
1913 if (path == "") return;
|
Chris@85
|
1914
|
Chris@85
|
1915 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@85
|
1916
|
Chris@85
|
1917 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@85
|
1918
|
Chris@85
|
1919 QString error;
|
Chris@85
|
1920
|
Chris@85
|
1921 if (suffix == "xml" || suffix == "svl") {
|
Chris@85
|
1922
|
Chris@85
|
1923 error = exportToSVL(path, layer);
|
Chris@85
|
1924
|
Chris@85
|
1925 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@85
|
1926
|
Chris@85
|
1927 MIDIFileWriter writer(path, model, model->getSampleRate());
|
Chris@85
|
1928 writer.write();
|
Chris@85
|
1929 if (!writer.isOK()) {
|
Chris@85
|
1930 error = writer.getError();
|
Chris@85
|
1931 }
|
Chris@85
|
1932
|
Chris@85
|
1933 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@85
|
1934
|
Chris@85
|
1935 RDFExporter exporter(path, model);
|
Chris@85
|
1936 exporter.write();
|
Chris@85
|
1937 if (!exporter.isOK()) {
|
Chris@85
|
1938 error = exporter.getError();
|
matthiasm@26
|
1939 }
|
matthiasm@26
|
1940
|
matthiasm@26
|
1941 } else {
|
matthiasm@26
|
1942
|
matthiasm@26
|
1943 CSVFileWriter writer(path, model,
|
matthiasm@26
|
1944 ((suffix == "csv") ? "," : "\t"));
|
matthiasm@26
|
1945 writer.write();
|
matthiasm@26
|
1946
|
matthiasm@26
|
1947 if (!writer.isOK()) {
|
matthiasm@26
|
1948 error = writer.getError();
|
matthiasm@26
|
1949 }
|
matthiasm@26
|
1950 }
|
matthiasm@26
|
1951
|
matthiasm@26
|
1952 if (error != "") {
|
matthiasm@26
|
1953 QMessageBox::critical(this, tr("Failed to write file"), error);
|
matthiasm@26
|
1954 } else {
|
matthiasm@26
|
1955 emit activity(tr("Export layer to \"%1\"").arg(path));
|
matthiasm@26
|
1956 }
|
matthiasm@26
|
1957 }
|
matthiasm@26
|
1958
|
Chris@139
|
1959 void
|
Chris@139
|
1960 MainWindow::doubleClickSelectInvoked(size_t frame)
|
Chris@139
|
1961 {
|
Chris@139
|
1962 size_t f0, f1;
|
Chris@139
|
1963 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
|
Chris@139
|
1964
|
Chris@139
|
1965 cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl;
|
Chris@139
|
1966
|
Chris@164
|
1967 Selection sel(f0, f1);
|
Chris@164
|
1968 m_viewManager->setSelection(sel);
|
Chris@164
|
1969 }
|
Chris@164
|
1970
|
Chris@164
|
1971 void
|
Chris@194
|
1972 MainWindow::abandonSelection()
|
Chris@167
|
1973 {
|
Chris@194
|
1974 // Named abandonSelection rather than clearSelection to indicate
|
Chris@194
|
1975 // that this is an active operation -- it restores the original
|
Chris@194
|
1976 // content of the pitch track in the selected region rather than
|
Chris@194
|
1977 // simply un-selecting.
|
Chris@194
|
1978
|
Chris@194
|
1979 cerr << "MainWindow::abandonSelection()" << endl;
|
Chris@167
|
1980
|
Chris@199
|
1981 CommandHistory::getInstance()->startCompoundOperation(tr("Abandon Selection"), true);
|
Chris@168
|
1982
|
Chris@194
|
1983 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@194
|
1984 if (!selections.empty()) {
|
Chris@194
|
1985 Selection sel = *selections.begin();
|
Chris@199
|
1986 m_analyser->abandonReAnalysis(sel);
|
Chris@252
|
1987 auxSnapNotes(sel);
|
Chris@194
|
1988 }
|
Chris@194
|
1989
|
Chris@167
|
1990 MainWindowBase::clearSelection();
|
Chris@168
|
1991
|
Chris@168
|
1992 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
1993 }
|
Chris@167
|
1994
|
Chris@167
|
1995 void
|
Chris@192
|
1996 MainWindow::selectionChangedByUser()
|
Chris@164
|
1997 {
|
Chris@221
|
1998 if (!m_document) {
|
Chris@221
|
1999 // we're exiting, most likely
|
Chris@221
|
2000 return;
|
Chris@221
|
2001 }
|
Chris@221
|
2002
|
Chris@164
|
2003 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@164
|
2004
|
Chris@192
|
2005 cerr << "MainWindow::selectionChangedByUser" << endl;
|
Chris@192
|
2006
|
Chris@192
|
2007 m_analyser->showPitchCandidates(m_pendingConstraint.isConstrained());
|
Chris@190
|
2008
|
Chris@164
|
2009 if (!selections.empty()) {
|
Chris@164
|
2010 Selection sel = *selections.begin();
|
Chris@192
|
2011 cerr << "MainWindow::selectionChangedByUser: have selection" << endl;
|
Chris@192
|
2012 QString error = m_analyser->reAnalyseSelection
|
Chris@192
|
2013 (sel, m_pendingConstraint);
|
Chris@164
|
2014 if (error != "") {
|
Chris@164
|
2015 QMessageBox::critical
|
Chris@164
|
2016 (this, tr("Failed to analyse selection"),
|
Chris@164
|
2017 tr("<b>Analysis failed</b><p>%2</p>").arg(error));
|
Chris@164
|
2018 }
|
Chris@164
|
2019 }
|
Chris@192
|
2020
|
Chris@192
|
2021 m_pendingConstraint = Analyser::FrequencyRange();
|
Chris@192
|
2022 }
|
Chris@192
|
2023
|
Chris@192
|
2024 void
|
Chris@192
|
2025 MainWindow::regionOutlined(QRect r)
|
Chris@192
|
2026 {
|
Chris@192
|
2027 cerr << "MainWindow::regionOutlined(" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ")" << endl;
|
Chris@192
|
2028
|
Chris@192
|
2029 Pane *pane = qobject_cast<Pane *>(sender());
|
Chris@192
|
2030 if (!pane) {
|
Chris@192
|
2031 cerr << "MainWindow::regionOutlined: not sent by pane, ignoring" << endl;
|
Chris@192
|
2032 return;
|
Chris@192
|
2033 }
|
Chris@192
|
2034
|
Chris@192
|
2035 if (!m_analyser) {
|
Chris@192
|
2036 cerr << "MainWindow::regionOutlined: no analyser, ignoring" << endl;
|
Chris@192
|
2037 return;
|
Chris@192
|
2038 }
|
Chris@192
|
2039
|
Chris@192
|
2040 SpectrogramLayer *spectrogram = qobject_cast<SpectrogramLayer *>
|
Chris@192
|
2041 (m_analyser->getLayer(Analyser::Spectrogram));
|
Chris@192
|
2042 if (!spectrogram) {
|
Chris@192
|
2043 cerr << "MainWindow::regionOutlined: no spectrogram layer, ignoring" << endl;
|
Chris@192
|
2044 return;
|
Chris@192
|
2045 }
|
Chris@192
|
2046
|
Chris@192
|
2047 int f0 = pane->getFrameForX(r.x());
|
Chris@192
|
2048 int f1 = pane->getFrameForX(r.x() + r.width());
|
Chris@192
|
2049
|
Chris@192
|
2050 float v0 = spectrogram->getFrequencyForY(pane, r.y() + r.height());
|
Chris@192
|
2051 float v1 = spectrogram->getFrequencyForY(pane, r.y());
|
Chris@192
|
2052
|
Chris@192
|
2053 cerr << "MainWindow::regionOutlined: frame " << f0 << " -> " << f1
|
Chris@192
|
2054 << ", frequency " << v0 << " -> " << v1 << endl;
|
Chris@192
|
2055
|
Chris@192
|
2056 m_pendingConstraint = Analyser::FrequencyRange(v0, v1);
|
Chris@192
|
2057
|
Chris@192
|
2058 Selection sel(f0, f1);
|
Chris@192
|
2059 m_viewManager->setSelection(sel);
|
Chris@0
|
2060 }
|
Chris@0
|
2061
|
Chris@0
|
2062 void
|
Chris@168
|
2063 MainWindow::clearPitches()
|
Chris@168
|
2064 {
|
Chris@168
|
2065 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@168
|
2066
|
Chris@168
|
2067 CommandHistory::getInstance()->startCompoundOperation(tr("Clear Pitches"), true);
|
Chris@168
|
2068
|
Chris@168
|
2069 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
2070 k != selections.end(); ++k) {
|
Chris@184
|
2071 m_analyser->deletePitches(*k);
|
Chris@252
|
2072 auxSnapNotes(*k);
|
Chris@168
|
2073 }
|
Chris@168
|
2074
|
Chris@168
|
2075 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@168
|
2076 }
|
Chris@168
|
2077
|
Chris@168
|
2078 void
|
Chris@142
|
2079 MainWindow::octaveShift(bool up)
|
Chris@142
|
2080 {
|
Chris@142
|
2081 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@142
|
2082
|
Chris@211
|
2083 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2084 (up ? tr("Choose Higher Octave") : tr("Choose Lower Octave"), true);
|
Chris@142
|
2085
|
Chris@168
|
2086 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
2087 k != selections.end(); ++k) {
|
Chris@142
|
2088
|
Chris@168
|
2089 m_analyser->shiftOctave(*k, up);
|
Chris@252
|
2090 auxSnapNotes(*k);
|
Chris@142
|
2091 }
|
Chris@142
|
2092
|
Chris@142
|
2093 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@142
|
2094 }
|
Chris@142
|
2095
|
Chris@142
|
2096 void
|
Chris@184
|
2097 MainWindow::togglePitchCandidates()
|
Chris@184
|
2098 {
|
Chris@199
|
2099 CommandHistory::getInstance()->startCompoundOperation(tr("Toggle Pitch Candidates"), true);
|
Chris@199
|
2100
|
Chris@184
|
2101 m_analyser->showPitchCandidates(!m_analyser->arePitchCandidatesShown());
|
Chris@199
|
2102
|
Chris@199
|
2103 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@199
|
2104
|
Chris@187
|
2105 updateMenuStates();
|
Chris@184
|
2106 }
|
Chris@184
|
2107
|
Chris@184
|
2108 void
|
Chris@184
|
2109 MainWindow::switchPitchUp()
|
Chris@167
|
2110 {
|
Chris@211
|
2111 if (m_analyser->arePitchCandidatesShown()) {
|
Chris@211
|
2112 if (m_analyser->haveHigherPitchCandidate()) {
|
Chris@211
|
2113
|
Chris@211
|
2114 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2115 (tr("Choose Higher Pitch Candidate"), true);
|
Chris@211
|
2116
|
Chris@211
|
2117 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@211
|
2118
|
Chris@211
|
2119 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@211
|
2120 k != selections.end(); ++k) {
|
Chris@211
|
2121 m_analyser->switchPitchCandidate(*k, true);
|
Chris@252
|
2122 auxSnapNotes(*k);
|
Chris@211
|
2123 }
|
Chris@211
|
2124
|
Chris@211
|
2125 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@211
|
2126 }
|
Chris@211
|
2127 } else {
|
Chris@211
|
2128 octaveShift(true);
|
Chris@167
|
2129 }
|
Chris@167
|
2130 }
|
Chris@167
|
2131
|
Chris@167
|
2132 void
|
Chris@184
|
2133 MainWindow::switchPitchDown()
|
Chris@184
|
2134 {
|
Chris@211
|
2135 if (m_analyser->arePitchCandidatesShown()) {
|
Chris@211
|
2136 if (m_analyser->haveLowerPitchCandidate()) {
|
Chris@211
|
2137
|
Chris@211
|
2138 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2139 (tr("Choose Lower Pitch Candidate"), true);
|
Chris@211
|
2140
|
Chris@211
|
2141 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@211
|
2142
|
Chris@211
|
2143 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@211
|
2144 k != selections.end(); ++k) {
|
Chris@211
|
2145 m_analyser->switchPitchCandidate(*k, false);
|
Chris@252
|
2146 auxSnapNotes(*k);
|
Chris@211
|
2147 }
|
Chris@211
|
2148
|
Chris@211
|
2149 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@211
|
2150 }
|
Chris@211
|
2151 } else {
|
Chris@211
|
2152 octaveShift(false);
|
Chris@184
|
2153 }
|
Chris@184
|
2154 }
|
Chris@184
|
2155
|
Chris@184
|
2156 void
|
Chris@237
|
2157 MainWindow::snapNotesToPitches()
|
Chris@237
|
2158 {
|
Chris@237
|
2159 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@237
|
2160
|
Chris@237
|
2161 if (!selections.empty()) {
|
Chris@237
|
2162
|
Chris@237
|
2163 CommandHistory::getInstance()->startCompoundOperation
|
Chris@237
|
2164 (tr("Snap Notes to Pitches"), true);
|
Chris@237
|
2165
|
Chris@237
|
2166 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@237
|
2167 k != selections.end(); ++k) {
|
Chris@239
|
2168 auxSnapNotes(*k);
|
Chris@237
|
2169 }
|
Chris@237
|
2170
|
Chris@237
|
2171 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@237
|
2172 }
|
Chris@237
|
2173 }
|
Chris@237
|
2174
|
Chris@237
|
2175 void
|
Chris@239
|
2176 MainWindow::auxSnapNotes(Selection s)
|
Chris@239
|
2177 {
|
Chris@239
|
2178 FlexiNoteLayer *layer =
|
Chris@239
|
2179 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@239
|
2180 if (!layer) return;
|
Chris@239
|
2181
|
Chris@239
|
2182 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), s);
|
Chris@239
|
2183 }
|
Chris@239
|
2184
|
Chris@239
|
2185 void
|
Chris@240
|
2186 MainWindow::splitNote()
|
Chris@237
|
2187 {
|
Chris@237
|
2188 FlexiNoteLayer *layer =
|
Chris@237
|
2189 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@237
|
2190 if (!layer) return;
|
Chris@237
|
2191
|
Chris@240
|
2192 layer->splitNotesAt(m_analyser->getPane(), m_viewManager->getPlaybackFrame());
|
Chris@237
|
2193 }
|
Chris@237
|
2194
|
Chris@237
|
2195 void
|
Chris@238
|
2196 MainWindow::mergeNotes()
|
Chris@238
|
2197 {
|
Chris@238
|
2198 FlexiNoteLayer *layer =
|
Chris@238
|
2199 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@238
|
2200 if (!layer) return;
|
Chris@238
|
2201
|
Chris@238
|
2202 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@238
|
2203
|
Chris@238
|
2204 if (!selections.empty()) {
|
Chris@238
|
2205
|
Chris@238
|
2206 CommandHistory::getInstance()->startCompoundOperation
|
Chris@238
|
2207 (tr("Merge Notes"), true);
|
Chris@238
|
2208
|
Chris@238
|
2209 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@238
|
2210 k != selections.end(); ++k) {
|
Chris@240
|
2211 layer->mergeNotes(m_analyser->getPane(), *k, true);
|
Chris@238
|
2212 }
|
Chris@238
|
2213
|
Chris@238
|
2214 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@238
|
2215 }
|
Chris@238
|
2216 }
|
Chris@238
|
2217
|
Chris@238
|
2218 void
|
Chris@240
|
2219 MainWindow::formNoteFromSelection()
|
Chris@240
|
2220 {
|
Chris@240
|
2221 FlexiNoteLayer *layer =
|
Chris@240
|
2222 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@240
|
2223 if (!layer) return;
|
Chris@240
|
2224
|
Chris@240
|
2225 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@240
|
2226
|
Chris@240
|
2227 if (!selections.empty()) {
|
Chris@240
|
2228
|
Chris@240
|
2229 CommandHistory::getInstance()->startCompoundOperation
|
Chris@240
|
2230 (tr("Form Note from Selection"), true);
|
Chris@240
|
2231
|
Chris@240
|
2232 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@240
|
2233 k != selections.end(); ++k) {
|
Chris@240
|
2234 layer->splitNotesAt(m_analyser->getPane(), k->getStartFrame());
|
Chris@240
|
2235 layer->splitNotesAt(m_analyser->getPane(), k->getEndFrame());
|
Chris@240
|
2236 layer->mergeNotes(m_analyser->getPane(), *k, false);
|
Chris@240
|
2237 }
|
Chris@240
|
2238
|
Chris@240
|
2239 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@240
|
2240 }
|
Chris@240
|
2241 }
|
Chris@240
|
2242
|
Chris@240
|
2243 void
|
Chris@0
|
2244 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
2245 {
|
Chris@0
|
2246 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@0
|
2247
|
Chris@0
|
2248 float percent = m_playSpeed->mappedValue();
|
Chris@0
|
2249 float factor = mapper.getFactorForValue(percent);
|
Chris@0
|
2250
|
Chris@70
|
2251 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
|
Chris@0
|
2252
|
Chris@0
|
2253 bool something = (position != 100);
|
Chris@0
|
2254
|
Chris@0
|
2255 int pc = lrintf(percent);
|
Chris@0
|
2256
|
Chris@0
|
2257 if (!something) {
|
Chris@0
|
2258 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@0
|
2259 } else {
|
Chris@0
|
2260 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@0
|
2261 .arg(position > 100 ? "+" : "")
|
Chris@0
|
2262 .arg(pc));
|
Chris@0
|
2263 }
|
Chris@0
|
2264
|
Chris@0
|
2265 m_playSource->setTimeStretch(factor);
|
Chris@0
|
2266
|
Chris@0
|
2267 updateMenuStates();
|
Chris@0
|
2268 }
|
Chris@0
|
2269
|
Chris@0
|
2270 void
|
Chris@0
|
2271 MainWindow::playSharpenToggled()
|
Chris@0
|
2272 {
|
Chris@0
|
2273 QSettings settings;
|
Chris@0
|
2274 settings.beginGroup("MainWindow");
|
Chris@0
|
2275 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@0
|
2276 settings.endGroup();
|
Chris@0
|
2277
|
Chris@0
|
2278 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
2279 // TODO: pitch gain?
|
Chris@0
|
2280 }
|
Chris@0
|
2281
|
Chris@0
|
2282 void
|
Chris@0
|
2283 MainWindow::playMonoToggled()
|
Chris@0
|
2284 {
|
Chris@0
|
2285 QSettings settings;
|
Chris@0
|
2286 settings.beginGroup("MainWindow");
|
Chris@0
|
2287 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@0
|
2288 settings.endGroup();
|
Chris@0
|
2289
|
Chris@0
|
2290 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
2291 // TODO: pitch gain?
|
Chris@0
|
2292 }
|
Chris@0
|
2293
|
Chris@0
|
2294 void
|
Chris@0
|
2295 MainWindow::speedUpPlayback()
|
Chris@0
|
2296 {
|
Chris@0
|
2297 int value = m_playSpeed->value();
|
Chris@0
|
2298 value = value + m_playSpeed->pageStep();
|
Chris@0
|
2299 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@0
|
2300 m_playSpeed->setValue(value);
|
Chris@0
|
2301 }
|
Chris@0
|
2302
|
Chris@0
|
2303 void
|
Chris@0
|
2304 MainWindow::slowDownPlayback()
|
Chris@0
|
2305 {
|
Chris@0
|
2306 int value = m_playSpeed->value();
|
Chris@0
|
2307 value = value - m_playSpeed->pageStep();
|
Chris@0
|
2308 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@0
|
2309 m_playSpeed->setValue(value);
|
Chris@0
|
2310 }
|
Chris@0
|
2311
|
Chris@0
|
2312 void
|
Chris@0
|
2313 MainWindow::restoreNormalPlayback()
|
Chris@0
|
2314 {
|
Chris@0
|
2315 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@0
|
2316 }
|
Chris@0
|
2317
|
justin@157
|
2318 void
|
justin@159
|
2319 MainWindow::audioGainChanged(int position)
|
justin@159
|
2320 {
|
justin@159
|
2321 float level = m_gainAudio->mappedValue();
|
justin@159
|
2322 float gain = powf(10, level / 20.0);
|
justin@159
|
2323
|
justin@159
|
2324 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
2325
|
justin@159
|
2326 contextHelpChanged(tr("Audio Gain: %1 dB").arg(position));
|
justin@159
|
2327
|
justin@159
|
2328 m_analyser->setGain(Analyser::Audio, gain);
|
justin@159
|
2329
|
justin@159
|
2330 updateMenuStates();
|
justin@159
|
2331 }
|
justin@159
|
2332
|
justin@159
|
2333 void
|
justin@159
|
2334 MainWindow::increaseAudioGain()
|
justin@159
|
2335 {
|
justin@159
|
2336 int value = m_gainAudio->value();
|
justin@159
|
2337 value = value + m_gainAudio->pageStep();
|
justin@159
|
2338 if (value > m_gainAudio->maximum()) value = m_gainAudio->maximum();
|
justin@159
|
2339 m_gainAudio->setValue(value);
|
justin@159
|
2340 }
|
justin@159
|
2341
|
justin@159
|
2342 void
|
justin@159
|
2343 MainWindow::decreaseAudioGain()
|
justin@159
|
2344 {
|
justin@159
|
2345 int value = m_gainAudio->value();
|
justin@159
|
2346 value = value - m_gainAudio->pageStep();
|
justin@159
|
2347 if (value < m_gainAudio->minimum()) value = m_gainAudio->minimum();
|
justin@159
|
2348 m_gainAudio->setValue(value);
|
justin@159
|
2349 }
|
justin@159
|
2350
|
justin@159
|
2351 void
|
justin@159
|
2352 MainWindow::restoreNormalAudioGain()
|
justin@159
|
2353 {
|
justin@159
|
2354 m_gainAudio->setValue(m_gainAudio->defaultValue());
|
justin@159
|
2355 }
|
justin@159
|
2356
|
justin@159
|
2357 void
|
justin@157
|
2358 MainWindow::pitchGainChanged(int position)
|
justin@157
|
2359 {
|
Chris@158
|
2360 float level = m_gainPitch->mappedValue();
|
Chris@158
|
2361 float gain = powf(10, level / 20.0);
|
justin@157
|
2362
|
Chris@158
|
2363 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@157
|
2364
|
Chris@158
|
2365 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position));
|
justin@157
|
2366
|
Chris@158
|
2367 m_analyser->setGain(Analyser::PitchTrack, gain);
|
justin@157
|
2368
|
justin@157
|
2369 updateMenuStates();
|
justin@157
|
2370 }
|
justin@157
|
2371
|
justin@157
|
2372 void
|
justin@157
|
2373 MainWindow::increasePitchGain()
|
justin@157
|
2374 {
|
justin@157
|
2375 int value = m_gainPitch->value();
|
justin@157
|
2376 value = value + m_gainPitch->pageStep();
|
justin@157
|
2377 if (value > m_gainPitch->maximum()) value = m_gainPitch->maximum();
|
justin@157
|
2378 m_gainPitch->setValue(value);
|
justin@157
|
2379 }
|
justin@157
|
2380
|
justin@157
|
2381 void
|
justin@157
|
2382 MainWindow::decreasePitchGain()
|
justin@157
|
2383 {
|
justin@157
|
2384 int value = m_gainPitch->value();
|
justin@157
|
2385 value = value - m_gainPitch->pageStep();
|
justin@157
|
2386 if (value < m_gainPitch->minimum()) value = m_gainPitch->minimum();
|
justin@157
|
2387 m_gainPitch->setValue(value);
|
justin@157
|
2388 }
|
justin@157
|
2389
|
justin@157
|
2390 void
|
justin@157
|
2391 MainWindow::restoreNormalPitchGain()
|
justin@157
|
2392 {
|
justin@157
|
2393 m_gainPitch->setValue(m_gainPitch->defaultValue());
|
justin@157
|
2394 }
|
justin@157
|
2395
|
Chris@0
|
2396 void
|
justin@159
|
2397 MainWindow::notesGainChanged(int position)
|
justin@159
|
2398 {
|
justin@159
|
2399 float level = m_gainNotes->mappedValue();
|
justin@159
|
2400 float gain = powf(10, level / 20.0);
|
justin@159
|
2401
|
justin@159
|
2402 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
|
justin@159
|
2403
|
justin@159
|
2404 contextHelpChanged(tr("Notes Gain: %1 dB").arg(position));
|
justin@159
|
2405
|
justin@159
|
2406 m_analyser->setGain(Analyser::Notes, gain);
|
justin@159
|
2407
|
justin@159
|
2408 updateMenuStates();
|
justin@159
|
2409 }
|
justin@159
|
2410
|
justin@159
|
2411 void
|
justin@159
|
2412 MainWindow::increaseNotesGain()
|
justin@159
|
2413 {
|
justin@159
|
2414 int value = m_gainNotes->value();
|
justin@159
|
2415 value = value + m_gainNotes->pageStep();
|
justin@159
|
2416 if (value > m_gainNotes->maximum()) value = m_gainNotes->maximum();
|
justin@159
|
2417 m_gainNotes->setValue(value);
|
justin@159
|
2418 }
|
justin@159
|
2419
|
justin@159
|
2420 void
|
justin@159
|
2421 MainWindow::decreaseNotesGain()
|
justin@159
|
2422 {
|
justin@159
|
2423 int value = m_gainNotes->value();
|
justin@159
|
2424 value = value - m_gainNotes->pageStep();
|
justin@159
|
2425 if (value < m_gainNotes->minimum()) value = m_gainNotes->minimum();
|
justin@159
|
2426 m_gainNotes->setValue(value);
|
justin@159
|
2427 }
|
justin@159
|
2428
|
justin@159
|
2429 void
|
justin@159
|
2430 MainWindow::restoreNormalNotesGain()
|
justin@159
|
2431 {
|
justin@159
|
2432 m_gainNotes->setValue(m_gainNotes->defaultValue());
|
justin@159
|
2433 }
|
justin@159
|
2434
|
justin@159
|
2435 void
|
justin@160
|
2436 MainWindow::audioPanChanged(int position)
|
justin@160
|
2437 {
|
justin@160
|
2438 float level = m_panAudio->mappedValue();
|
justin@160
|
2439 float pan = level/100.f;
|
justin@160
|
2440
|
justin@160
|
2441 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2442
|
justin@160
|
2443 contextHelpChanged(tr("Audio Pan: %1").arg(position));
|
justin@160
|
2444
|
justin@160
|
2445 m_analyser->setPan(Analyser::Audio, pan);
|
justin@160
|
2446
|
justin@160
|
2447 updateMenuStates();
|
justin@160
|
2448 }
|
justin@160
|
2449
|
justin@160
|
2450 void
|
justin@160
|
2451 MainWindow::increaseAudioPan()
|
justin@160
|
2452 {
|
justin@160
|
2453 int value = m_panAudio->value();
|
justin@160
|
2454 value = value + m_panAudio->pageStep();
|
justin@160
|
2455 if (value > m_panAudio->maximum()) value = m_panAudio->maximum();
|
justin@160
|
2456 m_panAudio->setValue(value);
|
justin@160
|
2457 }
|
justin@160
|
2458
|
justin@160
|
2459 void
|
justin@160
|
2460 MainWindow::decreaseAudioPan()
|
justin@160
|
2461 {
|
justin@160
|
2462 int value = m_panAudio->value();
|
justin@160
|
2463 value = value - m_panAudio->pageStep();
|
justin@160
|
2464 if (value < m_panAudio->minimum()) value = m_panAudio->minimum();
|
justin@160
|
2465 m_panAudio->setValue(value);
|
justin@160
|
2466 }
|
justin@160
|
2467
|
justin@160
|
2468 void
|
justin@160
|
2469 MainWindow::restoreNormalAudioPan()
|
justin@160
|
2470 {
|
justin@160
|
2471 m_panAudio->setValue(m_panAudio->defaultValue());
|
justin@160
|
2472 }
|
justin@160
|
2473
|
justin@160
|
2474 void
|
justin@160
|
2475 MainWindow::pitchPanChanged(int position)
|
justin@160
|
2476 {
|
justin@160
|
2477 float level = m_panPitch->mappedValue();
|
justin@160
|
2478 float pan = level/100.f;
|
justin@160
|
2479
|
justin@160
|
2480 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2481
|
justin@160
|
2482 contextHelpChanged(tr("Pitch Pan: %1").arg(position));
|
justin@160
|
2483
|
justin@160
|
2484 m_analyser->setPan(Analyser::PitchTrack, pan);
|
justin@160
|
2485
|
justin@160
|
2486 updateMenuStates();
|
justin@160
|
2487 }
|
justin@160
|
2488
|
justin@160
|
2489 void
|
justin@160
|
2490 MainWindow::increasePitchPan()
|
justin@160
|
2491 {
|
justin@160
|
2492 int value = m_panPitch->value();
|
justin@160
|
2493 value = value + m_panPitch->pageStep();
|
justin@160
|
2494 if (value > m_panPitch->maximum()) value = m_panPitch->maximum();
|
justin@160
|
2495 m_panPitch->setValue(value);
|
justin@160
|
2496 }
|
justin@160
|
2497
|
justin@160
|
2498 void
|
justin@160
|
2499 MainWindow::decreasePitchPan()
|
justin@160
|
2500 {
|
justin@160
|
2501 int value = m_panPitch->value();
|
justin@160
|
2502 value = value - m_panPitch->pageStep();
|
justin@160
|
2503 if (value < m_panPitch->minimum()) value = m_panPitch->minimum();
|
justin@160
|
2504 m_panPitch->setValue(value);
|
justin@160
|
2505 }
|
justin@160
|
2506
|
justin@160
|
2507 void
|
justin@160
|
2508 MainWindow::restoreNormalPitchPan()
|
justin@160
|
2509 {
|
justin@160
|
2510 m_panPitch->setValue(m_panPitch->defaultValue());
|
justin@160
|
2511 }
|
justin@160
|
2512
|
justin@160
|
2513 void
|
justin@160
|
2514 MainWindow::notesPanChanged(int position)
|
justin@160
|
2515 {
|
justin@160
|
2516 float level = m_panNotes->mappedValue();
|
justin@160
|
2517 float pan = level/100.f;
|
justin@160
|
2518
|
justin@160
|
2519 cerr << "pan = " << pan << " (" << position << ")" << endl;
|
justin@160
|
2520
|
justin@160
|
2521 contextHelpChanged(tr("Notes Pan: %1").arg(position));
|
justin@160
|
2522
|
justin@160
|
2523 m_analyser->setPan(Analyser::Notes, pan);
|
justin@160
|
2524
|
justin@160
|
2525 updateMenuStates();
|
justin@160
|
2526 }
|
justin@160
|
2527
|
justin@160
|
2528 void
|
justin@160
|
2529 MainWindow::increaseNotesPan()
|
justin@160
|
2530 {
|
justin@160
|
2531 int value = m_panNotes->value();
|
justin@160
|
2532 value = value + m_panNotes->pageStep();
|
justin@160
|
2533 if (value > m_panNotes->maximum()) value = m_panNotes->maximum();
|
justin@160
|
2534 m_panNotes->setValue(value);
|
justin@160
|
2535 }
|
justin@160
|
2536
|
justin@160
|
2537 void
|
justin@160
|
2538 MainWindow::decreaseNotesPan()
|
justin@160
|
2539 {
|
justin@160
|
2540 int value = m_panNotes->value();
|
justin@160
|
2541 value = value - m_panNotes->pageStep();
|
justin@160
|
2542 if (value < m_panNotes->minimum()) value = m_panNotes->minimum();
|
justin@160
|
2543 m_panNotes->setValue(value);
|
justin@160
|
2544 }
|
justin@160
|
2545
|
justin@160
|
2546 void
|
justin@160
|
2547 MainWindow::restoreNormalNotesPan()
|
justin@160
|
2548 {
|
justin@160
|
2549 m_panNotes->setValue(m_panNotes->defaultValue());
|
justin@160
|
2550 }
|
justin@160
|
2551
|
justin@160
|
2552 void
|
Chris@0
|
2553 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@0
|
2554 {
|
Chris@0
|
2555 if (!getMainModel() || !p) {
|
Chris@0
|
2556 return;
|
Chris@0
|
2557 }
|
Chris@0
|
2558
|
Chris@0
|
2559 bool haveSelection = false;
|
Chris@0
|
2560 size_t startFrame = 0, endFrame = 0;
|
Chris@0
|
2561
|
Chris@0
|
2562 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@0
|
2563
|
Chris@0
|
2564 bool exclusive = false;
|
Chris@0
|
2565 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@0
|
2566
|
Chris@0
|
2567 if (!s.isEmpty()) {
|
Chris@0
|
2568 haveSelection = true;
|
Chris@0
|
2569 startFrame = s.getStartFrame();
|
Chris@0
|
2570 endFrame = s.getEndFrame();
|
Chris@0
|
2571 }
|
Chris@0
|
2572 }
|
Chris@0
|
2573
|
Chris@0
|
2574 if (!haveSelection) {
|
Chris@0
|
2575 startFrame = p->getFirstVisibleFrame();
|
Chris@0
|
2576 endFrame = p->getLastVisibleFrame();
|
Chris@0
|
2577 }
|
Chris@0
|
2578
|
Chris@0
|
2579 RealTime start = RealTime::frame2RealTime
|
Chris@0
|
2580 (startFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2581
|
Chris@0
|
2582 RealTime end = RealTime::frame2RealTime
|
Chris@0
|
2583 (endFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2584
|
Chris@0
|
2585 RealTime duration = end - start;
|
Chris@0
|
2586
|
Chris@0
|
2587 QString startStr, endStr, durationStr;
|
Chris@0
|
2588 startStr = start.toText(true).c_str();
|
Chris@0
|
2589 endStr = end.toText(true).c_str();
|
Chris@0
|
2590 durationStr = duration.toText(true).c_str();
|
Chris@0
|
2591
|
Chris@0
|
2592 if (haveSelection) {
|
Chris@0
|
2593 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@0
|
2594 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2595 } else {
|
Chris@0
|
2596 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@0
|
2597 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2598 }
|
matthiasm@42
|
2599
|
matthiasm@42
|
2600 // scale Y axis
|
matthiasm@42
|
2601 FlexiNoteLayer *fnl = dynamic_cast<FlexiNoteLayer *>(p->getLayer(2));
|
matthiasm@42
|
2602 if (fnl) {
|
matthiasm@42
|
2603 fnl->setVerticalRangeToNoteRange(p);
|
matthiasm@42
|
2604 }
|
matthiasm@42
|
2605
|
Chris@0
|
2606 statusBar()->showMessage(m_myStatusMessage);
|
Chris@0
|
2607 }
|
Chris@0
|
2608
|
Chris@0
|
2609 void
|
Chris@0
|
2610 MainWindow::updatePositionStatusDisplays() const
|
Chris@0
|
2611 {
|
Chris@0
|
2612 if (!statusBar()->isVisible()) return;
|
Chris@0
|
2613
|
Chris@0
|
2614 }
|
Chris@0
|
2615
|
Chris@0
|
2616 void
|
Chris@0
|
2617 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
2618 {
|
Chris@0
|
2619 m_fader->setPeakLeft(left);
|
Chris@0
|
2620 m_fader->setPeakRight(right);
|
Chris@0
|
2621 }
|
Chris@0
|
2622
|
Chris@0
|
2623 void
|
Chris@0
|
2624 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
|
Chris@0
|
2625 bool willResample)
|
Chris@0
|
2626 {
|
Chris@0
|
2627 updateDescriptionLabel();
|
Chris@0
|
2628 }
|
Chris@0
|
2629
|
Chris@0
|
2630 void
|
Chris@0
|
2631 MainWindow::audioOverloadPluginDisabled()
|
Chris@0
|
2632 {
|
Chris@0
|
2633 QMessageBox::information
|
Chris@0
|
2634 (this, tr("Audio processing overload"),
|
Chris@0
|
2635 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@0
|
2636 }
|
Chris@0
|
2637
|
Chris@0
|
2638 void
|
Chris@0
|
2639 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@0
|
2640 {
|
Chris@0
|
2641 static bool shownOnce = false;
|
Chris@0
|
2642 if (shownOnce) return;
|
Chris@0
|
2643 QMessageBox::information
|
Chris@0
|
2644 (this, tr("Audio processing overload"),
|
Chris@0
|
2645 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@0
|
2646 shownOnce = true;
|
Chris@0
|
2647 }
|
Chris@0
|
2648
|
Chris@0
|
2649 void
|
Chris@0
|
2650 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
2651 {
|
Chris@0
|
2652 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
2653 }
|
Chris@0
|
2654
|
Chris@0
|
2655 void
|
Chris@0
|
2656 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
2657 {
|
Chris@0
|
2658 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
2659 }
|
Chris@0
|
2660
|
Chris@0
|
2661 void
|
Chris@0
|
2662 MainWindow::modelAdded(Model *model)
|
Chris@0
|
2663 {
|
Chris@0
|
2664 MainWindowBase::modelAdded(model);
|
Chris@3
|
2665 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
|
Chris@0
|
2666 if (dtvm) {
|
Chris@70
|
2667 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
|
Chris@0
|
2668 }
|
Chris@0
|
2669 }
|
Chris@0
|
2670
|
Chris@0
|
2671 void
|
Chris@0
|
2672 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
2673 {
|
Chris@0
|
2674 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@0
|
2675 }
|
Chris@0
|
2676
|
Chris@0
|
2677 void
|
Chris@0
|
2678 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
2679 {
|
Chris@0
|
2680 m_panLayer->setModel(model);
|
Chris@0
|
2681
|
Chris@0
|
2682 MainWindowBase::mainModelChanged(model);
|
Chris@0
|
2683
|
Chris@0
|
2684 if (m_playTarget) {
|
Chris@0
|
2685 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2686 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2687 }
|
Chris@259
|
2688
|
Chris@259
|
2689 analyseNewMainModel();
|
Chris@259
|
2690 }
|
Chris@259
|
2691
|
Chris@259
|
2692 void
|
Chris@259
|
2693 MainWindow::analyseNewMainModel()
|
Chris@259
|
2694 {
|
Chris@259
|
2695 WaveFileModel *model = getMainModel();
|
Chris@259
|
2696
|
Chris@72
|
2697 if (model) {
|
Chris@72
|
2698 if (m_paneStack) {
|
Chris@174
|
2699
|
Chris@174
|
2700 int pc = m_paneStack->getPaneCount();
|
Chris@174
|
2701 Pane *pane = 0;
|
Chris@174
|
2702
|
Chris@174
|
2703 if (pc < 1) {
|
Chris@72
|
2704 pane = m_paneStack->addPane();
|
Chris@131
|
2705
|
Chris@131
|
2706 Pane *selectionStrip = m_paneStack->addPane();
|
Chris@131
|
2707 selectionStrip->setFixedHeight(26);
|
Chris@131
|
2708 m_document->addLayerToView
|
Chris@131
|
2709 (selectionStrip,
|
Chris@131
|
2710 m_document->createMainModelLayer(LayerFactory::TimeRuler));
|
Chris@131
|
2711 m_paneStack->sizePanesEqually();
|
Chris@131
|
2712
|
Chris@131
|
2713 m_viewManager->clearToolModeOverrides();
|
Chris@131
|
2714 m_viewManager->setToolModeFor(selectionStrip,
|
Chris@131
|
2715 ViewManager::SelectMode);
|
Chris@174
|
2716 } else {
|
Chris@174
|
2717 pane = m_paneStack->getPane(0);
|
Chris@72
|
2718 }
|
Chris@174
|
2719
|
Chris@72
|
2720 if (pane) {
|
Chris@192
|
2721
|
Chris@192
|
2722 disconnect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@192
|
2723 pane, SLOT(zoomToRegion(QRect)));
|
Chris@192
|
2724 connect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@192
|
2725 this, SLOT(regionOutlined(QRect)));
|
Chris@192
|
2726
|
Chris@140
|
2727 QString error = m_analyser->newFileLoaded
|
Chris@72
|
2728 (m_document, getMainModel(), m_paneStack, pane);
|
Chris@140
|
2729 if (error != "") {
|
Chris@140
|
2730 QMessageBox::warning
|
Chris@140
|
2731 (this,
|
Chris@140
|
2732 tr("Failed to analyse audio"),
|
Chris@140
|
2733 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
|
Chris@140
|
2734 QMessageBox::Ok);
|
Chris@140
|
2735 }
|
Chris@72
|
2736 }
|
Chris@72
|
2737 }
|
Chris@72
|
2738 }
|
Chris@0
|
2739 }
|
Chris@0
|
2740
|
Chris@0
|
2741 void
|
Chris@0
|
2742 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@0
|
2743 {
|
Chris@0
|
2744 if (message != "") {
|
Chris@0
|
2745
|
Chris@0
|
2746 QMessageBox::warning
|
Chris@0
|
2747 (this,
|
Chris@0
|
2748 tr("Failed to generate layer"),
|
Chris@0
|
2749 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@0
|
2750 .arg(transformName).arg(message),
|
Chris@0
|
2751 QMessageBox::Ok);
|
Chris@0
|
2752 } else {
|
Chris@0
|
2753 QMessageBox::warning
|
Chris@0
|
2754 (this,
|
Chris@0
|
2755 tr("Failed to generate layer"),
|
Chris@0
|
2756 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@0
|
2757 .arg(transformName),
|
Chris@0
|
2758 QMessageBox::Ok);
|
Chris@0
|
2759 }
|
Chris@0
|
2760 }
|
Chris@0
|
2761
|
Chris@0
|
2762 void
|
Chris@0
|
2763 MainWindow::modelGenerationWarning(QString transformName, QString message)
|
Chris@0
|
2764 {
|
Chris@0
|
2765 QMessageBox::warning
|
Chris@0
|
2766 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@0
|
2767 }
|
Chris@0
|
2768
|
Chris@0
|
2769 void
|
Chris@0
|
2770 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@0
|
2771 QString transformName, QString message)
|
Chris@0
|
2772 {
|
Chris@0
|
2773 if (message != "") {
|
Chris@0
|
2774
|
Chris@0
|
2775 QMessageBox::warning
|
Chris@0
|
2776 (this,
|
Chris@0
|
2777 tr("Failed to regenerate layer"),
|
Chris@0
|
2778 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@0
|
2779 .arg(layerName).arg(transformName).arg(message),
|
Chris@0
|
2780 QMessageBox::Ok);
|
Chris@0
|
2781 } else {
|
Chris@0
|
2782 QMessageBox::warning
|
Chris@0
|
2783 (this,
|
Chris@0
|
2784 tr("Failed to regenerate layer"),
|
Chris@0
|
2785 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@0
|
2786 .arg(layerName).arg(transformName),
|
Chris@0
|
2787 QMessageBox::Ok);
|
Chris@0
|
2788 }
|
Chris@0
|
2789 }
|
Chris@0
|
2790
|
Chris@0
|
2791 void
|
Chris@0
|
2792 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@0
|
2793 QString transformName, QString message)
|
Chris@0
|
2794 {
|
Chris@0
|
2795 QMessageBox::warning
|
Chris@0
|
2796 (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@0
|
2797 }
|
Chris@0
|
2798
|
Chris@0
|
2799 void
|
Chris@0
|
2800 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
2801 {
|
Chris@0
|
2802 QMessageBox::warning
|
Chris@0
|
2803 (this,
|
Chris@0
|
2804 tr("Failed to calculate alignment"),
|
Chris@0
|
2805 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@0
|
2806 .arg(transformName).arg(message),
|
Chris@0
|
2807 QMessageBox::Ok);
|
Chris@0
|
2808 }
|
Chris@0
|
2809
|
Chris@0
|
2810 void
|
Chris@0
|
2811 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
2812 {
|
Chris@70
|
2813 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
2814 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
2815 m_rightButtonMenu->popup(position);
|
Chris@0
|
2816 }
|
Chris@0
|
2817
|
Chris@0
|
2818 void
|
Chris@0
|
2819 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@0
|
2820 {
|
Chris@70
|
2821 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
|
Chris@0
|
2822 }
|
Chris@0
|
2823
|
Chris@0
|
2824 void
|
Chris@0
|
2825 MainWindow::mouseEnteredWidget()
|
Chris@0
|
2826 {
|
Chris@3
|
2827 QWidget *w = qobject_cast<QWidget *>(sender());
|
Chris@0
|
2828 if (!w) return;
|
Chris@0
|
2829
|
Chris@0
|
2830 if (w == m_fader) {
|
Chris@0
|
2831 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@0
|
2832 } else if (w == m_playSpeed) {
|
Chris@0
|
2833 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@0
|
2834 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@0
|
2835 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@0
|
2836 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@0
|
2837 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
|
Chris@0
|
2838 }
|
Chris@0
|
2839 }
|
Chris@0
|
2840
|
Chris@0
|
2841 void
|
Chris@0
|
2842 MainWindow::mouseLeftWidget()
|
Chris@0
|
2843 {
|
Chris@0
|
2844 contextHelpChanged("");
|
Chris@0
|
2845 }
|
Chris@0
|
2846
|
Chris@0
|
2847 void
|
Chris@0
|
2848 MainWindow::website()
|
Chris@0
|
2849 {
|
Chris@4
|
2850 //!!! todo: URL!
|
Chris@4
|
2851 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2852 }
|
Chris@0
|
2853
|
Chris@0
|
2854 void
|
Chris@0
|
2855 MainWindow::help()
|
Chris@0
|
2856 {
|
Chris@4
|
2857 //!!! todo: help URL!
|
Chris@4
|
2858 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
2859 }
|
Chris@0
|
2860
|
Chris@0
|
2861 void
|
Chris@0
|
2862 MainWindow::about()
|
Chris@0
|
2863 {
|
Chris@0
|
2864 bool debug = false;
|
Chris@0
|
2865 QString version = "(unknown version)";
|
Chris@0
|
2866
|
Chris@0
|
2867 #ifdef BUILD_DEBUG
|
Chris@0
|
2868 debug = true;
|
Chris@0
|
2869 #endif
|
Chris@0
|
2870 version = tr("Release %1").arg(TONY_VERSION);
|
Chris@0
|
2871
|
Chris@0
|
2872 QString aboutText;
|
Chris@0
|
2873
|
Chris@0
|
2874 aboutText += tr("<h3>About Tony</h3>");
|
Chris@0
|
2875 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
|
Chris@0
|
2876 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
2877 .arg(version)
|
Chris@0
|
2878 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@212
|
2879 aboutText += tr("<p>Using Qt framework version %1.</p>")
|
Chris@206
|
2880 .arg(QT_VERSION_STR);
|
Chris@0
|
2881
|
Chris@0
|
2882 aboutText +=
|
Chris@212
|
2883 "<p>Copyright © 2005–2013 Chris Cannam, Queen Mary University of London, and the Tony project authors: Matthias Mauch, George Fazekas, Justin Salamon, and Rachel Bittner.</p>"
|
Chris@212
|
2884 "<p>pYIN analysis plugin written by Matthias Mauch.</p>"
|
Chris@90
|
2885 "<p>This program is free software; you can redistribute it and/or "
|
Chris@90
|
2886 "modify it under the terms of the GNU General Public License as "
|
Chris@90
|
2887 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
2888 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
2889 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
2890
|
Chris@0
|
2891 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
|
Chris@0
|
2892 }
|
Chris@0
|
2893
|
Chris@0
|
2894 void
|
Chris@0
|
2895 MainWindow::keyReference()
|
Chris@0
|
2896 {
|
Chris@0
|
2897 m_keyReference->show();
|
Chris@0
|
2898 }
|
Chris@0
|
2899
|
Chris@231
|
2900 void
|
Chris@231
|
2901 MainWindow::newerVersionAvailable(QString version)
|
Chris@231
|
2902 {
|
Chris@231
|
2903 //!!! nicer URL would be nicer
|
Chris@231
|
2904 QSettings settings;
|
Chris@231
|
2905 settings.beginGroup("NewerVersionWarning");
|
Chris@231
|
2906 QString tag = QString("version-%1-available-show").arg(version);
|
Chris@231
|
2907 if (settings.value(tag, true).toBool()) {
|
Chris@231
|
2908 QString title(tr("Newer version available"));
|
Chris@231
|
2909 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Tony, but version %2 is now available.</p><p>Please see the <a href=\"http://code.soundsoftware.ac.uk/projects/tony/\">Tony website</a> for more information.</p>").arg(TONY_VERSION).arg(version));
|
Chris@231
|
2910 QMessageBox::information(this, title, text);
|
Chris@231
|
2911 settings.setValue(tag, false);
|
Chris@231
|
2912 }
|
Chris@231
|
2913 settings.endGroup();
|
Chris@231
|
2914 }
|
Chris@231
|
2915
|
Chris@231
|
2916
|
Chris@231
|
2917
|