Skip to content
Permalink
Browse files

[FEATURE] Ctrl-shift-tab to toggle full map view (#6580)

  • Loading branch information
rduivenvoorde authored and nirvn committed Apr 4, 2018
1 parent 846ca49 commit 282a999ba824c7dbc1497f6bac52530e1e618be1
Showing with 79 additions and 10 deletions.
  1. +64 −10 src/app/qgisapp.cpp
  2. +7 −0 src/app/qgisapp.h
  3. +8 −0 src/ui/qgisapp.ui
@@ -683,6 +683,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
profiler->beginGroup( QStringLiteral( "startup" ) );
startProfile( QStringLiteral( "Setting up UI" ) );
setupUi( this );
// because mActionToggleMapOnly can hide the menu (thereby disabling menu actions),
// we attach the following actions to the MainWindow too (to be able to come back)
this->addAction( mActionToggleFullScreen );
this->addAction( mActionTogglePanelsVisibility );
this->addAction( mActionToggleMapOnly );
endProfile();

#if QT_VERSION >= 0x050600
@@ -2061,6 +2066,7 @@ void QgisApp::createActions()

connect( mActionToggleFullScreen, &QAction::triggered, this, &QgisApp::toggleFullScreen );
connect( mActionTogglePanelsVisibility, &QAction::triggered, this, &QgisApp::togglePanelsVisibility );
connect( mActionToggleMapOnly, &QAction::triggered, this, &QgisApp::toggleMapOnly );
connect( mActionProjectProperties, &QAction::triggered, this, &QgisApp::projectProperties );
connect( mActionOptions, &QAction::triggered, this, &QgisApp::options );
connect( mActionCustomProjection, &QAction::triggered, this, &QgisApp::customProjection );
@@ -2319,6 +2325,7 @@ void QgisApp::createMenus()
mViewMenu->addMenu( mToolbarMenu );
mViewMenu->addAction( mActionToggleFullScreen );
mViewMenu->addAction( mActionTogglePanelsVisibility );
mViewMenu->addAction( mActionToggleMapOnly );
}
else
{
@@ -2328,6 +2335,7 @@ void QgisApp::createMenus()
mSettingsMenu->insertMenu( before, mToolbarMenu );
mSettingsMenu->insertAction( before, mActionToggleFullScreen );
mSettingsMenu->insertAction( before, mActionTogglePanelsVisibility );
mSettingsMenu->insertAction( before, mActionToggleMapOnly );
mSettingsMenu->insertSeparator( before );
}

@@ -6235,46 +6243,83 @@ void QgisApp::toggleFullScreen()
}

void QgisApp::togglePanelsVisibility()
{
toggleReducedView( false );
}

void QgisApp::toggleMapOnly()
{
toggleReducedView( true );
}

void QgisApp::toggleReducedView( bool viewMapOnly )
{
QgsSettings settings;

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

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

if ( docksTitle.isEmpty() )
bool allWidgetsVisible = settings.value( QStringLiteral( "UI/allWidgetsVisible" ), true ).toBool();

if ( allWidgetsVisible ) // that is: currently nothing is hidden
{

Q_FOREACH ( QDockWidget *dock, docks )
if ( viewMapOnly ) //
{
// hide also statusbar and menubar and all toolbars
for ( QToolBar *toolBar : toolBars )
{
if ( toolBar->isVisible() && !toolBar->isFloating() )
{
// remember the active toolbars
toolBarsActive << toolBar->windowTitle();
toolBar->setVisible( false );
}
}

this->menuBar()->setVisible( false );
this->statusBar()->setVisible( false );

settings.setValue( QStringLiteral( "UI/hiddenToolBarsActive" ), toolBarsActive );
}

for ( QDockWidget *dock : docks )
{
if ( dock->isVisible() && !dock->isFloating() )
{
// remember the active docs
docksTitle << dock->windowTitle();
dock->setVisible( false );
}
}

Q_FOREACH ( QTabBar *tabBar, tabBars )
for ( QTabBar *tabBar : tabBars )
{
// remember the active tab from the docks
docksActive << tabBar->tabText( tabBar->currentIndex() );
}

settings.setValue( QStringLiteral( "UI/hiddenDocksTitle" ), docksTitle );
settings.setValue( QStringLiteral( "UI/hiddenDocksActive" ), docksActive );

settings.setValue( QStringLiteral( "UI/allWidgetsVisible" ), false );
}
else
else // currently panels or other widgets are hidden: show ALL based on 'remembered UI settings'
{
Q_FOREACH ( QDockWidget *dock, docks )
for ( QDockWidget *dock : docks )
{
if ( docksTitle.contains( dock->windowTitle() ) )
{
dock->setVisible( true );
}
}

Q_FOREACH ( QTabBar *tabBar, tabBars )
for ( QTabBar *tabBar : tabBars )
{
for ( int i = 0; i < tabBar->count(); ++i )
{
@@ -6285,8 +6330,17 @@ void QgisApp::togglePanelsVisibility()
}
}

settings.setValue( QStringLiteral( "UI/hiddenDocksTitle" ), QStringList() );
settings.setValue( QStringLiteral( "UI/hiddenDocksActive" ), QStringList() );
for ( QToolBar *toolBar : toolBars )
{
if ( toolBarsActive.contains( toolBar->windowTitle() ) )
{
toolBar->setVisible( true );
}
}
this->menuBar()->setVisible( true );
this->statusBar()->setVisible( true );

settings.setValue( QStringLiteral( "UI/allWidgetsVisible" ), true );
}
}

@@ -527,6 +527,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QAction *actionToggleFullScreen() { return mActionToggleFullScreen; }
QAction *actionTogglePanelsVisibility() { return mActionTogglePanelsVisibility; }
QAction *actionToggleMapOnly() { return mActionToggleMapOnly; }
QAction *actionOptions() { return mActionOptions; }
QAction *actionCustomProjection() { return mActionCustomProjection; }
QAction *actionConfigureShortcuts() { return mActionConfigureShortcuts; }
@@ -1533,6 +1534,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Toggle visibility of opened panels
void togglePanelsVisibility();

//! Toggle visibility of main map only
void toggleMapOnly();

//! Toggle between full QGIS view and reduced view (being either Map only or only hiding panels)
void toggleReducedView( bool viewMapOnly );

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

@@ -1651,6 +1651,14 @@
<string>Ctrl+Tab</string>
</property>
</action>
<action name="mActionToggleMapOnly">
<property name="text">
<string>Toggle Map Only</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Tab</string>
</property>
</action>
<action name="mActionProjectProperties">
<property name="icon">
<iconset resource="../../images/images.qrc">

0 comments on commit 282a999

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