mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
After adding plugin scroll to it in the plugins list
This commit is contained in:
parent
50dc7b1f09
commit
f7ae68a8c9
@ -269,10 +269,14 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=True,
|
|||||||
|
|
||||||
return d.exec_() == yes_button
|
return d.exec_() == yes_button
|
||||||
|
|
||||||
def info_dialog(parent, title, msg, det_msg='', show=False):
|
def info_dialog(parent, title, msg, det_msg='', show=False,
|
||||||
|
show_copy_button=True):
|
||||||
d = MessageBox(QMessageBox.Information, title, msg, QMessageBox.Ok,
|
d = MessageBox(QMessageBox.Information, title, msg, QMessageBox.Ok,
|
||||||
parent, det_msg)
|
parent, det_msg)
|
||||||
d.setIconPixmap(QPixmap(I('dialog_information.png')))
|
d.setIconPixmap(QPixmap(I('dialog_information.png')))
|
||||||
|
if not show_copy_button:
|
||||||
|
d.cb.setVisible(False)
|
||||||
|
|
||||||
if show:
|
if show:
|
||||||
return d.exec_()
|
return d.exec_()
|
||||||
return d
|
return d
|
||||||
|
@ -77,6 +77,16 @@ class PluginModel(QAbstractItemModel): # {{{
|
|||||||
return self.index(j, 0, parent)
|
return self.index(j, 0, parent)
|
||||||
return QModelIndex()
|
return QModelIndex()
|
||||||
|
|
||||||
|
def plugin_to_index_by_properties(self, plugin):
|
||||||
|
for i, category in enumerate(self.categories):
|
||||||
|
parent = self.index(i, 0, QModelIndex())
|
||||||
|
for j, p in enumerate(self._data[category]):
|
||||||
|
if plugin.name == p.name and plugin.type == p.type and \
|
||||||
|
plugin.author == p.author and plugin.version == p.version:
|
||||||
|
return self.index(j, 0, parent)
|
||||||
|
return QModelIndex()
|
||||||
|
|
||||||
|
|
||||||
def refresh_plugin(self, plugin, rescan=False):
|
def refresh_plugin(self, plugin, rescan=False):
|
||||||
if rescan:
|
if rescan:
|
||||||
self.populate()
|
self.populate()
|
||||||
@ -171,7 +181,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
_('Plugin <b>{0}</b> successfully installed under <b>'
|
_('Plugin <b>{0}</b> successfully installed under <b>'
|
||||||
' {1} plugins</b>. You may have to restart calibre '
|
' {1} plugins</b>. You may have to restart calibre '
|
||||||
'for the plugin to take effect.').format(plugin.name, plugin.type),
|
'for the plugin to take effect.').format(plugin.name, plugin.type),
|
||||||
show=True)
|
show=True, show_copy_button=False)
|
||||||
|
idx = self._plugin_model.plugin_to_index_by_properties(plugin)
|
||||||
|
if idx.isValid():
|
||||||
|
self.plugin_view.scrollTo(idx,
|
||||||
|
self.plugin_view.PositionAtCenter)
|
||||||
|
self.plugin_view.scrollTo(idx,
|
||||||
|
self.plugin_view.PositionAtCenter)
|
||||||
else:
|
else:
|
||||||
error_dialog(self, _('No valid plugin path'),
|
error_dialog(self, _('No valid plugin path'),
|
||||||
_('%s is not a valid plugin path')%path).exec_()
|
_('%s is not a valid plugin path')%path).exec_()
|
||||||
@ -201,10 +217,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
if plugin.do_user_config():
|
if plugin.do_user_config():
|
||||||
self._plugin_model.refresh_plugin(plugin)
|
self._plugin_model.refresh_plugin(plugin)
|
||||||
elif op == 'remove':
|
elif op == 'remove':
|
||||||
|
msg = _('Plugin {0} successfully removed').format(plugin.name)
|
||||||
if remove_plugin(plugin):
|
if remove_plugin(plugin):
|
||||||
self._plugin_model.populate()
|
self._plugin_model.populate()
|
||||||
self._plugin_model.reset()
|
self._plugin_model.reset()
|
||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
info_dialog(self, _('Success'), msg, show=True,
|
||||||
|
show_copy_button=False)
|
||||||
else:
|
else:
|
||||||
error_dialog(self, _('Cannot remove builtin plugin'),
|
error_dialog(self, _('Cannot remove builtin plugin'),
|
||||||
plugin.name + _(' cannot be removed. It is a '
|
plugin.name + _(' cannot be removed. It is a '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user