diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 3b397203e4..dbadd4fde1 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -825,7 +825,7 @@ class Boss(QObject): # }}} # Global history {{{ - def do_global_undo(self): + def do_global_undo(self, *a): container = self.global_undo.undo() if container is not None: set_current_container(container) diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 13a76fe119..fd105ad401 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -262,7 +262,7 @@ def install_new_plugins(): class MessagePopup(QLabel): - undo_requested = pyqtSignal() + undo_requested = pyqtSignal(object) def __init__(self, parent): QLabel.__init__(self, parent) @@ -294,12 +294,16 @@ class MessagePopup(QLabel): def link_activated(self, link): self.hide() if link.startswith('undo://'): - self.undo_requested.emit() + import base64, json + data = base64.urlsafe_b64decode(link.rpartition('/')[-1]) + self.undo_requested.emit(json.loads(data)) def __call__(self, text='Testing message popup', show_undo=True, timeout=5000, has_markup=False): text = '

' + (text if has_markup else prepare_string_for_xml(text)) if show_undo: - text += '\xa0\xa0{}'.format(_('Undo')) + import base64, json + data = base64.urlsafe_b64encode(json.dumps(show_undo).encode('utf-8')).decode('ascii') + text += '\xa0\xa0{}'.format(data, _('Undo')) text += f'\xa0\xa0' self.setText(text) self.resize(self.sizeHint()) @@ -317,7 +321,7 @@ class Main(MainWindow): APP_NAME = _('Edit book') STATE_VERSION = 0 - undo_requested = pyqtSignal() + undo_requested = pyqtSignal(object) def __init__(self, opts, notify=None): MainWindow.__init__(self, opts, disable_automatic_gc=True)