Fix i18n for tabs v3

This commit is contained in:
Jon Tibble 2009-10-28 21:52:13 +00:00
parent 439c3c90ca
commit fcd5836e0f
6 changed files with 18 additions and 33 deletions

View File

@ -46,8 +46,6 @@ class SettingsTab(QtGui.QWidget):
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
self.tabTitle = title self.tabTitle = title
self.tabTitleVisible = None self.tabTitleVisible = None
# Use the line below when pulling the translation template file.
#self.tabTitle = title
self.setupUi() self.setupUi()
self.retranslateUi() self.retranslateUi()
self.initialise() self.initialise()
@ -57,21 +55,6 @@ class SettingsTab(QtGui.QWidget):
self.config = PluginConfig(section) self.config = PluginConfig(section)
self.load() self.load()
def setTitle(self, title):
"""
Set the title of the tab.
``title``
The title of the tab, which is usually displayed on the tab.
"""
self.tabTitle = title
def title(self):
"""
Get the title of the tab.
"""
return self.tabTitle
def setupUi(self): def setupUi(self):
""" """
Setup the tab's interface. Setup the tab's interface.

View File

@ -32,13 +32,12 @@ class AlertsTab(SettingsTab):
""" """
def __init__(self): def __init__(self):
SettingsTab.__init__(self, u'Alerts', u'Alerts') SettingsTab.__init__(self, u'Alerts', u'Alerts')
# Use the line below when pulling the translation template file.
#SettingsTab.__init__(self, self.trUtf8(u'Alerts'), u'Alerts')
self.font_color = '#ffffff' self.font_color = '#ffffff'
self.bg_color = '#660000' self.bg_color = '#660000'
def setupUi(self): def setupUi(self):
self.setObjectName(u'AlertsTab') self.setObjectName(u'AlertsTab')
self.tabTitleVisible = self.trUtf8(u'Alerts')
self.AlertsLayout = QtGui.QHBoxLayout(self) self.AlertsLayout = QtGui.QHBoxLayout(self)
self.AlertsLayout.setSpacing(8) self.AlertsLayout.setSpacing(8)
self.AlertsLayout.setMargin(8) self.AlertsLayout.setMargin(8)

View File

@ -33,11 +33,10 @@ class GeneralTab(SettingsTab):
def __init__(self, screen_list): def __init__(self, screen_list):
self.screen_list = screen_list self.screen_list = screen_list
SettingsTab.__init__(self, u'General', u'General') SettingsTab.__init__(self, u'General', u'General')
# Use this line when pulling the translation template
#SettingsTab.__init__(self, self.trUtf8(u'General'), u'General')
def setupUi(self): def setupUi(self):
self.setObjectName(u'GeneralTab') self.setObjectName(u'GeneralTab')
self.tabTitleVisible = self.trUtf8(u'General')
self.GeneralLayout = QtGui.QHBoxLayout(self) self.GeneralLayout = QtGui.QHBoxLayout(self)
self.GeneralLayout.setSpacing(8) self.GeneralLayout.setSpacing(8)
self.GeneralLayout.setMargin(8) self.GeneralLayout.setMargin(8)

View File

