Skip to content

Commit

Permalink
[FEATURE][composer] New action for toggling visibility of panels
Browse files Browse the repository at this point in the history
This change adds a new action to the composer which hides or shows
all panels from the window. It's useful for maximising the space
available to interact with a composition. A shortcut (F10) and menu
item can be used to toggle this option, or via pressing 'tab' while
the main composer view is focused.
  • Loading branch information
nyalldawson committed Oct 31, 2014
1 parent 220bc84 commit 48e0a59
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mToolbarMenu->setObjectName( "mToolbarMenu" );
viewMenu->addSeparator();
viewMenu->addAction( mActionToggleFullScreen );
viewMenu->addAction( mActionHidePanels );
viewMenu->addMenu( mPanelMenu );
viewMenu->addMenu( mToolbarMenu );
// toolBar already exists, add other widgets as they are created
Expand Down Expand Up @@ -1246,6 +1247,16 @@ void QgsComposer::on_mActionToggleFullScreen_triggered()
}
}

void QgsComposer::on_mActionHidePanels_triggered()
{
bool showPanels = !mActionHidePanels->isChecked();
mItemDock->setVisible( showPanels );
mGeneralDock->setVisible( showPanels );
mUndoDock->setVisible( showPanels );
mAtlasDock->setVisible( showPanels );
mItemsDock->setVisible( showPanels );
}

void QgsComposer::disablePreviewMode()
{
if ( !mView )
Expand Down Expand Up @@ -3568,6 +3579,14 @@ void QgsComposer::createComposerView()
mView->setHorizontalRuler( mHorizontalRuler );
mView->setVerticalRuler( mVerticalRuler );
mViewLayout->addWidget( mView, 1, 1 );

//view does not accept focus via tab
mView->setFocusPolicy( Qt::ClickFocus );
//instead, if view is focused and tab is pressed than mActionHidePanels is triggered,
//to toggle display of panels
QShortcut* tab = new QShortcut( Qt::Key_Tab, mView );
tab->setContext( Qt::WidgetWithChildrenShortcut );
connect( tab, SIGNAL( activated() ), mActionHidePanels, SLOT( trigger() ) );
}

void QgsComposer::writeWorldFile( QString worldFileName, double a, double b, double c, double d, double e, double f ) const
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Toggle full screen mode
void on_mActionToggleFullScreen_triggered();

//! Toggle panels
void on_mActionHidePanels_triggered();

//! Save window state
void saveWindowState();

Expand Down
14 changes: 14 additions & 0 deletions src/ui/qgscomposerbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,20 @@
<string>F11</string>
</property>
</action>
<action name="mActionHidePanels">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Hide Panels</string>
</property>
<property name="toolTip">
<string>Hide panels</string>
</property>
<property name="shortcut">
<string>F10</string>
</property>
</action>
</widget>
<resources>
<include location="../../python/plugins/fTools/resources.qrc"/>
Expand Down

0 comments on commit 48e0a59

Please sign in to comment.