Skip to content
Permalink
Browse files

[FEATURE] toggle visibility of opened panels in main window

Accessible via:
- View menu > Toggle Panels Visibility
- Ctrl+Tab keyboard shortcut
  • Loading branch information
nirvn committed Dec 15, 2016
1 parent 6377303 commit 398249806f9cc87d935c5cd8a76c7dee3816d45b
Showing with 76 additions and 10 deletions.
  1. +2 −7 src/app/composer/qgscomposer.cpp
  2. +59 −0 src/app/qgisapp.cpp
  3. +4 −0 src/app/qgisapp.h
  4. +2 −2 src/ui/composer/qgscomposerbase.ui
  5. +9 −1 src/ui/qgisapp.ui
@@ -368,10 +368,10 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mToolbarMenu = new QMenu( tr( "&Toolbars" ), this );
mToolbarMenu->setObjectName( QStringLiteral( "mToolbarMenu" ) );
viewMenu->addSeparator();
viewMenu->addAction( mActionToggleFullScreen );
viewMenu->addAction( mActionHidePanels );
viewMenu->addMenu( mPanelMenu );
viewMenu->addMenu( mToolbarMenu );
viewMenu->addAction( mActionToggleFullScreen );
viewMenu->addAction( mActionHidePanels );
// toolBar already exists, add other widgets as they are created
mToolbarMenu->addAction( mComposerToolbar->toggleViewAction() );
mToolbarMenu->addAction( mPaperNavToolbar->toggleViewAction() );
@@ -4048,11 +4048,6 @@ void QgsComposer::createComposerView()

//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( const QString& worldFileName, double a, double b, double c, double d, double e, double f ) const
@@ -1714,6 +1714,7 @@ void QgisApp::createActions()
// Settings Menu Items

connect( mActionToggleFullScreen, SIGNAL( triggered() ), this, SLOT( toggleFullScreen() ) );
connect( mActionTogglePanelsVisibility, SIGNAL( triggered() ), this, SLOT( togglePanelsVisibility() ) );
connect( mActionProjectProperties, SIGNAL( triggered() ), this, SLOT( projectProperties() ) );
connect( mActionOptions, SIGNAL( triggered() ), this, SLOT( options() ) );
connect( mActionCustomProjection, SIGNAL( triggered() ), this, SLOT( customProjection() ) );
@@ -1998,6 +1999,7 @@ void QgisApp::createMenus()
mViewMenu->addMenu( mPanelMenu );
mViewMenu->addMenu( mToolbarMenu );
mViewMenu->addAction( mActionToggleFullScreen );
mViewMenu->addAction( mActionTogglePanelsVisibility );
}
else
{
@@ -2006,6 +2008,7 @@ void QgisApp::createMenus()
mSettingsMenu->insertMenu( before, mPanelMenu );
mSettingsMenu->insertMenu( before, mToolbarMenu );
mSettingsMenu->insertAction( before, mActionToggleFullScreen );
mSettingsMenu->insertAction( before, mActionTogglePanelsVisibility );
mSettingsMenu->insertSeparator( before );
}

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

void QgisApp::togglePanelsVisibility()
{
QSettings settings;

QStringList docksTitle = settings.value( "UI/hiddenDocksTitle", QString() ).toStringList();
QStringList docksActive = settings.value( "UI/hiddenDocksActive", QString() ).toStringList();

QList<QDockWidget*> docks = findChildren<QDockWidget*>();
QList<QTabBar *> tabBars = findChildren<QTabBar *>();

if ( docksTitle.isEmpty() )
{

Q_FOREACH ( QDockWidget* dock, docks )
{
if ( dock->isVisible() && !dock->isFloating() )
{
docksTitle << dock->windowTitle();
dock->setVisible( false );
}
}

Q_FOREACH ( QTabBar* tabBar, tabBars )
{
docksActive << tabBar->tabText( tabBar->currentIndex() );
}

settings.setValue( QStringLiteral( "/UI/hiddenDocksTitle" ), docksTitle );
settings.setValue( QStringLiteral( "/UI/hiddenDocksActive" ), docksActive );
}
else
{
Q_FOREACH ( QDockWidget* dock, docks )
{
if ( docksTitle.contains( dock->windowTitle() ) )
{
dock->setVisible( true );
}
}

Q_FOREACH ( QTabBar* tabBar, tabBars )
{
for ( int i = 0; i < tabBar->count(); ++i )
{
if ( docksActive.contains( tabBar->tabText( i ) ) )
{
tabBar->setCurrentIndex( i );
}
}
}

settings.setValue( QStringLiteral( "/UI/hiddenDocksTitle" ), QStringList() );
settings.setValue( QStringLiteral( "/UI/hiddenDocksActive" ), QStringList() );
}
}

void QgisApp::showActiveWindowMinimized()
{
QWidget *window = QApplication::activeWindow();
@@ -418,6 +418,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionShowPythonDialog() { return mActionShowPythonDialog; }

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

//! Toggle visibility of opened panels
void togglePanelsVisibility();

//! Set minimized mode of active window
void showActiveWindowMinimized();

@@ -1038,13 +1038,13 @@
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Hide Panels</string>
<string>Toggle Panel &amp;Visibility</string>
</property>
<property name="toolTip">
<string>Hide panels</string>
</property>
<property name="shortcut">
<string>F10</string>
<string>Ctrl+Tab</string>
</property>
</action>
<action name="mActionShowPage">
@@ -1548,12 +1548,20 @@
</action>
<action name="mActionToggleFullScreen">
<property name="text">
<string>Toggle Full Screen Mode</string>
<string>Toggle Full Scr&amp;een Mode</string>
</property>
<property name="shortcut">
<string>F11</string>
</property>
</action>
<action name="mActionTogglePanelsVisibility">
<property name="text">
<string>Toggle Panel &amp;Visibility</string>
</property>
<property name="shortcut">
<string>Ctrl+Tab</string>
</property>
</action>
<action name="mActionProjectProperties">
<property name="icon">
<iconset resource="../../images/images.qrc">

0 comments on commit 3982498

Please sign in to comment.
You can’t perform that action at this time.