annotate main/MainWindow.cpp @ 272:ffc0acc10ffc

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