Diff tool: Allow toggling beautify instead of just setting it

This commit is contained in:
Kovid Goyal 2014-01-31 11:34:23 +05:30
parent 2385da36aa
commit 869ccb9fa9

View File

@ -257,7 +257,8 @@ class Diff(Dialog):
for i in (3, 5, 10, 50): for i in (3, 5, 10, 50):
cm.addAction(_('Show %d lines of context') % i, partial(self.change_context, i)) cm.addAction(_('Show %d lines of context') % i, partial(self.change_context, i))
cm.addAction(_('Show all text'), partial(self.change_context, None)) cm.addAction(_('Show all text'), partial(self.change_context, None))
m.addAction(_('Beautify files before comparing them'), partial(self.change_beautify, True)) self.beautify_action = m.addAction('', self.toggle_beautify)
self.set_beautify_action_text()
m.addMenu(cm) m.addMenu(cm)
l.addWidget(b, r, 7) l.addWidget(b, r, 7)
@ -306,12 +307,16 @@ class Diff(Dialog):
self.view.add_diff(*args, **kwargs) self.view.add_diff(*args, **kwargs)
self.view.finalize() self.view.finalize()
def change_beautify(self, beautify): def toggle_beautify(self):
if beautify == self.beautify: self.beautify = not self.beautify
return self.set_beautify_action_text()
self.beautify = beautify
self.refresh() self.refresh()
def set_beautify_action_text(self):
self.beautify_action.setText(
_('Beautify files before comparing them') if not self.beautify else
_('Do not beautify files before comparing'))
def __enter__(self): def __enter__(self):
self.stacks.setCurrentIndex(0) self.stacks.setCurrentIndex(0)
self.busy.pi.startAnimation() self.busy.pi.startAnimation()