Skip to content

Commit

Permalink
Issue 616 zoom full (#15)
Browse files Browse the repository at this point in the history
* Adding zooming to full extent after opening layout template.

* Metadata update.

* Fixed imports.

* Fixed imports.

* Added resize page layout action after loading a template.
  • Loading branch information
ldebek authored Sep 24, 2019
1 parent d522d41 commit e7a48f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 4 additions & 2 deletions QGIS Plugin/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 protected]
about=Tools for simplifying and automating common tasks for national parks and other protected areas.
Expand All @@ -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
<p>1.3.1 - Bug fixes:
- Fixed issue #616
<p>1.3 Migration to QGIS 3:
- Ported to QGIS 3
Expand Down
21 changes: 19 additions & 2 deletions QGIS Plugin/templateselectordialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit e7a48f2

Please sign in to comment.