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:
Kovid Goyal 2014-02-27 14:34:19 +05:30
parent ec2952aeb1
commit 8d746b8044
2 changed files with 30 additions and 1 deletions

View File

@ -5,7 +5,7 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re, os, json
import re, os, json, weakref
from lxml import html
import sip
@ -69,6 +69,7 @@ class EditorWidget(QWebView): # {{{
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self._parent = weakref.ref(parent)
self.readonly = False
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
@ -407,6 +408,11 @@ class EditorWidget(QWebView): # {{{
for action in menu.actions():
if action == paste:
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())
# }}}
@ -743,6 +749,19 @@ class Editor(QWidget): # {{{
self.toolbar2.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):
self.editor.set_readonly(what)

View File

@ -402,6 +402,14 @@ class CompareSingle(QWidget):
self.sep2 = f = QFrame(self)
f.setFrameShape(f.VLine)
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):
w = self.widgets[field]
@ -510,10 +518,12 @@ class CompareMany(QDialog):
def accept(self):
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
self.compare_widget.save_comments_controls_state()
super(CompareMany, self).accept()
def reject(self):
gprefs.set('diff_dialog_geom', bytearray(self.saveGeometry()))
self.compare_widget.save_comments_controls_state()
super(CompareMany, self).reject()
@property