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