removed static methods

This commit is contained in:
Andreas Preikschat 2011-04-09 18:11:02 +02:00
parent 283171e296
commit 9011c85a6b
10 changed files with 102 additions and 70 deletions

View File

@ -259,7 +259,8 @@ def base_action(parent, name, category=None):
action = QtGui.QAction(parent) action = QtGui.QAction(parent)
action.setObjectName(name) action.setObjectName(name)
if category is not None: if category is not None:
ActionList.add_action(action, category) action_list = ActionList.get_instance()
action_list.add_action(action, category)
return action return action
def checkable_action(parent, name, checked=None, category=None): def checkable_action(parent, name, checked=None, category=None):
@ -297,7 +298,8 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
action.setChecked(checked) action.setChecked(checked)
action.setShortcuts(shortcuts) action.setShortcuts(shortcuts)
action.setShortcutContext(context) action.setShortcutContext(context)
ActionList.add_action(action, category) action_list = ActionList.get_instance()
action_list.add_action(action, category)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)
return action return action
@ -335,7 +337,8 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
if shortcuts is not None: if shortcuts is not None:
action.setShortcuts(shortcuts) action.setShortcuts(shortcuts)
action.setShortcutContext(context) action.setShortcutContext(context)
ActionList.add_action(action) action_list = ActionList.get_instance()
action_list.add_action(action)
return action return action
def context_menu(base, icon, text): def context_menu(base, icon, text):

View File

