From 64cd0499ba2ccc09f0799db4cf41930ad589960d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 12 Feb 2010 15:16:20 +0900 Subject: [PATCH] make sure to open a browser when link clicked in preview --- ankiqt/ui/facteditor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index c77b6c900..19086f8a3 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -1089,6 +1089,9 @@ class PreviewDialog(QDialog): self.dialog.setupUi(self) self.dialog.webView.page().setLinkDelegationPolicy( QWebPage.DelegateExternalLinks) + self.connect(self.dialog.webView, + SIGNAL("linkClicked(QUrl)"), + self.linkClicked) self.dialog.comboBox.addItems(QStringList( [c.cardModel.name for c in self.cards])) self.connect(self.dialog.comboBox, SIGNAL("activated(int)"), @@ -1097,6 +1100,9 @@ class PreviewDialog(QDialog): restoreGeom(self, "preview") self.exec_() + def linkClicked(self, url): + QDesktopServices.openUrl(QUrl(url)) + def updateCard(self): c = self.cards[self.currentCard] styles = (self.deck.css +