mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix split button
This commit is contained in:
parent
67f3422438
commit
37c277d684
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user