Fix configure metadata source widget not useable on small screens

This commit is contained in:
Kovid Goyal 2020-12-02 06:59:48 +05:30
parent a67fb90335
commit e38ae0e58e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 36 additions and 22 deletions

View File

@ -6,10 +6,12 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import textwrap, numbers
from PyQt5.Qt import (QWidget, QGridLayout, QGroupBox, QListView, Qt, QSpinBox,
QDoubleSpinBox, QCheckBox, QLineEdit, QComboBox, QLabel)
import numbers
import textwrap
from PyQt5.Qt import (
QCheckBox, QComboBox, QDoubleSpinBox, QGridLayout, QGroupBox, QLabel, QLineEdit,
QListView, QSpinBox, Qt, QVBoxLayout, QWidget
)
from calibre.gui2.preferences.metadata_sources import FieldsModel as FM
from calibre.utils.icu import sort_key
@ -54,35 +56,41 @@ class FieldsModel(FM): # {{{
# }}}
class FieldsList(QListView):
def sizeHint(self):
return self.minimumSizeHint()
class ConfigWidget(QWidget):
def __init__(self, plugin):
QWidget.__init__(self)
self.plugin = plugin
self.l = l = QGridLayout()
self.setLayout(l)
self.overl = l = QVBoxLayout(self)
self.gb = QGroupBox(_('Metadata fields to download'), self)
if plugin.config_help_message:
self.pchm = QLabel(plugin.config_help_message)
self.pchm.setWordWrap(True)
self.pchm.setOpenExternalLinks(True)
l.addWidget(self.pchm, 0, 0, 1, 2)
l.addWidget(self.gb, l.rowCount(), 0, 1, 2)
self.gb.l = QGridLayout()
self.gb.setLayout(self.gb.l)
self.fields_view = v = QListView(self)
self.gb.l.addWidget(v, 0, 0)
l.addWidget(self.pchm, 10)
l.addWidget(self.gb)
self.gb.l = g = QVBoxLayout(self.gb)
g.setContentsMargins(0, 0, 0, 0)
self.fields_view = v = FieldsList(self)
g.addWidget(v)
v.setFlow(v.LeftToRight)
v.setWrapping(True)
v.setResizeMode(v.Adjust)
self.fields_model = FieldsModel(self.plugin)
self.fields_model.initialize()
v.setModel(self.fields_model)
self.memory = []
self.widgets = []
self.l = QGridLayout()
self.l.setContentsMargins(0, 0, 0, 0)
l.addLayout(self.l, 100)
for opt in plugin.options:
self.create_widgets(opt)

View File

@ -7,16 +7,19 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from operator import attrgetter
from PyQt5.Qt import (
QAbstractListModel, QAbstractTableModel, QDialogButtonBox, QFrame, QIcon, QLabel,
QScrollArea, Qt, QVBoxLayout, QWidget, pyqtSignal
)
from PyQt5.Qt import (QAbstractTableModel, Qt, QAbstractListModel, QWidget,
pyqtSignal, QVBoxLayout, QDialogButtonBox, QFrame, QLabel, QIcon)
from calibre.customize.ui import (
all_metadata_plugins, default_disabled_plugins, disable_plugin, enable_plugin,
is_disabled
)
from calibre.ebooks.metadata.sources.prefs import msprefs
from calibre.gui2 import error_dialog, question_dialog
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
from calibre.ebooks.metadata.sources.prefs import msprefs
from calibre.customize.ui import (all_metadata_plugins, is_disabled,
enable_plugin, disable_plugin, default_disabled_plugins)
from calibre.gui2 import error_dialog, question_dialog
from polyglot.builtins import iteritems
@ -275,7 +278,10 @@ class PluginConfig(QWidget): # {{{
l.addWidget(c)
self.config_widget = plugin.config_widget()
self.l.addWidget(self.config_widget)
self.sa = sa = QScrollArea(self)
sa.setWidgetResizable(True)
sa.setWidget(self.config_widget)
l.addWidget(sa)
self.bb = QDialogButtonBox(
QDialogButtonBox.Save|QDialogButtonBox.Cancel,