Skip to content

Commit

Permalink
add about messagebox to show addon info;
Browse files Browse the repository at this point in the history
  • Loading branch information
finalion committed May 5, 2017
1 parent 6a2b165 commit 3c4fc26
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion wquery/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .lang import _
from .odds import get_model_byId, get_ord_from_fldname

VERSION = '20170416001'
VERSION = 'V4.0.20170506'
CONFIG_FILENAME = '.wqcfg'


Expand Down
12 changes: 11 additions & 1 deletion wquery/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@
'DICT_FIELDS': {'zh_CN': u'<b>字典字段</b>', 'en': u'<b>Dict fields</b>', 'fr': u'<b>Champ de dico</b>'},
'RADIOS_DESC': {'zh_CN': u'<b>单选框选中为待查询单词字段</b>', 'en': u'<b>Word field needs to be selected.</b>', 'fr': u'<b>Champ de mot doit d\'être sélectionné. </b>'},
'NO_QUERY_WORD': {'zh_CN': u'查询字段无单词', 'en': u'No word is found in the query field', 'fr': u'Aucun est trouvé dans le champ'},
'CSS_NOT_FOUND': {'zh_CN': u'没有找到CSS文件,请手动选择', 'en': u'No valid css stylesheets found, please choose the file', 'fr': u'Aucun fichier de style CSS valide, veuillez choisir le fichier'}
'CSS_NOT_FOUND': {'zh_CN': u'没有找到CSS文件,请手动选择', 'en': u'No valid css stylesheets found, please choose the file', 'fr': u'Aucun fichier de style CSS valide, veuillez choisir le fichier'},
'ABOUT': {'zh_CN': u'关于'},
'REPOSITORY': {'zh_CN': u'项目地址'},
'FEEDBACK': {'zh_CN': u'反馈'},
'VERSION': {'zh_CN': u'版本'}
}


def _(key, lang=currentLang):
if lang != 'zh_CN' and lang != 'en' and lang != 'fr':
lang = 'en' # fallback

def disp(s):
return '{first_character}{others}'.format(first_character=s[0].upper(), others=s[1:].lower())

if not trans.has_key(key) or not trans[key].has_key(lang):
return disp(key)
return trans[key][lang]


Expand Down
24 changes: 17 additions & 7 deletions wquery/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from aqt.studydeck import StudyDeck
from aqt.utils import shortcut, showInfo

from .context import config
from .context import config, VERSION
from .lang import _, _sl
from .odds import get_model_byId, get_ord_from_fldname
from .service import service_manager
Expand Down Expand Up @@ -140,8 +140,11 @@ def build(self):
self.main_layout.addWidget(scroll_area)
# add description of radio buttons AND ok button
bottom_layout = QHBoxLayout()
about_btn = QPushButton(_('ABOUT'))
about_btn.clicked.connect(self.show_about)
btnbox = QDialogButtonBox(QDialogButtonBox.Ok, Qt.Horizontal, self)
btnbox.accepted.connect(self.accept)
bottom_layout.addWidget(about_btn)
bottom_layout.addWidget(QLabel(_("RADIOS_DESC")))
bottom_layout.addWidget(btnbox)
self.main_layout.addLayout(bottom_layout)
Expand All @@ -156,6 +159,13 @@ def build(self):
# build fields -- dicts layout
self.build_mappings_layout(model)

def show_about(self):
info = u'<b>{t0}</b><br />{version}<br /><b>{t1}</b><br /><a href="{url}">{url}</a><br /><b>{t2}</b><br /><a href="{feedback0}">{feedback0}</a><br /><a href="mailto:{feedback1}">{feedback1}</a>'.format(
t0=_('VERSION'), version=VERSION,
t1=_('REPOSITORY'), url=u'https://github.com/finalion/WordQuery',
t2=_('FEEDBACK'), feedback0=u'https://github.com/finalion/WordQuery/issues', feedback1=u'[email protected]')
QMessageBox.about(self, _('ABOUT'), info)

def show_fm_dialog(self):
fm_dialog = FoldersManageDialog(self)
fm_dialog.activateWindow()
Expand Down Expand Up @@ -302,12 +312,12 @@ def add_dict_layout(self, i, **kwargs):
kwargs:
word_checked dict fld_name dict_field
"""
word_checked, dict_name, dict_unique, fld_name, dict_field =\
kwargs.get('word_checked', False), \
kwargs.get('dict', _('NOT_DICT_FIELD')), \
kwargs.get('dict_unique', ''),\
kwargs.get('fld_name', ''), \
kwargs.get('dict_field', '')
word_checked, dict_name, dict_unique, fld_name, dict_field = (
kwargs.get('word_checked', False),
kwargs.get('dict', _('NOT_DICT_FIELD')),
kwargs.get('dict_unique', ''),
kwargs.get('fld_name', ''),
kwargs.get('dict_field', ''),)

fldname_label = QRadioButton(fld_name)
fldname_label.setMinimumSize(100, 0)
Expand Down

0 comments on commit 3c4fc26

Please sign in to comment.