Add checkbox of ignore word case in Setting dialog

This commit is contained in:
St.Huang 2018-08-20 21:11:15 +08:00
parent 6c513ea720
commit f63e8604a6
8 changed files with 32 additions and 8 deletions

View File

@ -106,6 +106,10 @@ class Config(object):
def force_update(self):
return self.data.get('force_update', False)
@property
def ignore_mdx_wordcase(self):
return self.data.get('ignore_mdx_wordcase', False)
@property
def thread_number(self):
"""

View File

@ -58,6 +58,11 @@ class SettingDialog(Dialog):
layout.addWidget(check_auto_update)
layout.addSpacing(10)
check_ighore_mdx_wordcase = QCheckBox(_("IGNORE_MDX_WORDCASE"))
check_ighore_mdx_wordcase.setChecked(config.ignore_mdx_wordcase)
layout.addWidget(check_ighore_mdx_wordcase)
layout.addSpacing(10)
hbox = QHBoxLayout()
input_thread_number = QSpinBox(parent=self)
input_thread_number.setRange(1, 120)
@ -79,6 +84,7 @@ class SettingDialog(Dialog):
self.check_force_update = check_force_update
self.check_ignore_accents = check_ignore_accents
self.check_auto_update = check_auto_update
self.check_ighore_mdx_wordcase = check_ighore_mdx_wordcase
self.input_thread_number = input_thread_number
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
@ -93,6 +99,7 @@ class SettingDialog(Dialog):
'force_update': self.check_force_update.isChecked(),
'ignore_accents': self.check_ignore_accents.isChecked(),
'auto_update': self.check_auto_update.isChecked(),
'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(),
'thread_number': self.input_thread_number.value(),
}
config.update(data)

View File

@ -59,6 +59,7 @@ _arr = [
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
['UPDATE', u'更新', u'Update'],
['AUTO_UPDATE', u'自动检测新版本', u'Auto check new version'],
['IGNORE_MDX_WORDCASE', u'忽略本地词典单词大小写', u'Ignore MDX dictionary word case'],
['FORCE_UPDATE', u'强制更新字段', u'Forced Updates of all fields'],
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],

View File

@ -578,7 +578,7 @@ class MdxService(LocalService):
def _get_definition_mdx(self):
"""according to the word return mdx dictionary page"""
content = self.builder.mdx_lookup(self.word, ignorecase=True)
content = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase)
str_content = ""
if len(content) > 0:
for c in content:
@ -589,7 +589,7 @@ class MdxService(LocalService):
def _get_definition_mdd(self, word):
"""according to the keyword(param word) return the media file contents"""
word = word.replace('/', '\\')
content = self.builder.mdd_lookup(word, ignorecase=True)
content = self.builder.mdd_lookup(word, ignorecase=config.ignore_mdx_wordcase)
if len(content) > 0:
return [content[0]]
else:
@ -628,7 +628,7 @@ class MdxService(LocalService):
def _get_default_html(self):
html = u''
result = self.builder.mdx_lookup(self.word, ignorecase=True) # self.word: unicode
result = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase) # self.word: unicode
if result:
if result[0].upper().find(u"@@@LINK=") > -1:
# redirect to a new word behind the equal symol.
@ -698,7 +698,7 @@ class MdxService(LocalService):
shutil.copy(src_fn, savepath)
return savepath
else:
bytes_list = self.builder.mdd_lookup(filepath_in_mdx, ignorecase=True)
bytes_list = self.builder.mdd_lookup(filepath_in_mdx, ignorecase=config.ignore_mdx_wordcase)
if bytes_list:
with open(savepath, 'wb') as f:
f.write(bytes_list[0])

View File

@ -106,6 +106,10 @@ class Config(object):
@property
def force_update(self):
return self.data.get('force_update', False)
@property
def ignore_mdx_wordcase(self):
return self.data.get('ignore_mdx_wordcase', False)
@property
def thread_number(self):

View File

@ -58,6 +58,11 @@ class SettingDialog(Dialog):
layout.addWidget(check_auto_update)
layout.addSpacing(10)
check_ighore_mdx_wordcase = QCheckBox(_("IGNORE_MDX_WORDCASE"))
check_ighore_mdx_wordcase.setChecked(config.ignore_mdx_wordcase)
layout.addWidget(check_ighore_mdx_wordcase)
layout.addSpacing(10)
hbox = QHBoxLayout()
input_thread_number = QSpinBox(parent=self)
input_thread_number.setRange(1, 120)
@ -79,6 +84,7 @@ class SettingDialog(Dialog):
self.check_force_update = check_force_update
self.check_ignore_accents = check_ignore_accents
self.check_auto_update = check_auto_update
self.check_ighore_mdx_wordcase = check_ighore_mdx_wordcase
self.input_thread_number = input_thread_number
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
@ -93,6 +99,7 @@ class SettingDialog(Dialog):
'force_update': self.check_force_update.isChecked(),
'ignore_accents': self.check_ignore_accents.isChecked(),
'auto_update': self.check_auto_update.isChecked(),
'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(),
'thread_number': self.input_thread_number.value(),
}
config.update(data)

View File

@ -59,6 +59,7 @@ _arr = [
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
['UPDATE', u'更新', u'Update'],
['AUTO_UPDATE', u'自动检测新版本', u'Auto check new version'],
['IGNORE_MDX_WORDCASE', u'忽略本地词典单词大小写', u'Ignore MDX dictionary word case'],
['FORCE_UPDATE', u'强制更新字段', u'Forced Updates of all fields'],
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],

View File

@ -585,7 +585,7 @@ class MdxService(LocalService):
def _get_definition_mdx(self):
"""according to the word return mdx dictionary page"""
content = self.builder.mdx_lookup(self.word, ignorecase=True)
content = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase)
str_content = ""
if len(content) > 0:
for c in content:
@ -596,7 +596,7 @@ class MdxService(LocalService):
def _get_definition_mdd(self, word):
"""according to the keyword(param word) return the media file contents"""
word = word.replace('/', '\\')
content = self.builder.mdd_lookup(word, ignorecase=True)
content = self.builder.mdd_lookup(word, ignorecase=config.ignore_mdx_wordcase)
if len(content) > 0:
return [content[0]]
else:
@ -635,7 +635,7 @@ class MdxService(LocalService):
def _get_default_html(self):
html = u''
result = self.builder.mdx_lookup(self.word, ignorecase=True) # self.word: unicode
result = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase) # self.word: unicode
if result:
if result[0].upper().find(u"@@@LINK=") > -1:
# redirect to a new word behind the equal symol.
@ -705,7 +705,7 @@ class MdxService(LocalService):
shutil.copy(src_fn, savepath)
return savepath
else:
bytes_list = self.builder.mdd_lookup(filepath_in_mdx, ignorecase=True)
bytes_list = self.builder.mdd_lookup(filepath_in_mdx, ignorecase=config.ignore_mdx_wordcase)
if bytes_list:
with open(savepath, 'wb') as f:
f.write(bytes_list[0])