sourcepole / qgis-instantprint-plugin

QGIS Instant Print Plugin
GNU General Public License v2.0
10 stars 10 forks source link

Default template feature #5

Closed enricofer closed 7 years ago

enricofer commented 8 years ago

The PR populates plugin composer combobox with a default A4 vertical template to allow fast printing without defining a user composer. Regards. Enrico.

manisandro commented 8 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

enricofer commented 8 years ago

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?

manisandro commented 8 years ago

Please make a commit with this and I'll give it a look.