Closed enricofer closed 7 years ago
Thanks for this. I'd call the template "A4 Vertical", and perhaps also add an "A4 Horizontal". To make it clear that these are default templates, one could also add section separators "Default template" and "Project templates" to the combobox, where section separators would be disabled items, such as in [1]. What do you think?
[1] http://stackoverflow.com/questions/11439773/disable-item-in-qt-combobox
Instead PR, I was trying to add these lines, leaving the opportunity to define template formats as options, but they crashes Qgis (!?):
formats = {
"Default_A4_v":[210.0,297.0],
"Default_A4_h":[297.0,210.0]
}
for format,size in formats.iteritems():
composition = QgsComposition(self.iface.mapCanvas().mapRenderer())
composition.setPlotStyle(QgsComposition.Print)
x, y, w, h = 0, 0, size[0], size[1]
composition.setPaperSize(w, h)
composerMap = QgsComposerMap(composition, x ,y, w, h)
composerMap.setNewScale(composerMap.scale()/2)
composition.addItem(composerMap)_
composerView = QgsComposerView()
composerView.setComposition(composition)
self.dialogui.comboBox_composers.addItem(format, composerView)
Could you try to confirm the behaviour?
Please make a commit with this and I'll give it a look.
The PR populates plugin composer combobox with a default A4 vertical template to allow fast printing without defining a user composer. Regards. Enrico.