Skip to content

Commit

Permalink
Added option for setting custom dpi values for printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebek committed Jul 4, 2017
1 parent b383ccd commit 81b29ec
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 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 Selector
qgisMinimumVersion=2.0
qgisMaximumVersion=2.99
description=Tool for selecting pre-defined QGIS projects.
version=1.1.3
version=1.1.4
author=Dartmoor National Park Authority
[email protected]
about=Tools for simplifying and automating common tasks for national parks and other protected areas. Catchy name courtesy of Dartmoor National Park, UK.
Expand All @@ -24,7 +24,9 @@ about=Tools for simplifying and automating common tasks for national parks and o

# Uncomment the following line and add your changelog entries:

changelog=1.1.3 - New features:
<p>changelog=1.1.4 - New features:
- Added option for setting custom dpi values for printing
<p>changelog=1.1.3 - New features:
- added defaults.txt with predefined paths to projects and templates
<p>1.1.2 - Bug fixes:
- Fixed plugin crashing when choosing current map canvas scale
Expand Down
2 changes: 1 addition & 1 deletion QGIS Plugin/projectselectordialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* *
***************************************************************************/
"""
import collections
import os

from PyQt4 import QtCore, QtGui
from ui_projectselector import Ui_ProjectSelector
# create the dialog for zoom to point


class ProjectSelectorException(Exception):
pass

Expand Down
2 changes: 1 addition & 1 deletion QGIS Plugin/settingsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
***************************************************************************/
"""

from PyQt4 import QtCore, QtGui, QtXml
from PyQt4 import QtCore, QtGui
from ui_settings import Ui_Dialog
# create the dialog for zoom to point

Expand Down
26 changes: 22 additions & 4 deletions QGIS Plugin/templateselectordialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,20 @@ def __init__(self, iface):
self.plugin_dir = os.path.dirname(__file__)

# Replacement map
self.ui.suitableForComboBox.addItem('<custom>')
self.replaceMap = {'username': os.environ['username']}
self.ui.autofit_btn.clicked.connect(self.autofit_map)
self.ui.suitableForComboBox.currentIndexChanged.connect(self.specify_dpi)
self.ui.suitableForComboBox.editTextChanged.connect(self.text_changed)

def specify_dpi(self, idx):
if idx == 2:
self.ui.suitableForComboBox.setEditable(True)
else:
self.ui.suitableForComboBox.setEditable(False)

def text_changed(self, txt):
self.ui.suitableForComboBox.setItemText(self.ui.suitableForComboBox.currentIndex(), txt)

def autofit_map(self):
canvas = self.iface.mapCanvas()
Expand Down Expand Up @@ -394,13 +406,19 @@ def openTemplate(self):
compMap.updateCachedImage()

# Set scale
resText = self.ui.suitableForComboBox.currentText()
dpi = 0
if resText.startswith('Paper'):
cur_idx = self.ui.suitableForComboBox.currentIndex()
if cur_idx == 0:
# Paper
dpi = 300
else:
elif cur_idx == 1:
# Electronic
dpi = 96
else:
res_text = self.ui.suitableForComboBox.currentText()
try:
dpi = int(res_text)
except TypeError:
dpi = 96
composerView.composition().setPrintResolution(dpi)

# All done
Expand Down

0 comments on commit 81b29ec

Please sign in to comment.