为sound标签添加格式化样式设置(定制手机上播放图标大小)
This commit is contained in:
parent
e263e794e0
commit
51eeb232a3
@ -142,5 +142,15 @@ class Config(object):
|
||||
tmpstr = '{{c1::%s}}'
|
||||
return tmpstr
|
||||
|
||||
@property
|
||||
def sound_str(self):
|
||||
'''sound formater string'''
|
||||
# 设置音频播放按钮大小
|
||||
# <span style="width:24px;height:24px;">[sound:{0}]</span>
|
||||
tmpstr = self.data.get('sound_str', u'[sound:{0}]')
|
||||
if len(tmpstr.split('{0}')) != 2:
|
||||
tmpstr = u'[sound:{0}]'
|
||||
return tmpstr
|
||||
|
||||
|
||||
config = Config(mw)
|
||||
|
||||
@ -78,6 +78,16 @@ class SettingDialog(Dialog):
|
||||
hbox.setStretchFactor(input_cloze_str, 2)
|
||||
layout.addLayout(hbox)
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
input_sound_str = QLineEdit()
|
||||
input_sound_str.setText(config.sound_str)
|
||||
input_label = QLabel(_("SOUND_FORMAT") + ":", parent=self)
|
||||
hbox.addWidget(input_label)
|
||||
hbox.setStretchFactor(input_label, 1)
|
||||
hbox.addWidget(input_sound_str)
|
||||
hbox.setStretchFactor(input_sound_str, 2)
|
||||
layout.addLayout(hbox)
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
okbtn = QDialogButtonBox(parent=self)
|
||||
okbtn.setStandardButtons(QDialogButtonBox.Ok)
|
||||
@ -98,6 +108,7 @@ class SettingDialog(Dialog):
|
||||
self.check_ighore_mdx_wordcase = check_ighore_mdx_wordcase
|
||||
self.input_thread_number = input_thread_number
|
||||
self.input_cloze_str = input_cloze_str
|
||||
self.input_sound_str = input_sound_str
|
||||
|
||||
layout.setAlignment(Qt.AlignTop | Qt.AlignLeft)
|
||||
self.setLayout(layout)
|
||||
@ -112,7 +123,8 @@ class SettingDialog(Dialog):
|
||||
'ignore_accents': False,
|
||||
'ignore_mdx_wordcase': False,
|
||||
'thread_number': 16,
|
||||
'cloze_str': '{{c1::%s}}'
|
||||
'cloze_str': '{{c1::%s}}',
|
||||
'sound_str': '[sound:{0}]'
|
||||
}
|
||||
config.update(data)
|
||||
self.check_force_update.setChecked(config.force_update)
|
||||
@ -120,6 +132,7 @@ class SettingDialog(Dialog):
|
||||
self.check_ighore_mdx_wordcase.setChecked(config.ignore_mdx_wordcase)
|
||||
self.input_thread_number.setValue(config.thread_number)
|
||||
self.input_cloze_str.setText(config.cloze_str)
|
||||
self.input_sound_str.setText(config.sound_str)
|
||||
|
||||
def save(self):
|
||||
data = {
|
||||
@ -127,6 +140,7 @@ class SettingDialog(Dialog):
|
||||
'ignore_accents': self.check_ignore_accents.isChecked(),
|
||||
'ignore_mdx_wordcase': self.check_ighore_mdx_wordcase.isChecked(),
|
||||
'thread_number': self.input_thread_number.value(),
|
||||
'cloze_str': self.input_cloze_str.text()
|
||||
'cloze_str': self.input_cloze_str.text(),
|
||||
'sound_str': self.input_sound_str.text()
|
||||
}
|
||||
config.update(data)
|
||||
|
||||
@ -92,6 +92,7 @@ _arr = [
|
||||
['OPTIONS', u'选项', u'Options'],
|
||||
['CLOZE_WORD', u'单词填空', u'Cloze word'],
|
||||
['CLOZE_WORD_FORMAT', '单词填空格式', 'Cloze word formater'],
|
||||
['SOUND_FORMAT', '发音格式化', 'Sound formater'],
|
||||
['BRE_PRON', u'英式发音', u'British Pronunciation'],
|
||||
['AME_PRON', u'美式发音', u'American Pronunciation'],
|
||||
['PRON', u'发音', u'Audio Pronunciation'],
|
||||
|
||||
@ -295,7 +295,7 @@ class Service(object):
|
||||
|
||||
@staticmethod
|
||||
def get_anki_label(filename, type_):
|
||||
formats = {'audio': u'[sound:{0}]',
|
||||
formats = {'audio': config.sound_str,
|
||||
'img': u'<img src="{0}">',
|
||||
'video': u'<video controls="controls" width="100%" height="auto" src="{0}"></video>'}
|
||||
return formats[type_].format(filename)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user