Stop signal from running twice and set 'Autodetect' text after language names have been set.

This commit is contained in:
Raoul Snyman 2011-03-11 07:15:41 +02:00
parent c4e64dce8d
commit 21d59235ac
2 changed files with 11 additions and 9 deletions

View File

@ -425,14 +425,14 @@ class Ui_MainWindow(object):
translate('OpenLP.MainWindow', '&Online Help'))
self.helpWebSiteItem.setText(
translate('OpenLP.MainWindow', '&Web Site'))
self.AutoLanguageItem.setText(
translate('OpenLP.MainWindow', '&Auto Detect'))
self.AutoLanguageItem.setStatusTip(translate('OpenLP.MainWindow',
'Use the system language, if available.'))
for item in self.LanguageGroup.actions():
item.setText(item.objectName())
item.setStatusTip(unicode(translate('OpenLP.MainWindow',
'Set the interface language to %s')) % item.objectName())
self.AutoLanguageItem.setText(
translate('OpenLP.MainWindow', '&Autodetect'))
self.AutoLanguageItem.setStatusTip(translate('OpenLP.MainWindow',
'Use the system language, if available.'))
self.ToolsAddToolItem.setText(
translate('OpenLP.MainWindow', 'Add &Tool...'))
self.ToolsAddToolItem.setStatusTip(translate('OpenLP.MainWindow',
@ -550,8 +550,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.printServiceOrder)
# i18n set signals for languages
QtCore.QObject.connect(self.AutoLanguageItem,
QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage)
self.LanguageGroup.triggered.connect(LanguageManager.set_language)
QtCore.QObject.connect(self.ModeDefaultItem,
QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked)

View File

@ -112,9 +112,13 @@ class LanguageManager(object):
"""
language = u'en'
if action:
action_name = u'%s' % action.objectName()
qm_list = LanguageManager.get_qm_list()
language = u'%s' % qm_list[action_name]
action_name = unicode(action.objectName())
if action_name == u'AutoLanguageItem':
LanguageManager.auto_language = True
else:
LanguageManager.auto_language = False
qm_list = LanguageManager.get_qm_list()
language = unicode(qm_list[action_name])
if LanguageManager.auto_language:
language = u'[%s]' % language
# This needs to be here for the setValue to work