mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of the ResizableDialog class
This commit is contained in:
parent
16db1cad28
commit
d90586170a
@ -776,16 +776,15 @@ def decouple(prefix):
|
||||
|
||||
class ResizableDialog(QDialog):
|
||||
|
||||
# This class is present only for backwards compat with third party plugins
|
||||
# that might use it. Do not use it in new code.
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
QDialog.__init__(self, *args)
|
||||
self.setupUi(self)
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
geom = desktop.availableGeometry(self)
|
||||
nh, nw = geom.height()-25, geom.width()-10
|
||||
if nh < 0:
|
||||
nh = max(800, self.height())
|
||||
if nw < 0:
|
||||
nw = max(600, self.height())
|
||||
nh, nw = max(550, geom.height()-25), max(700, geom.width()-10)
|
||||
nh = min(self.height(), nh)
|
||||
nw = min(self.width(), nw)
|
||||
self.resize(nw, nh)
|
||||
|
@ -6,11 +6,10 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import shutil
|
||||
|
||||
from PyQt5.Qt import QModelIndex
|
||||
from PyQt5.Qt import QModelIndex, QDialog
|
||||
|
||||
from calibre.gui2.convert.single import (Config, sort_formats_by_preference,
|
||||
GroupModel, gprefs, get_output_formats)
|
||||
from calibre.gui2 import ResizableDialog
|
||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
||||
from calibre.gui2.convert.search_and_replace import SearchAndReplaceWidget
|
||||
@ -26,7 +25,8 @@ class BulkConfig(Config):
|
||||
|
||||
def __init__(self, parent, db, preferred_output_format=None,
|
||||
has_saved_settings=True):
|
||||
ResizableDialog.__init__(self, parent)
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
|
||||
self.setup_output_formats(db, preferred_output_format)
|
||||
self.db = db
|
||||
@ -59,6 +59,8 @@ class BulkConfig(Config):
|
||||
geom = gprefs.get('convert_bulk_dialog_geom', None)
|
||||
if geom:
|
||||
self.restoreGeometry(geom)
|
||||
else:
|
||||
self.resize(self.sizeHint())
|
||||
|
||||
def setup_pipeline(self, *args):
|
||||
oidx = self.groups.currentIndex().row()
|
||||
@ -132,12 +134,12 @@ class BulkConfig(Config):
|
||||
x = w.commit(save_defaults=False)
|
||||
recs.update(x)
|
||||
self._recommendations = recs
|
||||
ResizableDialog.accept(self)
|
||||
QDialog.accept(self)
|
||||
|
||||
def done(self, r):
|
||||
if self.isVisible():
|
||||
gprefs['convert_bulk_dialog_geom'] = \
|
||||
bytearray(self.saveGeometry())
|
||||
return ResizableDialog.done(self, r)
|
||||
return QDialog.done(self, r)
|
||||
|
||||
|
||||
|
@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import cPickle, shutil
|
||||
|
||||
from PyQt5.Qt import QAbstractListModel, Qt, QFont, QModelIndex
|
||||
from PyQt5.Qt import QAbstractListModel, Qt, QFont, QModelIndex, QDialog, QCoreApplication, QSize
|
||||
|
||||
from calibre.gui2 import ResizableDialog, gprefs
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.ebooks.conversion.config import (GuiRecommendations, save_specifics,
|
||||
load_specifics)
|
||||
from calibre.gui2.convert.single_ui import Ui_Dialog
|
||||
@ -127,7 +127,7 @@ def get_input_format_for_book(db, book_id, pref):
|
||||
return input_format, input_formats
|
||||
|
||||
|
||||
class Config(ResizableDialog, Ui_Dialog):
|
||||
class Config(QDialog, Ui_Dialog):
|
||||
'''
|
||||
Configuration dialog for single book conversion. If accepted, has the
|
||||
following important attributes
|
||||
@ -142,7 +142,8 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
|
||||
def __init__(self, parent, db, book_id,
|
||||
preferred_input_format=None, preferred_output_format=None):
|
||||
ResizableDialog.__init__(self, parent)
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.opt_individual_saved_settings.setVisible(False)
|
||||
self.db, self.book_id = db, book_id
|
||||
|
||||
@ -162,6 +163,14 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
geom = gprefs.get('convert_single_dialog_geom', None)
|
||||
if geom:
|
||||
self.restoreGeometry(geom)
|
||||
else:
|
||||
self.resize(self.sizeHint())
|
||||
|
||||
def sizeHint(self):
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
geom = desktop.availableGeometry(self)
|
||||
nh, nw = max(300, geom.height()-50), max(400, geom.width()-70)
|
||||
return QSize(nw, nh)
|
||||
|
||||
def restore_defaults(self):
|
||||
delete_specifics(self.db, self.book_id)
|
||||
@ -277,17 +286,17 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
recs['gui_preferred_input_format'] = self.input_format
|
||||
save_specifics(self.db, self.book_id, recs)
|
||||
self.break_cycles()
|
||||
ResizableDialog.accept(self)
|
||||
QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
self.break_cycles()
|
||||
ResizableDialog.reject(self)
|
||||
QDialog.reject(self)
|
||||
|
||||
def done(self, r):
|
||||
if self.isVisible():
|
||||
gprefs['convert_single_dialog_geom'] = \
|
||||
bytearray(self.saveGeometry())
|
||||
return ResizableDialog.done(self, r)
|
||||
return QDialog.done(self, r)
|
||||
|
||||
def break_cycles(self):
|
||||
for i in range(self.stack.count()):
|
||||
|
@ -8,12 +8,14 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, sys, importlib
|
||||
|
||||
from PyQt5.Qt import QDialog, QCoreApplication, QSize
|
||||
|
||||
from calibre.customize.ui import config
|
||||
from calibre.gui2.dialogs.catalog_ui import Ui_Dialog
|
||||
from calibre.gui2 import dynamic, ResizableDialog, info_dialog
|
||||
from calibre.gui2 import dynamic, info_dialog
|
||||
from calibre.customize.ui import catalog_plugins
|
||||
|
||||
class Catalog(ResizableDialog, Ui_Dialog):
|
||||
class Catalog(QDialog, Ui_Dialog):
|
||||
|
||||
''' Catalog Dialog builder'''
|
||||
|
||||
@ -22,7 +24,8 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
||||
from calibre import prints as info
|
||||
from PyQt5.uic import compileUi
|
||||
|
||||
ResizableDialog.__init__(self, parent)
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.dbspec, self.ids = dbspec, ids
|
||||
|
||||
# Display the number of books we've been passed
|
||||
@ -124,6 +127,14 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
||||
geom = dynamic.get('catalog_window_geom', None)
|
||||
if geom is not None:
|
||||
self.restoreGeometry(bytes(geom))
|
||||
else:
|
||||
self.resize(self.sizeHint())
|
||||
|
||||
def sizeHint(self):
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
geom = desktop.availableGeometry(self)
|
||||
nh, nw = max(300, geom.height()-50), max(400, geom.width()-70)
|
||||
return QSize(nw, nh)
|
||||
|
||||
def show_plugin_tab(self, idx):
|
||||
cf = unicode(self.format.currentText()).lower()
|
||||
@ -180,7 +191,7 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
||||
|
||||
def accept(self):
|
||||
self.save_catalog_settings()
|
||||
return ResizableDialog.accept(self)
|
||||
return QDialog.accept(self)
|
||||
|
||||
def help(self):
|
||||
'''
|
||||
@ -207,4 +218,4 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
||||
|
||||
def reject(self):
|
||||
dynamic.set('catalog_window_geom', bytearray(self.saveGeometry()))
|
||||
ResizableDialog.reject(self)
|
||||
QDialog.reject(self)
|
||||
|
@ -9,14 +9,14 @@ from threading import Thread
|
||||
|
||||
from PyQt5.Qt import Qt, QDialog, QGridLayout, QVBoxLayout, QFont, QLabel, \
|
||||
pyqtSignal, QDialogButtonBox, QInputDialog, QLineEdit, \
|
||||
QDateTime, QCompleter
|
||||
QDateTime, QCompleter, QCoreApplication, QSize
|
||||
|
||||
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
from calibre.ebooks.metadata import string_to_authors, authors_to_string, title_sort
|
||||
from calibre.ebooks.metadata.book.formatter import SafeFormat
|
||||
from calibre.gui2.custom_column_widgets import populate_metadata_page
|
||||
from calibre.gui2 import error_dialog, ResizableDialog, UNDEFINED_QDATETIME, \
|
||||
from calibre.gui2 import error_dialog, UNDEFINED_QDATETIME, \
|
||||
gprefs, question_dialog, FunctionDispatcher
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.metadata.basic_widgets import CalendarWidget
|
||||
@ -292,7 +292,7 @@ class MyBlockingBusy(QDialog): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
s_r_functions = {'' : lambda x: x,
|
||||
_('Lower Case') : lambda x: icu_lower(x),
|
||||
@ -311,8 +311,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
]
|
||||
|
||||
def __init__(self, window, rows, model, tab, refresh_books):
|
||||
ResizableDialog.__init__(self, window)
|
||||
Ui_MetadataBulkDialog.__init__(self)
|
||||
QDialog.__init__(self, window)
|
||||
self.setupUi(self)
|
||||
self.model = model
|
||||
self.db = model.db
|
||||
self.refresh_book_list.setChecked(gprefs['refresh_book_list_on_bulk_edit'])
|
||||
@ -380,6 +380,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
geom = gprefs.get('bulk_metadata_window_geometry', None)
|
||||
if geom is not None:
|
||||
self.restoreGeometry(bytes(geom))
|
||||
else:
|
||||
self.resize(self.sizeHint())
|
||||
ct = gprefs.get('bulk_metadata_window_tab', 0)
|
||||
self.central_widget.setCurrentIndex(ct)
|
||||
self.languages.init_langs(self.db)
|
||||
@ -390,6 +392,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
self.button_config_cover_gen.clicked.connect(self.customize_cover_generation)
|
||||
self.exec_()
|
||||
|
||||
def sizeHint(self):
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
geom = desktop.availableGeometry(self)
|
||||
nh, nw = max(300, geom.height()-50), max(400, geom.width()-70)
|
||||
return QSize(nw, nh)
|
||||
|
||||
def customize_cover_generation(self):
|
||||
from calibre.gui2.covers import CoverSettingsDialog
|
||||
d = CoverSettingsDialog(parent=self)
|
||||
@ -942,7 +950,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
def reject(self):
|
||||
self.save_state()
|
||||
ResizableDialog.reject(self)
|
||||
QDialog.reject(self)
|
||||
|
||||
def accept(self):
|
||||
self.save_state()
|
||||
|
@ -11,13 +11,13 @@ import os, errno
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
|
||||
QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont,
|
||||
QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont, QCoreApplication,
|
||||
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem,
|
||||
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut)
|
||||
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut, QDialog)
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
||||
from calibre.gui2 import ResizableDialog, error_dialog, gprefs, pixmap_to_data
|
||||
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
||||
from calibre.gui2.metadata.basic_widgets import (TitleEdit, AuthorsEdit,
|
||||
AuthorSortEdit, TitleSortEdit, SeriesEdit, SeriesIndexEdit, IdentifiersEdit,
|
||||
RatingEdit, PublisherEdit, TagsEdit, FormatsManager, Cover, CommentsEdit,
|
||||
@ -44,7 +44,7 @@ class ScrollArea(QScrollArea):
|
||||
if widget is not None:
|
||||
self.setWidget(widget)
|
||||
|
||||
class MetadataSingleDialogBase(ResizableDialog):
|
||||
class MetadataSingleDialogBase(QDialog):
|
||||
|
||||
view_format = pyqtSignal(object, object)
|
||||
cc_two_column = tweaks['metadata_single_use_2_cols_for_custom_fields']
|
||||
@ -59,11 +59,10 @@ class MetadataSingleDialogBase(ResizableDialog):
|
||||
self.metadata_before_fetch = None
|
||||
self.editing_multiple = editing_multiple
|
||||
self.comments_edit_state_at_apply = {}
|
||||
ResizableDialog.__init__(self, parent)
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi()
|
||||
|
||||
def setupUi(self, *args): # {{{
|
||||
self.resize(990, 670)
|
||||
|
||||
self.download_shortcut = QShortcut(self)
|
||||
self.download_shortcut.setKey(QKeySequence('Ctrl+D',
|
||||
QKeySequence.PortableText))
|
||||
@ -116,8 +115,16 @@ class MetadataSingleDialogBase(ResizableDialog):
|
||||
geom = gprefs.get('metasingle_window_geometry3', None)
|
||||
if geom is not None:
|
||||
self.restoreGeometry(bytes(geom))
|
||||
else:
|
||||
self.resize(self.sizeHint())
|
||||
# }}}
|
||||
|
||||
def sizeHint(self):
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
geom = desktop.availableGeometry(self)
|
||||
nh, nw = max(300, geom.height()-50), max(400, geom.width()-70)
|
||||
return QSize(nw, nh)
|
||||
|
||||
def create_basic_metadata_widgets(self): # {{{
|
||||
self.basic_metadata_widgets = []
|
||||
|
||||
@ -584,11 +591,11 @@ class MetadataSingleDialogBase(ResizableDialog):
|
||||
yes_icon='dot_red.png', no_icon='dot_green.png',
|
||||
default_yes=False, skip_dialog_name='edit-metadata-single-confirm-ok-on-multiple'):
|
||||
return self.do_one(delta=1, apply_changes=False)
|
||||
ResizableDialog.accept(self)
|
||||
QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
self.save_state()
|
||||
ResizableDialog.reject(self)
|
||||
QDialog.reject(self)
|
||||
|
||||
def save_state(self):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user