started to remove forgotten shortcut kwargs

This commit is contained in:
Andreas Preikschat 2013-02-19 10:13:49 +01:00
parent 6e5df92f2d
commit 781da422b6
10 changed files with 196 additions and 172 deletions

View File

@ -229,26 +229,26 @@ class MediaManagerItem(QtGui.QWidget):
triggers=self.onEditClick)
create_widget_action(self.listView, separator=True)
if self.hasDeleteIcon:
create_widget_action(self.listView,
create_widget_action(self.listView, u'%s%s' % (self.plugin.name, StringContent.Delete),
text=self.plugin.getString(StringContent.Delete)[u'title'],
icon=u':/general/general_delete.png',
shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteClick)
can_shortcuts=True,
triggers=self.onDeleteClick)
create_widget_action(self.listView, separator=True)
create_widget_action(self.listView,
text=self.plugin.getString(StringContent.Preview)[u'title'],
icon=u':/general/general_preview.png',
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
can_shortcuts=True,
triggers=self.onPreviewClick)
create_widget_action(self.listView,
text=self.plugin.getString(StringContent.Live)[u'title'],
icon=u':/general/general_live.png',
shortcuts=[QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter,
QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return],
can_shortcuts=True,
triggers=self.onLiveClick)
create_widget_action(self.listView,
text=self.plugin.getString(StringContent.Service)[u'title'],
can_shortcuts=True,
icon=u':/general/general_add.png',
shortcuts=[QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
triggers=self.onAddClick)
if self.addToServiceItem:
create_widget_action(self.listView, separator=True)

View File

@ -151,12 +151,15 @@ class Settings(QtCore.QSettings):
u'SettingsImport/type': u'OpenLP_settings_export',
u'SettingsImport/version': u'',
u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')],
u'shortcuts/addToService': [],
u'shortcuts/audioPauseItem': [],
u'shortcuts/displayTagItem': [],
u'shortcuts/blankScreen': [QtCore.Qt.Key_Period],
u'shortcuts/collapse': [QtCore.Qt.Key_Minus],
u'shortcuts/desktopScreen': [QtGui.QKeySequence(u'D')],
u'shortcuts/delete': [],
u'shortcuts/down': [QtCore.Qt.Key_Down],
u'shortcuts/editSong': [],
u'shortcuts/escapeItem': [QtCore.Qt.Key_Escape],
u'shortcuts/expand': [QtCore.Qt.Key_Plus],
u'shortcuts/exportThemeItem': [],
@ -165,8 +168,10 @@ class Settings(QtCore.QSettings):
u'shortcuts/fileExitItem': [QtGui.QKeySequence(u'Alt+F4')],
u'shortcuts/fileSaveItem': [QtGui.QKeySequence(u'Ctrl+S')],
u'shortcuts/fileOpenItem': [QtGui.QKeySequence(u'Ctrl+O')],
u'shortcuts/goLive': [],
u'shortcuts/importThemeItem': [],
u'shortcuts/importBibleItem': [],
u'shortcuts/lockPanel': [],
u'shortcuts/modeDefaultItem': [],
u'shortcuts/modeLiveItem': [],
u'shortcuts/make_live': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
@ -177,13 +182,21 @@ class Settings(QtCore.QSettings):
u'shortcuts/moveDown': [QtCore.Qt.Key_PageDown],
u'shortcuts/nextTrackItem': [],
u'shortcuts/nextItem_live': [QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
u'shortcuts/nextItem_preview': [],
u'shortcuts/nextService': [QtCore.Qt.Key_Right],
u'shortcuts/newService': [],
u'shortcuts/offlineHelpItem': [],
u'shortcuts/onlineHelpItem': [QtGui.QKeySequence(u'Alt+F1')],
u'shortcuts/openService': [],
u'shortcuts/saveService': [],
u'shortcuts/previousItem_live': [QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
u'shortcuts/playbackPause': [],
u'shortcuts/playbackPlay': [],
u'shortcuts/playbackStop': [],
u'shortcuts/playSlidesLoop': [],
u'shortcuts/playSlidesOnce': [],
u'shortcuts/previousService': [QtCore.Qt.Key_Left],
u'shortcuts/previousItem_preview': [],
u'shortcuts/printServiceItem': [QtGui.QKeySequence(u'Ctrl+P')],
u'shortcuts/songExportItem': [],
u'shortcuts/songUsageStatus': [QtCore.Qt.Key_F4],
@ -199,6 +212,16 @@ class Settings(QtCore.QSettings):
u'shortcuts/shortcutAction_O': [QtGui.QKeySequence(u'O')],
u'shortcuts/shortcutAction_P': [QtGui.QKeySequence(u'P')],
u'shortcuts/shortcutAction_V': [QtGui.QKeySequence(u'V')],
u'shortcuts/shortcutAction_0': [QtGui.QKeySequence(u'0')],
u'shortcuts/shortcutAction_1': [QtGui.QKeySequence(u'1')],
u'shortcuts/shortcutAction_2': [QtGui.QKeySequence(u'2')],
u'shortcuts/shortcutAction_3': [QtGui.QKeySequence(u'3')],
u'shortcuts/shortcutAction_4': [QtGui.QKeySequence(u'4')],
u'shortcuts/shortcutAction_5': [QtGui.QKeySequence(u'5')],
u'shortcuts/shortcutAction_6': [QtGui.QKeySequence(u'6')],
u'shortcuts/shortcutAction_7': [QtGui.QKeySequence(u'7')],
u'shortcuts/shortcutAction_8': [QtGui.QKeySequence(u'8')],
u'shortcuts/shortcutAction_9': [QtGui.QKeySequence(u'9')],
u'shortcuts/settingsExportItem': [],
u'shortcuts/songUsageReport': [],
u'shortcuts/songImportItem': [],
@ -286,6 +309,14 @@ class Settings(QtCore.QSettings):
else:
QtCore.QSettings.__init__(self, *args)
def get_default_value(self, key):
"""
Get the default value of the given key
"""
if self.group():
key = self.group() + u'/' + key
return Settings.__default_settings__[key]
def remove_obsolete_settings(self):
"""
This method is only called to clean up the config. It removes old settings and it renames settings. See

View File

@ -33,7 +33,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, UiStrings, build_icon, translate
from openlp.core.lib import Receiver, UiStrings, Settings, build_icon, translate
from openlp.core.utils.actions import ActionList
@ -236,6 +236,11 @@ def create_action(parent, name, **kwargs):
Either a QIcon, a resource string, or a file location string for the
action icon.
``can_shortcuts``
Boolean stating if this action has shortcuts or if it can have shortcuts. If ``True`` the action is added to
shortcut dialog. **Note**: Never set the shortcuts yourselt; use the :class:`~openlp.core.lib.Settings` class
to define the action's shortcuts.
``tooltip``
A string for the action tool tip.
@ -257,9 +262,6 @@ def create_action(parent, name, **kwargs):
``data``
The action's data.
``shortcuts``
A QList<QKeySequence> (or a list of strings) which are set as shortcuts.
``context``
A context for the shortcut execution.
@ -290,18 +292,20 @@ def create_action(parent, name, **kwargs):
action.setSeparator(True)
if u'data' in kwargs:
action.setData(kwargs.pop(u'data'))
if kwargs.get(u'shortcuts'):
action.setShortcuts(kwargs.pop(u'shortcuts'))
if u'context' in kwargs:
action.setShortcutContext(kwargs.pop(u'context'))
if kwargs.get(u'category'):
action_list = ActionList.get_instance()
action_list.add_action(action, unicode(kwargs.pop(u'category')))
if kwargs.get(u'triggers'):
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'),
kwargs.pop(u'triggers'))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), kwargs.pop(u'triggers'))
if kwargs.pop(u'can_shortcuts', False):
if not action.objectName():
raise Exception("objectName not set")
action_list = ActionList.get_instance()
action_list.add_action(action, kwargs.pop(u'category', None))
else:
pass
#print u'else', action.objectName()
for key in kwargs.keys():
if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked', u'shortcuts', u'category', u'triggers']:
if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked', u'category', u'triggers']:
log.warn(u'Parameter %s was not consumed in create_action().', key)
return action

View File

@ -174,68 +174,78 @@ class Ui_MainWindow(object):
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock)
# Create the menu items
action_list = ActionList.get_instance()
action_list.add_category(UiStrings().File, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().File, CategoryOrder.standard_menu)
self.fileNewItem = create_action(main_window, u'fileNewItem',
icon=u':/general/general_new.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+N')],
can_shortcuts=True,
category=UiStrings().File,
triggers=self.serviceManagerContents.on_new_service_clicked)
self.fileOpenItem = create_action(main_window, u'fileOpenItem',
icon=u':/general/general_open.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+O')],
can_shortcuts=True,
category=UiStrings().File,
triggers=self.serviceManagerContents.on_load_service_clicked)
self.fileSaveItem = create_action(main_window, u'fileSaveItem',
icon=u':/general/general_save.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+S')],
can_shortcuts=True,
category=UiStrings().File,
triggers=self.serviceManagerContents.save_file)
self.fileSaveAsItem = create_action(main_window, u'fileSaveAsItem',
shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')],
can_shortcuts=True,
category=UiStrings().File,
triggers=self.serviceManagerContents.save_file_as)
self.printServiceOrderItem = create_action(main_window,
u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')],
u'printServiceItem',
can_shortcuts=True,
category=UiStrings().File,
triggers=self.serviceManagerContents.print_service_order)
self.fileExitItem = create_action(main_window, u'fileExitItem',
icon=u':/system/system_exit.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F4')],
category=UiStrings().File, triggers=main_window.close)
can_shortcuts=True,
category=UiStrings().File,
triggers=main_window.close)
# Give QT Extra Hint that this is the Exit Menu Item
self.fileExitItem.setMenuRole(QtGui.QAction.QuitRole)
action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().Import, CategoryOrder.standard_menu)
self.importThemeItem = create_action(main_window, u'importThemeItem', category=UiStrings().Import)
self.importLanguageItem = create_action(main_window, u'importLanguageItem')
action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().Export, CategoryOrder.standard_menu)
self.exportThemeItem = create_action(main_window, u'exportThemeItem', category=UiStrings().Export)
self.exportLanguageItem = create_action(main_window, u'exportLanguageItem')
action_list.add_category(UiStrings().View, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().View, CategoryOrder.standard_menu)
self.viewMediaManagerItem = create_action(main_window,
u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')],
u'viewMediaManagerItem',
icon=u':/system/system_mediamanager.png',
checked=self.mediaManagerDock.isVisible(),
can_shortcuts=True,
category=UiStrings().View, triggers=self.toggleMediaManager)
self.viewThemeManagerItem = create_action(main_window,
u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')],
u'viewThemeManagerItem',
icon=u':/system/system_thememanager.png',
checked=self.themeManagerDock.isVisible(),
can_shortcuts=True,
category=UiStrings().View, triggers=self.toggleThemeManager)
self.viewServiceManagerItem = create_action(main_window,
u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')],
u'viewServiceManagerItem',
icon=u':/system/system_servicemanager.png',
checked=self.serviceManagerDock.isVisible(),
can_shortcuts=True,
category=UiStrings().View, triggers=self.toggleServiceManager)
self.viewPreviewPanel = create_action(main_window, u'viewPreviewPanel',
shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible,
checked=previewVisible,
can_shortcuts=True,
category=UiStrings().View, triggers=self.setPreviewPanelVisibility)
self.viewLivePanel = create_action(main_window, u'viewLivePanel',
shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible,
checked=liveVisible,
can_shortcuts=True,
category=UiStrings().View, triggers=self.setLivePanelVisibility)
self.lockPanel = create_action(main_window, u'lockPanel',
checked=panelLocked, triggers=self.setLockPanel)
checked=panelLocked,
can_shortcuts=True,
category=UiStrings().View,
triggers=self.setLockPanel)
action_list.add_category(UiStrings().ViewMode,
CategoryOrder.standardMenu)
CategoryOrder.standard_menu)
self.modeDefaultItem = create_action(main_window, u'modeDefaultItem', checked=False,
category=UiStrings().ViewMode)
self.modeSetupItem = create_action(main_window, u'modeSetupItem', checked=False, category=UiStrings().ViewMode)
@ -245,7 +255,7 @@ class Ui_MainWindow(object):
self.modeGroup.addAction(self.modeSetupItem)
self.modeGroup.addAction(self.modeLiveItem)
self.modeDefaultItem.setChecked(True)
action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().Tools, CategoryOrder.standard_menu)
self.toolsAddToolItem = create_action(main_window,
u'toolsAddToolItem', icon=u':/tools/tools_add.png',
category=UiStrings().Tools)
@ -258,11 +268,11 @@ class Ui_MainWindow(object):
self.updateThemeImages = create_action(main_window,
u'updateThemeImages', category=UiStrings().Tools)
action_list.add_category(UiStrings().Settings,
CategoryOrder.standardMenu)
CategoryOrder.standard_menu)
self.settingsPluginListItem = create_action(main_window,
u'settingsPluginListItem',
icon=u':/system/settings_plugin_list.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F7')],
can_shortcuts=True,
category=UiStrings().Settings, triggers=self.onPluginItemClicked)
# i18n Language Items
self.autoLanguageItem = create_action(main_window, u'autoLanguageItem',
@ -282,14 +292,14 @@ class Ui_MainWindow(object):
self.formattingTagItem = create_action(main_window, u'displayTagItem',
icon=u':/system/tag_editor.png', category=UiStrings().Settings)
self.settingsConfigureItem = create_action(main_window, u'settingsConfigureItem',
icon=u':/system/system_settings.png', category=UiStrings().Settings)
icon=u':/system/system_settings.png', can_shortcuts=True, category=UiStrings().Settings)
# Give QT Extra Hint that this is the Preferences Menu Item
self.settingsConfigureItem.setMenuRole(QtGui.QAction.PreferencesRole)
self.settingsImportItem = create_action(main_window, u'settingsImportItem', category=UiStrings().Settings)
self.settingsExportItem = create_action(main_window, u'settingsExportItem', category=UiStrings().Settings)
action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().Help, CategoryOrder.standard_menu)
self.aboutItem = create_action(main_window, u'aboutItem', icon=u':/system/system_about.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')],
can_shortcuts=True,
category=UiStrings().Help, triggers=self.onAboutItemClicked)
# Give QT Extra Hint that this is an About Menu Item
self.aboutItem.setMenuRole(QtGui.QAction.AboutRole)
@ -298,11 +308,11 @@ class Ui_MainWindow(object):
AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm')
self.offlineHelpItem = create_action(main_window, u'offlineHelpItem',
icon=u':/system/system_help_contents.png',
shortcuts=[QtGui.QKeySequence(u'F1')],
can_shortcuts=True,
category=UiStrings().Help, triggers=self.onOfflineHelpClicked)
self.onlineHelpItem = create_action(main_window, u'onlineHelpItem',
icon=u':/system/system_online_help.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F1')],
can_shortcuts=True,
category=UiStrings().Help, triggers=self.onOnlineHelpClicked)
self.webSiteItem = create_action(main_window, u'webSiteItem', category=UiStrings().Help)
add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem))

View File

@ -153,52 +153,52 @@ class ServiceManagerDialog(object):
# Add the bottom toolbar
self.order_toolbar = OpenLPToolbar(self)
action_list = ActionList.get_instance()
action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar)
action_list.add_category(UiStrings().Service, CategoryOrder.standard_toolbar)
self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop',
text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'),
shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop)
can_shortcuts=True, category=UiStrings().Service, triggers=self.onServiceTop)
self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp',
text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp)
can_shortcuts=True, category=UiStrings().Service, triggers=self.onServiceUp)
self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown',
text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown)
can_shortcuts=True, category=UiStrings().Service, triggers=self.onServiceDown)
self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom',
text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'),
shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd)
can_shortcuts=True, category=UiStrings().Service, triggers=self.onServiceEnd)
self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down',
text=translate('OpenLP.ServiceManager', 'Move &down'),
text=translate('OpenLP.ServiceManager', 'Move &down'), can_shortcuts=True,
tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False,
shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down)
triggers=self.on_move_selection_down)
action_list.add_action(self.service_manager_list.down)
self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up',
text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager',
'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up],
text=translate('OpenLP.ServiceManager', 'Move up'), can_shortcuts=True,
tooltip=translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), visible=False,
triggers=self.on_move_selection_up)
action_list.add_action(self.service_manager_list.up)
self.order_toolbar.addSeparator()
self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete',
self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', can_shortcuts=True,
text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'),
shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService)
triggers=self.onDeleteFromService)
self.order_toolbar.addSeparator()
self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand',
self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', can_shortcuts=True,
text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png',
tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'),
shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll)
self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse',
category=UiStrings().Service, triggers=self.onExpandAll)
self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', can_shortcuts=True,
text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png',
tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'),
shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll)
category=UiStrings().Service, triggers=self.onCollapseAll)
self.order_toolbar.addSeparator()
self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live',
self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', can_shortcuts=True,
text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png',
tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'),
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service,
category=UiStrings().Service,
triggers=self.make_live)
self.layout.addWidget(self.order_toolbar)
# Connect up our signals and slots

View File

@ -44,6 +44,14 @@ from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
AUDIO_TIME_LABEL_STYLESHEET = u'background-color: palette(background); ' \
u'border-top-color: palette(shadow); ' \
u'border-left-color: palette(shadow); ' \
u'border-bottom-color: palette(light); ' \
u'border-right-color: palette(light); ' \
u'border-radius: 3px; border-style: inset; ' \
u'border-width: 1; font-family: monospace; margin: 2px;'
class DisplayController(QtGui.QWidget):
"""
@ -124,7 +132,7 @@ class SlideController(DisplayController):
self.keypress_queue = deque()
self.keypress_loop = False
self.category = UiStrings().LiveToolbar
ActionList.get_instance().add_category(unicode(self.category), CategoryOrder.standardToolbar)
ActionList.get_instance().add_category(unicode(self.category), CategoryOrder.standard_toolbar)
else:
Registry().register(u'preview_controller', self)
self.typeLabel.setText(UiStrings().Preview)
@ -168,13 +176,13 @@ class SlideController(DisplayController):
self.previousItem = create_action(self, u'previousItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png',
tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut,
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.onSlideSelectedPrevious)
self.toolbar.addAction(self.previousItem)
self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png',
tooltip=translate('OpenLP.SlideController', 'Move to next.'),
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut,
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.onSlideSelectedNextAction)
self.toolbar.addAction(self.nextItem)
self.toolbar.addSeparator()
@ -190,14 +198,14 @@ class SlideController(DisplayController):
self.toolbar.addToolbarWidget(self.hideMenu)
self.blankScreen = create_action(self, u'blankScreen',
text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png',
checked=False, shortcuts=[QtCore.Qt.Key_Period], category=self.category, triggers=self.onBlankDisplay)
checked=False, category=self.category, triggers=self.onBlankDisplay)
self.themeScreen = create_action(self, u'themeScreen',
text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png',
checked=False, shortcuts=[QtGui.QKeySequence(u'T')], category=self.category,
checked=False, category=self.category,
triggers=self.onThemeDisplay)
self.desktopScreen = create_action(self, u'desktopScreen',
text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png',
checked=False, shortcuts=[QtGui.QKeySequence(u'D')], category=self.category,
checked=False, category=self.category,
triggers=self.onHideDisplay)
self.hideMenu.setDefaultAction(self.blankScreen)
self.hideMenu.menu().addAction(self.blankScreen)
@ -225,10 +233,10 @@ class SlideController(DisplayController):
self.playSlidesMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar))
self.toolbar.addToolbarWidget(self.playSlidesMenu)
self.playSlidesLoop = create_action(self, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop,
icon=u':/media/media_time.png', checked=False, shortcuts=[],
icon=u':/media/media_time.png', checked=False,
category=self.category, triggers=self.onPlaySlidesLoop)
self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
icon=u':/media/media_time.png', checked=False, shortcuts=[],
icon=u':/media/media_time.png', checked=False,
category=self.category, triggers=self.onPlaySlidesOnce)
if Settings().value(self.parent().advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap:
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
@ -267,7 +275,7 @@ class SlideController(DisplayController):
icon=u':/slides/media_playback_pause.png', text=translate('OpenLP.SlideController', 'Pause Audio'),
tooltip=translate('OpenLP.SlideController', 'Pause audio.'),
checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut,
shortcuts=[], triggers=self.onAudioPauseClicked)
triggers=self.onAudioPauseClicked)
self.audioMenu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar)
self.audioPauseItem.setMenu(self.audioMenu)
self.audioPauseItem.setParent(self.toolbar)
@ -276,20 +284,12 @@ class SlideController(DisplayController):
self.nextTrackItem = create_action(self, u'nextTrackItem', text=UiStrings().NextTrack,
icon=u':/slides/media_playback_next.png',
tooltip=translate('OpenLP.SlideController', 'Go to next audio track.'),
category=self.category, shortcuts=[], triggers=self.onNextTrackClicked)
category=self.category, triggers=self.onNextTrackClicked)
self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks'))
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setStyleSheet(
u'background-color: palette(background); '
u'border-top-color: palette(shadow); '
u'border-left-color: palette(shadow); '
u'border-bottom-color: palette(light); '
u'border-right-color: palette(light); '
u'border-radius: 3px; border-style: inset; '
u'border-width: 1; font-family: monospace; margin: 2px;'
)
self.audioTimeLabel.setStyleSheet(AUDIO_TIME_LABEL_STYLESHEET)
self.audioTimeLabel.setObjectName(u'audioTimeLabel')
self.toolbar.addToolbarWidget(self.audioTimeLabel)
self.toolbar.setWidgetVisible(self.audioList, False)
@ -334,28 +334,22 @@ class SlideController(DisplayController):
self.shortcutTimer = QtCore.QTimer()
self.shortcutTimer.setObjectName(u'shortcutTimer')
self.shortcutTimer.setSingleShot(True)
shortcuts = [{u'key': u'V', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Verse"')},
{u'key': u'C', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Chorus"')},
{u'key': u'B', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Bridge"')},
shortcuts = [
{u'key': u'V', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Verse"')},
{u'key': u'C', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Chorus"')},
{u'key': u'B', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Bridge"')},
{u'key': u'P', u'configurable': True,
u'text': translate('OpenLP.SlideController',
'Go to "Pre-Chorus"')},
{u'key': u'I', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Intro"')},
{u'key': u'E', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Ending"')},
{u'key': u'O', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Other"')}]
shortcuts += [{u'key': unicode(number)} for number in range(10)]
u'text': translate('OpenLP.SlideController', 'Go to "Pre-Chorus"')},
{u'key': u'I', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Intro"')},
{u'key': u'E', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Ending"')},
{u'key': u'O', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Other"')}
]
shortcuts.extend([{u'key': unicode(number)} for number in range(10)])
self.previewListWidget.addActions([create_action(self,
u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'),
shortcuts=[QtGui.QKeySequence(s[u'key'])],
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category if s.get(u'configurable') else None,
triggers=self._slideShortcutActivated) for s in shortcuts])
triggers=self._slideShortcutActivated, can_shortcuts=True) for s in shortcuts])
QtCore.QObject.connect(
self.shortcutTimer, QtCore.SIGNAL(u'timeout()'),
self._slideShortcutActivated)
@ -461,15 +455,15 @@ class SlideController(DisplayController):
"""
self.previousService = create_action(parent, u'previousService',
text=translate('OpenLP.SlideController', 'Previous Service'),
shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.servicePrevious)
self.nextService = create_action(parent, 'nextService',
text=translate('OpenLP.SlideController', 'Next Service'),
shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.serviceNext)
self.escapeItem = create_action(parent, 'escapeItem',
text=translate('OpenLP.SlideController', 'Escape Item'),
shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.liveEscape)
def liveEscape(self):

View File

@ -37,8 +37,8 @@ from openlp.core.lib import Settings
class ActionCategory(object):
"""
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
category for the :class:`~openlp.core.utils.CategoryList` class.
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a category for the
:class:`~openlp.core.utils.CategoryList` class.
"""
def __init__(self, name, weight=0):
"""
@ -51,8 +51,7 @@ class ActionCategory(object):
class CategoryActionList(object):
"""
The :class:`~openlp.core.utils.CategoryActionList` class provides a sorted
list of actions within a category.
The :class:`~openlp.core.utils.CategoryActionList` class provides a sorted list of actions within a category.
"""
def __init__(self):
"""
@ -142,9 +141,9 @@ class CategoryActionList(object):
class CategoryList(object):
"""
The :class:`~openlp.core.utils.CategoryList` class encapsulates a category
list for the :class:`~openlp.core.utils.ActionList` class and provides an
iterator interface for walking through the list of actions in this category.
The :class:`~openlp.core.utils.CategoryList` class encapsulates a category list for the
:class:`~openlp.core.utils.ActionList` class and provides an iterator interface for walking through the list of
actions in this category.
"""
def __init__(self):
@ -244,10 +243,9 @@ class CategoryList(object):
class ActionList(object):
"""
The :class:`~openlp.core.utils.ActionList` class contains a list of menu
actions and categories associated with those actions. Each category also
has a weight by which it is sorted when iterating through the list of
actions or categories.
The :class:`~openlp.core.utils.ActionList` class contains a list of menu actions and categories associated with
those actions. Each category also has a weight by which it is sorted when iterating through the list of actions or
categories.
"""
instance = None
shortcut_map = {}
@ -271,48 +269,44 @@ class ActionList(object):
"""
Add an action to the list of actions.
**Note**: The action's objectName must be set when you want to add it!
``action``
The action to add (QAction). **Note**, the action must not have an
empty ``objectName``.
The action to add (QAction). **Note**, the action must not have an empty ``objectName``.
``category``
The category this action belongs to. The category has to be a python
string. . **Note**, if the category is ``None``, the category and
its actions are being hidden in the shortcut dialog. However, if
they are added, it is possible to avoid assigning shortcuts twice,
which is important.
The category this action belongs to. The category has to be a python string. . **Note**, if the category
is ``None``, the category and its actions are being hidden in the shortcut dialog. However, if they are
added, it is possible to avoid assigning shortcuts twice, which is important.
``weight``
The weight specifies how important a category is. However, this only
has an impact on the order the categories are displayed.
The weight specifies how important a category is. However, this only has an impact on the order the
categories are displayed.
"""
if category not in self.categories:
self.categories.append(category)
action.defaultShortcuts = action.shortcuts()
settings = Settings()
settings.beginGroup(u'shortcuts')
# Get the default shortcut from the config.
action.defaultShortcuts = settings.get_default_value(action.objectName())
if weight is None:
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
# Load the shortcut from the config.
settings = Settings()
settings.beginGroup(u'shortcuts')
shortcuts = settings.value(action.objectName())
settings.endGroup()
if not shortcuts:
action.setShortcuts([])
return
# We have to do this to ensure that the loaded shortcut list e. g.
# STRG+O (German) is converted to CTRL+O, which is only done when we
# convert the strings in this way (QKeySequence -> QString -> unicode).
shortcuts = map(QtGui.QKeySequence, shortcuts)
shortcuts = map(unicode, map(QtGui.QKeySequence.toString, shortcuts))
# Check the alternate shortcut first, to avoid problems when the
# alternate shortcut becomes the primary shortcut after removing the
# (initial) primary shortcut due to conflicts.
# We have to do this to ensure that the loaded shortcut list e. g. STRG+O (German) is converted to CTRL+O,
# which is only done when we convert the strings in this way (QKeySequencet -> uncode).
shortcuts = map(QtGui.QKeySequence.toString, map(QtGui.QKeySequence, shortcuts))
# Check the alternate shortcut first, to avoid problems when the alternate shortcut becomes the primary shortcut
# after removing the (initial) primary shortcut due to conflicts.
if len(shortcuts) == 2:
existing_actions = ActionList.shortcut_map.get(shortcuts[1], [])
# Check for conflicts with other actions considering the shortcut
# context.
# Check for conflicts with other actions considering the shortcut context.
if self._is_shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[1], [])
actions.append(action)
@ -321,28 +315,24 @@ class ActionList(object):
shortcuts.remove(shortcuts[1])
# Check the primary shortcut.
existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
# Check for conflicts with other actions considering the shortcut
# context.
# Check for conflicts with other actions considering the shortcut context.
if self._is_shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[0], [])
actions.append(action)
ActionList.shortcut_map[shortcuts[0]] = actions
else:
shortcuts.remove(shortcuts[0])
action.setShortcuts(
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
def remove_action(self, action, category=None):
"""
This removes an action from its category. Empty categories are
automatically removed.
This removes an action from its category. Empty categories are automatically removed.
``action``
The ``QAction`` object to be removed.
``category``
The name (unicode string) of the category, which contains the
action. Defaults to None.
The name (unicode string) of the category, which contains the action. Defaults to None.
"""
if category not in self.categories:
return
@ -350,10 +340,9 @@ class ActionList(object):
# Remove empty categories.
if not self.categories[category].actions:
self.categories.remove(category)
shortcuts = map(unicode, map(QtGui.QKeySequence.toString, action.shortcuts()))
shortcuts = map(QtGui.QKeySequence.toString, action.shortcuts())
for shortcut in shortcuts:
# Remove action from the list of actions which are using this
# shortcut.
# Remove action from the list of actions which are using this shortcut.
ActionList.shortcut_map[shortcut].remove(action)
# Remove empty entries.
if not ActionList.shortcut_map[shortcut]:
@ -361,8 +350,7 @@ class ActionList(object):
def add_category(self, name, weight):
"""
Add an empty category to the list of categories. This is ony convenient
for categories with a given weight.
Add an empty category to the list of categories. This is ony convenient for categories with a given weight.
``name``
The category's name.
@ -381,27 +369,24 @@ class ActionList(object):
def update_shortcut_map(self, action, old_shortcuts):
"""
Remove the action for the given ``old_shortcuts`` from the
``shortcut_map`` to ensure its up-to-dateness.
Remove the action for the given ``old_shortcuts`` from the ``shortcut_map`` to ensure its up-to-dateness.
**Note**: The new action's shortcuts **must** be assigned to the given
``action`` **before** calling this method.
**Note**: The new action's shortcuts **must** be assigned to the given ``action`` **before** calling this
method.
``action``
The action whose shortcuts are supposed to be updated in the
``shortcut_map``.
The action whose shortcuts are supposed to be updated in the ``shortcut_map``.
``old_shortcuts``
A list of unicode keysequences.
"""
for old_shortcut in old_shortcuts:
# Remove action from the list of actions which are using this
# shortcut.
# Remove action from the list of actions which are using this shortcut.
ActionList.shortcut_map[old_shortcut].remove(action)
# Remove empty entries.
if not ActionList.shortcut_map[old_shortcut]:
del ActionList.shortcut_map[old_shortcut]
new_shortcuts = map(unicode, map(QtGui.QKeySequence.toString, action.shortcuts()))
new_shortcuts = map(QtGui.QKeySequence.toString, action.shortcuts())
# Add the new shortcuts to the map.
for new_shortcut in new_shortcuts:
existing_actions = ActionList.shortcut_map.get(new_shortcut, [])
@ -410,8 +395,7 @@ class ActionList(object):
def _is_shortcut_available(self, existing_actions, action):
"""
Checks if the given ``action`` may use its assigned shortcut(s) or not.
Returns ``True`` or ``False.
Checks if the given ``action`` may use its assigned shortcut(s) or not. Returns ``True`` or ``False.
``existing_actions``
A list of actions which already use a particular shortcut.
@ -420,8 +404,10 @@ class ActionList(object):
The action which wants to use a particular shortcut.
"""
local = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]
affected_actions = filter(lambda a: isinstance(a, QtGui.QAction),
self.getAllChildObjects(action.parent())) if local else []
affected_actions = []
if local:
affected_actions = filter(
lambda a: isinstance(a, QtGui.QAction), self.get_all_child_objects(action.parent()))
for existing_action in existing_actions:
if action is existing_action:
continue
@ -429,18 +415,17 @@ class ActionList(object):
return False
if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
return False
elif action in self.getAllChildObjects(existing_action.parent()):
elif action in self.get_all_child_objects(existing_action.parent()):
return False
return True
def getAllChildObjects(self, qobject):
def get_all_child_objects(self, qobject):
"""
Goes recursively through the children of ``qobject`` and returns a list
of all child objects.
Goes recursively through the children of ``qobject`` and returns a list of all child objects.
"""
children = [child for child in qobject.children()]
for child in qobject.children():
children.append(self.getAllChildObjects(child))
children = qobject.children()
# Append the children's children.
children.extend(map(self.get_all_child_objects, children))
return children
@ -448,5 +433,5 @@ class CategoryOrder(object):
"""
An enumeration class for category weights.
"""
standardMenu = -20
standardToolbar = -10
standard_menu = -20
standard_toolbar = -10

View File

@ -150,7 +150,7 @@ class AlertsPlugin(Plugin):
self.toolsAlertItem = create_action(tools_menu, u'toolsAlertItem',
text=translate('AlertsPlugin', '&Alert'), icon=u':/plugins/plugin_alerts.png',
statustip=translate('AlertsPlugin', 'Show an alert message.'),
visible=False, shortcuts=[u'F7'], triggers=self.onAlertsTrigger)
visible=False, triggers=self.onAlertsTrigger)
self.main_window.toolsMenu.addAction(self.toolsAlertItem)
def initialise(self):

View File

@ -32,7 +32,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, ItemCapabilities, Receiver, SettingsManager, ServiceItemContext, \
from openlp.core.lib import MediaManagerItem, ItemCapabilities, Receiver, ServiceItemContext, \
Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, create_thumb, translate, \
validate_thumb
from openlp.core.lib.ui import critical_error_message_box
@ -107,7 +107,7 @@ class ImageMediaItem(MediaManagerItem):
delete_file(os.path.join(self.servicePath, text.text()))
self.listView.takeItem(row)
self.main_window.incrementProgressBar()
SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList())
Settings.setValue(self.settingsSection + u'/images files', self.getFileList())
self.main_window.finishedProgressBar()
self.application.set_normal_cursor()
self.listView.blockSignals(False)

View File

@ -100,7 +100,7 @@ class SongUsagePlugin(Plugin):
self.songUsageStatus = create_action(tools_menu, u'songUsageStatus',
text=translate('SongUsagePlugin', 'Toggle Tracking'),
statustip=translate('SongUsagePlugin', 'Toggle the tracking of song usage.'), checked=False,
shortcuts=[QtCore.Qt.Key_F4], triggers=self.toggleSongUsageState)
triggers=self.toggleSongUsageState)
# Add Menus together
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
self.songUsageMenu.addAction(self.songUsageStatus)