![]() |
#1 |
Plugin Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,865
Karma: 4604429
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
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) 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. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,215
Karma: 27110894
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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Plugin Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,865
Karma: 4604429
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
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) 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)'. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,215
Karma: 27110894
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.
|
![]() |
![]() |
![]() |
#5 |
Plugin Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,865
Karma: 4604429
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Fair enough. Thanks for your help.
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
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 |