Skip to content

Commit 3982498

Browse files
committedDec 15, 2016
[FEATURE] toggle visibility of opened panels in main window
Accessible via: - View menu > Toggle Panels Visibility - Ctrl+Tab keyboard shortcut
1 parent 6377303 commit 3982498

File tree

5 files changed

+76
-10
lines changed

5 files changed

+76
-10
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
368368
mToolbarMenu = new QMenu( tr( "&Toolbars" ), this );
369369
mToolbarMenu->setObjectName( QStringLiteral( "mToolbarMenu" ) );
370370
viewMenu->addSeparator();
371-
viewMenu->addAction( mActionToggleFullScreen );
372-
viewMenu->addAction( mActionHidePanels );
373371
viewMenu->addMenu( mPanelMenu );
374372
viewMenu->addMenu( mToolbarMenu );
373+
viewMenu->addAction( mActionToggleFullScreen );
374+
viewMenu->addAction( mActionHidePanels );
375375
// toolBar already exists, add other widgets as they are created
376376
mToolbarMenu->addAction( mComposerToolbar->toggleViewAction() );
377377
mToolbarMenu->addAction( mPaperNavToolbar->toggleViewAction() );
@@ -4048,11 +4048,6 @@ void QgsComposer::createComposerView()
40484048

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

40584053
void QgsComposer::writeWorldFile( const QString& worldFileName, double a, double b, double c, double d, double e, double f ) const

‎src/app/qgisapp.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@ void QgisApp::createActions()
17141714
// Settings Menu Items
17151715

17161716
connect( mActionToggleFullScreen, SIGNAL( triggered() ), this, SLOT( toggleFullScreen() ) );
1717+
connect( mActionTogglePanelsVisibility, SIGNAL( triggered() ), this, SLOT( togglePanelsVisibility() ) );
17171718
connect( mActionProjectProperties, SIGNAL( triggered() ), this, SLOT( projectProperties() ) );
17181719
connect( mActionOptions, SIGNAL( triggered() ), this, SLOT( options() ) );
17191720
connect( mActionCustomProjection, SIGNAL( triggered() ), this, SLOT( customProjection() ) );
@@ -1998,6 +1999,7 @@ void QgisApp::createMenus()
19981999
mViewMenu->addMenu( mPanelMenu );
19992000
mViewMenu->addMenu( mToolbarMenu );
20002001
mViewMenu->addAction( mActionToggleFullScreen );
2002+
mViewMenu->addAction( mActionTogglePanelsVisibility );
20012003
}
20022004
else
20032005
{
@@ -2006,6 +2008,7 @@ void QgisApp::createMenus()
20062008
mSettingsMenu->insertMenu( before, mPanelMenu );
20072009
mSettingsMenu->insertMenu( before, mToolbarMenu );
20082010
mSettingsMenu->insertAction( before, mActionToggleFullScreen );
2011+
mSettingsMenu->insertAction( before, mActionTogglePanelsVisibility );
20092012
mSettingsMenu->insertSeparator( before );
20102013
}
20112014

@@ -5622,6 +5625,62 @@ void QgisApp::toggleFullScreen()
56225625
}
56235626
}
56245627

