本文整理汇总了Python中pluginmanager.PluginManager.get_compiled_hotkeys方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.get_compiled_hotkeys方法的具体用法?Python PluginManager.get_compiled_hotkeys怎么用?Python PluginManager.get_compiled_hotkeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pluginmanager.PluginManager
的用法示例。
在下文中一共展示了PluginManager.get_compiled_hotkeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Kalpana
# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import get_compiled_hotkeys [as 别名]
class Kalpana(QtGui.QApplication):
read_plugin_config = pyqtSignal()
write_plugin_config = pyqtSignal()
print_ = pyqtSignal(str)
error = pyqtSignal(str)
def __init__(self, configdir, file_to_open=None):
super().__init__(['kalpana'])
self.objects = create_objects(configdir)
self.objects['mainwindow'].create_ui(self.objects['chaptersidebar'],
self.objects['textarea'],
self.objects['terminal'])
# Plugins
self.pluginmanager = PluginManager(self.objects.copy())
self.objects['terminal'].update_commands(self.pluginmanager.plugin_commands)
# Signals
connect_others_signals(*self.objects.values())
self.connect_own_signals()
# Hotkeys
set_key_shortcuts(self.objects['mainwindow'], self.objects['textarea'],
self.objects['terminal'],
self.pluginmanager.get_compiled_hotkeys())
self.init_hotkeys()
# Load settings and get it oooon
self.objects['settingsmanager'].load_settings()
self.install_event_filter()
# Try to open a file and die if it doesn't work, or make a new file
if file_to_open:
if not self.objects['textarea'].open_file(file_to_open):
self.close()
else:
self.objects['textarea'].set_filename(new=True)
# FIN
self.objects['mainwindow'].show()
def install_event_filter(self):
# Event filter
class AppEventFilter(QtCore.QObject):
activation_event = pyqtSignal()
def eventFilter(self, object, event):
if event.type() == QtCore.QEvent.ApplicationActivate:
self.activation_event.emit()
return False
self.event_filter = AppEventFilter()
def refresh_config():
self.objects['settingsmanager'].load_settings(refresh_only=True)
self.event_filter.activation_event.connect(refresh_config)
self.installEventFilter(self.event_filter)
def connect_own_signals(self):
self.objects['settingsmanager'].set_stylesheet.connect(self.setStyleSheet)
self.objects['terminal'].list_plugins.connect(self.list_plugins)
def list_plugins(self, _):
plugins = self.pluginmanager.plugins
self.objects['terminal'].print_(', '.join(name for name, p in plugins))
# === Configurable hotkeys =========================================
def init_hotkeys(self):
l = (('terminal', self.objects['terminal'].toggle, self.set_terminal_hotkey),
('chapter sidebar', self.objects['chaptersidebar'].toggle, self.set_chaptersidebar_hotkey))
self.hotkeys = {name: QtGui.QShortcut(QtGui.QKeySequence(''),
self.objects['mainwindow'],
callback)
for name, callback, _ in l}
for n, _, callback in l:
self.objects['settingsmanager'].register_setting(n + ' hotkey', callback)
def set_terminal_hotkey(self, newkey):
self.set_hotkey('terminal', newkey)
def set_chaptersidebar_hotkey(self, newkey):
self.set_hotkey('chapter sidebar', newkey)
def set_hotkey(self, hotkey, newkey):
self.hotkeys[hotkey].setKey(QtGui.QKeySequence(newkey))