View Single Post
Old 06-30-2012, 09:24 AM   #22
kiwidude
calibre/Sigil 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,228
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
I can't use positional indexes because everything keeps moving . Like I said, so many plugins rebuild their menus as users "do stuff" with them. Say a user creates a new reading list - that means the View list menu is changed to insert the new list name as a choice. Even the Quick Switch menu in the library menu will change if the user creates another library. Its just a complete non-starter.

As for objectName() - what name can I give a menu item, that I know will survive calibre restarts that I can record in a configuration file? Surely the only thing a menu item is guaranteed to have that is unique within its siblings is its text (since I cant rely on position). So yes I "could" attribute all the menu items in that way at my plugin startup, and it would make rebuilding the menu each time it is shown potentially easier. However it doesn't solve the problem of what name I can give each menu item that is going to be guaranteed to be identical the next time I start calibre that I can store in the config?

If there's something obvious I'm missing I'm all ears. But the only way I can see around this is to add attribution to the QAction from the plugin responsible for creating that QAction in the first place, since it is the only one that knows what a consistent but unique name for that QAction could be. So for instance the Reading List plugin does something like:
ac.favourites_menu_name = 'View list Foo'
ac.favourites_menu_suffix = ' (%d)'%count
kiwidude is offline   Reply With Quote