Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-08-2020, 11:34 AM   #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,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
I never have been exactly sure about the available options for popup_type. I just learnt the hard way.

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)
Attached Thumbnails
Click image for larger version

Name:	calibre_noicon.jpg
Views:	237
Size:	317.6 KB
ID:	177020   Click image for larger version

Name:	calibre_noicon2.jpg
Views:	243
Size:	16.7 KB
ID:	177021  

Last edited by jackie_w; 02-08-2020 at 04:34 PM.
jackie_w is offline   Reply With Quote
Old 02-08-2020, 04:33 PM   #2
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,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
gave me the icon in the context menu but it seems to have also disabled the Shortcut key setting which is working OK when I have
Code:
popup_type = QToolButton.MenuButtonPopup
... or perhaps I haven't found the magic combo yet. The genesis is as shown in post #1 and the bit before genesis() is
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([])
Is there an obvious error here?

Last edited by jackie_w; 02-08-2020 at 04:38 PM.
jackie_w is offline   Reply With Quote
Advert
Old 02-08-2020, 11:51 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,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.
kovidgoyal is online now   Reply With Quote
Old 02-09-2020, 06:13 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,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by kovidgoyal View Post
looks ok at first glance, it would help if you posted the full plugin.
OK, here it is.

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
jackie_w is offline   Reply With Quote
Old 02-09-2020, 09:25 AM   #5
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,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.
kovidgoyal is online now   Reply With Quote
Advert
Old 02-09-2020, 09:40 AM   #6
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,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by kovidgoyal View Post
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.
Perhaps I didn't explain myself well enough. I have no problem adding to (or running from) the context menu. It's just that there is no icon displayed (on my Windows10 anyway) in the context menu when popup_type is set to MenuButtonPopup.

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.
jackie_w is offline   Reply With Quote
Old 02-09-2020, 11:38 AM   #7
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,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)
as well.
kovidgoyal is online now   Reply With Quote
Old 02-09-2020, 12:00 PM   #8
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,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by kovidgoyal View Post
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)
as well.
Oh, yes, that works.

I don't think I'd ever have worked that one out on my own.
jackie_w is offline   Reply With Quote
Old 02-09-2020, 08:10 PM   #9
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,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.
kovidgoyal is online now   Reply With Quote
Old 02-10-2020, 12:30 PM   #10
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,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by kovidgoyal View Post
It's really a regression, you should not need to do it at all and it will be fixed in the next release.
OK then, before I publish the python3-ready plugin update I'll revert back to the original code I had.

Was it a 4.10 regression?
jackie_w is offline   Reply With Quote
Old 02-10-2020, 08:34 PM   #11
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,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.
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 09:15 AM.


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