@ -36,20 +36,25 @@ class Ui_SettingsDialog(object):
self.SettingsTabWidget.setObjectName(u'SettingsTabWidget') self.SettingsTabWidget.setObjectName(u'SettingsTabWidget')
self.SettingsLayout.addWidget(self.SettingsTabWidget) self.SettingsLayout.addWidget(self.SettingsTabWidget)
self.ButtonsBox = QtGui.QDialogButtonBox(SettingsDialog) self.ButtonsBox = QtGui.QDialogButtonBox(SettingsDialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ButtonsBox.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(
self.ButtonsBox.sizePolicy().hasHeightForWidth())
self.ButtonsBox.setSizePolicy(sizePolicy) self.ButtonsBox.setSizePolicy(sizePolicy)
self.ButtonsBox.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.ButtonsBox.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.ButtonsBox.setOrientation(QtCore.Qt.Horizontal) self.ButtonsBox.setOrientation(QtCore.Qt.Horizontal)
self.ButtonsBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.ButtonsBox.setStandardButtons(
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.ButtonsBox.setObjectName(u'ButtonsBox') self.ButtonsBox.setObjectName(u'ButtonsBox')
self.SettingsLayout.addWidget(self.ButtonsBox) self.SettingsLayout.addWidget(self.ButtonsBox)
self.retranslateUi(SettingsDialog) self.retranslateUi(SettingsDialog)
self.SettingsTabWidget.setCurrentIndex(0) self.SettingsTabWidget.setCurrentIndex(0)
QtCore.QObject.connect(self.ButtonsBox, QtCore.SIGNAL(u'accepted()'), SettingsDialog.accept) QtCore.QObject.connect(self.ButtonsBox,
QtCore.QObject.connect(self.ButtonsBox, QtCore.SIGNAL(u'rejected()'), SettingsDialog.reject) QtCore.SIGNAL(u'accepted()'), SettingsDialog.accept)
QtCore.QObject.connect(self.ButtonsBox,
QtCore.SIGNAL(u'rejected()'), SettingsDialog.reject)
QtCore.QMetaObject.connectSlotsByName(SettingsDialog) QtCore.QMetaObject.connectSlotsByName(SettingsDialog)
def retranslateUi(self, SettingsDialog): def retranslateUi(self, SettingsDialog):

View File

@ -48,18 +48,18 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
self.addTab(u'Alerts', self.AlertsTab) self.addTab(u'Alerts', self.AlertsTab)
def addTab(self, name, tab): def addTab(self, name, tab):
log.info(u'Adding %s tab' % tab.title()) log.info(u'Adding %s tab' % tab.tabTitle)
self.SettingsTabWidget.addTab(tab, tab.title()) self.SettingsTabWidget.addTab(tab, tab.tabTitleVisible)
def insertTab(self, tab, location): def insertTab(self, tab, location):
log.debug(u'Inserting %s tab' % tab.title()) log.debug(u'Inserting %s tab' % tab.tabTitle)
self.SettingsTabWidget.insertTab(location + 13, tab, tab.title()) self.SettingsTabWidget.insertTab(location + 13, tab, tab.tabTitleVisible)
def removeTab(self, name): def removeTab(self, name):
log.debug(u'remove %s tab' % name) log.debug(u'remove %s tab' % name)
for tab_index in range(0, self.SettingsTabWidget.count()): for tab_index in range(0, self.SettingsTabWidget.count()):
if self.SettingsTabWidget.widget(tab_index) is not None: if self.SettingsTabWidget.widget(tab_index) is not None:
if self.SettingsTabWidget.widget(tab_index).title() == name: if self.SettingsTabWidget.widget(tab_index).tabTitle == name:
self.SettingsTabWidget.removeTab(tab_index) self.SettingsTabWidget.removeTab(tab_index)
def accept(self): def accept(self):

View File

@ -33,11 +33,10 @@ class ThemesTab(SettingsTab):
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
SettingsTab.__init__(self, u'Themes', u'Themes') SettingsTab.__init__(self, u'Themes', u'Themes')
# Use the line below when pulling the translation template file.
#SettingsTab.__init__(self, self.trUtf8(u'Themes'), u'Themes')
def setupUi(self): def setupUi(self):
self.setObjectName(u'ThemesTab') self.setObjectName(u'ThemesTab')
self.tabTitleVisible = self.trUtf8(u'Themes')
self.ThemesTabLayout = QtGui.QHBoxLayout(self) self.ThemesTabLayout = QtGui.QHBoxLayout(self)
self.ThemesTabLayout.setSpacing(8) self.ThemesTabLayout.setSpacing(8)
self.ThemesTabLayout.setMargin(8) self.ThemesTabLayout.setMargin(8)