From e7a48f268c5a91d4a8311afee0f161145ed8e5c6 Mon Sep 17 00:00:00 2001 From: DamnBack Date: Tue, 24 Sep 2019 10:12:57 +0200 Subject: [PATCH] Issue 616 zoom full (#15) * Adding zooming to full extent after opening layout template. * Metadata update. * Fixed imports. * Fixed imports. * Added resize page layout action after loading a template. --- QGIS Plugin/metadata.txt | 6 ++++-- QGIS Plugin/templateselectordialog.py | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/QGIS Plugin/metadata.txt b/QGIS Plugin/metadata.txt index 3b75404..8a2acd6 100644 --- a/QGIS Plugin/metadata.txt +++ b/QGIS Plugin/metadata.txt @@ -13,7 +13,7 @@ name=Project and Template Selector qgisMinimumVersion=3.4 qgisMaximumVersion=3.99 description=Tool for selecting pre-defined QGIS projects. -version=1.3.1 +version=1.3.2 author=Dartmoor National Park Authority email=gi@dartmoor.gov.uk about=Tools for simplifying and automating common tasks for national parks and other protected areas. @@ -23,7 +23,9 @@ about=Tools for simplifying and automating common tasks for national parks and o # Optional items: # Uncomment the following line and add your changelog entries: -changelog=1.3.1 - Bug fixes: +changelog=1.3.2 - Bug fixes: + - Added zooming to full extent after opening print layout +

1.3.1 - Bug fixes: - Fixed issue #616

1.3 Migration to QGIS 3: - Ported to QGIS 3 diff --git a/QGIS Plugin/templateselectordialog.py b/QGIS Plugin/templateselectordialog.py index 14c3b08..d7ff0fb 100644 --- a/QGIS Plugin/templateselectordialog.py +++ b/QGIS Plugin/templateselectordialog.py @@ -24,8 +24,18 @@ import traceback import locale from qgis.PyQt import QtGui, uic -from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QSpacerItem, QComboBox, QLabel, QSizePolicy, QMessageBox from qgis.PyQt.QtXml import QDomDocument +from qgis.PyQt.QtWidgets import ( + QAction, + QDialog, + QDialogButtonBox, + QSpacerItem, + QComboBox, + QLabel, + QPushButton, + QSizePolicy, + QMessageBox +) from qgis.core import ( QgsPrintLayout, QgsMapLayer, @@ -386,11 +396,18 @@ def openTemplate(self): except (TypeError, ValueError): dpi = 96 print_layout.renderContext().setDpi(dpi) - layout_designer_interface = self.iface.openLayoutDesigner(print_layout) + + # Maximize layout window ldi_window = layout_designer_interface.window() ldi_window.showMaximized() + # Resizing page and zoom in + ldi_parent = layout_designer_interface.parent() + resize_button = ldi_parent.findChild(QPushButton, 'mResizePageButton') + resize_button.click() + zoom_action = ldi_parent.findChild(QAction, 'mActionZoomAll') + zoom_action.trigger() # All done self.accept()