comparison main/MainWindow.cpp @ 421:07fbfba541b0 templating

Merge from branch "feature_150_menu_arrangement"
author Chris Cannam
date Thu, 28 Apr 2011 15:28:59 +0100
parents a0d162a3f3a7 5fdd59f8bff2
children 37fb42c2d0e7
comparison
equal deleted inserted replaced
417:a0d162a3f3a7 421:07fbfba541b0
386 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one")); 386 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one"));
387 connect(action, SIGNAL(triggered()), this, SLOT(newSession())); 387 connect(action, SIGNAL(triggered()), this, SLOT(newSession()));
388 m_keyReference->registerShortcut(action); 388 m_keyReference->registerShortcut(action);
389 menu->addAction(action); 389 menu->addAction(action);
390 toolbar->addAction(action); 390 toolbar->addAction(action);
391 391 /*
392 icon = il.load("fileopensession"); 392 icon = il.load("fileopensession");
393 action = new QAction(icon, tr("&Open Session..."), this); 393 action = new QAction(icon, tr("&Open Session..."), this);
394 action->setShortcut(tr("Ctrl+O")); 394 action->setShortcut(tr("Ctrl+O"));
395 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file")); 395 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file"));
396 connect(action, SIGNAL(triggered()), this, SLOT(openSession())); 396 connect(action, SIGNAL(triggered()), this, SLOT(openSession()));
397 m_keyReference->registerShortcut(action); 397 m_keyReference->registerShortcut(action);
398 menu->addAction(action); 398 menu->addAction(action);
399 399 */
400 icon = il.load("fileopen"); 400 icon = il.load("fileopen");
401 icon.addPixmap(il.loadPixmap("fileopen-22")); 401 icon.addPixmap(il.loadPixmap("fileopen-22"));
402
403 action = new QAction(icon, tr("&Open..."), this); 402 action = new QAction(icon, tr("&Open..."), this);
403 action->setShortcut(tr("Ctrl+O"));
404 action->setStatusTip(tr("Open a session file, audio file, or layer")); 404 action->setStatusTip(tr("Open a session file, audio file, or layer"));
405 connect(action, SIGNAL(triggered()), this, SLOT(openSomething())); 405 connect(action, SIGNAL(triggered()), this, SLOT(openSomething()));
406 toolbar->addAction(action); 406 toolbar->addAction(action);
407 menu->addAction(action);
408
409 // We want this one to go on the toolbar now, if we add it at all,
410 // but on the menu later
411 QAction *iaction = new QAction(tr("&Import More Audio..."), this);
412 iaction->setShortcut(tr("Ctrl+I"));
413 iaction->setStatusTip(tr("Import an extra audio file into a new pane"));
414 connect(iaction, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
415 connect(this, SIGNAL(canImportMoreAudio(bool)), iaction, SLOT(setEnabled(bool)));
416 m_keyReference->registerShortcut(iaction);
417
418 action = new QAction(tr("Open Lo&cation..."), this);
419 action->setShortcut(tr("Ctrl+Shift+O"));
420 action->setStatusTip(tr("Open or import a file from a remote URL"));
421 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
422 m_keyReference->registerShortcut(action);
423 menu->addAction(action);
424
425 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
426 m_recentFilesMenu->setTearOffEnabled(true);
427 setupRecentFilesMenu();
428 connect(&m_recentFiles, SIGNAL(recentChanged()),
429 this, SLOT(setupRecentFilesMenu()));
430
431 menu->addSeparator();
407 432
408 icon = il.load("filesave"); 433 icon = il.load("filesave");
409 icon.addPixmap(il.loadPixmap("filesave-22")); 434 icon.addPixmap(il.loadPixmap("filesave-22"));
410 action = new QAction(icon, tr("&Save Session"), this); 435 action = new QAction(icon, tr("&Save Session"), this);
411 action->setShortcut(tr("Ctrl+S")); 436 action->setShortcut(tr("Ctrl+S"));
425 menu->addAction(action); 450 menu->addAction(action);
426 toolbar->addAction(action); 451 toolbar->addAction(action);
427 452
428 menu->addSeparator(); 453 menu->addSeparator();
429 454
455 /*
430 icon = il.load("fileopenaudio"); 456 icon = il.load("fileopenaudio");
431 action = new QAction(icon, tr("&Import Audio File..."), this); 457 action = new QAction(icon, tr("&Import Audio File..."), this);
432 action->setShortcut(tr("Ctrl+I")); 458 action->setShortcut(tr("Ctrl+I"));
433 action->setStatusTip(tr("Import an existing audio file")); 459 action->setStatusTip(tr("Import an existing audio file"));
434 connect(action, SIGNAL(triggered()), this, SLOT(importAudio())); 460 connect(action, SIGNAL(triggered()), this, SLOT(importAudio()));
435 m_keyReference->registerShortcut(action); 461 m_keyReference->registerShortcut(action);
436 menu->addAction(action); 462 menu->addAction(action);
437 463 */
438 action = new QAction(tr("Import Secondary Audio File..."), this); 464
439 action->setShortcut(tr("Ctrl+Shift+I")); 465 // the Import action we made earlier
440 action->setStatusTip(tr("Import an extra audio file as a separate layer")); 466 menu->addAction(iaction);
441 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
442 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
443 m_keyReference->registerShortcut(action);
444 menu->addAction(action);
445 467
446 action = new QAction(tr("&Export Audio File..."), this); 468 action = new QAction(tr("&Export Audio File..."), this);
447 action->setStatusTip(tr("Export selection as an audio file")); 469 action->setStatusTip(tr("Export selection as an audio file"));
448 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); 470 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
449 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); 471 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
473 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool))); 495 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool)));
474 menu->addAction(action); 496 menu->addAction(action);
475 497
476 menu->addSeparator(); 498 menu->addSeparator();
477 499
478 action = new QAction(tr("Open Lo&cation..."), this);
479 action->setShortcut(tr("Ctrl+Shift+O"));
480 action->setStatusTip(tr("Open or import a file from a remote URL"));
481 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
482 m_keyReference->registerShortcut(action);
483 menu->addAction(action);
484
485 menu->addSeparator();
486
487 m_recentFilesMenu = menu->addMenu(tr("&Recent Files"));
488 m_recentFilesMenu->setTearOffEnabled(true);
489 setupRecentFilesMenu();
490 connect(&m_recentFiles, SIGNAL(recentChanged()),
491 this, SLOT(setupRecentFilesMenu()));
492
493 menu->addSeparator();
494 action = new QAction(tr("&Preferences..."), this); 500 action = new QAction(tr("&Preferences..."), this);
495 action->setStatusTip(tr("Adjust the application preferences")); 501 action->setStatusTip(tr("Adjust the application preferences"));
496 connect(action, SIGNAL(triggered()), this, SLOT(preferences())); 502 connect(action, SIGNAL(triggered()), this, SLOT(preferences()));
497 menu->addAction(action); 503 menu->addAction(action);
498 504
2669 2675
2670 QString path = getOpenFileName(FileFinder::AnyFile); 2676 QString path = getOpenFileName(FileFinder::AnyFile);
2671 2677
2672 if (path.isEmpty()) return; 2678 if (path.isEmpty()) return;
2673 2679
2674 FileOpenStatus status = open(path, AskUser); 2680 FileOpenStatus status = open(path, ReplaceMainModel);
2675 2681
2676 if (status == FileOpenFailed) { 2682 if (status == FileOpenFailed) {
2677 emit hideSplash(); 2683 emit hideSplash();
2678 QMessageBox::critical(this, tr("Failed to open file"), 2684 QMessageBox::critical(this, tr("Failed to open file"),
2679 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path)); 2685 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
2701 2707
2702 settings.setValue("lastremote", text); 2708 settings.setValue("lastremote", text);
2703 2709
2704 if (text.isEmpty()) return; 2710 if (text.isEmpty()) return;
2705 2711
2706 FileOpenStatus status = open(text); 2712 FileOpenStatus status = open(text, AskUser);
2707 2713
2708 if (status == FileOpenFailed) { 2714 if (status == FileOpenFailed) {
2709 emit hideSplash(); 2715 emit hideSplash();
2710 QMessageBox::critical(this, tr("Failed to open location"), 2716 QMessageBox::critical(this, tr("Failed to open location"),
2711 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text)); 2717 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
2729 } 2735 }
2730 2736
2731 QString path = action->text(); 2737 QString path = action->text();
2732 if (path == "") return; 2738 if (path == "") return;
2733 2739
2734 FileOpenStatus status = open(path); 2740 FileOpenStatus status = open(path, ReplaceMainModel);
2735 2741
2736 if (status == FileOpenFailed) { 2742 if (status == FileOpenFailed) {
2737 emit hideSplash(); 2743 emit hideSplash();
2738 QMessageBox::critical(this, tr("Failed to open location"), 2744 QMessageBox::critical(this, tr("Failed to open location"),
2739 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path)); 2745 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));