Preferences partially working now
Former-commit-id: 1d8395b26b30b13c2d9af76ef509ac84bada79ec
This commit is contained in:
parent
4f485ef2a9
commit
b2c3245e20
@ -129,6 +129,9 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tabAnki">
|
<widget class="QWidget" name="tabAnki">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Anki</string>
|
<string>Anki</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -197,12 +200,12 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show settings for</string>
|
<string>Profile</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonSettingsVocab">
|
<widget class="QRadioButton" name="radioButtonVocab">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Vocabulary</string>
|
<string>Vocabulary</string>
|
||||||
</property>
|
</property>
|
||||||
@ -212,7 +215,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonSettingsKanji">
|
<widget class="QRadioButton" name="radioButtonKanji">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Kanji</string>
|
<string>Kanji</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"bgColor": 4294967295,
|
"bgColor": 4294967295,
|
||||||
"checkForUpdates": true,
|
"checkForUpdates": true,
|
||||||
"fontFamily": "Arial",
|
"fgColor": 4278190080,
|
||||||
"fgColor": 4278190080,
|
"fontFamily": "Arial",
|
||||||
"fontSize": 12,
|
"fontSize": 12,
|
||||||
"loadRecentFile": true,
|
"loadRecentFile": true,
|
||||||
"recentFiles": [],
|
"profiles": {},
|
||||||
"scanLength": 16,
|
"recentFiles": [],
|
||||||
"stripReadings": false,
|
"scanLength": 16,
|
||||||
|
"stripReadings": false,
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"wordWrap": false
|
"wordWrap": false
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui/about.ui'
|
# Form implementation generated from reading ui file 'ui/about.ui'
|
||||||
#
|
#
|
||||||
# Created: Sun Nov 10 11:59:08 2013
|
# Created: Sun Nov 10 12:44:02 2013
|
||||||
# by: PyQt4 UI code generator 4.10
|
# by: PyQt4 UI code generator 4.10
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui/preferences.ui'
|
# Form implementation generated from reading ui file 'ui/preferences.ui'
|
||||||
#
|
#
|
||||||
# Created: Sun Nov 10 11:59:08 2013
|
# Created: Sun Nov 10 12:44:02 2013
|
||||||
# by: PyQt4 UI code generator 4.10
|
# by: PyQt4 UI code generator 4.10
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
@ -94,6 +94,7 @@ class Ui_DialogPreferences(object):
|
|||||||
self.verticalLayout_3.addWidget(self.textSample)
|
self.verticalLayout_3.addWidget(self.textSample)
|
||||||
self.tabWidget.addTab(self.tabAppearance, _fromUtf8(""))
|
self.tabWidget.addTab(self.tabAppearance, _fromUtf8(""))
|
||||||
self.tabAnki = QtGui.QWidget()
|
self.tabAnki = QtGui.QWidget()
|
||||||
|
self.tabAnki.setEnabled(False)
|
||||||
self.tabAnki.setObjectName(_fromUtf8("tabAnki"))
|
self.tabAnki.setObjectName(_fromUtf8("tabAnki"))
|
||||||
self.verticalLayout_2 = QtGui.QVBoxLayout(self.tabAnki)
|
self.verticalLayout_2 = QtGui.QVBoxLayout(self.tabAnki)
|
||||||
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
|
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
|
||||||
@ -139,13 +140,13 @@ class Ui_DialogPreferences(object):
|
|||||||
self.label = QtGui.QLabel(self.tabAnki)
|
self.label = QtGui.QLabel(self.tabAnki)
|
||||||
self.label.setObjectName(_fromUtf8("label"))
|
self.label.setObjectName(_fromUtf8("label"))
|
||||||
self.horizontalLayout_2.addWidget(self.label)
|
self.horizontalLayout_2.addWidget(self.label)
|
||||||
self.radioButtonSettingsVocab = QtGui.QRadioButton(self.tabAnki)
|
self.radioButtonVocab = QtGui.QRadioButton(self.tabAnki)
|
||||||
self.radioButtonSettingsVocab.setChecked(True)
|
self.radioButtonVocab.setChecked(True)
|
||||||
self.radioButtonSettingsVocab.setObjectName(_fromUtf8("radioButtonSettingsVocab"))
|
self.radioButtonVocab.setObjectName(_fromUtf8("radioButtonVocab"))
|
||||||
self.horizontalLayout_2.addWidget(self.radioButtonSettingsVocab)
|
self.horizontalLayout_2.addWidget(self.radioButtonVocab)
|
||||||
self.radioButtonSettingsKanji = QtGui.QRadioButton(self.tabAnki)
|
self.radioButtonKanji = QtGui.QRadioButton(self.tabAnki)
|
||||||
self.radioButtonSettingsKanji.setObjectName(_fromUtf8("radioButtonSettingsKanji"))
|
self.radioButtonKanji.setObjectName(_fromUtf8("radioButtonKanji"))
|
||||||
self.horizontalLayout_2.addWidget(self.radioButtonSettingsKanji)
|
self.horizontalLayout_2.addWidget(self.radioButtonKanji)
|
||||||
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
self.horizontalLayout_2.addItem(spacerItem)
|
self.horizontalLayout_2.addItem(spacerItem)
|
||||||
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
|
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
|
||||||
@ -181,9 +182,9 @@ class Ui_DialogPreferences(object):
|
|||||||
item.setText(_translate("DialogPreferences", "Field", None))
|
item.setText(_translate("DialogPreferences", "Field", None))
|
||||||
item = self.tableFields.horizontalHeaderItem(1)
|
item = self.tableFields.horizontalHeaderItem(1)
|
||||||
item.setText(_translate("DialogPreferences", "Value", None))
|
item.setText(_translate("DialogPreferences", "Value", None))
|
||||||
self.label.setText(_translate("DialogPreferences", "Show settings for", None))
|
self.label.setText(_translate("DialogPreferences", "Profile", None))
|
||||||
self.radioButtonSettingsVocab.setText(_translate("DialogPreferences", "Vocabulary", None))
|
self.radioButtonVocab.setText(_translate("DialogPreferences", "Vocabulary", None))
|
||||||
self.radioButtonSettingsKanji.setText(_translate("DialogPreferences", "Kanji", None))
|
self.radioButtonKanji.setText(_translate("DialogPreferences", "Kanji", None))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabAnki), _translate("DialogPreferences", "Anki", None))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabAnki), _translate("DialogPreferences", "Anki", None))
|
||||||
|
|
||||||
import resources_rc
|
import resources_rc
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui/reader.ui'
|
# Form implementation generated from reading ui file 'ui/reader.ui'
|
||||||
#
|
#
|
||||||
# Created: Sun Nov 10 11:59:08 2013
|
# Created: Sun Nov 10 12:44:02 2013
|
||||||
# by: PyQt4 UI code generator 4.10
|
# by: PyQt4 UI code generator 4.10
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Resource object code
|
# Resource object code
|
||||||
#
|
#
|
||||||
# Created: Sun Nov 10 11:59:08 2013
|
# Created: Sun Nov 10 12:44:02 2013
|
||||||
# by: The Resource Compiler for PyQt (Qt v4.8.4)
|
# by: The Resource Compiler for PyQt (Qt v4.8.4)
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
from gen import preferences_ui
|
from gen import preferences_ui
|
||||||
|
import copy
|
||||||
|
|
||||||
|
|
||||||
class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
||||||
@ -49,14 +50,10 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
self.comboFontFamily.setCurrentFont(font)
|
self.comboFontFamily.setCurrentFont(font)
|
||||||
self.spinFontSize.setValue(font.pointSize())
|
self.spinFontSize.setValue(font.pointSize())
|
||||||
|
|
||||||
self.tabAnki.setEnabled(self.anki is not None)
|
|
||||||
if self.anki is not None:
|
if self.anki is not None:
|
||||||
self.comboBoxDeck.addItems(self.anki.deckNames())
|
self.tabAnki.setEnabled(True)
|
||||||
self.comboBoxDeck.setCurrentIndex(self.comboBoxDeck.findText(self.preferences.ankiDeck))
|
self.profiles = copy.deepcopy(self.preferences['profiles'])
|
||||||
self.comboBoxModel.blockSignals(True)
|
self.profileToDialog()
|
||||||
self.comboBoxModel.addItems(self.anki.modelNames())
|
|
||||||
self.comboBoxModel.blockSignals(False)
|
|
||||||
self.comboBoxModel.setCurrentIndex(self.comboBoxModel.findText(self.preferences.ankiModel))
|
|
||||||
|
|
||||||
|
|
||||||
def dialogToData(self):
|
def dialogToData(self):
|
||||||
@ -66,9 +63,30 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
self.preferences['stripReadings'] = self.checkStripReadings.isChecked()
|
self.preferences['stripReadings'] = self.checkStripReadings.isChecked()
|
||||||
|
|
||||||
if self.anki is not None:
|
if self.anki is not None:
|
||||||
self.preferences.ankiDeck = unicode(self.comboBoxDeck.currentText())
|
self.dialogToProfile()
|
||||||
self.preferences.ankiModel = unicode(self.comboBoxModel.currentText())
|
self.preferences['profiles'] = self.profiles
|
||||||
self.preferences.ankiFields = self.ankiFields()
|
|
||||||
|
|
||||||
|
def dialogToProfile(self):
|
||||||
|
self.setActiveProfile({
|
||||||
|
'deck': unicode(self.comboBoxDeck.currentText()),
|
||||||
|
'model': unicode(self.comboBoxModel.currentText()),
|
||||||
|
'fields': self.ankiFields()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def profileToDialog(self):
|
||||||
|
profile = self.activeProfile()
|
||||||
|
|
||||||
|
deck = str() if profile is None else profile['deck']
|
||||||
|
model = str() if profile is None else profile['model']
|
||||||
|
|
||||||
|
self.comboBoxDeck.addItems(self.anki.deckNames())
|
||||||
|
self.comboBoxDeck.setCurrentIndex(self.comboBoxDeck.findText(deck))
|
||||||
|
self.comboBoxModel.blockSignals(True)
|
||||||
|
self.comboBoxModel.addItems(self.anki.modelNames())
|
||||||
|
self.comboBoxModel.blockSignals(False)
|
||||||
|
self.comboBoxModel.setCurrentIndex(self.comboBoxModel.findText(model))
|
||||||
|
|
||||||
|
|
||||||
def updateSampleText(self):
|
def updateSampleText(self):
|
||||||
@ -83,7 +101,7 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
self.textSample.setFont(font)
|
self.textSample.setFont(font)
|
||||||
|
|
||||||
|
|
||||||
def setFields(self, fields, fieldsPrefs):
|
def setAnkiFields(self, fields, fieldsPrefs):
|
||||||
if fields is None:
|
if fields is None:
|
||||||
fields = list()
|
fields = list()
|
||||||
|
|
||||||
@ -145,4 +163,18 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
def onModelChanged(self, index):
|
def onModelChanged(self, index):
|
||||||
modelName = self.comboBoxModel.currentText()
|
modelName = self.comboBoxModel.currentText()
|
||||||
fieldNames = self.anki.modelFieldNames(modelName) or list()
|
fieldNames = self.anki.modelFieldNames(modelName) or list()
|
||||||
self.setFields(fieldNames, self.preferences.ankiFields)
|
|
||||||
|
profile = self.activeProfile()
|
||||||
|
fields = dict() if profile is None else profile['fields']
|
||||||
|
|
||||||
|
self.setAnkiFields(fieldNames, fields)
|
||||||
|
|
||||||
|
|
||||||
|
def activeProfile(self):
|
||||||
|
key = 'vocab' if self.radioButtonVocab.isChecked() else 'kanji'
|
||||||
|
return self.profiles.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
def setActiveProfile(self, profile):
|
||||||
|
key = 'vocab' if self.radioButtonVocab.isChecked() else 'kanji'
|
||||||
|
self.profiles[key] = profile
|
||||||
|
Loading…
Reference in New Issue
Block a user