Add checkbox of ignore word case in Setting dialog
This commit is contained in:
parent
6c513ea720
commit
f63e8604a6
@ -106,6 +106,10 @@ class Config(object):
|
|||||||
def force_update(self):
|
def force_update(self):
|
||||||
return self.data.get('force_update', False)
|
return self.data.get('force_update', False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ignore_mdx_wordcase(self):
|
||||||
|
return self.data.get('ignore_mdx_wordcase', False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def thread_number(self):
|
def thread_number(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -58,6 +58,11 @@ class SettingDialog(Dialog):
|
|||||||
layout.addWidget(check_auto_update)
|
layout.addWidget(check_auto_update)
|
||||||
layout.addSpacing(10)
|
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()
|
hbox = QHBoxLayout()
|
||||||
input_thread_number = QSpinBox(parent=self)
|
input_thread_number = QSpinBox(parent=self)
|
||||||
input_thread_number.setRange(1, 120)
|
input_thread_number.setRange(1, 120)
|
||||||
@ -79,6 +84,7 @@ class SettingDialog(Dialog):
|
|||||||
self.check_force_update = check_force_update
|
self.check_force_update = check_force_update
|
||||||
self.check_ignore_accents = check_ignore_accents
|
self.check_ignore_accents = check_ignore_accents
|
||||||
self.check_auto_update = check_auto_update
|
self.check_auto_update = check_auto_update
|
||||||
|
self.check_ighore_mdx_wordcase = check_ighore_mdx_wordcase
|
||||||
self.input_thread_number = input_thread_number
|
self.input_thread_number = input_thread_number
|
||||||
|
|
||||||
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
|
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
|
||||||
@ -93,6 +99,7 @@ class SettingDialog(Dialog):
|
|||||||
'force_update': self.check_force_update.isChecked(),
|
'force_update': self.check_force_update.isChecked(),
|
||||||
'ignore_accents': self.check_ignore_accents.isChecked(),
|
'ignore_accents': self.check_ignore_accents.isChecked(),
|
||||||
'auto_update': self.check_auto_update.isChecked(),
|
'auto_update': self.check_auto_update.isChecked(),
|
||||||
|
'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(),
|
||||||
'thread_number': self.input_thread_number.value(),
|
'thread_number': self.input_thread_number.value(),
|
||||||
}
|
}
|
||||||
config.update(data)
|
config.update(data)
|
||||||
|
|||||||
@ -59,6 +59,7 @@ _arr = [
|
|||||||
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
|
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
|
||||||
['UPDATE', u'更新', u'Update'],
|
['UPDATE', u'更新', u'Update'],
|
||||||
['AUTO_UPDATE', u'自动检测新版本', u'Auto check new version'],
|
['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'],
|
['FORCE_UPDATE', u'强制更新字段', u'Forced Updates of all fields'],
|
||||||
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
|
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
|
||||||
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],
|
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],
|
||||||
|
|||||||
@ -578,7 +578,7 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_definition_mdx(self):
|
def _get_definition_mdx(self):
|
||||||
"""according to the word return mdx dictionary page"""
|
"""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 = ""
|
str_content = ""
|
||||||
if len(content) > 0:
|
if len(content) > 0:
|
||||||
for c in content:
|
for c in content:
|
||||||
@ -589,7 +589,7 @@ class MdxService(LocalService):
|
|||||||
def _get_definition_mdd(self, word):
|
def _get_definition_mdd(self, word):
|
||||||
"""according to the keyword(param word) return the media file contents"""
|
"""according to the keyword(param word) return the media file contents"""
|
||||||
word = word.replace('/', '\\')
|
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:
|
if len(content) > 0:
|
||||||
return [content[0]]
|
return [content[0]]
|
||||||
else:
|
else:
|
||||||
@ -628,7 +628,7 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_default_html(self):
|
def _get_default_html(self):
|
||||||
html = u''
|
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:
|
||||||
if result[0].upper().find(u"@@@LINK=") > -1:
|
if result[0].upper().find(u"@@@LINK=") > -1:
|
||||||
# redirect to a new word behind the equal symol.
|
# redirect to a new word behind the equal symol.
|
||||||
@ -698,7 +698,7 @@ class MdxService(LocalService):
|
|||||||
shutil.copy(src_fn, savepath)
|
shutil.copy(src_fn, savepath)
|
||||||
return savepath
|
return savepath
|
||||||
else:
|
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:
|
if bytes_list:
|
||||||
with open(savepath, 'wb') as f:
|
with open(savepath, 'wb') as f:
|
||||||
f.write(bytes_list[0])
|
f.write(bytes_list[0])
|
||||||
|
|||||||
@ -106,6 +106,10 @@ class Config(object):
|
|||||||
@property
|
@property
|
||||||
def force_update(self):
|
def force_update(self):
|
||||||
return self.data.get('force_update', False)
|
return self.data.get('force_update', False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ignore_mdx_wordcase(self):
|
||||||
|
return self.data.get('ignore_mdx_wordcase', False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def thread_number(self):
|
def thread_number(self):
|
||||||
|
|||||||
@ -58,6 +58,11 @@ class SettingDialog(Dialog):
|
|||||||
layout.addWidget(check_auto_update)
|
layout.addWidget(check_auto_update)
|
||||||
layout.addSpacing(10)
|
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()
|
hbox = QHBoxLayout()
|
||||||
input_thread_number = QSpinBox(parent=self)
|
input_thread_number = QSpinBox(parent=self)
|
||||||
input_thread_number.setRange(1, 120)
|
input_thread_number.setRange(1, 120)
|
||||||
@ -79,6 +84,7 @@ class SettingDialog(Dialog):
|
|||||||
self.check_force_update = check_force_update
|
self.check_force_update = check_force_update
|
||||||
self.check_ignore_accents = check_ignore_accents
|
self.check_ignore_accents = check_ignore_accents
|
||||||
self.check_auto_update = check_auto_update
|
self.check_auto_update = check_auto_update
|
||||||
|
self.check_ighore_mdx_wordcase = check_ighore_mdx_wordcase
|
||||||
self.input_thread_number = input_thread_number
|
self.input_thread_number = input_thread_number
|
||||||
|
|
||||||
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
|
layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
|
||||||
@ -93,6 +99,7 @@ class SettingDialog(Dialog):
|
|||||||
'force_update': self.check_force_update.isChecked(),
|
'force_update': self.check_force_update.isChecked(),
|
||||||
'ignore_accents': self.check_ignore_accents.isChecked(),
|
'ignore_accents': self.check_ignore_accents.isChecked(),
|
||||||
'auto_update': self.check_auto_update.isChecked(),
|
'auto_update': self.check_auto_update.isChecked(),
|
||||||
|
'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(),
|
||||||
'thread_number': self.input_thread_number.value(),
|
'thread_number': self.input_thread_number.value(),
|
||||||
}
|
}
|
||||||
config.update(data)
|
config.update(data)
|
||||||
|
|||||||
@ -59,6 +59,7 @@ _arr = [
|
|||||||
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
|
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
|
||||||
['UPDATE', u'更新', u'Update'],
|
['UPDATE', u'更新', u'Update'],
|
||||||
['AUTO_UPDATE', u'自动检测新版本', u'Auto check new version'],
|
['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'],
|
['FORCE_UPDATE', u'强制更新字段', u'Forced Updates of all fields'],
|
||||||
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
|
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
|
||||||
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],
|
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],
|
||||||
|
|||||||
@ -585,7 +585,7 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_definition_mdx(self):
|
def _get_definition_mdx(self):
|
||||||
"""according to the word return mdx dictionary page"""
|
"""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 = ""
|
str_content = ""
|
||||||
if len(content) > 0:
|
if len(content) > 0:
|
||||||
for c in content:
|
for c in content:
|
||||||
@ -596,7 +596,7 @@ class MdxService(LocalService):
|
|||||||
def _get_definition_mdd(self, word):
|
def _get_definition_mdd(self, word):
|
||||||
"""according to the keyword(param word) return the media file contents"""
|
"""according to the keyword(param word) return the media file contents"""
|
||||||
word = word.replace('/', '\\')
|
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:
|
if len(content) > 0:
|
||||||
return [content[0]]
|
return [content[0]]
|
||||||
else:
|
else:
|
||||||
@ -635,7 +635,7 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_default_html(self):
|
def _get_default_html(self):
|
||||||
html = u''
|
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:
|
||||||
if result[0].upper().find(u"@@@LINK=") > -1:
|
if result[0].upper().find(u"@@@LINK=") > -1:
|
||||||
# redirect to a new word behind the equal symol.
|
# redirect to a new word behind the equal symol.
|
||||||
@ -705,7 +705,7 @@ class MdxService(LocalService):
|
|||||||
shutil.copy(src_fn, savepath)
|
shutil.copy(src_fn, savepath)
|
||||||
return savepath
|
return savepath
|
||||||
else:
|
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:
|
if bytes_list:
|
||||||
with open(savepath, 'wb') as f:
|
with open(savepath, 'wb') as f:
|
||||||
f.write(bytes_list[0])
|
f.write(bytes_list[0])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user