Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-30-2012, 06:58 AM   #16
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
v1.0.1 Released

Changes in this release:
  • Add a hack to allow menu items from the Reading List plugin that have counts in them still be used in this plugin (without the counts)

@Jade - this should let you add those Reading List items to your menu now. Note that they won't have counts after their names like they have in the "original" Reading List menu. Trying to support that would have made it even more of a filthy hack than it already is. Hopefully there won't be too many more of these "dynamically changing menu names" that come up, we shall see.
kiwidude is offline   Reply With Quote
Old 06-30-2012, 07:13 AM   #17
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,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@kiwidude: Aren't you using the QAction::changed() signal? That is how calibre itself supports these types of actions when cloning them for the menubar.
kovidgoyal is offline   Reply With Quote
Advert
Old 06-30-2012, 07:35 AM   #18
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
No Kovid, I don't think I can do that, for two reasons. The biggest is because so many of the plugins have their menus completely rebuilt on their own bequest, it is not practical for my plugin to try to hold any links to their QActions for a period of time longer than at the time the user clicks on the button to show my menu. A large number of my plugins in particular have very dynamic menus, where the menu must constantly rebuild itself when the user creates new lists, configures new menu items etc. Even if that wasn't the case, how could my plugin work out the very first relationship with a menu at calibre startup, other than trying to walk comparing the menu text?

The second reason is that the user can rename menu items on my menu. Say for instance a user chose to put both Edit list -> List A and View list -> List A on their Favourites menu. The default names for those are going to appear as "List A" and "List A". So to stop their confusion they will rename them to "Edit List A" and "View List A". That of course means that the original name which is constantly changing due to the counts being appended to it cannot directly replace their custom name.

Now I could deepen the filth of my hack and have my plugin append the (#) count to whatever display name the user has chosen if push comes to shove but it is grubby enough putting in a special case for a plugin named "Reading List" as it is

The other idea I had was to use a hasattr() check against the QAction and look for a specially named attribute, like "favourite_menu_name" or whatever that represented the non-dynamic version of the name. However that would mean me having to make a change to the Reading List plugin to implement it, and also rely on every other developer in future who writes a plugin with a dynamic menu name to also implement it. It may come to that one day, but for now I kept the filth constrained to within this plugin
kiwidude is offline   Reply With Quote
Old 06-30-2012, 09:05 AM   #19
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,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Wait, I'm a a little confused. If you are dynamically building the favorites menu every time it is requested, why is there a problem at all? Surely, the menu text does not change while the favorites menu is displayed? Is the issue that you have no way of keeping a reference to the original action, because the action is deleted and recreated?
kovidgoyal is offline   Reply With Quote
Old 06-30-2012, 09:11 AM   #20
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
The issue is that I can't *find* the original action when the dynamic part is included in the name.

So a user on the configuration screen picks a menu item - at the time they configure it the path to that menu item might be something like:
["Reading List", "View list", "Foo (10)"]

So long as the user only keeps 10 items on that Foo list, then all would work fine

However obviously they don't. Every time my menu is clicked on to show, I have to walk through all the plugins to "find" the related menu item again, in order to build my Favourites Menu. It could be that in the interim since it was last shown that the user has reconfigured the menu for this plugin, reconfigured the menus for another plugin, uninstalled another plugin etc etc. So when my plugin goes to find "Foo (10)" within the "View list" menu, it won't find it if the user has changed the contents of that list.
kiwidude is offline   Reply With Quote
Advert
Old 06-30-2012, 09:14 AM   #21
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,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Is there a reason you aren't using positional indices for the path? If there is some reason you dont want to do that, then the solution is to add an attribute to the plugin that gives it a "static" name. You can use the Qt objectName() to do that.
kovidgoyal is offline   Reply With Quote
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
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
Old 06-30-2012, 09:51 AM   #23
GeckoFriend
Guru
GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.
 
GeckoFriend's Avatar
 
Posts: 614
Karma: 1164945
Join Date: Jan 2012
Location: SF Bay Area, California, USA
Device: iPhone 7+, iPad Mini4, Kindle Voyage
I followed kiwidude's directions in post #12 to replace the icon (only because I like dwanthny's better) but can't get it to work. The path on Vista is:

C:\Users\Myname\AppData\Roaming\calibre\resources\ images\favourites_menu\favourites_menu.png

