comparison main/MainWindow.cpp @ 494:238a97d2a8f4 fullscreen

Connect up various keyboard actions in full-screen mode
author Chris Cannam
date Mon, 23 Jan 2012 17:46:40 +0000
parents 3a85461ab9a7
children d2a58dfc3ae5
comparison
equal deleted inserted replaced
493:3a85461ab9a7 494:238a97d2a8f4
375 375
376 void 376 void
377 MainWindow::goFullScreen() 377 MainWindow::goFullScreen()
378 { 378 {
379 QWidget *ps = m_mainScroll->takeWidget(); 379 QWidget *ps = m_mainScroll->takeWidget();
380 // m_mainScroll->setWidget(0);
381 ps->setParent(0); 380 ps->setParent(0);
381
382 QShortcut *sc;
383
384 sc = new QShortcut(QKeySequence("Esc"), ps);
385 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen()));
386
387 sc = new QShortcut(QKeySequence("F11"), ps);
388 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen()));
389
390 QAction *acts[] = {
391 m_playAction, m_zoomInAction, m_zoomOutAction, m_zoomFitAction,
392 m_scrollLeftAction, m_scrollRightAction, m_showPropertyBoxesAction
393 };
394
395 for (int i = 0; i < sizeof(acts)/sizeof(acts[0]); ++i) {
396 sc = new QShortcut(acts[i]->shortcut(), ps);
397 connect(sc, SIGNAL(activated()), acts[i], SLOT(trigger()));
398 }
399
382 ps->showFullScreen(); 400 ps->showFullScreen();
383 // ps->showMaximized();
384 QShortcut *sc = new QShortcut(QKeySequence("Esc"), ps);
385 connect(sc, SIGNAL(activated()), this, SLOT(endFullScreen()));
386 // QApplication::processEvents();
387 // m_paneStack->adjustSize();
388 } 401 }
389 402
390 void 403 void
391 MainWindow::endFullScreen() 404 MainWindow::endFullScreen()
392 { 405 {
393 QShortcut *sc = dynamic_cast<QShortcut *>(sender()); 406 // these were only created in goFullScreen:
394 if (sc) delete sc; // it was only created in goFullScreen 407 QObjectList cl = m_paneStack->children();
408 foreach (QObject *o, cl) {
409 QShortcut *sc = qobject_cast<QShortcut *>(o);
410 if (sc) delete sc;
411 }
412
395 m_mainScroll->setWidget(m_paneStack); 413 m_mainScroll->setWidget(m_paneStack);
396 } 414 }
397 415
398 void 416 void
399 MainWindow::setupFileMenu() 417 MainWindow::setupFileMenu()
774 792
775 m_keyReference->setCategory(tr("Panning and Navigation")); 793 m_keyReference->setCategory(tr("Panning and Navigation"));
776 794
777 QMenu *menu = menuBar()->addMenu(tr("&View")); 795 QMenu *menu = menuBar()->addMenu(tr("&View"));
778 menu->setTearOffEnabled(true); 796 menu->setTearOffEnabled(true);
779 action = new QAction(tr("Scroll &Left"), this); 797 m_scrollLeftAction = new QAction(tr("Scroll &Left"), this);
780 action->setShortcut(tr("Left")); 798 m_scrollLeftAction->setShortcut(tr("Left"));
781 action->setStatusTip(tr("Scroll the current pane to the left")); 799 m_scrollLeftAction->setStatusTip(tr("Scroll the current pane to the left"));
782 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); 800 connect(m_scrollLeftAction, SIGNAL(triggered()), this, SLOT(scrollLeft()));
783 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 801 connect(this, SIGNAL(canScroll(bool)), m_scrollLeftAction, SLOT(setEnabled(bool)));
784 m_keyReference->registerShortcut(action); 802 m_keyReference->registerShortcut(m_scrollLeftAction);
785 menu->addAction(action); 803 menu->addAction(m_scrollLeftAction);
786 804
787 action = new QAction(tr("Scroll &Right"), this); 805 m_scrollRightAction = new QAction(tr("Scroll &Right"), this);
788 action->setShortcut(tr("Right")); 806 m_scrollRightAction->setShortcut(tr("Right"));
789 action->setStatusTip(tr("Scroll the current pane to the right")); 807 m_scrollRightAction->setStatusTip(tr("Scroll the current pane to the right"));
790 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); 808 connect(m_scrollRightAction, SIGNAL(triggered()), this, SLOT(scrollRight()));
791 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 809 connect(this, SIGNAL(canScroll(bool)), m_scrollRightAction, SLOT(setEnabled(bool)));
792 m_keyReference->registerShortcut(action); 810 m_keyReference->registerShortcut(m_scrollRightAction);
793 menu->addAction(action); 811 menu->addAction(m_scrollRightAction);
794 812
795 action = new QAction(tr("&Jump Left"), this); 813 action = new QAction(tr("&Jump Left"), this);
796 action->setShortcut(tr("Ctrl+Left")); 814 action->setShortcut(tr("Ctrl+Left"));
797 action->setStatusTip(tr("Scroll the current pane a big step to the left")); 815 action->setStatusTip(tr("Scroll the current pane a big step to the left"));
798 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); 816 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
826 844
827 menu->addSeparator(); 845 menu->addSeparator();
828 846
829 m_keyReference->setCategory(tr("Zoom")); 847 m_keyReference->setCategory(tr("Zoom"));
830 848
831 action = new QAction(il.load("zoom-in"), 849 m_zoomInAction = new QAction(il.load("zoom-in"),
832 tr("Zoom &In"), this); 850 tr("Zoom &In"), this);
833 action->setShortcut(tr("Up")); 851 m_zoomInAction->setShortcut(tr("Up"));
834 action->setStatusTip(tr("Increase the zoom level")); 852 m_zoomInAction->setStatusTip(tr("Increase the zoom level"));
835 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); 853 connect(m_zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
836 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 854 connect(this, SIGNAL(canZoom(bool)), m_zoomInAction, SLOT(setEnabled(bool)));
837 m_keyReference->registerShortcut(action); 855 m_keyReference->registerShortcut(m_zoomInAction);
838 menu->addAction(action); 856 menu->addAction(m_zoomInAction);
839 857
840 action = new QAction(il.load("zoom-out"), 858 m_zoomOutAction = new QAction(il.load("zoom-out"),
841 tr("Zoom &Out"), this); 859 tr("Zoom &Out"), this);
842 action->setShortcut(tr("Down")); 860 m_zoomOutAction->setShortcut(tr("Down"));
843 action->setStatusTip(tr("Decrease the zoom level")); 861 m_zoomOutAction->setStatusTip(tr("Decrease the zoom level"));
844 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); 862 connect(m_zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
845 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 863 connect(this, SIGNAL(canZoom(bool)), m_zoomOutAction, SLOT(setEnabled(bool)));
846 m_keyReference->registerShortcut(action); 864 m_keyReference->registerShortcut(m_zoomOutAction);
847 menu->addAction(action); 865 menu->addAction(m_zoomOutAction);
848 866
849 action = new QAction(tr("Restore &Default Zoom"), this); 867 action = new QAction(tr("Restore &Default Zoom"), this);
850 action->setStatusTip(tr("Restore the zoom level to the default")); 868 action->setStatusTip(tr("Restore the zoom level to the default"));
851 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); 869 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
852 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 870 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
853 menu->addAction(action); 871 menu->addAction(action);
854 872
855 action = new QAction(il.load("zoom-fit"), 873 m_zoomFitAction = new QAction(il.load("zoom-fit"),
856 tr("Zoom to &Fit"), this); 874 tr("Zoom to &Fit"), this);
857 action->setShortcut(tr("F")); 875 m_zoomFitAction->setShortcut(tr("F"));
858 action->setStatusTip(tr("Zoom to show the whole file")); 876 m_zoomFitAction->setStatusTip(tr("Zoom to show the whole file"));
859 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit())); 877 connect(m_zoomFitAction, SIGNAL(triggered()), this, SLOT(zoomToFit()));
860 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 878 connect(this, SIGNAL(canZoom(bool)), m_zoomFitAction, SLOT(setEnabled(bool)));
861 m_keyReference->registerShortcut(action); 879 m_keyReference->registerShortcut(m_zoomFitAction);
862 menu->addAction(action); 880 menu->addAction(m_zoomFitAction);
863 881
864 menu->addSeparator(); 882 menu->addSeparator();
865 883
866 m_keyReference->setCategory(tr("Display Features")); 884 m_keyReference->setCategory(tr("Display Features"));
867 885
925 action->setCheckable(true); 943 action->setCheckable(true);
926 action->setChecked(m_viewManager->getZoomWheelsEnabled()); 944 action->setChecked(m_viewManager->getZoomWheelsEnabled());
927 m_keyReference->registerShortcut(action); 945 m_keyReference->registerShortcut(action);
928 menu->addAction(action); 946 menu->addAction(action);
929 947
930 action = new QAction(tr("Show Property Bo&xes"), this); 948 m_showPropertyBoxesAction = new QAction(tr("Show Property Bo&xes"), this);
931 action->setShortcut(tr("X")); 949 m_showPropertyBoxesAction->setShortcut(tr("X"));
932 action->setStatusTip(tr("Show the layer property boxes at the side of the main window")); 950 m_showPropertyBoxesAction->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
933 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes())); 951 connect(m_showPropertyBoxesAction, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
934 action->setCheckable(true); 952 m_showPropertyBoxesAction->setCheckable(true);
935 action->setChecked(true); 953 m_showPropertyBoxesAction->setChecked(true);
936 m_keyReference->registerShortcut(action); 954 m_keyReference->registerShortcut(m_showPropertyBoxesAction);
937 menu->addAction(action); 955 menu->addAction(m_showPropertyBoxesAction);
938 956
939 action = new QAction(tr("Show Status &Bar"), this); 957 action = new QAction(tr("Show Status &Bar"), this);
940 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window")); 958 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
941 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar())); 959 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
942 action->setCheckable(true); 960 action->setCheckable(true);
964 action = new QAction(tr("Show Acti&vity Log"), this); 982 action = new QAction(tr("Show Acti&vity Log"), this);
965 action->setStatusTip(tr("Open a window listing interactions and other events")); 983 action->setStatusTip(tr("Open a window listing interactions and other events"));
966 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog())); 984 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog()));
967 menu->addAction(action); 985 menu->addAction(action);
968 986
969 //!!! 987 menu->addSeparator();
988
970 action = new QAction(tr("Go Full-Screen"), this); 989 action = new QAction(tr("Go Full-Screen"), this);
990 action->setShortcut(tr("F11"));
991 action->setStatusTip(tr("Expand the pane area to the whole screen"));
971 connect(action, SIGNAL(triggered()), this, SLOT(goFullScreen())); 992 connect(action, SIGNAL(triggered()), this, SLOT(goFullScreen()));
993 m_keyReference->registerShortcut(action);
972 menu->addAction(action); 994 menu->addAction(action);
973 } 995 }
974 996
975 void 997 void
976 MainWindow::setupPaneAndLayerMenus() 998 MainWindow::setupPaneAndLayerMenus()