forked from openlp/openlp
Settings Cleanup part2
This commit is contained in:
parent
e00eaba884
commit
20fbe4d28d
@ -141,6 +141,7 @@ class Plugin(QtCore.QObject):
|
||||
``settings_tab_class``
|
||||
The class name of the plugin's settings tab.
|
||||
"""
|
||||
log.debug(u'Plugin %s initialised' % name)
|
||||
QtCore.QObject.__init__(self)
|
||||
self.name = name
|
||||
self.textStrings = {}
|
||||
@ -250,7 +251,8 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
if self.settings_tab_class:
|
||||
return self.settings_tab_class(self.name,
|
||||
self.getString(StringContent.VisibleName)[u'title'], self.icon_path)
|
||||
self.getString(StringContent.VisibleName)[u'title'],
|
||||
self.icon_path)
|
||||
return None
|
||||
|
||||
def addToMenu(self, menubar):
|
||||
@ -287,32 +289,19 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediaItem.initialise()
|
||||
self.insertToolboxItem()
|
||||
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.insertTab(self.settings_tab, self.weight)
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Called by the plugin Manager to cleanup things.
|
||||
"""
|
||||
self.removeToolboxItem()
|
||||
|
||||
def removeToolboxItem(self):
|
||||
"""
|
||||
Called by the plugin to remove toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.remove_dock(self.mediaItem)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.removeTab(self.settings_tab)
|
||||
|
||||
def insertToolboxItem(self):
|
||||
"""
|
||||
Called by plugin to replace toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.insertTab(self.settings_tab, self.weight)
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if a plugin is currently using a theme.
|
||||
|
@ -206,8 +206,6 @@ class PluginManager(object):
|
||||
if plugin.isActive():
|
||||
plugin.initialise()
|
||||
log.info(u'Initialisation Complete for %s ' % plugin.name)
|
||||
if not plugin.isActive():
|
||||
plugin.removeToolboxItem()
|
||||
log.info(u'Initialise Plugins - Finished')
|
||||
|
||||
def finalise_plugins(self):
|
||||
|
@ -41,7 +41,8 @@ class AdvancedTab(SettingsTab):
|
||||
"""
|
||||
Initialise the settings tab
|
||||
"""
|
||||
SettingsTab.__init__(self, u'Advanced')
|
||||
generalTranslated = translate('AdvancedTab', 'Advanced')
|
||||
SettingsTab.__init__(self, u'Advanced', generalTranslated)
|
||||
self.default_image = u':/graphics/openlp-splash-screen.png'
|
||||
self.default_color = u'#ffffff'
|
||||
self.icon_path = u':/icon/openlp-logo-16x16.png'
|
||||
|
@ -45,7 +45,8 @@ class GeneralTab(SettingsTab):
|
||||
# Set to True to allow PostSetup to work on application start up
|
||||
self.overrideChanged = True
|
||||
self.icon_path = u':/icon/openlp-logo-16x16.png'
|
||||
SettingsTab.__init__(self, u'General')
|
||||
generalTranslated = translate('GeneralTab', 'General')
|
||||
SettingsTab.__init__(self, u'General', generalTranslated)
|
||||
|
||||
def preLoad(self):
|
||||
"""
|
||||
|
@ -84,5 +84,5 @@ class MediaDockManager(object):
|
||||
if self.media_dock.widget(dock_index):
|
||||
if self.media_dock.widget(dock_index).settingsSection == \
|
||||
media_item.plugin.name.lower():
|
||||
self.media_dock.widget(dock_index).hide()
|
||||
self.media_dock.widget(dock_index).setVisible(False)
|
||||
self.media_dock.removeItem(dock_index)
|
||||
|
@ -38,15 +38,20 @@ class Ui_SettingsDialog(object):
|
||||
self.settingsLayout = QtGui.QGridLayout(settingsDialog)
|
||||
self.settingsLayout.setObjectName(u'settingsLayout')
|
||||
self.settingListWidget = QtGui.QListWidget(settingsDialog)
|
||||
self.settingListWidget.setIconSize(QtCore.QSize(32, 32))
|
||||
self.settingListWidget.setObjectName(u'settingListWidget')
|
||||
self.settingsLayout.addWidget(self.settingListWidget, 0, 0, 1, 1)
|
||||
self.settingsTabWidget = QtGui.QTabWidget(settingsDialog)
|
||||
self.settingsTabWidget.setObjectName(u'settingsTabWidget')
|
||||
self.settingsLayout.addWidget(self.settingsTabWidget, 0, 1, 1, 1)
|
||||
self.stackedLayout = QtGui.QStackedLayout()
|
||||
self.stackedLayout.setObjectName(u'stackedLayout')
|
||||
self.settingsLayout.addLayout(self.stackedLayout, 0, 1, 1, 1)
|
||||
self.buttonBox = create_accept_reject_button_box(settingsDialog, True)
|
||||
self.settingsLayout.addWidget(self.buttonBox, 1, 1, 1, 1)
|
||||
self.retranslateUi(settingsDialog)
|
||||
self.stackedLayout.setCurrentIndex(0)
|
||||
QtCore.QMetaObject.connectSlotsByName(settingsDialog)
|
||||
QtCore.QObject.connect(self.settingListWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
self.stackedLayout.setCurrentIndex)
|
||||
|
||||
def retranslateUi(self, settingsDialog):
|
||||
settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm',
|
||||
|
@ -58,8 +58,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
|
||||
def exec_(self):
|
||||
# load all the settings
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
self.settingsTabWidget.widget(tabIndex).load()
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
self.stackedLayout.widget(tabIndex).load()
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
|
||||
@ -69,12 +69,19 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
"""
|
||||
log.debug(u'Inserting %s tab' % tab.tabTitle)
|
||||
# 14 : There are 3 tables currently and locations starts at -10
|
||||
self.settingsTabWidget.insertTab(
|
||||
location + 14, tab, tab.tabTitleVisible)
|
||||
match = False
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
if self.stackedLayout.widget(tabIndex):
|
||||
if self.stackedLayout.widget(tabIndex).tabTitleVisible == \
|
||||
tab.tabTitleVisible:
|
||||
print tab.tabTitleVisible
|
||||
self.stackedLayout.widget(tabIndex).setHidden(False)
|
||||
match = True
|
||||
break
|
||||
if not match:
|
||||
self.stackedLayout.addWidget(tab)
|
||||
item_name = QtGui.QListWidgetItem(tab.tabTitleVisible)
|
||||
icon = build_icon(tab.icon_path)
|
||||
pixmap = icon.pixmap(QtCore.QSize(88, 50))
|
||||
item_name.setIcon(icon)
|
||||
self.settingListWidget.insertItem(14 + location, item_name)
|
||||
|
||||
@ -83,18 +90,18 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
Remove a tab from the form
|
||||
"""
|
||||
log.debug(u'remove %s tab' % tab.tabTitleVisible)
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
if self.settingsTabWidget.widget(tabIndex):
|
||||
if self.settingsTabWidget.widget(tabIndex).tabTitleVisible == \
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
if self.stackedLayout.widget(tabIndex):
|
||||
if self.stackedLayout.widget(tabIndex).tabTitleVisible == \
|
||||
tab.tabTitleVisible:
|
||||
self.settingsTabWidget.removeTab(tabIndex)
|
||||
self.settingListWidget.item(tabIndex).setHidden(True)
|
||||
|
||||
def accept(self):
|
||||
"""
|
||||
Process the form saving the settings
|
||||
"""
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
self.settingsTabWidget.widget(tabIndex).save()
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
self.stackedLayout.widget(tabIndex).save()
|
||||
# Must go after all settings are save
|
||||
Receiver.send_message(u'config_updated')
|
||||
return QtGui.QDialog.accept(self)
|
||||
@ -103,13 +110,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
"""
|
||||
Process the form saving the settings
|
||||
"""
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
self.settingsTabWidget.widget(tabIndex).cancel()
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
self.stackedLayout.widget(tabIndex).cancel()
|
||||
return QtGui.QDialog.reject(self)
|
||||
|
||||
def postSetUp(self):
|
||||
"""
|
||||
Run any post-setup code for the tabs on the form
|
||||
"""
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
self.settingsTabWidget.widget(tabIndex).postSetUp()
|
||||
for tabIndex in range(0, self.stackedLayout.count()):
|
||||
self.stackedLayout.widget(tabIndex).postSetUp()
|
||||
|
@ -36,7 +36,8 @@ class ThemesTab(SettingsTab):
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
SettingsTab.__init__(self, u'Themes')
|
||||
generalTranslated = translate('ThemeTab', 'Themes')
|
||||
SettingsTab.__init__(self, u'Themes', generalTranslated)
|
||||
self.icon_path = u':/themes/theme_new.png'
|
||||
|
||||
def setupUi(self):
|
||||
|
@ -41,9 +41,10 @@ class AlertsPlugin(Plugin):
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
Plugin.__init__(self, u'Alerts', plugin_helpers,
|
||||
settingsTabClass=AlertsTab)
|
||||
settings_tab_class=AlertsTab)
|
||||
self.weight = -3
|
||||
self.icon = build_icon(u':/plugins/plugin_alerts.png')
|
||||
self.icon_path = u':/plugins/plugin_alerts.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.alertsmanager = AlertsManager(self)
|
||||
self.manager = Manager(u'alerts', init_schema)
|
||||
self.alertForm = AlertForm(self)
|
||||
|
@ -38,9 +38,9 @@ class RemotesPlugin(Plugin):
|
||||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
Plugin.__init__(self, u'Remotes', plugin_helpers,
|
||||
settingsTabClass=RemoteTab)
|
||||
self.icon = build_icon(u':/plugins/plugin_remote.png')
|
||||
Plugin.__init__(self, u'Remotes', plugin_helpers)
|
||||
self.icon_path = u':/plugins/plugin_remote.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.weight = -1
|
||||
self.server = None
|
||||
|
||||
@ -50,7 +50,6 @@ class RemotesPlugin(Plugin):
|
||||
"""
|
||||
log.debug(u'initialise')
|
||||
Plugin.initialise(self)
|
||||
self.insertToolboxItem()
|
||||
self.server = HttpServer(self)
|
||||
|
||||
def finalise(self):
|
||||
|
Loading…
Reference in New Issue
Block a user