mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Fix #1335598 [corrupted tooltip with very long tweak setting](https://bugs.launchpad.net/calibre/+bug/1335598) and pep8
This commit is contained in:
parent
2d364dfa4a
commit
bd460282a5
@ -129,7 +129,7 @@ class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
|||||||
tt += '<pre>'
|
tt += '<pre>'
|
||||||
for varn, val in tweak.custom_values.iteritems():
|
for varn, val in tweak.custom_values.iteritems():
|
||||||
tt += '%s = %r\n\n'%(varn, val)
|
tt += '%s = %r\n\n'%(varn, val)
|
||||||
return tt
|
return textwrap.fill(tt)
|
||||||
if role == Qt.UserRole:
|
if role == Qt.UserRole:
|
||||||
return tweak
|
return tweak
|
||||||
return NONE
|
return NONE
|
||||||
@ -137,13 +137,13 @@ class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
|||||||
def parse_tweaks(self, defaults, custom):
|
def parse_tweaks(self, defaults, custom):
|
||||||
l, g = {}, {}
|
l, g = {}, {}
|
||||||
try:
|
try:
|
||||||
exec custom in g, l
|
exec(custom, g, l)
|
||||||
except:
|
except:
|
||||||
print 'Failed to load custom tweaks file'
|
print 'Failed to load custom tweaks file'
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
dl, dg = {}, {}
|
dl, dg = {}, {}
|
||||||
exec defaults in dg, dl
|
exec(defaults, dg, dl)
|
||||||
lines = defaults.splitlines()
|
lines = defaults.splitlines()
|
||||||
pos = 0
|
pos = 0
|
||||||
self.tweaks = []
|
self.tweaks = []
|
||||||
@ -331,8 +331,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.splitter.setStretchFactor(1, 100)
|
self.splitter.setStretchFactor(1, 100)
|
||||||
self.next_button.clicked.connect(self.find_next)
|
self.next_button.clicked.connect(self.find_next)
|
||||||
self.previous_button.clicked.connect(self.find_previous)
|
self.previous_button.clicked.connect(self.find_previous)
|
||||||
self.search.initialize('tweaks_search_history', help_text=
|
self.search.initialize('tweaks_search_history', help_text=_('Search for tweak'))
|
||||||
_('Search for tweak'))
|
|
||||||
self.search.search.connect(self.find)
|
self.search.search.connect(self.find)
|
||||||
self.view.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.view.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
self.view.customContextMenuRequested.connect(self.show_context_menu)
|
self.view.customContextMenuRequested.connect(self.show_context_menu)
|
||||||
@ -364,7 +363,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
if d.exec_() == d.Accepted:
|
if d.exec_() == d.Accepted:
|
||||||
g, l = {}, {}
|
g, l = {}, {}
|
||||||
try:
|
try:
|
||||||
exec unicode(d.edit.toPlainText()) in g, l
|
exec(unicode(d.edit.toPlainText()), g, l)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
return error_dialog(self, _('Failed'),
|
return error_dialog(self, _('Failed'),
|
||||||
@ -405,7 +404,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
if idx.isValid():
|
if idx.isValid():
|
||||||
l, g = {}, {}
|
l, g = {}, {}
|
||||||
try:
|
try:
|
||||||
exec unicode(self.edit_tweak.toPlainText()) in g, l
|
exec(unicode(self.edit_tweak.toPlainText()), g, l)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
error_dialog(self.gui, _('Failed'),
|
error_dialog(self.gui, _('Failed'),
|
||||||
@ -419,7 +418,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
def commit(self):
|
def commit(self):
|
||||||
raw = self.tweaks.to_string()
|
raw = self.tweaks.to_string()
|
||||||
try:
|
try:
|
||||||
exec raw
|
exec(raw)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
error_dialog(self, _('Invalid tweaks'),
|
error_dialog(self, _('Invalid tweaks'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user