29
29
import time
30
30
31
31
from qgis .PyQt import uic
32
- from qgis .PyQt .QtCore import QUrl
32
+ from qgis .PyQt .QtCore import (QUrl ,
33
+ QFileInfo ,
34
+ QDir )
33
35
from qgis .PyQt .QtGui import QDesktopServices
34
36
from qgis .PyQt .QtWidgets import QTreeWidgetItem
35
37
@@ -49,6 +51,9 @@ def __init__(self):
49
51
self .treeResults .currentItemChanged .connect (self .updateDescription )
50
52
self .treeResults .itemDoubleClicked .connect (self .openResult )
51
53
54
+ self .txtDescription .setOpenLinks (False )
55
+ self .txtDescription .anchorClicked .connect (self .openLink )
56
+
52
57
self .fillTree ()
53
58
54
59
def fillTree (self ):
@@ -62,9 +67,12 @@ def fillTree(self):
62
67
63
68
def updateDescription (self , current , previous ):
64
69
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 ) )
66
71
self .txtDescription .setHtml (html )
67
72
73
+ def openLink (self , url ):
74
+ QDesktopServices .openUrl (url )
75
+
68
76
def openResult (self , item , column ):
69
77
QDesktopServices .openUrl (QUrl .fromLocalFile (item .filename ))
70
78
0 commit comments