diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index b524c5d06..fd5a53813 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,7 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC, ability to remove actions (e. g. reindex tool) +#TODO: do not close on ESC #TODO: save/load shortcuts, docs #TODO: Fix Preview/Live controller (have the same shortcut), make sure @@ -94,7 +94,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.treeWidget.clear() for category in actionList.categories: item = QtGui.QTreeWidgetItem([category.name]) - for action, default in category.actions: + for action in category.actions: self.assingedShortcuts.extend(action.shortcuts()) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) if len(action.shortcuts()) == 2: diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index cbfa3a488..8887a7e30 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -71,7 +71,7 @@ class CategoryActionList(object): raise StopIteration else: self.index += 1 - return self.actions[self.index - 1][1:] + return self.actions[self.index - 1][1] def next(self): """ @@ -92,9 +92,15 @@ class CategoryActionList(object): self.add(name, weight) def add(self, action, weight=0): - self.actions.append((weight, action, action.shortcuts())) + self.actions.append((weight, action)) self.actions.sort(key=lambda act: act[0]) + def remove(self, remove_action): + for action in self.actions: + if action[1] == remove_action: + self.actions.remove(action) + return + class CategoryList(object): """ @@ -176,7 +182,7 @@ class ActionList(object): def __init__(self): self.categories = CategoryList() - def add_action(self, action, category=u'Default', weight=None): + def add_action(self, action, category, weight=None): if category not in self.categories: self.categories.append(category) if weight is None: @@ -184,4 +190,9 @@ class ActionList(object): else: self.categories[category].actions.add(action, weight) + def remove_action(self, action, category): + if category not in self.categories: + return + self.categories[category].actions.remove(action) + actionList = ActionList() diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index c397fb9c4..a10d56a20 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -86,7 +86,7 @@ class AlertsPlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) - #TODO: remove the action from the actionList + actionList.remove_action(self.toolsAlertItem, u'Tools') def toggleAlertsState(self): self.alertsActive = not self.alertsActive diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index e1731bc01..e5ce25906 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -34,6 +34,7 @@ from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ Receiver from openlp.core.lib.db import Manager from openlp.core.lib.ui import UiStrings, base_action, icon_action +from openlp.core.utils.actions import actionList from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat @@ -65,6 +66,9 @@ class SongsPlugin(Plugin): log.info(u'Songs Initialising') Plugin.initialise(self) self.toolsReindexItem.setVisible(True) + actionList.add_action(self.SongImportItem, u'Import') + actionList.add_action(self.SongExportItem, u'Export') + actionList.add_action(self.toolsReindexItem, u'Tools') self.mediaItem.displayResultsSong( self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) @@ -78,8 +82,7 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongImportItem = base_action( - import_menu, u'SongImportItem', u'Import') + self.SongImportItem = base_action(import_menu, u'SongImportItem') self.SongImportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongImportItem.setToolTip(translate('SongsPlugin', @@ -99,7 +102,7 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongExportItem = base_action(export_menu, u'SongExportItem', u'Export') + self.SongExportItem = base_action(export_menu, u'SongExportItem') self.SongExportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongExportItem.setToolTip(translate('SongsPlugin', @@ -120,7 +123,7 @@ class SongsPlugin(Plugin): """ log.info(u'add tools menu') self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem', - u':/plugins/plugin_songs.png', category=u'Tools') + u':/plugins/plugin_songs.png') self.toolsReindexItem.setText( translate('SongsPlugin', '&Re-index Songs')) self.toolsReindexItem.setStatusTip( @@ -257,4 +260,7 @@ class SongsPlugin(Plugin): log.info(u'Songs Finalising') self.manager.finalise() self.toolsReindexItem.setVisible(False) + actionList.remove_action(self.SongImportItem, u'Import') + actionList.remove_action(self.SongExportItem, u'Export') + actionList.remove_action(self.toolsReindexItem, u'Tools') Plugin.finalise(self)