mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR patch supporting new user Apple driver disabling
This commit is contained in:
parent
e248642bbe
commit
eb38a529df
@ -17,35 +17,75 @@ from calibre.ebooks.metadata import authors_to_string, MetaInformation, \
|
|||||||
title_sort
|
title_sort
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.ebooks.metadata.epub import set_metadata
|
from calibre.ebooks.metadata.epub import set_metadata
|
||||||
|
from calibre.gui2.dialogs.confirm_delete import _config_name
|
||||||
from calibre.library.server.utils import strftime
|
from calibre.library.server.utils import strftime
|
||||||
from calibre.utils.config import config_dir, prefs
|
from calibre.utils.config import config_dir, dynamic, DynamicConfig, prefs
|
||||||
from calibre.utils.date import now, parse_date
|
from calibre.utils.date import now, parse_date
|
||||||
from calibre.utils.logging import Log
|
from calibre.utils.logging import Log
|
||||||
from calibre.utils.zipfile import ZipFile
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AppleOpenFeedback(OpenFeedback):
|
class AppleOpenFeedback(OpenFeedback):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, plugin):
|
||||||
OpenFeedback.__init__(self, u'')
|
OpenFeedback.__init__(self, u'')
|
||||||
|
self.log = plugin.log
|
||||||
|
self.plugin = plugin
|
||||||
|
|
||||||
def custom_dialog(self, parent):
|
def custom_dialog(self, parent):
|
||||||
from PyQt4.Qt import (QDialog, QVBoxLayout, QLabel, QDialogButtonBox)
|
from PyQt4.Qt import (QCheckBox, QDialog, QDialogButtonBox, QIcon,
|
||||||
|
QLabel, QPixmap, QPushButton, QSize, QVBoxLayout)
|
||||||
|
|
||||||
class Dialog(QDialog):
|
class Dialog(QDialog):
|
||||||
|
|
||||||
def __init__(self, p):
|
def __init__(self, p, pixmap='dialog_information.png'):
|
||||||
QDialog.__init__(self, p)
|
QDialog.__init__(self, p)
|
||||||
|
|
||||||
|
self.setWindowTitle("Apple iDevice detected")
|
||||||
self.l = l = QVBoxLayout()
|
self.l = l = QVBoxLayout()
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
l.addWidget(QLabel('test'))
|
msg = QLabel()
|
||||||
self.bb = QDialogButtonBox(QDialogButtonBox.OK)
|
msg.setText(
|
||||||
|
'<p>If you do not want calibre to recognize your Apple iDevice '
|
||||||
|
'when it is connected to your computer, '
|
||||||
|
'click <b>Disable Apple Driver</b>.</p>'
|
||||||
|
'<p>To transfer books to your iDevice, '
|
||||||
|
'click <b>Disable Apple Driver</b>, '
|
||||||
|
"then use the 'Connect to iTunes' method recommended in the "
|
||||||
|
'<a href=\"http://www.mobileread.com/forums/showthread.php?t=118559\">Calibre + iDevices FAQ</a>, '
|
||||||
|
'using the <em>Connect/Share</em>|<em>Connect to iTunes</em> menu item.</p>'
|
||||||
|
'<p>Enabling the Apple driver for direct connection to iDevices '
|
||||||
|
'is an unsupported advanced user mode.</p>'
|
||||||
|
'<p></p>'
|
||||||
|
)
|
||||||
|
msg.setWordWrap(True)
|
||||||
|
l.addWidget(msg)
|
||||||
|
|
||||||
|
self.bb = QDialogButtonBox()
|
||||||
|
disable_driver = QPushButton(_("Disable Apple driver"))
|
||||||
|
disable_driver.setDefault(True)
|
||||||
|
self.bb.addButton(disable_driver, QDialogButtonBox.RejectRole)
|
||||||
|
|
||||||
|
enable_driver = QPushButton(_("Enable Apple driver"))
|
||||||
|
self.bb.addButton(enable_driver, QDialogButtonBox.AcceptRole)
|
||||||
l.addWidget(self.bb)
|
l.addWidget(self.bb)
|
||||||
self.bb.accepted.connect(self.accept)
|
self.bb.accepted.connect(self.accept)
|
||||||
self.bb.rejected.connect(self.reject)
|
self.bb.rejected.connect(self.reject)
|
||||||
|
|
||||||
return Dialog(parent)
|
self.setWindowIcon(QIcon(I(pixmap)))
|
||||||
|
self.resize(self.sizeHint())
|
||||||
|
|
||||||
|
if Dialog(parent).exec_():
|
||||||
|
# Enable Apple driver, inhibit future display of dialog
|
||||||
|
# Reset dialog with Preferences|Behavior|Reset all disabled confirmation dialogs
|
||||||
|
self.log.info(" Apple driver ENABLED")
|
||||||
|
dynamic[_config_name(self.plugin.DISPLAY_DISABLE_DIALOG)] = False
|
||||||
|
else:
|
||||||
|
# Disable Apple driver
|
||||||
|
from calibre.customize.ui import disable_plugin
|
||||||
|
self.log.info(" Apple driver DISABLED")
|
||||||
|
disable_plugin(self.plugin)
|
||||||
|
|
||||||
|
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
@ -77,15 +117,11 @@ class DriverBase(DeviceConfig, DevicePlugin):
|
|||||||
'iBooks Category'),
|
'iBooks Category'),
|
||||||
_('Cache covers from iTunes/iBooks') +
|
_('Cache covers from iTunes/iBooks') +
|
||||||
':::' +
|
':::' +
|
||||||
_('Enable to cache and display covers from iTunes/iBooks'),
|
_('Enable to cache and display covers from iTunes/iBooks')
|
||||||
_("Skip 'Connect to iTunes' recommendation") +
|
|
||||||
':::' +
|
|
||||||
_("Enable to skip the 'Connect to iTunes' recommendation dialog")
|
|
||||||
]
|
]
|
||||||
EXTRA_CUSTOMIZATION_DEFAULT = [
|
EXTRA_CUSTOMIZATION_DEFAULT = [
|
||||||
True,
|
True,
|
||||||
True,
|
True,
|
||||||
False,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -141,12 +177,13 @@ class ITUNES(DriverBase):
|
|||||||
supported_platforms = ['osx','windows']
|
supported_platforms = ['osx','windows']
|
||||||
author = 'GRiker'
|
author = 'GRiker'
|
||||||
#: The version of this plugin as a 3-tuple (major, minor, revision)
|
#: The version of this plugin as a 3-tuple (major, minor, revision)
|
||||||
version = (0,9,0)
|
version = (1,0,0)
|
||||||
|
|
||||||
|
DISPLAY_DISABLE_DIALOG = "display_disable_dialog"
|
||||||
|
|
||||||
# EXTRA_CUSTOMIZATION_MESSAGE indexes
|
# EXTRA_CUSTOMIZATION_MESSAGE indexes
|
||||||
USE_SERIES_AS_CATEGORY = 0
|
USE_SERIES_AS_CATEGORY = 0
|
||||||
CACHE_COVERS = 1
|
CACHE_COVERS = 1
|
||||||
SKIP_CONNECT_TO_ITUNES_DIALOG = 2
|
|
||||||
|
|
||||||
OPEN_FEEDBACK_MESSAGE = _(
|
OPEN_FEEDBACK_MESSAGE = _(
|
||||||
'Apple device detected, launching iTunes, please wait ...')
|
'Apple device detected, launching iTunes, please wait ...')
|
||||||
@ -762,13 +799,15 @@ class ITUNES(DriverBase):
|
|||||||
Note that most of the initialization is necessarily performed in can_handle(), as
|
Note that most of the initialization is necessarily performed in can_handle(), as
|
||||||
we need to talk to iTunes to discover if there's a connected iPod
|
we need to talk to iTunes to discover if there's a connected iPod
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
self.log.info("ITUNES.open()")
|
self.log.info("ITUNES.open()")
|
||||||
|
|
||||||
# Display a dialog recommending using 'Connect to iTunes'
|
# Display a dialog recommending using 'Connect to iTunes' if user hasn't
|
||||||
if not self.settings().extra_customization[self.SKIP_CONNECT_TO_ITUNES_DIALOG]:
|
# previously disabled the dialog
|
||||||
raise AppleOpenFeedback()
|
if dynamic.get(_config_name(self.DISPLAY_DISABLE_DIALOG),True):
|
||||||
|
raise AppleOpenFeedback(self)
|
||||||
|
else:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
self.log.info(" advanced user mode, directly connecting to iDevice")
|
self.log.info(" advanced user mode, directly connecting to iDevice")
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class OpenFeedback(DeviceError):
|
|||||||
|
|
||||||
def custom_dialog(self, parent):
|
def custom_dialog(self, parent):
|
||||||
'''
|
'''
|
||||||
If you need to show the user a custom dialog, instead if just
|
If you need to show the user a custom dialog, create and
|
||||||
displaying the feedback_msg, create and return it here.
|
run it from a custom_dialog() method in your subclass.
|
||||||
'''
|
'''
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user