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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-19-2012, 01:05 PM   #1
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
Posts: 1,718
Karma: 509671
Join Date: Dec 2011
Location: Midwest USA
Device: Nook STR w/Glowlight, Kindle 3g, Droid
Disabled Actions still called by Keyboard Shortcut?

I borrowed some code from SendToDeviceAction to disable my plugins while on device view:
Code:
    def location_selected(self, loc):
        enabled = loc == 'library'
        self.qaction.setEnabled(enabled)
But in both my plugin and SendToDeviceAction, the Keyboard Shortcut key still triggered it.

IE, I can select a book in the library, switch to the device view--'Send to Device' on my toolbar is now disabled--and hit 'D' and calibre will send the book from the library to the device.

Is it supposed to work that way? I would expect disabled actions to not work from Keyboard Shortcut either.
JimmXinu is offline   Reply With Quote
Old 11-19-2012, 02:10 PM   #2
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: 26,125
Karma: 5101571
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It will only work if the qaction is the "shortcut_action". IIRC, by default, the qaction is not the shortcut_action, it is self.menuless_qaction, disabling that in addition to self.qaction should disable the keyboard shortcut. see the create_action() method in actions/__init__.py for details.
kovidgoyal is offline   Reply With Quote
Old 11-19-2012, 05:58 PM   #3
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
Posts: 1,718
Karma: 509671
Join Date: Dec 2011
Location: Midwest USA
Device: Nook STR w/Glowlight, Kindle 3g, Droid
Disabling self.menuless_qaction too does fix the problem. I've changed my code to:

Code:
    # disable when not in library. (main,carda,cardb)
    def location_selected(self, loc):
        enabled = loc == 'library'
        self.qaction.setEnabled(enabled)
        self.menuless_qaction.setEnabled(enabled)
Thanks for pointing it out.

Does that suggest that some of calibre's built in actions need that change, too?

I see the same issue--disabled button, but keyboard shortcut works with on last selected library book with ConvertAction, SendToDeviceAction and EditMetadataAction.

And a quick grep finds 12 places gui2/actions/*.py using 'self.qaction.setEnabled(enabled)'.
JimmXinu is offline   Reply With Quote
Old 11-19-2012, 09:26 PM   #4
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: 26,125
Karma: 5101571
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The problem is larger than that. Users can assign keyboard shortcuts to all sorts of actions like all the entries in a qactions sub menu, some of those would also have to be disabled. So far I haven't had any complaints from users about this, so I'd rather not fix a theoretical problem.
kovidgoyal is offline   Reply With Quote
Old 11-20-2012, 10:16 AM   #5
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
Posts: 1,718
Karma: 509671
Join Date: Dec 2011
Location: Midwest USA
Device: Nook STR w/Glowlight, Kindle 3g, Droid
Fair enough. Thanks for your help.
JimmXinu 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
Replace/customize keyboard shortcut? eosrose Calibre 2 11-10-2011 07:17 PM
Keyboard Shortcut Issue in viewer bigpallooka Calibre 2 10-21-2010 01:32 AM
Add keyboard shortcut? Chris Edwards Amazon Kindle 0 09-25-2010 01:58 PM
Issue with Send to device actions being disabled TCBW Calibre 4 02-13-2010 01:21 PM
Book Designer keyboard shortcut request LaughingVulcan Sony Reader 4 08-12-2007 08:25 AM


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


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