mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-12-14 00:55:03 -05:00
Allow installing new metadata sources from the configure metadata download window
This commit is contained in:
parent
faa13c1899
commit
81d16882bf
@ -538,6 +538,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
|
|||||||
|
|
||||||
initial_extra_size = QSize(350, 100)
|
initial_extra_size = QSize(350, 100)
|
||||||
forum_label_text = _('Plugin homepage')
|
forum_label_text = _('Plugin homepage')
|
||||||
|
warn_about_neededing_restart = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gui(self):
|
def gui(self):
|
||||||
@ -546,6 +547,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
|
|||||||
|
|
||||||
def __init__(self, parent, initial_filter=FILTER_UPDATE_AVAILABLE, initial_category: Category | None = None):
|
def __init__(self, parent, initial_filter=FILTER_UPDATE_AVAILABLE, initial_category: Category | None = None):
|
||||||
SizePersistedDialog.__init__(self, parent, 'Plugin Updater plugin:plugin updater dialog')
|
SizePersistedDialog.__init__(self, parent, 'Plugin Updater plugin:plugin updater dialog')
|
||||||
|
self.number_installed = 0
|
||||||
self.forum_link = None
|
self.forum_link = None
|
||||||
self.zip_url = None
|
self.zip_url = None
|
||||||
self.model = None
|
self.model = None
|
||||||
@ -855,7 +857,11 @@ class PluginUpdaterDialog(SizePersistedDialog):
|
|||||||
widget.gui = self.gui
|
widget.gui = self.gui
|
||||||
widget.check_for_add_to_toolbars(plugin, previously_installed=plugin.name in installed_plugins)
|
widget.check_for_add_to_toolbars(plugin, previously_installed=plugin.name in installed_plugins)
|
||||||
self.gui.status_bar.showMessage(_('Plugin installed: %s') % display_plugin.name)
|
self.gui.status_bar.showMessage(_('Plugin installed: %s') % display_plugin.name)
|
||||||
|
if self.warn_about_neededing_restart:
|
||||||
do_restart = notify_on_successful_install(self.gui, plugin)
|
do_restart = notify_on_successful_install(self.gui, plugin)
|
||||||
|
else:
|
||||||
|
info_dialog(self, _('Plugin installed'), _('The plugin {} was successfully installed.').format(display_plugin.name), show=True)
|
||||||
|
self.number_installed += 1
|
||||||
display_plugin.plugin = plugin
|
display_plugin.plugin = plugin
|
||||||
# We cannot read the 'actual' version information as the plugin will not be loaded yet
|
# We cannot read the 'actual' version information as the plugin will not be loaded yet
|
||||||
display_plugin.installed_version = display_plugin.available_version
|
display_plugin.installed_version = display_plugin.available_version
|
||||||
|
|||||||
@ -322,7 +322,11 @@ class MetadataSingleDialogBase(QDialog):
|
|||||||
|
|
||||||
self.fetch_metadata_button = b = CenteredToolButton(QIcon.ic('download-metadata.png'), _('&Download metadata'), self)
|
self.fetch_metadata_button = b = CenteredToolButton(QIcon.ic('download-metadata.png'), _('&Download metadata'), self)
|
||||||
b.setPopupMode(QToolButton.ToolButtonPopupMode.DelayedPopup)
|
b.setPopupMode(QToolButton.ToolButtonPopupMode.DelayedPopup)
|
||||||
b.setToolTip(_('Download metadata for this book [%s]') % self.download_shortcut.key().toString(QKeySequence.SequenceFormat.NativeText))
|
b.setToolTip(_(
|
||||||
|
'Download metadata for this book [{}]\n\nMetadata includes title, authors, series, covers, etc.\n'
|
||||||
|
'For improved results, you can install more metadata sources,\n'
|
||||||
|
'by clicking the configure button to the right.').format(
|
||||||
|
self.download_shortcut.key().toString(QKeySequence.SequenceFormat.NativeText)))
|
||||||
self.fetch_metadata_button.clicked.connect(self.fetch_metadata)
|
self.fetch_metadata_button.clicked.connect(self.fetch_metadata)
|
||||||
self.fetch_metadata_menu = m = QMenu(self.fetch_metadata_button)
|
self.fetch_metadata_menu = m = QMenu(self.fetch_metadata_button)
|
||||||
m.addAction(QIcon.ic('edit-undo.png'), _('Undo last metadata download'), self.undo_fetch_metadata)
|
m.addAction(QIcon.ic('edit-undo.png'), _('Undo last metadata download'), self.undo_fetch_metadata)
|
||||||
|
|||||||
@ -5,8 +5,6 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from operator import attrgetter
|
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractListModel,
|
QAbstractListModel,
|
||||||
QAbstractTableModel,
|
QAbstractTableModel,
|
||||||
@ -29,6 +27,7 @@ from calibre.ebooks.metadata.sources.prefs import msprefs
|
|||||||
from calibre.gui2 import error_dialog, question_dialog
|
from calibre.gui2 import error_dialog, question_dialog
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||||
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
|
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
|
||||||
|
from calibre.utils.icu import primary_sort_key
|
||||||
from calibre.utils.localization import ngettext
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
@ -43,10 +42,16 @@ class SourcesModel(QAbstractTableModel): # {{{
|
|||||||
self.enabled_overrides = {}
|
self.enabled_overrides = {}
|
||||||
self.cover_overrides = {}
|
self.cover_overrides = {}
|
||||||
|
|
||||||
|
def reload_plugins(self):
|
||||||
|
self.beginResetModel()
|
||||||
|
self.plugins = list(all_metadata_plugins())
|
||||||
|
self.plugins.sort(key=lambda p: primary_sort_key(p.name))
|
||||||
|
self.endResetModel()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
self.plugins = list(all_metadata_plugins())
|
self.plugins = list(all_metadata_plugins())
|
||||||
self.plugins.sort(key=attrgetter('name'))
|
self.plugins.sort(key=lambda p: primary_sort_key(p.name))
|
||||||
self.enabled_overrides = {}
|
self.enabled_overrides = {}
|
||||||
self.cover_overrides = {}
|
self.cover_overrides = {}
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
@ -352,6 +357,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
l = self.page.layout()
|
l = self.page.layout()
|
||||||
l.setStretch(0, 1)
|
l.setStretch(0, 1)
|
||||||
l.setStretch(1, 1)
|
l.setStretch(1, 1)
|
||||||
|
self.add_new_source_button.clicked.connect(self.add_new_source)
|
||||||
|
|
||||||
|
def add_new_source(self):
|
||||||
|
from calibre.gui2.dialogs.plugin_updater import FILTER_NOT_INSTALLED, Category, PluginUpdaterDialog
|
||||||
|
d = PluginUpdaterDialog(self, initial_filter=FILTER_NOT_INSTALLED, initial_category=Category.MetadataSource)
|
||||||
|
d.warn_about_neededing_restart = False
|
||||||
|
d.exec()
|
||||||
|
if d.number_installed:
|
||||||
|
self.sources_model.reload_plugins()
|
||||||
|
self.fields_model.initialize()
|
||||||
|
|
||||||
def context_menu(self, pos):
|
def context_menu(self, pos):
|
||||||
m = QMenu(self)
|
m = QMenu(self)
|
||||||
|
|||||||
@ -77,6 +77,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="add_new_source_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add new source</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/plus.png</normaloff>:/images/plus.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -164,7 +175,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>350</width>
|
<width>350</width>
|
||||||
<height>441</height>
|
<height>455</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user