mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
dialog->form
This commit is contained in:
parent
37d04c1831
commit
86c4934e31
1 changed files with 48 additions and 48 deletions
|
@ -16,10 +16,10 @@ class Preferences(QDialog):
|
|||
self.mw = mw
|
||||
self.config = mw.config
|
||||
self.origInterfaceLang = self.config['interfaceLang']
|
||||
self.dialog = aqt.forms.preferences.Ui_Preferences()
|
||||
self.dialog.setupUi(self)
|
||||
self.form = aqt.forms.preferences.Ui_Preferences()
|
||||
self.form.setupUi(self)
|
||||
self.needDeckClose = False
|
||||
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
|
||||
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
|
||||
lambda: aqt.openHelp("Preferences"))
|
||||
self.setupLang()
|
||||
self.setupNetwork()
|
||||
|
@ -47,21 +47,21 @@ class Preferences(QDialog):
|
|||
def setupLang(self):
|
||||
# interface lang
|
||||
for (lang, code) in langs:
|
||||
self.dialog.interfaceLang.addItem(lang)
|
||||
self.dialog.interfaceLang.setCurrentIndex(
|
||||
self.form.interfaceLang.addItem(lang)
|
||||
self.form.interfaceLang.setCurrentIndex(
|
||||
self.codeToIndex(self.config['interfaceLang']))
|
||||
self.connect(self.dialog.interfaceLang,
|
||||
self.connect(self.form.interfaceLang,
|
||||
SIGNAL("currentIndexChanged(QString)"),
|
||||
self.interfaceLangChanged)
|
||||
|
||||
def interfaceLangChanged(self):
|
||||
self.config['interfaceLang'] = (
|
||||
langs[self.dialog.interfaceLang.currentIndex()])[1]
|
||||
langs[self.form.interfaceLang.currentIndex()])[1]
|
||||
self.mw.setupLang()
|
||||
self.dialog.retranslateUi(self)
|
||||
self.form.retranslateUi(self)
|
||||
|
||||
def setupMedia(self):
|
||||
self.dialog.mediaChoice.addItems(
|
||||
self.form.mediaChoice.addItems(
|
||||
QStringList([
|
||||
_("Keep media next to deck"),
|
||||
_("Keep media in DropBox"),
|
||||
|
@ -73,16 +73,16 @@ class Preferences(QDialog):
|
|||
idx = 1
|
||||
else:
|
||||
idx = 2
|
||||
self.dialog.mediaChoice.setCurrentIndex(idx)
|
||||
self.form.mediaChoice.setCurrentIndex(idx)
|
||||
self.mediaChoiceChanged(idx)
|
||||
self.connect(self.dialog.mediaChoice,
|
||||
self.connect(self.form.mediaChoice,
|
||||
SIGNAL("currentIndexChanged(int)"),
|
||||
self.mediaChoiceChanged)
|
||||
self.origMediaChoice = idx
|
||||
|
||||
def mediaChoiceChanged(self, idx):
|
||||
mp = self.dialog.mediaPath
|
||||
mpl = self.dialog.mediaPrefix
|
||||
mp = self.form.mediaPath
|
||||
mpl = self.form.mediaPrefix
|
||||
if idx == 2:
|
||||
mp.setText(self.config['mediaLocation'])
|
||||
mp.setShown(True)
|
||||
|
@ -92,28 +92,28 @@ class Preferences(QDialog):
|
|||
mpl.setShown(False)
|
||||
|
||||
def setupNetwork(self):
|
||||
self.dialog.syncOnProgramOpen.setChecked(self.config['syncOnProgramOpen'])
|
||||
self.dialog.disableWhenMoved.setChecked(self.config['syncDisableWhenMoved'])
|
||||
self.dialog.syncUser.setText(self.config['syncUsername'])
|
||||
self.dialog.syncPass.setText(self.config['syncPassword'])
|
||||
self.dialog.proxyHost.setText(self.config['proxyHost'])
|
||||
self.dialog.proxyPort.setValue(self.config['proxyPort'])
|
||||
self.dialog.proxyUser.setText(self.config['proxyUser'])
|
||||
self.dialog.proxyPass.setText(self.config['proxyPass'])
|
||||
self.form.syncOnProgramOpen.setChecked(self.config['syncOnProgramOpen'])
|
||||
self.form.disableWhenMoved.setChecked(self.config['syncDisableWhenMoved'])
|
||||
self.form.syncUser.setText(self.config['syncUsername'])
|
||||
self.form.syncPass.setText(self.config['syncPassword'])
|
||||
self.form.proxyHost.setText(self.config['proxyHost'])
|
||||
self.form.proxyPort.setValue(self.config['proxyPort'])
|
||||
self.form.proxyUser.setText(self.config['proxyUser'])
|
||||
self.form.proxyPass.setText(self.config['proxyPass'])
|
||||
|
||||
def updateNetwork(self):
|
||||
self.config['syncOnProgramOpen'] = self.dialog.syncOnProgramOpen.isChecked()
|
||||
self.config['syncDisableWhenMoved'] = self.dialog.disableWhenMoved.isChecked()
|
||||
self.config['syncUsername'] = unicode(self.dialog.syncUser.text())
|
||||
self.config['syncPassword'] = unicode(self.dialog.syncPass.text())
|
||||
self.config['proxyHost'] = unicode(self.dialog.proxyHost.text())
|
||||
self.config['proxyPort'] = int(self.dialog.proxyPort.value())
|
||||
self.config['proxyUser'] = unicode(self.dialog.proxyUser.text())
|
||||
self.config['proxyPass'] = unicode(self.dialog.proxyPass.text())
|
||||
self.config['syncOnProgramOpen'] = self.form.syncOnProgramOpen.isChecked()
|
||||
self.config['syncDisableWhenMoved'] = self.form.disableWhenMoved.isChecked()
|
||||
self.config['syncUsername'] = unicode(self.form.syncUser.text())
|
||||
self.config['syncPassword'] = unicode(self.form.syncPass.text())
|
||||
self.config['proxyHost'] = unicode(self.form.proxyHost.text())
|
||||
self.config['proxyPort'] = int(self.form.proxyPort.value())
|
||||
self.config['proxyUser'] = unicode(self.form.proxyUser.text())
|
||||
self.config['proxyPass'] = unicode(self.form.proxyPass.text())
|
||||
|
||||
def setupSave(self):
|
||||
self.dialog.numBackups.setValue(self.config['numBackups'])
|
||||
self.connect(self.dialog.openBackupFolder,
|
||||
self.form.numBackups.setValue(self.config['numBackups'])
|
||||
self.connect(self.form.openBackupFolder,
|
||||
SIGNAL("linkActivated(QString)"),
|
||||
self.onOpenBackup)
|
||||
|
||||
|
@ -123,7 +123,7 @@ class Preferences(QDialog):
|
|||
|
||||
def updateMedia(self):
|
||||
orig = self.origMediaChoice
|
||||
new = self.dialog.mediaChoice.currentIndex()
|
||||
new = self.form.mediaChoice.currentIndex()
|
||||
if orig == new and orig != 2:
|
||||
return
|
||||
if new == 0:
|
||||
|
@ -133,30 +133,30 @@ class Preferences(QDialog):
|
|||
# reset public folder location
|
||||
self.config['dropboxPublicFolder'] = ""
|
||||
else:
|
||||
p = unicode(self.dialog.mediaPath.text())
|
||||
p = unicode(self.form.mediaPath.text())
|
||||
self.config['mediaLocation'] = p
|
||||
self.needDeckClose = True
|
||||
|
||||
def updateSave(self):
|
||||
self.config['numBackups'] = self.dialog.numBackups.value()
|
||||
self.config['numBackups'] = self.form.numBackups.value()
|
||||
|
||||
def setupAdvanced(self):
|
||||
self.dialog.showEstimates.setChecked(not self.config['suppressEstimates'])
|
||||
self.dialog.centerQA.setChecked(self.config['centerQA'])
|
||||
self.dialog.showProgress.setChecked(self.config['showProgress'])
|
||||
self.dialog.openLastDeck.setChecked(self.config['loadLastDeck'])
|
||||
self.dialog.deleteMedia.setChecked(self.config['deleteMedia'])
|
||||
self.dialog.stripHTML.setChecked(self.config['stripHTML'])
|
||||
self.dialog.autoplaySounds.setChecked(self.config['autoplaySounds'])
|
||||
self.form.showEstimates.setChecked(not self.config['suppressEstimates'])
|
||||
self.form.centerQA.setChecked(self.config['centerQA'])
|
||||
self.form.showProgress.setChecked(self.config['showProgress'])
|
||||
self.form.openLastDeck.setChecked(self.config['loadLastDeck'])
|
||||
self.form.deleteMedia.setChecked(self.config['deleteMedia'])
|
||||
self.form.stripHTML.setChecked(self.config['stripHTML'])
|
||||
self.form.autoplaySounds.setChecked(self.config['autoplaySounds'])
|
||||
|
||||
def updateAdvanced(self):
|
||||
self.config['suppressEstimates'] = not self.dialog.showEstimates.isChecked()
|
||||
self.config['centerQA'] = self.dialog.centerQA.isChecked()
|
||||
self.config['showProgress'] = self.dialog.showProgress.isChecked()
|
||||
self.config['stripHTML'] = self.dialog.stripHTML.isChecked()
|
||||
self.config['autoplaySounds'] = self.dialog.autoplaySounds.isChecked()
|
||||
self.config['loadLastDeck'] = self.dialog.openLastDeck.isChecked()
|
||||
self.config['deleteMedia'] = self.dialog.deleteMedia.isChecked()
|
||||
self.config['suppressEstimates'] = not self.form.showEstimates.isChecked()
|
||||
self.config['centerQA'] = self.form.centerQA.isChecked()
|
||||
self.config['showProgress'] = self.form.showProgress.isChecked()
|
||||
self.config['stripHTML'] = self.form.stripHTML.isChecked()
|
||||
self.config['autoplaySounds'] = self.form.autoplaySounds.isChecked()
|
||||
self.config['loadLastDeck'] = self.form.openLastDeck.isChecked()
|
||||
self.config['deleteMedia'] = self.form.deleteMedia.isChecked()
|
||||
|
||||
def codeToIndex(self, code):
|
||||
n = 0
|
||||
|
|
Loading…
Reference in a new issue