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