DeDRM_tools/Calibre_Plugins/K4MobiDeDRM_plugin/convert2xml.py

60 lines
2.0 KiB
Python
Raw Normal View History

2012-11-07 14:14:25 +01:00
from PyQt4.Qt import QWidget, QVBoxLayout, QLabel, QLineEdit
2012-11-07 14:14:25 +01:00
from calibre.utils.config import JSONConfig
2012-11-07 14:14:25 +01:00
# This is where all preferences for this plugin will be stored
# You should always prefix your config file name with plugins/,
# so as to ensure you dont accidentally clobber a calibre config file
prefs = JSONConfig('plugins/K4MobiDeDRM')
2012-11-07 14:14:25 +01:00
# Set defaults
prefs.defaults['pids'] = ""
prefs.defaults['serials'] = ""
prefs.defaults['WINEPREFIX'] = None
2012-11-07 14:14:25 +01:00
class ConfigWidget(QWidget):
2012-11-07 14:14:25 +01:00
def __init__(self):
QWidget.__init__(self)
self.l = QVBoxLayout()
self.setLayout(self.l)
2012-11-07 14:14:25 +01:00
self.serialLabel = QLabel('eInk Kindle Serial numbers (First character B, 16 characters, use commas if more than one)')
self.l.addWidget(self.serialLabel)
2012-11-07 14:14:25 +01:00
self.serials = QLineEdit(self)
self.serials.setText(prefs['serials'])
self.l.addWidget(self.serials)
self.serialLabel.setBuddy(self.serials)
2012-11-07 14:14:25 +01:00
self.pidLabel = QLabel('Mobipocket PIDs (8 or 10 characters, use commas if more than one)')
self.l.addWidget(self.pidLabel)
2012-11-07 14:14:25 +01:00
self.pids = QLineEdit(self)
self.pids.setText(prefs['pids'])
self.l.addWidget(self.pids)
self.pidLabel.setBuddy(self.serials)
2012-11-07 14:14:25 +01:00
self.wpLabel = QLabel('For Linux only: WINEPREFIX (enter absolute path)')
self.l.addWidget(self.wpLabel)
2012-11-07 14:14:25 +01:00
self.wineprefix = QLineEdit(self)
wineprefix = prefs['WINEPREFIX']
if wineprefix is not None:
self.wineprefix.setText(wineprefix)
2010-01-17 13:10:35 +01:00
else:
2012-11-07 14:14:25 +01:00
self.wineprefix.setText('')
2012-11-07 14:14:25 +01:00
self.l.addWidget(self.wineprefix)
self.wpLabel.setBuddy(self.wineprefix)
2012-11-07 14:14:25 +01:00
def save_settings(self):
prefs['pids'] = str(self.pids.text()).replace(" ","")
prefs['serials'] = str(self.serials.text()).replace(" ","")
winepref=str(self.wineprefix.text())
if winepref.strip() != '':
prefs['WINEPREFIX'] = winepref
2010-01-17 13:10:35 +01:00
else:
2012-11-07 14:14:25 +01:00
prefs['WINEPREFIX'] = None