5628+
void QgisApp::togglePanelsVisibility()
5629+
{
5630+
QSettings settings;
5631+
5632+
QStringList docksTitle = settings.value( "UI/hiddenDocksTitle", QString() ).toStringList();
5633+
QStringList docksActive = settings.value( "UI/hiddenDocksActive", QString() ).toStringList();
5634+
5635+
QList<QDockWidget*> docks = findChildren<QDockWidget*>();
5636+
QList<QTabBar *> tabBars = findChildren<QTabBar *>();
5637+
5638+
if ( docksTitle.isEmpty() )
5639+
{
5640+
5641+
Q_FOREACH ( QDockWidget* dock, docks )
5642+
{
5643+
if ( dock->isVisible() && !dock->isFloating() )
5644+
{
5645+
docksTitle << dock->windowTitle();
5646+
dock->setVisible( false );
5647+
}
5648+
}
5649+
5650+
Q_FOREACH ( QTabBar* tabBar, tabBars )
5651+
{
5652+
docksActive << tabBar->tabText( tabBar->currentIndex() );
5653+
}
5654+
5655+
settings.setValue( QStringLiteral( "/UI/hiddenDocksTitle" ), docksTitle );
5656+
settings.setValue( QStringLiteral( "/UI/hiddenDocksActive" ), docksActive );
5657+
}
5658+
else
5659+
{
5660+
Q_FOREACH ( QDockWidget* dock, docks )
5661+
{
5662+
if ( docksTitle.contains( dock->windowTitle() ) )
5663+
{
5664+
dock->setVisible( true );
5665+
}
5666+
}
5667+
5668+
Q_FOREACH ( QTabBar* tabBar, tabBars )
5669+
{
5670+
for ( int i = 0; i < tabBar->count(); ++i )
5671+
{
5672+
if ( docksActive.contains( tabBar->tabText( i ) ) )
5673+
{
5674+
tabBar->setCurrentIndex( i );
5675+
}
5676+
}
5677+
}
5678+
5679+
settings.setValue( QStringLiteral( "/UI/hiddenDocksTitle" ), QStringList() );
5680+
settings.setValue( QStringLiteral( "/UI/hiddenDocksActive" ), QStringList() );
5681+
}
5682+
}
5683+
56255684
void QgisApp::showActiveWindowMinimized()
56265685
{
56275686
QWidget *window = QApplication::activeWindow();

‎src/app/qgisapp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
418418
QAction *actionShowPythonDialog() { return mActionShowPythonDialog; }
419419

420420
QAction *actionToggleFullScreen() { return mActionToggleFullScreen; }
421+
QAction *actionTogglePanelsVisibility() { return mActionTogglePanelsVisibility; }
421422
QAction *actionOptions() { return mActionOptions; }
422423
QAction *actionCustomProjection() { return mActionCustomProjection; }
423424
QAction *actionConfigureShortcuts() { return mActionConfigureShortcuts; }
@@ -1279,6 +1280,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12791280
//! Toggle full screen mode
12801281
void toggleFullScreen();
12811282

1283+
//! Toggle visibility of opened panels
1284+
void togglePanelsVisibility();
1285+
12821286
//! Set minimized mode of active window
12831287
void showActiveWindowMinimized();
12841288

‎src/ui/composer/qgscomposerbase.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,13 +1038,13 @@
10381038
<bool>true</bool>
10391039
</property>
10401040
<property name="text">
1041-
<string>&amp;Hide Panels</string>
1041+
<string>Toggle Panel &amp;Visibility</string>
10421042
</property>
10431043
<property name="toolTip">
10441044
<string>Hide panels</string>
10451045
</property>
10461046
<property name="shortcut">
1047-
<string>F10</string>
1047+
<string>Ctrl+Tab</string>
10481048
</property>
10491049
</action>
10501050
<action name="mActionShowPage">

‎src/ui/qgisapp.ui

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,12 +1548,20 @@
15481548
</action>
15491549
<action name="mActionToggleFullScreen">
15501550
<property name="text">
1551-
<string>Toggle Full Screen Mode</string>
1551+
<string>Toggle Full Scr&amp;een Mode</string>
15521552
</property>
15531553
<property name="shortcut">
15541554
<string>F11</string>
15551555
</property>
15561556
</action>
1557+
<action name="mActionTogglePanelsVisibility">
1558+
<property name="text">
1559+
<string>Toggle Panel &amp;Visibility</string>
1560+
</property>
1561+
<property name="shortcut">
1562+
<string>Ctrl+Tab</string>
1563+
</property>
1564+
</action>
15571565
<action name="mActionProjectProperties">
15581566
<property name="icon">
15591567
<iconset resource="../../images/images.qrc">

0 commit comments

Comments
 (0)
Please sign in to comment.