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