-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from DavidCEllis/fix_links
Allow links to work and make them launch in an external browser.
- Loading branch information
Showing
5 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .webenginepage import ExtLinkWebEnginePage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Replace the standard QWebEnginePage with one that launches links in the user's default browser | ||
""" | ||
from PySide2.QtWebEngineWidgets import QWebEnginePage | ||
from PySide2.QtGui import QDesktopServices | ||
|
||
|
||
class ExtLinkWebEnginePage(QWebEnginePage): | ||
""" | ||
QWebEnginePage that launches links in an external browser | ||
""" | ||
|
||
def acceptNavigationRequest(self, url, _type, is_mainframe): | ||
# Launch external browser for clicking links, otherwise do default behaviour | ||
if _type == QWebEnginePage.NavigationTypeLinkClicked: | ||
QDesktopServices.openUrl(url) | ||
return False | ||
return super().acceptNavigationRequest(url, _type, is_mainframe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters