More updates to preferences, getting closer to making it work
Former-commit-id: edf2bba8d74c92ca2abe0fafaa9a87154d250220
This commit is contained in:
parent
dce854f966
commit
4f485ef2a9
@ -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 10:19:58 2013
|
# Created: Sun Nov 10 11:59:08 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 10:19:59 2013
|
# Created: Sun Nov 10 11:59:08 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!
|
||||||
@ -47,15 +47,15 @@ class Ui_DialogPreferences(object):
|
|||||||
self.label_14 = QtGui.QLabel(self.tabGeneral)
|
self.label_14 = QtGui.QLabel(self.tabGeneral)
|
||||||
self.label_14.setObjectName(_fromUtf8("label_14"))
|
self.label_14.setObjectName(_fromUtf8("label_14"))
|
||||||
self.formLayout_2.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_14)
|
self.formLayout_2.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_14)
|
||||||
self.spinMaxScanLength = QtGui.QSpinBox(self.tabGeneral)
|
self.spinScanLength = QtGui.QSpinBox(self.tabGeneral)
|
||||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||||
sizePolicy.setHorizontalStretch(0)
|
sizePolicy.setHorizontalStretch(0)
|
||||||
sizePolicy.setVerticalStretch(0)
|
sizePolicy.setVerticalStretch(0)
|
||||||
sizePolicy.setHeightForWidth(self.spinMaxScanLength.sizePolicy().hasHeightForWidth())
|
sizePolicy.setHeightForWidth(self.spinScanLength.sizePolicy().hasHeightForWidth())
|
||||||
self.spinMaxScanLength.setSizePolicy(sizePolicy)
|
self.spinScanLength.setSizePolicy(sizePolicy)
|
||||||
self.spinMaxScanLength.setMinimum(1)
|
self.spinScanLength.setMinimum(1)
|
||||||
self.spinMaxScanLength.setObjectName(_fromUtf8("spinMaxScanLength"))
|
self.spinScanLength.setObjectName(_fromUtf8("spinScanLength"))
|
||||||
self.formLayout_2.setWidget(3, QtGui.QFormLayout.FieldRole, self.spinMaxScanLength)
|
self.formLayout_2.setWidget(3, QtGui.QFormLayout.FieldRole, self.spinScanLength)
|
||||||
self.tabWidget.addTab(self.tabGeneral, _fromUtf8(""))
|
self.tabWidget.addTab(self.tabGeneral, _fromUtf8(""))
|
||||||
self.tabAppearance = QtGui.QWidget()
|
self.tabAppearance = QtGui.QWidget()
|
||||||
self.tabAppearance.setObjectName(_fromUtf8("tabAppearance"))
|
self.tabAppearance.setObjectName(_fromUtf8("tabAppearance"))
|
||||||
@ -165,10 +165,10 @@ class Ui_DialogPreferences(object):
|
|||||||
|
|
||||||
def retranslateUi(self, DialogPreferences):
|
def retranslateUi(self, DialogPreferences):
|
||||||
DialogPreferences.setWindowTitle(_translate("DialogPreferences", "Preferences", None))
|
DialogPreferences.setWindowTitle(_translate("DialogPreferences", "Preferences", None))
|
||||||
self.checkLoadRecentFile.setText(_translate("DialogPreferences", "Load recent file on startup", None))
|
self.checkLoadRecentFile.setText(_translate("DialogPreferences", "Load most recent file", None))
|
||||||
self.checkStripReadings.setText(_translate("DialogPreferences", "Strip readings from loaded files", None))
|
self.checkStripReadings.setText(_translate("DialogPreferences", "Strip readings from files", None))
|
||||||
self.checkCheckForUpdates.setText(_translate("DialogPreferences", "Check for updates on startup", None))
|
self.checkCheckForUpdates.setText(_translate("DialogPreferences", "Check for updates", None))
|
||||||
self.label_14.setText(_translate("DialogPreferences", "Maximum scan length", None))
|
self.label_14.setText(_translate("DialogPreferences", "Text scan length", None))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabGeneral), _translate("DialogPreferences", "General", None))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabGeneral), _translate("DialogPreferences", "General", None))
|
||||||
self.buttonColorFg.setText(_translate("DialogPreferences", "Foreground...", None))
|
self.buttonColorFg.setText(_translate("DialogPreferences", "Foreground...", None))
|
||||||
self.buttonColorBg.setText(_translate("DialogPreferences", "Background...", None))
|
self.buttonColorBg.setText(_translate("DialogPreferences", "Background...", None))
|
||||||
|
@ -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 10:19:59 2013
|
# Created: Sun Nov 10 11:59:08 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 10:19:59 2013
|
# Created: Sun Nov 10 11:59:08 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!
|
||||||
|
@ -26,11 +26,11 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.accepted.connect(self.onAccept)
|
self.accepted.connect(self.onAccept)
|
||||||
self.buttonContentColorFg.clicked.connect(self.onButtonColorFgClicked)
|
self.buttonColorBg.clicked.connect(self.onButtonColorBgClicked)
|
||||||
self.buttonContentColorBg.clicked.connect(self.onButtonColorBgClicked)
|
self.buttonColorFg.clicked.connect(self.onButtonColorFgClicked)
|
||||||
self.comboContentFontFamily.currentFontChanged.connect(self.onFontFamilyChanged)
|
self.comboBoxModel.currentIndexChanged.connect(self.onModelChanged)
|
||||||
self.spinContentFontSize.valueChanged.connect(self.onFontSizeChanged)
|
self.comboFontFamily.currentFontChanged.connect(self.onFontFamilyChanged)
|
||||||
self.comboBoxAnkiModel.currentIndexChanged.connect(self.onAnkiModelChanged)
|
self.spinFontSize.valueChanged.connect(self.onFontSizeChanged)
|
||||||
|
|
||||||
self.preferences = preferences
|
self.preferences = preferences
|
||||||
self.anki = anki
|
self.anki = anki
|
||||||
@ -39,63 +39,57 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
|
|
||||||
|
|
||||||
def dataToDialog(self):
|
def dataToDialog(self):
|
||||||
self.checkGeneralRecentLoad.setChecked(self.preferences.generalRecentLoad)
|
self.checkCheckForUpdates.setChecked(self.preferences['checkForUpdates'])
|
||||||
self.checkGeneralReadingsStrip.setChecked(self.preferences.generalReadingsStrip)
|
self.checkLoadRecentFile.setChecked(self.preferences['loadRecentFile'])
|
||||||
self.checkGeneralFindUpdates.setChecked(self.preferences.generalFindUpdates)
|
self.checkStripReadings.setChecked(self.preferences['stripReadings'])
|
||||||
|
self.spinScanLength.setValue(self.preferences['scanLength'])
|
||||||
|
|
||||||
self.updateSampleText()
|
self.updateSampleText()
|
||||||
font = self.textContentSample.font()
|
font = self.textSample.font()
|
||||||
self.comboContentFontFamily.setCurrentFont(font)
|
self.comboFontFamily.setCurrentFont(font)
|
||||||
self.spinContentFontSize.setValue(font.pointSize())
|
self.spinFontSize.setValue(font.pointSize())
|
||||||
|
|
||||||
self.spinSearchScanMax.setValue(self.preferences.searchScanMax)
|
|
||||||
self.spinSearchResultMax.setValue(self.preferences.searchResultMax)
|
|
||||||
self.checkSearchGroupByExp.setChecked(self.preferences.searchGroupByExp)
|
|
||||||
|
|
||||||
self.tabAnki.setEnabled(self.anki is not None)
|
self.tabAnki.setEnabled(self.anki is not None)
|
||||||
if self.anki:
|
if self.anki is not None:
|
||||||
self.comboBoxAnkiDeck.addItems(self.anki.deckNames())
|
self.comboBoxDeck.addItems(self.anki.deckNames())
|
||||||
self.comboBoxAnkiDeck.setCurrentIndex(self.comboBoxAnkiDeck.findText(self.preferences.ankiDeck))
|
self.comboBoxDeck.setCurrentIndex(self.comboBoxDeck.findText(self.preferences.ankiDeck))
|
||||||
self.comboBoxAnkiModel.blockSignals(True)
|
self.comboBoxModel.blockSignals(True)
|
||||||
self.comboBoxAnkiModel.addItems(self.anki.modelNames())
|
self.comboBoxModel.addItems(self.anki.modelNames())
|
||||||
self.comboBoxAnkiModel.blockSignals(False)
|
self.comboBoxModel.blockSignals(False)
|
||||||
self.comboBoxAnkiModel.setCurrentIndex(self.comboBoxAnkiModel.findText(self.preferences.ankiModel))
|
self.comboBoxModel.setCurrentIndex(self.comboBoxModel.findText(self.preferences.ankiModel))
|
||||||
|
|
||||||
|
|
||||||
def dialogToData(self):
|
def dialogToData(self):
|
||||||
self.preferences.generalRecentLoad = self.checkGeneralRecentLoad.isChecked()
|
self.preferences['checkForUpdates'] = self.checkCheckForUpdates.isChecked()
|
||||||
self.preferences.generalReadingsStrip = self.checkGeneralReadingsStrip.isChecked()
|
self.preferences['loadRecentFile'] = self.checkLoadRecentFile.isChecked()
|
||||||
self.preferences.generalFindUpdates = self.checkGeneralFindUpdates.isChecked()
|
self.preferences['scanLength'] = self.spinScanLength.value()
|
||||||
|
self.preferences['stripReadings'] = self.checkStripReadings.isChecked()
|
||||||
|
|
||||||
self.preferences.searchScanMax = self.spinSearchScanMax.value()
|
if self.anki is not None:
|
||||||
self.preferences.searchResultMax = self.spinSearchResultMax.value()
|
self.preferences.ankiDeck = unicode(self.comboBoxDeck.currentText())
|
||||||
self.preferences.searchGroupByExp = self.checkSearchGroupByExp.isChecked()
|
self.preferences.ankiModel = unicode(self.comboBoxModel.currentText())
|
||||||
|
|
||||||
if self.anki:
|
|
||||||
self.preferences.ankiDeck = unicode(self.comboBoxAnkiDeck.currentText())
|
|
||||||
self.preferences.ankiModel = unicode(self.comboBoxAnkiModel.currentText())
|
|
||||||
self.preferences.ankiFields = self.ankiFields()
|
self.preferences.ankiFields = self.ankiFields()
|
||||||
|
|
||||||
|
|
||||||
def updateSampleText(self):
|
def updateSampleText(self):
|
||||||
palette = self.textContentSample.palette()
|
palette = self.textSample.palette()
|
||||||
palette.setColor(QtGui.QPalette.Base, QtGui.QColor(self.preferences.uiContentColorBg))
|
palette.setColor(QtGui.QPalette.Base, QtGui.QColor(self.preferences['bgColor']))
|
||||||
palette.setColor(QtGui.QPalette.Text, QtGui.QColor(self.preferences.uiContentColorFg))
|
palette.setColor(QtGui.QPalette.Text, QtGui.QColor(self.preferences['fgColor']))
|
||||||
self.textContentSample.setPalette(palette)
|
self.textSample.setPalette(palette)
|
||||||
|
|
||||||
font = self.textContentSample.font()
|
font = self.textSample.font()
|
||||||
font.setFamily(self.preferences.uiContentFontFamily)
|
font.setFamily(self.preferences['fontFamily'])
|
||||||
font.setPointSize(self.preferences.uiContentFontSize)
|
font.setPointSize(self.preferences['fontSize'])
|
||||||
self.textContentSample.setFont(font)
|
self.textSample.setFont(font)
|
||||||
|
|
||||||
|
|
||||||
def setAnkiFields(self, fieldsAnki, fieldsPrefs):
|
def setFields(self, fields, fieldsPrefs):
|
||||||
if fieldsAnki is None:
|
if fields is None:
|
||||||
fieldsAnki = list()
|
fields = list()
|
||||||
|
|
||||||
self.tableAnkiFields.setRowCount(len(fieldsAnki))
|
self.tableFields.setRowCount(len(fields))
|
||||||
|
|
||||||
for i, name in enumerate(fieldsAnki):
|
for i, name in enumerate(fields):
|
||||||
columns = list()
|
columns = list()
|
||||||
|
|
||||||
itemName = QtGui.QTableWidgetItem(name)
|
itemName = QtGui.QTableWidgetItem(name)
|
||||||
@ -106,15 +100,15 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
columns.append(itemValue)
|
columns.append(itemValue)
|
||||||
|
|
||||||
for j, column in enumerate(columns):
|
for j, column in enumerate(columns):
|
||||||
self.tableAnkiFields.setItem(i, j, column)
|
self.tableFields.setItem(i, j, column)
|
||||||
|
|
||||||
|
|
||||||
def ankiFields(self):
|
def ankiFields(self):
|
||||||
result = dict()
|
result = dict()
|
||||||
|
|
||||||
for i in range(0, self.tableAnkiFields.rowCount()):
|
for i in range(0, self.tableFields.rowCount()):
|
||||||
itemName = unicode(self.tableAnkiFields.item(i, 0).text())
|
itemName = unicode(self.tableFields.item(i, 0).text())
|
||||||
itemValue = unicode(self.tableAnkiFields.item(i, 1).text())
|
itemValue = unicode(self.tableFields.item(i, 1).text())
|
||||||
result[itemName] = itemValue
|
result[itemName] = itemValue
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -125,30 +119,30 @@ class DialogPreferences(QtGui.QDialog, preferences_ui.Ui_DialogPreferences):
|
|||||||
|
|
||||||
|
|
||||||
def onButtonColorFgClicked(self):
|
def onButtonColorFgClicked(self):
|
||||||
color, ok = QtGui.QColorDialog.getRgba(self.preferences.uiContentColorFg, self)
|
color, ok = QtGui.QColorDialog.getRgba(self.preferences['fgColor'], self)
|
||||||
if ok:
|
if ok:
|
||||||
self.preferences.uiContentColorFg = color
|
self.preferences['fgColor'] = color
|
||||||
self.updateSampleText()
|
self.updateSampleText()
|
||||||
|
|
||||||
|
|
||||||
def onButtonColorBgClicked(self):
|
def onButtonColorBgClicked(self):
|
||||||
color, ok = QtGui.QColorDialog.getRgba(self.preferences.uiContentColorBg, self)
|
color, ok = QtGui.QColorDialog.getRgba(self.preferences['bgColor'], self)
|
||||||
if ok:
|
if ok:
|
||||||
self.preferences.uiContentColorBg = color
|
self.preferences['bgColor'] = color
|
||||||
self.updateSampleText()
|
self.updateSampleText()
|
||||||
|
|
||||||
|
|
||||||
def onFontFamilyChanged(self, font):
|
def onFontFamilyChanged(self, font):
|
||||||
self.preferences.uiContentFontFamily = font.family()
|
self.preferences['fontFamily'] = str(font.family())
|
||||||
self.updateSampleText()
|
self.updateSampleText()
|
||||||
|
|
||||||
|
|
||||||
def onFontSizeChanged(self, size):
|
def onFontSizeChanged(self, size):
|
||||||
self.preferences.uiContentFontSize = size
|
self.preferences['fontSize'] = size
|
||||||
self.updateSampleText()
|
self.updateSampleText()
|
||||||
|
|
||||||
|
|
||||||
def onAnkiModelChanged(self, index):
|
def onModelChanged(self, index):
|
||||||
modelName = self.comboBoxAnkiModel.currentText()
|
modelName = self.comboBoxModel.currentText()
|
||||||
fieldNames = self.anki.modelFieldNames(modelName) or list()
|
fieldNames = self.anki.modelFieldNames(modelName) or list()
|
||||||
self.setAnkiFields(fieldNames, self.preferences.ankiFields)
|
self.setFields(fieldNames, self.preferences.ankiFields)
|
||||||
|
Loading…
Reference in New Issue
Block a user