annotate src/MainWindow.cpp @ 167:6b6906017536

Choose a different pitch candidate within selection by hitting Return
author Chris Cannam
date Mon, 03 Feb 2014 17:04:03 +0000
parents 62ceae757fe0
children c5e4eaeb9a27
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@167 539
Chris@167 540 //!!! shortcuts, status tip, key reference etc
Chris@167 541 action = new QAction(tr("Switch Pitch Candidate"), this);
Chris@167 542 action->setShortcut(tr("Return"));
Chris@167 543 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
Chris@167 544 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
Chris@167 545 menu->addAction(action);
Chris@0 546 }
Chris@0 547
Chris@0 548 void
Chris@0 549 MainWindow::setupViewMenu()
Chris@0 550 {
Chris@0 551 if (m_mainMenusCreated) return;
Chris@0 552
Chris@0 553 IconLoader il;
Chris@0 554
Chris@0 555 QAction *action = 0;
Chris@0 556
Chris@0 557 m_keyReference->setCategory(tr("Panning and Navigation"));
Chris@0 558
Chris@0 559 QMenu *menu = menuBar()->addMenu(tr("&View"));
Chris@0 560 menu->setTearOffEnabled(true);
Chris@0 561 action = new QAction(tr("Scroll &Left"), this);
Chris@0 562 action->setShortcut(tr("Left"));
Chris@0 563 action->setStatusTip(tr("Scroll the current pane to the left"));
Chris@0 564 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
Chris@0 565 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@0 566 m_keyReference->registerShortcut(action);
Chris@0 567 menu->addAction(action);
gyorgyf@27 568
Chris@0 569 action = new QAction(tr("Scroll &Right"), this);
Chris@0 570 action->setShortcut(tr("Right"));
Chris@0 571 action->setStatusTip(tr("Scroll the current pane to the right"));
Chris@0 572 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
Chris@0 573 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@0 574 m_keyReference->registerShortcut(action);
Chris@0 575 menu->addAction(action);
gyorgyf@27 576
Chris@0 577 action = new QAction(tr("&Jump Left"), this);
Chris@0 578 action->setShortcut(tr("Ctrl+Left"));
Chris@0 579 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
Chris@0 580 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
Chris@0 581 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@0 582 m_keyReference->registerShortcut(action);
Chris@0 583 menu->addAction(action);
gyorgyf@27 584
Chris@0 585 action = new QAction(tr("J&ump Right"), this);
Chris@0 586 action->setShortcut(tr("Ctrl+Right"));
Chris@0 587 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
Chris@0 588 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
Chris@0 589 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@0 590 m_keyReference->registerShortcut(action);
Chris@0 591 menu->addAction(action);
Chris@0 592
Chris@0 593 menu->addSeparator();
Chris@0 594
Chris@0 595 m_keyReference->setCategory(tr("Zoom"));
Chris@0 596
Chris@0 597 action = new QAction(il.load("zoom-in"),
Chris@0 598 tr("Zoom &In"), this);
Chris@0 599 action->setShortcut(tr("Up"));
Chris@0 600 action->setStatusTip(tr("Increase the zoom level"));
Chris@0 601 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
Chris@0 602 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@0 603 m_keyReference->registerShortcut(action);
Chris@0 604 menu->addAction(action);
gyorgyf@27 605
Chris@0 606 action = new QAction(il.load("zoom-out"),
Chris@0 607 tr("Zoom &Out"), this);
Chris@0 608 action->setShortcut(tr("Down"));
Chris@0 609 action->setStatusTip(tr("Decrease the zoom level"));
Chris@0 610 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
Chris@0 611 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@0 612 m_keyReference->registerShortcut(action);
Chris@0 613 menu->addAction(action);
gyorgyf@27 614
Chris@0 615 action = new QAction(tr("Restore &Default Zoom"), this);
Chris@0 616 action->setStatusTip(tr("Restore the zoom level to the default"));
Chris@0 617 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
Chris@0 618 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@0 619 menu->addAction(action);
Chris@0 620
Chris@0 621 action = new QAction(il.load("zoom-fit"),
Chris@0 622 tr("Zoom to &Fit"), this);
Chris@0 623 action->setShortcut(tr("F"));
Chris@0 624 action->setStatusTip(tr("Zoom to show the whole file"));
Chris@0 625 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
Chris@0 626 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@0 627 m_keyReference->registerShortcut(action);
Chris@0 628 menu->addAction(action);
Chris@0 629 }
Chris@0 630
Chris@0 631 void
Chris@0 632 MainWindow::setupHelpMenu()
Chris@0 633 {
Chris@0 634 QMenu *menu = menuBar()->addMenu(tr("&Help"));
Chris@0 635 menu->setTearOffEnabled(true);
Chris@0 636
Chris@0 637 m_keyReference->setCategory(tr("Help"));
Chris@0 638
Chris@0 639 IconLoader il;
Chris@0 640
Chris@1 641 QString name = QApplication::applicationName();
Chris@1 642
Chris@0 643 QAction *action = new QAction(il.load("help"),
Chris@0 644 tr("&Help Reference"), this);
Chris@0 645 action->setShortcut(tr("F1"));
Chris@1 646 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
Chris@0 647 connect(action, SIGNAL(triggered()), this, SLOT(help()));
Chris@0 648 m_keyReference->registerShortcut(action);
Chris@0 649 menu->addAction(action);
Chris@0 650
Chris@0 651 action = new QAction(tr("&Key and Mouse Reference"), this);
Chris@0 652 action->setShortcut(tr("F2"));
Chris@1 653 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
Chris@0 654 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
Chris@0 655 m_keyReference->registerShortcut(action);
Chris@0 656 menu->addAction(action);
Chris@0 657
Chris@1 658 action = new QAction(tr("%1 on the &Web").arg(name), this);
Chris@1 659 action->setStatusTip(tr("Open the %1 website").arg(name));
Chris@0 660 connect(action, SIGNAL(triggered()), this, SLOT(website()));
Chris@0 661 menu->addAction(action);
Chris@0 662
Chris@1 663 action = new QAction(tr("&About %1").arg(name), this);
Chris@1 664 action->setStatusTip(tr("Show information about %1").arg(name));
Chris@0 665 connect(action, SIGNAL(triggered()), this, SLOT(about()));
Chris@0 666 menu->addAction(action);
Chris@0 667 }
Chris@0 668
Chris@0 669 void
Chris@0 670 MainWindow::setupRecentFilesMenu()
Chris@0 671 {
Chris@0 672 m_recentFilesMenu->clear();
Chris@0 673 vector<QString> files = m_recentFiles.getRecent();
Chris@0 674 for (size_t i = 0; i < files.size(); ++i) {
Chris@50 675 QAction *action = new QAction(files[i], this);
Chris@50 676 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
Chris@0 677 if (i == 0) {
Chris@0 678 action->setShortcut(tr("Ctrl+R"));
Chris@0 679 m_keyReference->registerShortcut
Chris@0 680 (tr("Re-open"),
Chris@50 681 action->shortcut().toString(),
Chris@0 682 tr("Re-open the current or most recently opened file"));
Chris@0 683 }
Chris@50 684 m_recentFilesMenu->addAction(action);
Chris@0 685 }
Chris@0 686 }
Chris@0 687
Chris@0 688 void
Chris@0 689 MainWindow::setupToolbars()
Chris@0 690 {
Chris@0 691 m_keyReference->setCategory(tr("Playback and Transport Controls"));
Chris@0 692
Chris@0 693 IconLoader il;
Chris@0 694
Chris@0 695 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
Chris@0 696 menu->setTearOffEnabled(true);
Chris@0 697 m_rightButtonMenu->addSeparator();
Chris@0 698 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
Chris@0 699
Chris@0 700 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
Chris@0 701
Chris@0 702 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
Chris@0 703 tr("Rewind to Start"));
Chris@0 704 rwdStartAction->setShortcut(tr("Home"));
Chris@0 705 rwdStartAction->setStatusTip(tr("Rewind to the start"));
Chris@0 706 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
Chris@0 707 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
Chris@0 708
Chris@0 709 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
Chris@0 710 tr("Rewind"));
Chris@0 711 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
Chris@0 712 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
Chris@0 713 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
Chris@0 714
Chris@0 715 QAction *playAction = toolbar->addAction(il.load("playpause"),
Chris@0 716 tr("Play / Pause"));
Chris@0 717 playAction->setCheckable(true);
Chris@0 718 playAction->setShortcut(tr("Space"));
Chris@0 719 playAction->setStatusTip(tr("Start or stop playback from the current position"));
Chris@0 720 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
Chris@0 721 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
gyorgyf@27 722 playAction, SLOT(setChecked(bool)));
Chris@0 723 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
Chris@0 724
Chris@0 725 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
Chris@0 726 tr("Fast Forward"));
Chris@0 727 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
Chris@0 728 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
Chris@0 729 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
Chris@0 730
Chris@0 731 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
Chris@0 732 tr("Fast Forward to End"));
Chris@0 733 ffwdEndAction->setShortcut(tr("End"));
Chris@0 734 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
Chris@0 735 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
Chris@0 736 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
Chris@6 737
Chris@0 738 toolbar = addToolBar(tr("Play Mode Toolbar"));
Chris@0 739
Chris@0 740 QAction *psAction = toolbar->addAction(il.load("playselection"),
Chris@0 741 tr("Constrain Playback to Selection"));
Chris@0 742 psAction->setCheckable(true);
Chris@0 743 psAction->setChecked(m_viewManager->getPlaySelectionMode());
Chris@0 744 psAction->setShortcut(tr("s"));
Chris@0 745 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
Chris@0 746 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
Chris@0 747 psAction, SLOT(setChecked(bool)));
Chris@0 748 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
Chris@0 749 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
Chris@0 750
Chris@0 751 QAction *plAction = toolbar->addAction(il.load("playloop"),
Chris@0 752 tr("Loop Playback"));
Chris@0 753 plAction->setCheckable(true);
Chris@0 754 plAction->setChecked(m_viewManager->getPlayLoopMode());
Chris@0 755 plAction->setShortcut(tr("l"));
Chris@0 756 plAction->setStatusTip(tr("Loop playback"));
Chris@0 757 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
Chris@0 758 plAction, SLOT(setChecked(bool)));
Chris@0 759 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
Chris@0 760 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
Chris@0 761
Chris@0 762 m_keyReference->registerShortcut(psAction);
Chris@0 763 m_keyReference->registerShortcut(plAction);
Chris@0 764 m_keyReference->registerShortcut(playAction);
Chris@0 765 m_keyReference->registerShortcut(m_rwdAction);
Chris@0 766 m_keyReference->registerShortcut(m_ffwdAction);
Chris@0 767 m_keyReference->registerShortcut(rwdStartAction);
Chris@0 768 m_keyReference->registerShortcut(ffwdEndAction);
Chris@0 769
Chris@6 770 menu->addAction(playAction);
Chris@0 771 menu->addAction(psAction);
Chris@0 772 menu->addAction(plAction);
Chris@0 773 menu->addSeparator();
Chris@0 774 menu->addAction(m_rwdAction);
Chris@0 775 menu->addAction(m_ffwdAction);
Chris@0 776 menu->addSeparator();
Chris@0 777 menu->addAction(rwdStartAction);
Chris@0 778 menu->addAction(ffwdEndAction);
Chris@0 779 menu->addSeparator();
Chris@0 780
Chris@0 781 m_rightButtonPlaybackMenu->addAction(playAction);
Chris@0 782 m_rightButtonPlaybackMenu->addAction(psAction);
Chris@0 783 m_rightButtonPlaybackMenu->addAction(plAction);
Chris@0 784 m_rightButtonPlaybackMenu->addSeparator();
Chris@0 785 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
Chris@0 786 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
Chris@0 787 m_rightButtonPlaybackMenu->addSeparator();
Chris@0 788 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
Chris@0 789 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
Chris@0 790 m_rightButtonPlaybackMenu->addSeparator();
Chris@0 791
Chris@0 792 QAction *fastAction = menu->addAction(tr("Speed Up"));
Chris@0 793 fastAction->setShortcut(tr("Ctrl+PgUp"));
Chris@0 794 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
Chris@0 795 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
Chris@0 796 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
Chris@0 797
Chris@0 798 QAction *slowAction = menu->addAction(tr("Slow Down"));
Chris@0 799 slowAction->setShortcut(tr("Ctrl+PgDown"));
Chris@0 800 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
Chris@0 801 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
Chris@0 802 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
Chris@0 803
Chris@0 804 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
Chris@0 805 normalAction->setShortcut(tr("Ctrl+Home"));
Chris@0 806 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
Chris@0 807 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
Chris@0 808 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
Chris@0 809
Chris@0 810 m_keyReference->registerShortcut(fastAction);
Chris@0 811 m_keyReference->registerShortcut(slowAction);
Chris@0 812 m_keyReference->registerShortcut(normalAction);
Chris@0 813
Chris@0 814 m_rightButtonPlaybackMenu->addAction(fastAction);
Chris@0 815 m_rightButtonPlaybackMenu->addAction(slowAction);
Chris@0 816 m_rightButtonPlaybackMenu->addAction(normalAction);
Chris@6 817
Chris@6 818 toolbar = addToolBar(tr("Playback Controls"));
Chris@6 819 toolbar->addWidget(m_playSpeed);
Chris@6 820 toolbar->addWidget(m_fader);
Chris@0 821
Chris@128 822 toolbar = addToolBar(tr("Show and Play"));
Chris@144 823
justin@156 824 /* ORIGINAL DESIGN
Chris@144 825 QLabel *eye = new QLabel;
Chris@144 826 eye->setFixedWidth(40);
Chris@144 827 eye->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
Chris@144 828 eye->setPixmap(il.loadPixmap("eye"));
Chris@144 829 toolbar->addWidget(eye);
Chris@144 830
Chris@144 831 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
Chris@144 832 m_showAudio->setCheckable(true);
Chris@144 833 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
Chris@144 834 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
Chris@144 835
Chris@145 836 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
Chris@145 837 m_showSpect->setCheckable(true);
Chris@145 838 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
Chris@145 839 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
Chris@145 840
Chris@144 841 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
Chris@144 842 m_showPitch->setCheckable(true);
Chris@144 843 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
Chris@144 844 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
Chris@144 845
Chris@144 846 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
Chris@144 847 m_showNotes->setCheckable(true);
Chris@144 848 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
Chris@144 849 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
Chris@144 850
Chris@144 851 QLabel *speaker = new QLabel;
Chris@144 852 speaker->setFixedWidth(40);
Chris@144 853 speaker->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
Chris@144 854 speaker->setPixmap(il.loadPixmap("speaker"));
Chris@144 855 toolbar->addWidget(speaker);
Chris@128 856
Chris@144 857 m_playAudio = toolbar->addAction(il.load("waveform"), tr("Play Audio"));
Chris@144 858 m_playAudio->setCheckable(true);
Chris@144 859 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
Chris@144 860 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
Chris@128 861
Chris@144 862 m_playPitch = toolbar->addAction(il.load("values"), tr("Play Pitch Track"));
Chris@144 863 m_playPitch->setCheckable(true);
Chris@144 864 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
Chris@144 865 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
Chris@128 866
Chris@144 867 m_playNotes = toolbar->addAction(il.load("notes"), tr("Play Notes"));
Chris@144 868 m_playNotes->setCheckable(true);
Chris@144 869 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
Chris@144 870 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
justin@156 871 */
justin@156 872
justin@156 873 // Audio
justin@156 874 QLabel *icon_audio = new QLabel;
justin@156 875 icon_audio->setFixedWidth(40);
justin@156 876 icon_audio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
justin@156 877 icon_audio->setPixmap(il.loadPixmap("waveform"));
justin@156 878 toolbar->addWidget(icon_audio);
justin@156 879
justin@156 880 m_showAudio = toolbar->addAction(il.load("eye"), tr("Show Audio"));
justin@156 881 m_showAudio->setCheckable(true);
justin@156 882 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
justin@156 883 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
justin@156 884
justin@156 885 m_playAudio = toolbar->addAction(il.load("speaker"), tr("Play Audio"));
justin@156 886 m_playAudio->setCheckable(true);
justin@156 887 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
justin@156 888 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool)));
justin@156 889
justin@159 890 toolbar->addWidget(m_gainAudio);
justin@160 891 toolbar->addWidget(m_panAudio);
justin@159 892
justin@156 893 // Pitch (f0)
justin@156 894 QLabel *icon_pitch = new QLabel;
justin@156 895 icon_pitch->setFixedWidth(40);
justin@156 896 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
justin@156 897 icon_pitch->setPixmap(il.loadPixmap("values"));
justin@156 898 toolbar->addWidget(icon_pitch);
justin@156 899
justin@156 900 m_showPitch = toolbar->addAction(il.load("eye"), tr("Show Pitch Track"));
justin@156 901 m_showPitch->setCheckable(true);
justin@156 902 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
justin@156 903 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
justin@156 904
justin@156 905 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
justin@156 906 m_playPitch->setCheckable(true);
justin@156 907 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
justin@156 908 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
justin@156 909
Chris@158 910 toolbar->addWidget(m_gainPitch);
justin@160 911 toolbar->addWidget(m_panPitch);
justin@156 912
justin@156 913 // Notes
justin@156 914 QLabel *icon_notes = new QLabel;
justin@156 915 icon_notes->setFixedWidth(40);
justin@156 916 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
justin@156 917 icon_notes->setPixmap(il.loadPixmap("notes"));
justin@156 918 toolbar->addWidget(icon_notes);
justin@156 919
justin@156 920 m_showNotes = toolbar->addAction(il.load("eye"), tr("Show Notes"));
justin@156 921 m_showNotes->setCheckable(true);
justin@156 922 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
justin@156 923 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
justin@156 924
justin@156 925 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes"));
justin@156 926 m_playNotes->setCheckable(true);
justin@156 927 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
justin@156 928 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool)));
justin@156 929
justin@159 930 toolbar->addWidget(m_gainNotes);
justin@160 931 toolbar->addWidget(m_panNotes);
justin@159 932
justin@156 933 // Spectrogram
justin@156 934 QLabel *icon_spectrogram = new QLabel;
justin@156 935 icon_spectrogram->setFixedWidth(40);
justin@156 936 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
justin@156 937 icon_spectrogram->setPixmap(il.loadPixmap("spectrogram"));
justin@156 938 toolbar->addWidget(icon_spectrogram);
justin@156 939
justin@156 940 m_showSpect = toolbar->addAction(il.load("eye"), tr("Show Spectrogram"));
justin@156 941 m_showSpect->setCheckable(true);
justin@156 942 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
justin@156 943 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
Chris@128 944
Chris@0 945 Pane::registerShortcuts(*m_keyReference);
Chris@0 946 }
Chris@0 947
Chris@0 948 void
Chris@70 949 MainWindow::toolNavigateSelected()
Chris@70 950 {
Chris@70 951 m_viewManager->setToolMode(ViewManager::NavigateMode);
Chris@70 952 m_intelligentActionOn = true;
Chris@70 953 }
Chris@70 954
Chris@70 955 void
Chris@70 956 MainWindow::toolEditSelected()
Chris@70 957 {
Chris@77 958 m_viewManager->setToolMode(ViewManager::NoteEditMode);
Chris@70 959 m_intelligentActionOn = true;
Chris@70 960 m_analyser->setIntelligentActions(m_intelligentActionOn);
Chris@70 961 }
Chris@70 962
Chris@70 963 void
Chris@70 964 MainWindow::toolFreeEditSelected()
Chris@70 965 {
Chris@77 966 m_viewManager->setToolMode(ViewManager::NoteEditMode);
Chris@70 967 m_intelligentActionOn = false;
Chris@70 968 m_analyser->setIntelligentActions(m_intelligentActionOn);
Chris@70 969 }
Chris@70 970
gyorgyf@21 971 void
Chris@0 972 MainWindow::updateMenuStates()
Chris@0 973 {
Chris@0 974 MainWindowBase::updateMenuStates();
Chris@0 975
Chris@0 976 Pane *currentPane = 0;
Chris@0 977 Layer *currentLayer = 0;
Chris@0 978
Chris@0 979 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
Chris@0 980 if (currentPane) currentLayer = currentPane->getSelectedLayer();
Chris@0 981
Chris@0 982 bool haveCurrentPane =
Chris@0 983 (currentPane != 0);
Chris@0 984 bool haveCurrentLayer =
Chris@0 985 (haveCurrentPane &&
Chris@0 986 (currentLayer != 0));
Chris@0 987 bool haveSelection =
gyorgyf@27 988 (m_viewManager &&
gyorgyf@27 989 !m_viewManager->getSelections().empty());
Chris@0 990 bool haveCurrentEditableLayer =
gyorgyf@27 991 (haveCurrentLayer &&
gyorgyf@27 992 currentLayer->isLayerEditable());
Chris@0 993 bool haveCurrentTimeInstantsLayer =
gyorgyf@27 994 (haveCurrentLayer &&
gyorgyf@27 995 qobject_cast<TimeInstantLayer *>(currentLayer));
Chris@0 996 bool haveCurrentTimeValueLayer =
gyorgyf@27 997 (haveCurrentLayer &&
gyorgyf@27 998 qobject_cast<TimeValueLayer *>(currentLayer));
Chris@0 999
Chris@0 1000 emit canChangePlaybackSpeed(true);
Chris@0 1001 int v = m_playSpeed->value();
Chris@0 1002 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
Chris@0 1003 emit canSlowDownPlayback(v > m_playSpeed->minimum());
Chris@0 1004
Chris@0 1005 if (m_ffwdAction && m_rwdAction) {
Chris@0 1006 if (haveCurrentTimeInstantsLayer) {
Chris@0 1007 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
Chris@0 1008 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
Chris@0 1009 m_rwdAction->setText(tr("Rewind to Previous Instant"));
Chris@0 1010 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
Chris@0 1011 } else if (haveCurrentTimeValueLayer) {
Chris@0 1012 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
Chris@0 1013 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
Chris@0 1014 m_rwdAction->setText(tr("Rewind to Previous Point"));
Chris@0 1015 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
Chris@0 1016 } else {
Chris@0 1017 m_ffwdAction->setText(tr("Fast Forward"));
Chris@0 1018 m_ffwdAction->setStatusTip(tr("Fast forward"));
Chris@0 1019 m_rwdAction->setText(tr("Rewind"));
Chris@0 1020 m_rwdAction->setStatusTip(tr("Rewind"));
Chris@0 1021 }
Chris@0 1022 }
Chris@0 1023 }
Chris@0 1024
Chris@0 1025 void
Chris@144 1026 MainWindow::showAudioToggled()
Chris@128 1027 {
Chris@144 1028 m_analyser->toggleVisible(Analyser::Audio);
Chris@128 1029 }
Chris@128 1030
Chris@128 1031 void
Chris@144 1032 MainWindow::showPitchToggled()
Chris@128 1033 {
Chris@144 1034 m_analyser->toggleVisible(Analyser::PitchTrack);
Chris@128 1035 }
Chris@128 1036
Chris@128 1037 void
Chris@145 1038 MainWindow::showSpectToggled()
Chris@145 1039 {
Chris@145 1040 m_analyser->toggleVisible(Analyser::Spectrogram);
Chris@145 1041 }
Chris@145 1042
Chris@145 1043 void
Chris@144 1044 MainWindow::showNotesToggled()
Chris@128 1045 {
Chris@144 1046 m_analyser->toggleVisible(Analyser::Notes);
Chris@144 1047 }
Chris@144 1048
Chris@144 1049 void
Chris@144 1050 MainWindow::playAudioToggled()
Chris@144 1051 {
Chris@144 1052 m_analyser->toggleAudible(Analyser::Audio);
Chris@144 1053 }
Chris@144 1054
Chris@144 1055 void
Chris@144 1056 MainWindow::playPitchToggled()
Chris@144 1057 {
Chris@144 1058 m_analyser->toggleAudible(Analyser::PitchTrack);
Chris@144 1059 }
Chris@144 1060
Chris@144 1061 void
Chris@144 1062 MainWindow::playNotesToggled()
Chris@144 1063 {
Chris@144 1064 m_analyser->toggleAudible(Analyser::Notes);
Chris@144 1065 }
Chris@144 1066
Chris@144 1067 void
Chris@144 1068 MainWindow::updateLayerStatuses()
Chris@144 1069 {
Chris@144 1070 m_showAudio->setChecked(m_analyser->isVisible(Analyser::Audio));
Chris@145 1071 m_showSpect->setChecked(m_analyser->isVisible(Analyser::Spectrogram));
Chris@144 1072 m_showPitch->setChecked(m_analyser->isVisible(Analyser::PitchTrack));
Chris@144 1073 m_showNotes->setChecked(m_analyser->isVisible(Analyser::Notes));
Chris@144 1074 m_playAudio->setChecked(m_analyser->isAudible(Analyser::Audio));
Chris@144 1075 m_playPitch->setChecked(m_analyser->isAudible(Analyser::PitchTrack));
Chris@144 1076 m_playNotes->setChecked(m_analyser->isAudible(Analyser::Notes));
Chris@128 1077 }
Chris@128 1078
Chris@128 1079 void
Chris@0 1080 MainWindow::updateDescriptionLabel()
Chris@0 1081 {
Chris@6 1082 // Nothing, we don't have one
Chris@0 1083 }
Chris@0 1084
Chris@0 1085 void
Chris@0 1086 MainWindow::documentModified()
Chris@0 1087 {
Chris@0 1088 MainWindowBase::documentModified();
Chris@0 1089 }
Chris@0 1090
Chris@0 1091 void
Chris@0 1092 MainWindow::documentRestored()
Chris@0 1093 {
Chris@0 1094 MainWindowBase::documentRestored();
Chris@0 1095 }
Chris@0 1096
Chris@0 1097 void
Chris@0 1098 MainWindow::newSession()
Chris@0 1099 {
Chris@0 1100 if (!checkSaveModified()) return;
Chris@0 1101
Chris@0 1102 closeSession();
Chris@0 1103 createDocument();
Chris@0 1104 m_document->setAutoAlignment(true);
Chris@0 1105
Chris@0 1106 Pane *pane = m_paneStack->addPane();
Chris@0 1107
Chris@0 1108 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
Chris@0 1109 this, SLOT(contextHelpChanged(const QString &)));
Chris@0 1110
Chris@6 1111 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
Chris@6 1112 // m_document->addLayerToView(pane, waveform);
Chris@0 1113
Chris@0 1114 m_overview->registerView(pane);
Chris@0 1115
Chris@0 1116 CommandHistory::getInstance()->clear();
Chris@0 1117 CommandHistory::getInstance()->documentSaved();
Chris@0 1118 documentRestored();
Chris@0 1119 updateMenuStates();
Chris@0 1120 }
Chris@0 1121
Chris@0 1122 void
Chris@0 1123 MainWindow::closeSession()
Chris@0 1124 {
Chris@0 1125 if (!checkSaveModified()) return;
Chris@0 1126
Chris@0 1127 while (m_paneStack->getPaneCount() > 0) {
Chris@0 1128
Chris@167 1129 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
Chris@0 1130
Chris@167 1131 while (pane->getLayerCount() > 0) {
Chris@167 1132 m_document->removeLayerFromView
Chris@167 1133 (pane, pane->getLayer(pane->getLayerCount() - 1));
Chris@167 1134 }
Chris@167 1135
Chris@167 1136 m_overview->unregisterView(pane);
Chris@167 1137 m_paneStack->deletePane(pane);
Chris@0 1138 }
Chris@0 1139
Chris@0 1140 while (m_paneStack->getHiddenPaneCount() > 0) {
Chris@0 1141
Chris@167 1142 Pane *pane = m_paneStack->getHiddenPane
Chris@167 1143 (m_paneStack->getHiddenPaneCount() - 1);
Chris@167 1144
Chris@167 1145 while (pane->getLayerCount() > 0) {
Chris@167 1146 m_document->removeLayerFromView
Chris@167 1147 (pane, pane->getLayer(pane->getLayerCount() - 1));
Chris@167 1148 }
Chris@167 1149
Chris@167 1150 m_overview->unregisterView(pane);
Chris@167 1151 m_paneStack->deletePane(pane);
Chris@0 1152 }
Chris@0 1153
Chris@0 1154 delete m_document;
Chris@0 1155 m_document = 0;
Chris@0 1156 m_viewManager->clearSelections();
Chris@0 1157 m_timeRulerLayer = 0; // document owned this
Chris@0 1158
Chris@0 1159 m_sessionFile = "";
Chris@0 1160
Chris@0 1161 CommandHistory::getInstance()->clear();
Chris@0 1162 CommandHistory::getInstance()->documentSaved();
Chris@0 1163 documentRestored();
Chris@0 1164 }
Chris@0 1165
Chris@0 1166 void
Chris@0 1167 MainWindow::openFile()
Chris@0 1168 {
Chris@0 1169 QString orig = m_audioFile;
Chris@0 1170 if (orig == "") orig = ".";
Chris@0 1171 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
Chris@0 1172
Chris@0 1173 QString path = getOpenFileName(FileFinder::AnyFile);
Chris@0 1174
Chris@0 1175 if (path.isEmpty()) return;
Chris@0 1176
Chris@1 1177 FileOpenStatus status = open(path, ReplaceSession);
Chris@0 1178
Chris@0 1179 if (status == FileOpenFailed) {
Chris@0 1180 QMessageBox::critical(this, tr("Failed to open file"),
Chris@0 1181 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
Chris@0 1182 } else if (status == FileOpenWrongMode) {
Chris@0 1183 QMessageBox::critical(this, tr("Failed to open file"),
Chris@0 1184 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 1185 }
Chris@0 1186 }
Chris@0 1187
Chris@0 1188 void
Chris@0 1189 MainWindow::openLocation()
Chris@0 1190 {
Chris@0 1191 QSettings settings;
Chris@0 1192 settings.beginGroup("MainWindow");
Chris@0 1193 QString lastLocation = settings.value("lastremote", "").toString();
Chris@0 1194
Chris@0 1195 bool ok = false;
Chris@0 1196 QString text = QInputDialog::getText
Chris@0 1197 (this, tr("Open Location"),
Chris@0 1198 tr("Please enter the URL of the location to open:"),
Chris@0 1199 QLineEdit::Normal, lastLocation, &ok);
Chris@0 1200
Chris@0 1201 if (!ok) return;
Chris@0 1202
Chris@0 1203 settings.setValue("lastremote", text);
Chris@0 1204
Chris@0 1205 if (text.isEmpty()) return;
Chris@0 1206
Chris@1 1207 FileOpenStatus status = open(text, ReplaceSession);
Chris@0 1208
Chris@0 1209 if (status == FileOpenFailed) {
Chris@0 1210 QMessageBox::critical(this, tr("Failed to open location"),
Chris@0 1211 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
Chris@0 1212 } else if (status == FileOpenWrongMode) {
Chris@0 1213 QMessageBox::critical(this, tr("Failed to open location"),
Chris@0 1214 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 1215 }
Chris@0 1216 }
Chris@0 1217
Chris@0 1218 void
Chris@0 1219 MainWindow::openRecentFile()
Chris@0 1220 {
Chris@0 1221 QObject *obj = sender();
Chris@3 1222 QAction *action = qobject_cast<QAction *>(obj);
Chris@0 1223
Chris@0 1224 if (!action) {
Chris@70 1225 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
Chris@70 1226 << endl;
gyorgyf@27 1227 return;
Chris@0 1228 }
Chris@0 1229
Chris@0 1230 QString path = action->text();
Chris@0 1231 if (path == "") return;
Chris@0 1232
Chris@1 1233 FileOpenStatus status = open(path, ReplaceSession);
Chris@0 1234
Chris@0 1235 if (status == FileOpenFailed) {
Chris@0 1236 QMessageBox::critical(this, tr("Failed to open location"),
Chris@0 1237 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
Chris@0 1238 } else if (status == FileOpenWrongMode) {
Chris@0 1239 QMessageBox::critical(this, tr("Failed to open location"),
Chris@0 1240 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 1241 }
Chris@0 1242 }
Chris@0 1243
Chris@0 1244 void
Chris@0 1245 MainWindow::paneAdded(Pane *pane)
Chris@0 1246 {
Chris@6 1247 pane->setPlaybackFollow(PlaybackScrollPage);
Chris@0 1248 m_paneStack->sizePanesEqually();
Chris@0 1249 if (m_overview) m_overview->registerView(pane);
Chris@0 1250 }
Chris@0 1251
Chris@0 1252 void
Chris@0 1253 MainWindow::paneHidden(Pane *pane)
Chris@0 1254 {
Chris@0 1255 if (m_overview) m_overview->unregisterView(pane);
Chris@0 1256 }
Chris@0 1257
Chris@0 1258 void
Chris@0 1259 MainWindow::paneAboutToBeDeleted(Pane *pane)
Chris@0 1260 {
Chris@0 1261 if (m_overview) m_overview->unregisterView(pane);
Chris@0 1262 }
Chris@0 1263
Chris@0 1264 void
Chris@0 1265 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
Chris@0 1266 {
Chris@4 1267 if (pane) m_paneStack->setCurrentPane(pane);
Chris@0 1268
Chris@0 1269 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
Chris@0 1270
Chris@1 1271 FileOpenStatus status = open(*i, ReplaceSession);
Chris@0 1272
Chris@0 1273 if (status == FileOpenFailed) {
Chris@0 1274 QMessageBox::critical(this, tr("Failed to open dropped URL"),
Chris@0 1275 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
Chris@0 1276 } else if (status == FileOpenWrongMode) {
Chris@0 1277 QMessageBox::critical(this, tr("Failed to open dropped URL"),
Chris@0 1278 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 1279 }
Chris@0 1280 }
Chris@0 1281 }
Chris@0 1282
Chris@0 1283 void
Chris@0 1284 MainWindow::paneDropAccepted(Pane *pane, QString text)
Chris@0 1285 {
Chris@0 1286 if (pane) m_paneStack->setCurrentPane(pane);
Chris@0 1287
Chris@0 1288 QUrl testUrl(text);
Chris@0 1289 if (testUrl.scheme() == "file" ||
Chris@0 1290 testUrl.scheme() == "http" ||
Chris@0 1291 testUrl.scheme() == "ftp") {
Chris@0 1292 QStringList list;
Chris@0 1293 list.push_back(text);
Chris@0 1294 paneDropAccepted(pane, list);
Chris@0 1295 return;
Chris@0 1296 }
Chris@0 1297
Chris@0 1298 //!!! open as text -- but by importing as if a CSV, or just adding
Chris@0 1299 //to a text layer?
Chris@0 1300 }
Chris@0 1301
Chris@0 1302 void
Chris@0 1303 MainWindow::closeEvent(QCloseEvent *e)
Chris@0 1304 {
Chris@70 1305 // cerr << "MainWindow::closeEvent" << endl;
Chris@0 1306
Chris@0 1307 if (m_openingAudioFile) {
Chris@70 1308 // cerr << "Busy - ignoring close event" << endl;
gyorgyf@27 1309 e->ignore();
gyorgyf@27 1310 return;
Chris@0 1311 }
Chris@0 1312
Chris@0 1313 if (!m_abandoning && !checkSaveModified()) {
Chris@70 1314 // cerr << "Ignoring close event" << endl;
gyorgyf@27 1315 e->ignore();
gyorgyf@27 1316 return;
Chris@0 1317 }
Chris@0 1318
Chris@0 1319 QSettings settings;
Chris@0 1320 settings.beginGroup("MainWindow");
Chris@0 1321 settings.setValue("size", size());
Chris@0 1322 settings.setValue("position", pos());
Chris@0 1323 settings.endGroup();
Chris@0 1324
Chris@0 1325 delete m_keyReference;
Chris@0 1326 m_keyReference = 0;
Chris@0 1327
Chris@0 1328 closeSession();
Chris@0 1329
Chris@0 1330 e->accept();
Chris@0 1331 return;
Chris@0 1332 }
Chris@0 1333
Chris@0 1334 bool
Chris@0 1335 MainWindow::commitData(bool mayAskUser)
Chris@0 1336 {
Chris@0 1337 if (mayAskUser) {
Chris@0 1338 bool rv = checkSaveModified();
Chris@0 1339 return rv;
Chris@0 1340 } else {
Chris@0 1341 if (!m_documentModified) return true;
Chris@0 1342
Chris@0 1343 // If we can't check with the user first, then we can't save
Chris@0 1344 // to the original session file (even if we have it) -- have
Chris@0 1345 // to use a temporary file
Chris@0 1346
Chris@0 1347 QString svDirBase = ".sv1";
Chris@0 1348 QString svDir = QDir::home().filePath(svDirBase);
Chris@0 1349
Chris@0 1350 if (!QFileInfo(svDir).exists()) {
Chris@0 1351 if (!QDir::home().mkdir(svDirBase)) return false;
Chris@0 1352 } else {
Chris@0 1353 if (!QFileInfo(svDir).isDir()) return false;
Chris@0 1354 }
Chris@0 1355
Chris@0 1356 // This name doesn't have to be unguessable
Chris@0 1357 #ifndef _WIN32
Chris@0 1358 QString fname = QString("tmp-%1-%2.sv")
Chris@0 1359 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
Chris@0 1360 .arg(QProcess().pid());
Chris@0 1361 #else
Chris@0 1362 QString fname = QString("tmp-%1.sv")
Chris@0 1363 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
Chris@0 1364 #endif
Chris@0 1365 QString fpath = QDir(svDir).filePath(fname);
Chris@0 1366 if (saveSessionFile(fpath)) {
Chris@0 1367 m_recentFiles.addFile(fpath);
Chris@0 1368 return true;
Chris@0 1369 } else {
Chris@0 1370 return false;
Chris@0 1371 }
Chris@0 1372 }
Chris@0 1373 }
Chris@0 1374
Chris@0 1375 bool
Chris@0 1376 MainWindow::checkSaveModified()
Chris@0 1377 {
Chris@0 1378 // Called before some destructive operation (e.g. new session,
Chris@0 1379 // exit program). Return true if we can safely proceed, false to
Chris@0 1380 // cancel.
Chris@0 1381
Chris@0 1382 if (!m_documentModified) return true;
Chris@0 1383
Chris@0 1384 int button =
gyorgyf@27 1385 QMessageBox::warning(this,
gyorgyf@27 1386 tr("Session modified"),
gyorgyf@27 1387 tr("The current session has been modified.\nDo you want to save it?"),
gyorgyf@27 1388 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
Chris@0 1389 QMessageBox::Yes);
Chris@0 1390
Chris@0 1391 if (button == QMessageBox::Yes) {
gyorgyf@27 1392 saveSession();
gyorgyf@27 1393 if (m_documentModified) { // save failed -- don't proceed!
gyorgyf@27 1394 return false;
gyorgyf@27 1395 } else {
Chris@0 1396 return true; // saved, so it's safe to continue now
Chris@0 1397 }
Chris@0 1398 } else if (button == QMessageBox::No) {
gyorgyf@27 1399 m_documentModified = false; // so we know to abandon it
gyorgyf@27 1400 return true;
Chris@0 1401 }
Chris@0 1402
Chris@0 1403 // else cancel
Chris@0 1404 return false;
Chris@0 1405 }
Chris@0 1406
Chris@0 1407 void
Chris@0 1408 MainWindow::saveSession()
Chris@0 1409 {
Chris@0 1410 if (m_sessionFile != "") {
gyorgyf@27 1411 if (!saveSessionFile(m_sessionFile)) {
gyorgyf@27 1412 QMessageBox::critical(this, tr("Failed to save file"),
gyorgyf@27 1413 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
Chris@0 1414 } else {
gyorgyf@27 1415 CommandHistory::getInstance()->documentSaved();
gyorgyf@27 1416 documentRestored();
gyorgyf@27 1417 }
gyorgyf@27 1418 } else {
gyorgyf@27 1419 saveSessionAs();
Chris@0 1420 }
Chris@0 1421 }
Chris@0 1422
Chris@0 1423 void
Chris@0 1424 MainWindow::saveSessionAs()
Chris@0 1425 {
Chris@0 1426 QString orig = m_audioFile;
Chris@0 1427 if (orig == "") orig = ".";
Chris@0 1428 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
Chris@0 1429
Chris@0 1430 QString path = getSaveFileName(FileFinder::SessionFile);
Chris@0 1431
Chris@0 1432 if (path == "") return;
Chris@0 1433
Chris@0 1434 if (!saveSessionFile(path)) {
Chris@85 1435 QMessageBox::critical(this, tr("Failed to save file"),
Chris@85 1436 tr("Session file \"%1\" could not be saved.").arg(path));
Chris@0 1437 } else {
Chris@85 1438 setWindowTitle(tr("%1: %2")
Chris@0 1439 .arg(QApplication::applicationName())
Chris@85 1440 .arg(QFileInfo(path).fileName()));
Chris@85 1441 m_sessionFile = path;
Chris@85 1442 CommandHistory::getInstance()->documentSaved();
Chris@85 1443 documentRestored();
Chris@0 1444 m_recentFiles.addFile(path);
Chris@0 1445 }
Chris@0 1446 }
Chris@0 1447
Chris@85 1448 QString
Chris@85 1449 MainWindow::exportToSVL(QString path, Layer *layer)
Chris@85 1450 {
Chris@85 1451 Model *model = layer->getModel();
Chris@85 1452
Chris@85 1453 QFile file(path);
Chris@85 1454 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
Chris@85 1455 return tr("Failed to open file %1 for writing").arg(path);
Chris@85 1456 } else {
Chris@85 1457 QTextStream out(&file);
Chris@85 1458 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
Chris@85 1459 << "<!DOCTYPE sonic-visualiser>\n"
Chris@85 1460 << "<sv>\n"
Chris@85 1461 << " <data>\n";
Chris@85 1462
Chris@85 1463 model->toXml(out, " ");
Chris@85 1464
Chris@85 1465 out << " </data>\n"
Chris@85 1466 << " <display>\n";
Chris@85 1467
Chris@85 1468 layer->toXml(out, " ");
Chris@85 1469
Chris@85 1470 out << " </display>\n"
Chris@85 1471 << "</sv>\n";
Chris@85 1472
Chris@85 1473 return "";
Chris@85 1474 }
Chris@85 1475 }
Chris@85 1476
Chris@0 1477 void
Chris@85 1478 MainWindow::exportPitchLayer()
matthiasm@26 1479 {
Chris@85 1480 Layer *layer = 0;
Chris@85 1481 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
Chris@85 1482 Pane *pane = m_paneStack->getPane(i);
Chris@85 1483 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@85 1484 layer = qobject_cast<TimeValueLayer *>(pane->getLayer(j));
Chris@85 1485 if (layer) break;
Chris@85 1486 }
Chris@85 1487 if (layer) break;
Chris@85 1488 }
matthiasm@26 1489
matthiasm@26 1490 if (!layer) return;
matthiasm@26 1491
Chris@85 1492 SparseTimeValueModel *model =
Chris@85 1493 qobject_cast<SparseTimeValueModel *>(layer->getModel());
matthiasm@26 1494 if (!model) return;
matthiasm@26 1495
Chris@96 1496 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
matthiasm@26 1497
matthiasm@26 1498 QString path = getSaveFileName(type);
matthiasm@26 1499
matthiasm@26 1500 if (path == "") return;
matthiasm@26 1501
matthiasm@26 1502 if (QFileInfo(path).suffix() == "") path += ".svl";
matthiasm@26 1503
matthiasm@26 1504 QString suffix = QFileInfo(path).suffix().toLower();
matthiasm@26 1505
matthiasm@26 1506 QString error;
matthiasm@26 1507
matthiasm@26 1508 if (suffix == "xml" || suffix == "svl") {
matthiasm@26 1509
Chris@85 1510 error = exportToSVL(path, layer);
matthiasm@26 1511
matthiasm@26 1512 } else if (suffix == "ttl" || suffix == "n3") {
matthiasm@26 1513
Chris@85 1514 RDFExporter exporter(path, model);
Chris@85 1515 exporter.write();
Chris@85 1516 if (!exporter.isOK()) {
Chris@85 1517 error = exporter.getError();
Chris@85 1518 }
Chris@85 1519
Chris@85 1520 } else {
Chris@85 1521
Chris@85 1522 CSVFileWriter writer(path, model,
Chris@85 1523 ((suffix == "csv") ? "," : "\t"));
Chris@85 1524 writer.write();
Chris@85 1525
Chris@85 1526 if (!writer.isOK()) {
Chris@85 1527 error = writer.getError();
Chris@85 1528 }
Chris@85 1529 }
Chris@85 1530
Chris@85 1531 if (error != "") {
Chris@85 1532 QMessageBox::critical(this, tr("Failed to write file"), error);
Chris@85 1533 } else {
Chris@85 1534 m_recentFiles.addFile(path);
Chris@85 1535 emit activity(tr("Export layer to \"%1\"").arg(path));
Chris@85 1536 }
Chris@85 1537 }
Chris@85 1538
Chris@85 1539 void
Chris@85 1540 MainWindow::exportNoteLayer()
Chris@85 1541 {
Chris@85 1542 Layer *layer = 0;
Chris@85 1543 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
Chris@85 1544 Pane *pane = m_paneStack->getPane(i);
Chris@85 1545 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@85 1546 layer = qobject_cast<FlexiNoteLayer *>(pane->getLayer(j));
Chris@85 1547 if (layer) break;
Chris@85 1548 }
Chris@85 1549 if (layer) break;
Chris@85 1550 }
Chris@85 1551
Chris@85 1552 if (!layer) return;
Chris@85 1553
Chris@85 1554 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
Chris@85 1555 if (!model) return;
Chris@85 1556
Chris@96 1557 FileFinder::FileType type = FileFinder::LayerFileNonSV;
Chris@85 1558
Chris@85 1559 QString path = getSaveFileName(type);
Chris@85 1560
Chris@85 1561 if (path == "") return;
Chris@85 1562
Chris@85 1563 if (QFileInfo(path).suffix() == "") path += ".svl";
Chris@85 1564
Chris@85 1565 QString suffix = QFileInfo(path).suffix().toLower();
Chris@85 1566
Chris@85 1567 QString error;
Chris@85 1568
Chris@85 1569 if (suffix == "xml" || suffix == "svl") {
Chris@85 1570
Chris@85 1571 error = exportToSVL(path, layer);
Chris@85 1572
Chris@85 1573 } else if (suffix == "mid" || suffix == "midi") {
Chris@85 1574
Chris@85 1575 MIDIFileWriter writer(path, model, model->getSampleRate());
Chris@85 1576 writer.write();
Chris@85 1577 if (!writer.isOK()) {
Chris@85 1578 error = writer.getError();
Chris@85 1579 }
Chris@85 1580
Chris@85 1581 } else if (suffix == "ttl" || suffix == "n3") {
Chris@85 1582
Chris@85 1583 RDFExporter exporter(path, model);
Chris@85 1584 exporter.write();
Chris@85 1585 if (!exporter.isOK()) {
Chris@85 1586 error = exporter.getError();
matthiasm@26 1587 }
matthiasm@26 1588
matthiasm@26 1589 } else {
matthiasm@26 1590
matthiasm@26 1591 CSVFileWriter writer(path, model,
matthiasm@26 1592 ((suffix == "csv") ? "," : "\t"));
matthiasm@26 1593 writer.write();
matthiasm@26 1594
matthiasm@26 1595 if (!writer.isOK()) {
matthiasm@26 1596 error = writer.getError();
matthiasm@26 1597 }
matthiasm@26 1598 }
matthiasm@26 1599
matthiasm@26 1600 if (error != "") {
matthiasm@26 1601 QMessageBox::critical(this, tr("Failed to write file"), error);
matthiasm@26 1602 } else {
matthiasm@26 1603 m_recentFiles.addFile(path);
matthiasm@26 1604 emit activity(tr("Export layer to \"%1\"").arg(path));
matthiasm@26 1605 }
matthiasm@26 1606 }
matthiasm@26 1607
matthiasm@26 1608
matthiasm@26 1609 void
Chris@0 1610 MainWindow::renameCurrentLayer()
Chris@0 1611 {
Chris@0 1612 Pane *pane = m_paneStack->getCurrentPane();
Chris@0 1613 if (pane) {
Chris@139 1614 Layer *layer = pane->getSelectedLayer();
Chris@139 1615 if (layer) {
Chris@139 1616 bool ok = false;
Chris@139 1617 QString newName = QInputDialog::getText
Chris@139 1618 (this, tr("Rename Layer"),
Chris@139 1619 tr("New name for this layer:"),
Chris@139 1620 QLineEdit::Normal, layer->objectName(), &ok);
Chris@139 1621 if (ok) {
Chris@139 1622 layer->setObjectName(newName);
Chris@139 1623 }
gyorgyf@27 1624 }
gyorgyf@27 1625 }
Chris@139 1626 }
Chris@139 1627
Chris@139 1628 void
Chris@139 1629 MainWindow::doubleClickSelectInvoked(size_t frame)
Chris@139 1630 {
Chris@139 1631 size_t f0, f1;
Chris@139 1632 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
Chris@139 1633
Chris@139 1634 cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl;
Chris@139 1635
Chris@164 1636 Selection sel(f0, f1);
Chris@164 1637 m_viewManager->setSelection(sel);
Chris@164 1638 }
Chris@164 1639
Chris@164 1640 void
Chris@167 1641 MainWindow::clearSelection()
Chris@167 1642 {
Chris@167 1643 cerr << "MainWindow::clearSelection()" << endl;
Chris@167 1644
Chris@167 1645 m_analyser->clearReAnalysis();
Chris@167 1646 MainWindowBase::clearSelection();
Chris@167 1647 }
Chris@167 1648
Chris@167 1649 void
Chris@164 1650 MainWindow::selectionChanged()
Chris@164 1651 {
Chris@164 1652 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@164 1653
Chris@164 1654 cerr << "MainWindow::selectionChanged" << endl;
Chris@164 1655
Chris@164 1656 if (!selections.empty()) {
Chris@164 1657 Selection sel = *selections.begin();
Chris@164 1658 cerr << "MainWindow::selectionChanged: have selection" << endl;
Chris@164 1659 QString error = m_analyser->reAnalyseSelection(sel);
Chris@164 1660 if (error != "") {
Chris@164 1661 QMessageBox::critical
Chris@164 1662 (this, tr("Failed to analyse selection"),
Chris@164 1663 tr("<b>Analysis failed</b><p>%2</p>").arg(error));
Chris@164 1664 }
Chris@164 1665 }
Chris@0 1666 }
Chris@0 1667
Chris@0 1668 void
Chris@142 1669 MainWindow::octaveShiftUp()
Chris@142 1670 {
Chris@142 1671 octaveShift(true);
Chris@142 1672 }
Chris@142 1673
Chris@142 1674 void
Chris@142 1675 MainWindow::octaveShiftDown()
Chris@142 1676 {
Chris@142 1677 octaveShift(false);
Chris@142 1678 }
Chris@142 1679
Chris@142 1680 void
Chris@142 1681 MainWindow::octaveShift(bool up)
Chris@142 1682 {
Chris@167 1683 // Should this be in the Analyser?
Chris@167 1684
Chris@142 1685 float factor = (up ? 2.f : 0.5f);
Chris@142 1686
Chris@142 1687 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@142 1688
Chris@142 1689 CommandHistory::getInstance()->startCompoundOperation(tr("Octave Shift"), true);
Chris@142 1690
Chris@142 1691 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
Chris@142 1692
Chris@142 1693 Pane *pane = m_paneStack->getPane(i);
Chris@142 1694 if (!pane) continue;
Chris@142 1695
Chris@142 1696 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@142 1697
Chris@142 1698 Layer *layer = pane->getLayer(j);
Chris@142 1699 if (!layer) continue;
Chris@142 1700
Chris@142 1701 for (MultiSelection::SelectionList::iterator k = selections.begin();
Chris@142 1702 k != selections.end(); ++k) {
Chris@142 1703
Chris@142 1704 Clipboard clip;
Chris@142 1705 layer->copy(pane, *k, clip);
Chris@142 1706 layer->deleteSelection(*k);
Chris@142 1707
Chris@142 1708 Clipboard shifted;
Chris@142 1709 foreach (Clipboard::Point p, clip.getPoints()) {
Chris@142 1710 if (p.haveValue()) {
Chris@142 1711 Clipboard::Point sp =
Chris@142 1712 p.withValue(p.getValue() * factor);
Chris@142 1713 shifted.addPoint(sp);
Chris@142 1714 } else {
Chris@142 1715 shifted.addPoint(p);
Chris@142 1716 }
Chris@142 1717 }
Chris@142 1718
Chris@142 1719 layer->paste(pane, shifted, 0, false);
Chris@142 1720 }
Chris@142 1721 }
Chris@142 1722 }
Chris@142 1723
Chris@142 1724 CommandHistory::getInstance()->endCompoundOperation();
Chris@142 1725 }
Chris@142 1726
Chris@142 1727 void
Chris@167 1728 MainWindow::switchPitchUp()
Chris@167 1729 {
Chris@167 1730 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@167 1731
Chris@167 1732 for (MultiSelection::SelectionList::iterator k = selections.begin();
Chris@167 1733 k != selections.end(); ++k) {
Chris@167 1734 m_analyser->switchPitchCandidate(*k, true);
Chris@167 1735 }
Chris@167 1736 }
Chris@167 1737
Chris@167 1738 void
Chris@167 1739 MainWindow::switchPitchDown()
Chris@167 1740 {
Chris@167 1741 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@167 1742
Chris@167 1743 for (MultiSelection::SelectionList::iterator k = selections.begin();
Chris@167 1744 k != selections.end(); ++k) {
Chris@167 1745 m_analyser->switchPitchCandidate(*k, false);
Chris@167 1746 }
Chris@167 1747 }
Chris@167 1748
Chris@167 1749 void
Chris@0 1750 MainWindow::playSpeedChanged(int position)
Chris@0 1751 {
Chris@0 1752 PlaySpeedRangeMapper mapper(0, 200);
Chris@0 1753
Chris@0 1754 float percent = m_playSpeed->mappedValue();
Chris@0 1755 float factor = mapper.getFactorForValue(percent);
Chris@0 1756
Chris@70 1757 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
Chris@0 1758
Chris@0 1759 bool something = (position != 100);
Chris@0 1760
Chris@0 1761 int pc = lrintf(percent);
Chris@0 1762
Chris@0 1763 if (!something) {
Chris@0 1764 contextHelpChanged(tr("Playback speed: Normal"));
Chris@0 1765 } else {
Chris@0 1766 contextHelpChanged(tr("Playback speed: %1%2%")
Chris@0 1767 .arg(position > 100 ? "+" : "")
Chris@0 1768 .arg(pc));
Chris@0 1769 }
Chris@0 1770
Chris@0 1771 m_playSource->setTimeStretch(factor);
Chris@0 1772
Chris@0 1773 updateMenuStates();
Chris@0 1774 }
Chris@0 1775
Chris@0 1776 void
Chris@0 1777 MainWindow::playSharpenToggled()
Chris@0 1778 {
Chris@0 1779 QSettings settings;
Chris@0 1780 settings.beginGroup("MainWindow");
Chris@0 1781 settings.setValue("playsharpen", m_playSharpen->isChecked());
Chris@0 1782 settings.endGroup();
Chris@0 1783
Chris@0 1784 playSpeedChanged(m_playSpeed->value());
justin@157 1785 // TODO: pitch gain?
Chris@0 1786 }
Chris@0 1787
Chris@0 1788 void
Chris@0 1789 MainWindow::playMonoToggled()
Chris@0 1790 {
Chris@0 1791 QSettings settings;
Chris@0 1792 settings.beginGroup("MainWindow");
Chris@0 1793 settings.setValue("playmono", m_playMono->isChecked());
Chris@0 1794 settings.endGroup();
Chris@0 1795
Chris@0 1796 playSpeedChanged(m_playSpeed->value());
justin@157 1797 // TODO: pitch gain?
Chris@0 1798 }
Chris@0 1799
Chris@0 1800 void
Chris@0 1801 MainWindow::speedUpPlayback()
Chris@0 1802 {
Chris@0 1803 int value = m_playSpeed->value();
Chris@0 1804 value = value + m_playSpeed->pageStep();
Chris@0 1805 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
Chris@0 1806 m_playSpeed->setValue(value);
Chris@0 1807 }
Chris@0 1808
Chris@0 1809 void
Chris@0 1810 MainWindow::slowDownPlayback()
Chris@0 1811 {
Chris@0 1812 int value = m_playSpeed->value();
Chris@0 1813 value = value - m_playSpeed->pageStep();
Chris@0 1814 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
Chris@0 1815 m_playSpeed->setValue(value);
Chris@0 1816 }
Chris@0 1817
Chris@0 1818 void
Chris@0 1819 MainWindow::restoreNormalPlayback()
Chris@0 1820 {
Chris@0 1821 m_playSpeed->setValue(m_playSpeed->defaultValue());
Chris@0 1822 }
Chris@0 1823
justin@157 1824 void
justin@159 1825 MainWindow::audioGainChanged(int position)
justin@159 1826 {
justin@159 1827 float level = m_gainAudio->mappedValue();
justin@159 1828 float gain = powf(10, level / 20.0);
justin@159 1829
justin@159 1830 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
justin@159 1831
justin@159 1832 contextHelpChanged(tr("Audio Gain: %1 dB").arg(position));
justin@159 1833
justin@159 1834 m_analyser->setGain(Analyser::Audio, gain);
justin@159 1835
justin@159 1836 updateMenuStates();
justin@159 1837 }
justin@159 1838
justin@159 1839 void
justin@159 1840 MainWindow::increaseAudioGain()
justin@159 1841 {
justin@159 1842 int value = m_gainAudio->value();
justin@159 1843 value = value + m_gainAudio->pageStep();
justin@159 1844 if (value > m_gainAudio->maximum()) value = m_gainAudio->maximum();
justin@159 1845 m_gainAudio->setValue(value);
justin@159 1846 }
justin@159 1847
justin@159 1848 void
justin@159 1849 MainWindow::decreaseAudioGain()
justin@159 1850 {
justin@159 1851 int value = m_gainAudio->value();
justin@159 1852 value = value - m_gainAudio->pageStep();
justin@159 1853 if (value < m_gainAudio->minimum()) value = m_gainAudio->minimum();
justin@159 1854 m_gainAudio->setValue(value);
justin@159 1855 }
justin@159 1856
justin@159 1857 void
justin@159 1858 MainWindow::restoreNormalAudioGain()
justin@159 1859 {
justin@159 1860 m_gainAudio->setValue(m_gainAudio->defaultValue());
justin@159 1861 }
justin@159 1862
justin@159 1863 void
justin@157 1864 MainWindow::pitchGainChanged(int position)
justin@157 1865 {
Chris@158 1866 float level = m_gainPitch->mappedValue();
Chris@158 1867 float gain = powf(10, level / 20.0);
justin@157 1868
Chris@158 1869 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
justin@157 1870
Chris@158 1871 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position));
justin@157 1872
Chris@158 1873 m_analyser->setGain(Analyser::PitchTrack, gain);
justin@157 1874
justin@157 1875 updateMenuStates();
justin@157 1876 }
justin@157 1877
justin@157 1878 void
justin@157 1879 MainWindow::increasePitchGain()
justin@157 1880 {
justin@157 1881 int value = m_gainPitch->value();
justin@157 1882 value = value + m_gainPitch->pageStep();
justin@157 1883 if (value > m_gainPitch->maximum()) value = m_gainPitch->maximum();
justin@157 1884 m_gainPitch->setValue(value);
justin@157 1885 }
justin@157 1886
justin@157 1887 void
justin@157 1888 MainWindow::decreasePitchGain()
justin@157 1889 {
justin@157 1890 int value = m_gainPitch->value();
justin@157 1891 value = value - m_gainPitch->pageStep();
justin@157 1892 if (value < m_gainPitch->minimum()) value = m_gainPitch->minimum();
justin@157 1893 m_gainPitch->setValue(value);
justin@157 1894 }
justin@157 1895
justin@157 1896 void
justin@157 1897 MainWindow::restoreNormalPitchGain()
justin@157 1898 {
justin@157 1899 m_gainPitch->setValue(m_gainPitch->defaultValue());
justin@157 1900 }
justin@157 1901
Chris@0 1902 void
justin@159 1903 MainWindow::notesGainChanged(int position)
justin@159 1904 {
justin@159 1905 float level = m_gainNotes->mappedValue();
justin@159 1906 float gain = powf(10, level / 20.0);
justin@159 1907
justin@159 1908 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
justin@159 1909
justin@159 1910 contextHelpChanged(tr("Notes Gain: %1 dB").arg(position));
justin@159 1911
justin@159 1912 m_analyser->setGain(Analyser::Notes, gain);
justin@159 1913
justin@159 1914 updateMenuStates();
justin@159 1915 }
justin@159 1916
justin@159 1917 void
justin@159 1918 MainWindow::increaseNotesGain()
justin@159 1919 {
justin@159 1920 int value = m_gainNotes->value();
justin@159 1921 value = value + m_gainNotes->pageStep();
justin@159 1922 if (value > m_gainNotes->maximum()) value = m_gainNotes->maximum();
justin@159 1923 m_gainNotes->setValue(value);
justin@159 1924 }
justin@159 1925
justin@159 1926 void
justin@159 1927 MainWindow::decreaseNotesGain()
justin@159 1928 {
justin@159 1929 int value = m_gainNotes->value();
justin@159 1930 value = value - m_gainNotes->pageStep();
justin@159 1931 if (value < m_gainNotes->minimum()) value = m_gainNotes->minimum();
justin@159 1932 m_gainNotes->setValue(value);
justin@159 1933 }
justin@159 1934
justin@159 1935 void
justin@159 1936 MainWindow::restoreNormalNotesGain()
justin@159 1937 {
justin@159 1938 m_gainNotes->setValue(m_gainNotes->defaultValue());
justin@159 1939 }
justin@159 1940
justin@159 1941 void
justin@160 1942 MainWindow::audioPanChanged(int position)
justin@160 1943 {
justin@160 1944 float level = m_panAudio->mappedValue();
justin@160 1945 float pan = level/100.f;
justin@160 1946
justin@160 1947 cerr << "pan = " << pan << " (" << position << ")" << endl;
justin@160 1948
justin@160 1949 contextHelpChanged(tr("Audio Pan: %1").arg(position));
justin@160 1950
justin@160 1951 m_analyser->setPan(Analyser::Audio, pan);
justin@160 1952
justin@160 1953 updateMenuStates();
justin@160 1954 }
justin@160 1955
justin@160 1956 void
justin@160 1957 MainWindow::increaseAudioPan()
justin@160 1958 {
justin@160 1959 int value = m_panAudio->value();
justin@160 1960 value = value + m_panAudio->pageStep();
justin@160 1961 if (value > m_panAudio->maximum()) value = m_panAudio->maximum();
justin@160 1962 m_panAudio->setValue(value);
justin@160 1963 }
justin@160 1964
justin@160 1965 void
justin@160 1966 MainWindow::decreaseAudioPan()
justin@160 1967 {
justin@160 1968 int value = m_panAudio->value();
justin@160 1969 value = value - m_panAudio->pageStep();
justin@160 1970 if (value < m_panAudio->minimum()) value = m_panAudio->minimum();
justin@160 1971 m_panAudio->setValue(value);
justin@160 1972 }
justin@160 1973
justin@160 1974 void
justin@160 1975 MainWindow::restoreNormalAudioPan()
justin@160 1976 {
justin@160 1977 m_panAudio->setValue(m_panAudio->defaultValue());
justin@160 1978 }
justin@160 1979
justin@160 1980 void
justin@160 1981 MainWindow::pitchPanChanged(int position)
justin@160 1982 {
justin@160 1983 float level = m_panPitch->mappedValue();
justin@160 1984 float pan = level/100.f;
justin@160 1985
justin@160 1986 cerr << "pan = " << pan << " (" << position << ")" << endl;
justin@160 1987
justin@160 1988 contextHelpChanged(tr("Pitch Pan: %1").arg(position));
justin@160 1989
justin@160 1990 m_analyser->setPan(Analyser::PitchTrack, pan);
justin@160 1991
justin@160 1992 updateMenuStates();
justin@160 1993 }
justin@160 1994
justin@160 1995 void
justin@160 1996 MainWindow::increasePitchPan()
justin@160 1997 {
justin@160 1998 int value = m_panPitch->value();
justin@160 1999 value = value + m_panPitch->pageStep();
justin@160 2000 if (value > m_panPitch->maximum()) value = m_panPitch->maximum();
justin@160 2001 m_panPitch->setValue(value);
justin@160 2002 }
justin@160 2003
justin@160 2004 void
justin@160 2005 MainWindow::decreasePitchPan()
justin@160 2006 {
justin@160 2007 int value = m_panPitch->value();
justin@160 2008 value = value - m_panPitch->pageStep();
justin@160 2009 if (value < m_panPitch->minimum()) value = m_panPitch->minimum();
justin@160 2010 m_panPitch->setValue(value);
justin@160 2011 }
justin@160 2012
justin@160 2013 void
justin@160 2014 MainWindow::restoreNormalPitchPan()
justin@160 2015 {
justin@160 2016 m_panPitch->setValue(m_panPitch->defaultValue());
justin@160 2017 }
justin@160 2018
justin@160 2019 void
justin@160 2020 MainWindow::notesPanChanged(int position)
justin@160 2021 {
justin@160 2022 float level = m_panNotes->mappedValue();
justin@160 2023 float pan = level/100.f;
justin@160 2024
justin@160 2025 cerr << "pan = " << pan << " (" << position << ")" << endl;
justin@160 2026
justin@160 2027 contextHelpChanged(tr("Notes Pan: %1").arg(position));
justin@160 2028
justin@160 2029 m_analyser->setPan(Analyser::Notes, pan);
justin@160 2030
justin@160 2031 updateMenuStates();
justin@160 2032 }
justin@160 2033
justin@160 2034 void
justin@160 2035 MainWindow::increaseNotesPan()
justin@160 2036 {
justin@160 2037 int value = m_panNotes->value();
justin@160 2038 value = value + m_panNotes->pageStep();
justin@160 2039 if (value > m_panNotes->maximum()) value = m_panNotes->maximum();
justin@160 2040 m_panNotes->setValue(value);
justin@160 2041 }
justin@160 2042
justin@160 2043 void
justin@160 2044 MainWindow::decreaseNotesPan()
justin@160 2045 {
justin@160 2046 int value = m_panNotes->value();
justin@160 2047 value = value - m_panNotes->pageStep();
justin@160 2048 if (value < m_panNotes->minimum()) value = m_panNotes->minimum();
justin@160 2049 m_panNotes->setValue(value);
justin@160 2050 }
justin@160 2051
justin@160 2052 void
justin@160 2053 MainWindow::restoreNormalNotesPan()
justin@160 2054 {
justin@160 2055 m_panNotes->setValue(m_panNotes->defaultValue());
justin@160 2056 }
justin@160 2057
justin@160 2058 void
Chris@0 2059 MainWindow::updateVisibleRangeDisplay(Pane *p) const
Chris@0 2060 {
Chris@0 2061 if (!getMainModel() || !p) {
Chris@0 2062 return;
Chris@0 2063 }
Chris@0 2064
Chris@0 2065 bool haveSelection = false;
Chris@0 2066 size_t startFrame = 0, endFrame = 0;
Chris@0 2067
Chris@0 2068 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
Chris@0 2069
Chris@0 2070 bool exclusive = false;
Chris@0 2071 Selection s = m_viewManager->getInProgressSelection(exclusive);
Chris@0 2072
Chris@0 2073 if (!s.isEmpty()) {
Chris@0 2074 haveSelection = true;
Chris@0 2075 startFrame = s.getStartFrame();
Chris@0 2076 endFrame = s.getEndFrame();
Chris@0 2077 }
Chris@0 2078 }
Chris@0 2079
Chris@0 2080 if (!haveSelection) {
Chris@0 2081 startFrame = p->getFirstVisibleFrame();
Chris@0 2082 endFrame = p->getLastVisibleFrame();
Chris@0 2083 }
Chris@0 2084
Chris@0 2085 RealTime start = RealTime::frame2RealTime
Chris@0 2086 (startFrame, getMainModel()->getSampleRate());
Chris@0 2087
Chris@0 2088 RealTime end = RealTime::frame2RealTime
Chris@0 2089 (endFrame, getMainModel()->getSampleRate());
Chris@0 2090
Chris@0 2091 RealTime duration = end - start;
Chris@0 2092
Chris@0 2093 QString startStr, endStr, durationStr;
Chris@0 2094 startStr = start.toText(true).c_str();
Chris@0 2095 endStr = end.toText(true).c_str();
Chris@0 2096 durationStr = duration.toText(true).c_str();
Chris@0 2097
Chris@0 2098 if (haveSelection) {
Chris@0 2099 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
Chris@0 2100 .arg(startStr).arg(endStr).arg(durationStr);
Chris@0 2101 } else {
Chris@0 2102 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
Chris@0 2103 .arg(startStr).arg(endStr).arg(durationStr);
Chris@0 2104 }
matthiasm@42 2105
matthiasm@42 2106 // scale Y axis
matthiasm@42 2107 FlexiNoteLayer *fnl = dynamic_cast<FlexiNoteLayer *>(p->getLayer(2));
matthiasm@42 2108 if (fnl) {
matthiasm@42 2109 fnl->setVerticalRangeToNoteRange(p);
matthiasm@42 2110 }
matthiasm@42 2111
Chris@0 2112 statusBar()->showMessage(m_myStatusMessage);
Chris@0 2113 }
Chris@0 2114
Chris@0 2115 void
Chris@0 2116 MainWindow::updatePositionStatusDisplays() const
Chris@0 2117 {
Chris@0 2118 if (!statusBar()->isVisible()) return;
Chris@0 2119
Chris@0 2120 }
Chris@0 2121
Chris@0 2122 void
Chris@0 2123 MainWindow::outputLevelsChanged(float left, float right)
Chris@0 2124 {
Chris@0 2125 m_fader->setPeakLeft(left);
Chris@0 2126 m_fader->setPeakRight(right);
Chris@0 2127 }
Chris@0 2128
Chris@0 2129 void
Chris@0 2130 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
Chris@0 2131 bool willResample)
Chris@0 2132 {
Chris@0 2133 updateDescriptionLabel();
Chris@0 2134 }
Chris@0 2135
Chris@0 2136 void
Chris@0 2137 MainWindow::audioOverloadPluginDisabled()
Chris@0 2138 {
Chris@0 2139 QMessageBox::information
Chris@0 2140 (this, tr("Audio processing overload"),
Chris@0 2141 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
Chris@0 2142 }
Chris@0 2143
Chris@0 2144 void
Chris@0 2145 MainWindow::audioTimeStretchMultiChannelDisabled()
Chris@0 2146 {
Chris@0 2147 static bool shownOnce = false;
Chris@0 2148 if (shownOnce) return;
Chris@0 2149 QMessageBox::information
Chris@0 2150 (this, tr("Audio processing overload"),
Chris@0 2151 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
Chris@0 2152 shownOnce = true;
Chris@0 2153 }
Chris@0 2154
Chris@0 2155 void
Chris@0 2156 MainWindow::layerRemoved(Layer *layer)
Chris@0 2157 {
Chris@0 2158 MainWindowBase::layerRemoved(layer);
Chris@0 2159 }
Chris@0 2160
Chris@0 2161 void
Chris@0 2162 MainWindow::layerInAView(Layer *layer, bool inAView)
Chris@0 2163 {
Chris@0 2164 MainWindowBase::layerInAView(layer, inAView);
Chris@0 2165 }
Chris@0 2166
Chris@0 2167 void
Chris@0 2168 MainWindow::modelAdded(Model *model)
Chris@0 2169 {
Chris@0 2170 MainWindowBase::modelAdded(model);
Chris@3 2171 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
Chris@0 2172 if (dtvm) {
Chris@70 2173 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
Chris@0 2174 }
Chris@0 2175 }
Chris@0 2176
Chris@0 2177 void
Chris@0 2178 MainWindow::modelAboutToBeDeleted(Model *model)
Chris@0 2179 {
Chris@0 2180 MainWindowBase::modelAboutToBeDeleted(model);
Chris@0 2181 }
Chris@0 2182
Chris@0 2183 void
Chris@0 2184 MainWindow::mainModelChanged(WaveFileModel *model)
Chris@0 2185 {
Chris@0 2186 m_panLayer->setModel(model);
Chris@0 2187
Chris@0 2188 MainWindowBase::mainModelChanged(model);
Chris@0 2189
Chris@0 2190 if (m_playTarget) {
Chris@0 2191 connect(m_fader, SIGNAL(valueChanged(float)),
Chris@0 2192 m_playTarget, SLOT(setOutputGain(float)));
Chris@0 2193 }
Chris@72 2194
Chris@72 2195 if (model) {
Chris@72 2196 if (m_paneStack) {
Chris@72 2197 Pane *pane = m_paneStack->getCurrentPane();
Chris@72 2198 if (!pane) {
Chris@72 2199 pane = m_paneStack->addPane();
Chris@131 2200
Chris@131 2201 Pane *selectionStrip = m_paneStack->addPane();
Chris@131 2202 selectionStrip->setFixedHeight(26);
Chris@131 2203 m_document->addLayerToView
Chris@131 2204 (selectionStrip,
Chris@131 2205 m_document->createMainModelLayer(LayerFactory::TimeRuler));
Chris@131 2206 m_paneStack->sizePanesEqually();
Chris@131 2207
Chris@131 2208 m_viewManager->clearToolModeOverrides();
Chris@131 2209 m_viewManager->setToolModeFor(selectionStrip,
Chris@131 2210 ViewManager::SelectMode);
Chris@72 2211 }
Chris@72 2212 if (pane) {
Chris@140 2213 QString error = m_analyser->newFileLoaded
Chris@72 2214 (m_document, getMainModel(), m_paneStack, pane);
Chris@140 2215 if (error != "") {
Chris@140 2216 QMessageBox::warning
Chris@140 2217 (this,
Chris@140 2218 tr("Failed to analyse audio"),
Chris@140 2219 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
Chris@140 2220 QMessageBox::Ok);
Chris@140 2221 }
Chris@72 2222 }
Chris@72 2223 }
Chris@72 2224 }
Chris@0 2225 }
Chris@0 2226
Chris@0 2227 void
Chris@0 2228 MainWindow::modelGenerationFailed(QString transformName, QString message)
Chris@0 2229 {
Chris@0 2230 if (message != "") {
Chris@0 2231
Chris@0 2232 QMessageBox::warning
Chris@0 2233 (this,
Chris@0 2234 tr("Failed to generate layer"),
Chris@0 2235 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
Chris@0 2236 .arg(transformName).arg(message),
Chris@0 2237 QMessageBox::Ok);
Chris@0 2238 } else {
Chris@0 2239 QMessageBox::warning
Chris@0 2240 (this,
Chris@0 2241 tr("Failed to generate layer"),
Chris@0 2242 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 2243 .arg(transformName),
Chris@0 2244 QMessageBox::Ok);
Chris@0 2245 }
Chris@0 2246 }
Chris@0 2247
Chris@0 2248 void
Chris@0 2249 MainWindow::modelGenerationWarning(QString transformName, QString message)
Chris@0 2250 {
Chris@0 2251 QMessageBox::warning
Chris@0 2252 (this, tr("Warning"), message, QMessageBox::Ok);
Chris@0 2253 }
Chris@0 2254
Chris@0 2255 void
Chris@0 2256 MainWindow::modelRegenerationFailed(QString layerName,
Chris@0 2257 QString transformName, QString message)
Chris@0 2258 {
Chris@0 2259 if (message != "") {
Chris@0 2260
Chris@0 2261 QMessageBox::warning
Chris@0 2262 (this,
Chris@0 2263 tr("Failed to regenerate layer"),
Chris@0 2264 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 2265 .arg(layerName).arg(transformName).arg(message),
Chris@0 2266 QMessageBox::Ok);
Chris@0 2267 } else {
Chris@0 2268 QMessageBox::warning
Chris@0 2269 (this,
Chris@0 2270 tr("Failed to regenerate layer"),
Chris@0 2271 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 2272 .arg(layerName).arg(transformName),
Chris@0 2273 QMessageBox::Ok);
Chris@0 2274 }
Chris@0 2275 }
Chris@0 2276
Chris@0 2277 void
Chris@0 2278 MainWindow::modelRegenerationWarning(QString layerName,
Chris@0 2279 QString transformName, QString message)
Chris@0 2280 {
Chris@0 2281 QMessageBox::warning
Chris@0 2282 (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 2283 }
Chris@0 2284
Chris@0 2285 void
Chris@0 2286 MainWindow::alignmentFailed(QString transformName, QString message)
Chris@0 2287 {
Chris@0 2288 QMessageBox::warning
Chris@0 2289 (this,
Chris@0 2290 tr("Failed to calculate alignment"),
Chris@0 2291 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
Chris@0 2292 .arg(transformName).arg(message),
Chris@0 2293 QMessageBox::Ok);
Chris@0 2294 }
Chris@0 2295
Chris@0 2296 void
Chris@0 2297 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
Chris@0 2298 {
Chris@70 2299 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
Chris@0 2300 m_paneStack->setCurrentPane(pane);
Chris@0 2301 m_rightButtonMenu->popup(position);
Chris@0 2302 }
Chris@0 2303
Chris@0 2304 void
Chris@0 2305 MainWindow::handleOSCMessage(const OSCMessage &message)
Chris@0 2306 {
Chris@70 2307 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
Chris@0 2308 }
Chris@0 2309
Chris@0 2310 void
Chris@0 2311 MainWindow::mouseEnteredWidget()
Chris@0 2312 {
Chris@3 2313 QWidget *w = qobject_cast<QWidget *>(sender());
Chris@0 2314 if (!w) return;
Chris@0 2315
Chris@0 2316 if (w == m_fader) {
Chris@0 2317 contextHelpChanged(tr("Adjust the master playback level"));
Chris@0 2318 } else if (w == m_playSpeed) {
Chris@0 2319 contextHelpChanged(tr("Adjust the master playback speed"));
Chris@0 2320 } else if (w == m_playSharpen && w->isEnabled()) {
Chris@0 2321 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
Chris@0 2322 } else if (w == m_playMono && w->isEnabled()) {
Chris@0 2323 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
Chris@0 2324 }
Chris@0 2325 }
Chris@0 2326
Chris@0 2327 void
Chris@0 2328 MainWindow::mouseLeftWidget()
Chris@0 2329 {
Chris@0 2330 contextHelpChanged("");
Chris@0 2331 }
Chris@0 2332
Chris@0 2333 void
Chris@0 2334 MainWindow::website()
Chris@0 2335 {
Chris@4 2336 //!!! todo: URL!
Chris@4 2337 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
Chris@0 2338 }
Chris@0 2339
Chris@0 2340 void
Chris@0 2341 MainWindow::help()
Chris@0 2342 {
Chris@4 2343 //!!! todo: help URL!
Chris@4 2344 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
Chris@0 2345 }
Chris@0 2346
Chris@0 2347 void
Chris@0 2348 MainWindow::about()
Chris@0 2349 {
Chris@0 2350 bool debug = false;
Chris@0 2351 QString version = "(unknown version)";
Chris@0 2352
Chris@0 2353 #ifdef BUILD_DEBUG
Chris@0 2354 debug = true;
Chris@0 2355 #endif
Chris@0 2356 version = tr("Release %1").arg(TONY_VERSION);
Chris@0 2357
Chris@0 2358 QString aboutText;
Chris@0 2359
Chris@0 2360 aboutText += tr("<h3>About Tony</h3>");
Chris@0 2361 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
Chris@0 2362 aboutText += tr("<p>%1 : %2 configuration</p>")
Chris@0 2363 .arg(version)
Chris@0 2364 .arg(debug ? tr("Debug") : tr("Release"));
Chris@0 2365
Chris@0 2366 aboutText +=
Chris@90 2367 "<p>Copyright &copy; 2005&ndash;2013 Chris Cannam, Matthias Mauch, George Fazekas, and Queen Mary University of London.</p>"
Chris@90 2368 "<p>This program is free software; you can redistribute it and/or "
Chris@90 2369 "modify it under the terms of the GNU General Public License as "
Chris@90 2370 "published by the Free Software Foundation; either version 2 of the "
Chris@0 2371 "License, or (at your option) any later version.<br>See the file "
Chris@0 2372 "COPYING included with this distribution for more information.</p>";
Chris@0 2373
Chris@0 2374 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
Chris@0 2375 }
Chris@0 2376
Chris@0 2377 void
Chris@0 2378 MainWindow::keyReference()
Chris@0 2379 {
Chris@0 2380 m_keyReference->show();
Chris@0 2381 }
Chris@0 2382
Chris@0 2383