06-18-2019, 11:19 AM | #16 | |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Well that would have been nice to know!
So do you use the QWebChannel.js or do you serialize and send back and forth across a pipe, or yourself? I will take a peek to try to understand your approach. That said, I really am not a javascript programmer (what I know about javascript you could put in a thimble) but luckily I have been able to adapt the javascript used in Sigil to get effectively a cfi (webpath) to synchronize scrolling between our CodeView and Preview. Take care, KevinH Quote:
|
|
06-18-2019, 11:28 AM | #17 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
web channel did not work for me because the browser has multiple web pages and it is not easy to know which page which channel belongs to, so I used a rather glorious hack -- for communication for JS back to the outside world I seriealized the message as JSON and set it as the document.title which fires the Qt titleChanged() signal, and my Qt side code can then call a function in JS to get the payload for the message in caseit was too large to send via a title.
And yeah JS is a pain, I ended up writing my own python like language that compiles to JS to make working with it tolerable. Th entire calibre content server and all the webengine code are written in it. https://github.com/kovidgoyal/rapydscript-ng |
Advert | |
|
06-18-2019, 12:00 PM | #18 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Gotta love that hack!
So to go from python to javascript you use pyqt5 to invoke runjavascript to send a json object to your own javascript routine preloaded in the page. Then to go the other way, javascript just changes the document title to add a message and a Qt signal titleChanged() is fired automatically which tells the python side to run a javascript to get the result from the document title tag resetting it back to normal. And since the document title is for informational purposes and not actually shown, everything just works! And this can work for any number of different webpages each with its own document title. Absolutely wonderful! No pipes, no shared memory, no extra signals, no QWebChannel, just a little extra javascript to read and manipulate the document title. Qt should pay you for this idea and then create an extra signal tied to an always *non-displayed* tag such as a qt:message tag stored in head or even a standard comment tag in head. Nicely done! |
06-18-2019, 01:26 PM | #19 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
thanks I was rather proud of the hack, simple, but effective. I actually reported it to Qt ina bug report about the inadequacies of web channel, but they weren't interested
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Style Sheet entry for a 'hanging' style | AThirstyMind | Kindle Formats | 6 | 12-10-2016 12:28 AM |
Search not filtering? | VelvetElvis | Library Management | 5 | 05-30-2014 05:12 AM |
Possible calibre filtering? | Glenndk | Calibre | 0 | 07-31-2010 01:34 PM |
Mobi TOC style vs ePub style? | phearlez | Kindle Formats | 3 | 04-11-2010 06:35 AM |
0.6.4 and filtering by tags | itimpi | Calibre | 3 | 08-01-2009 01:43 PM |