@ -39,7 +39,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ShortcutListForm, DisplayTagForm ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
get_application_version get_application_version
from openlp.core.utils.actions import ActionList from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -162,7 +162,8 @@ class Ui_MainWindow(object):
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
self.themeManagerDock) self.themeManagerDock)
# Create the menu items # Create the menu items
ActionList.add_category(UiStrings.File, 100) action_list = ActionList.get_instance()
action_list.add_category(UiStrings.File, CategoryOrder.standardMenu)
self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem', self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem',
[QtGui.QKeySequence(u'Ctrl+N')], [QtGui.QKeySequence(u'Ctrl+N')],
self.ServiceManagerContents.onNewServiceClicked, self.ServiceManagerContents.onNewServiceClicked,
@ -185,17 +186,17 @@ class Ui_MainWindow(object):
self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem',
[QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close,
u':/system/system_exit.png', category=UiStrings.File) u':/system/system_exit.png', category=UiStrings.File)
ActionList.add_category(UiStrings.Import, 95) action_list.add_category(UiStrings.Import, CategoryOrder.standardMenu)
self.ImportThemeItem = base_action( self.ImportThemeItem = base_action(
mainWindow, u'ImportThemeItem', UiStrings.Import) mainWindow, u'ImportThemeItem', UiStrings.Import)
self.ImportLanguageItem = base_action( self.ImportLanguageItem = base_action(
mainWindow, u'ImportLanguageItem')#, UiStrings.Import) mainWindow, u'ImportLanguageItem')#, UiStrings.Import)
ActionList.add_category(UiStrings.Export, 90) action_list.add_category(UiStrings.Export, CategoryOrder.standardMenu)
self.ExportThemeItem = base_action( self.ExportThemeItem = base_action(
mainWindow, u'ExportThemeItem', UiStrings.Export) mainWindow, u'ExportThemeItem', UiStrings.Export)
self.ExportLanguageItem = base_action( self.ExportLanguageItem = base_action(
mainWindow, u'ExportLanguageItem')#, UiStrings.Export) mainWindow, u'ExportLanguageItem')#, UiStrings.Export)
ActionList.add_category(UiStrings.View, 85) action_list.add_category(UiStrings.View, CategoryOrder.standardMenu)
self.ViewMediaManagerItem = shortcut_action(mainWindow, self.ViewMediaManagerItem = shortcut_action(mainWindow,
u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')],
self.toggleMediaManager, u':/system/system_mediamanager.png', self.toggleMediaManager, u':/system/system_mediamanager.png',
@ -215,7 +216,7 @@ class Ui_MainWindow(object):
self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel',
[QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility,
checked=liveVisible, category=UiStrings.View) checked=liveVisible, category=UiStrings.View)
ActionList.add_category(UiStrings.ViewMode, 80) action_list.add_category(UiStrings.ViewMode, CategoryOrder.standardMenu)
self.ModeDefaultItem = checkable_action( self.ModeDefaultItem = checkable_action(
mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode) mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode)
self.ModeSetupItem = checkable_action( self.ModeSetupItem = checkable_action(
@ -227,13 +228,13 @@ class Ui_MainWindow(object):
self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeSetupItem)
self.ModeGroup.addAction(self.ModeLiveItem) self.ModeGroup.addAction(self.ModeLiveItem)
self.ModeDefaultItem.setChecked(True) self.ModeDefaultItem.setChecked(True)
ActionList.add_category(UiStrings.Tools, 75) action_list.add_category(UiStrings.Tools, CategoryOrder.standardMenu)
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
u':/tools/tools_add.png', category=UiStrings.Tools) u':/tools/tools_add.png', category=UiStrings.Tools)
self.ToolsOpenDataFolder = icon_action(mainWindow, self.ToolsOpenDataFolder = icon_action(mainWindow,
u'ToolsOpenDataFolder', u':/general/general_open.png', u'ToolsOpenDataFolder', u':/general/general_open.png',
category=UiStrings.Tools) category=UiStrings.Tools)
ActionList.add_category(UiStrings.Settings, 70) action_list.add_category(UiStrings.Settings, CategoryOrder.standardMenu)
self.settingsPluginListItem = shortcut_action(mainWindow, self.settingsPluginListItem = shortcut_action(mainWindow,
u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
self.onPluginItemClicked, u':/system/settings_plugin_list.png', self.onPluginItemClicked, u':/system/settings_plugin_list.png',
@ -261,7 +262,7 @@ class Ui_MainWindow(object):
self.SettingsConfigureItem = icon_action(mainWindow, self.SettingsConfigureItem = icon_action(mainWindow,
u'SettingsConfigureItem', u':/system/system_settings.png', u'SettingsConfigureItem', u':/system/system_settings.png',
category=UiStrings.Settings) category=UiStrings.Settings)
ActionList.add_category(UiStrings.Help, 65) action_list.add_category(UiStrings.Help, CategoryOrder.standardMenu)
self.HelpDocumentationItem = icon_action(mainWindow, self.HelpDocumentationItem = icon_action(mainWindow,
u'HelpDocumentationItem', u':/system/system_help_contents.png', u'HelpDocumentationItem', u':/system/system_help_contents.png',
category=None)#UiStrings.Help) category=None)#UiStrings.Help)

View File

@ -40,7 +40,7 @@ from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
split_filename split_filename
from openlp.core.utils.actions import ActionList from openlp.core.utils.actions import ActionList, CategoryOrder
class ServiceManagerList(QtGui.QTreeWidget): class ServiceManagerList(QtGui.QTreeWidget):
""" """
@ -167,8 +167,9 @@ class ServiceManager(QtGui.QWidget):
'Move item to the top of the service.'), 'Move item to the top of the service.'),
self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home])
self.serviceManagerList.moveTop.setObjectName(u'moveTop') self.serviceManagerList.moveTop.setObjectName(u'moveTop')
ActionList.add_category(UiStrings.Service, 45) action_list = ActionList.get_instance()
ActionList.add_action( action_list.add_category(UiStrings.Service, CategoryOrder.standardToolbar)
action_list.add_action(
self.serviceManagerList.moveTop, UiStrings.Service) self.serviceManagerList.moveTop, UiStrings.Service)
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &up'), translate('OpenLP.ServiceManager', 'Move &up'),
@ -177,7 +178,7 @@ class ServiceManager(QtGui.QWidget):
'Move item up one position in the service.'), 'Move item up one position in the service.'),
self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp]) self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp])
self.serviceManagerList.moveUp.setObjectName(u'moveUp') self.serviceManagerList.moveUp.setObjectName(u'moveUp')
ActionList.add_action(self.serviceManagerList.moveUp, UiStrings.Service) action_list.add_action(self.serviceManagerList.moveUp, UiStrings.Service)
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'), translate('OpenLP.ServiceManager', 'Move &down'),
u':/services/service_down.png', u':/services/service_down.png',
@ -185,7 +186,7 @@ class ServiceManager(QtGui.QWidget):
'Move item down one position in the service.'), 'Move item down one position in the service.'),
self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown])
self.serviceManagerList.moveDown.setObjectName(u'moveDown') self.serviceManagerList.moveDown.setObjectName(u'moveDown')
ActionList.add_action( action_list.add_action(
self.serviceManagerList.moveDown, UiStrings.Service) self.serviceManagerList.moveDown, UiStrings.Service)
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move to &bottom'), translate('OpenLP.ServiceManager', 'Move to &bottom'),
@ -194,7 +195,7 @@ class ServiceManager(QtGui.QWidget):
'Move item to the end of the service.'), 'Move item to the end of the service.'),
self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End])
self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') self.serviceManagerList.moveBottom.setObjectName(u'moveBottom')
ActionList.add_action( action_list.add_action(
self.serviceManagerList.moveBottom, UiStrings.Service) self.serviceManagerList.moveBottom, UiStrings.Service)
self.serviceManagerList.down = self.orderToolbar.addToolbarButton( self.serviceManagerList.down = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'), translate('OpenLP.ServiceManager', 'Move &down'),
@ -203,7 +204,7 @@ class ServiceManager(QtGui.QWidget):
'Moves the selection down the window.'), 'Moves the selection down the window.'),
self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down])
self.serviceManagerList.down.setObjectName(u'down') self.serviceManagerList.down.setObjectName(u'down')
ActionList.add_action(self.serviceManagerList.down) action_list.add_action(self.serviceManagerList.down)
self.serviceManagerList.down.setVisible(False) self.serviceManagerList.down.setVisible(False)
self.serviceManagerList.up = self.orderToolbar.addToolbarButton( self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move up'), translate('OpenLP.ServiceManager', 'Move up'),
@ -212,7 +213,7 @@ class ServiceManager(QtGui.QWidget):
'Moves the selection up the window.'), 'Moves the selection up the window.'),
self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up])
self.serviceManagerList.up.setObjectName(u'up') self.serviceManagerList.up.setObjectName(u'up')
ActionList.add_action(self.serviceManagerList.up) action_list.add_action(self.serviceManagerList.up)
self.serviceManagerList.up.setVisible(False) self.serviceManagerList.up.setVisible(False)
self.orderToolbar.addSeparator() self.orderToolbar.addSeparator()
self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
@ -229,7 +230,7 @@ class ServiceManager(QtGui.QWidget):
'Expand all the service items.'), 'Expand all the service items.'),
self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus]) self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus])
self.serviceManagerList.expand.setObjectName(u'expand') self.serviceManagerList.expand.setObjectName(u'expand')
ActionList.add_action(self.serviceManagerList.expand, UiStrings.Service) action_list.add_action(self.serviceManagerList.expand, UiStrings.Service)
self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', '&Collapse all'), translate('OpenLP.ServiceManager', '&Collapse all'),
u':/services/service_collapse_all.png', u':/services/service_collapse_all.png',
@ -237,7 +238,7 @@ class ServiceManager(QtGui.QWidget):
'Collapse all the service items.'), 'Collapse all the service items.'),
self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus])
self.serviceManagerList.collapse.setObjectName(u'collapse') self.serviceManagerList.collapse.setObjectName(u'collapse')
ActionList.add_action( action_list.add_action(
self.serviceManagerList.collapse, UiStrings.Service) self.serviceManagerList.collapse, UiStrings.Service)
self.orderToolbar.addSeparator() self.orderToolbar.addSeparator()
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton(
@ -247,7 +248,7 @@ class ServiceManager(QtGui.QWidget):
'Send the selected item to Live.'), self.makeLive, 'Send the selected item to Live.'), self.makeLive,
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return])
self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') self.serviceManagerList.makeLive.setObjectName(u'orderToolbar')
ActionList.add_action( action_list.add_action(
self.serviceManagerList.makeLive, UiStrings.Service) self.serviceManagerList.makeLive, UiStrings.Service)
self.layout.addWidget(self.orderToolbar) self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots # Connect up our signals and slots

