View Single Post
Old 08-29-2011, 01:10 PM   #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,731
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@Kovid - just giving this a go now, a few things:

(1) There is a typo in gui2/preferences/keyboard.py of "highligh_group" instead of "highlight_group"

(2) I am launching my dialog to host the widget (rather than using it from its native Preferences dialog home) - as there will be no room to put the widget on my own dialogs without making them all much bigger or tabbed. However I need to figure out the right code to display something as right now the keyboard widget's contents is empty. This snippet below is part of what I have (have extra code for a button box with accept/reject)... what am I missing?
Code:
from calibre.gui2.keyboard import ShortcutConfig
class KeyboardConfigDialog(SizePersistedDialog):
    def __init__(self, gui, group_name):
        SizePersistedDialog.__init__(self, gui, 'Keyboard shortcut dialog')
        self.gui = gui
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        self.keyboard_widget = ShortcutConfig(gui)
        layout.addWidget(self.keyboard_widget)
        self.group_name = group_name

    def initialize(self):
        SizePersistedDialog.initialize()
        self.keyboard_widget.initialize(self.gui.keyboard)
        self.keyboard_widget.highlight_group(self.group_name)
(3) How should I handle the situation of where in many of my plugins I end up rebuilding the plugin menus? Because I get an error being thrown where the keyboard logic thinks there is a keyboard shortcut conflict?
Code:
calibre, version 0.8.16
ERROR: Unhandled exception: <b>NameConflict</b>:Shortcut for u'Interface Action: Clipboard Search (Clipboard Search) : menu action : Text search' already registered by Text search

Traceback (most recent call last):
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\dialogs\plugin_updater.py", line 788, in _configure_clicked
  File "D:\CalibreDev\latest\calibre\src\calibre\customize\__init__.py", line 171, in do_user_config
  File "calibre_plugins.clipboard_search.__init__", line 72, in save_settings
  File "calibre_plugins.clipboard_search.action", line 48, in rebuild_menus
  File "calibre_plugins.clipboard_search.common_utils", line 139, in create_menu_action_unique
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\actions\__init__.py", line 222, in create_menu_action
  File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 106, in register_shortcut
NameConflict: Shortcut for u'Interface Action: Clipboard Search (Clipboard Search) : menu action : Text search' already registered by Text search
kiwidude is offline   Reply With Quote