Skip to content

Commit 207a947

Browse files
committed
[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.
1 parent a9d61ff commit 207a947

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

python/plugins/processing/gui/ResultsDock.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import time
3030

3131
from qgis.PyQt import uic
32-
from qgis.PyQt.QtCore import QUrl
32+
from qgis.PyQt.QtCore import (QUrl,
33+
QFileInfo,
34+
QDir)
3335
from qgis.PyQt.QtGui import QDesktopServices
3436
from qgis.PyQt.QtWidgets import QTreeWidgetItem
3537

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

54+
self.txtDescription.setOpenLinks(False)
55+
self.txtDescription.anchorClicked.connect(self.openLink)
56+
5257
self.fillTree()
5358

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

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

73+
def openLink(self, url):
74+
QDesktopServices.openUrl(url)
75+
6876
def openResult(self, item, column):
6977
QDesktopServices.openUrl(QUrl.fromLocalFile(item.filename))
7078

python/plugins/processing/ui/resultsdockbase.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</property>
4646
</column>
4747
</widget>
48-
<widget class="QTextEdit" name="txtDescription"/>
48+
<widget class="QTextBrowser" name="txtDescription"/>
4949
</widget>
5050
</item>
5151
</layout>

0 commit comments

Comments
 (0)