Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 162:9c9bce6440f5
* Add key reference window to Help menu (also needs mouse reference)
author | Chris Cannam |
---|---|
date | Wed, 04 Jul 2007 17:22:12 +0000 |
parents | 39dda80acb10 |
children | 652b22dcd4ed |
comparison
equal
deleted
inserted
replaced
161:39dda80acb10 | 162:9c9bce6440f5 |
---|---|
39 #include "widgets/AudioDial.h" | 39 #include "widgets/AudioDial.h" |
40 #include "widgets/LayerTree.h" | 40 #include "widgets/LayerTree.h" |
41 #include "widgets/ListInputDialog.h" | 41 #include "widgets/ListInputDialog.h" |
42 #include "widgets/SubdividingMenu.h" | 42 #include "widgets/SubdividingMenu.h" |
43 #include "widgets/NotifyingPushButton.h" | 43 #include "widgets/NotifyingPushButton.h" |
44 #include "widgets/KeyReference.h" | |
44 #include "audioio/AudioCallbackPlaySource.h" | 45 #include "audioio/AudioCallbackPlaySource.h" |
45 #include "audioio/AudioCallbackPlayTarget.h" | 46 #include "audioio/AudioCallbackPlayTarget.h" |
46 #include "audioio/AudioTargetFactory.h" | 47 #include "audioio/AudioTargetFactory.h" |
47 #include "audioio/PlaySpeedRangeMapper.h" | 48 #include "audioio/PlaySpeedRangeMapper.h" |
48 #include "data/fileio/AudioFileReaderFactory.h" | 49 #include "data/fileio/AudioFileReaderFactory.h" |
130 m_ffwdAction(0), | 131 m_ffwdAction(0), |
131 m_rwdAction(0), | 132 m_rwdAction(0), |
132 m_documentModified(false), | 133 m_documentModified(false), |
133 m_openingAudioFile(false), | 134 m_openingAudioFile(false), |
134 m_abandoning(false), | 135 m_abandoning(false), |
135 m_preferencesDialog(0) | 136 m_preferencesDialog(0), |
137 m_keyReference(new KeyReference()) | |
136 { | 138 { |
137 setWindowTitle(tr("Sonic Visualiser")); | 139 setWindowTitle(tr("Sonic Visualiser")); |
138 | 140 |
139 UnitDatabase::getInstance()->registerUnit("Hz"); | 141 UnitDatabase::getInstance()->registerUnit("Hz"); |
140 UnitDatabase::getInstance()->registerUnit("dB"); | 142 UnitDatabase::getInstance()->registerUnit("dB"); |
326 } | 328 } |
327 delete m_playTarget; | 329 delete m_playTarget; |
328 delete m_playSource; | 330 delete m_playSource; |
329 delete m_viewManager; | 331 delete m_viewManager; |
330 delete m_oscQueue; | 332 delete m_oscQueue; |
333 delete m_keyReference; | |
331 Profiles::getInstance()->dump(); | 334 Profiles::getInstance()->dump(); |
332 } | 335 } |
333 | 336 |
334 QString | 337 QString |
335 MainWindow::getOpenFileName(FileFinder::FileType type) | 338 MainWindow::getOpenFileName(FileFinder::FileType type) |
439 | 442 |
440 QMenu *menu = menuBar()->addMenu(tr("&File")); | 443 QMenu *menu = menuBar()->addMenu(tr("&File")); |
441 menu->setTearOffEnabled(true); | 444 menu->setTearOffEnabled(true); |
442 QToolBar *toolbar = addToolBar(tr("File Toolbar")); | 445 QToolBar *toolbar = addToolBar(tr("File Toolbar")); |
443 | 446 |
447 m_keyReference->setCategory(tr("File and Session Management")); | |
448 | |
444 QIcon icon(":icons/filenew.png"); | 449 QIcon icon(":icons/filenew.png"); |
445 icon.addFile(":icons/filenew-22.png"); | 450 icon.addFile(":icons/filenew-22.png"); |
446 QAction *action = new QAction(icon, tr("&New Session"), this); | 451 QAction *action = new QAction(icon, tr("&New Session"), this); |
447 action->setShortcut(tr("Ctrl+N")); | 452 action->setShortcut(tr("Ctrl+N")); |
448 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one")); | 453 action->setStatusTip(tr("Abandon the current Sonic Visualiser session and start a new one")); |
449 connect(action, SIGNAL(triggered()), this, SLOT(newSession())); | 454 connect(action, SIGNAL(triggered()), this, SLOT(newSession())); |
455 m_keyReference->registerShortcut(action); | |
450 menu->addAction(action); | 456 menu->addAction(action); |
451 toolbar->addAction(action); | 457 toolbar->addAction(action); |
452 | 458 |
453 icon = QIcon(":icons/fileopensession.png"); | 459 icon = QIcon(":icons/fileopensession.png"); |
454 action = new QAction(icon, tr("&Open Session..."), this); | 460 action = new QAction(icon, tr("&Open Session..."), this); |
455 action->setShortcut(tr("Ctrl+O")); | 461 action->setShortcut(tr("Ctrl+O")); |
456 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file")); | 462 action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file")); |
457 connect(action, SIGNAL(triggered()), this, SLOT(openSession())); | 463 connect(action, SIGNAL(triggered()), this, SLOT(openSession())); |
464 m_keyReference->registerShortcut(action); | |
458 menu->addAction(action); | 465 menu->addAction(action); |
459 | 466 |
460 icon = QIcon(":icons/fileopen.png"); | 467 icon = QIcon(":icons/fileopen.png"); |
461 icon.addFile(":icons/fileopen-22.png"); | 468 icon.addFile(":icons/fileopen-22.png"); |
462 | 469 |
470 action = new QAction(icon, tr("&Save Session"), this); | 477 action = new QAction(icon, tr("&Save Session"), this); |
471 action->setShortcut(tr("Ctrl+S")); | 478 action->setShortcut(tr("Ctrl+S")); |
472 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file")); | 479 action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file")); |
473 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); | 480 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); |
474 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); | 481 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); |
482 m_keyReference->registerShortcut(action); | |
475 menu->addAction(action); | 483 menu->addAction(action); |
476 toolbar->addAction(action); | 484 toolbar->addAction(action); |
477 | 485 |
478 icon = QIcon(":icons/filesaveas.png"); | 486 icon = QIcon(":icons/filesaveas.png"); |
479 icon.addFile(":icons/filesaveas-22.png"); | 487 icon.addFile(":icons/filesaveas-22.png"); |
488 icon = QIcon(":icons/fileopenaudio.png"); | 496 icon = QIcon(":icons/fileopenaudio.png"); |
489 action = new QAction(icon, tr("&Import Audio File..."), this); | 497 action = new QAction(icon, tr("&Import Audio File..."), this); |
490 action->setShortcut(tr("Ctrl+I")); | 498 action->setShortcut(tr("Ctrl+I")); |
491 action->setStatusTip(tr("Import an existing audio file")); | 499 action->setStatusTip(tr("Import an existing audio file")); |
492 connect(action, SIGNAL(triggered()), this, SLOT(importAudio())); | 500 connect(action, SIGNAL(triggered()), this, SLOT(importAudio())); |
501 m_keyReference->registerShortcut(action); | |
493 menu->addAction(action); | 502 menu->addAction(action); |
494 | 503 |
495 action = new QAction(tr("Import Secondary Audio File..."), this); | 504 action = new QAction(tr("Import Secondary Audio File..."), this); |
496 action->setShortcut(tr("Ctrl+Shift+I")); | 505 action->setShortcut(tr("Ctrl+Shift+I")); |
497 action->setStatusTip(tr("Import an extra audio file as a separate layer")); | 506 action->setStatusTip(tr("Import an extra audio file as a separate layer")); |
498 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio())); | 507 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio())); |
499 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool))); | 508 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool))); |
509 m_keyReference->registerShortcut(action); | |
500 menu->addAction(action); | 510 menu->addAction(action); |
501 | 511 |
502 action = new QAction(tr("&Export Audio File..."), this); | 512 action = new QAction(tr("&Export Audio File..."), this); |
503 action->setStatusTip(tr("Export selection as an audio file")); | 513 action->setStatusTip(tr("Export selection as an audio file")); |
504 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); | 514 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); |
510 action = new QAction(tr("Import Annotation &Layer..."), this); | 520 action = new QAction(tr("Import Annotation &Layer..."), this); |
511 action->setShortcut(tr("Ctrl+L")); | 521 action->setShortcut(tr("Ctrl+L")); |
512 action->setStatusTip(tr("Import layer data from an existing file")); | 522 action->setStatusTip(tr("Import layer data from an existing file")); |
513 connect(action, SIGNAL(triggered()), this, SLOT(importLayer())); | 523 connect(action, SIGNAL(triggered()), this, SLOT(importLayer())); |
514 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool))); | 524 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool))); |
525 m_keyReference->registerShortcut(action); | |
515 menu->addAction(action); | 526 menu->addAction(action); |
516 | 527 |
517 action = new QAction(tr("Export Annotation Layer..."), this); | 528 action = new QAction(tr("Export Annotation Layer..."), this); |
518 action->setStatusTip(tr("Export layer data to a file")); | 529 action->setStatusTip(tr("Export layer data to a file")); |
519 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer())); | 530 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer())); |
532 | 543 |
533 action = new QAction(tr("Open Lo&cation..."), this); | 544 action = new QAction(tr("Open Lo&cation..."), this); |
534 action->setShortcut(tr("Ctrl+Shift+O")); | 545 action->setShortcut(tr("Ctrl+Shift+O")); |
535 action->setStatusTip(tr("Open or import a file from a remote URL")); | 546 action->setStatusTip(tr("Open or import a file from a remote URL")); |
536 connect(action, SIGNAL(triggered()), this, SLOT(openLocation())); | 547 connect(action, SIGNAL(triggered()), this, SLOT(openLocation())); |
548 m_keyReference->registerShortcut(action); | |
537 menu->addAction(action); | 549 menu->addAction(action); |
538 | 550 |
539 menu->addSeparator(); | 551 menu->addSeparator(); |
540 | 552 |
541 m_recentFilesMenu = menu->addMenu(tr("&Recent Files")); | 553 m_recentFilesMenu = menu->addMenu(tr("&Recent Files")); |
554 action = new QAction(QIcon(":/icons/exit.png"), | 566 action = new QAction(QIcon(":/icons/exit.png"), |
555 tr("&Quit"), this); | 567 tr("&Quit"), this); |
556 action->setShortcut(tr("Ctrl+Q")); | 568 action->setShortcut(tr("Ctrl+Q")); |
557 action->setStatusTip(tr("Exit Sonic Visualiser")); | 569 action->setStatusTip(tr("Exit Sonic Visualiser")); |
558 connect(action, SIGNAL(triggered()), this, SLOT(close())); | 570 connect(action, SIGNAL(triggered()), this, SLOT(close())); |
571 m_keyReference->registerShortcut(action); | |
559 menu->addAction(action); | 572 menu->addAction(action); |
560 } | 573 } |
561 | 574 |
562 void | 575 void |
563 MainWindow::setupEditMenu() | 576 MainWindow::setupEditMenu() |
565 if (m_mainMenusCreated) return; | 578 if (m_mainMenusCreated) return; |
566 | 579 |
567 QMenu *menu = menuBar()->addMenu(tr("&Edit")); | 580 QMenu *menu = menuBar()->addMenu(tr("&Edit")); |
568 menu->setTearOffEnabled(true); | 581 menu->setTearOffEnabled(true); |
569 CommandHistory::getInstance()->registerMenu(menu); | 582 CommandHistory::getInstance()->registerMenu(menu); |
583 | |
584 m_keyReference->setCategory(tr("Editing")); | |
570 | 585 |
571 menu->addSeparator(); | 586 menu->addSeparator(); |
572 | 587 |
573 QAction *action = new QAction(QIcon(":/icons/editcut.png"), | 588 QAction *action = new QAction(QIcon(":/icons/editcut.png"), |
574 tr("Cu&t"), this); | 589 tr("Cu&t"), this); |
575 action->setShortcut(tr("Ctrl+X")); | 590 action->setShortcut(tr("Ctrl+X")); |
576 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard")); | 591 action->setStatusTip(tr("Cut the selection from the current layer to the clipboard")); |
577 connect(action, SIGNAL(triggered()), this, SLOT(cut())); | 592 connect(action, SIGNAL(triggered()), this, SLOT(cut())); |
578 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); | 593 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); |
594 m_keyReference->registerShortcut(action); | |
579 menu->addAction(action); | 595 menu->addAction(action); |
580 m_rightButtonMenu->addAction(action); | 596 m_rightButtonMenu->addAction(action); |
581 | 597 |
582 action = new QAction(QIcon(":/icons/editcopy.png"), | 598 action = new QAction(QIcon(":/icons/editcopy.png"), |
583 tr("&Copy"), this); | 599 tr("&Copy"), this); |
584 action->setShortcut(tr("Ctrl+C")); | 600 action->setShortcut(tr("Ctrl+C")); |
585 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard")); | 601 action->setStatusTip(tr("Copy the selection from the current layer to the clipboard")); |
586 connect(action, SIGNAL(triggered()), this, SLOT(copy())); | 602 connect(action, SIGNAL(triggered()), this, SLOT(copy())); |
587 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); | 603 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); |
604 m_keyReference->registerShortcut(action); | |
588 menu->addAction(action); | 605 menu->addAction(action); |
589 m_rightButtonMenu->addAction(action); | 606 m_rightButtonMenu->addAction(action); |
590 | 607 |
591 action = new QAction(QIcon(":/icons/editpaste.png"), | 608 action = new QAction(QIcon(":/icons/editpaste.png"), |
592 tr("&Paste"), this); | 609 tr("&Paste"), this); |
593 action->setShortcut(tr("Ctrl+V")); | 610 action->setShortcut(tr("Ctrl+V")); |
594 action->setStatusTip(tr("Paste from the clipboard to the current layer")); | 611 action->setStatusTip(tr("Paste from the clipboard to the current layer")); |
595 connect(action, SIGNAL(triggered()), this, SLOT(paste())); | 612 connect(action, SIGNAL(triggered()), this, SLOT(paste())); |
596 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool))); | 613 connect(this, SIGNAL(canPaste(bool)), action, SLOT(setEnabled(bool))); |
614 m_keyReference->registerShortcut(action); | |
597 menu->addAction(action); | 615 menu->addAction(action); |
598 m_rightButtonMenu->addAction(action); | 616 m_rightButtonMenu->addAction(action); |
599 | 617 |
600 action = new QAction(tr("&Delete Selected Items"), this); | 618 action = new QAction(tr("&Delete Selected Items"), this); |
601 action->setShortcut(tr("Del")); | 619 action->setShortcut(tr("Del")); |
602 action->setStatusTip(tr("Delete the selection from the current layer")); | 620 action->setStatusTip(tr("Delete the selection from the current layer")); |
603 connect(action, SIGNAL(triggered()), this, SLOT(deleteSelected())); | 621 connect(action, SIGNAL(triggered()), this, SLOT(deleteSelected())); |
604 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); | 622 connect(this, SIGNAL(canEditSelection(bool)), action, SLOT(setEnabled(bool))); |
623 m_keyReference->registerShortcut(action); | |
605 menu->addAction(action); | 624 menu->addAction(action); |
606 m_rightButtonMenu->addAction(action); | 625 m_rightButtonMenu->addAction(action); |
607 | 626 |
608 menu->addSeparator(); | 627 menu->addSeparator(); |
609 m_rightButtonMenu->addSeparator(); | 628 m_rightButtonMenu->addSeparator(); |
610 | 629 |
630 m_keyReference->setCategory(tr("Selection")); | |
631 | |
611 action = new QAction(tr("Select &All"), this); | 632 action = new QAction(tr("Select &All"), this); |
612 action->setShortcut(tr("Ctrl+A")); | 633 action->setShortcut(tr("Ctrl+A")); |
613 action->setStatusTip(tr("Select the whole duration of the current session")); | 634 action->setStatusTip(tr("Select the whole duration of the current session")); |
614 connect(action, SIGNAL(triggered()), this, SLOT(selectAll())); | 635 connect(action, SIGNAL(triggered()), this, SLOT(selectAll())); |
615 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 636 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
637 m_keyReference->registerShortcut(action); | |
616 menu->addAction(action); | 638 menu->addAction(action); |
617 m_rightButtonMenu->addAction(action); | 639 m_rightButtonMenu->addAction(action); |
618 | 640 |
619 action = new QAction(tr("Select &Visible Range"), this); | 641 action = new QAction(tr("Select &Visible Range"), this); |
620 action->setShortcut(tr("Ctrl+Shift+A")); | 642 action->setShortcut(tr("Ctrl+Shift+A")); |
621 action->setStatusTip(tr("Select the time range corresponding to the current window width")); | 643 action->setStatusTip(tr("Select the time range corresponding to the current window width")); |
622 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible())); | 644 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible())); |
623 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 645 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
646 m_keyReference->registerShortcut(action); | |
624 menu->addAction(action); | 647 menu->addAction(action); |
625 | 648 |
626 action = new QAction(tr("Select to &Start"), this); | 649 action = new QAction(tr("Select to &Start"), this); |
627 action->setShortcut(tr("Shift+Left")); | 650 action->setShortcut(tr("Shift+Left")); |
628 action->setStatusTip(tr("Select from the start of the session to the current playback position")); | 651 action->setStatusTip(tr("Select from the start of the session to the current playback position")); |
629 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart())); | 652 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart())); |
630 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 653 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
654 m_keyReference->registerShortcut(action); | |
631 menu->addAction(action); | 655 menu->addAction(action); |
632 | 656 |
633 action = new QAction(tr("Select to &End"), this); | 657 action = new QAction(tr("Select to &End"), this); |
634 action->setShortcut(tr("Shift+Right")); | 658 action->setShortcut(tr("Shift+Right")); |
635 action->setStatusTip(tr("Select from the current playback position to the end of the session")); | 659 action->setStatusTip(tr("Select from the current playback position to the end of the session")); |
636 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd())); | 660 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd())); |
637 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 661 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
662 m_keyReference->registerShortcut(action); | |
638 menu->addAction(action); | 663 menu->addAction(action); |
639 | 664 |
640 action = new QAction(tr("C&lear Selection"), this); | 665 action = new QAction(tr("C&lear Selection"), this); |
641 action->setShortcut(tr("Esc")); | 666 action->setShortcut(tr("Esc")); |
642 action->setStatusTip(tr("Clear the selection")); | 667 action->setStatusTip(tr("Clear the selection")); |
643 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection())); | 668 connect(action, SIGNAL(triggered()), this, SLOT(clearSelection())); |
644 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); | 669 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); |
670 m_keyReference->registerShortcut(action); | |
645 menu->addAction(action); | 671 menu->addAction(action); |
646 m_rightButtonMenu->addAction(action); | 672 m_rightButtonMenu->addAction(action); |
647 | 673 |
648 menu->addSeparator(); | 674 menu->addSeparator(); |
675 | |
676 m_keyReference->setCategory(tr("Tapping Time Instants")); | |
649 | 677 |
650 action = new QAction(tr("&Insert Instant at Playback Position"), this); | 678 action = new QAction(tr("&Insert Instant at Playback Position"), this); |
651 action->setShortcut(tr("Enter")); | 679 action->setShortcut(tr("Enter")); |
652 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary")); | 680 action->setStatusTip(tr("Insert a new time instant at the current playback position, in a new layer if necessary")); |
653 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant())); | 681 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant())); |
654 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool))); | 682 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool))); |
683 m_keyReference->registerShortcut(action); | |
655 menu->addAction(action); | 684 menu->addAction(action); |
685 | |
686 // Laptop shortcut (no keypad Enter key) | |
687 QString shortcut(tr(";")); | |
688 connect(new QShortcut(shortcut, this), SIGNAL(activated()), | |
689 this, SLOT(insertInstant())); | |
690 m_keyReference->registerAlternativeShortcut(action, shortcut); | |
656 | 691 |
657 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this); | 692 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this); |
658 action->setShortcut(tr("Shift+Enter")); | 693 action->setShortcut(tr("Shift+Enter")); |
659 action->setStatusTip(tr("Insert new time instants at the start and end of the current selection, in a new layer if necessary")); | 694 action->setStatusTip(tr("Insert new time instants at the start and end of the current selection, in a new layer if necessary")); |
660 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries())); | 695 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries())); |
661 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool))); | 696 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool))); |
697 m_keyReference->registerShortcut(action); | |
662 menu->addAction(action); | 698 menu->addAction(action); |
663 | |
664 // Laptop shortcut (no keypad Enter key) | |
665 connect(new QShortcut(tr(";"), this), SIGNAL(activated()), | |
666 this, SLOT(insertInstant())); | |
667 } | 699 } |
668 | 700 |
669 void | 701 void |
670 MainWindow::setupViewMenu() | 702 MainWindow::setupViewMenu() |
671 { | 703 { |
672 if (m_mainMenusCreated) return; | 704 if (m_mainMenusCreated) return; |
673 | 705 |
674 QAction *action = 0; | 706 QAction *action = 0; |
707 | |
708 m_keyReference->setCategory(tr("Panning and Navigation")); | |
675 | 709 |
676 QMenu *menu = menuBar()->addMenu(tr("&View")); | 710 QMenu *menu = menuBar()->addMenu(tr("&View")); |
677 menu->setTearOffEnabled(true); | 711 menu->setTearOffEnabled(true); |
678 action = new QAction(tr("Scroll &Left"), this); | 712 action = new QAction(tr("Scroll &Left"), this); |
679 action->setShortcut(tr("Left")); | 713 action->setShortcut(tr("Left")); |
680 action->setStatusTip(tr("Scroll the current pane to the left")); | 714 action->setStatusTip(tr("Scroll the current pane to the left")); |
681 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); | 715 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); |
682 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 716 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
717 m_keyReference->registerShortcut(action); | |
683 menu->addAction(action); | 718 menu->addAction(action); |
684 | 719 |
685 action = new QAction(tr("Scroll &Right"), this); | 720 action = new QAction(tr("Scroll &Right"), this); |
686 action->setShortcut(tr("Right")); | 721 action->setShortcut(tr("Right")); |
687 action->setStatusTip(tr("Scroll the current pane to the right")); | 722 action->setStatusTip(tr("Scroll the current pane to the right")); |
688 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); | 723 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); |
689 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 724 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
725 m_keyReference->registerShortcut(action); | |
690 menu->addAction(action); | 726 menu->addAction(action); |
691 | 727 |
692 action = new QAction(tr("&Jump Left"), this); | 728 action = new QAction(tr("&Jump Left"), this); |
693 action->setShortcut(tr("Ctrl+Left")); | 729 action->setShortcut(tr("Ctrl+Left")); |
694 action->setStatusTip(tr("Scroll the current pane a big step to the left")); | 730 action->setStatusTip(tr("Scroll the current pane a big step to the left")); |
695 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); | 731 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); |
696 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 732 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
733 m_keyReference->registerShortcut(action); | |
697 menu->addAction(action); | 734 menu->addAction(action); |
698 | 735 |
699 action = new QAction(tr("J&ump Right"), this); | 736 action = new QAction(tr("J&ump Right"), this); |
700 action->setShortcut(tr("Ctrl+Right")); | 737 action->setShortcut(tr("Ctrl+Right")); |
701 action->setStatusTip(tr("Scroll the current pane a big step to the right")); | 738 action->setStatusTip(tr("Scroll the current pane a big step to the right")); |
702 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight())); | 739 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight())); |
703 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 740 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
741 m_keyReference->registerShortcut(action); | |
704 menu->addAction(action); | 742 menu->addAction(action); |
705 | 743 |
706 menu->addSeparator(); | 744 menu->addSeparator(); |
745 | |
746 m_keyReference->setCategory(tr("Zoom")); | |
707 | 747 |
708 action = new QAction(QIcon(":/icons/zoom-in.png"), | 748 action = new QAction(QIcon(":/icons/zoom-in.png"), |
709 tr("Zoom &In"), this); | 749 tr("Zoom &In"), this); |
710 action->setShortcut(tr("Up")); | 750 action->setShortcut(tr("Up")); |
711 action->setStatusTip(tr("Increase the zoom level")); | 751 action->setStatusTip(tr("Increase the zoom level")); |
712 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); | 752 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); |
713 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); | 753 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); |
754 m_keyReference->registerShortcut(action); | |
714 menu->addAction(action); | 755 menu->addAction(action); |
715 | 756 |
716 action = new QAction(QIcon(":/icons/zoom-out.png"), | 757 action = new QAction(QIcon(":/icons/zoom-out.png"), |
717 tr("Zoom &Out"), this); | 758 tr("Zoom &Out"), this); |
718 action->setShortcut(tr("Down")); | 759 action->setShortcut(tr("Down")); |
719 action->setStatusTip(tr("Decrease the zoom level")); | 760 action->setStatusTip(tr("Decrease the zoom level")); |
720 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); | 761 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); |
721 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); | 762 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); |
763 m_keyReference->registerShortcut(action); | |
722 menu->addAction(action); | 764 menu->addAction(action); |
723 | 765 |
724 action = new QAction(tr("Restore &Default Zoom"), this); | 766 action = new QAction(tr("Restore &Default Zoom"), this); |
725 action->setStatusTip(tr("Restore the zoom level to the default")); | 767 action->setStatusTip(tr("Restore the zoom level to the default")); |
726 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); | 768 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); |
731 tr("Zoom to &Fit"), this); | 773 tr("Zoom to &Fit"), this); |
732 action->setShortcut(tr("F")); | 774 action->setShortcut(tr("F")); |
733 action->setStatusTip(tr("Zoom to show the whole file")); | 775 action->setStatusTip(tr("Zoom to show the whole file")); |
734 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit())); | 776 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit())); |
735 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); | 777 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); |
778 m_keyReference->registerShortcut(action); | |
736 menu->addAction(action); | 779 menu->addAction(action); |
737 | 780 |
738 menu->addSeparator(); | 781 menu->addSeparator(); |
782 | |
783 m_keyReference->setCategory(tr("Display Features")); | |
739 | 784 |
740 QActionGroup *overlayGroup = new QActionGroup(this); | 785 QActionGroup *overlayGroup = new QActionGroup(this); |
741 | 786 |
742 action = new QAction(tr("Show &No Overlays"), this); | 787 action = new QAction(tr("Show &No Overlays"), this); |
743 action->setShortcut(tr("0")); | 788 action->setShortcut(tr("0")); |
744 action->setStatusTip(tr("Hide centre indicator, frame times, layer names and scale")); | 789 action->setStatusTip(tr("Hide centre indicator, frame times, layer names and scale")); |
745 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays())); | 790 connect(action, SIGNAL(triggered()), this, SLOT(showNoOverlays())); |
746 action->setCheckable(true); | 791 action->setCheckable(true); |
747 action->setChecked(false); | 792 action->setChecked(false); |
748 overlayGroup->addAction(action); | 793 overlayGroup->addAction(action); |
794 m_keyReference->registerShortcut(action); | |
749 menu->addAction(action); | 795 menu->addAction(action); |
750 | 796 |
751 action = new QAction(tr("Show &Minimal Overlays"), this); | 797 action = new QAction(tr("Show &Minimal Overlays"), this); |
752 action->setShortcut(tr("9")); | 798 action->setShortcut(tr("9")); |
753 action->setStatusTip(tr("Show centre indicator only")); | 799 action->setStatusTip(tr("Show centre indicator only")); |
754 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays())); | 800 connect(action, SIGNAL(triggered()), this, SLOT(showMinimalOverlays())); |
755 action->setCheckable(true); | 801 action->setCheckable(true); |
756 action->setChecked(false); | 802 action->setChecked(false); |
757 overlayGroup->addAction(action); | 803 overlayGroup->addAction(action); |
804 m_keyReference->registerShortcut(action); | |
758 menu->addAction(action); | 805 menu->addAction(action); |
759 | 806 |
760 action = new QAction(tr("Show &Standard Overlays"), this); | 807 action = new QAction(tr("Show &Standard Overlays"), this); |
761 action->setShortcut(tr("8")); | 808 action->setShortcut(tr("8")); |
762 action->setStatusTip(tr("Show centre indicator, frame times and scale")); | 809 action->setStatusTip(tr("Show centre indicator, frame times and scale")); |
763 connect(action, SIGNAL(triggered()), this, SLOT(showStandardOverlays())); | 810 connect(action, SIGNAL(triggered()), this, SLOT(showStandardOverlays())); |
764 action->setCheckable(true); | 811 action->setCheckable(true); |
765 action->setChecked(true); | 812 action->setChecked(true); |
766 overlayGroup->addAction(action); | 813 overlayGroup->addAction(action); |
814 m_keyReference->registerShortcut(action); | |
767 menu->addAction(action); | 815 menu->addAction(action); |
768 | 816 |
769 action = new QAction(tr("Show &All Overlays"), this); | 817 action = new QAction(tr("Show &All Overlays"), this); |
770 action->setShortcut(tr("7")); | 818 action->setShortcut(tr("7")); |
771 action->setStatusTip(tr("Show all texts and scale")); | 819 action->setStatusTip(tr("Show all texts and scale")); |
772 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays())); | 820 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays())); |
773 action->setCheckable(true); | 821 action->setCheckable(true); |
774 action->setChecked(false); | 822 action->setChecked(false); |
775 overlayGroup->addAction(action); | 823 overlayGroup->addAction(action); |
824 m_keyReference->registerShortcut(action); | |
776 menu->addAction(action); | 825 menu->addAction(action); |
777 | 826 |
778 menu->addSeparator(); | 827 menu->addSeparator(); |
779 | 828 |
780 action = new QAction(tr("Show &Zoom Wheels"), this); | 829 action = new QAction(tr("Show &Zoom Wheels"), this); |
781 action->setShortcut(tr("Z")); | 830 action->setShortcut(tr("Z")); |
782 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically")); | 831 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically")); |
783 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels())); | 832 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels())); |
784 action->setCheckable(true); | 833 action->setCheckable(true); |
785 action->setChecked(m_viewManager->getZoomWheelsEnabled()); | 834 action->setChecked(m_viewManager->getZoomWheelsEnabled()); |
835 m_keyReference->registerShortcut(action); | |
786 menu->addAction(action); | 836 menu->addAction(action); |
787 | 837 |
788 action = new QAction(tr("Show Property Bo&xes"), this); | 838 action = new QAction(tr("Show Property Bo&xes"), this); |
789 action->setShortcut(tr("X")); | 839 action->setShortcut(tr("X")); |
790 action->setStatusTip(tr("Show the layer property boxes at the side of the main window")); | 840 action->setStatusTip(tr("Show the layer property boxes at the side of the main window")); |
791 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes())); | 841 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes())); |
792 action->setCheckable(true); | 842 action->setCheckable(true); |
793 action->setChecked(true); | 843 action->setChecked(true); |
844 m_keyReference->registerShortcut(action); | |
794 menu->addAction(action); | 845 menu->addAction(action); |
795 | 846 |
796 action = new QAction(tr("Show Status &Bar"), this); | 847 action = new QAction(tr("Show Status &Bar"), this); |
797 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window")); | 848 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window")); |
798 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar())); | 849 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar())); |
813 | 864 |
814 action = new QAction(tr("Show La&yer Hierarchy"), this); | 865 action = new QAction(tr("Show La&yer Hierarchy"), this); |
815 action->setShortcut(tr("H")); | 866 action->setShortcut(tr("H")); |
816 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session")); | 867 action->setStatusTip(tr("Open a window displaying the hierarchy of panes and layers in this session")); |
817 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree())); | 868 connect(action, SIGNAL(triggered()), this, SLOT(showLayerTree())); |
869 m_keyReference->registerShortcut(action); | |
818 menu->addAction(action); | 870 menu->addAction(action); |
819 } | 871 } |
820 | 872 |
821 void | 873 void |
822 MainWindow::setupPaneAndLayerMenus() | 874 MainWindow::setupPaneAndLayerMenus() |
837 m_layerMenu->setTearOffEnabled(true); | 889 m_layerMenu->setTearOffEnabled(true); |
838 } | 890 } |
839 | 891 |
840 QMenu *menu = m_paneMenu; | 892 QMenu *menu = m_paneMenu; |
841 | 893 |
894 m_keyReference->setCategory(tr("Managing Panes and Layers")); | |
895 | |
842 QAction *action = new QAction(QIcon(":/icons/pane.png"), tr("Add &New Pane"), this); | 896 QAction *action = new QAction(QIcon(":/icons/pane.png"), tr("Add &New Pane"), this); |
843 action->setShortcut(tr("N")); | 897 action->setShortcut(tr("N")); |
844 action->setStatusTip(tr("Add a new pane containing only a time ruler")); | 898 action->setStatusTip(tr("Add a new pane containing only a time ruler")); |
845 connect(action, SIGNAL(triggered()), this, SLOT(addPane())); | 899 connect(action, SIGNAL(triggered()), this, SLOT(addPane())); |
846 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool))); | 900 connect(this, SIGNAL(canAddPane(bool)), action, SLOT(setEnabled(bool))); |
847 m_paneActions[action] = PaneConfiguration(LayerFactory::TimeRuler); | 901 m_paneActions[action] = PaneConfiguration(LayerFactory::TimeRuler); |
902 m_keyReference->registerShortcut(action); | |
848 menu->addAction(action); | 903 menu->addAction(action); |
849 | 904 |
850 menu->addSeparator(); | 905 menu->addSeparator(); |
851 | 906 |
852 menu = m_layerMenu; | 907 menu = m_layerMenu; |
873 action = new QAction(icon, mainText, this); | 928 action = new QAction(icon, mainText, this); |
874 action->setStatusTip(tipText); | 929 action->setStatusTip(tipText); |
875 | 930 |
876 if (type == LayerFactory::Text) { | 931 if (type == LayerFactory::Text) { |
877 action->setShortcut(tr("T")); | 932 action->setShortcut(tr("T")); |
933 m_keyReference->registerShortcut(action); | |
878 } | 934 } |
879 | 935 |
880 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); | 936 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); |
881 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); | 937 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); |
882 m_layerActions[action] = type; | 938 m_layerActions[action] = type; |
1034 this, SLOT(addLayer())); | 1090 this, SLOT(addLayer())); |
1035 connect(this, SIGNAL(canAddLayer(bool)), | 1091 connect(this, SIGNAL(canAddLayer(bool)), |
1036 action, SLOT(setEnabled(bool))); | 1092 action, SLOT(setEnabled(bool))); |
1037 m_layerActions[action] = type; | 1093 m_layerActions[action] = type; |
1038 } | 1094 } |
1095 if (shortcutText != "") { | |
1096 m_keyReference->registerShortcut(action); | |
1097 } | |
1039 menu->addAction(action); | 1098 menu->addAction(action); |
1040 | 1099 |
1041 } else { | 1100 } else { |
1042 | 1101 |
1043 if (!submenu) { | 1102 if (!submenu) { |
1065 } | 1124 } |
1066 | 1125 |
1067 if (isDefault) { | 1126 if (isDefault) { |
1068 action = new QAction(icon, actionText, this); | 1127 action = new QAction(icon, actionText, this); |
1069 if (!model || model == getMainModel()) { | 1128 if (!model || model == getMainModel()) { |
1070 action->setShortcut(shortcutText); | 1129 action->setShortcut(shortcutText); |
1130 m_keyReference->registerShortcut(action); | |
1071 } | 1131 } |
1072 } else { | 1132 } else { |
1073 action = new QAction(actionText, this); | 1133 action = new QAction(actionText, this); |
1074 } | 1134 } |
1075 | 1135 |
1104 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Pane"), this); | 1164 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Pane"), this); |
1105 action->setShortcut(tr("Ctrl+Shift+D")); | 1165 action->setShortcut(tr("Ctrl+Shift+D")); |
1106 action->setStatusTip(tr("Delete the currently active pane")); | 1166 action->setStatusTip(tr("Delete the currently active pane")); |
1107 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane())); | 1167 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentPane())); |
1108 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool))); | 1168 connect(this, SIGNAL(canDeleteCurrentPane(bool)), action, SLOT(setEnabled(bool))); |
1169 m_keyReference->registerShortcut(action); | |
1109 menu->addAction(action); | 1170 menu->addAction(action); |
1110 | 1171 |
1111 menu = m_layerMenu; | 1172 menu = m_layerMenu; |
1112 | 1173 |
1113 action = new QAction(QIcon(":/icons/timeruler.png"), tr("Add &Time Ruler"), this); | 1174 action = new QAction(QIcon(":/icons/timeruler.png"), tr("Add &Time Ruler"), this); |
1135 action = new QAction(tr("&Rename Layer..."), this); | 1196 action = new QAction(tr("&Rename Layer..."), this); |
1136 action->setShortcut(tr("R")); | 1197 action->setShortcut(tr("R")); |
1137 action->setStatusTip(tr("Rename the currently active layer")); | 1198 action->setStatusTip(tr("Rename the currently active layer")); |
1138 connect(action, SIGNAL(triggered()), this, SLOT(renameCurrentLayer())); | 1199 connect(action, SIGNAL(triggered()), this, SLOT(renameCurrentLayer())); |
1139 connect(this, SIGNAL(canRenameLayer(bool)), action, SLOT(setEnabled(bool))); | 1200 connect(this, SIGNAL(canRenameLayer(bool)), action, SLOT(setEnabled(bool))); |
1201 m_keyReference->registerShortcut(action); | |
1140 menu->addAction(action); | 1202 menu->addAction(action); |
1141 m_rightButtonLayerMenu->addAction(action); | 1203 m_rightButtonLayerMenu->addAction(action); |
1142 | 1204 |
1143 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this); | 1205 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this); |
1144 action->setShortcut(tr("Ctrl+D")); | 1206 action->setShortcut(tr("Ctrl+D")); |
1145 action->setStatusTip(tr("Delete the currently active layer")); | 1207 action->setStatusTip(tr("Delete the currently active layer")); |
1146 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer())); | 1208 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer())); |
1147 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool))); | 1209 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool))); |
1210 m_keyReference->registerShortcut(action); | |
1148 menu->addAction(action); | 1211 menu->addAction(action); |
1149 m_rightButtonLayerMenu->addAction(action); | 1212 m_rightButtonLayerMenu->addAction(action); |
1150 } | 1213 } |
1151 | 1214 |
1152 void | 1215 void |
1356 MainWindow::setupHelpMenu() | 1419 MainWindow::setupHelpMenu() |
1357 { | 1420 { |
1358 QMenu *menu = menuBar()->addMenu(tr("&Help")); | 1421 QMenu *menu = menuBar()->addMenu(tr("&Help")); |
1359 menu->setTearOffEnabled(true); | 1422 menu->setTearOffEnabled(true); |
1360 | 1423 |
1424 m_keyReference->setCategory(tr("Help")); | |
1425 | |
1361 QAction *action = new QAction(QIcon(":icons/help.png"), | 1426 QAction *action = new QAction(QIcon(":icons/help.png"), |
1362 tr("&Help Reference"), this); | 1427 tr("&Help Reference"), this); |
1428 action->setShortcut(tr("F1")); | |
1363 action->setStatusTip(tr("Open the Sonic Visualiser reference manual")); | 1429 action->setStatusTip(tr("Open the Sonic Visualiser reference manual")); |
1364 connect(action, SIGNAL(triggered()), this, SLOT(help())); | 1430 connect(action, SIGNAL(triggered()), this, SLOT(help())); |
1431 m_keyReference->registerShortcut(action); | |
1365 menu->addAction(action); | 1432 menu->addAction(action); |
1366 | 1433 |
1367 action = new QAction(tr("Sonic Visualiser on the &Web"), this); | 1434 action = new QAction(tr("Sonic Visualiser on the &Web"), this); |
1368 action->setStatusTip(tr("Open the Sonic Visualiser website")); | 1435 action->setStatusTip(tr("Open the Sonic Visualiser website")); |
1369 connect(action, SIGNAL(triggered()), this, SLOT(website())); | 1436 connect(action, SIGNAL(triggered()), this, SLOT(website())); |
1370 menu->addAction(action); | 1437 menu->addAction(action); |
1438 | |
1439 action = new QAction(tr("&Key Reference"), this); | |
1440 action->setShortcut(tr("F2")); | |
1441 action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser")); | |
1442 connect(action, SIGNAL(triggered()), this, SLOT(keyReference())); | |
1443 m_keyReference->registerShortcut(action); | |
1444 menu->addAction(action); | |
1371 | 1445 |
1372 action = new QAction(tr("&About Sonic Visualiser"), this); | 1446 action = new QAction(tr("&About Sonic Visualiser"), this); |
1373 action->setStatusTip(tr("Show information about Sonic Visualiser")); | 1447 action->setStatusTip(tr("Show information about Sonic Visualiser")); |
1374 connect(action, SIGNAL(triggered()), this, SLOT(about())); | 1448 connect(action, SIGNAL(triggered()), this, SLOT(about())); |
1375 menu->addAction(action); | 1449 menu->addAction(action); |
1381 m_recentFilesMenu->clear(); | 1455 m_recentFilesMenu->clear(); |
1382 vector<QString> files = m_recentFiles.getRecent(); | 1456 vector<QString> files = m_recentFiles.getRecent(); |
1383 for (size_t i = 0; i < files.size(); ++i) { | 1457 for (size_t i = 0; i < files.size(); ++i) { |
1384 QAction *action = new QAction(files[i], this); | 1458 QAction *action = new QAction(files[i], this); |
1385 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); | 1459 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); |
1386 if (i == 0) action->setShortcut(tr("Ctrl+R")); | 1460 if (i == 0) { |
1461 action->setShortcut(tr("Ctrl+R")); | |
1462 m_keyReference->registerShortcut | |
1463 (action, tr("Re-open the most recently opened file")); | |
1464 } | |
1387 m_recentFilesMenu->addAction(action); | 1465 m_recentFilesMenu->addAction(action); |
1388 } | 1466 } |
1389 } | 1467 } |
1390 | 1468 |
1391 void | 1469 void |
1400 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: " | 1478 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: " |
1401 << "Unknown transform \"" << transforms[i].toStdString() | 1479 << "Unknown transform \"" << transforms[i].toStdString() |
1402 << "\" in recent transforms list" << std::endl; | 1480 << "\" in recent transforms list" << std::endl; |
1403 continue; | 1481 continue; |
1404 } | 1482 } |
1405 if (i == 0) ti->second->setShortcut(tr("Ctrl+T")); | 1483 if (i == 0) { |
1484 ti->second->setShortcut(tr("Ctrl+T")); | |
1485 m_keyReference->registerShortcut | |
1486 (tr("Re-run the most recently run transform"), | |
1487 ti->second->shortcut(), | |
1488 ""); | |
1489 } | |
1406 m_recentTransformsMenu->addAction(ti->second); | 1490 m_recentTransformsMenu->addAction(ti->second); |
1407 } | 1491 } |
1408 } | 1492 } |
1409 | 1493 |
1410 void | 1494 void |
1486 } | 1570 } |
1487 | 1571 |
1488 void | 1572 void |
1489 MainWindow::setupToolbars() | 1573 MainWindow::setupToolbars() |
1490 { | 1574 { |
1575 m_keyReference->setCategory(tr("Playback and Transport Controls")); | |
1576 | |
1491 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back")); | 1577 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back")); |
1492 menu->setTearOffEnabled(true); | 1578 menu->setTearOffEnabled(true); |
1493 m_rightButtonMenu->addSeparator(); | 1579 m_rightButtonMenu->addSeparator(); |
1494 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback")); | 1580 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback")); |
1495 | 1581 |
1553 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)), | 1639 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)), |
1554 plAction, SLOT(setChecked(bool))); | 1640 plAction, SLOT(setChecked(bool))); |
1555 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled())); | 1641 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled())); |
1556 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool))); | 1642 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool))); |
1557 | 1643 |
1644 m_keyReference->registerShortcut(playAction); | |
1645 m_keyReference->registerShortcut(psAction); | |
1646 m_keyReference->registerShortcut(plAction); | |
1647 m_keyReference->registerShortcut(m_rwdAction); | |
1648 m_keyReference->registerShortcut(m_ffwdAction); | |
1649 m_keyReference->registerShortcut(rwdStartAction); | |
1650 m_keyReference->registerShortcut(ffwdEndAction); | |
1651 | |
1558 menu->addAction(playAction); | 1652 menu->addAction(playAction); |
1559 menu->addAction(psAction); | 1653 menu->addAction(psAction); |
1560 menu->addAction(plAction); | 1654 menu->addAction(plAction); |
1561 menu->addSeparator(); | 1655 menu->addSeparator(); |
1562 menu->addAction(m_rwdAction); | 1656 menu->addAction(m_rwdAction); |
1590 QAction *normalAction = menu->addAction(tr("Restore Normal Speed")); | 1684 QAction *normalAction = menu->addAction(tr("Restore Normal Speed")); |
1591 normalAction->setShortcut(tr("Ctrl+Home")); | 1685 normalAction->setShortcut(tr("Ctrl+Home")); |
1592 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback())); | 1686 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback())); |
1593 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool))); | 1687 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool))); |
1594 | 1688 |
1689 m_keyReference->registerShortcut(fastAction); | |
1690 m_keyReference->registerShortcut(slowAction); | |
1691 m_keyReference->registerShortcut(normalAction); | |
1692 | |
1595 m_rightButtonPlaybackMenu->addAction(fastAction); | 1693 m_rightButtonPlaybackMenu->addAction(fastAction); |
1596 m_rightButtonPlaybackMenu->addAction(slowAction); | 1694 m_rightButtonPlaybackMenu->addAction(slowAction); |
1597 m_rightButtonPlaybackMenu->addAction(normalAction); | 1695 m_rightButtonPlaybackMenu->addAction(normalAction); |
1598 | 1696 |
1599 toolbar = addToolBar(tr("Edit Toolbar")); | 1697 toolbar = addToolBar(tr("Edit Toolbar")); |
1600 CommandHistory::getInstance()->registerToolbar(toolbar); | 1698 CommandHistory::getInstance()->registerToolbar(toolbar); |
1699 | |
1700 m_keyReference->setCategory(tr("Tool Selection")); | |
1601 | 1701 |
1602 toolbar = addToolBar(tr("Tools Toolbar")); | 1702 toolbar = addToolBar(tr("Tools Toolbar")); |
1603 QActionGroup *group = new QActionGroup(this); | 1703 QActionGroup *group = new QActionGroup(this); |
1604 | 1704 |
1605 QAction *action = toolbar->addAction(QIcon(":/icons/navigate.png"), | 1705 QAction *action = toolbar->addAction(QIcon(":/icons/navigate.png"), |
1608 action->setChecked(true); | 1708 action->setChecked(true); |
1609 action->setShortcut(tr("1")); | 1709 action->setShortcut(tr("1")); |
1610 action->setStatusTip(tr("Navigate")); | 1710 action->setStatusTip(tr("Navigate")); |
1611 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected())); | 1711 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected())); |
1612 group->addAction(action); | 1712 group->addAction(action); |
1713 m_keyReference->registerShortcut(action); | |
1613 m_toolActions[ViewManager::NavigateMode] = action; | 1714 m_toolActions[ViewManager::NavigateMode] = action; |
1614 | 1715 |
1615 action = toolbar->addAction(QIcon(":/icons/select.png"), | 1716 action = toolbar->addAction(QIcon(":/icons/select.png"), |
1616 tr("Select")); | 1717 tr("Select")); |
1617 action->setCheckable(true); | 1718 action->setCheckable(true); |
1618 action->setShortcut(tr("2")); | 1719 action->setShortcut(tr("2")); |
1619 action->setStatusTip(tr("Select ranges")); | 1720 action->setStatusTip(tr("Select ranges")); |
1620 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected())); | 1721 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected())); |
1621 group->addAction(action); | 1722 group->addAction(action); |
1723 m_keyReference->registerShortcut(action); | |
1622 m_toolActions[ViewManager::SelectMode] = action; | 1724 m_toolActions[ViewManager::SelectMode] = action; |
1623 | 1725 |
1624 action = toolbar->addAction(QIcon(":/icons/move.png"), | 1726 action = toolbar->addAction(QIcon(":/icons/move.png"), |
1625 tr("Edit")); | 1727 tr("Edit")); |
1626 action->setCheckable(true); | 1728 action->setCheckable(true); |
1627 action->setShortcut(tr("3")); | 1729 action->setShortcut(tr("3")); |
1628 action->setStatusTip(tr("Edit items in layer")); | 1730 action->setStatusTip(tr("Edit items in layer")); |
1629 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected())); | 1731 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected())); |
1630 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); | 1732 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); |
1631 group->addAction(action); | 1733 group->addAction(action); |
1734 m_keyReference->registerShortcut(action); | |
1632 m_toolActions[ViewManager::EditMode] = action; | 1735 m_toolActions[ViewManager::EditMode] = action; |
1633 | 1736 |
1634 action = toolbar->addAction(QIcon(":/icons/draw.png"), | 1737 action = toolbar->addAction(QIcon(":/icons/draw.png"), |
1635 tr("Draw")); | 1738 tr("Draw")); |
1636 action->setCheckable(true); | 1739 action->setCheckable(true); |
1637 action->setShortcut(tr("4")); | 1740 action->setShortcut(tr("4")); |
1638 action->setStatusTip(tr("Draw new items in layer")); | 1741 action->setStatusTip(tr("Draw new items in layer")); |
1639 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected())); | 1742 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected())); |
1640 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); | 1743 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); |
1641 group->addAction(action); | 1744 group->addAction(action); |
1745 m_keyReference->registerShortcut(action); | |
1642 m_toolActions[ViewManager::DrawMode] = action; | 1746 m_toolActions[ViewManager::DrawMode] = action; |
1643 | 1747 |
1644 action = toolbar->addAction(QIcon(":/icons/measure.png"), | 1748 action = toolbar->addAction(QIcon(":/icons/measure.png"), |
1645 tr("Measure")); | 1749 tr("Measure")); |
1646 action->setCheckable(true); | 1750 action->setCheckable(true); |
1647 action->setShortcut(tr("5")); | 1751 action->setShortcut(tr("5")); |
1648 action->setStatusTip(tr("Make measurements in layer")); | 1752 action->setStatusTip(tr("Make measurements in layer")); |
1649 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected())); | 1753 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected())); |
1650 group->addAction(action); | 1754 group->addAction(action); |
1755 m_keyReference->registerShortcut(action); | |
1651 m_toolActions[ViewManager::MeasureMode] = action; | 1756 m_toolActions[ViewManager::MeasureMode] = action; |
1652 | 1757 |
1653 // action = toolbar->addAction(QIcon(":/icons/text.png"), | 1758 // action = toolbar->addAction(QIcon(":/icons/text.png"), |
1654 // tr("Text")); | 1759 // tr("Text")); |
1655 // action->setCheckable(true); | 1760 // action->setCheckable(true); |
4977 "COPYING included with this distribution for more information.</p>"; | 5082 "COPYING included with this distribution for more information.</p>"; |
4978 | 5083 |
4979 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText); | 5084 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText); |
4980 } | 5085 } |
4981 | 5086 |
5087 void | |
5088 MainWindow::keyReference() | |
5089 { | |
5090 m_keyReference->show(); | |
5091 } | |
5092 |