More stupid PyQt enums

This commit is contained in:
Kovid Goyal 2020-12-19 14:16:02 +05:30
parent 17e875a326
commit f80f13c607
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
9 changed files with 23 additions and 22 deletions

View File

@ -504,7 +504,7 @@ class Text(Base):
else:
w = EditWithComplete(parent)
w.set_separator(None)
w.setSizeAdjustPolicy(w.AdjustToMinimumContentsLengthWithIcon)
w.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
w.setMinimumContentsLength(25)
self.set_to_undefined = w.clearEditText
self.widgets = [QLabel(label_string(self.col_metadata['name']), parent)]
@ -578,7 +578,7 @@ class Series(Base):
def setup_ui(self, parent):
w = EditWithComplete(parent)
w.set_separator(None)
w.setSizeAdjustPolicy(w.AdjustToMinimumContentsLengthWithIcon)
w.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
w.setMinimumContentsLength(25)
self.name_widget = w
self.widgets = [QLabel(label_string(self.col_metadata['name']), parent)]
@ -1156,7 +1156,7 @@ class BulkSeries(BulkBase):
self.make_widgets(parent, EditWithComplete)
values = self.all_values = list(self.db.all_custom(num=self.col_id))
values.sort(key=sort_key)
self.main_widget.setSizeAdjustPolicy(self.main_widget.AdjustToMinimumContentsLengthWithIcon)
self.main_widget.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.main_widget.setMinimumContentsLength(25)
self.widgets.append(QLabel('', parent))
w = QWidget(parent)
@ -1401,7 +1401,7 @@ class BulkText(BulkBase):
self.make_widgets(parent, EditWithComplete)
self.main_widget.set_separator(None)
self.main_widget.setSizeAdjustPolicy(
self.main_widget.AdjustToMinimumContentsLengthWithIcon)
QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.main_widget.setMinimumContentsLength(25)
self.ignore_change_signals = False
self.parent = parent

View File

@ -40,7 +40,7 @@ class AddEmptyBookDialog(QDialog):
self.authors_combo = EditWithComplete(self)
self.authors_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.authors_combo.setEditable(True)
self._layout.addWidget(self.authors_combo, 3, 0, 1, 1)
self.initialize_authors(db, author)
@ -56,7 +56,7 @@ class AddEmptyBookDialog(QDialog):
self.series_combo = EditWithComplete(self)
self.series_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.series_combo.setEditable(True)
self._layout.addWidget(self.series_combo, 5, 0, 1, 1)
self.initialize_series(db, series)

View File

@ -9,7 +9,7 @@ from io import BytesIO
from threading import Thread
from PyQt5.Qt import (
QCompleter, QCoreApplication, QDateTime, QDialog, QDialogButtonBox, QFont, QProgressBar,
QCompleter, QCoreApplication, QDateTime, QDialog, QDialogButtonBox, QFont, QProgressBar, QComboBox,
QGridLayout, QInputDialog, QLabel, QLineEdit, QSize, Qt, QVBoxLayout, pyqtSignal, QApplication
)
@ -1087,7 +1087,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.initialize_publisher()
for x in ('authors', 'publisher', 'series'):
x = getattr(self, x)
x.setSizeAdjustPolicy(x.AdjustToMinimumContentsLengthWithIcon)
x.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
x.setMinimumContentsLength(25)
def initalize_authors(self):

View File

@ -6,6 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from PyQt5.Qt import QComboBox
from calibre.gui2 import gui_prefs
from calibre.gui2.complete2 import EditWithComplete
from calibre.utils.localization import lang_map_for_ui
@ -20,7 +21,7 @@ class LanguagesEdit(EditWithComplete):
self.refresh_recently_used()
EditWithComplete.__init__(self, parent, sort_func=self.sort_language_items_key)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.setMinimumContentsLength(20)
self._lang_map = lang_map_for_ui()
self.names_with_commas = [x for x in itervalues(self._lang_map) if ',' in x]

View File

@ -15,7 +15,7 @@ from datetime import date, datetime
from PyQt5.Qt import (
QAction, QApplication, QDateTime, QDialog, QDialogButtonBox, QDoubleSpinBox,
QGridLayout, QIcon, QKeySequence, QLabel, QLineEdit, QListWidgetItem, QMenu,
QMessageBox, QPixmap, QPlainTextEdit, QSize, QSizePolicy, Qt, QToolButton,
QMessageBox, QPixmap, QPlainTextEdit, QSize, QSizePolicy, Qt, QToolButton, QComboBox,
QUndoCommand, QUndoStack, QUrl, QVBoxLayout, QWidget, pyqtSignal
)
@ -344,7 +344,7 @@ class AuthorsEdit(EditWithComplete, ToMetadataMixin):
self.setToolTip(self.TOOLTIP)
self.setWhatsThis(self.TOOLTIP)
self.setEditable(True)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.manage_authors_signal = manage_authors
manage_authors.triggered.connect(self.manage_authors)
self.lineEdit().createStandardContextMenu = self.createStandardContextMenu
@ -601,7 +601,7 @@ class SeriesEdit(EditWithComplete, ToMetadataMixin):
self.set_separator(None)
self.dialog = parent
self.setSizeAdjustPolicy(
self.AdjustToMinimumContentsLengthWithIcon)
QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.setToolTip(self.TOOLTIP)
self.setWhatsThis(self.TOOLTIP)
self.setEditable(True)
@ -1770,7 +1770,7 @@ class PublisherEdit(EditWithComplete, ToMetadataMixin): # {{{
self.currentTextChanged.connect(self.data_changed)
self.set_separator(None)
self.setSizeAdjustPolicy(
self.AdjustToMinimumContentsLengthWithIcon)
QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.books_to_refresh = set()
self.clear_button = QToolButton(parent)
self.clear_button.setIcon(QIcon(I('trash.png')))

