07-30-2018, 05:13 PM | #1 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
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 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. |
07-30-2018, 11:05 PM | #2 |
creator of calibre
Posts: 43,860
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
|
Advert | |
|
07-30-2018, 11:08 PM | #3 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
07-31-2018, 09:46 AM | #4 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
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
|
|
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 |