annotate src/MainWindow.cpp @ 239:d40c6cdb30a4

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