annotate src/MainWindow.cpp @ 164:62ceae757fe0

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