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