This commit is contained in:
Kovid Goyal 2011-03-28 17:17:05 -06:00
commit 78d492b554
4 changed files with 18 additions and 18 deletions

View File

@ -61,6 +61,9 @@ def osx_version():
if m:
return int(m.group(1)), int(m.group(2)), int(m.group(3))
def confirm_config_name(name):
return name + '_again'
_filename_sanitize = re.compile(r'[\xae\0\\|\?\*<":>\+/]')
_filename_sanitize_unicode = frozenset([u'\\', u'|', u'?', u'*', u'<',
u'"', u':', u'>', u'+', u'/'] + list(map(unichr, xrange(32))))

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import cStringIO, ctypes, datetime, os, re, shutil, subprocess, sys, tempfile, time
from calibre.constants import __appname__, __version__, DEBUG
from calibre import fit_image
from calibre import fit_image, confirm_config_name
from calibre.constants import isosx, iswindows
from calibre.devices.errors import OpenFeedback, UserFeedback
from calibre.devices.usbms.deviceconfig import DeviceConfig
@ -37,9 +37,9 @@ class AppleOpenFeedback(OpenFeedback):
class Dialog(QDialog):
def __init__(self, p, pixmap='dialog_information.png'):
def __init__(self, p, cd, pixmap='dialog_information.png'):
QDialog.__init__(self, p)
self.cd = cd
self.setWindowTitle("Apple iDevice detected")
self.l = l = QVBoxLayout()
self.setLayout(l)
@ -79,15 +79,14 @@ class AppleOpenFeedback(OpenFeedback):
def do_it(self, return_code):
if return_code == self.Accepted:
from calibre.gui2.dialogs.confirm_delete import config_name
self.log.info(" Apple driver ENABLED")
dynamic[config_name(self.plugin.DISPLAY_DISABLE_DIALOG)] = False
self.cd.log.info(" Apple driver ENABLED")
dynamic[confirm_config_name(self.cd.plugin.DISPLAY_DISABLE_DIALOG)] = False
else:
from calibre.customize.ui import disable_plugin
self.log.info(" Apple driver DISABLED")
disable_plugin(self.plugin)
self.cd.log.info(" Apple driver DISABLED")
disable_plugin(self.cd.plugin)
return Dialog(parent)
return Dialog(parent, self)
from PIL import Image as PILImage
@ -808,8 +807,7 @@ class ITUNES(DriverBase):
# Display a dialog recommending using 'Connect to iTunes' if user hasn't
# previously disabled the dialog
from calibre.gui2.dialogs.confirm_delete import config_name
if dynamic.get(config_name(self.DISPLAY_DISABLE_DIALOG),True):
if dynamic.get(confirm_config_name(self.DISPLAY_DISABLE_DIALOG),True):
raise AppleOpenFeedback(self)
else:
if DEBUG:

View File

@ -43,7 +43,7 @@ class OpenFeedback(DeviceError):
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, instead of just
displaying the feedback_msg, create and return it here.
'''
raise NotImplementedError

View File

@ -3,12 +3,11 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
from calibre.gui2 import dynamic
from calibre.gui2.dialogs.confirm_delete_ui import Ui_Dialog
from PyQt4.Qt import QDialog, Qt, QPixmap, QIcon
def config_name(name):
return name + '_again'
from calibre import confirm_config_name
from calibre.gui2 import dynamic
from calibre.gui2.dialogs.confirm_delete_ui import Ui_Dialog
class Dialog(QDialog, Ui_Dialog):
@ -22,11 +21,11 @@ class Dialog(QDialog, Ui_Dialog):
self.buttonBox.setFocus(Qt.OtherFocusReason)
def toggle(self, *args):
dynamic[config_name(self.name)] = self.again.isChecked()
dynamic[confirm_config_name(self.name)] = self.again.isChecked()
def confirm(msg, name, parent=None, pixmap='dialog_warning.png'):
if not dynamic.get(config_name(name), True):
if not dynamic.get(confirm_config_name(name), True):
return True
d = Dialog(msg, name, parent)
d.label.setPixmap(QPixmap(I(pixmap)))