Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 07-30-2018, 05:13 PM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Editor plugin tools & shortcut keys

I have quite a lot of editor plugin tools and up to now have only ever added each tool to one of the toolbars. Each tool also appears under Plugins on the menu. No problems to date.

I don't normally care about shortcut keys (difficulty remembering them) but with my latest tool I thought a shortcut key might be more convenient. The default shortcut key combo I assigned (Ctrl+Alt+Shift+Z) appears in the list under
Edit > Preferences > Keyboard shortcuts > Plugins > MyUnicodeTool
and I can customise it there if I want. It has no conflicts. On the face of it everything appears OK.

However, no matter what I set the shortcut to, the tool is never run. Typing Ctrl+Alt+Shift+Z just types a Z in the editor at the current cursor position.

The tool does run OK via a toolbar button or from the Plugin menu.

I'm wondering if I have the wrong magic combination of settings in the Tool class. I currently have:
Code:
allowed_in_toolbar = True
allowed_in_menu = True

def create_action(self, for_toolbar=True):
    ac = QAction(get_icons('images/unicode.png'), _('MyUnicodeTool'), self.gui)
    if for_toolbar:
        self.register_shortcut(ac, 'get-unicode-tool', default_keys=('Ctrl+Shift+Alt+Z',))
    ac.triggered.connect(self.do_the_action)
    return ac
I have tried various variations in the 3 True/False variables above but haven't found a working combo.

I also tried installing your demo, editor_demo_plugin.zip, the Magnify Fonts tool. I had the same problem with this tool as well. Typing Ctrl+Shift+Alt+D just types a D.

Any idea what I'm doing wrong? What should the settings be to get a working shortcut? Is there some higher level config or tweak I may have unset long ago which could stop plugin shortcuts working.

In case it's relevant, other Editor standard shortcuts, like Ctrl+C, Ctrl+F, Ctrl+N, F7 (Check Book) etc work OK.
jackie_w is offline   Reply With Quote
Old 07-30-2018, 11:05 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
As far as I know, that should be all that is needed. You can comare it to the registering of th eshortcuts or builtin actions. Relevant code is lines 326-327 in tweak_book/ui.py and and line 86-87 in tweak_book/plugin.py
kovidgoyal is offline   Reply With Quote
Old 07-30-2018, 11:08 PM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...778cf5c5d9366f
kovidgoyal is offline   Reply With Quote
Old 07-31-2018, 09:46 AM   #4
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Not just me then. I just tried your fix in my run-from-source. All OK now, thanks
jackie_w is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content server: adding books using the web interface and Tools plugin... gbm Calibre 1 01-27-2018 09:14 PM
Plugin icons on Tools toolbar DNSB Sigil 6 12-07-2017 01:58 AM
Keyboard shortcut to cycle between editor and files? Aquinax Editor 2 05-26-2017 02:39 PM
Q: Editor shortcut keys question phossler Editor 16 10-16-2015 11:24 PM
Java Bytecode Editor + Method Tools dsmid Kindle Developer's Corner 0 03-31-2014 04:17 AM


All times are GMT -4. The time now is 03:07 PM.


MobileRead.com is a privately owned, operated and funded community.