Skeleton code for Open feedback in Apple driver

This commit is contained in:
Kovid Goyal 2011-03-28 09:04:59 -06:00
parent 517a8d82cd
commit 28a5223eed
3 changed files with 37 additions and 10 deletions

View File

@ -24,6 +24,29 @@ from calibre.utils.logging import Log
from calibre.utils.zipfile import ZipFile from calibre.utils.zipfile import ZipFile
class AppleOpenFeedback(OpenFeedback):
def __init__(self):
OpenFeedback.__init__(self, u'')
def custom_dialog(self, parent):
from PyQt4.Qt import (QDialog, QVBoxLayout, QLabel, QDialogButtonBox)
class Dialog(QDialog):
def __init__(self, p):
QDialog.__init__(self, p)
self.l = l = QVBoxLayout()
self.setLayout(l)
l.addWidget(QLabel('test'))
self.bb = QDialogButtonBox(QDialogButtonBox.OK)
l.addWidget(self.bb)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
return Dialog(parent)
from PIL import Image as PILImage from PIL import Image as PILImage
from lxml import etree from lxml import etree
@ -744,13 +767,7 @@ class ITUNES(DriverBase):
# Display a dialog recommending using 'Connect to iTunes' # Display a dialog recommending using 'Connect to iTunes'
if False and not self.settings().extra_customization[self.SKIP_CONNECT_TO_ITUNES_DIALOG]: if False and not self.settings().extra_customization[self.SKIP_CONNECT_TO_ITUNES_DIALOG]:
raise OpenFeedback('<p>' + ('Click the "Connect/Share" button and choose' raise AppleOpenFeedback()
' "Connect to iTunes" to send books from your calibre library'
' to your Apple iDevice.<p>For more information, see '
'<a href="http://www.mobileread.com/forums/showthread.php?t=118559">'
'Calibre + Apple iDevices FAQ</a>.<p>'
'After following the Quick Start steps outlined in the FAQ, '
'restart calibre.'))
if DEBUG: if DEBUG:
self.log.info(" advanced user mode, directly connecting to iDevice") self.log.info(" advanced user mode, directly connecting to iDevice")

View File

@ -41,6 +41,13 @@ class OpenFeedback(DeviceError):
self.feedback_msg = msg self.feedback_msg = msg
DeviceError.__init__(self, msg) DeviceError.__init__(self, msg)
def custom_dialog(self, parent):
'''
If you need to show the user a custom dialog, instead if just
displaying the feedback_msg, create and return it here.
'''
raise NotImplementedError
class DeviceBusy(ProtocolError): class DeviceBusy(ProtocolError):
""" Raised when device is busy """ """ Raised when device is busy """
def __init__(self, uerr=""): def __init__(self, uerr=""):

View File

@ -164,7 +164,7 @@ class DeviceManager(Thread): # {{{
dev.open(self.current_library_uuid) dev.open(self.current_library_uuid)
except OpenFeedback as e: except OpenFeedback as e:
if dev not in self.ejected_devices: if dev not in self.ejected_devices:
self.open_feedback_msg(dev.get_gui_name(), e.feedback_msg) self.open_feedback_msg(dev.get_gui_name(), e)
self.ejected_devices.add(dev) self.ejected_devices.add(dev)
continue continue
except: except:
@ -618,8 +618,11 @@ class DeviceMixin(object): # {{{
if tweaks['auto_connect_to_folder']: if tweaks['auto_connect_to_folder']:
self.connect_to_folder_named(tweaks['auto_connect_to_folder']) self.connect_to_folder_named(tweaks['auto_connect_to_folder'])
def show_open_feedback(self, devname, msg): def show_open_feedback(self, devname, e):
self.__of_dev_mem__ = d = info_dialog(self, devname, msg) try:
self.__of_dev_mem__ = d = e.custom_dialog(self)
except NotImplementedError:
self.__of_dev_mem__ = d = info_dialog(self, devname, e.feedback_msg)
d.show() d.show()
def auto_convert_question(self, msg, autos): def auto_convert_question(self, msg, autos):