From f63e8604a63e891d3196aace31d7698597dba365 Mon Sep 17 00:00:00 2001 From: "St.Huang" Date: Mon, 20 Aug 2018 21:11:15 +0800 Subject: [PATCH] Add checkbox of ignore word case in Setting dialog --- addons/fastwq/context.py | 4 ++++ addons/fastwq/gui/setting.py | 7 +++++++ addons/fastwq/lang.py | 1 + addons/fastwq/service/base.py | 8 ++++---- addons21/fastwq/context.py | 4 ++++ addons21/fastwq/gui/setting.py | 7 +++++++ addons21/fastwq/lang.py | 1 + addons21/fastwq/service/base.py | 8 ++++---- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/addons/fastwq/context.py b/addons/fastwq/context.py index 206505d..79f1309 100644 --- a/addons/fastwq/context.py +++ b/addons/fastwq/context.py @@ -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): """ diff --git a/addons/fastwq/gui/setting.py b/addons/fastwq/gui/setting.py index e1bb7d4..1d12492 100644 --- a/addons/fastwq/gui/setting.py +++ b/addons/fastwq/gui/setting.py @@ -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) diff --git a/addons/fastwq/lang.py b/addons/fastwq/lang.py index 54afdd0..8c21416 100644 --- a/addons/fastwq/lang.py +++ b/addons/fastwq/lang.py @@ -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'], diff --git a/addons/fastwq/service/base.py b/addons/fastwq/service/base.py index f0f7665..7d95f10 100644 --- a/addons/fastwq/service/base.py +++ b/addons/fastwq/service/base.py @@ -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]) diff --git a/addons21/fastwq/context.py b/addons21/fastwq/context.py index 6da3bfd..95e4e81 100644 --- a/addons21/fastwq/context.py +++ b/addons21/fastwq/context.py @@ -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): diff --git a/addons21/fastwq/gui/setting.py b/addons21/fastwq/gui/setting.py index e1bb7d4..1d12492 100644 --- a/addons21/fastwq/gui/setting.py +++ b/addons21/fastwq/gui/setting.py @@ -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) diff --git a/addons21/fastwq/lang.py b/addons21/fastwq/lang.py index 54afdd0..8c21416 100644 --- a/addons21/fastwq/lang.py +++ b/addons21/fastwq/lang.py @@ -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'], diff --git a/addons21/fastwq/service/base.py b/addons21/fastwq/service/base.py index 2073e96..ca31772 100644 --- a/addons21/fastwq/service/base.py +++ b/addons21/fastwq/service/base.py @@ -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])