mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make notes display a bit nicer
This commit is contained in:
parent
8dd3f055e2
commit
cac8628fa0
@ -8,8 +8,8 @@ from itertools import chain
|
|||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QFont, QHBoxLayout, QIcon, QItemSelectionModel, QKeySequence, QLabel,
|
QFont, QHBoxLayout, QIcon, QItemSelectionModel, QKeySequence, QLabel,
|
||||||
QPushButton, Qt, QTextEdit, QToolButton, QTreeWidget, QTreeWidgetItem,
|
QPushButton, Qt, QTextEdit, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,
|
||||||
QVBoxLayout, QWidget, pyqtSignal
|
pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import plugins
|
from calibre.constants import plugins
|
||||||
@ -229,22 +229,18 @@ class NotesDisplay(QWidget):
|
|||||||
h = QHBoxLayout(self)
|
h = QHBoxLayout(self)
|
||||||
h.setContentsMargins(0, 0, 0, 0)
|
h.setContentsMargins(0, 0, 0, 0)
|
||||||
self.browser = nd = Details(self)
|
self.browser = nd = Details(self)
|
||||||
|
self.browser.anchorClicked.connect(self.edit_notes)
|
||||||
h.addWidget(nd)
|
h.addWidget(nd)
|
||||||
self.current_notes = ''
|
self.current_notes = ''
|
||||||
self.edit_button = eb = QToolButton(self)
|
|
||||||
eb.setIcon(QIcon(I('modified.png')))
|
|
||||||
eb.setToolTip(_('Edit the notes for this highlight'))
|
|
||||||
h.addWidget(eb)
|
|
||||||
eb.clicked.connect(self.edit_notes)
|
|
||||||
|
|
||||||
def show_notes(self, text=''):
|
def show_notes(self, text=''):
|
||||||
text = (text or '').strip()
|
text = (text or '').strip()
|
||||||
self.setVisible(bool(text))
|
self.setVisible(bool(text))
|
||||||
self.current_notes = text
|
self.current_notes = text
|
||||||
self.browser.setHtml('\n'.join(render_notes(text)))
|
html = '\n'.join(render_notes(text))
|
||||||
|
self.browser.setHtml('<div><a href="edit://moo" style="text-decoration: none">{}</a></div>{}'.format(_('Edit notes'), html))
|
||||||
h = self.browser.document().size().height() + 8
|
h = self.browser.document().size().height() + 8
|
||||||
self.browser.setMaximumHeight(h)
|
self.browser.setMaximumHeight(h)
|
||||||
self.setMaximumHeight(max(self.edit_button.sizeHint().height() + 4, h))
|
|
||||||
|
|
||||||
def edit_notes(self):
|
def edit_notes(self):
|
||||||
current_text = self.current_notes
|
current_text = self.current_notes
|
||||||
@ -282,7 +278,6 @@ class HighlightsPanel(QWidget):
|
|||||||
self.refresh = h.refresh
|
self.refresh = h.refresh
|
||||||
|
|
||||||
self.h = h = QHBoxLayout()
|
self.h = h = QHBoxLayout()
|
||||||
l.addLayout(h)
|
|
||||||
|
|
||||||
def button(icon, text, tt, target):
|
def button(icon, text, tt, target):
|
||||||
b = QPushButton(QIcon(I(icon)), text, self)
|
b = QPushButton(QIcon(I(icon)), text, self)
|
||||||
@ -300,6 +295,7 @@ class HighlightsPanel(QWidget):
|
|||||||
nd.notes_edited.connect(self.notes_edited)
|
nd.notes_edited.connect(self.notes_edited)
|
||||||
l.addWidget(nd)
|
l.addWidget(nd)
|
||||||
nd.setVisible(False)
|
nd.setVisible(False)
|
||||||
|
l.addLayout(h)
|
||||||
|
|
||||||
def notes_edited(self, text):
|
def notes_edited(self, text):
|
||||||
h = self.highlights.current_highlight
|
h = self.highlights.current_highlight
|
||||||
|
Loading…
x
Reference in New Issue
Block a user