Skip to content

Commit

Permalink
[processing] offer hyperlink to file path in the results viewer
Browse files Browse the repository at this point in the history
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 207a947
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions python/plugins/processing/gui/ResultsDock.py
Expand Up @@ -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

Expand All @@ -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):
Expand All @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/ui/resultsdockbase.ui
Expand Up @@ -45,7 +45,7 @@
</property>
</column>
</widget>
<widget class="QTextEdit" name="txtDescription"/>
<widget class="QTextBrowser" name="txtDescription"/>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 207a947

Please sign in to comment.