annotate main/MainWindow.cpp @ 280:5dbbf539fda9

* Update to new-line vamp plugin sdk
author Chris Cannam
date Fri, 07 Nov 2008 17:31:06 +0000
parents 7dfaaead2ba4
children b9c35cbfb39c
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 Sonic Visualiser
Chris@0 5 An audio file viewer and annotation editor.
Chris@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@200 7 This file copyright 2006-2007 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@144 16 #include "../version.h"
Chris@0 17
Chris@0 18 #include "MainWindow.h"
Chris@0 19 #include "PreferencesDialog.h"
Chris@0 20
Chris@1 21 #include "view/Pane.h"
Chris@1 22 #include "view/PaneStack.h"
Chris@1 23 #include "data/model/WaveFileModel.h"
Chris@1 24 #include "data/model/SparseOneDimensionalModel.h"
Chris@185 25 #include "data/model/NoteModel.h"
Chris@189 26 #include "data/model/Labeller.h"
Chris@222 27 #include "data/osc/OSCQueue.h"
Chris@216 28 #include "framework/Document.h"
Chris@1 29 #include "view/ViewManager.h"
Chris@0 30 #include "base/Preferences.h"
Chris@0 31 #include "layer/WaveformLayer.h"
Chris@0 32 #include "layer/TimeRulerLayer.h"
Chris@0 33 #include "layer/TimeInstantLayer.h"
Chris@0 34 #include "layer/TimeValueLayer.h"
Chris@0 35 #include "layer/Colour3DPlotLayer.h"
Chris@95 36 #include "layer/SliceLayer.h"
Chris@95 37 #include "layer/SliceableLayer.h"
Chris@193 38 #include "layer/ImageLayer.h"
Chris@0 39 #include "widgets/Fader.h"
Chris@65 40 #include "view/Overview.h"
Chris@0 41 #include "widgets/PropertyBox.h"
Chris@0 42 #include "widgets/PropertyStack.h"
Chris@0 43 #include "widgets/AudioDial.h"
Chris@168 44 #include "widgets/IconLoader.h"
Chris@219 45 #include "widgets/LayerTreeDialog.h"
Chris@0 46 #include "widgets/ListInputDialog.h"
Chris@36 47 #include "widgets/SubdividingMenu.h"
Chris@90 48 #include "widgets/NotifyingPushButton.h"
Chris@162 49 #include "widgets/KeyReference.h"
Chris@273 50 #include "widgets/TransformFinder.h"
Chris@192 51 #include "widgets/LabelCounterInputDialog.h"
Chris@0 52 #include "audioio/AudioCallbackPlaySource.h"
Chris@0 53 #include "audioio/AudioCallbackPlayTarget.h"
Chris@0 54 #include "audioio/AudioTargetFactory.h"
Chris@59 55 #include "audioio/PlaySpeedRangeMapper.h"
Chris@1 56 #include "data/fileio/DataFileReaderFactory.h"
Chris@180 57 #include "data/fileio/PlaylistFileReader.h"
Chris@1 58 #include "data/fileio/WavFileWriter.h"
Chris@1 59 #include "data/fileio/CSVFileWriter.h"
Chris@185 60 #include "data/fileio/MIDIFileWriter.h"
Chris@1 61 #include "data/fileio/BZipFileDevice.h"
Chris@198 62 #include "data/fileio/FileSource.h"
Chris@91 63 #include "data/fft/FFTDataServer.h"
Chris@1 64 #include "base/RecentFiles.h"
Chris@249 65 #include "transform/TransformFactory.h"
Chris@249 66 #include "transform/ModelTransformerFactory.h"
Chris@0 67 #include "base/PlayParameterRepository.h"
Chris@0 68 #include "base/XmlExportable.h"
Chris@248 69 #include "widgets/CommandHistory.h"
Chris@0 70 #include "base/Profiler.h"
Chris@0 71 #include "base/Clipboard.h"
Chris@165 72 #include "base/UnitDatabase.h"
Chris@248 73 #include "layer/ColourDatabase.h"
Chris@265 74 #include "widgets/ModelDataTableDialog.h"
Chris@0 75
Chris@276 76 #include "rdf/PluginRDFIndexer.h" //!!!
Chris@276 77
Chris@0 78 // For version information
Chris@280 79 #include <vamp/vamp.h>
Chris@280 80 #include <vamp-hostsdk/PluginBase.h>
Chris@0 81 #include "plugin/api/ladspa.h"
Chris@0 82 #include "plugin/api/dssi.h"
Chris@0 83
Chris@0 84 #include <QApplication>
Chris@0 85 #include <QMessageBox>
Chris@0 86 #include <QGridLayout>
Chris@0 87 #include <QLabel>
Chris@0 88 #include <QAction>
Chris@0 89 #include <QMenuBar>
Chris@0 90 #include <QToolBar>
Chris@0 91 #include <QInputDialog>
Chris@0 92 #include <QStatusBar>
Chris@0 93 #include <QTreeView>
Chris@0 94 #include <QFile>
Chris@88 95 #include <QFileInfo>
Chris@88 96 #include <QDir>
Chris@0 97 #include <QTextStream>
Chris@0 98 #include <QProcess>
Chris@7 99 #include <QShortcut>
Chris@5 100 #include <QSettings>
Chris@11 101 #include <QDateTime>
Chris@11 102 #include <QProcess>
Chris@16 103 #include <QCheckBox>
Chris@55 104 #include <QRegExp>
Chris@158 105 #include <QScrollArea>
Chris@0 106
Chris@0 107 #include <iostream>
Chris@0 108 #include <cstdio>
Chris@0 109 #include <errno.h>
Chris@0 110
Chris@0 111 using std::cerr;
Chris@0 112 using std::endl;
Chris@0 113
Chris@33 114 using std::vector;
Chris@33 115 using std::map;
Chris@33 116 using std::set;
Chris@33 117
Chris@0 118
Chris@70 119 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
Chris@200 120 MainWindowBase(withAudioOutput, withOSCSupport),
Chris@65 121 m_overview(0),
Chris@0 122 m_mainMenusCreated(false),
Chris@0 123 m_paneMenu(0),
Chris@0 124 m_layerMenu(0),
Chris@34 125 m_transformsMenu(0),
Chris@155 126 m_playbackMenu(0),
Chris@0 127 m_existingLayersMenu(0),
Chris@95 128 m_sliceMenu(0),
Chris@34 129 m_recentFilesMenu(0),
Chris@211 130 m_recentTransformsMenu(0),
Chris@0 131 m_rightButtonMenu(0),
Chris@0 132 m_rightButtonLayerMenu(0),
Chris@211 133 m_rightButtonTransformsMenu(0),
Chris@155 134 m_rightButtonPlaybackMenu(0),
Chris@207 135 m_soloAction(0),
Chris@207 136 m_soloModified(false),
Chris@207 137 m_prevSolo(false),
Chris@265 138 m_rwdStartAction(0),
Chris@265 139 m_rwdAction(0),
Chris@155 140 m_ffwdAction(0),
Chris@265 141 m_ffwdEndAction(0),
Chris@265 142 m_playAction(0),
Chris@265 143 m_playSelectionAction(0),
Chris@265 144 m_playLoopAction(0),
Chris@239 145 m_playControlsSpacer(0),
Chris@239 146 m_playControlsWidth(0),
Chris@162 147 m_preferencesDialog(0),
Chris@219 148 m_layerTreeDialog(0),
Chris@162 149 m_keyReference(new KeyReference())
Chris@0 150 {
Chris@253 151 Profiler profiler("MainWindow::MainWindow");
Chris@253 152
Chris@0 153 setWindowTitle(tr("Sonic Visualiser"));
Chris@0 154
Chris@165 155 UnitDatabase *udb = UnitDatabase::getInstance();
Chris@165 156 udb->registerUnit("Hz");
Chris@165 157 udb->registerUnit("dB");
Chris@165 158 udb->registerUnit("s");
Chris@165 159
Chris@165 160 ColourDatabase *cdb = ColourDatabase::getInstance();
Chris@165 161 cdb->addColour(Qt::black, tr("Black"));
Chris@165 162 cdb->addColour(Qt::darkRed, tr("Red"));
Chris@165 163 cdb->addColour(Qt::darkBlue, tr("Blue"));
Chris@165 164 cdb->addColour(Qt::darkGreen, tr("Green"));
Chris@165 165 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
Chris@165 166 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
Chris@166 167 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
Chris@166 168 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
Chris@166 169 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
Chris@166 170 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
Chris@166 171 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
Chris@166 172 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
Chris@0 173
Chris@0 174 QFrame *frame = new QFrame;
Chris@0 175 setCentralWidget(frame);
Chris@0 176
Chris@0 177 QGridLayout *layout = new QGridLayout;
Chris@180 178
Chris@205 179 m_descriptionLabel = new QLabel; //!!! hang on, this is declared in base class -- should be declared and initialised by same class
Chris@0 180
Chris@158 181 QScrollArea *scroll = new QScrollArea(frame);
Chris@158 182 scroll->setWidgetResizable(true);
Chris@158 183 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Chris@159 184 scroll->setFrameShape(QFrame::NoFrame);
Chris@159 185
Chris@159 186 scroll->setWidget(m_paneStack);
Chris@159 187
Chris@65 188 m_overview = new Overview(frame);
Chris@65 189 m_overview->setViewManager(m_viewManager);
Chris@65 190 m_overview->setFixedHeight(40);
Chris@144 191 #ifndef _WIN32
Chris@144 192 // For some reason, the contents of the overview never appear if we
Chris@144 193 // make this setting on Windows. I have no inclination at the moment
Chris@144 194 // to track down the reason why.
Chris@129 195 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
Chris@144 196 #endif
Chris@90 197 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
Chris@116 198 this, SLOT(contextHelpChanged(const QString &)));
Chris@0 199
Chris@0 200 m_panLayer = new WaveformLayer;
Chris@0 201 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
Chris@0 202 m_panLayer->setAggressiveCacheing(true);
Chris@65 203 m_overview->addLayer(m_panLayer);
Chris@174 204
Chris@174 205 if (m_viewManager->getGlobalDarkBackground()) {
Chris@174 206 m_panLayer->setBaseColour
Chris@174 207 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
Chris@174 208 } else {
Chris@174 209 m_panLayer->setBaseColour
Chris@174 210 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
Chris@200 211 }
Chris@0 212
Chris@0 213 m_fader = new Fader(frame, false);
Chris@90 214 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
Chris@90 215 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
Chris@0 216
Chris@0 217 m_playSpeed = new AudioDial(frame);
Chris@12 218 m_playSpeed->setMinimum(0);
Chris@48 219 m_playSpeed->setMaximum(200);
Chris@25 220 m_playSpeed->setValue(100);
Chris@261 221 m_playSpeed->setFixedWidth(32);
Chris@261 222 m_playSpeed->setFixedHeight(32);
Chris@0 223 m_playSpeed->setNotchesVisible(true);
Chris@25 224 m_playSpeed->setPageStep(10);
Chris@60 225 m_playSpeed->setObjectName(tr("Playback Speedup"));
Chris@25 226 m_playSpeed->setDefaultValue(100);
Chris@59 227 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
Chris@60 228 m_playSpeed->setShowToolTip(true);
Chris@0 229 connect(m_playSpeed, SIGNAL(valueChanged(int)),
Chris@0 230 this, SLOT(playSpeedChanged(int)));
Chris@90 231 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
Chris@90 232 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
Chris@90 233
Chris@168 234 IconLoader il;
Chris@168 235
Chris@21 236 QSettings settings;
Chris@21 237 settings.beginGroup("MainWindow");
Chris@21 238 settings.endGroup();
Chris@21 239
Chris@239 240 m_playControlsSpacer = new QFrame;
Chris@239 241
Chris@129 242 layout->setSpacing(4);
Chris@159 243 layout->addWidget(scroll, 0, 0, 1, 5);
Chris@239 244 layout->addWidget(m_overview, 1, 1);
Chris@239 245 layout->addWidget(m_playControlsSpacer, 1, 2);
Chris@239 246 layout->addWidget(m_playSpeed, 1, 3);
Chris@239 247 layout->addWidget(m_fader, 1, 4);
Chris@239 248
Chris@239 249 m_playControlsWidth =
Chris@240 250 m_fader->width() + m_playSpeed->width() + layout->spacing() * 2;
Chris@239 251
Chris@239 252 layout->setColumnMinimumWidth(0, 14);
Chris@239 253 layout->setColumnStretch(0, 0);
Chris@239 254
Chris@239 255 m_paneStack->setPropertyStackMinWidth(m_playControlsWidth
Chris@239 256 + 2 + layout->spacing());
Chris@239 257 m_playControlsSpacer->setFixedSize(QSize(2, 2));
Chris@239 258
Chris@239 259 layout->setColumnStretch(1, 10);
Chris@239 260
Chris@239 261 connect(m_paneStack, SIGNAL(propertyStacksResized(int)),
Chris@239 262 this, SLOT(propertyStacksResized(int)));
Chris@16 263
Chris@0 264 frame->setLayout(layout);
Chris@0 265
Chris@0 266 setupMenus();
Chris@0 267 setupToolbars();
Chris@155 268 setupHelpMenu();
Chris@0 269
Chris@90 270 statusBar();
Chris@0 271
Chris@0 272 newSession();
Chris@0 273 }
Chris@0 274
Chris@0 275 MainWindow::~MainWindow()
Chris@0 276 {
Chris@162 277 delete m_keyReference;
Chris@163 278 delete m_preferencesDialog;
Chris@219 279 delete m_layerTreeDialog;
Chris@0 280 Profiles::getInstance()->dump();
Chris@0 281 }
Chris@0 282
Chris@81 283 void
Chris@0 284 MainWindow::setupMenus()
Chris@0 285 {
Chris@0 286 if (!m_mainMenusCreated) {
Chris@0 287 m_rightButtonMenu = new QMenu();
Chris@104 288
Chris@104 289 // No -- we don't want tear-off enabled on the right-button
Chris@104 290 // menu. If it is enabled, then simply right-clicking and
Chris@104 291 // releasing will pop up the menu, activate the tear-off, and
Chris@104 292 // leave the torn-off menu window in front of the main window.
Chris@104 293 // That isn't desirable. I'm not sure it ever would be, in a
Chris@104 294 // context menu -- perhaps technically a Qt bug?
Chris@104 295 // m_rightButtonMenu->setTearOffEnabled(true);
Chris@0 296 }
Chris@0 297
Chris@0 298 if (m_rightButtonLayerMenu) {
Chris@0 299 m_rightButtonLayerMenu->clear();
Chris@0 300 } else {
Chris@0 301 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer"));
Chris@97 302 m_rightButtonLayerMenu->setTearOffEnabled(true);
Chris@0 303 m_rightButtonMenu->addSeparator();
Chris@0 304 }
Chris@0 305
Chris@211 306 if (m_rightButtonTransformsMenu) {
Chris@211 307 m_rightButtonTransformsMenu->clear();
Chris@34 308 } else {
Chris@211 309 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform"));
Chris@211 310 m_rightButtonTransformsMenu->setTearOffEnabled(true);
Chris@34 311 m_rightButtonMenu->addSeparator();
Chris@34 312 }
Chris@34 313
Chris@0 314 if (!m_mainMenusCreated) {
Chris@0 315 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
Chris@0 316 m_rightButtonMenu->addSeparator();
Chris@66 317 }
Chris@66 318
Chris@66 319 setupFileMenu();
Chris@66 320 setupEditMenu();
Chris@66 321 setupViewMenu();
Chris@66 322 setupPaneAndLayerMenus();
Chris@211 323 setupTransformsMenu();
Chris@66 324
Chris@66 325 m_mainMenusCreated = true;
Chris@66 326 }
Chris@66 327
Chris@66 328 void
Chris@66 329 MainWindow::setupFileMenu()
Chris@66 330 {
Chris@66 331 if (m_mainMenusCreated) return;
Chris@66 332
Chris@66 333 QMenu *menu = menuBar()->addMenu(tr("&File"));
Chris@97 334 menu->setTearOffEnabled(true);
Chris@66 335 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
Chris@66 336
Chris@162 337 m_keyReference->setCategory(tr("File and Session Management"));
Chris@162 338
Chris@168 339 IconLoader il;
Chris@168 340
Chris@168 341 QIcon icon = il.load("filenew");
Chris@168 342 icon.addPixmap(il.loadPixmap("filenew-22"));
Chris@66 343 QAction *action = new QAction(icon, tr("&New Session"), this);
Chris@66 344 action->setShortcut(tr("Ctrl+N"));
Chris@90 345 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one"));
Chris@66 346 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
Chris@162 347 m_keyReference->registerShortcut(action);
Chris@66 348 menu->addAction(action);
Chris@66 349 toolbar->addAction(action);
Chris@138 350
Chris@168 351 icon = il.load("fileopensession");
Chris@66 352 action = new QAction(icon, tr("&Open Session..."), this);
Chris@66 353 action->setShortcut(tr("Ctrl+O"));
Chris@66 354 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file"));
Chris@66 355 connect(action, SIGNAL(triggered()), this, SLOT(openSession()));
Chris@162 356 m_keyReference->registerShortcut(action);
Chris@66 357 menu->addAction(action);
Chris@66 358
Chris@168 359 icon = il.load("fileopen");
Chris@168 360 icon.addPixmap(il.loadPixmap("fileopen-22"));
Chris@138 361
Chris@66 362 action = new QAction(icon, tr("&Open..."), this);
Chris@66 363 action->setStatusTip(tr("Open a session file, audio file, or layer"));
Chris@66 364 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
Chris@66 365 toolbar->addAction(action);
Chris@66 366
Chris@168 367 icon = il.load("filesave");
Chris@168 368 icon.addPixmap(il.loadPixmap("filesave-22"));
Chris@66 369 action = new QAction(icon, tr("&Save Session"), this);
Chris@66 370 action->setShortcut(tr("Ctrl+S"));
Chris@66 371 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file"));
Chris@66 372 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
Chris@66 373 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
Chris@162 374 m_keyReference->registerShortcut(action);
Chris@66 375 menu->addAction(action);
Chris@66 376 toolbar->addAction(action);
Chris@0 377
Chris@168 378 icon = il.load("filesaveas");
Chris@168 379 icon.addPixmap(il.loadPixmap("filesaveas-22"));
Chris@66 380 action = new QAction(icon, tr("Save Session &As..."), this);
Chris@66 381 action->setStatusTip(tr("Save the current session into a new Sonic Visualiser session file"));
Chris@66 382 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
Chris@66 383 menu->addAction(action);
Chris@66 384 toolbar->addAction(action);
Chris@66 385
Chris@66 386 menu->addSeparator();
Chris@66 387
Chris@168 388 icon = il.load("fileopenaudio");
Chris@138 389 action = new QAction(icon, tr("&Import Audio File..."), this);
Chris@66 390 action->setShortcut(tr("Ctrl+I"));
Chris@66 391 action->setStatusTip(tr("Import an existing audio file"));
Chris@66 392 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
Chris@162 393 m_keyReference->registerShortcut(action);
Chris@66 394 menu->addAction(action);
Chris@66 395
Chris@66 396 action = new QAction(tr("Import Secondary Audio File..."), this);
Chris@66 397 action->setShortcut(tr("Ctrl+Shift+I"));
Chris@66 398 action->setStatusTip(tr("Import an extra audio file as a separate layer"));
Chris@66 399 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
Chris@66 400 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
Chris@162 401 m_keyReference->registerShortcut(action);
Chris@66 402 menu->addAction(action);
Chris@66 403
Chris@66 404 action = new QAction(tr("&Export Audio File..."), this);
Chris@66 405 action->setStatusTip(tr("Export selection as an audio file"));
Chris@66 406 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
Chris@66 407 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
Chris@66 408 menu->addAction(action);
Chris@66 409
Chris@66 410 menu->addSeparator();
Chris@66 411
Chris@66 412 action = new QAction(tr("Import Annotation &Layer..."), this);
Chris@66 413 action->setShortcut(tr("Ctrl+L"));
Chris@66 414 action->setStatusTip(tr("Import layer data from an existing file"));
Chris@66 415 connect(action, SIGNAL(triggered()), this, SLOT(importLayer()));
Chris@66 416 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@162 417 m_keyReference->registerShortcut(action);
Chris@66 418 menu->addAction(action);
Chris@66 419
Chris@66 420 action = new QAction(tr("Export Annotation Layer..."), this);
Chris@66 421 action->setStatusTip(tr("Export layer data to a file"));
Chris@66 422 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer()));
Chris@66 423 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@66 424 menu->addAction(action);
Chris@66 425
Chris@66 426 menu->addSeparator();
Chris@86 427
Chris@121 428 action = new QAction(tr("Export Image File..."), this);
Chris@121 429 action->setStatusTip(tr("Export a single pane to an image file"));
Chris@121 430 connect(action, SIGNAL(triggered()), this, SLOT(exportImage()));
Chris@121 431 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
Chris@121 432 menu->addAction(action);
Chris@121 433
Chris@121 434 menu->addSeparator();
Chris@121 435
Chris@86 436 action = new QAction(tr("Open Lo&cation..."), this);
Chris@86 437 action->setShortcut(tr("Ctrl+Shift+O"));
Chris@86 438 action->setStatusTip(tr("Open or import a file from a remote URL"));
Chris@86 439 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
Chris@162 440 m_keyReference->registerShortcut(action);
Chris@86 441 menu->addAction(action);
Chris@86 442
Chris@86 443 menu->addSeparator();
Chris@86 444
Chris@66 445 m_recentFilesMenu = menu->addMenu(tr("&Recent Files"));
Chris@97 446 m_recentFilesMenu->setTearOffEnabled(true);
Chris@66 447 setupRecentFilesMenu();
Chris@66 448 connect(&m_recentFiles, SIGNAL(recentChanged()),
Chris@66 449 this, SLOT(setupRecentFilesMenu()));
Chris@66 450
Chris@66 451 menu->addSeparator();
Chris@66 452 action = new QAction(tr("&Preferences..."), this);
Chris@66 453 action->setStatusTip(tr("Adjust the application preferences"));
Chris@66 454 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
Chris@66 455 menu->addAction(action);
Chris@0 456
Chris@66 457 menu->addSeparator();
Chris@168 458 action = new QAction(il.load("exit"),
Chris@66 459 tr("&Quit"), this);
Chris@66 460 action->setShortcut(tr("Ctrl+Q"));
Chris@90 461 action->setStatusTip(tr("Exit Sonic Visualiser"));
Chris@66 462 connect(action, SIGNAL(triggered()), this, SLOT(close()));
Chris@162 463 m_keyReference->registerShortcut(action);
Chris@66 464 menu->addAction(action);
Chris@66 465 }
Chris@66 466
Chris@66 467 void
Chris@66 468 MainWindow::setupEditMenu()
Chris@66 469 {
Chris@66 470 if (m_mainMenusCreated) return;
Chris@66 471
Chris@66 472 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
Chris@97 473 menu->setTearOffEnabled(true);
Chris@66 474 CommandHistory::getInstance()->registerMenu(menu);
Chris@66 475
Chris@162 476 m_keyReference->setCategory(tr("Editing"));
Chris@162 477
Chris@66 478 menu->addSeparator();
Chris@66 479
Chris@168 480 IconLoader il;
Chris@168 481
Chris@168 482 QAction *action = new QAction(il.load("editcut"),
Chris@66 483 tr("Cu&t"), this);
Chris@66 484 action->setShortcut(tr("Ctrl+X"));
Chris@90 485 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard"));
Chris@66 486 connect(action, SIGNAL(triggered()), this, SLOT(cut()));
Chris@66 487 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
Chris@162 488 m_keyReference->registerShortcut(action);
Chris@66 489 menu->addAction(action);
Chris@66 490 m_rightButtonMenu->addAction(action);
Chris@66 491
Chris@168 492 action = new QAction(il.load("editcopy"),
Chris@66 493 tr("&Copy"), this);
Chris@66 494 action->setShortcut(tr("Ctrl+C"));
Chris@90 495 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard"));
Chris@66 496 connect(action, SIGNAL(triggered()), this, SLOT(copy()));
Chris@66 497 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool)));
Chris@162 498 m_keyReference->registerShortcut(action);
Chris@66 499 menu->addAction(action);
Chris@66 500 m_rightButtonMenu->addAction(action);
Chris@66 501
Chris@168 502 action = new QAction(il.load("editpaste"),
Chris@66 503 tr("&Paste"), this);
Chris@66 504 action->setShortcut(tr("Ctrl+V"));
Chris@90 505 action->setStatusTip(tr("Paste from the clipboard to the current layer"));
Chris@66 506 connect(action, SIGNAL(triggered()), this, SLOT(paste()));
Chris@66 507 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool)));
Chris@162 508 m_keyReference->registerShortcut(action);
Chris@66 509 menu->addAction(action);
Chris@66 510 m_rightButtonMenu->addAction(action);
Chris@66 511
Chris@164 512 m_deleteSelectedAction = new QAction(tr("&Delete Selected Items"), this);
Chris@164 513 m_deleteSelectedAction->setShortcut(tr("Del"));
Chris@164 514 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
Chris@164 515 connect(m_deleteSelectedAction, SIGNAL(triggered()), this, SLOT(deleteSelected()));
Chris@164 516 connect(this, SIGNAL(canDeleteSelection(bool)), m_deleteSelectedAction, SLOT(setEnabled(bool)));
Chris@164 517 m_keyReference->registerShortcut(m_deleteSelectedAction);
Chris@164 518 menu->addAction(m_deleteSelectedAction);
Chris@164 519 m_rightButtonMenu->addAction(m_deleteSelectedAction);
Chris@66 520
Chris@66 521 menu->addSeparator();
Chris@66 522 m_rightButtonMenu->addSeparator();
Chris@162 523
Chris@162 524 m_keyReference->setCategory(tr("Selection"));
Chris@162 525
Chris@66 526 action = new QAction(tr("Select &All"), this);
Chris@66 527 action->setShortcut(tr("Ctrl+A"));
Chris@90 528 action->setStatusTip(tr("Select the whole duration of the current session"));
Chris@66 529 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
Chris@66 530 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
Chris@162 531 m_keyReference->registerShortcut(action);
Chris@66 532 menu->addAction(action);
Chris@66 533 m_rightButtonMenu->addAction(action);
Chris@0 534
Chris@66 535 action = new QAction(tr("Select &Visible Range"), this);
Chris@66 536 action->setShortcut(tr("Ctrl+Shift+A"));
Chris@90 537 action->setStatusTip(tr("Select the time range corresponding to the current window width"));
Chris@66 538 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible()));
Chris@66 539 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
Chris@162 540 m_keyReference->registerShortcut(action);
Chris@66 541 menu->addAction(action);
Chris@0 542
Chris@66 543 action = new QAction(tr("Select to &Start"), this);
Chris@66 544 action->setShortcut(tr("Shift+Left"));
Chris@90 545 action->setStatusTip(tr("Select from the start of the session to the current playback position"));
Chris@66 546 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart()));
Chris@66 547 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
Chris@162 548 m_keyReference->registerShortcut(action);
Chris@66 549 menu->addAction(action);
Chris@0 550
Chris@66 551 action = new QAction(tr("Select to &End"), this);
Chris@66 552 action->setShortcut(tr("Shift+Right"));
Chris@90 553 action->setStatusTip(tr("Select from the current playback position to the end of the session"));
Chris@66 554 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd()));
Chris@66 555 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
Chris@162 556 m_keyReference->registerShortcut(action);
Chris@66 557 menu->addAction(action);
Chris@66 558
Chris@66 559 action = new QAction(tr("C&lear Selection"), this);
Chris@66 560 action->setShortcut(tr("Esc"));
Chris@90 561 action->setStatusTip(tr("Clear the selection"));
Chris@66 562 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection()));
Chris@66 563 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
Chris@162 564 m_keyReference->registerShortcut(action);
Chris@66 565 menu->addAction(action);
Chris@66 566 m_rightButtonMenu->addAction(action);
Chris@66 567
Chris@66 568 menu->addSeparator();
Chris@66 569
Chris@162 570 m_keyReference->setCategory(tr("Tapping Time Instants"));
Chris@162 571
Chris@66 572 action = new QAction(tr("&Insert Instant at Playback Position"), this);
Chris@66 573 action->setShortcut(tr("Enter"));
Chris@90 574 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary"));
Chris@66 575 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
Chris@66 576 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
Chris@162 577 m_keyReference->registerShortcut(action);
Chris@66 578 menu->addAction(action);
Chris@66 579
Chris@162 580 // Laptop shortcut (no keypad Enter key)
Chris@162 581 QString shortcut(tr(";"));
Chris@162 582 connect(new QShortcut(shortcut, this), SIGNAL(activated()),
Chris@162 583 this, SLOT(insertInstant()));
Chris@162 584 m_keyReference->registerAlternativeShortcut(action, shortcut);
Chris@162 585
Chris@81 586 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
Chris@81 587 action->setShortcut(tr("Shift+Enter"));
Chris@163 588 action->setStatusTip(tr("Insert new time instants at the start and end of the current selected regions, in a new layer if necessary"));
Chris@81 589 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
Chris@81 590 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
Chris@162 591 m_keyReference->registerShortcut(action);
Chris@81 592 menu->addAction(action);
Chris@189 593
Chris@190 594 QMenu *numberingMenu = menu->addMenu(tr("Number New Instants with"));
Chris@225 595 numberingMenu->setTearOffEnabled(true);
Chris@189 596 QActionGroup *numberingGroup = new QActionGroup(this);
Chris@189 597
Chris@189 598 Labeller::TypeNameMap types = m_labeller->getTypeNames();
Chris@189 599 for (Labeller::TypeNameMap::iterator i = types.begin(); i != types.end(); ++i) {
Chris@190 600
Chris@190 601 if (i->first == Labeller::ValueFromLabel ||
Chris@190 602 i->first == Labeller::ValueFromExistingNeighbour) continue;
Chris@190 603
Chris@189 604 action = new QAction(i->second, this);
Chris@189 605 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsNumbering()));
Chris@189 606 action->setCheckable(true);
Chris@189 607 action->setChecked(m_labeller->getType() == i->first);
Chris@189 608 numberingGroup->addAction(action);
Chris@189 609 numberingMenu->addAction(action);
Chris@189 610 m_numberingActions[action] = (int)i->first;
Chris@190 611
Chris@190 612 if (i->first == Labeller::ValueFromTwoLevelCounter) {
Chris@192 613
Chris@190 614 QMenu *cycleMenu = numberingMenu->addMenu(tr("Cycle size"));
Chris@190 615 QActionGroup *cycleGroup = new QActionGroup(this);
Chris@190 616
Chris@229 617 int cycles[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16 };
Chris@200 618 for (int i = 0; i < int(sizeof(cycles)/sizeof(cycles[0])); ++i) {
Chris@190 619 action = new QAction(QString("%1").arg(cycles[i]), this);
Chris@190 620 connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounterCycle()));
Chris@190 621 action->setCheckable(true);
Chris@190 622 action->setChecked(cycles[i] == m_labeller->getCounterCycleSize());
Chris@190 623 cycleGroup->addAction(action);
Chris@190 624 cycleMenu->addAction(action);
Chris@190 625 }
Chris@190 626 }
Chris@190 627
Chris@190 628 if (i->first == Labeller::ValueNone ||
Chris@190 629 i->first == Labeller::ValueFromTwoLevelCounter ||
Chris@190 630 i->first == Labeller::ValueFromRealTime) {
Chris@190 631 numberingMenu->addSeparator();
Chris@190 632 }
Chris@189 633 }
Chris@189 634
Chris@241 635 action = new QAction(tr("Set Numbering Counters..."), this);
Chris@241 636 action->setStatusTip(tr("Set the counters used for counter-based labelling"));
Chris@241 637 connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
Chris@241 638 menu->addAction(action);
Chris@241 639
Chris@241 640 action = new QAction(tr("Renumber Selected Instants"), this);
Chris@241 641 action->setStatusTip(tr("Renumber the selected instants using the current labelling scheme"));
Chris@189 642 connect(action, SIGNAL(triggered()), this, SLOT(renumberInstants()));
Chris@189 643 connect(this, SIGNAL(canRenumberInstants(bool)), action, SLOT(setEnabled(bool)));
Chris@189 644 // m_keyReference->registerShortcut(action);
Chris@189 645 menu->addAction(action);
Chris@66 646 }
Chris@66 647
Chris@66 648 void
Chris@66 649 MainWindow::setupViewMenu()
Chris@66 650 {
Chris@66 651 if (m_mainMenusCreated) return;
Chris@66 652
Chris@168 653 IconLoader il;
Chris@168 654
Chris@90 655 QAction *action = 0;
Chris@90 656
Chris@162 657 m_keyReference->setCategory(tr("Panning and Navigation"));
Chris@162 658
Chris@66 659 QMenu *menu = menuBar()->addMenu(tr("&View"));
Chris@97 660 menu->setTearOffEnabled(true);
Chris@66 661 action = new QAction(tr("Scroll &Left"), this);
Chris@66 662 action->setShortcut(tr("Left"));
Chris@66 663 action->setStatusTip(tr("Scroll the current pane to the left"));
Chris@66 664 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
Chris@66 665 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@162 666 m_keyReference->registerShortcut(action);
Chris@66 667 menu->addAction(action);
Chris@0 668
Chris@66 669 action = new QAction(tr("Scroll &Right"), this);
Chris@66 670 action->setShortcut(tr("Right"));
Chris@66 671 action->setStatusTip(tr("Scroll the current pane to the right"));
Chris@66 672 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
Chris@66 673 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@162 674 m_keyReference->registerShortcut(action);
Chris@66 675 menu->addAction(action);
Chris@0 676
Chris@90 677 action = new QAction(tr("&Jump Left"), this);
Chris@66 678 action->setShortcut(tr("Ctrl+Left"));
Chris@66 679 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
Chris@66 680 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
Chris@66 681 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@162 682 m_keyReference->registerShortcut(action);
Chris@66 683 menu->addAction(action);
Chris@0 684
Chris@90 685 action = new QAction(tr("J&ump Right"), this);
Chris@66 686 action->setShortcut(tr("Ctrl+Right"));
Chris@66 687 action->setStatusTip(tr("Scroll the current pane a big step to the right"));
Chris@66 688 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight()));
Chris@66 689 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
Chris@162 690 m_keyReference->registerShortcut(action);
Chris@66 691 menu->addAction(action);
Chris@66 692
Chris@66 693 menu->addSeparator();
Chris@66 694
Chris@162 695 m_keyReference->setCategory(tr("Zoom"));
Chris@162 696
Chris@168 697 action = new QAction(il.load("zoom-in"),
Chris@66 698 tr("Zoom &In"), this);
Chris@66 699 action->setShortcut(tr("Up"));
Chris@66 700 action->setStatusTip(tr("Increase the zoom level"));
Chris@66 701 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
Chris@66 702 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@162 703 m_keyReference->registerShortcut(action);
Chris@66 704 menu->addAction(action);
Chris@0 705
Chris@168 706 action = new QAction(il.load("zoom-out"),
Chris@66 707 tr("Zoom &Out"), this);
Chris@66 708 action->setShortcut(tr("Down"));
Chris@66 709 action->setStatusTip(tr("Decrease the zoom level"));
Chris@66 710 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
Chris@66 711 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@162 712 m_keyReference->registerShortcut(action);
Chris@66 713 menu->addAction(action);
Chris@0 714
Chris@66 715 action = new QAction(tr("Restore &Default Zoom"), this);
Chris@90 716 action->setStatusTip(tr("Restore the zoom level to the default"));
Chris@66 717 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
Chris@66 718 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@66 719 menu->addAction(action);
Chris@66 720
Chris@168 721 action = new QAction(il.load("zoom-fit"),
Chris@138 722 tr("Zoom to &Fit"), this);
Chris@155 723 action->setShortcut(tr("F"));
Chris@66 724 action->setStatusTip(tr("Zoom to show the whole file"));
Chris@66 725 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
Chris@66 726 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
Chris@162 727 m_keyReference->registerShortcut(action);
Chris@66 728 menu->addAction(action);
Chris@90 729
Chris@90 730 menu->addSeparator();
Chris@90 731
Chris@162 732 m_keyReference->setCategory(tr("Display Features"));
Chris@162 733
Chris@90 734 QActionGroup *overlayGroup = new QActionGroup(this);
Chris@90 735
Chris@90 736 action = new QAction(tr("Show &No Overlays"), this);
Chris@90 737 action->setShortcut(tr("0"));
Chris@90 738 action->setStatusTip(tr("Hide centre indicator, frame times, layer names and scale"));
Chris@90 739 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays()));
Chris@90 740 action->setCheckable(true);
Chris@90 741 action->setChecked(false);
Chris@90 742 overlayGroup->addAction(action);
Chris@162 743 m_keyReference->registerShortcut(action);
Chris@90 744 menu->addAction(action);
Chris@90 745
Chris@90 746 action = new QAction(tr("Show &Minimal Overlays"), this);
Chris@90 747 action->setShortcut(tr("9"));
Chris@90 748 action->setStatusTip(tr("Show centre indicator only"));
Chris@90 749 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays()));
Chris@90 750 action->setCheckable(true);
Chris@90 751 action->setChecked(false);
Chris@90 752 overlayGroup->addAction(action);
Chris@162 753 m_keyReference->registerShortcut(action);
Chris@90 754 menu->addAction(action);
Chris@90 755
Chris@90 756 action = new QAction(tr("Show &Standard Overlays"), this);
Chris@90 757 action->setShortcut(tr("8"));
Chris@90 758 action->setStatusTip(tr("Show centre indicator, frame times and scale"));
Chris@90 759 connect(action, SIGNAL(triggered()), this, SLOT(showStandardOverlays()));
Chris@90 760 action->setCheckable(true);
Chris@90 761 action->setChecked(true);
Chris@90 762 overlayGroup->addAction(action);
Chris@162 763 m_keyReference->registerShortcut(action);
Chris@90 764 menu->addAction(action);
Chris@90 765
Chris@90 766 action = new QAction(tr("Show &All Overlays"), this);
Chris@90 767 action->setShortcut(tr("7"));
Chris@90 768 action->setStatusTip(tr("Show all texts and scale"));
Chris@90 769 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays()));
Chris@90 770 action->setCheckable(true);
Chris@90 771 action->setChecked(false);
Chris@90 772 overlayGroup->addAction(action);
Chris@162 773 m_keyReference->registerShortcut(action);
Chris@90 774 menu->addAction(action);
Chris@7 775
Chris@72 776 menu->addSeparator();
Chris@72 777
Chris@66 778 action = new QAction(tr("Show &Zoom Wheels"), this);
Chris@66 779 action->setShortcut(tr("Z"));
Chris@66 780 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically"));
Chris@66 781 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels()));
Chris@66 782 action->setCheckable(true);
Chris@66 783 action->setChecked(m_viewManager->getZoomWheelsEnabled());
Chris@162 784 m_keyReference->registerShortcut(action);
Chris@66 785 menu->addAction(action);
Chris@72 786
Chris@72 787 action = new QAction(tr("Show Property Bo&xes"), this);
Chris@72 788 action->setShortcut(tr("X"));
Chris@72 789 action->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
Chris@72 790 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
Chris@72 791 action->setCheckable(true);
Chris@72 792 action->setChecked(true);
Chris@162 793 m_keyReference->registerShortcut(action);
Chris@72 794 menu->addAction(action);
Chris@0 795
Chris@90 796 action = new QAction(tr("Show Status &Bar"), this);
Chris@90 797 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
Chris@90 798 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
Chris@90 799 action->setCheckable(true);
Chris@90 800 action->setChecked(true);
Chris@90 801 menu->addAction(action);
Chris@90 802
Chris@90 803 QSettings settings;
Chris@90 804 settings.beginGroup("MainWindow");
Chris@90 805 bool sb = settings.value("showstatusbar", true).toBool();
Chris@90 806 if (!sb) {
Chris@90 807 action->setChecked(false);
Chris@90 808 statusBar()->hide();
Chris@90 809 }
Chris@90 810 settings.endGroup();
Chris@90 811
Chris@66 812 menu->addSeparator();
Chris@66 813
Chris@219 814 action = new QAction(tr("Show La&yer Summary"), this);
Chris@219 815 action->setShortcut(tr("Y"));
Chris@90 816 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session"));
Chris@66 817 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree()));
Chris@162 818 m_keyReference->registerShortcut(action);
Chris@66 819 menu->addAction(action);
Chris@66 820 }
Chris@66 821
Chris@66 822 void
Chris@66 823 MainWindow::setupPaneAndLayerMenus()
Chris@66 824 {
Chris@0 825 if (m_paneMenu) {
Chris@0 826 m_paneActions.clear();
Chris@0 827 m_paneMenu->clear();
Chris@0 828 } else {
Chris@0 829 m_paneMenu = menuBar()->addMenu(tr("&Pane"));
Chris@97 830 m_paneMenu->setTearOffEnabled(true);
Chris@0 831 }
Chris@0 832
Chris@0 833 if (m_layerMenu) {
Chris@0 834 m_layerActions.clear();
Chris@0 835 m_layerMenu->clear();
Chris@0 836 } else {
Chris@0 837 m_layerMenu = menuBar()->addMenu(tr("&Layer"));
Chris@97 838 m_layerMenu->setTearOffEnabled(true);
Chris@0 839 }
Chris@0 840
Chris@66 841 QMenu *menu = m_paneMenu;
Chris@66 842
Chris@168 843 IconLoader il;
Chris@168 844
Chris@162 845 m_keyReference->setCategory(tr("Managing Panes and Layers"));
Chris@162 846
Chris@168 847 QAction *action = new QAction(il.load("pane"), tr("Add &New Pane"), this);
Chris@155 848 action->setShortcut(tr("N"));
Chris@66 849 action->setStatusTip(tr("Add a new pane containing only a time ruler"));
Chris@66 850 connect(action, SIGNAL(triggered()), this, SLOT(addPane()));
Chris@66 851 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool)));
Chris@232 852 m_paneActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
Chris@162 853 m_keyReference->registerShortcut(action);
Chris@66 854 menu->addAction(action);
Chris@66 855
Chris@66 856 menu->addSeparator();
Chris@66 857
Chris@66 858 menu = m_layerMenu;
Chris@66 859
Chris@66 860 // menu->addSeparator();
Chris@66 861
Chris@66 862 LayerFactory::LayerTypeSet emptyLayerTypes =
Chris@66 863 LayerFactory::getInstance()->getValidEmptyLayerTypes();
Chris@66 864
Chris@66 865 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin();
Chris@66 866 i != emptyLayerTypes.end(); ++i) {
Chris@66 867
Chris@66 868 QIcon icon;
Chris@66 869 QString mainText, tipText, channelText;
Chris@66 870 LayerFactory::LayerType type = *i;
Chris@66 871 QString name = LayerFactory::getInstance()->getLayerPresentationName(type);
Chris@66 872
Chris@168 873 icon = il.load(LayerFactory::getInstance()->getLayerIconName(type));
Chris@66 874
Chris@66 875 mainText = tr("Add New %1 Layer").arg(name);
Chris@66 876 tipText = tr("Add a new empty layer of type %1").arg(name);
Chris@66 877
Chris@66 878 action = new QAction(icon, mainText, this);
Chris@66 879 action->setStatusTip(tipText);
Chris@66 880
Chris@66 881 if (type == LayerFactory::Text) {
Chris@155 882 action->setShortcut(tr("T"));
Chris@162 883 m_keyReference->registerShortcut(action);
Chris@66 884 }
Chris@66 885
Chris@66 886 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@66 887 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@232 888 m_layerActions[action] = LayerConfiguration(type);
Chris@66 889 menu->addAction(action);
Chris@66 890 m_rightButtonLayerMenu->addAction(action);
Chris@66 891 }
Chris@66 892
Chris@66 893 m_rightButtonLayerMenu->addSeparator();
Chris@66 894 menu->addSeparator();
Chris@66 895
Chris@66 896 LayerFactory::LayerType backgroundTypes[] = {
Chris@66 897 LayerFactory::Waveform,
Chris@66 898 LayerFactory::Spectrogram,
Chris@66 899 LayerFactory::MelodicRangeSpectrogram,
Chris@66 900 LayerFactory::PeakFrequencySpectrogram,
Chris@66 901 LayerFactory::Spectrum
Chris@66 902 };
Chris@66 903
Chris@66 904 std::vector<Model *> models;
Chris@224 905 if (m_document) models = m_document->getTransformInputModels();
Chris@66 906 bool plural = (models.size() > 1);
Chris@66 907 if (models.empty()) {
Chris@67 908 models.push_back(getMainModel()); // probably 0
Chris@66 909 }
Chris@66 910
Chris@66 911 for (unsigned int i = 0;
Chris@66 912 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
Chris@66 913
Chris@231 914 const int paneMenuType = 0, layerMenuType = 1;
Chris@231 915
Chris@231 916 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) {
Chris@231 917
Chris@231 918 if (menuType == paneMenuType) menu = m_paneMenu;
Chris@66 919 else menu = m_layerMenu;
Chris@66 920
Chris@66 921 QMenu *submenu = 0;
Chris@66 922
Chris@66 923 QIcon icon;
Chris@66 924 QString mainText, shortcutText, tipText, channelText;
Chris@66 925 LayerFactory::LayerType type = backgroundTypes[i];
Chris@66 926 bool mono = true;
Chris@66 927
Chris@66 928 switch (type) {
Chris@66 929
Chris@66 930 case LayerFactory::Waveform:
Chris@168 931 icon = il.load("waveform");
Chris@66 932 mainText = tr("Add &Waveform");
Chris@231 933 if (menuType == paneMenuType) {
Chris@155 934 shortcutText = tr("W");
Chris@66 935 tipText = tr("Add a new pane showing a waveform view");
Chris@66 936 } else {
Chris@66 937 tipText = tr("Add a new layer showing a waveform view");
Chris@66 938 }
Chris@66 939 mono = false;
Chris@66 940 break;
Chris@66 941
Chris@66 942 case LayerFactory::Spectrogram:
Chris@168 943 icon = il.load("spectrogram");
Chris@161 944 mainText = tr("Add Spectro&gram");
Chris@231 945 if (menuType == paneMenuType) {
Chris@155 946 shortcutText = tr("G");
Chris@90 947 tipText = tr("Add a new pane showing a spectrogram");
Chris@66 948 } else {
Chris@90 949 tipText = tr("Add a new layer showing a spectrogram");
Chris@66 950 }
Chris@66 951 break;
Chris@66 952
Chris@66 953 case LayerFactory::MelodicRangeSpectrogram:
Chris@168 954 icon = il.load("spectrogram");
Chris@66 955 mainText = tr("Add &Melodic Range Spectrogram");
Chris@231 956 if (menuType == paneMenuType) {
Chris@155 957 shortcutText = tr("M");
Chris@90 958 tipText = tr("Add a new pane showing a spectrogram set up for an overview of note pitches");
Chris@66 959 } else {
Chris@90 960 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches");
Chris@66 961 }
Chris@66 962 break;
Chris@66 963
Chris@66 964 case LayerFactory::PeakFrequencySpectrogram:
Chris@168 965 icon = il.load("spectrogram");
Chris@155 966 mainText = tr("Add Pea&k Frequency Spectrogram");
Chris@231 967 if (menuType == paneMenuType) {
Chris@155 968 shortcutText = tr("K");
Chris@66 969 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies");
Chris@66 970 } else {
Chris@66 971 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
Chris@66 972 }
Chris@66 973 break;
Chris@66 974
Chris@66 975 case LayerFactory::Spectrum:
Chris@168 976 icon = il.load("spectrum");
Chris@66 977 mainText = tr("Add Spectr&um");
Chris@231 978 if (menuType == paneMenuType) {
Chris@155 979 shortcutText = tr("U");
Chris@66 980 tipText = tr("Add a new pane showing a frequency spectrum");
Chris@66 981 } else {
Chris@66 982 tipText = tr("Add a new layer showing a frequency spectrum");
Chris@66 983 }
Chris@66 984 break;
Chris@66 985
Chris@66 986 default: break;
Chris@66 987 }
Chris@66 988
Chris@66 989 std::vector<Model *> candidateModels;
Chris@231 990 // if (menuType == paneMenuType) {
Chris@66 991 candidateModels = models;
Chris@231 992 // } else {
Chris@231 993 // candidateModels.push_back(0);
Chris@231 994 // }
Chris@66 995
Chris@66 996 for (std::vector<Model *>::iterator mi =
Chris@66 997 candidateModels.begin();
Chris@66 998 mi != candidateModels.end(); ++mi) {
Chris@66 999
Chris@66 1000 Model *model = *mi;
Chris@66 1001
Chris@66 1002 int channels = 0;
Chris@66 1003 if (model) {
Chris@66 1004 DenseTimeValueModel *dtvm =
Chris@66 1005 dynamic_cast<DenseTimeValueModel *>(model);
Chris@66 1006 if (dtvm) channels = dtvm->getChannelCount();
Chris@66 1007 }
Chris@66 1008 if (channels < 1 && getMainModel()) {
Chris@66 1009 channels = getMainModel()->getChannelCount();
Chris@66 1010 }
Chris@66 1011 if (channels < 1) channels = 1;
Chris@66 1012
Chris@66 1013 for (int c = 0; c <= channels; ++c) {
Chris@66 1014
Chris@66 1015 if (c == 1 && channels == 1) continue;
Chris@66 1016 bool isDefault = (c == 0);
Chris@66 1017 bool isOnly = (isDefault && (channels == 1));
Chris@66 1018
Chris@231 1019 // if (menuType == layerMenuType) {
Chris@231 1020 // if (isDefault) isOnly = true;
Chris@231 1021 // else continue;
Chris@231 1022 // }
Chris@231 1023
Chris@231 1024 if (isOnly && (!plural /*|| menuType == layerMenuType*/)) {
Chris@231 1025
Chris@231 1026 // if (menuType == layerMenuType && type != LayerFactory::Waveform) {
Chris@231 1027 // action = new QAction(mainText, this);
Chris@231 1028 // } else {
Chris@67 1029 action = new QAction(icon, mainText, this);
Chris@231 1030 // }
Chris@67 1031
Chris@66 1032 action->setShortcut(shortcutText);
Chris@66 1033 action->setStatusTip(tipText);
Chris@231 1034 if (menuType == paneMenuType) {
Chris@66 1035 connect(action, SIGNAL(triggered()),
Chris@66 1036 this, SLOT(addPane()));
Chris@66 1037 connect(this, SIGNAL(canAddPane(bool)),
Chris@66 1038 action, SLOT(setEnabled(bool)));
Chris@232 1039 m_paneActions[action] = LayerConfiguration(type);
Chris@66 1040 } else {
Chris@66 1041 connect(action, SIGNAL(triggered()),
Chris@66 1042 this, SLOT(addLayer()));
Chris@66 1043 connect(this, SIGNAL(canAddLayer(bool)),
Chris@66 1044 action, SLOT(setEnabled(bool)));
Chris@232 1045 m_layerActions[action] = LayerConfiguration(type);
Chris@66 1046 }
Chris@162 1047 if (shortcutText != "") {
Chris@162 1048 m_keyReference->registerShortcut(action);
Chris@162 1049 }
Chris@66 1050 menu->addAction(action);
Chris@66 1051
Chris@66 1052 } else {
Chris@66 1053
Chris@66 1054 if (!submenu) {
Chris@66 1055 submenu = menu->addMenu(mainText);
Chris@97 1056 submenu->setTearOffEnabled(true);
Chris@67 1057 } else if (isDefault) {
Chris@67 1058 submenu->addSeparator();
Chris@66 1059 }
Chris@66 1060
Chris@66 1061 QString actionText;
Chris@66 1062 if (c == 0) {
Chris@66 1063 if (mono) {
Chris@66 1064 actionText = tr("&All Channels Mixed");
Chris@66 1065 } else {
Chris@66 1066 actionText = tr("&All Channels");
Chris@66 1067 }
Chris@66 1068 } else {
Chris@66 1069 actionText = tr("Channel &%1").arg(c);
Chris@66 1070 }
Chris@66 1071
Chris@66 1072 if (model) {
Chris@66 1073 actionText = tr("%1: %2")
Chris@66 1074 .arg(model->objectName())
Chris@66 1075 .arg(actionText);
Chris@66 1076 }
Chris@67 1077
Chris@67 1078 if (isDefault) {
Chris@67 1079 action = new QAction(icon, actionText, this);
Chris@67 1080 if (!model || model == getMainModel()) {
Chris@162 1081 action->setShortcut(shortcutText);
Chris@67 1082 }
Chris@67 1083 } else {
Chris@67 1084 action = new QAction(actionText, this);
Chris@67 1085 }
Chris@67 1086
Chris@66 1087 action->setStatusTip(tipText);
Chris@66 1088
Chris@231 1089 if (menuType == paneMenuType) {
Chris@66 1090 connect(action, SIGNAL(triggered()),
Chris@66 1091 this, SLOT(addPane()));
Chris@66 1092 connect(this, SIGNAL(canAddPane(bool)),
Chris@66 1093 action, SLOT(setEnabled(bool)));
Chris@66 1094 m_paneActions[action] =
Chris@232 1095 LayerConfiguration(type, model, c - 1);
Chris@66 1096 } else {
Chris@66 1097 connect(action, SIGNAL(triggered()),
Chris@66 1098 this, SLOT(addLayer()));
Chris@66 1099 connect(this, SIGNAL(canAddLayer(bool)),
Chris@66 1100 action, SLOT(setEnabled(bool)));
Chris@232 1101 m_layerActions[action] =
Chris@232 1102 LayerConfiguration(type, model, c - 1);
Chris@66 1103 }
Chris@66 1104
Chris@66 1105 submenu->addAction(action);
Chris@66 1106 }
Chris@66 1107 }
Chris@66 1108 }
Chris@66 1109 }
Chris@66 1110 }
Chris@66 1111
Chris@66 1112 menu = m_paneMenu;
Chris@225 1113 menu->addSeparator();
Chris@225 1114
Chris@225 1115 action = new QAction(tr("Switch to Previous Pane"), this);
Chris@225 1116 action->setShortcut(tr("["));
Chris@225 1117 action->setStatusTip(tr("Make the next pane up in the pane stack current"));
Chris@225 1118 connect(action, SIGNAL(triggered()), this, SLOT(previousPane()));
Chris@225 1119 connect(this, SIGNAL(canSelectPreviousPane(bool)), action, SLOT(setEnabled(bool)));
Chris@225 1120 m_keyReference->registerShortcut(action);
Chris@225 1121 menu->addAction(action);
Chris@225 1122
Chris@225 1123 action = new QAction(tr("Switch to Next Pane"), this);
Chris@225 1124 action->setShortcut(tr("]"));
Chris@225 1125 action->setStatusTip(tr("Make the next pane down in the pane stack current"));
Chris@225 1126 connect(action, SIGNAL(triggered()), this, SLOT(nextPane()));
Chris@225 1127 connect(this, SIGNAL(canSelectNextPane(bool)), action, SLOT(setEnabled(bool)));
Chris@225 1128 m_keyReference->registerShortcut(action);
Chris@225 1129 menu->addAction(action);
Chris@66 1130
Chris@66 1131 menu->addSeparator();
Chris@66 1132
Chris@168 1133 action = new QAction(il.load("editdelete"), tr("&Delete Pane"), this);
Chris@155 1134 action->setShortcut(tr("Ctrl+Shift+D"));
Chris@90 1135 action->setStatusTip(tr("Delete the currently active pane"));
Chris@66 1136 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane()));
Chris@66 1137 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool)));
Chris@162 1138 m_keyReference->registerShortcut(action);
Chris@66 1139 menu->addAction(action);
Chris@66 1140
Chris@66 1141 menu = m_layerMenu;
Chris@66 1142
Chris@168 1143 action = new QAction(il.load("timeruler"), tr("Add &Time Ruler"), this);
Chris@66 1144 action->setStatusTip(tr("Add a new layer showing a time ruler"));
Chris@66 1145 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@66 1146 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@232 1147 m_layerActions[action] = LayerConfiguration(LayerFactory::TimeRuler);
Chris@66 1148 menu->addAction(action);
Chris@66 1149
Chris@66 1150 menu->addSeparator();
Chris@66 1151
Chris@66 1152 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer"));
Chris@97 1153 m_existingLayersMenu->setTearOffEnabled(true);
Chris@66 1154 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu);
Chris@95 1155
Chris@95 1156 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer"));
Chris@97 1157 m_sliceMenu->setTearOffEnabled(true);
Chris@95 1158 m_rightButtonLayerMenu->addMenu(m_sliceMenu);
Chris@95 1159
Chris@95 1160 setupExistingLayersMenus();
Chris@66 1161
Chris@225 1162 /*!!! These don't work correctly -- fix or omit
Chris@225 1163 menu->addSeparator();
Chris@225 1164
Chris@225 1165 action = new QAction(tr("Switch to Previous Layer"), this);
Chris@225 1166 action->setShortcut(tr("{"));
Chris@225 1167 action->setStatusTip(tr("Make the previous layer in the pane current"));
Chris@225 1168 connect(action, SIGNAL(triggered()), this, SLOT(previousLayer()));
Chris@225 1169 connect(this, SIGNAL(canSelectPreviousLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@225 1170 m_keyReference->registerShortcut(action);
Chris@225 1171 menu->addAction(action);
Chris@225 1172
Chris@225 1173 action = new QAction(tr("Switch to Next Layer"), this);
Chris@225 1174 action->setShortcut(tr("}"));
Chris@225 1175 action->setStatusTip(tr("Make the next layer in the pane current"));
Chris@225 1176 connect(action, SIGNAL(triggered()), this, SLOT(nextLayer()));
Chris@225 1177 connect(this, SIGNAL(canSelectNextLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@225 1178 m_keyReference->registerShortcut(action);
Chris@225 1179 menu->addAction(action);
Chris@225 1180 */
Chris@66 1181 m_rightButtonLayerMenu->addSeparator();
Chris@66 1182 menu->addSeparator();
Chris@66 1183
Chris@163 1184 QAction *raction = new QAction(tr("&Rename Layer..."), this);
Chris@163 1185 raction->setShortcut(tr("R"));
Chris@163 1186 raction->setStatusTip(tr("Rename the currently active layer"));
Chris@163 1187 connect(raction, SIGNAL(triggered()), this, SLOT(renameCurrentLayer()));
Chris@163 1188 connect(this, SIGNAL(canRenameLayer(bool)), raction, SLOT(setEnabled(bool)));
Chris@163 1189 menu->addAction(raction);
Chris@163 1190 m_rightButtonLayerMenu->addAction(raction);
Chris@66 1191
Chris@258 1192 QAction *eaction = new QAction(tr("Edit Layer Data"), this);
Chris@258 1193 eaction->setShortcut(tr("E"));
Chris@258 1194 eaction->setStatusTip(tr("Edit the currently active layer as a data grid"));
Chris@258 1195 connect(eaction, SIGNAL(triggered()), this, SLOT(editCurrentLayer()));
Chris@258 1196 connect(this, SIGNAL(canEditLayer(bool)), eaction, SLOT(setEnabled(bool)));
Chris@258 1197 menu->addAction(eaction);
Chris@258 1198 m_rightButtonLayerMenu->addAction(eaction);
Chris@258 1199
Chris@168 1200 action = new QAction(il.load("editdelete"), tr("&Delete Layer"), this);
Chris@155 1201 action->setShortcut(tr("Ctrl+D"));
Chris@66 1202 action->setStatusTip(tr("Delete the currently active layer"));
Chris@66 1203 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer()));
Chris@66 1204 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@162 1205 m_keyReference->registerShortcut(action);
Chris@66 1206 menu->addAction(action);
Chris@66 1207 m_rightButtonLayerMenu->addAction(action);
Chris@163 1208
Chris@163 1209 m_keyReference->registerShortcut(raction); // rename after delete, so delete layer goes next to delete pane
Chris@258 1210 m_keyReference->registerShortcut(eaction); // edit also after delete
Chris@66 1211 }
Chris@66 1212
Chris@66 1213 void
Chris@211 1214 MainWindow::setupTransformsMenu()
Chris@66 1215 {
Chris@34 1216 if (m_transformsMenu) {
Chris@34 1217 m_transformActions.clear();
Chris@34 1218 m_transformActionsReverse.clear();
Chris@34 1219 m_transformsMenu->clear();
Chris@34 1220 } else {
Chris@97 1221 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
Chris@97 1222 m_transformsMenu->setTearOffEnabled(true);
Chris@272 1223 }
Chris@34 1224
Chris@210 1225 TransformList transforms =
Chris@224 1226 TransformFactory::getInstance()->getAllTransformDescriptions();
Chris@274 1227
Chris@276 1228 //!!!
Chris@276 1229
Chris@277 1230 // PluginRDFIndexer::getInstance()->indexURL("http://www.vamp-plugins.org/rdf/plugins/vamp-example-plugins");
Chris@276 1231
Chris@276 1232 // TransformList uninstalled =
Chris@276 1233 // TransformFactory::getInstance()->getUninstalledTransformDescriptions();
Chris@276 1234 // for (int i = 0; i < uninstalled.size(); ++i) {
Chris@276 1235 // std::cerr << "uninstalled transform: " << uninstalled[i].name.toStdString() << std::endl;
Chris@276 1236 // }
Chris@276 1237
Chris@276 1238
Chris@33 1239 vector<QString> types =
Chris@211 1240 TransformFactory::getInstance()->getAllTransformTypes();
Chris@0 1241
Chris@37 1242 map<QString, map<QString, SubdividingMenu *> > categoryMenus;
Chris@37 1243 map<QString, map<QString, SubdividingMenu *> > makerMenus;
Chris@33 1244
Chris@36 1245 map<QString, SubdividingMenu *> byPluginNameMenus;
Chris@33 1246 map<QString, map<QString, QMenu *> > pluginNameMenus;
Chris@33 1247
Chris@37 1248 set<SubdividingMenu *> pendingMenus;
Chris@37 1249
Chris@211 1250 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms"));
Chris@211 1251 m_recentTransformsMenu->setTearOffEnabled(true);
Chris@211 1252 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu);
Chris@211 1253 connect(&m_recentTransforms, SIGNAL(recentChanged()),
Chris@211 1254 this, SLOT(setupRecentTransformsMenu()));
Chris@34 1255
Chris@34 1256 m_transformsMenu->addSeparator();
Chris@211 1257 m_rightButtonTransformsMenu->addSeparator();
Chris@34 1258
Chris@33 1259 for (vector<QString>::iterator i = types.begin(); i != types.end(); ++i) {
Chris@33 1260
Chris@33 1261 if (i != types.begin()) {
Chris@34 1262 m_transformsMenu->addSeparator();
Chris@211 1263 m_rightButtonTransformsMenu->addSeparator();
Chris@33 1264 }
Chris@33 1265
Chris@33 1266 QString byCategoryLabel = tr("%1 by Category").arg(*i);
Chris@37 1267 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel,
Chris@37 1268 20, 40);
Chris@97 1269 byCategoryMenu->setTearOffEnabled(true);
Chris@37 1270 m_transformsMenu->addMenu(byCategoryMenu);
Chris@211 1271 m_rightButtonTransformsMenu->addMenu(byCategoryMenu);
Chris@37 1272 pendingMenus.insert(byCategoryMenu);
Chris@33 1273
Chris@33 1274 vector<QString> categories =
Chris@211 1275 TransformFactory::getInstance()->getTransformCategories(*i);
Chris@33 1276
Chris@33 1277 for (vector<QString>::iterator j = categories.begin();
Chris@33 1278 j != categories.end(); ++j) {
Chris@33 1279
Chris@33 1280 QString category = *j;
Chris@33 1281 if (category == "") category = tr("Unclassified");
Chris@33 1282
Chris@33 1283 if (categories.size() < 2) {
Chris@33 1284 categoryMenus[*i][category] = byCategoryMenu;
Chris@33 1285 continue;
Chris@33 1286 }
Chris@33 1287
Chris@33 1288 QStringList components = category.split(" > ");
Chris@33 1289 QString key;
Chris@33 1290
Chris@33 1291 for (QStringList::iterator k = components.begin();
Chris@33 1292 k != components.end(); ++k) {
Chris@33 1293
Chris@33 1294 QString parentKey = key;
Chris@33 1295 if (key != "") key += " > ";
Chris@33 1296 key += *k;
Chris@33 1297
Chris@33 1298 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) {
Chris@37 1299 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40);
Chris@97 1300 m->setTearOffEnabled(true);
Chris@37 1301 pendingMenus.insert(m);
Chris@37 1302 categoryMenus[*i][key] = m;
Chris@33 1303 if (parentKey == "") {
Chris@37 1304 byCategoryMenu->addMenu(m);
Chris@33 1305 } else {
Chris@37 1306 categoryMenus[*i][parentKey]->addMenu(m);
Chris@33 1307 }
Chris@33 1308 }
Chris@33 1309 }
Chris@33 1310 }
Chris@33 1311
Chris@34 1312 QString byPluginNameLabel = tr("%1 by Plugin Name").arg(*i);
Chris@36 1313 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel);
Chris@97 1314 byPluginNameMenus[*i]->setTearOffEnabled(true);
Chris@36 1315 m_transformsMenu->addMenu(byPluginNameMenus[*i]);
Chris@211 1316 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]);
Chris@37 1317 pendingMenus.insert(byPluginNameMenus[*i]);
Chris@34 1318
Chris@33 1319 QString byMakerLabel = tr("%1 by Maker").arg(*i);
Chris@37 1320 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40);
Chris@97 1321 byMakerMenu->setTearOffEnabled(true);
Chris@37 1322 m_transformsMenu->addMenu(byMakerMenu);
Chris@211 1323 m_rightButtonTransformsMenu->addMenu(byMakerMenu);
Chris@37 1324 pendingMenus.insert(byMakerMenu);
Chris@33 1325
Chris@33 1326 vector<QString> makers =
Chris@211 1327 TransformFactory::getInstance()->getTransformMakers(*i);
Chris@37 1328
Chris@33 1329 for (vector<QString>::iterator j = makers.begin();
Chris@33 1330 j != makers.end(); ++j) {
Chris@33 1331
Chris@33 1332 QString maker = *j;
Chris@33 1333 if (maker == "") maker = tr("Unknown");
Chris@55 1334 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
Chris@55 1335
Chris@37 1336 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40);
Chris@97 1337 makerMenus[*i][maker]->setTearOffEnabled(true);
Chris@37 1338 byMakerMenu->addMenu(makerMenus[*i][maker]);
Chris@37 1339 pendingMenus.insert(makerMenus[*i][maker]);
Chris@33 1340 }
Chris@0 1341 }
Chris@0 1342
Chris@230 1343 // Names should only be duplicated here if they have the same
Chris@230 1344 // plugin name, output name and maker but are in different library
Chris@230 1345 // .so names -- that won't happen often I hope
Chris@230 1346 std::map<QString, QString> idNameSonameMap;
Chris@230 1347 std::set<QString> seenNames, duplicateNames;
Chris@230 1348 for (unsigned int i = 0; i < transforms.size(); ++i) {
Chris@230 1349 QString name = transforms[i].name;
Chris@230 1350 if (seenNames.find(name) != seenNames.end()) {
Chris@230 1351 duplicateNames.insert(name);
Chris@230 1352 } else {
Chris@230 1353 seenNames.insert(name);
Chris@230 1354 }
Chris@230 1355 }
Chris@230 1356
Chris@0 1357 for (unsigned int i = 0; i < transforms.size(); ++i) {
Chris@0 1358
Chris@107 1359 QString name = transforms[i].name;
Chris@107 1360 if (name == "") name = transforms[i].identifier;
Chris@107 1361
Chris@107 1362 // std::cerr << "Plugin Name: " << name.toStdString() << std::endl;
Chris@80 1363
Chris@33 1364 QString type = transforms[i].type;
Chris@33 1365
Chris@33 1366 QString category = transforms[i].category;
Chris@33 1367 if (category == "") category = tr("Unclassified");
Chris@33 1368
Chris@33 1369 QString maker = transforms[i].maker;
Chris@33 1370 if (maker == "") maker = tr("Unknown");
Chris@55 1371 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
Chris@33 1372
Chris@107 1373 QString pluginName = name.section(": ", 0, 0);
Chris@107 1374 QString output = name.section(": ", 1);
Chris@107 1375
Chris@230 1376 if (duplicateNames.find(pluginName) != duplicateNames.end()) {
Chris@230 1377 pluginName = QString("%1 <%2>")
Chris@230 1378 .arg(pluginName)
Chris@230 1379 .arg(transforms[i].identifier.section(':', 1, 1));
Chris@230 1380 if (output == "") name = pluginName;
Chris@230 1381 else name = QString("%1: %2")
Chris@230 1382 .arg(pluginName)
Chris@230 1383 .arg(output);
Chris@230 1384 }
Chris@230 1385
Chris@107 1386 QAction *action = new QAction(tr("%1...").arg(name), this);
Chris@0 1387 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@107 1388 m_transformActions[action] = transforms[i].identifier;
Chris@107 1389 m_transformActionsReverse[transforms[i].identifier] = action;
Chris@0 1390 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@33 1391
Chris@272 1392 action->setStatusTip(transforms[i].longDescription);
Chris@90 1393
Chris@33 1394 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
Chris@33 1395 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
Chris@33 1396 << "No category menu for transform \""
Chris@107 1397 << name.toStdString() << "\" (category = \""
Chris@33 1398 << category.toStdString() << "\")" << std::endl;
Chris@33 1399 } else {
Chris@33 1400 categoryMenus[type][category]->addAction(action);
Chris@33 1401 }
Chris@33 1402
Chris@33 1403 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
Chris@33 1404 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
Chris@33 1405 << "No maker menu for transform \""
Chris@107 1406 << name.toStdString() << "\" (maker = \""
Chris@33 1407 << maker.toStdString() << "\")" << std::endl;
Chris@33 1408 } else {
Chris@80 1409 makerMenus[type][maker]->addAction(action);
Chris@33 1410 }
Chris@33 1411
Chris@33 1412 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
Chris@33 1413 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@107 1414 m_transformActions[action] = transforms[i].identifier;
Chris@33 1415 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@272 1416 action->setStatusTip(transforms[i].longDescription);
Chris@33 1417
Chris@211 1418 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl;
Chris@34 1419
Chris@33 1420 if (pluginNameMenus[type].find(pluginName) ==
Chris@33 1421 pluginNameMenus[type].end()) {
Chris@33 1422
Chris@36 1423 SubdividingMenu *parentMenu = byPluginNameMenus[type];
Chris@97 1424 parentMenu->setTearOffEnabled(true);
Chris@34 1425
Chris@33 1426 if (output == "") {
Chris@36 1427 parentMenu->addAction(pluginName, action);
Chris@33 1428 } else {
Chris@34 1429 pluginNameMenus[type][pluginName] =
Chris@34 1430 parentMenu->addMenu(pluginName);
Chris@33 1431 connect(this, SIGNAL(canAddLayer(bool)),
Chris@33 1432 pluginNameMenus[type][pluginName],
Chris@33 1433 SLOT(setEnabled(bool)));
Chris@33 1434 }
Chris@33 1435 }
Chris@33 1436
Chris@33 1437 if (pluginNameMenus[type].find(pluginName) !=
Chris@33 1438 pluginNameMenus[type].end()) {
Chris@33 1439 pluginNameMenus[type][pluginName]->addAction(action);
Chris@33 1440 }
Chris@0 1441 }
Chris@0 1442
Chris@37 1443 for (set<SubdividingMenu *>::iterator i = pendingMenus.begin();
Chris@37 1444 i != pendingMenus.end(); ++i) {
Chris@37 1445 (*i)->entriesAdded();
Chris@37 1446 }
Chris@37 1447
Chris@273 1448 m_transformsMenu->addSeparator();
Chris@273 1449 m_rightButtonTransformsMenu->addSeparator();
Chris@273 1450
Chris@273 1451 QAction *action = new QAction(tr("Find a Transform..."), this);
Chris@273 1452 action->setStatusTip(tr("Search for a transform from the installed plugins, by name or description"));
Chris@275 1453 action->setShortcut(tr("Ctrl+M"));
Chris@273 1454 connect(action, SIGNAL(triggered()), this, SLOT(findTransform()));
Chris@273 1455 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@275 1456 m_keyReference->registerShortcut(action);
Chris@273 1457 m_transformsMenu->addAction(action);
Chris@273 1458 m_rightButtonTransformsMenu->addAction(action);
Chris@273 1459
Chris@211 1460 setupRecentTransformsMenu();
Chris@66 1461 }
Chris@66 1462
Chris@66 1463 void
Chris@66 1464 MainWindow::setupHelpMenu()
Chris@66 1465 {
Chris@66 1466 QMenu *menu = menuBar()->addMenu(tr("&Help"));
Chris@97 1467 menu->setTearOffEnabled(true);
Chris@66 1468
Chris@162 1469 m_keyReference->setCategory(tr("Help"));
Chris@162 1470
Chris@168 1471 IconLoader il;
Chris@168 1472
Chris@168 1473 QAction *action = new QAction(il.load("help"),
Chris@138 1474 tr("&Help Reference"), this);
Chris@162 1475 action->setShortcut(tr("F1"));
Chris@66 1476 action->setStatusTip(tr("Open the Sonic Visualiser reference manual"));
Chris@66 1477 connect(action, SIGNAL(triggered()), this, SLOT(help()));
Chris@162 1478 m_keyReference->registerShortcut(action);
Chris@0 1479 menu->addAction(action);
Chris@162 1480
Chris@163 1481 action = new QAction(tr("&Key and Mouse Reference"), this);
Chris@162 1482 action->setShortcut(tr("F2"));
Chris@162 1483 action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser"));
Chris@162 1484 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
Chris@162 1485 m_keyReference->registerShortcut(action);
Chris@162 1486 menu->addAction(action);
Chris@66 1487
Chris@164 1488 action = new QAction(tr("Sonic Visualiser on the &Web"), this);
Chris@164 1489 action->setStatusTip(tr("Open the Sonic Visualiser website"));
Chris@164 1490 connect(action, SIGNAL(triggered()), this, SLOT(website()));
Chris@164 1491 menu->addAction(action);
Chris@164 1492
Chris@66 1493 action = new QAction(tr("&About Sonic Visualiser"), this);
Chris@66 1494 action->setStatusTip(tr("Show information about Sonic Visualiser"));
Chris@66 1495 connect(action, SIGNAL(triggered()), this, SLOT(about()));
Chris@0 1496 menu->addAction(action);
Chris@0 1497 }
Chris@0 1498
Chris@0 1499 void
Chris@0 1500 MainWindow::setupRecentFilesMenu()
Chris@0 1501 {
Chris@0 1502 m_recentFilesMenu->clear();
Chris@34 1503 vector<QString> files = m_recentFiles.getRecent();
Chris@0 1504 for (size_t i = 0; i < files.size(); ++i) {
Chris@0 1505 QAction *action = new QAction(files[i], this);
Chris@0 1506 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
Chris@162 1507 if (i == 0) {
Chris@162 1508 action->setShortcut(tr("Ctrl+R"));
Chris@162 1509 m_keyReference->registerShortcut
Chris@163 1510 (tr("Re-open"),
Chris@163 1511 action->shortcut(),
Chris@163 1512 tr("Re-open the current or most recently opened file"));
Chris@162 1513 }
Chris@0 1514 m_recentFilesMenu->addAction(action);
Chris@0 1515 }
Chris@0 1516 }
Chris@0 1517
Chris@0 1518 void
Chris@211 1519 MainWindow::setupRecentTransformsMenu()
Chris@34 1520 {
Chris@211 1521 m_recentTransformsMenu->clear();
Chris@211 1522 vector<QString> transforms = m_recentTransforms.getRecent();
Chris@34 1523 for (size_t i = 0; i < transforms.size(); ++i) {
Chris@211 1524 TransformActionReverseMap::iterator ti =
Chris@34 1525 m_transformActionsReverse.find(transforms[i]);
Chris@34 1526 if (ti == m_transformActionsReverse.end()) {
Chris@211 1527 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
Chris@34 1528 << "Unknown transform \"" << transforms[i].toStdString()
Chris@34 1529 << "\" in recent transforms list" << std::endl;
Chris@34 1530 continue;
Chris@34 1531 }
Chris@162 1532 if (i == 0) {
Chris@162 1533 ti->second->setShortcut(tr("Ctrl+T"));
Chris@162 1534 m_keyReference->registerShortcut
Chris@211 1535 (tr("Repeat Transform"),
Chris@162 1536 ti->second->shortcut(),
Chris@163 1537 tr("Re-select the most recently run transform"));
Chris@216 1538 } else {
Chris@216 1539 ti->second->setShortcut(QString(""));
Chris@162 1540 }
Chris@211 1541 m_recentTransformsMenu->addAction(ti->second);
Chris@34 1542 }
Chris@34 1543 }
Chris@34 1544
Chris@34 1545 void
Chris@95 1546 MainWindow::setupExistingLayersMenus()
Chris@0 1547 {
Chris@0 1548 if (!m_existingLayersMenu) return; // should have been created by setupMenus
Chris@0 1549
Chris@0 1550 // std::cerr << "MainWindow::setupExistingLayersMenu" << std::endl;
Chris@0 1551
Chris@0 1552 m_existingLayersMenu->clear();
Chris@0 1553 m_existingLayerActions.clear();
Chris@0 1554
Chris@95 1555 m_sliceMenu->clear();
Chris@95 1556 m_sliceActions.clear();
Chris@95 1557
Chris@168 1558 IconLoader il;
Chris@168 1559
Chris@33 1560 vector<Layer *> orderedLayers;
Chris@33 1561 set<Layer *> observedLayers;
Chris@95 1562 set<Layer *> sliceableLayers;
Chris@95 1563
Chris@95 1564 LayerFactory *factory = LayerFactory::getInstance();
Chris@0 1565
Chris@0 1566 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
Chris@0 1567
Chris@0 1568 Pane *pane = m_paneStack->getPane(i);
Chris@0 1569 if (!pane) continue;
Chris@0 1570
Chris@0 1571 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@0 1572
Chris@0 1573 Layer *layer = pane->getLayer(j);
Chris@0 1574 if (!layer) continue;
Chris@0 1575 if (observedLayers.find(layer) != observedLayers.end()) {
Chris@137 1576 // std::cerr << "found duplicate layer " << layer << std::endl;
Chris@0 1577 continue;
Chris@0 1578 }
Chris@0 1579
Chris@0 1580 // std::cerr << "found new layer " << layer << " (name = "
Chris@0 1581 // << layer->getLayerPresentationName().toStdString() << ")" << std::endl;
Chris@0 1582
Chris@0 1583 orderedLayers.push_back(layer);
Chris@0 1584 observedLayers.insert(layer);
Chris@95 1585
Chris@95 1586 if (factory->isLayerSliceable(layer)) {
Chris@95 1587 sliceableLayers.insert(layer);
Chris@95 1588 }
Chris@0 1589 }
Chris@0 1590 }
Chris@0 1591
Chris@33 1592 map<QString, int> observedNames;
Chris@0 1593
Chris@137 1594 for (size_t i = 0; i < orderedLayers.size(); ++i) {
Chris@0 1595
Chris@95 1596 Layer *layer = orderedLayers[i];
Chris@95 1597
Chris@95 1598 QString name = layer->getLayerPresentationName();
Chris@0 1599 int n = ++observedNames[name];
Chris@0 1600 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n);
Chris@0 1601
Chris@168 1602 QIcon icon = il.load(factory->getLayerIconName
Chris@168 1603 (factory->getLayerType(layer)));
Chris@95 1604
Chris@95 1605 QAction *action = new QAction(icon, name, this);
Chris@0 1606 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@0 1607 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@95 1608 m_existingLayerActions[action] = layer;
Chris@0 1609
Chris@0 1610 m_existingLayersMenu->addAction(action);
Chris@95 1611
Chris@95 1612 if (sliceableLayers.find(layer) != sliceableLayers.end()) {
Chris@95 1613 action = new QAction(icon, name, this);
Chris@95 1614 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
Chris@95 1615 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@95 1616 m_sliceActions[action] = layer;
Chris@95 1617 m_sliceMenu->addAction(action);
Chris@95 1618 }
Chris@0 1619 }
Chris@95 1620
Chris@95 1621 m_sliceMenu->setEnabled(!m_sliceActions.empty());
Chris@0 1622 }
Chris@0 1623
Chris@0 1624 void
Chris@0 1625 MainWindow::setupToolbars()
Chris@0 1626 {
Chris@162 1627 m_keyReference->setCategory(tr("Playback and Transport Controls"));
Chris@162 1628
Chris@168 1629 IconLoader il;
Chris@168 1630
Chris@155 1631 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
Chris@155 1632 menu->setTearOffEnabled(true);
Chris@155 1633 m_rightButtonMenu->addSeparator();
Chris@155 1634 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
Chris@155 1635
Chris@155 1636 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
Chris@155 1637
Chris@265 1638 m_rwdStartAction = toolbar->addAction(il.load("rewind-start"),
Chris@265 1639 tr("Rewind to Start"));
Chris@265 1640 m_rwdStartAction->setShortcut(tr("Home"));
Chris@265 1641 m_rwdStartAction->setStatusTip(tr("Rewind to the start"));
Chris@265 1642 connect(m_rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
Chris@265 1643 connect(this, SIGNAL(canPlay(bool)), m_rwdStartAction, SLOT(setEnabled(bool)));
Chris@265 1644
Chris@265 1645 m_rwdAction = toolbar->addAction(il.load("rewind"), tr("Rewind"));
Chris@155 1646 m_rwdAction->setShortcut(tr("PgUp"));
Chris@163 1647 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
Chris@155 1648 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
Chris@155 1649 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
Chris@155 1650
Chris@265 1651 m_playAction = toolbar->addAction(il.load("playpause"),
Chris@265 1652 tr("Play / Pause"));
Chris@265 1653 m_playAction->setCheckable(true);
Chris@265 1654 m_playAction->setShortcut(tr("Space"));
Chris@265 1655 m_playAction->setStatusTip(tr("Start or stop playback from the current position"));
Chris@265 1656 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
Chris@0 1657 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
Chris@265 1658 m_playAction, SLOT(setChecked(bool)));
Chris@265 1659 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool)));
Chris@155 1660
Chris@168 1661 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
Chris@155 1662 tr("Fast Forward"));
Chris@155 1663 m_ffwdAction->setShortcut(tr("PgDown"));
Chris@163 1664 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
Chris@155 1665 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
Chris@155 1666 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
Chris@155 1667
Chris@265 1668 m_ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
Chris@265 1669 tr("Fast Forward to End"));
Chris@265 1670 m_ffwdEndAction->setShortcut(tr("End"));
Chris@265 1671 m_ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
Chris@265 1672 connect(m_ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
Chris@265 1673 connect(this, SIGNAL(canPlay(bool)), m_ffwdEndAction, SLOT(setEnabled(bool)));
Chris@0 1674
Chris@0 1675 toolbar = addToolBar(tr("Play Mode Toolbar"));
Chris@0 1676
Chris@265 1677 m_playSelectionAction = toolbar->addAction(il.load("playselection"),
Chris@265 1678 tr("Constrain Playback to Selection"));
Chris@265 1679 m_playSelectionAction->setCheckable(true);
Chris@265 1680 m_playSelectionAction->setChecked(m_viewManager->getPlaySelectionMode());
Chris@265 1681 m_playSelectionAction->setShortcut(tr("s"));
Chris@265 1682 m_playSelectionAction->setStatusTip(tr("Constrain playback to the selected regions"));
Chris@69 1683 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
Chris@265 1684 m_playSelectionAction, SLOT(setChecked(bool)));
Chris@265 1685 connect(m_playSelectionAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
Chris@265 1686 connect(this, SIGNAL(canPlaySelection(bool)), m_playSelectionAction, SLOT(setEnabled(bool)));
Chris@265 1687
Chris@265 1688 m_playLoopAction = toolbar->addAction(il.load("playloop"),
Chris@265 1689 tr("Loop Playback"));
Chris@265 1690 m_playLoopAction->setCheckable(true);
Chris@265 1691 m_playLoopAction->setChecked(m_viewManager->getPlayLoopMode());
Chris@265 1692 m_playLoopAction->setShortcut(tr("l"));
Chris@265 1693 m_playLoopAction->setStatusTip(tr("Loop playback"));
Chris@69 1694 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
Chris@265 1695 m_playLoopAction, SLOT(setChecked(bool)));
Chris@265 1696 connect(m_playLoopAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
Chris@265 1697 connect(this, SIGNAL(canPlay(bool)), m_playLoopAction, SLOT(setEnabled(bool)));
Chris@155 1698
Chris@207 1699 m_soloAction = toolbar->addAction(il.load("solo"),
Chris@180 1700 tr("Solo Current Pane"));
Chris@207 1701 m_soloAction->setCheckable(true);
Chris@207 1702 m_soloAction->setChecked(m_viewManager->getPlaySoloMode());
Chris@207 1703 m_prevSolo = m_viewManager->getPlaySoloMode();
Chris@207 1704 m_soloAction->setShortcut(tr("o"));
Chris@207 1705 m_soloAction->setStatusTip(tr("Solo the current pane during playback"));
Chris@180 1706 connect(m_viewManager, SIGNAL(playSoloModeChanged(bool)),
Chris@207 1707 m_soloAction, SLOT(setChecked(bool)));
Chris@207 1708 connect(m_soloAction, SIGNAL(triggered()), this, SLOT(playSoloToggled()));
Chris@207 1709 connect(this, SIGNAL(canChangeSolo(bool)), m_soloAction, SLOT(setEnabled(bool)));
Chris@180 1710
Chris@208 1711 QAction *alAction = 0;
Chris@208 1712 if (Document::canAlign()) {
Chris@208 1713 alAction = toolbar->addAction(il.load("align"),
Chris@208 1714 tr("Align File Timelines"));
Chris@208 1715 alAction->setCheckable(true);
Chris@208 1716 alAction->setChecked(m_viewManager->getAlignMode());
Chris@208 1717 alAction->setStatusTip(tr("Treat multiple audio files as versions of the same work, and align their timelines"));
Chris@208 1718 connect(m_viewManager, SIGNAL(alignModeChanged(bool)),
Chris@208 1719 alAction, SLOT(setChecked(bool)));
Chris@208 1720 connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled()));
Chris@208 1721 connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool)));
Chris@208 1722 }
Chris@206 1723
Chris@265 1724 m_keyReference->registerShortcut(m_playAction);
Chris@265 1725 m_keyReference->registerShortcut(m_playSelectionAction);
Chris@265 1726 m_keyReference->registerShortcut(m_playLoopAction);
Chris@207 1727 m_keyReference->registerShortcut(m_soloAction);
Chris@208 1728 if (alAction) m_keyReference->registerShortcut(alAction);
Chris@162 1729 m_keyReference->registerShortcut(m_rwdAction);
Chris@162 1730 m_keyReference->registerShortcut(m_ffwdAction);
Chris@265 1731 m_keyReference->registerShortcut(m_rwdStartAction);
Chris@265 1732 m_keyReference->registerShortcut(m_ffwdEndAction);
Chris@265 1733
Chris@265 1734 menu->addAction(m_playAction);
Chris@265 1735 menu->addAction(m_playSelectionAction);
Chris@265 1736 menu->addAction(m_playLoopAction);
Chris@207 1737 menu->addAction(m_soloAction);
Chris@208 1738 if (alAction) menu->addAction(alAction);
Chris@155 1739 menu->addSeparator();
Chris@155 1740 menu->addAction(m_rwdAction);
Chris@155 1741 menu->addAction(m_ffwdAction);
Chris@155 1742 menu->addSeparator();
Chris@265 1743 menu->addAction(m_rwdStartAction);
Chris@265 1744 menu->addAction(m_ffwdEndAction);
Chris@155 1745 menu->addSeparator();
Chris@155 1746
Chris@265 1747 m_rightButtonPlaybackMenu->addAction(m_playAction);
Chris@265 1748 m_rightButtonPlaybackMenu->addAction(m_playSelectionAction);
Chris@265 1749 m_rightButtonPlaybackMenu->addAction(m_playLoopAction);
Chris@207 1750 m_rightButtonPlaybackMenu->addAction(m_soloAction);
Chris@208 1751 if (alAction) m_rightButtonPlaybackMenu->addAction(alAction);
Chris@155 1752 m_rightButtonPlaybackMenu->addSeparator();
Chris@155 1753 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
Chris@155 1754 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
Chris@155 1755 m_rightButtonPlaybackMenu->addSeparator();
Chris@265 1756 m_rightButtonPlaybackMenu->addAction(m_rwdStartAction);
Chris@265 1757 m_rightButtonPlaybackMenu->addAction(m_ffwdEndAction);
Chris@155 1758 m_rightButtonPlaybackMenu->addSeparator();
Chris@155 1759
Chris@155 1760 QAction *fastAction = menu->addAction(tr("Speed Up"));
Chris@155 1761 fastAction->setShortcut(tr("Ctrl+PgUp"));
Chris@163 1762 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
Chris@155 1763 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
Chris@155 1764 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
Chris@155 1765
Chris@155 1766 QAction *slowAction = menu->addAction(tr("Slow Down"));
Chris@155 1767 slowAction->setShortcut(tr("Ctrl+PgDown"));
Chris@163 1768 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
Chris@155 1769 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
Chris@155 1770 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
Chris@155 1771
Chris@155 1772 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
Chris@155 1773 normalAction->setShortcut(tr("Ctrl+Home"));
Chris@163 1774 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
Chris@155 1775 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
Chris@155 1776 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
Chris@155 1777
Chris@162 1778 m_keyReference->registerShortcut(fastAction);
Chris@162 1779 m_keyReference->registerShortcut(slowAction);
Chris@162 1780 m_keyReference->registerShortcut(normalAction);
Chris@162 1781
Chris@155 1782 m_rightButtonPlaybackMenu->addAction(fastAction);
Chris@155 1783 m_rightButtonPlaybackMenu->addAction(slowAction);
Chris@155 1784 m_rightButtonPlaybackMenu->addAction(normalAction);
Chris@0 1785
Chris@0 1786 toolbar = addToolBar(tr("Edit Toolbar"));
Chris@0 1787 CommandHistory::getInstance()->registerToolbar(toolbar);
Chris@0 1788
Chris@162 1789 m_keyReference->setCategory(tr("Tool Selection"));
Chris@162 1790
Chris@0 1791 toolbar = addToolBar(tr("Tools Toolbar"));
Chris@0 1792 QActionGroup *group = new QActionGroup(this);
Chris@0 1793
Chris@168 1794 QAction *action = toolbar->addAction(il.load("navigate"),
Chris@155 1795 tr("Navigate"));
Chris@0 1796 action->setCheckable(true);
Chris@0 1797 action->setChecked(true);
Chris@0 1798 action->setShortcut(tr("1"));
Chris@90 1799 action->setStatusTip(tr("Navigate"));
Chris@0 1800 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
Chris@0 1801 group->addAction(action);
Chris@162 1802 m_keyReference->registerShortcut(action);
Chris@0 1803 m_toolActions[ViewManager::NavigateMode] = action;
Chris@0 1804
Chris@168 1805 action = toolbar->addAction(il.load("select"),
Chris@0 1806 tr("Select"));
Chris@0 1807 action->setCheckable(true);
Chris@0 1808 action->setShortcut(tr("2"));
Chris@90 1809 action->setStatusTip(tr("Select ranges"));
Chris@0 1810 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected()));
Chris@0 1811 group->addAction(action);
Chris@162 1812 m_keyReference->registerShortcut(action);
Chris@0 1813 m_toolActions[ViewManager::SelectMode] = action;
Chris@0 1814
Chris@168 1815 action = toolbar->addAction(il.load("move"),
Chris@0 1816 tr("Edit"));
Chris@0 1817 action->setCheckable(true);
Chris@0 1818 action->setShortcut(tr("3"));
Chris@90 1819 action->setStatusTip(tr("Edit items in layer"));
Chris@0 1820 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
Chris@0 1821 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@0 1822 group->addAction(action);
Chris@162 1823 m_keyReference->registerShortcut(action);
Chris@0 1824 m_toolActions[ViewManager::EditMode] = action;
Chris@0 1825
Chris@168 1826 action = toolbar->addAction(il.load("draw"),
Chris@0 1827 tr("Draw"));
Chris@0 1828 action->setCheckable(true);
Chris@0 1829 action->setShortcut(tr("4"));
Chris@90 1830 action->setStatusTip(tr("Draw new items in layer"));
Chris@0 1831 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected()));
Chris@0 1832 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@0 1833 group->addAction(action);
Chris@162 1834 m_keyReference->registerShortcut(action);
Chris@0 1835 m_toolActions[ViewManager::DrawMode] = action;
Chris@0 1836
Chris@217 1837 action = toolbar->addAction(il.load("erase"),
Chris@217 1838 tr("Erase"));
Chris@217 1839 action->setCheckable(true);
Chris@217 1840 action->setShortcut(tr("5"));
Chris@217 1841 action->setStatusTip(tr("Erase items from layer"));
Chris@217 1842 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected()));
Chris@217 1843 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@217 1844 group->addAction(action);
Chris@217 1845 m_keyReference->registerShortcut(action);
Chris@217 1846 m_toolActions[ViewManager::EraseMode] = action;
Chris@217 1847
Chris@265 1848 action = toolbar->addAction(il.load("measure"), tr("Measure"));
Chris@151 1849 action->setCheckable(true);
Chris@217 1850 action->setShortcut(tr("6"));
Chris@151 1851 action->setStatusTip(tr("Make measurements in layer"));
Chris@151 1852 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected()));
Chris@169 1853 connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool)));
Chris@151 1854 group->addAction(action);
Chris@162 1855 m_keyReference->registerShortcut(action);
Chris@151 1856 m_toolActions[ViewManager::MeasureMode] = action;
Chris@151 1857
Chris@0 1858 toolNavigateSelected();
Chris@163 1859
Chris@163 1860 Pane::registerShortcuts(*m_keyReference);
Chris@0 1861 }
Chris@0 1862
Chris@0 1863 void
Chris@265 1864 MainWindow::connectLayerEditDialog(ModelDataTableDialog *dialog)
Chris@265 1865 {
Chris@265 1866 MainWindowBase::connectLayerEditDialog(dialog);
Chris@265 1867 QToolBar *toolbar = dialog->getPlayToolbar();
Chris@265 1868 if (toolbar) {
Chris@265 1869 toolbar->addAction(m_rwdStartAction);
Chris@265 1870 toolbar->addAction(m_rwdAction);
Chris@265 1871 toolbar->addAction(m_playAction);
Chris@265 1872 toolbar->addAction(m_ffwdAction);
Chris@265 1873 toolbar->addAction(m_ffwdEndAction);
Chris@265 1874 }
Chris@265 1875 }
Chris@265 1876
Chris@265 1877 void
Chris@0 1878 MainWindow::updateMenuStates()
Chris@0 1879 {
Chris@200 1880 MainWindowBase::updateMenuStates();
Chris@200 1881
Chris@117 1882 Pane *currentPane = 0;
Chris@117 1883 Layer *currentLayer = 0;
Chris@117 1884
Chris@117 1885 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
Chris@117 1886 if (currentPane) currentLayer = currentPane->getSelectedLayer();
Chris@117 1887
Chris@0 1888 bool haveCurrentPane =
Chris@117 1889 (currentPane != 0);
Chris@0 1890 bool haveCurrentLayer =
Chris@117 1891 (haveCurrentPane &&
Chris@117 1892 (currentLayer != 0));
Chris@206 1893 bool havePlayTarget =
Chris@206 1894 (m_playTarget != 0);
Chris@0 1895 bool haveSelection =
Chris@0 1896 (m_viewManager &&
Chris@0 1897 !m_viewManager->getSelections().empty());
Chris@0 1898 bool haveCurrentEditableLayer =
Chris@0 1899 (haveCurrentLayer &&
Chris@117 1900 currentLayer->isLayerEditable());
Chris@0 1901 bool haveCurrentTimeInstantsLayer =
Chris@0 1902 (haveCurrentLayer &&
Chris@117 1903 dynamic_cast<TimeInstantLayer *>(currentLayer));
Chris@0 1904 bool haveCurrentTimeValueLayer =
Chris@0 1905 (haveCurrentLayer &&
Chris@117 1906 dynamic_cast<TimeValueLayer *>(currentLayer));
Chris@207 1907
Chris@207 1908 emit canChangeSolo(havePlayTarget);
Chris@207 1909 emit canAlign(havePlayTarget && m_document && m_document->canAlign());
Chris@206 1910
Chris@200 1911 emit canChangePlaybackSpeed(true);
Chris@200 1912 int v = m_playSpeed->value();
Chris@200 1913 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
Chris@200 1914 emit canSlowDownPlayback(v > m_playSpeed->minimum());
Chris@155 1915
Chris@164 1916 if (m_viewManager &&
Chris@164 1917 (m_viewManager->getToolMode() == ViewManager::MeasureMode)) {
Chris@164 1918 emit canDeleteSelection(haveCurrentLayer);
Chris@164 1919 m_deleteSelectedAction->setText(tr("&Delete Current Measurement"));
Chris@164 1920 m_deleteSelectedAction->setStatusTip(tr("Delete the measurement currently under the mouse pointer"));
Chris@164 1921 } else {
Chris@164 1922 emit canDeleteSelection(haveSelection && haveCurrentEditableLayer);
Chris@164 1923 m_deleteSelectedAction->setText(tr("&Delete Selected Items"));
Chris@164 1924 m_deleteSelectedAction->setStatusTip(tr("Delete items in current selection from the current layer"));
Chris@164 1925 }
Chris@164 1926
Chris@155 1927 if (m_ffwdAction && m_rwdAction) {
Chris@155 1928 if (haveCurrentTimeInstantsLayer) {
Chris@155 1929 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
Chris@155 1930 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
Chris@155 1931 m_rwdAction->setText(tr("Rewind to Previous Instant"));
Chris@155 1932 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
Chris@155 1933 } else if (haveCurrentTimeValueLayer) {
Chris@155 1934 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
Chris@155 1935 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
Chris@155 1936 m_rwdAction->setText(tr("Rewind to Previous Point"));
Chris@155 1937 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
Chris@155 1938 } else {
Chris@155 1939 m_ffwdAction->setText(tr("Fast Forward"));
Chris@155 1940 m_ffwdAction->setStatusTip(tr("Fast forward"));
Chris@155 1941 m_rwdAction->setText(tr("Rewind"));
Chris@155 1942 m_rwdAction->setStatusTip(tr("Rewind"));
Chris@155 1943 }
Chris@155 1944 }
Chris@0 1945 }
Chris@0 1946
Chris@0 1947 void
Chris@0 1948 MainWindow::updateDescriptionLabel()
Chris@0 1949 {
Chris@0 1950 if (!getMainModel()) {
Chris@0 1951 m_descriptionLabel->setText(tr("No audio file loaded."));
Chris@0 1952 return;
Chris@0 1953 }
Chris@0 1954
Chris@0 1955 QString description;
Chris@0 1956
Chris@0 1957 size_t ssr = getMainModel()->getSampleRate();
Chris@0 1958 size_t tsr = ssr;
Chris@0 1959 if (m_playSource) tsr = m_playSource->getTargetSampleRate();
Chris@0 1960
Chris@0 1961 if (ssr != tsr) {
Chris@0 1962 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
Chris@0 1963 } else {
Chris@0 1964 description = QString("%1Hz").arg(ssr);
Chris@0 1965 }
Chris@0 1966
Chris@0 1967 description = QString("%1 - %2")
Chris@0 1968 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr)
Chris@0 1969 .toText(false).c_str())
Chris@0 1970 .arg(description);
Chris@0 1971
Chris@0 1972 m_descriptionLabel->setText(description);
Chris@0 1973 }
Chris@0 1974
Chris@0 1975 void
Chris@0 1976 MainWindow::documentModified()
Chris@0 1977 {
Chris@200 1978 //!!!
Chris@200 1979 MainWindowBase::documentModified();
Chris@0 1980 }
Chris@0 1981
Chris@0 1982 void
Chris@0 1983 MainWindow::documentRestored()
Chris@0 1984 {
Chris@200 1985 //!!!
Chris@200 1986 MainWindowBase::documentRestored();
Chris@0 1987 }
Chris@0 1988
Chris@0 1989 void
Chris@0 1990 MainWindow::toolNavigateSelected()
Chris@0 1991 {
Chris@0 1992 m_viewManager->setToolMode(ViewManager::NavigateMode);
Chris@0 1993 }
Chris@0 1994
Chris@0 1995 void
Chris@0 1996 MainWindow::toolSelectSelected()
Chris@0 1997 {
Chris@0 1998 m_viewManager->setToolMode(ViewManager::SelectMode);
Chris@0 1999 }
Chris@0 2000
Chris@0 2001 void
Chris@0 2002 MainWindow::toolEditSelected()
Chris@0 2003 {
Chris@0 2004 m_viewManager->setToolMode(ViewManager::EditMode);
Chris@0 2005 }
Chris@0 2006
Chris@0 2007 void
Chris@0 2008 MainWindow::toolDrawSelected()
Chris@0 2009 {
Chris@0 2010 m_viewManager->setToolMode(ViewManager::DrawMode);
Chris@0 2011 }
Chris@0 2012
Chris@151 2013 void
Chris@217 2014 MainWindow::toolEraseSelected()
Chris@217 2015 {
Chris@217 2016 m_viewManager->setToolMode(ViewManager::EraseMode);
Chris@217 2017 }
Chris@217 2018
Chris@217 2019 void
Chris@151 2020 MainWindow::toolMeasureSelected()
Chris@151 2021 {
Chris@151 2022 m_viewManager->setToolMode(ViewManager::MeasureMode);
Chris@151 2023 }
Chris@151 2024
Chris@0 2025 void
Chris@0 2026 MainWindow::importAudio()
Chris@0 2027 {
Chris@88 2028 QString path = getOpenFileName(FileFinder::AudioFile);
Chris@0 2029
Chris@0 2030 if (path != "") {
Chris@197 2031 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) {
Chris@247 2032 emit hideSplash();
Chris@0 2033 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2034 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
Chris@0 2035 }
Chris@0 2036 }
Chris@0 2037 }
Chris@0 2038
Chris@0 2039 void
Chris@0 2040 MainWindow::importMoreAudio()
Chris@0 2041 {
Chris@88 2042 QString path = getOpenFileName(FileFinder::AudioFile);
Chris@0 2043
Chris@0 2044 if (path != "") {
Chris@197 2045 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) {
Chris@247 2046 emit hideSplash();
Chris@0 2047 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2048 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
Chris@0 2049 }
Chris@0 2050 }
Chris@0 2051 }
Chris@0 2052
Chris@0 2053 void
Chris@0 2054 MainWindow::exportAudio()
Chris@0 2055 {
Chris@0 2056 if (!getMainModel()) return;
Chris@0 2057
Chris@88 2058 QString path = getSaveFileName(FileFinder::AudioFile);
Chris@0 2059
Chris@0 2060 if (path == "") return;
Chris@0 2061
Chris@0 2062 bool ok = false;
Chris@0 2063 QString error;
Chris@0 2064
Chris@0 2065 MultiSelection ms = m_viewManager->getSelection();
Chris@0 2066 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@0 2067
Chris@0 2068 bool multiple = false;
Chris@0 2069
Chris@38 2070 MultiSelection *selectionToWrite = 0;
Chris@38 2071
Chris@38 2072 if (selections.size() == 1) {
Chris@0 2073
Chris@0 2074 QStringList items;
Chris@0 2075 items << tr("Export the selected region only")
Chris@0 2076 << tr("Export the whole audio file");
Chris@0 2077
Chris@0 2078 bool ok = false;
Chris@0 2079 QString item = ListInputDialog::getItem
Chris@0 2080 (this, tr("Select region to export"),
Chris@0 2081 tr("Which region from the original audio file do you want to export?"),
Chris@0 2082 items, 0, &ok);
Chris@0 2083
Chris@0 2084 if (!ok || item.isEmpty()) return;
Chris@0 2085
Chris@38 2086 if (item == items[0]) selectionToWrite = &ms;
Chris@38 2087
Chris@38 2088 } else if (selections.size() > 1) {
Chris@0 2089
Chris@0 2090 QStringList items;
Chris@0 2091 items << tr("Export the selected regions into a single audio file")
Chris@0 2092 << tr("Export the selected regions into separate files")
Chris@0 2093 << tr("Export the whole audio file");
Chris@0 2094
Chris@0 2095 QString item = ListInputDialog::getItem
Chris@0 2096 (this, tr("Select region to export"),
Chris@0 2097 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"),
Chris@0 2098 items, 0, &ok);
Chris@0 2099
Chris@0 2100 if (!ok || item.isEmpty()) return;
Chris@0 2101
Chris@0 2102 if (item == items[0]) {
Chris@0 2103
Chris@38 2104 selectionToWrite = &ms;
Chris@38 2105
Chris@38 2106 } else if (item == items[1]) {
Chris@0 2107
Chris@0 2108 multiple = true;
Chris@0 2109
Chris@0 2110 int n = 1;
Chris@0 2111 QString base = path;
Chris@0 2112 base.replace(".wav", "");
Chris@0 2113
Chris@0 2114 for (MultiSelection::SelectionList::iterator i = selections.begin();
Chris@0 2115 i != selections.end(); ++i) {
Chris@0 2116
Chris@0 2117 MultiSelection subms;
Chris@0 2118 subms.setSelection(*i);
Chris@0 2119
Chris@0 2120 QString subpath = QString("%1.%2.wav").arg(base).arg(n);
Chris@0 2121 ++n;
Chris@0 2122
Chris@0 2123 if (QFileInfo(subpath).exists()) {
Chris@0 2124 error = tr("Fragment file %1 already exists, aborting").arg(subpath);
Chris@0 2125 break;
Chris@0 2126 }
Chris@0 2127
Chris@38 2128 WavFileWriter subwriter(subpath,
Chris@38 2129 getMainModel()->getSampleRate(),
Chris@38 2130 getMainModel()->getChannelCount());
Chris@38 2131 subwriter.writeModel(getMainModel(), &subms);
Chris@0 2132 ok = subwriter.isOK();
Chris@0 2133
Chris@0 2134 if (!ok) {
Chris@0 2135 error = subwriter.getError();
Chris@0 2136 break;
Chris@0 2137 }
Chris@0 2138 }
Chris@0 2139 }
Chris@0 2140 }
Chris@0 2141
Chris@38 2142 if (!multiple) {
Chris@38 2143 WavFileWriter writer(path,
Chris@38 2144 getMainModel()->getSampleRate(),
Chris@38 2145 getMainModel()->getChannelCount());
Chris@38 2146 writer.writeModel(getMainModel(), selectionToWrite);
Chris@38 2147 ok = writer.isOK();
Chris@38 2148 error = writer.getError();
Chris@0 2149 }
Chris@0 2150
Chris@0 2151 if (ok) {
Chris@0 2152 if (!multiple) {
Chris@34 2153 m_recentFiles.addFile(path);
Chris@0 2154 }
Chris@0 2155 } else {
Chris@0 2156 QMessageBox::critical(this, tr("Failed to write file"), error);
Chris@0 2157 }
Chris@0 2158 }
Chris@0 2159
Chris@0 2160 void
Chris@0 2161 MainWindow::importLayer()
Chris@0 2162 {
Chris@0 2163 Pane *pane = m_paneStack->getCurrentPane();
Chris@0 2164
Chris@0 2165 if (!pane) {
Chris@0 2166 // shouldn't happen, as the menu action should have been disabled
Chris@0 2167 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl;
Chris@0 2168 return;
Chris@0 2169 }
Chris@0 2170
Chris@0 2171 if (!getMainModel()) {
Chris@0 2172 // shouldn't happen, as the menu action should have been disabled
Chris@0 2173 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl;
Chris@0 2174 return;
Chris@0 2175 }
Chris@0 2176
Chris@88 2177 QString path = getOpenFileName(FileFinder::LayerFile);
Chris@0 2178
Chris@0 2179 if (path != "") {
Chris@0 2180
Chris@197 2181 FileOpenStatus status = openLayer(path);
Chris@193 2182
Chris@193 2183 if (status == FileOpenFailed) {
Chris@247 2184 emit hideSplash();
Chris@0 2185 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2186 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
Chris@0 2187 return;
Chris@193 2188 } else if (status == FileOpenWrongMode) {
Chris@247 2189 emit hideSplash();
Chris@193 2190 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2191 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 2192 }
Chris@0 2193 }
Chris@0 2194 }
Chris@0 2195
Chris@0 2196 void
Chris@0 2197 MainWindow::exportLayer()
Chris@0 2198 {
Chris@0 2199 Pane *pane = m_paneStack->getCurrentPane();
Chris@0 2200 if (!pane) return;
Chris@0 2201
Chris@0 2202 Layer *layer = pane->getSelectedLayer();
Chris@0 2203 if (!layer) return;
Chris@0 2204
Chris@0 2205 Model *model = layer->getModel();
Chris@0 2206 if (!model) return;
Chris@0 2207
Chris@185 2208 FileFinder::FileType type = FileFinder::LayerFileNoMidi;
Chris@185 2209
Chris@185 2210 if (dynamic_cast<NoteModel *>(model)) type = FileFinder::LayerFile;
Chris@185 2211
Chris@185 2212 QString path = getSaveFileName(type);
Chris@0 2213
Chris@0 2214 if (path == "") return;
Chris@0 2215
Chris@0 2216 if (QFileInfo(path).suffix() == "") path += ".svl";
Chris@0 2217
Chris@185 2218 QString suffix = QFileInfo(path).suffix().toLower();
Chris@185 2219
Chris@0 2220 QString error;
Chris@0 2221
Chris@185 2222 if (suffix == "xml" || suffix == "svl") {
Chris@0 2223
Chris@0 2224 QFile file(path);
Chris@0 2225 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
Chris@0 2226 error = tr("Failed to open file %1 for writing").arg(path);
Chris@0 2227 } else {
Chris@0 2228 QTextStream out(&file);
Chris@0 2229 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
Chris@0 2230 << "<!DOCTYPE sonic-visualiser>\n"
Chris@0 2231 << "<sv>\n"
Chris@0 2232 << " <data>\n";
Chris@0 2233
Chris@0 2234 model->toXml(out, " ");
Chris@0 2235
Chris@0 2236 out << " </data>\n"
Chris@0 2237 << " <display>\n";
Chris@0 2238
Chris@0 2239 layer->toXml(out, " ");
Chris@0 2240
Chris@0 2241 out << " </display>\n"
Chris@0 2242 << "</sv>\n";
Chris@0 2243 }
Chris@0 2244
Chris@185 2245 } else if (suffix == "mid" || suffix == "midi") {
Chris@185 2246
Chris@185 2247 NoteModel *nm = dynamic_cast<NoteModel *>(model);
Chris@185 2248
Chris@185 2249 if (!nm) {
Chris@185 2250 error = tr("Can't export non-note layers to MIDI");
Chris@185 2251 } else {
Chris@185 2252 MIDIFileWriter writer(path, nm);
Chris@185 2253 writer.write();
Chris@185 2254 if (!writer.isOK()) {
Chris@185 2255 error = writer.getError();
Chris@185 2256 }
Chris@185 2257 }
Chris@185 2258
Chris@0 2259 } else {
Chris@0 2260
Chris@0 2261 CSVFileWriter writer(path, model,
Chris@185 2262 ((suffix == "csv") ? "," : "\t"));
Chris@0 2263 writer.write();
Chris@0 2264
Chris@0 2265 if (!writer.isOK()) {
Chris@0 2266 error = writer.getError();
Chris@0 2267 }
Chris@0 2268 }
Chris@0 2269
Chris@0 2270 if (error != "") {
Chris@0 2271 QMessageBox::critical(this, tr("Failed to write file"), error);
Chris@0 2272 } else {
Chris@34 2273 m_recentFiles.addFile(path);
Chris@0 2274 }
Chris@0 2275 }
Chris@0 2276
Chris@121 2277 void
Chris@121 2278 MainWindow::exportImage()
Chris@121 2279 {
Chris@121 2280 Pane *pane = m_paneStack->getCurrentPane();
Chris@121 2281 if (!pane) return;
Chris@121 2282
Chris@121 2283 QString path = getSaveFileName(FileFinder::ImageFile);
Chris@121 2284
Chris@121 2285 if (path == "") return;
Chris@121 2286
Chris@121 2287 if (QFileInfo(path).suffix() == "") path += ".png";
Chris@121 2288
Chris@123 2289 bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
Chris@123 2290
Chris@123 2291 QSize total, visible, selected;
Chris@123 2292 total = pane->getImageSize();
Chris@123 2293 visible = pane->getImageSize(pane->getFirstVisibleFrame(),
Chris@123 2294 pane->getLastVisibleFrame());
Chris@123 2295
Chris@123 2296 size_t sf0 = 0, sf1 = 0;
Chris@123 2297
Chris@123 2298 if (haveSelection) {
Chris@123 2299 MultiSelection::SelectionList selections = m_viewManager->getSelections();
Chris@123 2300 sf0 = selections.begin()->getStartFrame();
Chris@123 2301 MultiSelection::SelectionList::iterator e = selections.end();
Chris@123 2302 --e;
Chris@123 2303 sf1 = e->getEndFrame();
Chris@123 2304 selected = pane->getImageSize(sf0, sf1);
Chris@123 2305 }
Chris@123 2306
Chris@123 2307 QStringList items;
Chris@125 2308 items << tr("Export the whole pane (%1x%2 pixels)")
Chris@123 2309 .arg(total.width()).arg(total.height());
Chris@123 2310 items << tr("Export the visible area only (%1x%2 pixels)")
Chris@123 2311 .arg(visible.width()).arg(visible.height());
Chris@123 2312 if (haveSelection) {
Chris@123 2313 items << tr("Export the selection extent (%1x%2 pixels)")
Chris@123 2314 .arg(selected.width()).arg(selected.height());
Chris@124 2315 } else {
Chris@124 2316 items << tr("Export the selection extent");
Chris@123 2317 }
Chris@123 2318
Chris@123 2319 QSettings settings;
Chris@123 2320 settings.beginGroup("MainWindow");
Chris@123 2321 int deflt = settings.value("lastimageexportregion", 0).toInt();
Chris@123 2322 if (deflt == 2 && !haveSelection) deflt = 1;
Chris@124 2323 if (deflt == 0 && total.width() > 32767) deflt = 1;
Chris@124 2324
Chris@124 2325 ListInputDialog *lid = new ListInputDialog
Chris@123 2326 (this, tr("Select region to export"),
Chris@123 2327 tr("Which region of the current pane do you want to export as an image?"),
Chris@124 2328 items, deflt);
Chris@124 2329
Chris@124 2330 if (!haveSelection) {
Chris@124 2331 lid->setItemAvailability(2, false);
Chris@124 2332 }
Chris@124 2333 if (total.width() > 32767) { // appears to be the limit of a QImage
Chris@124 2334 lid->setItemAvailability(0, false);
Chris@124 2335 lid->setFootnote(tr("Note: the whole pane is too wide to be exported as a single image."));
Chris@124 2336 }
Chris@124 2337
Chris@124 2338 bool ok = lid->exec();
Chris@124 2339 QString item = lid->getCurrentString();
Chris@124 2340 delete lid;
Chris@123 2341
Chris@123 2342 if (!ok || item.isEmpty()) return;
Chris@123 2343
Chris@123 2344 settings.setValue("lastimageexportregion", deflt);
Chris@123 2345
Chris@123 2346 QImage *image = 0;
Chris@123 2347
Chris@123 2348 if (item == items[0]) {
Chris@123 2349 image = pane->toNewImage();
Chris@123 2350 } else if (item == items[1]) {
Chris@123 2351 image = pane->toNewImage(pane->getFirstVisibleFrame(),
Chris@123 2352 pane->getLastVisibleFrame());
Chris@123 2353 } else if (haveSelection) {
Chris@123 2354 image = pane->toNewImage(sf0, sf1);
Chris@123 2355 }
Chris@123 2356
Chris@121 2357 if (!image) return;
Chris@121 2358
Chris@121 2359 if (!image->save(path, "PNG")) {
Chris@121 2360 QMessageBox::critical(this, tr("Failed to save image file"),
Chris@121 2361 tr("Failed to save image file %1").arg(path));
Chris@121 2362 }
Chris@121 2363
Chris@121 2364 delete image;
Chris@121 2365 }
Chris@121 2366
Chris@0 2367 void
Chris@0 2368 MainWindow::newSession()
Chris@0 2369 {
Chris@0 2370 if (!checkSaveModified()) return;
Chris@0 2371
Chris@0 2372 closeSession();
Chris@0 2373 createDocument();
Chris@0 2374
Chris@0 2375 Pane *pane = m_paneStack->addPane();
Chris@0 2376
Chris@90 2377 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
Chris@116 2378 this, SLOT(contextHelpChanged(const QString &)));
Chris@90 2379
Chris@0 2380 if (!m_timeRulerLayer) {
Chris@0 2381 m_timeRulerLayer = m_document->createMainModelLayer
Chris@0 2382 (LayerFactory::TimeRuler);
Chris@0 2383 }
Chris@0 2384
Chris@0 2385 m_document->addLayerToView(pane, m_timeRulerLayer);
Chris@0 2386
Chris@0 2387 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
Chris@0 2388 m_document->addLayerToView(pane, waveform);
Chris@0 2389
Chris@65 2390 m_overview->registerView(pane);
Chris@0 2391
Chris@0 2392 CommandHistory::getInstance()->clear();
Chris@0 2393 CommandHistory::getInstance()->documentSaved();
Chris@0 2394 documentRestored();
Chris@0 2395 updateMenuStates();
Chris@0 2396 }
Chris@0 2397
Chris@0 2398 void
Chris@0 2399 MainWindow::closeSession()
Chris@0 2400 {
Chris@0 2401 if (!checkSaveModified()) return;
Chris@0 2402
Chris@0 2403 while (m_paneStack->getPaneCount() > 0) {
Chris@0 2404
Chris@0 2405 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
Chris@0 2406
Chris@0 2407 while (pane->getLayerCount() > 0) {
Chris@0 2408 m_document->removeLayerFromView
Chris@0 2409 (pane, pane->getLayer(pane->getLayerCount() - 1));
Chris@0 2410 }
Chris@0 2411
Chris@65 2412 m_overview->unregisterView(pane);
Chris@0 2413 m_paneStack->deletePane(pane);
Chris@0 2414 }
Chris@0 2415
Chris@0 2416 while (m_paneStack->getHiddenPaneCount() > 0) {
Chris@0 2417
Chris@0 2418 Pane *pane = m_paneStack->getHiddenPane
Chris@0 2419 (m_paneStack->getHiddenPaneCount() - 1);
Chris@0 2420
Chris@0 2421 while (pane->getLayerCount() > 0) {
Chris@0 2422 m_document->removeLayerFromView
Chris@0 2423 (pane, pane->getLayer(pane->getLayerCount() - 1));
Chris@0 2424 }
Chris@0 2425
Chris@65 2426 m_overview->unregisterView(pane);
Chris@0 2427 m_paneStack->deletePane(pane);
Chris@0 2428 }
Chris@0 2429
Chris@0 2430 delete m_document;
Chris@0 2431 m_document = 0;
Chris@0 2432 m_viewManager->clearSelections();
Chris@0 2433 m_timeRulerLayer = 0; // document owned this
Chris@0 2434
Chris@0 2435 m_sessionFile = "";
Chris@0 2436 setWindowTitle(tr("Sonic Visualiser"));
Chris@0 2437
Chris@0 2438 CommandHistory::getInstance()->clear();
Chris@0 2439 CommandHistory::getInstance()->documentSaved();
Chris@0 2440 documentRestored();
Chris@0 2441 }
Chris@0 2442
Chris@0 2443 void
Chris@0 2444 MainWindow::openSession()
Chris@0 2445 {
Chris@0 2446 if (!checkSaveModified()) return;
Chris@0 2447
Chris@0 2448 QString orig = m_audioFile;
Chris@0 2449 if (orig == "") orig = ".";
Chris@0 2450 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
Chris@0 2451
Chris@88 2452 QString path = getOpenFileName(FileFinder::SessionFile);
Chris@0 2453
Chris@0 2454 if (path.isEmpty()) return;
Chris@0 2455
Chris@200 2456 if (openSessionFile(path) == FileOpenFailed) {
Chris@247 2457 emit hideSplash();
Chris@0 2458 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2459 tr("<b>File open failed</b><p>Session file \"%1\" could not be opened").arg(path));
Chris@0 2460 }
Chris@0 2461 }
Chris@0 2462
Chris@0 2463 void
Chris@0 2464 MainWindow::openSomething()
Chris@0 2465 {
Chris@0 2466 QString orig = m_audioFile;
Chris@0 2467 if (orig == "") orig = ".";
Chris@0 2468 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
Chris@0 2469
Chris@88 2470 QString path = getOpenFileName(FileFinder::AnyFile);
Chris@0 2471
Chris@0 2472 if (path.isEmpty()) return;
Chris@0 2473
Chris@197 2474 FileOpenStatus status = open(path, AskUser);
Chris@193 2475
Chris@193 2476 if (status == FileOpenFailed) {
Chris@247 2477 emit hideSplash();
Chris@193 2478 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2479 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
Chris@193 2480 } else if (status == FileOpenWrongMode) {
Chris@247 2481 emit hideSplash();
Chris@193 2482 QMessageBox::critical(this, tr("Failed to open file"),
Chris@193 2483 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 2484 }
Chris@0 2485 }
Chris@0 2486
Chris@0 2487 void
Chris@86 2488 MainWindow::openLocation()
Chris@86 2489 {
Chris@103 2490 QSettings settings;
Chris@103 2491 settings.beginGroup("MainWindow");
Chris@103 2492 QString lastLocation = settings.value("lastremote", "").toString();
Chris@103 2493
Chris@86 2494 bool ok = false;
Chris@86 2495 QString text = QInputDialog::getText
Chris@86 2496 (this, tr("Open Location"),
Chris@86 2497 tr("Please enter the URL of the location to open:"),
Chris@103 2498 QLineEdit::Normal, lastLocation, &ok);
Chris@103 2499
Chris@103 2500 if (!ok) return;
Chris@103 2501
Chris@103 2502 settings.setValue("lastremote", text);
Chris@103 2503
Chris@103 2504 if (text.isEmpty()) return;
Chris@86 2505
Chris@197 2506 FileOpenStatus status = open(text);
Chris@193 2507
Chris@193 2508 if (status == FileOpenFailed) {
Chris@247 2509 emit hideSplash();
Chris@86 2510 QMessageBox::critical(this, tr("Failed to open location"),
Chris@193 2511 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
Chris@193 2512 } else if (status == FileOpenWrongMode) {
Chris@247 2513 emit hideSplash();
Chris@193 2514 QMessageBox::critical(this, tr("Failed to open location"),
Chris@193 2515 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@86 2516 }
Chris@86 2517 }
Chris@86 2518
Chris@86 2519 void
Chris@0 2520 MainWindow::openRecentFile()
Chris@0 2521 {
Chris@0 2522 QObject *obj = sender();
Chris@0 2523 QAction *action = dynamic_cast<QAction *>(obj);
Chris@0 2524
Chris@0 2525 if (!action) {
Chris@0 2526 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
Chris@0 2527 << std::endl;
Chris@0 2528 return;
Chris@0 2529 }
Chris@0 2530
Chris@0 2531 QString path = action->text();
Chris@0 2532 if (path == "") return;
Chris@0 2533
Chris@197 2534 FileOpenStatus status = open(path);
Chris@193 2535
Chris@193 2536 if (status == FileOpenFailed) {
Chris@247 2537 emit hideSplash();
Chris@193 2538 QMessageBox::critical(this, tr("Failed to open location"),
Chris@193 2539 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
Chris@193 2540 } else if (status == FileOpenWrongMode) {
Chris@247 2541 emit hideSplash();
Chris@193 2542 QMessageBox::critical(this, tr("Failed to open location"),
Chris@193 2543 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@0 2544 }
Chris@0 2545 }
Chris@0 2546
Chris@0 2547 void
Chris@200 2548 MainWindow::paneAdded(Pane *pane)
Chris@200 2549 {
Chris@200 2550 if (m_overview) m_overview->registerView(pane);
Chris@200 2551 }
Chris@200 2552
Chris@200 2553 void
Chris@200 2554 MainWindow::paneHidden(Pane *pane)
Chris@200 2555 {
Chris@200 2556 if (m_overview) m_overview->unregisterView(pane);
Chris@200 2557 }
Chris@200 2558
Chris@200 2559 void
Chris@200 2560 MainWindow::paneAboutToBeDeleted(Pane *pane)
Chris@200 2561 {
Chris@200 2562 if (m_overview) m_overview->unregisterView(pane);
Chris@200 2563 }
Chris@200 2564
Chris@200 2565 void
Chris@193 2566 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
Chris@193 2567 {
Chris@193 2568 if (pane) m_paneStack->setCurrentPane(pane);
Chris@193 2569
Chris@193 2570 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
Chris@193 2571
Chris@197 2572 FileOpenStatus status = open(*i, ReplaceCurrentPane);
Chris@193 2573
Chris@193 2574 if (status == FileOpenFailed) {
Chris@247 2575 emit hideSplash();
Chris@193 2576 QMessageBox::critical(this, tr("Failed to open dropped URL"),
Chris@193 2577 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
Chris@193 2578 } else if (status == FileOpenWrongMode) {
Chris@247 2579 emit hideSplash();
Chris@193 2580 QMessageBox::critical(this, tr("Failed to open dropped URL"),
Chris@193 2581 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
Chris@193 2582 }
Chris@193 2583 }
Chris@193 2584 }
Chris@193 2585
Chris@193 2586 void
Chris@193 2587 MainWindow::paneDropAccepted(Pane *pane, QString text)
Chris@193 2588 {
Chris@193 2589 if (pane) m_paneStack->setCurrentPane(pane);
Chris@193 2590
Chris@193 2591 QUrl testUrl(text);
Chris@193 2592 if (testUrl.scheme() == "file" ||
Chris@193 2593 testUrl.scheme() == "http" ||
Chris@193 2594 testUrl.scheme() == "ftp") {
Chris@193 2595 QStringList list;
Chris@193 2596 list.push_back(text);
Chris@193 2597 paneDropAccepted(pane, list);
Chris@193 2598 return;
Chris@193 2599 }
Chris@193 2600
Chris@193 2601 //!!! open as text -- but by importing as if a CSV, or just adding
Chris@193 2602 //to a text layer?
Chris@193 2603 }
Chris@193 2604
Chris@193 2605 void
Chris@0 2606 MainWindow::closeEvent(QCloseEvent *e)
Chris@0 2607 {
Chris@137 2608 // std::cerr << "MainWindow::closeEvent" << std::endl;
Chris@118 2609
Chris@136 2610 if (m_openingAudioFile) {
Chris@137 2611 // std::cerr << "Busy - ignoring close event" << std::endl;
Chris@136 2612 e->ignore();
Chris@136 2613 return;
Chris@136 2614 }
Chris@136 2615
Chris@70 2616 if (!m_abandoning && !checkSaveModified()) {
Chris@137 2617 // std::cerr << "Ignoring close event" << std::endl;
Chris@0 2618 e->ignore();
Chris@0 2619 return;
Chris@0 2620 }
Chris@0 2621
Chris@5 2622 QSettings settings;
Chris@5 2623 settings.beginGroup("MainWindow");
Chris@5 2624 settings.setValue("size", size());
Chris@5 2625 settings.setValue("position", pos());
Chris@5 2626 settings.endGroup();
Chris@5 2627
Chris@163 2628 delete m_keyReference;
Chris@163 2629 m_keyReference = 0;
Chris@163 2630
Chris@163 2631 if (m_preferencesDialog &&
Chris@163 2632 m_preferencesDialog->isVisible()) {
Chris@164 2633 closeSession(); // otherwise we'll have to wait for prefs changes
Chris@163 2634 m_preferencesDialog->applicationClosing(false);
Chris@163 2635 }
Chris@163 2636
Chris@200 2637 closeSession();
Chris@200 2638
Chris@0 2639 e->accept();
Chris@0 2640 return;
Chris@0 2641 }
Chris@0 2642
Chris@0 2643 bool
Chris@11 2644 MainWindow::commitData(bool mayAskUser)
Chris@11 2645 {
Chris@11 2646 if (mayAskUser) {
Chris@163 2647 bool rv = checkSaveModified();
Chris@163 2648 if (rv) {
Chris@163 2649 if (m_preferencesDialog &&
Chris@163 2650 m_preferencesDialog->isVisible()) {
Chris@163 2651 m_preferencesDialog->applicationClosing(false);
Chris@163 2652 }
Chris@163 2653 }
Chris@163 2654 return rv;
Chris@11 2655 } else {
Chris@163 2656 if (m_preferencesDialog &&
Chris@163 2657 m_preferencesDialog->isVisible()) {
Chris@163 2658 m_preferencesDialog->applicationClosing(true);
Chris@163 2659 }
Chris@11 2660 if (!m_documentModified) return true;
Chris@11 2661
Chris@11 2662 // If we can't check with the user first, then we can't save
Chris@11 2663 // to the original session file (even if we have it) -- have
Chris@11 2664 // to use a temporary file
Chris@11 2665
Chris@11 2666 QString svDirBase = ".sv1";
Chris@11 2667 QString svDir = QDir::home().filePath(svDirBase);
Chris@11 2668
Chris@11 2669 if (!QFileInfo(svDir).exists()) {
Chris@11 2670 if (!QDir::home().mkdir(svDirBase)) return false;
Chris@11 2671 } else {
Chris@11 2672 if (!QFileInfo(svDir).isDir()) return false;
Chris@11 2673 }
Chris@11 2674
Chris@11 2675 // This name doesn't have to be unguessable
Chris@93 2676 #ifndef _WIN32
Chris@11 2677 QString fname = QString("tmp-%1-%2.sv")
Chris@11 2678 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
Chris@11 2679 .arg(QProcess().pid());
Chris@93 2680 #else
Chris@93 2681 QString fname = QString("tmp-%1.sv")
Chris@93 2682 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
Chris@93 2683 #endif
Chris@11 2684 QString fpath = QDir(svDir).filePath(fname);
Chris@11 2685 if (saveSessionFile(fpath)) {
Chris@34 2686 m_recentFiles.addFile(fpath);
Chris@11 2687 return true;
Chris@11 2688 } else {
Chris@11 2689 return false;
Chris@11 2690 }
Chris@11 2691 }
Chris@11 2692 }
Chris@11 2693
Chris@11 2694 bool
Chris@0 2695 MainWindow::checkSaveModified()
Chris@0 2696 {
Chris@0 2697 // Called before some destructive operation (e.g. new session,
Chris@0 2698 // exit program). Return true if we can safely proceed, false to
Chris@0 2699 // cancel.
Chris@0 2700
Chris@0 2701 if (!m_documentModified) return true;
Chris@0 2702
Chris@247 2703 emit hideSplash();
Chris@247 2704
Chris@0 2705 int button =
Chris@0 2706 QMessageBox::warning(this,
Chris@0 2707 tr("Session modified"),
Chris@207 2708 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"),
Chris@165 2709 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
Chris@165 2710 QMessageBox::Yes);
Chris@0 2711
Chris@0 2712 if (button == QMessageBox::Yes) {
Chris@0 2713 saveSession();
Chris@0 2714 if (m_documentModified) { // save failed -- don't proceed!
Chris@0 2715 return false;
Chris@0 2716 } else {
Chris@0 2717 return true; // saved, so it's safe to continue now
Chris@0 2718 }
Chris@0 2719 } else if (button == QMessageBox::No) {
Chris@0 2720 m_documentModified = false; // so we know to abandon it
Chris@0 2721 return true;
Chris@0 2722 }
Chris@0 2723
Chris@0 2724 // else cancel
Chris@0 2725 return false;
Chris@0 2726 }
Chris@0 2727
Chris@0 2728 void
Chris@0 2729 MainWindow::saveSession()
Chris@0 2730 {
Chris@0 2731 if (m_sessionFile != "") {
Chris@0 2732 if (!saveSessionFile(m_sessionFile)) {
Chris@0 2733 QMessageBox::critical(this, tr("Failed to save file"),
Chris@193 2734 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile));
Chris@0 2735 } else {
Chris@0 2736 CommandHistory::getInstance()->documentSaved();
Chris@0 2737 documentRestored();
Chris@0 2738 }
Chris@0 2739 } else {
Chris@0 2740 saveSessionAs();
Chris@0 2741 }
Chris@0 2742 }
Chris@0 2743
Chris@0 2744 void
Chris@0 2745 MainWindow::saveSessionAs()
Chris@0 2746 {
Chris@0 2747 QString orig = m_audioFile;
Chris@0 2748 if (orig == "") orig = ".";
Chris@0 2749 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
Chris@0 2750
Chris@88 2751 QString path = getSaveFileName(FileFinder::SessionFile);
Chris@81 2752
Chris@81 2753 if (path == "") return;
Chris@0 2754
Chris@0 2755 if (!saveSessionFile(path)) {
Chris@0 2756 QMessageBox::critical(this, tr("Failed to save file"),
Chris@193 2757 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
Chris@0 2758 } else {
Chris@0 2759 setWindowTitle(tr("Sonic Visualiser: %1")
Chris@0 2760 .arg(QFileInfo(path).fileName()));
Chris@0 2761 m_sessionFile = path;
Chris@0 2762 CommandHistory::getInstance()->documentSaved();
Chris@0 2763 documentRestored();
Chris@34 2764 m_recentFiles.addFile(path);
Chris@0 2765 }
Chris@0 2766 }
Chris@0 2767
Chris@90 2768 void
Chris@72 2769 MainWindow::preferenceChanged(PropertyContainer::PropertyName name)
Chris@72 2770 {
Chris@200 2771 MainWindowBase::preferenceChanged(name);
Chris@200 2772
Chris@200 2773 if (name == "Background Mode" && m_viewManager) {
Chris@180 2774 if (m_viewManager->getGlobalDarkBackground()) {
Chris@180 2775 m_panLayer->setBaseColour
Chris@180 2776 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
Chris@180 2777 } else {
Chris@180 2778 m_panLayer->setBaseColour
Chris@180 2779 (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
Chris@180 2780 }
Chris@200 2781 }
Chris@0 2782 }
Chris@0 2783
Chris@0 2784 void
Chris@239 2785 MainWindow::propertyStacksResized(int width)
Chris@239 2786 {
Chris@251 2787 // std::cerr << "MainWindow::propertyStacksResized(" << width << ")" << std::endl;
Chris@239 2788
Chris@239 2789 if (!m_playControlsSpacer) return;
Chris@239 2790
Chris@239 2791 int spacerWidth = width - m_playControlsWidth - 4;
Chris@239 2792
Chris@251 2793 // std::cerr << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << std::endl;
Chris@239 2794
Chris@239 2795 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
Chris@239 2796 }
Chris@239 2797
Chris@239 2798 void
Chris@0 2799 MainWindow::addPane()
Chris@0 2800 {
Chris@0 2801 QObject *s = sender();
Chris@0 2802 QAction *action = dynamic_cast<QAction *>(s);
Chris@0 2803
Chris@0 2804 if (!action) {
Chris@0 2805 std::cerr << "WARNING: MainWindow::addPane: sender is not an action"
Chris@0 2806 << std::endl;
Chris@0 2807 return;
Chris@0 2808 }
Chris@0 2809
Chris@0 2810 PaneActionMap::iterator i = m_paneActions.find(action);
Chris@0 2811
Chris@0 2812 if (i == m_paneActions.end()) {
Chris@0 2813 std::cerr << "WARNING: MainWindow::addPane: unknown action "
Chris@0 2814 << action->objectName().toStdString() << std::endl;
Chris@0 2815 return;
Chris@0 2816 }
Chris@0 2817
Chris@69 2818 addPane(i->second, action->text());
Chris@69 2819 }
Chris@69 2820
Chris@69 2821 void
Chris@232 2822 MainWindow::addPane(const LayerConfiguration &configuration, QString text)
Chris@69 2823 {
Chris@69 2824 CommandHistory::getInstance()->startCompoundOperation(text, true);
Chris@0 2825
Chris@0 2826 AddPaneCommand *command = new AddPaneCommand(this);
Chris@0 2827 CommandHistory::getInstance()->addCommand(command);
Chris@0 2828
Chris@0 2829 Pane *pane = command->getPane();
Chris@0 2830
Chris@69 2831 if (configuration.layer == LayerFactory::Spectrum) {
Chris@109 2832 pane->setPlaybackFollow(PlaybackScrollContinuous);
Chris@110 2833 pane->setFollowGlobalZoom(false);
Chris@112 2834 pane->setZoomLevel(512);
Chris@7 2835 }
Chris@7 2836
Chris@69 2837 if (configuration.layer != LayerFactory::TimeRuler &&
Chris@69 2838 configuration.layer != LayerFactory::Spectrum) {
Chris@8 2839
Chris@0 2840 if (!m_timeRulerLayer) {
Chris@0 2841 // std::cerr << "no time ruler layer, creating one" << std::endl;
Chris@0 2842 m_timeRulerLayer = m_document->createMainModelLayer
Chris@0 2843 (LayerFactory::TimeRuler);
Chris@0 2844 }
Chris@0 2845
Chris@0 2846 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl;
Chris@0 2847
Chris@0 2848 m_document->addLayerToView(pane, m_timeRulerLayer);
Chris@0 2849 }
Chris@0 2850
Chris@69 2851 Layer *newLayer = m_document->createLayer(configuration.layer);
Chris@69 2852
Chris@69 2853 Model *suggestedModel = configuration.sourceModel;
Chris@66 2854 Model *model = 0;
Chris@66 2855
Chris@66 2856 if (suggestedModel) {
Chris@66 2857
Chris@66 2858 // check its validity
Chris@224 2859 std::vector<Model *> inputModels = m_document->getTransformInputModels();
Chris@66 2860 for (size_t j = 0; j < inputModels.size(); ++j) {
Chris@66 2861 if (inputModels[j] == suggestedModel) {
Chris@66 2862 model = suggestedModel;
Chris@66 2863 break;
Chris@66 2864 }
Chris@66 2865 }
Chris@66 2866
Chris@66 2867 if (!model) {
Chris@66 2868 std::cerr << "WARNING: Model " << (void *)suggestedModel
Chris@66 2869 << " appears in pane action map, but is not reported "
Chris@66 2870 << "by document as a valid transform source" << std::endl;
Chris@66 2871 }
Chris@66 2872 }
Chris@66 2873
Chris@66 2874 if (!model) model = m_document->getMainModel();
Chris@66 2875
Chris@66 2876 m_document->setModel(newLayer, model);
Chris@66 2877
Chris@69 2878 m_document->setChannel(newLayer, configuration.channel);
Chris@0 2879 m_document->addLayerToView(pane, newLayer);
Chris@0 2880
Chris@0 2881 m_paneStack->setCurrentPane(pane);
Chris@70 2882 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@0 2883
Chris@130 2884 // std::cerr << "MainWindow::addPane: global centre frame is "
Chris@130 2885 // << m_viewManager->getGlobalCentreFrame() << std::endl;
Chris@130 2886 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
Chris@73 2887
Chris@0 2888 CommandHistory::getInstance()->endCompoundOperation();
Chris@0 2889
Chris@0 2890 updateMenuStates();
Chris@0 2891 }
Chris@0 2892
Chris@0 2893 void
Chris@0 2894 MainWindow::addLayer()
Chris@0 2895 {
Chris@0 2896 QObject *s = sender();
Chris@0 2897 QAction *action = dynamic_cast<QAction *>(s);
Chris@0 2898
Chris@0 2899 if (!action) {
Chris@0 2900 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action"
Chris@0 2901 << std::endl;
Chris@0 2902 return;
Chris@0 2903 }
Chris@0 2904
Chris@0 2905 Pane *pane = m_paneStack->getCurrentPane();
Chris@0 2906
Chris@0 2907 if (!pane) {
Chris@0 2908 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
Chris@0 2909 return;
Chris@0 2910 }
Chris@0 2911
Chris@0 2912 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
Chris@0 2913
Chris@0 2914 if (ei != m_existingLayerActions.end()) {
Chris@0 2915 Layer *newLayer = ei->second;
Chris@0 2916 m_document->addLayerToView(pane, newLayer);
Chris@0 2917 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@0 2918 return;
Chris@0 2919 }
Chris@0 2920
Chris@95 2921 ei = m_sliceActions.find(action);
Chris@95 2922
Chris@95 2923 if (ei != m_sliceActions.end()) {
Chris@95 2924 Layer *newLayer = m_document->createLayer(LayerFactory::Slice);
Chris@95 2925 // document->setModel(newLayer, ei->second->getModel());
Chris@95 2926 SliceableLayer *source = dynamic_cast<SliceableLayer *>(ei->second);
Chris@95 2927 SliceLayer *dest = dynamic_cast<SliceLayer *>(newLayer);
Chris@95 2928 if (source && dest) {
Chris@205 2929 //!!!???
Chris@95 2930 dest->setSliceableModel(source->getSliceableModel());
Chris@95 2931 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)),
Chris@95 2932 dest, SLOT(sliceableModelReplaced(const Model *, const Model *)));
Chris@95 2933 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
Chris@95 2934 dest, SLOT(modelAboutToBeDeleted(Model *)));
Chris@95 2935 }
Chris@95 2936 m_document->addLayerToView(pane, newLayer);
Chris@95 2937 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@95 2938 return;
Chris@95 2939 }
Chris@95 2940
Chris@211 2941 TransformActionMap::iterator i = m_transformActions.find(action);
Chris@34 2942
Chris@34 2943 if (i == m_transformActions.end()) {
Chris@0 2944
Chris@0 2945 LayerActionMap::iterator i = m_layerActions.find(action);
Chris@0 2946
Chris@0 2947 if (i == m_layerActions.end()) {
Chris@0 2948 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
Chris@0 2949 << action->objectName().toStdString() << std::endl;
Chris@0 2950 return;
Chris@0 2951 }
Chris@0 2952
Chris@232 2953 LayerFactory::LayerType type = i->second.layer;
Chris@0 2954
Chris@0 2955 LayerFactory::LayerTypeSet emptyTypes =
Chris@0 2956 LayerFactory::getInstance()->getValidEmptyLayerTypes();
Chris@0 2957
Chris@0 2958 Layer *newLayer;
Chris@0 2959
Chris@0 2960 if (emptyTypes.find(type) != emptyTypes.end()) {
Chris@0 2961
Chris@0 2962 newLayer = m_document->createEmptyLayer(type);
Chris@217 2963 if (newLayer) {
Chris@217 2964 m_toolActions[ViewManager::DrawMode]->trigger();
Chris@217 2965 }
Chris@0 2966
Chris@0 2967 } else {
Chris@0 2968
Chris@238 2969 if (!i->second.sourceModel) {
Chris@238 2970 // e.g. time ruler
Chris@238 2971 newLayer = m_document->createMainModelLayer(type);
Chris@232 2972 } else {
Chris@238 2973 newLayer = m_document->createLayer(type);
Chris@238 2974 if (m_document->isKnownModel(i->second.sourceModel)) {
Chris@238 2975 m_document->setChannel(newLayer, i->second.channel);
Chris@238 2976 m_document->setModel(newLayer, i->second.sourceModel);
Chris@238 2977 } else {
Chris@238 2978 std::cerr << "WARNING: MainWindow::addLayer: unknown model "
Chris@238 2979 << i->second.sourceModel
Chris@238 2980 << " (\""
Chris@238 2981 << (i->second.sourceModel ? i->second.sourceModel->objectName().toStdString() : "")
Chris@238 2982 << "\") in layer action map"
Chris@238 2983 << std::endl;
Chris@238 2984 }
Chris@232 2985 }
Chris@238 2986 }
Chris@0 2987
Chris@217 2988 if (newLayer) {
Chris@217 2989 m_document->addLayerToView(pane, newLayer);
Chris@217 2990 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@217 2991 }
Chris@0 2992
Chris@0 2993 return;
Chris@0 2994 }
Chris@0 2995
Chris@224 2996 //!!! want to do something like this, but it's not supported in
Chris@224 2997 //ModelTransformerFactory yet
Chris@224 2998 /*
Chris@0 2999 int channel = -1;
Chris@0 3000 // pick up the default channel from any existing layers on the same pane
Chris@0 3001 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@0 3002 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
Chris@0 3003 if (c != -1) {
Chris@0 3004 channel = c;
Chris@0 3005 break;
Chris@0 3006 }
Chris@0 3007 }
Chris@224 3008 */
Chris@0 3009
Chris@33 3010 // We always ask for configuration, even if the plugin isn't
Chris@33 3011 // supposed to be configurable, because we need to let the user
Chris@33 3012 // change the execution context (block size etc).
Chris@0 3013
Chris@224 3014 QString transformId = i->second;
Chris@274 3015
Chris@274 3016 addLayer(transformId);
Chris@274 3017 }
Chris@274 3018
Chris@274 3019 void
Chris@274 3020 MainWindow::addLayer(QString transformId)
Chris@274 3021 {
Chris@274 3022 Pane *pane = m_paneStack->getCurrentPane();
Chris@274 3023 if (!pane) {
Chris@274 3024 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl;
Chris@274 3025 return;
Chris@274 3026 }
Chris@274 3027
Chris@224 3028 Transform transform = TransformFactory::getInstance()->
Chris@224 3029 getDefaultTransformFor(transformId);
Chris@27 3030
Chris@66 3031 std::vector<Model *> candidateInputModels =
Chris@224 3032 m_document->getTransformInputModels();
Chris@53 3033
Chris@219 3034 Model *defaultInputModel = 0;
Chris@219 3035 for (int j = 0; j < pane->getLayerCount(); ++j) {
Chris@219 3036 Layer *layer = pane->getLayer(j);
Chris@219 3037 if (!layer) continue;
Chris@243 3038 if (LayerFactory::getInstance()->getLayerType(layer) !=
Chris@243 3039 LayerFactory::Waveform &&
Chris@243 3040 !layer->isLayerOpaque()) continue;
Chris@219 3041 Model *model = layer->getModel();
Chris@219 3042 if (!model) continue;
Chris@219 3043 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
Chris@219 3044 if (candidateInputModels[k] == model) {
Chris@219 3045 defaultInputModel = model;
Chris@219 3046 break;
Chris@219 3047 }
Chris@219 3048 }
Chris@219 3049 if (defaultInputModel) break;
Chris@219 3050 }
Chris@219 3051
Chris@184 3052 size_t startFrame = 0, duration = 0;
Chris@184 3053 size_t endFrame = 0;
Chris@184 3054 m_viewManager->getSelection().getExtents(startFrame, endFrame);
Chris@184 3055 if (endFrame > startFrame) duration = endFrame - startFrame;
Chris@184 3056 else startFrame = 0;
Chris@184 3057
Chris@224 3058 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
Chris@224 3059 getConfigurationForTransform
Chris@211 3060 (transform,
Chris@211 3061 candidateInputModels,
Chris@219 3062 defaultInputModel,
Chris@211 3063 m_playSource,
Chris@211 3064 startFrame,
Chris@211 3065 duration);
Chris@211 3066
Chris@224 3067 if (!input.getModel()) return;
Chris@224 3068
Chris@224 3069 // std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl;
Chris@224 3070
Chris@224 3071 Layer *newLayer = m_document->createDerivedLayer(transform, input);
Chris@0 3072
Chris@0 3073 if (newLayer) {
Chris@0 3074 m_document->addLayerToView(pane, newLayer);
Chris@224 3075 m_document->setChannel(newLayer, input.getChannel());
Chris@224 3076 m_recentTransforms.add(transformId);
Chris@70 3077 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@0 3078 }
Chris@0 3079
Chris@0 3080 updateMenuStates();
Chris@0 3081 }
Chris@0 3082
Chris@0 3083 void
Chris@0 3084 MainWindow::renameCurrentLayer()
Chris@0 3085 {
Chris@0 3086 Pane *pane = m_paneStack->getCurrentPane();
Chris@0 3087 if (pane) {
Chris@0 3088 Layer *layer = pane->getSelectedLayer();
Chris@0 3089 if (layer) {
Chris@0 3090 bool ok = false;
Chris@0 3091 QString newName = QInputDialog::getText
Chris@0 3092 (this, tr("Rename Layer"),
Chris@0 3093 tr("New name for this layer:"),
Chris@0 3094 QLineEdit::Normal, layer->objectName(), &ok);
Chris@0 3095 if (ok) {
Chris@239 3096 layer->setPresentationName(newName);
Chris@95 3097 setupExistingLayersMenus();
Chris@0 3098 }
Chris@0 3099 }
Chris@0 3100 }
Chris@0 3101 }
Chris@0 3102
Chris@0 3103 void
Chris@272 3104 MainWindow::findTransform()
Chris@272 3105 {
Chris@274 3106 TransformFinder *finder = new TransformFinder(this);
Chris@274 3107 if (!finder->exec()) {
Chris@274 3108 delete finder;
Chris@274 3109 return;
Chris@273 3110 }
Chris@274 3111 TransformId transform = finder->getTransform();
Chris@274 3112 delete finder;
Chris@274 3113 addLayer(transform);
Chris@272 3114 }
Chris@272 3115
Chris@272 3116 void
Chris@207 3117 MainWindow::playSoloToggled()
Chris@207 3118 {
Chris@207 3119 MainWindowBase::playSoloToggled();
Chris@207 3120 m_soloModified = true;
Chris@207 3121 }
Chris@207 3122
Chris@207 3123 void
Chris@206 3124 MainWindow::alignToggled()
Chris@206 3125 {
Chris@206 3126 QAction *action = dynamic_cast<QAction *>(sender());
Chris@206 3127
Chris@207 3128 if (!m_viewManager) return;
Chris@207 3129
Chris@206 3130 if (action) {
Chris@206 3131 m_viewManager->setAlignMode(action->isChecked());
Chris@206 3132 } else {
Chris@206 3133 m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
Chris@206 3134 }
Chris@206 3135
Chris@206 3136 if (m_viewManager->getAlignMode()) {
Chris@207 3137 m_prevSolo = m_soloAction->isChecked();
Chris@208 3138 if (!m_soloAction->isChecked()) {
Chris@208 3139 m_soloAction->setChecked(true);
Chris@208 3140 MainWindowBase::playSoloToggled();
Chris@208 3141 }
Chris@207 3142 m_soloModified = false;
Chris@207 3143 emit canChangeSolo(false);
Chris@206 3144 m_document->alignModels();
Chris@206 3145 m_document->setAutoAlignment(true);
Chris@206 3146 } else {
Chris@207 3147 if (!m_soloModified) {
Chris@208 3148 if (m_soloAction->isChecked() != m_prevSolo) {
Chris@208 3149 m_soloAction->setChecked(m_prevSolo);
Chris@208 3150 MainWindowBase::playSoloToggled();
Chris@208 3151 }
Chris@207 3152 }
Chris@207 3153 emit canChangeSolo(true);
Chris@206 3154 m_document->setAutoAlignment(false);
Chris@206 3155 }
Chris@206 3156
Chris@206 3157 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
Chris@206 3158
Chris@206 3159 Pane *pane = m_paneStack->getPane(i);
Chris@206 3160 if (!pane) continue;
Chris@206 3161
Chris@206 3162 pane->update();
Chris@206 3163 }
Chris@206 3164 }
Chris@206 3165
Chris@206 3166 void
Chris@59 3167 MainWindow::playSpeedChanged(int position)
Chris@0 3168 {
Chris@59 3169 PlaySpeedRangeMapper mapper(0, 200);
Chris@60 3170
Chris@60 3171 float percent = m_playSpeed->mappedValue();
Chris@60 3172 float factor = mapper.getFactorForValue(percent);
Chris@60 3173
Chris@267 3174 // std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl;
Chris@60 3175
Chris@59 3176 bool something = (position != 100);
Chris@155 3177
Chris@59 3178 int pc = lrintf(percent);
Chris@21 3179
Chris@155 3180 if (!something) {
Chris@155 3181 contextHelpChanged(tr("Playback speed: Normal"));
Chris@155 3182 } else {
Chris@155 3183 contextHelpChanged(tr("Playback speed: %1%2%")
Chris@155 3184 .arg(position > 100 ? "+" : "")
Chris@155 3185 .arg(pc));
Chris@155 3186 }
Chris@155 3187
Chris@240 3188 m_playSource->setTimeStretch(factor);
Chris@155 3189
Chris@155 3190 updateMenuStates();
Chris@16 3191 }
Chris@16 3192
Chris@26 3193 void
Chris@155 3194 MainWindow::speedUpPlayback()
Chris@155 3195 {
Chris@155 3196 int value = m_playSpeed->value();
Chris@155 3197 value = value + m_playSpeed->pageStep();
Chris@155 3198 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
Chris@155 3199 m_playSpeed->setValue(value);
Chris@155 3200 }
Chris@155 3201
Chris@155 3202 void
Chris@155 3203 MainWindow::slowDownPlayback()
Chris@155 3204 {
Chris@155 3205 int value = m_playSpeed->value();
Chris@155 3206 value = value - m_playSpeed->pageStep();
Chris@155 3207 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
Chris@155 3208 m_playSpeed->setValue(value);
Chris@155 3209 }
Chris@155 3210
Chris@155 3211 void
Chris@155 3212 MainWindow::restoreNormalPlayback()
Chris@155 3213 {
Chris@155 3214 m_playSpeed->setValue(m_playSpeed->defaultValue());
Chris@155 3215 }
Chris@155 3216
Chris@155 3217 void
Chris@227 3218 MainWindow::currentPaneChanged(Pane *pane)
Chris@227 3219 {
Chris@228 3220 MainWindowBase::currentPaneChanged(pane);
Chris@228 3221
Chris@227 3222 if (!pane || !m_panLayer) return;
Chris@227 3223 for (int i = pane->getLayerCount(); i > 0; ) {
Chris@227 3224 --i;
Chris@227 3225 Layer *layer = pane->getLayer(i);
Chris@227 3226 if (LayerFactory::getInstance()->getLayerType(layer) ==
Chris@227 3227 LayerFactory::Waveform) {
Chris@227 3228 RangeSummarisableTimeValueModel *tvm =
Chris@227 3229 dynamic_cast<RangeSummarisableTimeValueModel *>(layer->getModel());
Chris@227 3230 if (tvm) {
Chris@227 3231 m_panLayer->setModel(tvm);
Chris@227 3232 return;
Chris@227 3233 }
Chris@227 3234 }
Chris@227 3235 }
Chris@227 3236 }
Chris@227 3237
Chris@227 3238 void
Chris@116 3239 MainWindow::updateVisibleRangeDisplay(Pane *p) const
Chris@116 3240 {
Chris@116 3241 if (!getMainModel() || !p) {
Chris@116 3242 return;
Chris@116 3243 }
Chris@116 3244
Chris@117 3245 bool haveSelection = false;
Chris@117 3246 size_t startFrame = 0, endFrame = 0;
Chris@117 3247
Chris@117 3248 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
Chris@117 3249
Chris@117 3250 bool exclusive = false;
Chris@117 3251 Selection s = m_viewManager->getInProgressSelection(exclusive);
Chris@117 3252
Chris@117 3253 if (!s.isEmpty()) {
Chris@117 3254 haveSelection = true;
Chris@117 3255 startFrame = s.getStartFrame();
Chris@117 3256 endFrame = s.getEndFrame();
Chris@117 3257 }
Chris@117 3258 }
Chris@117 3259
Chris@117 3260 if (!haveSelection) {
Chris@117 3261 startFrame = p->getFirstVisibleFrame();
Chris@117 3262 endFrame = p->getLastVisibleFrame();
Chris@117 3263 }
Chris@117 3264
Chris@116 3265 RealTime start = RealTime::frame2RealTime
Chris@117 3266 (startFrame, getMainModel()->getSampleRate());
Chris@116 3267
Chris@116 3268 RealTime end = RealTime::frame2RealTime
Chris@117 3269 (endFrame, getMainModel()->getSampleRate());
Chris@116 3270
Chris@116 3271 RealTime duration = end - start;
Chris@116 3272
Chris@116 3273 QString startStr, endStr, durationStr;
Chris@116 3274 startStr = start.toText(true).c_str();
Chris@116 3275 endStr = end.toText(true).c_str();
Chris@116 3276 durationStr = duration.toText(true).c_str();
Chris@116 3277
Chris@117 3278 if (haveSelection) {
Chris@117 3279 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
Chris@117 3280 .arg(startStr).arg(endStr).arg(durationStr);
Chris@117 3281 } else {
Chris@117 3282 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
Chris@117 3283 .arg(startStr).arg(endStr).arg(durationStr);
Chris@117 3284 }
Chris@116 3285
Chris@116 3286 statusBar()->showMessage(m_myStatusMessage);
Chris@116 3287 }
Chris@116 3288
Chris@116 3289 void
Chris@0 3290 MainWindow::outputLevelsChanged(float left, float right)
Chris@0 3291 {
Chris@0 3292 m_fader->setPeakLeft(left);
Chris@0 3293 m_fader->setPeakRight(right);
Chris@0 3294 }
Chris@0 3295
Chris@0 3296 void
Chris@0 3297 MainWindow::sampleRateMismatch(size_t requested, size_t actual,
Chris@0 3298 bool willResample)
Chris@0 3299 {
Chris@0 3300 if (!willResample) {
Chris@247 3301 emit hideSplash();
Chris@0 3302 QMessageBox::information
Chris@0 3303 (this, tr("Sample rate mismatch"),
Chris@193 3304 tr("<b>Wrong sample rate</b><p>The sample rate of this audio file (%1 Hz) does not match\nthe current playback rate (%2 Hz).<p>The file will play at the wrong speed and pitch.<p>Change the <i>Resample mismatching files on import</i> option under <i>File</i> -> <i>Preferences</i> if you want to alter this behaviour.")
Chris@0 3305 .arg(requested).arg(actual));
Chris@0 3306 }
Chris@0 3307
Chris@0 3308 updateDescriptionLabel();
Chris@0 3309 }
Chris@0 3310
Chris@0 3311 void
Chris@42 3312 MainWindow::audioOverloadPluginDisabled()
Chris@42 3313 {
Chris@42 3314 QMessageBox::information
Chris@42 3315 (this, tr("Audio processing overload"),
Chris@193 3316 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
Chris@42 3317 }
Chris@42 3318
Chris@42 3319 void
Chris@266 3320 MainWindow::audioTimeStretchMultiChannelDisabled()
Chris@266 3321 {
Chris@266 3322 static bool shownOnce = false;
Chris@266 3323 if (shownOnce) return;
Chris@266 3324 QMessageBox::information
Chris@266 3325 (this, tr("Audio processing overload"),
Chris@266 3326 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
Chris@266 3327 shownOnce = true;
Chris@266 3328 }
Chris@266 3329
Chris@266 3330 void
Chris@200 3331 MainWindow::layerRemoved(Layer *layer)
Chris@0 3332 {
Chris@95 3333 setupExistingLayersMenus();
Chris@200 3334 MainWindowBase::layerRemoved(layer);
Chris@0 3335 }
Chris@0 3336
Chris@0 3337 void
Chris@0 3338 MainWindow::layerInAView(Layer *layer, bool inAView)
Chris@0 3339 {
Chris@95 3340 setupExistingLayersMenus();
Chris@200 3341 MainWindowBase::layerInAView(layer, inAView);
Chris@0 3342 }
Chris@0 3343
Chris@0 3344 void
Chris@0 3345 MainWindow::modelAdded(Model *model)
Chris@0 3346 {
Chris@200 3347 MainWindowBase::modelAdded(model);
Chris@66 3348 if (dynamic_cast<DenseTimeValueModel *>(model)) {
Chris@66 3349 setupPaneAndLayerMenus();
Chris@66 3350 }
Chris@0 3351 }
Chris@0 3352
Chris@0 3353 void
Chris@0 3354 MainWindow::mainModelChanged(WaveFileModel *model)
Chris@0 3355 {
Chris@0 3356 m_panLayer->setModel(model);
Chris@200 3357
Chris@200 3358 MainWindowBase::mainModelChanged(model);
Chris@200 3359
Chris@200 3360 if (m_playTarget) {
Chris@200 3361 connect(m_fader, SIGNAL(valueChanged(float)),
Chris@200 3362 m_playTarget, SLOT(setOutputGain(float)));
Chris@200 3363 }
Chris@0 3364 }
Chris@0 3365
Chris@0 3366 void
Chris@200 3367 MainWindow::setInstantsNumbering()
Chris@0 3368 {
Chris@200 3369 QAction *a = dynamic_cast<QAction *>(sender());
Chris@200 3370 if (!a) return;
Chris@200 3371
Chris@200 3372 int type = m_numberingActions[a];
Chris@200 3373
Chris@200 3374 if (m_labeller) m_labeller->setType(Labeller::ValueType(type));
Chris@200 3375
Chris@200 3376 QSettings settings;
Chris@200 3377 settings.beginGroup("MainWindow");
Chris@200 3378 settings.setValue("labellertype", type);
Chris@200 3379 settings.endGroup();
Chris@200 3380 }
Chris@200 3381
Chris@200 3382 void
Chris@200 3383 MainWindow::setInstantsCounterCycle()
Chris@200 3384 {
Chris@200 3385 QAction *a = dynamic_cast<QAction *>(sender());
Chris@200 3386 if (!a) return;
Chris@200 3387
Chris@200 3388 int cycle = a->text().toInt();
Chris@200 3389 if (cycle == 0) return;
Chris@200 3390
Chris@200 3391 if (m_labeller) m_labeller->setCounterCycleSize(cycle);
Chris@200 3392
Chris@200 3393 QSettings settings;
Chris@200 3394 settings.beginGroup("MainWindow");
Chris@200 3395 settings.setValue("labellercycle", cycle);
Chris@200 3396 settings.endGroup();
Chris@200 3397 }
Chris@200 3398
Chris@200 3399 void
Chris@200 3400 MainWindow::resetInstantsCounters()
Chris@200 3401 {
Chris@200 3402 LabelCounterInputDialog dialog(m_labeller, this);
Chris@241 3403 dialog.setWindowTitle(tr("Reset Counters"));
Chris@200 3404 dialog.exec();
Chris@0 3405 }
Chris@0 3406
Chris@0 3407 void
Chris@233 3408 MainWindow::modelGenerationFailed(QString transformName, QString message)
Chris@233 3409 {
Chris@247 3410 emit hideSplash();
Chris@247 3411
Chris@233 3412 if (message != "") {
Chris@233 3413
Chris@233 3414 QMessageBox::warning
Chris@233 3415 (this,
Chris@233 3416 tr("Failed to generate layer"),
Chris@233 3417 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
Chris@233 3418 .arg(transformName).arg(message),
Chris@233 3419 QMessageBox::Ok);
Chris@233 3420 } else {
Chris@233 3421 QMessageBox::warning
Chris@233 3422 (this,
Chris@233 3423 tr("Failed to generate layer"),
Chris@233 3424 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@233 3425 .arg(transformName),
Chris@233 3426 QMessageBox::Ok);
Chris@233 3427 }
Chris@233 3428 }
Chris@233 3429
Chris@233 3430 void
Chris@233 3431 MainWindow::modelGenerationWarning(QString transformName, QString message)
Chris@233 3432 {
Chris@247 3433 emit hideSplash();
Chris@247 3434
Chris@233 3435 QMessageBox::warning
Chris@233 3436 (this, tr("Warning"), message, QMessageBox::Ok);
Chris@233 3437 }
Chris@233 3438
Chris@233 3439 void
Chris@233 3440 MainWindow::modelRegenerationFailed(QString layerName,
Chris@233 3441 QString transformName, QString message)
Chris@233 3442 {
Chris@247 3443 emit hideSplash();
Chris@247 3444
Chris@233 3445 if (message != "") {
Chris@233 3446
Chris@233 3447 QMessageBox::warning
Chris@233 3448 (this,
Chris@233 3449 tr("Failed to regenerate layer"),
Chris@233 3450 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@233 3451 .arg(layerName).arg(transformName).arg(message),
Chris@233 3452 QMessageBox::Ok);
Chris@233 3453 } else {
Chris@233 3454 QMessageBox::warning
Chris@233 3455 (this,
Chris@233 3456 tr("Failed to regenerate layer"),
Chris@233 3457 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@233 3458 .arg(layerName).arg(transformName),
Chris@233 3459 QMessageBox::Ok);
Chris@233 3460 }
Chris@233 3461 }
Chris@233 3462
Chris@233 3463 void
Chris@233 3464 MainWindow::modelRegenerationWarning(QString layerName,
Chris@233 3465 QString transformName, QString message)
Chris@233 3466 {
Chris@247 3467 emit hideSplash();
Chris@247 3468
Chris@233 3469 QMessageBox::warning
Chris@233 3470 (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@233 3471 }
Chris@233 3472
Chris@233 3473 void
Chris@233 3474 MainWindow::alignmentFailed(QString transformName, QString message)
Chris@0 3475 {
Chris@247 3476 emit hideSplash();
Chris@247 3477
Chris@0 3478 QMessageBox::warning
Chris@0 3479 (this,
Chris@233 3480 tr("Failed to calculate alignment"),
Chris@233 3481 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
Chris@233 3482 .arg(transformName).arg(message),
Chris@165 3483 QMessageBox::Ok);
Chris@0 3484 }
Chris@0 3485
Chris@0 3486 void
Chris@0 3487 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
Chris@0 3488 {
Chris@0 3489 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl;
Chris@0 3490 m_paneStack->setCurrentPane(pane);
Chris@0 3491 m_rightButtonMenu->popup(position);
Chris@0 3492 }
Chris@0 3493
Chris@0 3494 void
Chris@0 3495 MainWindow::showLayerTree()
Chris@0 3496 {
Chris@219 3497 if (!m_layerTreeDialog.isNull()) {
Chris@219 3498 m_layerTreeDialog->show();
Chris@219 3499 m_layerTreeDialog->raise();
Chris@177 3500 return;
Chris@177 3501 }
Chris@177 3502
Chris@219 3503 m_layerTreeDialog = new LayerTreeDialog(m_paneStack);
Chris@232 3504 m_layerTreeDialog->setAttribute(Qt::WA_DeleteOnClose); // see below
Chris@219 3505 m_layerTreeDialog->show();
Chris@0 3506 }
Chris@0 3507
Chris@0 3508 void
Chris@0 3509 MainWindow::preferences()
Chris@0 3510 {
Chris@0 3511 if (!m_preferencesDialog.isNull()) {
Chris@0 3512 m_preferencesDialog->show();
Chris@0 3513 m_preferencesDialog->raise();
Chris@0 3514 return;
Chris@0 3515 }
Chris@0 3516
Chris@0 3517 m_preferencesDialog = new PreferencesDialog(this);
Chris@0 3518
Chris@0 3519 // DeleteOnClose is safe here, because m_preferencesDialog is a
Chris@0 3520 // QPointer that will be zeroed when the dialog is deleted. We
Chris@0 3521 // use it in preference to leaving the dialog lying around because
Chris@0 3522 // if you Cancel the dialog, it resets the preferences state
Chris@0 3523 // without resetting its own widgets, so its state will be
Chris@0 3524 // incorrect when next shown unless we construct it afresh
Chris@0 3525 m_preferencesDialog->setAttribute(Qt::WA_DeleteOnClose);
Chris@0 3526
Chris@0 3527 m_preferencesDialog->show();
Chris@0 3528 }
Chris@0 3529
Chris@0 3530 void
Chris@90 3531 MainWindow::mouseEnteredWidget()
Chris@90 3532 {
Chris@90 3533 QWidget *w = dynamic_cast<QWidget *>(sender());
Chris@90 3534 if (!w) return;
Chris@90 3535
Chris@90 3536 if (w == m_fader) {
Chris@116 3537 contextHelpChanged(tr("Adjust the master playback level"));
Chris@90 3538 } else if (w == m_playSpeed) {
Chris@116 3539 contextHelpChanged(tr("Adjust the master playback speed"));
Chris@90 3540 }
Chris@90 3541 }
Chris@90 3542
Chris@90 3543 void
Chris@90 3544 MainWindow::mouseLeftWidget()
Chris@90 3545 {
Chris@116 3546 contextHelpChanged("");
Chris@116 3547 }
Chris@116 3548
Chris@116 3549 void
Chris@0 3550 MainWindow::website()
Chris@0 3551 {
Chris@0 3552 openHelpUrl(tr("http://www.sonicvisualiser.org/"));
Chris@0 3553 }
Chris@0 3554
Chris@0 3555 void
Chris@0 3556 MainWindow::help()
Chris@0 3557 {
Chris@267 3558 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/1.3/en/"));
Chris@0 3559 }
Chris@0 3560
Chris@0 3561 void
Chris@0 3562 MainWindow::about()
Chris@0 3563 {
Chris@0 3564 bool debug = false;
Chris@0 3565 QString version = "(unknown version)";
Chris@0 3566
Chris@0 3567 #ifdef BUILD_DEBUG
Chris@0 3568 debug = true;
Chris@0 3569 #endif
Chris@0 3570 #ifdef SV_VERSION
Chris@0 3571 #ifdef SVNREV
Chris@0 3572 version = tr("Release %1 : Revision %2").arg(SV_VERSION).arg(SVNREV);
Chris@0 3573 #else
Chris@0 3574 version = tr("Release %1").arg(SV_VERSION);
Chris@0 3575 #endif
Chris@0 3576 #else
Chris@0 3577 #ifdef SVNREV
Chris@0 3578 version = tr("Unreleased : Revision %1").arg(SVNREV);
Chris@0 3579 #endif
Chris@0 3580 #endif
Chris@0 3581
Chris@0 3582 QString aboutText;
Chris@0 3583
Chris@0 3584 aboutText += tr("<h3>About Sonic Visualiser</h3>");
Chris@231 3585 aboutText += tr("<p>Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p>");
Chris@111 3586 aboutText += tr("<p>%1 : %2 configuration</p>")
Chris@0 3587 .arg(version)
Chris@0 3588 .arg(debug ? tr("Debug") : tr("Release"));
Chris@0 3589
Chris@132 3590 #ifndef BUILD_STATIC
Chris@132 3591 aboutText += tr("<br>Using Qt v%1 &copy; Trolltech AS").arg(QT_VERSION_STR);
Chris@132 3592 #else
Chris@132 3593 #ifdef QT_SHARED
Chris@132 3594 aboutText += tr("<br>Using Qt v%1 &copy; Trolltech AS").arg(QT_VERSION_STR);
Chris@132 3595 #endif
Chris@132 3596 #endif
Chris@132 3597
Chris@0 3598 #ifdef BUILD_STATIC
Chris@0 3599 aboutText += tr("<p>Statically linked");
Chris@0 3600 #ifndef QT_SHARED
Chris@0 3601 aboutText += tr("<br>With Qt (v%1) &copy; Trolltech AS").arg(QT_VERSION_STR);
Chris@0 3602 #endif
Chris@0 3603 #ifdef HAVE_JACK
Chris@93 3604 #ifdef JACK_VERSION
Chris@257 3605 aboutText += tr("<br>With JACK audio output library (v%1) &copy; Paul Davis and Jack O'Quin").arg(JACK_VERSION);
Chris@93 3606 #else
Chris@257 3607 aboutText += tr("<br>With JACK audio output library &copy; Paul Davis and Jack O'Quin");
Chris@93 3608 #endif
Chris@0 3609 #endif
Chris@0 3610 #ifdef HAVE_PORTAUDIO
Chris@257 3611 aboutText += tr("<br>With PortAudio audio output library &copy; Ross Bencina and Phil Burk");
Chris@257 3612 #endif
Chris@257 3613 #ifdef HAVE_LIBPULSE
Chris@257 3614 aboutText += tr("<br>With PulseAudio audio output library &copy; Lennart Poettering and Pierre Ossman");
Chris@0 3615 #endif
Chris@0 3616 #ifdef HAVE_OGGZ
Chris@93 3617 #ifdef OGGZ_VERSION
Chris@0 3618 aboutText += tr("<br>With Ogg file decoder (oggz v%1, fishsound v%2) &copy; CSIRO Australia").arg(OGGZ_VERSION).arg(FISHSOUND_VERSION);
Chris@93 3619 #else
Chris@93 3620 aboutText += tr("<br>With Ogg file decoder &copy; CSIRO Australia");
Chris@93 3621 #endif
Chris@0 3622 #endif
Chris@0 3623 #ifdef HAVE_MAD
Chris@93 3624 #ifdef MAD_VERSION
Chris@0 3625 aboutText += tr("<br>With MAD mp3 decoder (v%1) &copy; Underbit Technologies Inc").arg(MAD_VERSION);
Chris@93 3626 #else
Chris@93 3627 aboutText += tr("<br>With MAD mp3 decoder &copy; Underbit Technologies Inc");
Chris@93 3628 #endif
Chris@0 3629 #endif
Chris@0 3630 #ifdef HAVE_SAMPLERATE
Chris@93 3631 #ifdef SAMPLERATE_VERSION
Chris@0 3632 aboutText += tr("<br>With libsamplerate (v%1) &copy; Erik de Castro Lopo").arg(SAMPLERATE_VERSION);
Chris@93 3633 #else
Chris@93 3634 aboutText += tr("<br>With libsamplerate &copy; Erik de Castro Lopo");
Chris@93 3635 #endif
Chris@0 3636 #endif
Chris@0 3637 #ifdef HAVE_SNDFILE
Chris@93 3638 #ifdef SNDFILE_VERSION
Chris@0 3639 aboutText += tr("<br>With libsndfile (v%1) &copy; Erik de Castro Lopo").arg(SNDFILE_VERSION);
Chris@93 3640 #else
Chris@93 3641 aboutText += tr("<br>With libsndfile &copy; Erik de Castro Lopo");
Chris@93 3642 #endif
Chris@0 3643 #endif
Chris@127 3644 #ifdef HAVE_FFTW3F
Chris@93 3645 #ifdef FFTW3_VERSION
Chris@0 3646 aboutText += tr("<br>With FFTW3 (v%1) &copy; Matteo Frigo and MIT").arg(FFTW3_VERSION);
Chris@93 3647 #else
Chris@93 3648 aboutText += tr("<br>With FFTW3 &copy; Matteo Frigo and MIT");
Chris@93 3649 #endif
Chris@0 3650 #endif
Chris@267 3651 #ifdef HAVE_RUBBERBAND
Chris@267 3652 #ifdef RUBBERBAND_VERSION
Chris@267 3653 aboutText += tr("<br>With Rubber Band (v%1) &copy; Chris Cannam").arg(RUBBERBAND_VERSION);
Chris@267 3654 #else
Chris@267 3655 aboutText += tr("<br>With Rubber Band &copy; Chris Cannam");
Chris@267 3656 #endif
Chris@267 3657 #endif
Chris@0 3658 #ifdef HAVE_VAMP
Chris@114 3659 aboutText += tr("<br>With Vamp plugin support (API v%1, host SDK v%2) &copy; Chris Cannam").arg(VAMP_API_VERSION).arg(VAMP_SDK_VERSION);
Chris@0 3660 #endif
Chris@0 3661 aboutText += tr("<br>With LADSPA plugin support (API v%1) &copy; Richard Furse, Paul Davis, Stefan Westerfeld").arg(LADSPA_VERSION);
Chris@0 3662 aboutText += tr("<br>With DSSI plugin support (API v%1) &copy; Chris Cannam, Steve Harris, Sean Bolton").arg(DSSI_VERSION);
Chris@69 3663 #ifdef HAVE_LIBLO
Chris@93 3664 #ifdef LIBLO_VERSION
Chris@69 3665 aboutText += tr("<br>With liblo Lite OSC library (v%1) &copy; Steve Harris").arg(LIBLO_VERSION);
Chris@93 3666 #else
Chris@93 3667 aboutText += tr("<br>With liblo Lite OSC library &copy; Steve Harris").arg(LIBLO_VERSION);
Chris@93 3668 #endif
Chris@70 3669 if (m_oscQueue && m_oscQueue->isOK()) {
Chris@69 3670 aboutText += tr("<p>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL());
Chris@69 3671 }
Chris@69 3672 #endif
Chris@0 3673 aboutText += "</p>";
Chris@0 3674 #endif
Chris@0 3675
Chris@0 3676 aboutText +=
Chris@231 3677 "<p>Sonic Visualiser Copyright &copy; 2005 - 2008 Chris Cannam and "
Chris@90 3678 "Queen Mary, University of London.</p>"
Chris@231 3679 "<p>This program is free software; you can redistribute it and/or "
Chris@231 3680 "modify it under the terms of the GNU General Public License as "
Chris@231 3681 "published by the Free Software Foundation; either version 2 of the "
Chris@0 3682 "License, or (at your option) any later version.<br>See the file "
Chris@0 3683 "COPYING included with this distribution for more information.</p>";
Chris@0 3684
Chris@0 3685 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText);
Chris@0 3686 }
Chris@0 3687
Chris@162 3688 void
Chris@162 3689 MainWindow::keyReference()
Chris@162 3690 {
Chris@162 3691 m_keyReference->show();
Chris@162 3692 }
Chris@162 3693