02-08-2020, 11:34 AM | #1 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
UI plugin icon not displaying in context menu
Never mind, I figured it out. My problem was due to a missing line.
Code:
popup_type = QToolButton.InstantPopup Hi Kovid, calibre 4.10.1 Win10 32-bit ... Can you shed any light on the following: This is not a showstopper but I've just noticed a problem with non-display of the main plugin icon in some of my UI plugins. It may have been around longer but I've only just noticed it. The problem seems to occur only in the right-click context menu and only for UI plugins which don't have a sub-menu. See attached screenshots. Using ScrambleEbook as an example of a UI plugin with no sub-menu, as you can see (2nd image) the plugin icon displays OK in the main toolbar and in the main menu. However in the right-click context menu (1st image) the icon is blank. Compare this with the 'TTS to MP3' (which does have a sub-menu) next to ScrambleEbook where the icon displays OK everywhere. I notice that the built-in tools/plugins which don't have a sub-menu (e.g. 'Polish book', 'Unpack book') don't have the same problem. I don't think the problem is specific to ScrambleEbook because 2 of my other (personal) plugins have the same problem. This is the genesis code from ScrambleEbook in case this is where the problem lies. Code:
def genesis(self): self.is_library_selected = True self.icons = get_icons(['images/plugin_icon.png', 'images/azw3.png', 'images/epub.png', 'images/kepub.png', 'images/azw3.svg', 'images/epub.svg', 'images/kepub.svg' ]) icon = get_icons('images/plugin_icon.png') self.qaction.setIcon(icon) self.qaction.triggered.connect(self.show_dialog) Last edited by jackie_w; 02-08-2020 at 04:34 PM. |
02-08-2020, 04:33 PM | #2 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Hmm. Maybe I spoke too soon.
Code:
popup_type = QToolButton.InstantPopup Code:
popup_type = QToolButton.MenuButtonPopup Code:
class ScrambleEbookUiAction(InterfaceAction): name = PLUGIN_NAME ttip = '%s\n(%s)' % (PLUGIN_DESCRIPTION, ','.join(OK_FORMATS)) action_spec = (PLUGIN_NAME, None, ttip, _('Ctrl+Shift+S')) popup_type = QToolButton.InstantPopup action_type = 'current' dont_add_to = frozenset([]) dont_remove_from = frozenset([]) Last edited by jackie_w; 02-08-2020 at 04:38 PM. |
Advert | |
|
02-08-2020, 11:51 PM | #3 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
looks ok at first glance, it would help if you posted the full plugin.
|
02-09-2020, 06:13 AM | #4 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
Just to recap, as this is a public plugin, my first priority is to enable a shortcut key and the second (cosmetic) priority is to have the icon displayed in the context menu. If you can tell me where I'm going wrong I'll be most grateful. Last edited by jackie_w; 02-14-2020 at 09:03 PM. Reason: attachment removed |
|
02-09-2020, 09:25 AM | #5 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Works for me once I commented out popup_type completely (which is the same as setting it to menubuttonpopup). I could add it to the context menu and I could use ctrl+shift+s to trigger it.
|
Advert | |
|
02-09-2020, 09:40 AM | #6 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
The context menu icon does appear if popup_type is InstantPopup, but then the shortcut doesn't work. If I have to settle for only one of the two I'll have to choose shortcut over icon, but I'd like to have both working if possible. |
|
02-09-2020, 11:38 AM | #7 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
ah ok, is see, where you have
self.qaction.setIcon(icon) add Code:
if hasattr(self, 'shortcut_action_for_context_menu'): self.shortcut_action_for_context_menu.setIcon(icon) |
02-09-2020, 12:00 PM | #8 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
I don't think I'd ever have worked that one out on my own. |
|
02-09-2020, 08:10 PM | #9 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It's really a regression, you should not need to do it at all and it will be fixed in the next release.
|
02-10-2020, 12:30 PM | #10 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
|
02-10-2020, 08:34 PM | #11 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can keep the code I mentioned, it's harmless. The regression was in either 4.9 or 4.10 dont remember.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Context Menu for EPUB Files | Woznet | Calibre | 2 | 03-23-2017 09:21 AM |
Question About Calibre Context Menu | Albion | Calibre | 9 | 09-21-2014 04:33 PM |
How to register a plugin to viewer selected text context menu? | Gerbrand | Development | 2 | 05-04-2014 01:24 PM |
Copy in Preview Context Menu | BetterRed | Editor | 2 | 03-17-2014 12:35 AM |
no context-menu, no wifi | snakeduh | PocketBook | 3 | 07-08-2010 03:24 PM |