View File

@ -46,6 +46,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.changedActions = {} self.changedActions = {}
self.action_list = ActionList.get_instance()
QtCore.QObject.connect(self.primaryPushButton, QtCore.QObject.connect(self.primaryPushButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked) QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked)
QtCore.QObject.connect(self.alternatePushButton, QtCore.QObject.connect(self.alternatePushButton,
@ -96,7 +97,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
# The action we are attempting to change. # The action we are attempting to change.
changing_action = self._currentItemAction() changing_action = self._currentItemAction()
shortcut_valid = True shortcut_valid = True
for category in ActionList.categories: for category in self.action_list.categories:
for action in category.actions: for action in category.actions:
shortcuts = self._actionShortcuts(action) shortcuts = self._actionShortcuts(action)
if key_sequence not in shortcuts: if key_sequence not in shortcuts:
@ -149,7 +150,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
Reload the ``treeWidget`` list to add new and remove old actions. Reload the ``treeWidget`` list to add new and remove old actions.
""" """
self.treeWidget.clear() self.treeWidget.clear()
for category in ActionList.categories: for category in self.action_list.categories:
# Check if the category is for internal use only. # Check if the category is for internal use only.
if category.name is None: if category.name is None:
continue continue
@ -303,7 +304,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
return return
self._adjustButton(self.primaryPushButton, False, text=u'') self._adjustButton(self.primaryPushButton, False, text=u'')
self._adjustButton(self.alternatePushButton, False, text=u'') self._adjustButton(self.alternatePushButton, False, text=u'')
for category in ActionList.categories: for category in self.action_list.categories:
for action in category.actions: for action in category.actions:
self.changedActions[action] = action.defaultShortcuts self.changedActions[action] = action.defaultShortcuts
self.refreshShortcutList() self.refreshShortcutList()
@ -349,7 +350,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
""" """
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts') settings.beginGroup(u'shortcuts')
for category in ActionList.categories: for category in self.action_list.categories:
# Check if the category is for internal use only. # Check if the category is for internal use only.
if category.name is None: if category.name is None:
continue continue

View File

@ -34,7 +34,7 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
ItemCapabilities, translate ItemCapabilities, translate
from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.lib.ui import UiStrings, shortcut_action
from openlp.core.ui import HideMode, MainDisplay from openlp.core.ui import HideMode, MainDisplay
from openlp.core.utils.actions import ActionList from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -367,16 +367,20 @@ class SlideController(QtGui.QWidget):
def setPreviewHotkeys(self, parent=None): def setPreviewHotkeys(self, parent=None):
self.previousItem.setObjectName(u'previousItemPreview') self.previousItem.setObjectName(u'previousItemPreview')
self.nextItem.setObjectName(u'nextItemPreview') self.nextItem.setObjectName(u'nextItemPreview')
ActionList.add_category(UiStrings.PreviewToolbar, 55) action_list = ActionList.get_instance()
ActionList.add_action(self.previousItem, UiStrings.PreviewToolbar) action_list.add_category(
ActionList.add_action(self.nextItem, UiStrings.PreviewToolbar) UiStrings.PreviewToolbar, CategoryOrder.standardToolbar)
action_list.add_action(self.previousItem, UiStrings.PreviewToolbar)
action_list.add_action(self.nextItem, UiStrings.PreviewToolbar)
def setLiveHotkeys(self, parent=None): def setLiveHotkeys(self, parent=None):
self.previousItem.setObjectName(u'previousItemLive') self.previousItem.setObjectName(u'previousItemLive')
self.nextItem.setObjectName(u'nextItemLive') self.nextItem.setObjectName(u'nextItemLive')
ActionList.add_category(UiStrings.LiveToolbar, 60) action_list = ActionList.get_instance()
ActionList.add_action(self.previousItem, UiStrings.LiveToolbar) action_list.add_category(
ActionList.add_action(self.nextItem, UiStrings.LiveToolbar) UiStrings.LiveToolbar, CategoryOrder.standardToolbar)
action_list.add_action(self.previousItem, UiStrings.LiveToolbar)
action_list.add_action(self.nextItem, UiStrings.LiveToolbar)
self.previousService = shortcut_action(parent, u'previousService', self.previousService = shortcut_action(parent, u'previousService',
[QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar) [QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar)
self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)

View File

@ -183,10 +183,18 @@ class ActionList(object):
has a weight by which it is sorted when iterating through the list of has a weight by which it is sorted when iterating through the list of
actions or categories. actions or categories.
""" """
categories = CategoryList() instance = None
def __init__(self):
self.categories = CategoryList()
@staticmethod @staticmethod
def add_action(action, category=None, weight=None): def get_instance():
if ActionList.instance is None:
ActionList.instance = ActionList()
return ActionList.instance
def add_action(self, action, category=None, weight=None):
""" """
Add an action to the list of actions. Add an action to the list of actions.
@ -206,13 +214,13 @@ class ActionList(object):
""" """
if category is not None: if category is not None:
category = unicode(category) category = unicode(category)
if category not in ActionList.categories: if category not in self.categories:
ActionList.categories.append(category) self.categories.append(category)
action.defaultShortcuts = action.shortcuts() action.defaultShortcuts = action.shortcuts()
if weight is None: if weight is None:
ActionList.categories[category].actions.append(action) self.categories[category].actions.append(action)
else: else:
ActionList.categories[category].actions.add(action, weight) self.categories[category].actions.add(action, weight)
if category is None: if category is None:
# Stop here, as this action is not configurable. # Stop here, as this action is not configurable.
return return
@ -225,8 +233,7 @@ class ActionList(object):
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) [QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
settings.endGroup() settings.endGroup()
@staticmethod def remove_action(self, action, category=None):
def remove_action(action, category=None):
""" """
This removes an action from its category. Empty categories are This removes an action from its category. Empty categories are
automatically removed. automatically removed.
@ -240,15 +247,14 @@ class ActionList(object):
""" """
if category is not None: if category is not None:
category = unicode(category) category = unicode(category)
if category not in ActionList.categories: if category not in self.categories:
return return
ActionList.categories[category].actions.remove(action) self.categories[category].actions.remove(action)
# Remove empty categories. # Remove empty categories.
if len(ActionList.categories[category].actions) == 0: if len(self.categories[category].actions) == 0:
ActionList.categories.remove(category) self.categories.remove(category)
@staticmethod def add_category(self, name, weight):
def add_category(name, weight):
""" """
Add an empty category to the list of categories. This is ony convenient Add an empty category to the list of categories. This is ony convenient
for categories with a given weight. for categories with a given weight.
@ -259,12 +265,20 @@ class ActionList(object):
``weight`` ``weight``
The category's weight (int). The category's weight (int).
""" """
if name in ActionList.categories: if name in self.categories:
# Only change the weight and resort the categories again. # Only change the weight and resort the categories again.
for category in ActionList.categories: for category in self.categories:
if category.name == name: if category.name == name:
category.weight = weight category.weight = weight
ActionList.categories.categories.sort( self.categories.categories.sort(
key=lambda cat: cat.weight, reverse=True) key=lambda cat: cat.weight, reverse=True)
return return
ActionList.categories.add(name, weight) self.categories.add(name, weight)
class CategoryOrder(object):
"""
An enumeration class for category weights.
"""
standardMenu = 100
standardToolbar = 90

View File

@ -75,7 +75,8 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising') log.info(u'Alerts Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.toolsAlertItem.setVisible(True) self.toolsAlertItem.setVisible(True)
ActionList.add_action(self.toolsAlertItem, UiStrings.Tools) action_list = ActionList.get_instance()
action_list.add_action(self.toolsAlertItem, UiStrings.Tools)
self.liveController.alertTab = self.settings_tab self.liveController.alertTab = self.settings_tab
def finalise(self): def finalise(self):
@ -86,7 +87,8 @@ class AlertsPlugin(Plugin):
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
self.toolsAlertItem.setVisible(False) self.toolsAlertItem.setVisible(False)
ActionList.remove_action(self.toolsAlertItem, u'Tools') action_list = ActionList.get_instance()
action_list.remove_action(self.toolsAlertItem, u'Tools')
def toggleAlertsState(self): def toggleAlertsState(self):
self.alertsActive = not self.alertsActive self.alertsActive = not self.alertsActive

View File

@ -52,9 +52,10 @@ class BiblePlugin(Plugin):
self.manager = BibleManager(self) self.manager = BibleManager(self)
Plugin.initialise(self) Plugin.initialise(self)
self.importBibleItem.setVisible(True) self.importBibleItem.setVisible(True)
ActionList.add_action(self.importBibleItem, UiStrings.Import) action_list = ActionList.get_instance()
action_list.add_action(self.importBibleItem, UiStrings.Import)
# Do not add the action to the list yet. # Do not add the action to the list yet.
#ActionList.add_action(self.exportBibleItem, UiStrings.Export) #action_list.add_action(self.exportBibleItem, UiStrings.Export)
# Set to invisible until we can export bibles # Set to invisible until we can export bibles
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
@ -65,9 +66,10 @@ class BiblePlugin(Plugin):
log.info(u'Plugin Finalise') log.info(u'Plugin Finalise')
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
ActionList.remove_action(self.importBibleItem, UiStrings.Import) action_list = ActionList.get_instance()
action_list.remove_action(self.importBibleItem, UiStrings.Import)
self.importBibleItem.setVisible(False) self.importBibleItem.setVisible(False)
#ActionList.remove_action(self.exportBibleItem, UiStrings.Export) #action_list.remove_action(self.exportBibleItem, UiStrings.Export)
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
def addImportMenuItem(self, import_menu): def addImportMenuItem(self, import_menu):

View File

@ -66,9 +66,10 @@ class SongsPlugin(Plugin):
log.info(u'Songs Initialising') log.info(u'Songs Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.toolsReindexItem.setVisible(True) self.toolsReindexItem.setVisible(True)
ActionList.add_action(self.SongImportItem, UiStrings.Import) action_list = ActionList.get_instance()
ActionList.add_action(self.SongExportItem, UiStrings.Export) action_list.add_action(self.SongImportItem, UiStrings.Import)
ActionList.add_action(self.toolsReindexItem, UiStrings.Tools) action_list.add_action(self.SongExportItem, UiStrings.Export)
action_list.add_action(self.toolsReindexItem, UiStrings.Tools)
self.mediaItem.displayResultsSong( self.mediaItem.displayResultsSong(
self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) self.manager.get_all_objects(Song, order_by_ref=Song.search_title))
@ -258,7 +259,8 @@ class SongsPlugin(Plugin):
log.info(u'Songs Finalising') log.info(u'Songs Finalising')
self.manager.finalise() self.manager.finalise()
self.toolsReindexItem.setVisible(False) self.toolsReindexItem.setVisible(False)
ActionList.remove_action(self.SongImportItem, UiStrings.Import) action_list = ActionList.get_instance()
ActionList.remove_action(self.SongExportItem, UiStrings.Export) action_list.remove_action(self.SongImportItem, UiStrings.Import)
ActionList.remove_action(self.toolsReindexItem, UiStrings.Tools) action_list.remove_action(self.SongExportItem, UiStrings.Export)
action_list.remove_action(self.toolsReindexItem, UiStrings.Tools)
Plugin.finalise(self) Plugin.finalise(self)

View File

@ -110,11 +110,12 @@ class SongUsagePlugin(Plugin):
self.settingsSection + u'/active', self.settingsSection + u'/active',
QtCore.QVariant(False)).toBool() QtCore.QVariant(False)).toBool()
self.SongUsageStatus.setChecked(self.SongUsageActive) self.SongUsageStatus.setChecked(self.SongUsageActive)
ActionList.add_action(self.SongUsageDelete, action_list = ActionList.get_instance()
action_list.add_action(self.SongUsageDelete,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
ActionList.add_action(self.SongUsageReport, action_list.add_action(self.SongUsageReport,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
ActionList.add_action(self.SongUsageStatus, action_list.add_action(self.SongUsageStatus,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
if self.manager is None: if self.manager is None:
self.manager = Manager(u'songusage', init_schema) self.manager = Manager(u'songusage', init_schema)
@ -131,11 +132,12 @@ class SongUsagePlugin(Plugin):
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
self.SongUsageMenu.menuAction().setVisible(False) self.SongUsageMenu.menuAction().setVisible(False)
ActionList.remove_action(self.SongUsageDelete, action_list = ActionList.get_instance()
action_list.remove_action(self.SongUsageDelete,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
ActionList.remove_action(self.SongUsageReport, action_list.remove_action(self.SongUsageReport,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
ActionList.remove_action(self.SongUsageStatus, action_list.remove_action(self.SongUsageStatus,
translate('SongUsagePlugin', 'Song Usage')) translate('SongUsagePlugin', 'Song Usage'))
#stop any events being processed #stop any events being processed
self.SongUsageActive = False self.SongUsageActive = False