annotate main/MainWindow.cpp @ 274:1da9d83fbde6

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