diff --git a/addons/fastwq/context.py b/addons/fastwq/context.py index be47614..34092bb 100644 --- a/addons/fastwq/context.py +++ b/addons/fastwq/context.py @@ -136,5 +136,10 @@ def auto_update(self): '''auto check new version''' return self.data.get('auto_update', True) + @property + def cloze_str(self): + '''cloze formater string''' + return self.data.get('cloze_str', '{{c1::%s}}') + config = Config(mw) diff --git a/addons/fastwq/gui/setting.py b/addons/fastwq/gui/setting.py index 1d12492..f34226d 100644 --- a/addons/fastwq/gui/setting.py +++ b/addons/fastwq/gui/setting.py @@ -74,6 +74,16 @@ def build(self): hbox.setStretchFactor(input_thread_number, 2) layout.addLayout(hbox) + hbox = QHBoxLayout() + input_cloze_str = QLineEdit() + input_cloze_str.setText(config.cloze_str) + input_label = QLabel(_("CLOZE_WORD_FORMAT") + ":", parent=self) + hbox.addWidget(input_label) + hbox.setStretchFactor(input_label, 1) + hbox.addWidget(input_cloze_str) + hbox.setStretchFactor(input_cloze_str, 2) + layout.addLayout(hbox) + buttonBox = QDialogButtonBox(parent=self) buttonBox.setStandardButtons(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) # 确定 @@ -86,6 +96,7 @@ def build(self): 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_cloze_str = input_cloze_str layout.setAlignment(Qt.AlignTop|Qt.AlignLeft) self.setLayout(layout) @@ -101,6 +112,7 @@ def save(self): 'auto_update': self.check_auto_update.isChecked(), 'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(), 'thread_number': self.input_thread_number.value(), + 'cloze_str': self.input_cloze_str.text() } config.update(data) \ No newline at end of file diff --git a/addons/fastwq/lang.py b/addons/fastwq/lang.py index 821fc60..6b791b4 100644 --- a/addons/fastwq/lang.py +++ b/addons/fastwq/lang.py @@ -79,6 +79,7 @@ ['CURRENT_FIELDS', u'当前字段', u'Current Fields'], ['OPTIONS', u'选项', u'Options'], ['CLOZE_WORD', u'单词填空', u'Cloze word'], + ['CLOZE_WORD_FORMAT', '单词填空格式', 'Cloze word formater'], ['BRE_PRON', u'英式发音', u'British Pronunciation'], ['AME_PRON', u'美式发音', u'American Pronunciation'], diff --git a/addons/fastwq/query/common.py b/addons/fastwq/query/common.py index 38a8975..9c5bd48 100644 --- a/addons/fastwq/query/common.py +++ b/addons/fastwq/query/common.py @@ -288,7 +288,7 @@ def cloze_deletion(text, cloze): if w[:l].lower() == cloze.lower(): e = s + l w = word[:l] - result = result[:s+offset] + "{{c1::" + w + "}}" + result[e+offset:] + result = result[:s+offset] + (config.cloze_str % w) + result[e+offset:] offset += 8 return result diff --git a/addons21/fastwq/context.py b/addons21/fastwq/context.py index de988ef..85a0800 100644 --- a/addons21/fastwq/context.py +++ b/addons21/fastwq/context.py @@ -136,4 +136,10 @@ def auto_update(self): '''auto check new version''' return self.data.get('auto_update', True) + @property + def cloze_str(self): + '''cloze formater string''' + return self.data.get('cloze_str', '{{c1::%s}}') + + config = Config(mw) diff --git a/addons21/fastwq/gui/setting.py b/addons21/fastwq/gui/setting.py index 1d12492..f34226d 100644 --- a/addons21/fastwq/gui/setting.py +++ b/addons21/fastwq/gui/setting.py @@ -74,6 +74,16 @@ def build(self): hbox.setStretchFactor(input_thread_number, 2) layout.addLayout(hbox) + hbox = QHBoxLayout() + input_cloze_str = QLineEdit() + input_cloze_str.setText(config.cloze_str) + input_label = QLabel(_("CLOZE_WORD_FORMAT") + ":", parent=self) + hbox.addWidget(input_label) + hbox.setStretchFactor(input_label, 1) + hbox.addWidget(input_cloze_str) + hbox.setStretchFactor(input_cloze_str, 2) + layout.addLayout(hbox) + buttonBox = QDialogButtonBox(parent=self) buttonBox.setStandardButtons(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) # 确定 @@ -86,6 +96,7 @@ def build(self): 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_cloze_str = input_cloze_str layout.setAlignment(Qt.AlignTop|Qt.AlignLeft) self.setLayout(layout) @@ -101,6 +112,7 @@ def save(self): 'auto_update': self.check_auto_update.isChecked(), 'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(), 'thread_number': self.input_thread_number.value(), + 'cloze_str': self.input_cloze_str.text() } config.update(data) \ No newline at end of file diff --git a/addons21/fastwq/lang.py b/addons21/fastwq/lang.py index 821fc60..6b791b4 100644 --- a/addons21/fastwq/lang.py +++ b/addons21/fastwq/lang.py @@ -79,6 +79,7 @@ ['CURRENT_FIELDS', u'当前字段', u'Current Fields'], ['OPTIONS', u'选项', u'Options'], ['CLOZE_WORD', u'单词填空', u'Cloze word'], + ['CLOZE_WORD_FORMAT', '单词填空格式', 'Cloze word formater'], ['BRE_PRON', u'英式发音', u'British Pronunciation'], ['AME_PRON', u'美式发音', u'American Pronunciation'], diff --git a/addons21/fastwq/query/common.py b/addons21/fastwq/query/common.py index be9786f..870a845 100644 --- a/addons21/fastwq/query/common.py +++ b/addons21/fastwq/query/common.py @@ -289,7 +289,7 @@ def cloze_deletion(text, cloze): if w[:l].lower() == cloze.lower(): e = s + l w = word[:l] - result = result[:s+offset] + "{{c1::" + w + "}}" + result[e+offset:] + result = result[:s+offset] + (config.cloze_str % w) + result[e+offset:] offset += 8 return result