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