Skip to content
Permalink
Browse files

[processing] offer hyperlink to file path in the results viewer

because users don't always get that there is a dbl-click action
against the tree view items.
  • Loading branch information
nirvn committed Feb 12, 2018
1 parent a9d61ff commit 207a94738d94c2653a9e088752170cd1dbd9a37f
Showing with 11 additions and 3 deletions.
  1. +10 −2 python/plugins/processing/gui/ResultsDock.py
  2. +1 −1 python/plugins/processing/ui/resultsdockbase.ui
@@ -29,7 +29,9 @@
import time

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtCore import (QUrl,
QFileInfo,
QDir)
from qgis.PyQt.QtGui import QDesktopServices
from qgis.PyQt.QtWidgets import QTreeWidgetItem

@@ -49,6 +51,9 @@ def __init__(self):
self.treeResults.currentItemChanged.connect(self.updateDescription)
self.treeResults.itemDoubleClicked.connect(self.openResult)

self.txtDescription.setOpenLinks(False)
self.txtDescription.anchorClicked.connect(self.openLink)

self.fillTree()

def fillTree(self):
@@ -62,9 +67,12 @@ def fillTree(self):

def updateDescription(self, current, previous):
if isinstance(current, TreeResultItem):
html = '<b>Algorithm</b>: {}<br><b>File path</b>: {}'.format(current.algorithm, current.filename)
html = '<b>Algorithm</b>: {}<br><b>File path</b>: <a href="{}">{}</a>'.format(current.algorithm, QUrl.fromLocalFile(current.filename).toString(), QDir.toNativeSeparators(current.filename))
self.txtDescription.setHtml(html)

def openLink(self, url):
QDesktopServices.openUrl(url)

def openResult(self, item, column):
QDesktopServices.openUrl(QUrl.fromLocalFile(item.filename))

@@ -45,7 +45,7 @@
</property>
</column>
</widget>
<widget class="QTextEdit" name="txtDescription"/>
<widget class="QTextBrowser" name="txtDescription"/>
</widget>
</item>
</layout>

0 comments on commit 207a947

Please sign in to comment.
You can’t perform that action at this time.