mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #8054 (Hyperlinks in book descriptions don't work)
This commit is contained in:
parent
bebc782180
commit
85bf7da1fb
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, collections, sys
|
import os, collections, sys
|
||||||
from Queue import Queue
|
from Queue import Queue
|
||||||
|
|
||||||
from PyQt4.Qt import QPixmap, QSize, QWidget, Qt, pyqtSignal, \
|
from PyQt4.Qt import QPixmap, QSize, QWidget, Qt, pyqtSignal, QUrl, \
|
||||||
QPropertyAnimation, QEasingCurve, QThread, QApplication, QFontInfo, \
|
QPropertyAnimation, QEasingCurve, QThread, QApplication, QFontInfo, \
|
||||||
QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette
|
QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette
|
||||||
from PyQt4.QtWebKit import QWebView
|
from PyQt4.QtWebKit import QWebView
|
||||||
@ -18,7 +18,7 @@ from calibre.gui2.widgets import IMAGE_EXTENSIONS
|
|||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.constants import preferred_encoding
|
from calibre.constants import preferred_encoding
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre.gui2 import config, open_local_file
|
from calibre.gui2 import config, open_local_file, open_url
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
# render_rows(data) {{{
|
# render_rows(data) {{{
|
||||||
@ -412,6 +412,12 @@ class BookDetails(QWidget): # {{{
|
|||||||
self.view_specific_format.emit(int(id_), fmt)
|
self.view_specific_format.emit(int(id_), fmt)
|
||||||
elif typ == 'devpath':
|
elif typ == 'devpath':
|
||||||
open_local_file(val)
|
open_local_file(val)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
open_url(QUrl(link, QUrl.TolerantMode))
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
def mouseDoubleClickEvent(self, ev):
|
def mouseDoubleClickEvent(self, ev):
|
||||||
|
@ -9,7 +9,7 @@ from PyQt4.Qt import QCoreApplication, SIGNAL, QModelIndex, QTimer, Qt, \
|
|||||||
QDialog, QPixmap, QGraphicsScene, QIcon, QSize
|
QDialog, QPixmap, QGraphicsScene, QIcon, QSize
|
||||||
|
|
||||||
from calibre.gui2.dialogs.book_info_ui import Ui_BookInfo
|
from calibre.gui2.dialogs.book_info_ui import Ui_BookInfo
|
||||||
from calibre.gui2 import dynamic, open_local_file
|
from calibre.gui2 import dynamic, open_local_file, open_url
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
@ -22,6 +22,8 @@ class BookInfo(QDialog, Ui_BookInfo):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.cover_pixmap = None
|
self.cover_pixmap = None
|
||||||
self.comments.sizeHint = self.comments_size_hint
|
self.comments.sizeHint = self.comments_size_hint
|
||||||
|
self.comments.page().setLinkDelegationPolicy(self.comments.page().DelegateAllLinks)
|
||||||
|
self.comments.linkClicked(self.link_clicked)
|
||||||
self.view_func = view_func
|
self.view_func = view_func
|
||||||
|
|
||||||
|
|
||||||
@ -41,6 +43,8 @@ class BookInfo(QDialog, Ui_BookInfo):
|
|||||||
screen_height = desktop.availableGeometry().height() - 100
|
screen_height = desktop.availableGeometry().height() - 100
|
||||||
self.resize(self.size().width(), screen_height)
|
self.resize(self.size().width(), screen_height)
|
||||||
|
|
||||||
|
def link_clicked(self, url):
|
||||||
|
open_url(url)
|
||||||
|
|
||||||
def comments_size_hint(self):
|
def comments_size_hint(self):
|
||||||
return QSize(350, 250)
|
return QSize(350, 250)
|
||||||
@ -115,6 +119,7 @@ class BookInfo(QDialog, Ui_BookInfo):
|
|||||||
lines = [x if x.strip() else '<br><br>' for x in lines]
|
lines = [x if x.strip() else '<br><br>' for x in lines]
|
||||||
comments = '\n'.join(lines)
|
comments = '\n'.join(lines)
|
||||||
self.comments.setHtml('<div>%s</div>' % comments)
|
self.comments.setHtml('<div>%s</div>' % comments)
|
||||||
|
self.comments.page().setLinkDelegationPolicy(self.comments.page().DelegateAllLinks)
|
||||||
cdata = info.pop('cover', '')
|
cdata = info.pop('cover', '')
|
||||||
self.cover_pixmap = QPixmap.fromImage(cdata)
|
self.cover_pixmap = QPixmap.fromImage(cdata)
|
||||||
self.resize_cover()
|
self.resize_cover()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user