Skip to content
Permalink
Browse files

When theme is removed, canvas falls back to default view

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 2cba528 commit a271199b0cceb5b1c9cfa8e7534011ca33452190
Showing with 17 additions and 0 deletions.
  1. +14 −0 src/gui/qgsmapcanvas.cpp
  2. +2 −0 src/gui/qgsmapcanvas.h
  3. +1 −0 tests/src/python/test_qgsmapthemecollection.py
@@ -142,6 +142,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent )
this, &QgsMapCanvas::writeProject );

connect( QgsProject::instance()->mapThemeCollection(), &QgsMapThemeCollection::mapThemeChanged, this, &QgsMapCanvas::mapThemeChanged );
connect( QgsProject::instance()->mapThemeCollection(), &QgsMapThemeCollection::mapThemesChanged, this, &QgsMapCanvas::projectThemesChanged );

mSettings.setFlag( QgsMapSettings::DrawEditingInfo );
mSettings.setFlag( QgsMapSettings::UseRenderingOptimization );
@@ -1735,6 +1736,19 @@ void QgsMapCanvas::updateAutoRefreshTimer()
}
}

void QgsMapCanvas::projectThemesChanged()
{
if ( mTheme.isEmpty() )
return;

if ( !QgsProject::instance()->mapThemeCollection()->hasMapTheme( mTheme ) )
{
// theme has been removed - stop following
setTheme( QString() );
}

}

QgsMapTool *QgsMapCanvas::mapTool()
{
return mMapTool;
@@ -688,6 +688,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

void updateAutoRefreshTimer();

void projectThemesChanged();

private:
/// this class is non-copyable

@@ -210,5 +210,6 @@ def testMasterVisibleLayers(self):
layer_node.setItemVisibilityChecked(True)
self.assertEqual(prj.mapThemeCollection().masterVisibleLayers(), [layer, layer2, layer3])


if __name__ == '__main__':
unittest.main()

0 comments on commit a271199

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