View Single Post
Old 03-12-2011, 09:11 AM   #18
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,732
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by kiwidude View Post
Quote:
Originally Posted by meme View Post
By the way, in preferences->customize the toolbar how do I put my custom icon next to the text name of the icon like the built-in entries?
Your other question about the icons for the Preferences->Customize the toolbar is something that has been bugging me for a while. I did look at the code once and found the reason why it would not display them - there is nothing we as plugin developers can do, it needs Calibre code changes.
I just took another look at this to remind myself what the issue is. The way the code is written currently (in gui2\preferences\toolbar.py line 50), it uses the action_spec of the InterfaceAction to get a name of the icon.

Unfortunately in our plugins we have to set the icon name in that action spec to None, because our icons are coming from the plugin zip file. Your plugin used to have an icon appear for it because you used to set that action_spec value to the name of an icon that was in Calibre.

One workaround for this that comes to mind is if the Calibre code was to support grabbing the icon from the .qaction of the InterfaceAction. I added these lines of code at line 58:
Code:
            if hasattr(self._data[row], 'qaction'):
                icon = self._data[row].qaction.icon()
                if not icon.isNull():
                    return QVariant(icon)
And as per the screenshot icons magically appear
Click image for larger version

Name:	CustomiseToolbar.png
Views:	441
Size:	82.3 KB
ID:	68208
kiwidude is offline   Reply With Quote