mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Bulk metadata download: When reviewing downloaded metadata allow hiding the controls on the comments box by right clicking in the comments area. Useful on smaller screens. Fixes #1283251 [review downloaded metadata fix/enhancement](https://bugs.launchpad.net/calibre/+bug/1283251)
This commit is contained in:
parent
ec2952aeb1
commit
8d746b8044
@ -5,7 +5,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re, os, json
|
import re, os, json, weakref
|
||||||
|
|
||||||
from lxml import html
|
from lxml import html
|
||||||
import sip
|
import sip
|
||||||
@ -69,6 +69,7 @@ class EditorWidget(QWebView): # {{{
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QWebView.__init__(self, parent)
|
QWebView.__init__(self, parent)
|
||||||
|
self._parent = weakref.ref(parent)
|
||||||
self.readonly = False
|
self.readonly = False
|
||||||
|
|
||||||
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
|
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
|
||||||
@ -407,6 +408,11 @@ class EditorWidget(QWebView): # {{{
|
|||||||
for action in menu.actions():
|
for action in menu.actions():
|
||||||
if action == paste:
|
if action == paste:
|
||||||
menu.insertAction(action, self.pageAction(QWebPage.PasteAndMatchStyle))
|
menu.insertAction(action, self.pageAction(QWebPage.PasteAndMatchStyle))
|
||||||
|
parent = self._parent()
|
||||||
|
if hasattr(parent, 'toolbars_visible'):
|
||||||
|
vis = parent.toolbars_visible
|
||||||
|
menu.addAction(_('%s toolbars') % (_('Hide') if vis else _('Show')),
|
||||||
|
(parent.hide_toolbars if vis else parent.show_toolbars))
|
||||||
menu.exec_(ev.globalPos())
|
menu.exec_(ev.globalPos())
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
@ -743,6 +749,19 @@ class Editor(QWidget): # {{{
|
|||||||
self.toolbar2.setVisible(False)
|
self.toolbar2.setVisible(False)
|
||||||
self.toolbar3.setVisible(False)
|
self.toolbar3.setVisible(False)
|
||||||
|
|
||||||
|
def show_toolbars(self):
|
||||||
|
self.toolbar1.setVisible(True)
|
||||||
|
self.toolbar2.setVisible(True)
|
||||||
|
self.toolbar3.setVisible(True)
|
||||||
|
|
||||||
|
@dynamic_property
|
||||||
|
def toolbars_visible(self):
|
||||||
|
def fget(self):
|
||||||
|
return self.toolbar1.isVisible() or self.toolbar2.isVisible() or self.toolbar3.isVisible()
|
||||||
|
def fset(self, val):
|
||||||
|
getattr(self, ('show' if val else 'hide') + '_toolbars')()
|
||||||
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
def set_readonly(self, what):
|
def set_readonly(self, what):
|
||||||
self.editor.set_readonly(what)
|
self.editor.set_readonly(what)
|
||||||
|
|
||||||
|
@ -402,6 +402,14 @@ class CompareSingle(QWidget):
|
|||||||
self.sep2 = f = QFrame(self)
|
self.sep2 = f = QFrame(self)
|
||||||
f.setFrameShape(f.VLine)
|
f.setFrameShape(f.VLine)
|
||||||
l.addWidget(f, 0, 4, row, 1)
|
l.addWidget(f, 0, 4, row, 1)
|
||||||
|
if 'comments' in self.widgets and not gprefs.get('diff_widget_show_comments_controls', True):
|
||||||
|
self.widgets['comments'].new.hide_toolbars()
|
||||||
|
|
||||||
|
def save_comments_controls_state(self):
|
||||||
|
if 'comments' in self.widgets:
|
||||||
|
vis = self.widgets['comments'].new.toolbars_visible
|
||||||
|
if vis != gprefs.get('diff_widget_show_comments_controls', True):
|
||||||
|
gprefs.set('diff_widget_show_comments_controls', vis)
|
||||||
|
|
||||||
def changed(self, field):
|
def changed(self, field):
|
||||||
w = self.widgets[field]
|
w = self.widgets[field]
|
||||||
@ -510,10 +518,12 @@ class CompareMany(QDialog):
|
|||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
|
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
|
||||||
|
self.compare_widget.save_comments_controls_state()
|
||||||
super(CompareMany, self).accept()
|
super(CompareMany, self).accept()
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
|
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
|
||||||
|
self.compare_widget.save_comments_controls_state()
|
||||||
super(CompareMany, self).reject()
|
super(CompareMany, self).reject()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user