From f80f13c6079515a9e0cd14f184771f12a3d3d957 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Dec 2020 14:16:02 +0530 Subject: [PATCH] More stupid PyQt enums --- src/calibre/gui2/custom_column_widgets.py | 8 ++++---- src/calibre/gui2/dialogs/add_empty_book.py | 4 ++-- src/calibre/gui2/dialogs/metadata_bulk.py | 4 ++-- src/calibre/gui2/languages.py | 3 ++- src/calibre/gui2/metadata/basic_widgets.py | 8 ++++---- src/calibre/gui2/preferences/coloring.py | 6 +++--- src/calibre/gui2/preferences/tweaks.py | 4 ++-- src/calibre/gui2/search_box.py | 4 ++-- src/calibre/gui2/tag_browser/ui.py | 4 ++-- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py index 9da24c9b05..fe500125a2 100644 --- a/src/calibre/gui2/custom_column_widgets.py +++ b/src/calibre/gui2/custom_column_widgets.py @@ -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 diff --git a/src/calibre/gui2/dialogs/add_empty_book.py b/src/calibre/gui2/dialogs/add_empty_book.py index 1dbe1abe44..fa745e6dbd 100644 --- a/src/calibre/gui2/dialogs/add_empty_book.py +++ b/src/calibre/gui2/dialogs/add_empty_book.py @@ -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) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 256f01a4b8..dba1080c04 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -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): diff --git a/src/calibre/gui2/languages.py b/src/calibre/gui2/languages.py index ed38960d17..e49dce1c86 100644 --- a/src/calibre/gui2/languages.py +++ b/src/calibre/gui2/languages.py @@ -6,6 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2011, Kovid Goyal ' __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] diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index 5e3dd76408..21e4167fa9 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -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'))) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index ecaa137053..866b391168 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -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), diff --git a/src/calibre/gui2/preferences/tweaks.py b/src/calibre/gui2/preferences/tweaks.py index 4987d39413..8136584abf 100644 --- a/src/calibre/gui2/preferences/tweaks.py +++ b/src/calibre/gui2/preferences/tweaks.py @@ -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) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index ea2ebe61db..de171b7aa9 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -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() diff --git a/src/calibre/gui2/tag_browser/ui.py b/src/calibre/gui2/tag_browser/ui.py index b37bfb56ef..ccfc3d0953 100644 --- a/src/calibre/gui2/tag_browser/ui.py +++ b/src/calibre/gui2/tag_browser/ui.py @@ -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(