Skip to content

Commit

Permalink
[processing] add msg bar links to files when saving/exporting models
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Sep 11, 2018
1 parent ac3b37f commit 68b7e79
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -35,6 +35,7 @@
from qgis.PyQt.QtCore import (
Qt,
QCoreApplication,
QDir,
QRectF,
QMimeData,
QPoint,
Expand All @@ -44,7 +45,8 @@
QSizeF,
pyqtSignal,
QDataStream,
QIODevice)
QIODevice,
QUrl)
from qgis.PyQt.QtWidgets import (QGraphicsView,
QTreeWidget,
QMessageBox,
Expand Down Expand Up @@ -570,7 +572,7 @@ def exportAsImage(self):

img.save(filename)

self.bar.pushMessage("", self.tr("Model was correctly exported as image"), level=Qgis.Success, duration=5)
self.bar.pushMessage("", self.tr("Successfully exported model as image to <a href=\"{}\">{}</a>").format(QUrl.fromLocalFile(filename).toString(), QDir.toNativeSeparators(filename)), level=Qgis.Success, duration=5)
self.repaintModel(controls=True)

def exportAsPdf(self):
Expand Down Expand Up @@ -598,7 +600,7 @@ def exportAsPdf(self):
self.scene.render(painter, printerRect, totalRect)
painter.end()

self.bar.pushMessage("", self.tr("Model was correctly exported as PDF"), level=Qgis.Success, duration=5)
self.bar.pushMessage("", self.tr("Successfully exported model as PDF to <a href=\"{}\">{}</a>").format(QUrl.fromLocalFile(filename).toString(), QDir.toNativeSeparators(filename)), level=Qgis.Success, duration=5)
self.repaintModel(controls=True)

def exportAsSvg(self):
Expand Down Expand Up @@ -626,7 +628,7 @@ def exportAsSvg(self):
self.scene.render(painter, svgRect, totalRect)
painter.end()

self.bar.pushMessage("", self.tr("Model was correctly exported as SVG"), level=Qgis.Success, duration=5)
self.bar.pushMessage("", self.tr("Successfully exported model as SVG to <a href=\"{}\">{}</a>").format(QUrl.fromLocalFile(filename).toString(), QDir.toNativeSeparators(filename)), level=Qgis.Success, duration=5)
self.repaintModel(controls=True)

def exportAsPython(self):
Expand All @@ -643,7 +645,7 @@ def exportAsPython(self):
with codecs.open(filename, 'w', encoding='utf-8') as fout:
fout.write(text)

self.bar.pushMessage("", self.tr("Model was correctly exported as python script"), level=Qgis.Success, duration=5)
self.bar.pushMessage("", self.tr("Successfully exported model as python script to <a href=\"{}\">{}</a>").format(QUrl.fromLocalFile(filename).toString(), QDir.toNativeSeparators(filename)), level=Qgis.Success, duration=5)

def can_save(self):
"""
Expand Down Expand Up @@ -686,7 +688,10 @@ def saveModel(self, saveAs):
)
return
self.update_model.emit()
self.bar.pushMessage("", self.tr("Model was correctly saved"), level=Qgis.Success, duration=5)
if saveAs:
self.bar.pushMessage("", self.tr("Model was correctly saved to <a href=\"{}\">{}</a>").format(QUrl.fromLocalFile(filename).toString(), QDir.toNativeSeparators(filename)), level=Qgis.Success, duration=5)
else:
self.bar.pushMessage("", self.tr("Model was correctly saved"), level=Qgis.Success, duration=5)

self.hasChanged = False

Expand Down

0 comments on commit 68b7e79

Please sign in to comment.