mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround for weird PyQt return with error set in the conversion dialog
Probably a regression in the latest version of PyQt, but rather than track it down, easier to just get rid of the .ui file anyway.
This commit is contained in:
parent
38b5c97eeb
commit
b71bd6478b
@ -8,12 +8,15 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from PyQt5.Qt import QAbstractListModel, Qt, QFont, QModelIndex, QDialog, QCoreApplication, QSize
|
from PyQt5.Qt import (
|
||||||
|
QAbstractListModel, Qt, QFont, QModelIndex, QDialog, QCoreApplication,
|
||||||
|
QSize, QDialogButtonBox, QGridLayout, QHBoxLayout, QCheckBox, QLabel,
|
||||||
|
QIcon, QComboBox, QListView, QSizePolicy, QSpacerItem, QStackedWidget,
|
||||||
|
QVBoxLayout, QFrame, QWidget, QTextEdit, QScrollArea, QRect)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.ebooks.conversion.config import (
|
from calibre.ebooks.conversion.config import (
|
||||||
GuiRecommendations, save_specifics, sort_formats_by_preference, get_input_format_for_book, get_output_formats)
|
GuiRecommendations, save_specifics, sort_formats_by_preference, get_input_format_for_book, get_output_formats)
|
||||||
from calibre.gui2.convert.single_ui import Ui_Dialog
|
|
||||||
from calibre.gui2.convert.metadata import MetadataWidget
|
from calibre.gui2.convert.metadata import MetadataWidget
|
||||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||||
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
||||||
@ -56,7 +59,7 @@ class GroupModel(QAbstractListModel):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Config(QDialog, Ui_Dialog):
|
class Config(QDialog):
|
||||||
'''
|
'''
|
||||||
Configuration dialog for single book conversion. If accepted, has the
|
Configuration dialog for single book conversion. If accepted, has the
|
||||||
following important attributes
|
following important attributes
|
||||||
@ -72,7 +75,7 @@ class Config(QDialog, Ui_Dialog):
|
|||||||
def __init__(self, parent, db, book_id,
|
def __init__(self, parent, db, book_id,
|
||||||
preferred_input_format=None, preferred_output_format=None):
|
preferred_input_format=None, preferred_output_format=None):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi()
|
||||||
self.opt_individual_saved_settings.setVisible(False)
|
self.opt_individual_saved_settings.setVisible(False)
|
||||||
self.db, self.book_id = db, book_id
|
self.db, self.book_id = db, book_id
|
||||||
|
|
||||||
@ -96,6 +99,102 @@ class Config(QDialog, Ui_Dialog):
|
|||||||
else:
|
else:
|
||||||
self.resize(self.sizeHint())
|
self.resize(self.sizeHint())
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.setObjectName("Dialog")
|
||||||
|
self.resize(1024, 700)
|
||||||
|
self.setWindowIcon(QIcon(I('convert.png')))
|
||||||
|
self.gridLayout = QGridLayout(self)
|
||||||
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
|
self.horizontalLayout = QHBoxLayout()
|
||||||
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
|
self.input_label = QLabel(self)
|
||||||
|
self.input_label.setObjectName("input_label")
|
||||||
|
self.horizontalLayout.addWidget(self.input_label)
|
||||||
|
self.input_formats = QComboBox(self)
|
||||||
|
self.input_formats.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
|
self.input_formats.setMinimumContentsLength(5)
|
||||||
|
self.input_formats.setObjectName("input_formats")
|
||||||
|
self.horizontalLayout.addWidget(self.input_formats)
|
||||||
|
self.opt_individual_saved_settings = QCheckBox(self)
|
||||||
|
self.opt_individual_saved_settings.setObjectName("opt_individual_saved_settings")
|
||||||
|
self.horizontalLayout.addWidget(self.opt_individual_saved_settings)
|
||||||
|
spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||||
|
self.horizontalLayout.addItem(spacerItem)
|
||||||
|
self.label_2 = QLabel(self)
|
||||||
|
self.label_2.setObjectName("label_2")
|
||||||
|
self.horizontalLayout.addWidget(self.label_2)
|
||||||
|
self.output_formats = QComboBox(self)
|
||||||
|
self.output_formats.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
|
self.output_formats.setMinimumContentsLength(5)
|
||||||
|
self.output_formats.setObjectName("output_formats")
|
||||||
|
self.horizontalLayout.addWidget(self.output_formats)
|
||||||
|
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 2)
|
||||||
|
self.groups = QListView(self)
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(1)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.groups.sizePolicy().hasHeightForWidth())
|
||||||
|
self.groups.setSizePolicy(sizePolicy)
|
||||||
|
self.groups.setTabKeyNavigation(True)
|
||||||
|
self.groups.setIconSize(QSize(48, 48))
|
||||||
|
self.groups.setWordWrap(True)
|
||||||
|
self.groups.setObjectName("groups")
|
||||||
|
self.gridLayout.addWidget(self.groups, 1, 0, 3, 1)
|
||||||
|
self.scrollArea = QScrollArea(self)
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(4)
|
||||||
|
sizePolicy.setVerticalStretch(10)
|
||||||
|
sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth())
|
||||||
|
self.scrollArea.setSizePolicy(sizePolicy)
|
||||||
|
self.scrollArea.setFrameShape(QFrame.NoFrame)
|
||||||
|
self.scrollArea.setLineWidth(0)
|
||||||
|
self.scrollArea.setWidgetResizable(True)
|
||||||
|
self.scrollArea.setObjectName("scrollArea")
|
||||||
|
self.scrollAreaWidgetContents = QWidget()
|
||||||
|
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 810, 494))
|
||||||
|
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
|
||||||
|
self.verticalLayout_3 = QVBoxLayout(self.scrollAreaWidgetContents)
|
||||||
|
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.verticalLayout_3.setObjectName("verticalLayout_3")
|
||||||
|
self.stack = QStackedWidget(self.scrollAreaWidgetContents)
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.stack.sizePolicy().hasHeightForWidth())
|
||||||
|
self.stack.setSizePolicy(sizePolicy)
|
||||||
|
self.stack.setObjectName("stack")
|
||||||
|
self.page = QWidget()
|
||||||
|
self.page.setObjectName("page")
|
||||||
|
self.stack.addWidget(self.page)
|
||||||
|
self.page_2 = QWidget()
|
||||||
|
self.page_2.setObjectName("page_2")
|
||||||
|
self.stack.addWidget(self.page_2)
|
||||||
|
self.verticalLayout_3.addWidget(self.stack)
|
||||||
|
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
|
||||||
|
self.gridLayout.addWidget(self.scrollArea, 1, 1, 1, 1)
|
||||||
|
self.buttonBox = QDialogButtonBox(self)
|
||||||
|
self.buttonBox.setOrientation(Qt.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok|QDialogButtonBox.RestoreDefaults)
|
||||||
|
self.buttonBox.setObjectName("buttonBox")
|
||||||
|
self.gridLayout.addWidget(self.buttonBox, 3, 1, 1, 1)
|
||||||
|
self.help = QTextEdit(self)
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.help.sizePolicy().hasHeightForWidth())
|
||||||
|
self.help.setSizePolicy(sizePolicy)
|
||||||
|
self.help.setMaximumSize(QSize(16777215, 130))
|
||||||
|
self.help.setObjectName("help")
|
||||||
|
self.gridLayout.addWidget(self.help, 2, 1, 1, 1)
|
||||||
|
self.input_label.setBuddy(self.input_formats)
|
||||||
|
self.label_2.setBuddy(self.output_formats)
|
||||||
|
self.input_label.setText(_("&Input format:"))
|
||||||
|
self.opt_individual_saved_settings.setText(_("Use &saved conversion settings for individual books"))
|
||||||
|
self.label_2.setText(_("&Output format:"))
|
||||||
|
|
||||||
|
self.buttonBox.accepted.connect(self.accept)
|
||||||
|
self.buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
desktop = QCoreApplication.instance().desktop()
|
desktop = QCoreApplication.instance().desktop()
|
||||||
geom = desktop.availableGeometry(self)
|
geom = desktop.availableGeometry(self)
|
||||||
|
@ -1,221 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1024</width>
|
|
||||||
<height>700</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<property name="windowIcon">
|
|
||||||
<iconset resource="../../../../resources/images.qrc">
|
|
||||||
<normaloff>:/images/convert.png</normaloff>:/images/convert.png</iconset>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="input_label">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Input format:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>input_formats</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="input_formats">
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="minimumContentsLength">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="opt_individual_saved_settings">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use &saved conversion settings for individual books</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Output format:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>output_formats</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="output_formats">
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="minimumContentsLength">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" rowspan="3">
|
|
||||||
<widget class="QListView" name="groups">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="tabKeyNavigation">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>48</width>
|
|
||||||
<height>48</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="spacing">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>4</horstretch>
|
|
||||||
<verstretch>10</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="lineWidth">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>810</width>
|
|
||||||
<height>494</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QStackedWidget" name="stack">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="page"/>
|
|
||||||
<widget class="QWidget" name="page_2"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QTextEdit" name="help">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>130</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="../../../../resources/images.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Loading…
x
Reference in New Issue
Block a user