From 37c277d684d5024bed3eb7c96bb6941f762c6fe1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 27 Jul 2018 22:32:55 +0530 Subject: [PATCH] Fix split button --- src/calibre/gui2/tweak_book/preview.py | 5 ++--- src/pyj/editor.pyj | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/tweak_book/preview.py b/src/calibre/gui2/tweak_book/preview.py index 675fc5a1bb..3796b18e68 100644 --- a/src/calibre/gui2/tweak_book/preview.py +++ b/src/calibre/gui2/tweak_book/preview.py @@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera # TODO: # live css # check that clicking on both internal and external links works -# check all buttons in preview panel import json import textwrap @@ -301,10 +300,10 @@ class Bridge(QObject): except (TypeError, ValueError, OverflowError, AttributeError): pass - @pyqtSlot(native_string_type, native_string_type) + @pyqtSlot('QJsonArray', 'QJsonArray') def request_split(self, loc, totals): actions['split-in-preview'].setChecked(False) - loc, totals = json.loads(unicode_type(loc)), json.loads(unicode_type(totals)) + loc, totals = [x.toInt() for x in loc], [x.toInt() for x in totals] if not loc or not totals: return error_dialog(self.view(), _('Invalid location'), _('Cannot split on the body tag'), show=True) diff --git a/src/pyj/editor.pyj b/src/pyj/editor.pyj index f92e0b4615..80d9b3eab3 100644 --- a/src/pyj/editor.pyj +++ b/src/pyj/editor.pyj @@ -28,7 +28,7 @@ def in_table(elem): def find_containing_block(elem): - while elem and elem.getAttribute('data-is-block') != '1': + while elem and elem.dataset.isBlock is not '1': elem = elem.parentNode return elem @@ -256,7 +256,7 @@ class PreviewIntegration: if window is window.top: setTimeout(self.connect_channel, 10) document.body.addEventListener('click', self.onclick, True) - document.body.appendChild(E.style( + document.head.appendChild(E.style( type='text/css', '[data-in-split-mode="1"] [data-is-block="1"]:hover { cursor: pointer !important; border-top: solid 5px green !important }' )) @@ -298,7 +298,7 @@ class PreviewIntegration: def set_split_mode(self, enabled): self.in_split_mode = enabled - document.body.setAttribute('data-in-split-mode', '1' if enabled else '0') + document.body.dataset.inSplitMode = '1' if enabled else '0' if enabled: self.find_blocks() @@ -317,7 +317,7 @@ class PreviewIntegration: parent = parent.parentNode loc.reverse() totals.reverse() - self.bridge.request_split(JSON.stringify(loc), JSON.stringify(totals)) + self.bridge.request_split(loc, totals) def connect_channel(self): self.qwebchannel = new window.QWebChannel(window.qt.webChannelTransport, def(channel):