mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Reload store plugins when they are enabled and disabled.
This commit is contained in:
parent
baf16af89f
commit
1ec3860ee6
@ -18,6 +18,10 @@ class StoreAction(InterfaceAction):
|
|||||||
def genesis(self):
|
def genesis(self):
|
||||||
self.qaction.triggered.connect(self.search)
|
self.qaction.triggered.connect(self.search)
|
||||||
self.store_menu = QMenu()
|
self.store_menu = QMenu()
|
||||||
|
self.load_menu()
|
||||||
|
|
||||||
|
def load_menu(self):
|
||||||
|
self.store_menu.clear()
|
||||||
self.store_menu.addAction(_('Search'), self.search)
|
self.store_menu.addAction(_('Search'), self.search)
|
||||||
self.store_menu.addSeparator()
|
self.store_menu.addSeparator()
|
||||||
for n, p in self.gui.istores.items():
|
for n, p in self.gui.istores.items():
|
||||||
|
@ -217,6 +217,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.search.search.connect(self.find)
|
self.search.search.connect(self.find)
|
||||||
self.next_button.clicked.connect(self.find_next)
|
self.next_button.clicked.connect(self.find_next)
|
||||||
self.previous_button.clicked.connect(self.find_previous)
|
self.previous_button.clicked.connect(self.find_previous)
|
||||||
|
self.changed_signal.connect(self.reload_store_plugins)
|
||||||
|
|
||||||
def find(self, query):
|
def find(self, query):
|
||||||
idx = self._plugin_model.find(query)
|
idx = self._plugin_model.find(query)
|
||||||
@ -342,6 +343,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
plugin.name + _(' cannot be removed. It is a '
|
plugin.name + _(' cannot be removed. It is a '
|
||||||
'builtin plugin. Try disabling it instead.')).exec_()
|
'builtin plugin. Try disabling it instead.')).exec_()
|
||||||
|
|
||||||
|
def reload_store_plugins(self):
|
||||||
|
self.gui.load_store_plugins()
|
||||||
|
if self.gui.iactions.has_key('Store'):
|
||||||
|
self.gui.iactions['Store'].load_menu()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from PyQt4.Qt import QApplication
|
from PyQt4.Qt import QApplication
|
||||||
|
@ -118,10 +118,27 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
ac.plugin_path = action.plugin_path
|
ac.plugin_path = action.plugin_path
|
||||||
ac.interface_action_base_plugin = action
|
ac.interface_action_base_plugin = action
|
||||||
self.add_iaction(ac)
|
self.add_iaction(ac)
|
||||||
# Stores
|
self.load_store_plugins()
|
||||||
|
|
||||||
|
def init_iaction(self, action):
|
||||||
|
ac = action.load_actual_plugin(self)
|
||||||
|
ac.plugin_path = action.plugin_path
|
||||||
|
ac.interface_action_base_plugin = action
|
||||||
|
action.actual_iaction_plugin_loaded = True
|
||||||
|
return ac
|
||||||
|
|
||||||
|
def add_iaction(self, ac):
|
||||||
|
acmap = self.iactions
|
||||||
|
if ac.name in acmap:
|
||||||
|
if ac.priority >= acmap[ac.name].priority:
|
||||||
|
acmap[ac.name] = ac
|
||||||
|
else:
|
||||||
|
acmap[ac.name] = ac
|
||||||
|
|
||||||
|
def load_store_plugins(self):
|
||||||
self.istores = OrderedDict()
|
self.istores = OrderedDict()
|
||||||
for store in store_plugins():
|
for store in store_plugins():
|
||||||
if opts.ignore_plugins and store.plugin_path is not None:
|
if self.opts.ignore_plugins and store.plugin_path is not None:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
st = self.init_istore(store)
|
st = self.init_istore(store)
|
||||||
@ -134,13 +151,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
raise
|
raise
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def init_iaction(self, action):
|
|
||||||
ac = action.load_actual_plugin(self)
|
|
||||||
ac.plugin_path = action.plugin_path
|
|
||||||
ac.interface_action_base_plugin = action
|
|
||||||
action.actual_iaction_plugin_loaded = True
|
|
||||||
return ac
|
|
||||||
|
|
||||||
def init_istore(self, store):
|
def init_istore(self, store):
|
||||||
st = store.load_actual_plugin(self)
|
st = store.load_actual_plugin(self)
|
||||||
st.plugin_path = store.plugin_path
|
st.plugin_path = store.plugin_path
|
||||||
@ -148,14 +158,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
store.actual_istore_plugin_loaded = True
|
store.actual_istore_plugin_loaded = True
|
||||||
return st
|
return st
|
||||||
|
|
||||||
def add_iaction(self, ac):
|
|
||||||
acmap = self.iactions
|
|
||||||
if ac.name in acmap:
|
|
||||||
if ac.priority >= acmap[ac.name].priority:
|
|
||||||
acmap[ac.name] = ac
|
|
||||||
else:
|
|
||||||
acmap[ac.name] = ac
|
|
||||||
|
|
||||||
def add_istore(self, st):
|
def add_istore(self, st):
|
||||||
stmap = self.istores
|
stmap = self.istores
|
||||||
if st.name in stmap:
|
if st.name in stmap:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user