mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of another .ui file and fix that the confirm location dialog had no parent
This commit is contained in:
parent
822646d494
commit
bc0b5fdcaf
@ -415,7 +415,7 @@ class DeleteAction(InterfaceActionWithLibraryDrop):
|
||||
if on_device:
|
||||
loc = confirm_location('<p>' + _('Some of the selected books are on the attached device. '
|
||||
'<b>Where</b> do you want the selected files deleted from?'),
|
||||
self.gui)
|
||||
name='device-and-or-lib', parent=self.gui)
|
||||
if not loc:
|
||||
return
|
||||
elif loc == 'dev':
|
||||
|
@ -6,25 +6,50 @@ __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' \
|
||||
'2010, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import QDialog, QIcon, Qt
|
||||
from qt.core import QDialog, QIcon, Qt, QVBoxLayout, QHBoxLayout, QSizePolicy, QLabel, QPushButton
|
||||
|
||||
from calibre.gui2.dialogs.confirm_delete_location_ui import Ui_Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
|
||||
|
||||
class Dialog(QDialog, Ui_Dialog):
|
||||
class Dialog(QDialog):
|
||||
|
||||
def __init__(self, msg, name, parent):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
def __init__(self, msg, name, parent, icon='dialog_warning.png'):
|
||||
super().__init__(parent)
|
||||
ic = QIcon.ic(icon)
|
||||
self.setWindowIcon(ic)
|
||||
self.l = l = QVBoxLayout(self)
|
||||
h = QHBoxLayout()
|
||||
la = QLabel(self)
|
||||
sp = QSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Preferred)
|
||||
sp.setHorizontalStretch(0), sp.setVerticalStretch(0)
|
||||
sp.setHeightForWidth(la.sizePolicy().hasHeightForWidth())
|
||||
la.setSizePolicy(sp)
|
||||
la.setPixmap(ic.pixmap(ic.availableSizes()[0]))
|
||||
h.addWidget(la)
|
||||
la = QLabel(msg)
|
||||
h.addWidget(la)
|
||||
la.setWordWrap(True)
|
||||
l.addLayout(h)
|
||||
h = QHBoxLayout()
|
||||
l.addLayout(h)
|
||||
self.button_lib = b = QPushButton(QIcon.ic('lt.png'), _('&Library'), self)
|
||||
h.addWidget(b)
|
||||
self.button_device = b = QPushButton(QIcon.ic('reader.png'), _('&Device'), self)
|
||||
h.addWidget(b)
|
||||
self.button_both = b = QPushButton(QIcon.ic('trash.png'), _('Library &and device'), self)
|
||||
h.addWidget(b)
|
||||
h.addStretch(10)
|
||||
self.button_cancel = b = QPushButton(QIcon.ic('window-close.png'), _('&Cancel'), self)
|
||||
h.addWidget(b)
|
||||
|
||||
self.loc = None
|
||||
self.msg.setText(msg)
|
||||
self.name = name
|
||||
self.buttonBox.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.button_cancel.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
connect_lambda(self.button_lib.clicked, self, lambda self: self.set_loc('lib'))
|
||||
connect_lambda(self.button_device.clicked, self, lambda self: self.set_loc('dev'))
|
||||
connect_lambda(self.button_both.clicked, self, lambda self: self.set_loc('both'))
|
||||
connect_lambda(self.button_cancel.clicked, self, lambda self: self.reject())
|
||||
self.resize(self.sizeHint())
|
||||
|
||||
def set_loc(self, loc):
|
||||
self.loc = loc
|
||||
@ -43,13 +68,13 @@ class Dialog(QDialog, Ui_Dialog):
|
||||
|
||||
|
||||
def confirm_location(msg, name, parent=None, pixmap='dialog_warning.png'):
|
||||
d = Dialog(msg, name, parent)
|
||||
ic = QIcon.ic(pixmap)
|
||||
d.label.setPixmap(ic.pixmap(ic.availableSizes()[0]))
|
||||
d.setWindowIcon(ic)
|
||||
d.resize(d.sizeHint())
|
||||
d = Dialog(msg, name, parent, icon=pixmap)
|
||||
ret = d.exec()
|
||||
d.break_cycles()
|
||||
if ret == QDialog.DialogCode.Accepted:
|
||||
return d.choice()
|
||||
return None
|
||||
return d.choice() if ret == QDialog.DialogCode.Accepted else None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from calibre.gui2 import Application
|
||||
app = Application([])
|
||||
confirm_location('testing this dialog', 'test dialog')
|
||||
|
@ -1,134 +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>459</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Where do you want to delete from?</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../../resources/images.qrc">
|
||||
<normaloff>:/images/dialog_warning.png</normaloff>:/images/dialog_warning.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../resources/images.qrc">:/images/dialog_warning.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="msg">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_lib">
|
||||
<property name="text">
|
||||
<string>Library</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources/images.qrc">
|
||||
<normaloff>:/images/lt.png</normaloff>:/images/lt.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_device">
|
||||
<property name="text">
|
||||
<string>Device</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources/images.qrc">
|
||||
<normaloff>:/images/reader.png</normaloff>:/images/reader.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_both">
|
||||
<property name="text">
|
||||
<string>Library and device</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources/images.qrc">
|
||||
<normaloff>:/images/trash.png</normaloff>:/images/trash.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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