comparison main/MainWindow.cpp @ 498:d2a58dfc3ae5

Merge from branch "fullscreen"
author Chris Cannam
date Mon, 30 Jan 2012 16:06:47 +0000
parents e583f57f1311 238a97d2a8f4
children 44ab626bb866 032deed8b35b
comparison
equal deleted inserted replaced
497:e583f57f1311 498:d2a58dfc3ae5
195 195
196 QGridLayout *layout = new QGridLayout; 196 QGridLayout *layout = new QGridLayout;
197 197
198 m_descriptionLabel = new QLabel; //!!! hang on, this is declared in base class -- should be declared and initialised by same class 198 m_descriptionLabel = new QLabel; //!!! hang on, this is declared in base class -- should be declared and initialised by same class
199 199
200 QScrollArea *scroll = new QScrollArea(frame); 200 m_mainScroll = new QScrollArea(frame);
201 scroll->setWidgetResizable(true); 201 m_mainScroll->setWidgetResizable(true);
202 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 202 m_mainScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
203 scroll->setFrameShape(QFrame::NoFrame); 203 m_mainScroll->setFrameShape(QFrame::NoFrame);
204 204
205 scroll->setWidget(m_paneStack); 205 m_mainScroll->setWidget(m_paneStack);
206 206
207 m_overview = new Overview(frame); 207 m_overview = new Overview(frame);
208 m_overview->setViewManager(m_viewManager); 208 m_overview->setViewManager(m_viewManager);
209 m_overview->setFixedHeight(40); 209 m_overview->setFixedHeight(40);
210 #ifndef _WIN32 210 #ifndef _WIN32
257 settings.endGroup(); 257 settings.endGroup();
258 258
259 m_playControlsSpacer = new QFrame; 259 m_playControlsSpacer = new QFrame;
260 260
261 layout->setSpacing(4); 261 layout->setSpacing(4);
262 layout->addWidget(scroll, 0, 0, 1, 5); 262 layout->addWidget(m_mainScroll, 0, 0, 1, 5);
263 layout->addWidget(m_overview, 1, 1); 263 layout->addWidget(m_overview, 1, 1);
264 layout->addWidget(m_playControlsSpacer, 1, 2); 264 layout->addWidget(m_playControlsSpacer, 1, 2);
265 layout->addWidget(m_playSpeed, 1, 3); 265 layout->addWidget(m_playSpeed, 1, 3);
266 layout->addWidget(m_fader, 1, 4); 266 layout->addWidget(m_fader, 1, 4);
267 267
372 372
373 m_mainMenusCreated = true; 373 m_mainMenusCreated = true;
374 } 374 }
375 375
376 void 376 void
377 MainWindow::goFullScreen()
378 {
379 QWidget *ps = m_mainScroll->takeWidget();
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
400 ps->showFullScreen();
401 }
402
403 void
404 MainWindow::endFullScreen()
405 {
406 // these were 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
413 m_mainScroll->setWidget(m_paneStack);
414 }
415
416 void
377 MainWindow::setupFileMenu() 417 MainWindow::setupFileMenu()
378 { 418 {
379 if (m_mainMenusCreated) return; 419 if (m_mainMenusCreated) return;
380 420
381 QMenu *menu = menuBar()->addMenu(tr("&File")); 421 QMenu *menu = menuBar()->addMenu(tr("&File"));
752 792
753 m_keyReference->setCategory(tr("Panning and Navigation")); 793 m_keyReference->setCategory(tr("Panning and Navigation"));
754 794
755 QMenu *menu = menuBar()->addMenu(tr("&View")); 795 QMenu *menu = menuBar()->addMenu(tr("&View"));
756 menu->setTearOffEnabled(true); 796 menu->setTearOffEnabled(true);
757 action = new QAction(tr("Scroll &Left"), this); 797 m_scrollLeftAction = new QAction(tr("Scroll &Left"), this);
758 action->setShortcut(tr("Left")); 798 m_scrollLeftAction->setShortcut(tr("Left"));
759 action->setStatusTip(tr("Scroll the current pane to the left")); 799 m_scrollLeftAction->setStatusTip(tr("Scroll the current pane to the left"));
760 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); 800 connect(m_scrollLeftAction, SIGNAL(triggered()), this, SLOT(scrollLeft()));
761 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 801 connect(this, SIGNAL(canScroll(bool)), m_scrollLeftAction, SLOT(setEnabled(bool)));
762 m_keyReference->registerShortcut(action); 802 m_keyReference->registerShortcut(m_scrollLeftAction);
763 menu->addAction(action); 803 menu->addAction(m_scrollLeftAction);
764 804
765 action = new QAction(tr("Scroll &Right"), this); 805 m_scrollRightAction = new QAction(tr("Scroll &Right"), this);
766 action->setShortcut(tr("Right")); 806 m_scrollRightAction->setShortcut(tr("Right"));
767 action->setStatusTip(tr("Scroll the current pane to the right")); 807 m_scrollRightAction->setStatusTip(tr("Scroll the current pane to the right"));
768 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); 808 connect(m_scrollRightAction, SIGNAL(triggered()), this, SLOT(scrollRight()));
769 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 809 connect(this, SIGNAL(canScroll(bool)), m_scrollRightAction, SLOT(setEnabled(bool)));
770 m_keyReference->registerShortcut(action); 810 m_keyReference->registerShortcut(m_scrollRightAction);
771 menu->addAction(action); 811 menu->addAction(m_scrollRightAction);
772 812
773 action = new QAction(tr("&Jump Left"), this); 813 action = new QAction(tr("&Jump Left"), this);
774 action->setShortcut(tr("Ctrl+Left")); 814 action->setShortcut(tr("Ctrl+Left"));
775 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"));
776 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); 816 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft()));
804 844
805 menu->addSeparator(); 845 menu->addSeparator();
806 846
807 m_keyReference->setCategory(tr("Zoom")); 847 m_keyReference->setCategory(tr("Zoom"));
808 848
809 action = new QAction(il.load("zoom-in"), 849 m_zoomInAction = new QAction(il.load("zoom-in"),
810 tr("Zoom &In"), this); 850 tr("Zoom &In"), this);
811 action->setShortcut(tr("Up")); 851 m_zoomInAction->setShortcut(tr("Up"));
812 action->setStatusTip(tr("Increase the zoom level")); 852 m_zoomInAction->setStatusTip(tr("Increase the zoom level"));
813 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); 853 connect(m_zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
814 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 854 connect(this, SIGNAL(canZoom(bool)), m_zoomInAction, SLOT(setEnabled(bool)));
815 m_keyReference->registerShortcut(action); 855 m_keyReference->registerShortcut(m_zoomInAction);
816 menu->addAction(action); 856 menu->addAction(m_zoomInAction);
817 857
818 action = new QAction(il.load("zoom-out"), 858 m_zoomOutAction = new QAction(il.load("zoom-out"),
819 tr("Zoom &Out"), this); 859 tr("Zoom &Out"), this);
820 action->setShortcut(tr("Down")); 860 m_zoomOutAction->setShortcut(tr("Down"));
821 action->setStatusTip(tr("Decrease the zoom level")); 861 m_zoomOutAction->setStatusTip(tr("Decrease the zoom level"));
822 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); 862 connect(m_zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
823 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 863 connect(this, SIGNAL(canZoom(bool)), m_zoomOutAction, SLOT(setEnabled(bool)));
824 m_keyReference->registerShortcut(action); 864 m_keyReference->registerShortcut(m_zoomOutAction);
825 menu->addAction(action); 865 menu->addAction(m_zoomOutAction);
826 866
827 action = new QAction(tr("Restore &Default Zoom"), this); 867 action = new QAction(tr("Restore &Default Zoom"), this);
828 action->setStatusTip(tr("Restore the zoom level to the default")); 868 action->setStatusTip(tr("Restore the zoom level to the default"));
829 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); 869 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
830 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 870 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
831 menu->addAction(action); 871 menu->addAction(action);
832 872
833 action = new QAction(il.load("zoom-fit"), 873 m_zoomFitAction = new QAction(il.load("zoom-fit"),
834 tr("Zoom to &Fit"), this); 874 tr("Zoom to &Fit"), this);
835 action->setShortcut(tr("F")); 875 m_zoomFitAction->setShortcut(tr("F"));
836 action->setStatusTip(tr("Zoom to show the whole file")); 876 m_zoomFitAction->setStatusTip(tr("Zoom to show the whole file"));
837 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit())); 877 connect(m_zoomFitAction, SIGNAL(triggered()), this, SLOT(zoomToFit()));
838 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 878 connect(this, SIGNAL(canZoom(bool)), m_zoomFitAction, SLOT(setEnabled(bool)));
839 m_keyReference->registerShortcut(action); 879 m_keyReference->registerShortcut(m_zoomFitAction);
840 menu->addAction(action); 880 menu->addAction(m_zoomFitAction);
841 881
842 menu->addSeparator(); 882 menu->addSeparator();
843 883
844 m_keyReference->setCategory(tr("Display Features")); 884 m_keyReference->setCategory(tr("Display Features"));
845 885
902 action->setCheckable(true); 942 action->setCheckable(true);
903 action->setChecked(m_viewManager->getZoomWheelsEnabled()); 943 action->setChecked(m_viewManager->getZoomWheelsEnabled());
904 m_keyReference->registerShortcut(action); 944 m_keyReference->registerShortcut(action);
905 menu->addAction(action); 945 menu->addAction(action);
906 946
907 action = new QAction(tr("Show Property Bo&xes"), this); 947 m_showPropertyBoxesAction = new QAction(tr("Show Property Bo&xes"), this);
908 action->setShortcut(tr("X")); 948 m_showPropertyBoxesAction->setShortcut(tr("X"));
909 action->setStatusTip(tr("Show the layer property boxes at the side of the main window")); 949 m_showPropertyBoxesAction->setStatusTip(tr("Show the layer property boxes at the side of the main window"));
910 connect(action, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes())); 950 connect(m_showPropertyBoxesAction, SIGNAL(triggered()), this, SLOT(togglePropertyBoxes()));
911 action->setCheckable(true); 951 m_showPropertyBoxesAction->setCheckable(true);
912 action->setChecked(true); 952 m_showPropertyBoxesAction->setChecked(true);
913 m_keyReference->registerShortcut(action); 953 m_keyReference->registerShortcut(m_showPropertyBoxesAction);
914 menu->addAction(action); 954 menu->addAction(m_showPropertyBoxesAction);
915 955
916 action = new QAction(tr("Show Status &Bar"), this); 956 action = new QAction(tr("Show Status &Bar"), this);
917 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window")); 957 action->setStatusTip(tr("Show context help information in the status bar at the bottom of the window"));
918 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar())); 958 connect(action, SIGNAL(triggered()), this, SLOT(toggleStatusBar()));
919 action->setCheckable(true); 959 action->setCheckable(true);
939 menu->addAction(action); 979 menu->addAction(action);
940 980
941 action = new QAction(tr("Show Acti&vity Log"), this); 981 action = new QAction(tr("Show Acti&vity Log"), this);
942 action->setStatusTip(tr("Open a window listing interactions and other events")); 982 action->setStatusTip(tr("Open a window listing interactions and other events"));
943 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog())); 983 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog()));
984 menu->addAction(action);
985
986 menu->addSeparator();
987
988 action = new QAction(tr("Go Full-Screen"), this);
989 action->setShortcut(tr("F11"));
990 action->setStatusTip(tr("Expand the pane area to the whole screen"));
991 connect(action, SIGNAL(triggered()), this, SLOT(goFullScreen()));
992 m_keyReference->registerShortcut(action);
944 menu->addAction(action); 993 menu->addAction(action);
945 } 994 }
946 995
947 void 996 void
948 MainWindow::setupPaneAndLayerMenus() 997 MainWindow::setupPaneAndLayerMenus()