Can anyone spot my error?
GeckoFriend is offline   Reply With Quote
Old 06-30-2012, 10:03 AM   #24
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Yes - the folder name should be "Favourites Menu", not "favourites_menu". It must be the same as the name of the plugin (the name of the zip file).
kiwidude is offline   Reply With Quote
Old 06-30-2012, 10:22 AM   #25
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,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Positional indices can still be meaningful, they just mean the nth entry in amenu as opposed to entry with x text.

For objectName() I meant that the plugin would set an object name to use, instead of using a custom attribute. Obviously not every plugin author will do this, but then most plugins will not have mutable menu entries anyway.
kovidgoyal is offline   Reply With Quote
Old 06-30-2012, 10:36 AM   #26
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@Kovid - right, I thought you meant some trickery to get this plugin to assign the objectName() for each item. I still don't understand your positional index point - being the nth menu in a menu doesn't mean much if it has become the nth+1 item on the menu at the time you go looking for it at the nth position

I (think) we are agreed that it would have to be *other* plugins setting "something" on *their* QAction items in this rare circumstance of a menu item not being mutable. Which puts me pretty much back where I started at the top of the page, be it with confirmation it is the only other way .

Longer term when I next fiddle with the Reading List plugin I will figure out some additional attribution or objectName approach that will be the new "workaround" should any other plugins hit this situation, and push a new release of this plugin to cope with it. I just didn't want to do it yet without thinking through all the scenarios I want to cater for (such as allowing a suffix or pattern to be applied to the user specified custom name to retain the dynamic aspect to it when place on this plugin's menu).
kiwidude is offline   Reply With Quote
Old 06-30-2012, 10:37 AM   #27
GeckoFriend
Guru
GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.
 
GeckoFriend's Avatar
 
Posts: 614
Karma: 1164945
Join Date: Jan 2012
Location: SF Bay Area, California, USA
Device: iPhone 7+, iPad Mini4, Kindle Voyage
Quote:
Originally Posted by kiwidude View Post
Yes - the folder name should be "Favourites Menu", not "favourites_menu". It must be the same as the name of the plugin (the name of the zip file).
Made this change and reinstalled the plugin but the icon did not change.

Side note: why is the Generate Cover plugin images folder named generate_cover?
GeckoFriend is offline   Reply With Quote
Old 06-30-2012, 10:42 AM   #28
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@GeckoFriend - you will need to restart calibre to pickup the new icon.

As to why generate_cover is called that and not "Generate Cover", it is because that folder is *private* to the plugin and not intended for this general "plugin image replacement" purpose. It contains cover images a user uploads into the Generate Cover plugin - you wouldn't want an accidental name conflict to suddenly mean a cover becomes a plugin icon would you?
kiwidude is offline   Reply With Quote
Old 06-30-2012, 10:54 AM   #29
GeckoFriend
Guru
GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.GeckoFriend ought to be getting tired of karma fortunes by now.
 
GeckoFriend's Avatar
 
Posts: 614
Karma: 1164945
Join Date: Jan 2012
Location: SF Bay Area, California, USA
Device: iPhone 7+, iPad Mini4, Kindle Voyage
@kiwidude

Tried again: removed plugin, removed icon from menu bars, restarted calibre, installed plugin and icons, restarted calibre

Still have old icon

Thanks for the explanation about Generate Cover; makes perfect sense.
GeckoFriend is offline   Reply With Quote
Old 06-30-2012, 10:59 AM   #30
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,606
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@GeckoFriend - you don't need to do any reinstalling of the plugin or removing/adding to the bars. Just drop the icon in there and restart calibre. This trick does work, you must have something wrong with your path. It should be in your case:
Code:
C:\Users\Myname\AppData\Roaming\calibre\resources\images\Favourites Menu\favourites_menu.png
kiwidude is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Open With kiwidude Plugins 402 03-16-2024 11:44 PM
[GUI Plugin] EpubMerge JimmXinu Plugins 521 02-11-2024 06:07 PM
[GUI Plugin] KindleUnpack - The Plugin DiapDealer Plugins 492 10-25-2022 08:13 AM
[GUI Plugin] FanFictionDownLoader JimmXinu Plugins 3985 05-08-2015 11:18 PM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM


All times are GMT -4. The time now is 02:43 AM.


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