View File

@ -143,7 +143,7 @@ class ConditionEditor(QWidget): # {{{
self.action_box.currentIndexChanged.connect(self.init_value_box)
for b in (self.column_box, self.action_box):
b.setSizeAdjustPolicy(b.AdjustToMinimumContentsLengthWithIcon)
b.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
b.setMinimumContentsLength(20)
@property
@ -358,7 +358,7 @@ class RuleEditor(QDialog): # {{{
v.setIconSize(QSize(32, 32))
self.filename_box.setView(v)
self.orig_filenamebox_view = f.view()
f.setMinimumContentsLength(20), f.setSizeAdjustPolicy(f.AdjustToMinimumContentsLengthWithIcon)
f.setMinimumContentsLength(20), f.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.populate_icon_filenames()
if self.rule_kind == 'color':
@ -433,7 +433,7 @@ class RuleEditor(QDialog): # {{{
if self.rule_kind == 'color':
for b in (self.column_box, ):
b.setSizeAdjustPolicy(b.AdjustToMinimumContentsLengthWithIcon)
b.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
b.setMinimumContentsLength(15)
for key in sorted(displayable_columns(fm),

View File

@ -10,7 +10,7 @@ from operator import attrgetter
from PyQt5.Qt import (
QAbstractListModel, QApplication, QDialog, QDialogButtonBox, QFont, QGridLayout,
QGroupBox, QIcon, QLabel, QListView, QMenu, QModelIndex, QPlainTextEdit,
QGroupBox, QIcon, QLabel, QListView, QMenu, QModelIndex, QPlainTextEdit, QComboBox,
QPushButton, QSizePolicy, QSplitter, QStyle, QStyledItemDelegate, QAbstractItemView, QItemSelectionModel,
QStyleOptionViewItem, Qt, QVBoxLayout, QWidget, pyqtSignal
)
@ -408,7 +408,7 @@ class ConfigWidget(ConfigWidgetBase):
self.search = sb = SearchBox2(self)
sb.sizePolicy().setHorizontalStretch(10)
sb.setSizeAdjustPolicy(sb.AdjustToMinimumContentsLength)
sb.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLength)
sb.setMinimumContentsLength(10)
g.addWidget(self.search, 0, 0, 1, 1)
self.next_button = b = QPushButton(self)

View File

@ -140,7 +140,7 @@ class SearchBox2(QComboBox): # {{{
self.timer.timeout.connect(self.timer_event, type=Qt.ConnectionType.QueuedConnection)
self.setInsertPolicy(self.NoInsert)
self.setMaxCount(self.MAX_COUNT)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.setMinimumContentsLength(25)
self._in_a_search = False
self.tool_tip_text = self.toolTip()
@ -343,7 +343,7 @@ class SavedSearchBox(QComboBox): # {{{
self.setEditable(True)
self.setInsertPolicy(self.NoInsert)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.setMinimumContentsLength(10)
self.tool_tip_text = self.toolTip()

View File

@ -10,7 +10,7 @@ import textwrap
from functools import partial
from PyQt5.Qt import (
Qt, QIcon, QWidget, QHBoxLayout, QVBoxLayout, QToolButton, QLabel, QFrame, QDialog,
Qt, QIcon, QWidget, QHBoxLayout, QVBoxLayout, QToolButton, QLabel, QFrame, QDialog, QComboBox,
QTimer, QMenu, QActionGroup, QAction, QSizePolicy, pyqtSignal)
from calibre.gui2 import error_dialog, question_dialog, gprefs
@ -480,7 +480,7 @@ class TagBrowserBar(QWidget): # {{{
self.item_search = FindBox(parent)
self.item_search.setMinimumContentsLength(5)
self.item_search.setSizeAdjustPolicy(self.item_search.AdjustToMinimumContentsLengthWithIcon)
self.item_search.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
self.item_search.initialize('tag_browser_search')
self.item_search.completer().setCaseSensitivity(Qt.CaseSensitivity.CaseSensitive)
self.item_search.setToolTip(