r2194 + conflict

This commit is contained in:
Andreas Preikschat 2013-02-27 12:33:03 +01:00
commit 25b1584a9d
14 changed files with 672 additions and 657 deletions

View File

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

View File

@ -152,42 +152,99 @@ class Settings(QtCore.QSettings):
u'SettingsImport/type': u'OpenLP_settings_export', u'SettingsImport/type': u'OpenLP_settings_export',
u'SettingsImport/version': u'', u'SettingsImport/version': u'',
u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')], u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')],
u'shortcuts/addToService': [],
u'shortcuts/audioPauseItem': [], u'shortcuts/audioPauseItem': [],
u'shortcuts/displayTagItem': [], u'shortcuts/displayTagItem': [],
u'shortcuts/blankScreen': [QtCore.Qt.Key_Period], u'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)],
u'shortcuts/collapse': [QtCore.Qt.Key_Minus], u'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)],
u'shortcuts/desktopScreen': [QtGui.QKeySequence(u'D')], u'shortcuts/desktopScreen': [QtGui.QKeySequence(u'D')],
u'shortcuts/down': [QtCore.Qt.Key_Down], u'shortcuts/delete': [],
u'shortcuts/escapeItem': [QtCore.Qt.Key_Escape], u'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)],
u'shortcuts/expand': [QtCore.Qt.Key_Plus], u'shortcuts/editSong': [],
u'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)],
u'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)],
u'shortcuts/exportThemeItem': [], u'shortcuts/exportThemeItem': [],
u'shortcuts/fileNewItem': [QtGui.QKeySequence(u'Ctrl+N')], u'shortcuts/fileNewItem': [QtGui.QKeySequence(u'Ctrl+N')],
u'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(u'Ctrl+Shift+S')], u'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(u'Ctrl+Shift+S')],
u'shortcuts/fileExitItem': [QtGui.QKeySequence(u'Alt+F4')], u'shortcuts/fileExitItem': [QtGui.QKeySequence(u'Alt+F4')],
u'shortcuts/fileSaveItem': [QtGui.QKeySequence(u'Ctrl+S')], u'shortcuts/fileSaveItem': [QtGui.QKeySequence(u'Ctrl+S')],
u'shortcuts/fileOpenItem': [QtGui.QKeySequence(u'Ctrl+O')], u'shortcuts/fileOpenItem': [QtGui.QKeySequence(u'Ctrl+O')],
u'shortcuts/goLive': [],
u'shortcuts/importThemeItem': [], u'shortcuts/importThemeItem': [],
u'shortcuts/importBibleItem': [], u'shortcuts/importBibleItem': [],
u'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
u'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
u'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
u'shortcuts/lockPanel': [],
u'shortcuts/modeDefaultItem': [], u'shortcuts/modeDefaultItem': [],
u'shortcuts/modeLiveItem': [], u'shortcuts/modeLiveItem': [],
u'shortcuts/make_live': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], u'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), QtGui.QKeySequence(QtCore.Qt.Key_Return)],
u'shortcuts/moveUp': [QtCore.Qt.Key_PageUp], u'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
u'shortcuts/moveTop': [QtCore.Qt.Key_Home], u'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)],
u'shortcuts/modeSetupItem': [], u'shortcuts/modeSetupItem': [],
u'shortcuts/moveBottom': [QtCore.Qt.Key_End], u'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)],
u'shortcuts/moveDown': [QtCore.Qt.Key_PageDown], u'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
u'shortcuts/nextTrackItem': [], u'shortcuts/nextTrackItem': [],
u'shortcuts/nextItem_live': [QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], u'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
u'shortcuts/nextService': [QtCore.Qt.Key_Right], QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
u'shortcuts/nextItem_preview': [],
u'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)],
u'shortcuts/newService': [],
u'shortcuts/offlineHelpItem': [], u'shortcuts/offlineHelpItem': [],
u'shortcuts/onlineHelpItem': [QtGui.QKeySequence(u'Alt+F1')], u'shortcuts/onlineHelpItem': [QtGui.QKeySequence(u'Alt+F1')],
u'shortcuts/previousItem_live': [QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], u'shortcuts/openService': [],
u'shortcuts/saveService': [],
u'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up),
QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
u'shortcuts/playbackPause': [],
u'shortcuts/playbackPlay': [],
u'shortcuts/playbackStop': [],
u'shortcuts/playSlidesLoop': [], u'shortcuts/playSlidesLoop': [],
u'shortcuts/playSlidesOnce': [], u'shortcuts/playSlidesOnce': [],
u'shortcuts/previousService': [QtCore.Qt.Key_Left], u'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)],
u'shortcuts/previousItem_preview': [],
u'shortcuts/printServiceItem': [QtGui.QKeySequence(u'Ctrl+P')], u'shortcuts/printServiceItem': [QtGui.QKeySequence(u'Ctrl+P')],
u'shortcuts/songExportItem': [], u'shortcuts/songExportItem': [],
u'shortcuts/songUsageStatus': [QtCore.Qt.Key_F4], u'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)],
u'shortcuts/settingsShortcutsItem': [], u'shortcuts/settingsShortcutsItem': [],
u'shortcuts/settingsImportItem': [], u'shortcuts/settingsImportItem': [],
u'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(u'Alt+F7')], u'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(u'Alt+F7')],
@ -200,17 +257,27 @@ class Settings(QtCore.QSettings):
u'shortcuts/shortcutAction_O': [QtGui.QKeySequence(u'O')], u'shortcuts/shortcutAction_O': [QtGui.QKeySequence(u'O')],
u'shortcuts/shortcutAction_P': [QtGui.QKeySequence(u'P')], u'shortcuts/shortcutAction_P': [QtGui.QKeySequence(u'P')],
u'shortcuts/shortcutAction_V': [QtGui.QKeySequence(u'V')], 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/settingsExportItem': [],
u'shortcuts/songUsageReport': [], u'shortcuts/songUsageReport': [],
u'shortcuts/songImportItem': [], u'shortcuts/songImportItem': [],
u'shortcuts/themeScreen': [QtGui.QKeySequence(u'T')], u'shortcuts/themeScreen': [QtGui.QKeySequence(u'T')],
u'shortcuts/toolsReindexItem': [], u'shortcuts/toolsReindexItem': [],
u'shortcuts/toolsAlertItem': [u'F7'], u'shortcuts/toolsAlertItem': [QtGui.QKeySequence(u'F7')],
u'shortcuts/toolsFirstTimeWizard': [], u'shortcuts/toolsFirstTimeWizard': [],
u'shortcuts/toolsOpenDataFolder': [], u'shortcuts/toolsOpenDataFolder': [],
u'shortcuts/toolsAddToolItem': [], u'shortcuts/toolsAddToolItem': [],
u'shortcuts/updateThemeImages': [], u'shortcuts/updateThemeImages': [],
u'shortcuts/up': [QtCore.Qt.Key_Up], u'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)],
u'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(u'F10')], u'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(u'F10')],
u'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(u'F8')], u'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(u'F8')],
u'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(u'F11')], u'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(u'F11')],
@ -287,6 +354,14 @@ class Settings(QtCore.QSettings):
else: else:
QtCore.QSettings.__init__(self, *args) 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): def remove_obsolete_settings(self):
""" """
This method is only called to clean up the config. It removes old settings and it renames settings. See This method is only called to clean up the config. It removes old settings and it renames settings. See

View File

@ -69,9 +69,8 @@ def add_welcome_page(parent, image):
def create_button_box(dialog, name, standard_buttons, custom_buttons=None): def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
""" """
Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and ``rejected()`` signals of the button box
``rejected()`` signals of the button box are connected with the dialogs are connected with the dialogs ``accept()`` and ``reject()`` slots.
``accept()`` and ``reject()`` slots.
``dialog`` ``dialog``
The parent object. This has to be a ``QDialog`` descendant. The parent object. This has to be a ``QDialog`` descendant.
@ -80,13 +79,12 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
A string which is set as object name. A string which is set as object name.
``standard_buttons`` ``standard_buttons``
A list of strings for the used buttons. It might contain: ``ok``, A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, ``close``, and
``save``, ``cancel``, ``close``, and ``defaults``. ``defaults``.
``custom_buttons`` ``custom_buttons``
A list of additional buttons. If a item is a instance of A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added with
QtGui.QAbstractButton it is added with QDialogButtonBox.ActionRole. QDialogButtonBox.ActionRole. Otherwhise the item has to be a tuple of a button and a ButtonRole.
Otherwhise the item has to be a tuple of a button and a ButtonRole.
""" """
if custom_buttons is None: if custom_buttons is None:
custom_buttons = [] custom_buttons = []
@ -116,8 +114,7 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
def critical_error_message_box(title=None, message=None, parent=None, question=False): def critical_error_message_box(title=None, message=None, parent=None, question=False):
""" """
Provides a standard critical message box for errors that OpenLP displays Provides a standard critical message box for errors that OpenLP displays to users.
to users.
``title`` ``title``
The title for the message box. The title for the message box.
@ -134,7 +131,6 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F
if question: if question:
return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, return QtGui.QMessageBox.critical(parent, UiStrings().Error, message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
data = {u'message': message}
return Registry().get(u'main_window').error_message(title if title else UiStrings().Error, message) return Registry().get(u'main_window').error_message(title if title else UiStrings().Error, message)
@ -166,16 +162,14 @@ def create_button(parent, name, **kwargs):
A string which is set as object name (required). A string which is set as object name (required).
``role`` ``role``
A string which can have one value out of ``delete``, ``up``, and A string which can have one value out of ``delete``, ``up``, and ``down``. This decides about default values
``down``. This decides about default values for properties like text, for properties like text, icon, or tooltip.
icon, or tooltip.
``text`` ``text``
A string for the action text. A string for the action text.
``icon`` ``icon``
Either a QIcon, a resource string, or a file location string for the Either a QIcon, a resource string, or a file location string for the action icon.
action icon.
``tooltip`` ``tooltip``
A string for the action tool tip. A string for the action tool tip.
@ -195,8 +189,7 @@ def create_button(parent, name, **kwargs):
kwargs.setdefault(u'icon', u':/services/service_down.png') kwargs.setdefault(u'icon', u':/services/service_down.png')
kwargs.setdefault(u'tooltip', translate('OpenLP.Ui', 'Move selection down one position.')) kwargs.setdefault(u'tooltip', translate('OpenLP.Ui', 'Move selection down one position.'))
else: else:
log.warn(u'The role "%s" is not defined in create_push_button().', log.warn(u'The role "%s" is not defined in create_push_button().', role)
role)
if kwargs.pop(u'class', u'') == u'toolbutton': if kwargs.pop(u'class', u'') == u'toolbutton':
button = QtGui.QToolButton(parent) button = QtGui.QToolButton(parent)
else: else:
@ -256,8 +249,10 @@ def create_action(parent, name, **kwargs):
``data`` ``data``
The action's data. The action's data.
``shortcuts`` ``can_shortcuts``
A QList<QKeySequence> (or a list of strings) which are set as shortcuts. Capability stating if this action can have shortcuts. If ``True`` the action is added to shortcut dialog
otherwise it it not. Define your shortcut in the :class:`~openlp.core.lib.Settings` class. *Note*: When *not*
``True`` you *must not* set a shortcuts at all.
``context`` ``context``
A context for the shortcut execution. A context for the shortcut execution.
@ -289,26 +284,24 @@ def create_action(parent, name, **kwargs):
action.setSeparator(True) action.setSeparator(True)
if u'data' in kwargs: if u'data' in kwargs:
action.setData(kwargs.pop(u'data')) action.setData(kwargs.pop(u'data'))
if kwargs.get(u'shortcuts'): if kwargs.pop(u'can_shortcuts', False):
action.setShortcuts(kwargs.pop(u'shortcuts')) action_list = ActionList.get_instance()
action_list.add_action(action, kwargs.pop(u'category', None))
if u'context' in kwargs: if u'context' in kwargs:
action.setShortcutContext(kwargs.pop(u'context')) 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'): if kwargs.get(u'triggers'):
action.triggered.connect(kwargs.pop(u'triggers')) action.triggered.connect(kwargs.pop(u'triggers'))
for key in kwargs.keys(): 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'can_shortcuts',
u'category', u'triggers']:
log.warn(u'Parameter %s was not consumed in create_action().', key) log.warn(u'Parameter %s was not consumed in create_action().', key)
return action return action
def create_widget_action(parent, name=u'', **kwargs): def create_widget_action(parent, name=u'', **kwargs):
""" """
Return a new QAction by calling ``create_action(parent, name, **kwargs)``. Return a new QAction by calling ``create_action(parent, name, **kwargs)``. The shortcut context defaults to
The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action ``QtCore.Qt.WidgetShortcut`` and the action is added to the parents action list.
is added to the parents action list.
""" """
kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut) kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut)
action = create_action(parent, name, **kwargs) action = create_action(parent, name, **kwargs)
@ -333,8 +326,7 @@ def set_case_insensitive_completer(cache, widget):
def create_valign_selection_widgets(parent): def create_valign_selection_widgets(parent):
""" """
Creates a standard label and combo box for asking users to select a Creates a standard label and combo box for asking users to select a vertical alignment.
vertical alignment.
``parent`` ``parent``
The parent object. This should be a ``QWidget`` descendant. The parent object. This should be a ``QWidget`` descendant.

View File

@ -174,99 +174,101 @@ class Ui_MainWindow(object):
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock)
# Create the menu items # Create the menu items
action_list = ActionList.get_instance() 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', self.fileNewItem = create_action(main_window, u'fileNewItem',
icon=u':/general/general_new.png', icon=u':/general/general_new.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+N')], can_shortcuts=True,
category=UiStrings().File, category=UiStrings().File,
triggers=self.serviceManagerContents.on_new_service_clicked) triggers=self.serviceManagerContents.on_new_service_clicked)
self.fileOpenItem = create_action(main_window, u'fileOpenItem', self.fileOpenItem = create_action(main_window, u'fileOpenItem',
icon=u':/general/general_open.png', icon=u':/general/general_open.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+O')], can_shortcuts=True,
category=UiStrings().File, category=UiStrings().File,
triggers=self.serviceManagerContents.on_load_service_clicked) triggers=self.serviceManagerContents.on_load_service_clicked)
self.fileSaveItem = create_action(main_window, u'fileSaveItem', self.fileSaveItem = create_action(main_window, u'fileSaveItem',
icon=u':/general/general_save.png', icon=u':/general/general_save.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+S')], can_shortcuts=True,
category=UiStrings().File, category=UiStrings().File,
triggers=self.serviceManagerContents.save_file) triggers=self.serviceManagerContents.save_file)
self.fileSaveAsItem = create_action(main_window, u'fileSaveAsItem', self.fileSaveAsItem = create_action(main_window, u'fileSaveAsItem',
shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')], can_shortcuts=True,
category=UiStrings().File, category=UiStrings().File,
triggers=self.serviceManagerContents.save_file_as) triggers=self.serviceManagerContents.save_file_as)
self.printServiceOrderItem = create_action(main_window, self.printServiceOrderItem = create_action(main_window,
u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')], u'printServiceItem', can_shortcuts=True,
category=UiStrings().File, category=UiStrings().File,
triggers=self.serviceManagerContents.print_service_order) triggers=self.serviceManagerContents.print_service_order)
self.fileExitItem = create_action(main_window, u'fileExitItem', self.fileExitItem = create_action(main_window, u'fileExitItem',
icon=u':/system/system_exit.png', icon=u':/system/system_exit.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F4')], can_shortcuts=True,
category=UiStrings().File, triggers=main_window.close) category=UiStrings().File, triggers=main_window.close)
# Give QT Extra Hint that this is the Exit Menu Item # Give QT Extra Hint that this is the Exit Menu Item
self.fileExitItem.setMenuRole(QtGui.QAction.QuitRole) 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.importThemeItem = create_action(
main_window, u'importThemeItem', category=UiStrings().Import, can_shortcuts=True)
self.importLanguageItem = create_action(main_window, u'importLanguageItem') 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.exportThemeItem = create_action(
main_window, u'exportThemeItem', category=UiStrings().Export, can_shortcuts=True)
self.exportLanguageItem = create_action(main_window, u'exportLanguageItem') 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, self.viewMediaManagerItem = create_action(main_window,
u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], u'viewMediaManagerItem',
icon=u':/system/system_mediamanager.png', icon=u':/system/system_mediamanager.png',
checked=self.mediaManagerDock.isVisible(), checked=self.mediaManagerDock.isVisible(),
can_shortcuts=True,
category=UiStrings().View, triggers=self.toggleMediaManager) category=UiStrings().View, triggers=self.toggleMediaManager)
self.viewThemeManagerItem = create_action(main_window, self.viewThemeManagerItem = create_action(main_window,
u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')], u'viewThemeManagerItem', can_shortcuts=True,
icon=u':/system/system_thememanager.png', icon=u':/system/system_thememanager.png',
checked=self.themeManagerDock.isVisible(), checked=self.themeManagerDock.isVisible(),
category=UiStrings().View, triggers=self.toggleThemeManager) category=UiStrings().View, triggers=self.toggleThemeManager)
self.viewServiceManagerItem = create_action(main_window, self.viewServiceManagerItem = create_action(main_window,
u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')], u'viewServiceManagerItem', can_shortcuts=True,
icon=u':/system/system_servicemanager.png', icon=u':/system/system_servicemanager.png',
checked=self.serviceManagerDock.isVisible(), checked=self.serviceManagerDock.isVisible(),
category=UiStrings().View, triggers=self.toggleServiceManager) category=UiStrings().View, triggers=self.toggleServiceManager)
self.viewPreviewPanel = create_action(main_window, u'viewPreviewPanel', self.viewPreviewPanel = create_action(main_window, u'viewPreviewPanel',
shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible, can_shortcuts=True, checked=previewVisible,
category=UiStrings().View, triggers=self.setPreviewPanelVisibility) category=UiStrings().View, triggers=self.setPreviewPanelVisibility)
self.viewLivePanel = create_action(main_window, u'viewLivePanel', self.viewLivePanel = create_action(main_window, u'viewLivePanel',
shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible, can_shortcuts=True, checked=liveVisible,
category=UiStrings().View, triggers=self.setLivePanelVisibility) category=UiStrings().View, triggers=self.setLivePanelVisibility)
self.lockPanel = create_action(main_window, u'lockPanel', self.lockPanel = create_action(main_window, u'lockPanel',
checked=panelLocked, triggers=self.setLockPanel) can_shortcuts=True, checked=panelLocked,
action_list.add_category(UiStrings().ViewMode, category=UiStrings().View,
CategoryOrder.standardMenu) triggers=self.setLockPanel)
self.modeDefaultItem = create_action(main_window, u'modeDefaultItem', checked=False, action_list.add_category(UiStrings().ViewMode, CategoryOrder.standard_menu)
category=UiStrings().ViewMode) self.modeDefaultItem = create_action(
self.modeSetupItem = create_action(main_window, u'modeSetupItem', checked=False, category=UiStrings().ViewMode) main_window, u'modeDefaultItem', checked=False, category=UiStrings().ViewMode, can_shortcuts=True)
self.modeLiveItem = create_action(main_window, u'modeLiveItem', checked=True, category=UiStrings().ViewMode) self.modeSetupItem = create_action(
main_window, u'modeSetupItem', checked=False, category=UiStrings().ViewMode, can_shortcuts=True)
self.modeLiveItem = create_action(
main_window, u'modeLiveItem', checked=True, category=UiStrings().ViewMode, can_shortcuts=True)
self.modeGroup = QtGui.QActionGroup(main_window) self.modeGroup = QtGui.QActionGroup(main_window)
self.modeGroup.addAction(self.modeDefaultItem) self.modeGroup.addAction(self.modeDefaultItem)
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)
action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu) action_list.add_category(UiStrings().Tools, CategoryOrder.standard_menu)
self.toolsAddToolItem = create_action(main_window, self.toolsAddToolItem = create_action(main_window,
u'toolsAddToolItem', icon=u':/tools/tools_add.png', u'toolsAddToolItem', icon=u':/tools/tools_add.png', category=UiStrings().Tools, can_shortcuts=True)
category=UiStrings().Tools)
self.toolsOpenDataFolder = create_action(main_window, self.toolsOpenDataFolder = create_action(main_window,
u'toolsOpenDataFolder', icon=u':/general/general_open.png', u'toolsOpenDataFolder', icon=u':/general/general_open.png', category=UiStrings().Tools, can_shortcuts=True)
category=UiStrings().Tools)
self.toolsFirstTimeWizard = create_action(main_window, self.toolsFirstTimeWizard = create_action(main_window,
u'toolsFirstTimeWizard', icon=u':/general/general_revert.png', u'toolsFirstTimeWizard', icon=u':/general/general_revert.png',
category=UiStrings().Tools) category=UiStrings().Tools, can_shortcuts=True)
self.updateThemeImages = create_action(main_window, self.updateThemeImages = create_action(main_window,
u'updateThemeImages', category=UiStrings().Tools) u'updateThemeImages', category=UiStrings().Tools, can_shortcuts=True)
action_list.add_category(UiStrings().Settings, action_list.add_category(UiStrings().Settings, CategoryOrder.standard_menu)
CategoryOrder.standardMenu)
self.settingsPluginListItem = create_action(main_window, self.settingsPluginListItem = create_action(main_window,
u'settingsPluginListItem', u'settingsPluginListItem',
icon=u':/system/settings_plugin_list.png', icon=u':/system/settings_plugin_list.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F7')], can_shortcuts=True,
category=UiStrings().Settings, triggers=self.onPluginItemClicked) category=UiStrings().Settings, triggers=self.onPluginItemClicked)
# i18n Language Items # i18n Language Items
self.autoLanguageItem = create_action(main_window, u'autoLanguageItem', self.autoLanguageItem = create_action(main_window, u'autoLanguageItem', checked=LanguageManager.auto_language)
checked=LanguageManager.auto_language)
self.languageGroup = QtGui.QActionGroup(main_window) self.languageGroup = QtGui.QActionGroup(main_window)
self.languageGroup.setExclusive(True) self.languageGroup.setExclusive(True)
self.languageGroup.setObjectName(u'languageGroup') self.languageGroup.setObjectName(u'languageGroup')
@ -277,20 +279,21 @@ class Ui_MainWindow(object):
languageItem = create_action(main_window, key, checked=qmList[key] == savedLanguage) languageItem = create_action(main_window, key, checked=qmList[key] == savedLanguage)
add_actions(self.languageGroup, [languageItem]) add_actions(self.languageGroup, [languageItem])
self.settingsShortcutsItem = create_action(main_window, u'settingsShortcutsItem', self.settingsShortcutsItem = create_action(main_window, u'settingsShortcutsItem',
icon=u':/system/system_configure_shortcuts.png', category=UiStrings().Settings) icon=u':/system/system_configure_shortcuts.png', category=UiStrings().Settings, can_shortcuts=True)
# Formatting Tags were also known as display tags. # Formatting Tags were also known as display tags.
self.formattingTagItem = create_action(main_window, u'displayTagItem', self.formattingTagItem = create_action(main_window, u'displayTagItem',
icon=u':/system/tag_editor.png', category=UiStrings().Settings) icon=u':/system/tag_editor.png', category=UiStrings().Settings, can_shortcuts=True)
self.settingsConfigureItem = create_action(main_window, u'settingsConfigureItem', 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 # Give QT Extra Hint that this is the Preferences Menu Item
self.settingsConfigureItem.setMenuRole(QtGui.QAction.PreferencesRole) self.settingsConfigureItem.setMenuRole(QtGui.QAction.PreferencesRole)
self.settingsImportItem = create_action(main_window, u'settingsImportItem', category=UiStrings().Settings) self.settingsImportItem = create_action(
self.settingsExportItem = create_action(main_window, u'settingsExportItem', category=UiStrings().Settings) main_window, u'settingsImportItem', category=UiStrings().Import, can_shortcuts=True)
action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) self.settingsExportItem = create_action(
main_window, u'settingsExportItem', category=UiStrings().Export, can_shortcuts=True)
action_list.add_category(UiStrings().Help, CategoryOrder.standard_menu)
self.aboutItem = create_action(main_window, u'aboutItem', icon=u':/system/system_about.png', 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)
category=UiStrings().Help, triggers=self.onAboutItemClicked)
# Give QT Extra Hint that this is an About Menu Item # Give QT Extra Hint that this is an About Menu Item
self.aboutItem.setMenuRole(QtGui.QAction.AboutRole) self.aboutItem.setMenuRole(QtGui.QAction.AboutRole)
if os.name == u'nt': if os.name == u'nt':
@ -298,13 +301,13 @@ class Ui_MainWindow(object):
AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm')
self.offlineHelpItem = create_action(main_window, u'offlineHelpItem', self.offlineHelpItem = create_action(main_window, u'offlineHelpItem',
icon=u':/system/system_help_contents.png', icon=u':/system/system_help_contents.png',
shortcuts=[QtGui.QKeySequence(u'F1')], can_shortcuts=True,
category=UiStrings().Help, triggers=self.onOfflineHelpClicked) category=UiStrings().Help, triggers=self.onOfflineHelpClicked)
self.onlineHelpItem = create_action(main_window, u'onlineHelpItem', self.onlineHelpItem = create_action(main_window, u'onlineHelpItem',
icon=u':/system/system_online_help.png', icon=u':/system/system_online_help.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F1')], can_shortcuts=True,
category=UiStrings().Help, triggers=self.onOnlineHelpClicked) category=UiStrings().Help, triggers=self.onOnlineHelpClicked)
self.webSiteItem = create_action(main_window, u'webSiteItem', category=UiStrings().Help) self.webSiteItem = create_action(main_window, u'webSiteItem', can_shortcuts=True, category=UiStrings().Help)
add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem)) add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem))
add_actions(self.fileExportMenu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem)) add_actions(self.fileExportMenu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem))
add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem, add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem,
@ -1349,7 +1352,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.version_text) self.version_text)
else: else:
# the thread has not confirmed it is running or it has not yet sent any data so lets keep waiting # the thread has not confirmed it is running or it has not yet sent any data so lets keep waiting
if not hasattr(self,u'version_update_running') or self.version_update_running: if not hasattr(self, u'version_update_running') or self.version_update_running:
self.timer_version_id = self.startTimer(1000) self.timer_version_id = self.startTimer(1000)
self.application.process_events() self.application.process_events()

View File

@ -2,7 +2,7 @@
# Python ctypes bindings for VLC # Python ctypes bindings for VLC
# #
# Copyright (C) 2009-2013 the VideoLAN team # Copyright (C) 2009-2012 the VideoLAN team
# $Id: $ # $Id: $
# #
# Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr> # Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
@ -48,7 +48,7 @@ import sys
from inspect import getargspec from inspect import getargspec
__version__ = "N/A" __version__ = "N/A"
build_date = "Fri Oct 5 21:35:59 2012" build_date = "Wed Feb 13 18:40:24 2013"
if sys.version_info[0] > 2: if sys.version_info[0] > 2:
str = str str = str
@ -1000,6 +1000,50 @@ class MediaTrackInfo(_Cstruct):
('rate_or_width', ctypes.c_uint ), ('rate_or_width', ctypes.c_uint ),
] ]
class AudioTrack(_Cstruct):
_fields_ = [
('channels', ctypes.c_uint),
('rate', ctypes.c_uint),
]
class VideoTrack(_Cstruct):
_fields_ = [
('height', ctypes.c_uint),
('width', ctypes.c_uint),
('sar_num', ctypes.c_uint),
('sar_den', ctypes.c_uint),
('frame_rate_num', ctypes.c_uint),
('frame_rate_den', ctypes.c_uint),
]
class SubtitleTrack(_Cstruct):
_fields_ = [
('encoding', ctypes.c_char_p),
]
class MediaTrackTracks(ctypes.Union):
_fields_ = [
('audio', ctypes.POINTER(AudioTrack)),
('video', ctypes.POINTER(VideoTrack)),
('subtitle', ctypes.POINTER(SubtitleTrack)),
]
class MediaTrack(_Cstruct):
_anonymous_ = ("u",)
_fields_ = [
('codec', ctypes.c_uint32),
('original_fourcc', ctypes.c_uint32),
('id', ctypes.c_int ),
('type', TrackType ),
('profile', ctypes.c_int ),
('level', ctypes.c_int ),
('u', MediaTrackTracks),
('bitrate', ctypes.c_uint),
('language', ctypes.c_char_p),
('description', ctypes.c_char_p),
]
class PlaylistItem(_Cstruct): class PlaylistItem(_Cstruct):
_fields_ = [ _fields_ = [
('id', ctypes.c_int ), ('id', ctypes.c_int ),
@ -1122,6 +1166,17 @@ def module_description_list(head):
libvlc_module_description_list_release(head) libvlc_module_description_list_release(head)
return r return r
class AudioOutputDevice(_Cstruct):
def __str__(self):
return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
AudioOutputDevice._fields_ = [ # recursive struct
('next', ctypes.POINTER(AudioOutputDevice)),
('device', ctypes.c_char_p ),
('description', ctypes.c_char_p),
]
# End of header.py # # End of header.py #
class EventManager(_Ctype): class EventManager(_Ctype):
@ -1282,7 +1337,7 @@ class Instance(_Ctype):
m = libvlc_media_new_location(self, str_to_bytes(mrl)) m = libvlc_media_new_location(self, str_to_bytes(mrl))
else: else:
# Else it should be a local path. # Else it should be a local path.
m = libvlc_media_new_path(self, str_to_bytes(mrl)) m = libvlc_media_new_path(self, str_to_bytes(os.path.normpath(mrl)))
for o in options: for o in options:
libvlc_media_add_option(m, str_to_bytes(o)) libvlc_media_add_option(m, str_to_bytes(o))
m._instance = self m._instance = self
@ -1361,27 +1416,6 @@ class Instance(_Ctype):
''' '''
return libvlc_set_user_agent(self, name, http) return libvlc_set_user_agent(self, name, http)
def get_log_verbosity(self):
'''Always returns minus one.
This function is only provided for backward compatibility.
@return: always -1.
'''
return libvlc_get_log_verbosity(self)
def set_log_verbosity(self, level):
'''This function does nothing.
It is only provided for backward compatibility.
@param level: ignored.
'''
return libvlc_set_log_verbosity(self, level)
def log_open(self):
'''This function does nothing useful.
It is only provided for backward compatibility.
@return: an unique pointer or NULL on error.
'''
return libvlc_log_open(self)
def media_new_location(self, psz_mrl): def media_new_location(self, psz_mrl):
'''Create a media with a certain given media resource location, '''Create a media with a certain given media resource location,
for instance a valid URL. for instance a valid URL.
@ -1445,34 +1479,26 @@ class Instance(_Ctype):
return libvlc_media_library_new(self) return libvlc_media_library_new(self)
def audio_output_list_get(self): def audio_output_list_get(self):
'''Get the list of available audio outputs. '''Gets the list of available audio outputs.
@return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned.
''' '''
return libvlc_audio_output_list_get(self) return libvlc_audio_output_list_get(self)
def audio_output_device_count(self, psz_audio_output): def audio_output_device_list_get(self, aout):
'''Get count of devices for audio output, these devices are hardware oriented '''Gets a list of audio output devices for a given audio output.
like analor or digital output of sound card. See L{audio_output_device_set}().
@param psz_audio_output: - name of audio output, See L{AudioOutput}. @note: Not all audio outputs support this. In particular, an empty (NULL)
@return: number of devices. list of devices does B{not} imply that the specified audio output does
not work.
@note: The list might not be exhaustive.
@warning: Some audio output devices in the list might not actually work in
some circumstances. By default, it is recommended to not specify any
explicit audio device.
@param psz_aout: audio output name (as returned by L{audio_output_list_get}()).
@return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}().
@version: LibVLC 2.1.0 or later.
''' '''
return libvlc_audio_output_device_count(self, psz_audio_output) return libvlc_audio_output_device_list_get(self, aout)
def audio_output_device_longname(self, psz_audio_output, i_device):
'''Get long name of device, if not available short name given.
@param psz_audio_output: - name of audio output, See L{AudioOutput}.
@param i_device: device index.
@return: long name of device.
'''
return libvlc_audio_output_device_longname(self, psz_audio_output, i_device)
def audio_output_device_id(self, psz_audio_output, i_device):
'''Get id name of device.
@param psz_audio_output: - name of audio output, See L{AudioOutput}.
@param i_device: device index.
@return: id name of device, use for setting device, need to be free after use.
'''
return libvlc_audio_output_device_id(self, psz_audio_output, i_device)
def vlm_release(self): def vlm_release(self):
'''Release the vlm instance related to the given L{Instance}. '''Release the vlm instance related to the given L{Instance}.
@ -1683,87 +1709,6 @@ class Instance(_Ctype):
''' '''
return libvlc_vlm_get_event_manager(self) return libvlc_vlm_get_event_manager(self)
class Log(_Ctype):
'''Create a new VLC log instance.
'''
def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor.
'''
return _Constructor(cls, ptr)
def __iter__(self):
return self.get_iterator()
def dump(self):
return [ str(m) for m in self ]
def close(self):
'''Frees memory allocated by L{open}().
'''
return libvlc_log_close(self)
def count(self):
'''Always returns zero.
This function is only provided for backward compatibility.
@return: always zero.
'''
return libvlc_log_count(self)
def __len__(self):
return libvlc_log_count(self)
def clear(self):
'''This function does nothing.
It is only provided for backward compatibility.
'''
return libvlc_log_clear(self)
def get_iterator(self):
'''This function does nothing useful.
It is only provided for backward compatibility.
@return: an unique pointer or NULL on error or if the parameter was NULL.
'''
return libvlc_log_get_iterator(self)
class LogIterator(_Ctype):
'''Create a new VLC log iterator.
'''
def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor.
'''
return _Constructor(cls, ptr)
def __iter__(self):
return self
def next(self):
if self.has_next():
b = LogMessage()
i = libvlc_log_iterator_next(self, b)
return i.contents
raise StopIteration
def __next__(self):
return self.next()
def free(self):
'''Frees memory allocated by L{log_get_iterator}().
'''
return libvlc_log_iterator_free(self)
def has_next(self):
'''Always returns zero.
This function is only provided for backward compatibility.
@return: always zero.
'''
return libvlc_log_iterator_has_next(self)
class Media(_Ctype): class Media(_Ctype):
'''Create a new Media instance. '''Create a new Media instance.
@ -1809,11 +1754,13 @@ class Media(_Ctype):
This option will be used to determine how the media_player will This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis. reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance @note: The options are listed in 'vlc --long-help' from the command line,
"--sout-all". Note that all options are not usable on medias: e.g. "-sout-all". Keep in mind that available options and their semantics
specifically, due to architectural issues, video-related options vary across LibVLC versions and builds.
such as text renderer options cannot be set on a single media. They @warning: Not all options affects L{Media} objects:
must be set on the whole libvlc instance instead. Specifically, due to architectural issues most audio and video options,
such as text renderer options, have no effects on an individual media.
These options must be set through L{new}() instead.
@param ppsz_options: the options (as a string). @param ppsz_options: the options (as a string).
''' '''
return libvlc_media_add_option(self, ppsz_options) return libvlc_media_add_option(self, ppsz_options)
@ -1906,6 +1853,14 @@ class Media(_Ctype):
''' '''
return libvlc_media_get_stats(self, p_stats) return libvlc_media_get_stats(self, p_stats)
def subitems(self):
'''Get subitems of media descriptor object. This will increment
the reference count of supplied media descriptor object. Use
L{list_release}() to decrement the reference counting.
@return: list of media descriptor subitems or NULL.
'''
return libvlc_media_subitems(self)
def event_manager(self): def event_manager(self):
'''Get event manager from media descriptor object. '''Get event manager from media descriptor object.
NOTE: this function doesn't increment reference counting. NOTE: this function doesn't increment reference counting.
@ -1925,7 +1880,7 @@ class Media(_Ctype):
The method is synchronous. The method is synchronous.
See L{parse_async} See L{parse_async}
See L{get_meta} See L{get_meta}
See L{get_tracks_info}. See libvlc_media_get_tracks_info.
''' '''
return libvlc_media_parse(self) return libvlc_media_parse(self)
@ -1939,7 +1894,7 @@ class Media(_Ctype):
See L{parse} See L{parse}
See libvlc_MediaParsedChanged See libvlc_MediaParsedChanged
See L{get_meta} See L{get_meta}
See L{get_tracks_info}. See libvlc_media_get_tracks_info.
''' '''
return libvlc_media_parse_async(self) return libvlc_media_parse_async(self)
@ -1965,15 +1920,16 @@ class Media(_Ctype):
''' '''
return libvlc_media_get_user_data(self) return libvlc_media_get_user_data(self)
def get_tracks_info(self): def tracks_get(self, tracks):
'''Get media descriptor's elementary streams description '''Get media descriptor's elementary streams description
Note, you need to call L{parse}() or play the media at least once Note, you need to call L{parse}() or play the media at least once
before calling this function. before calling this function.
Not doing this will result in an empty array. Not doing this will result in an empty array.
@param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT]. @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed with L{tracks_release}.
@return: the number of Elementary Streams. @return: the number of Elementary Streams (zero on error).
@version: LibVLC 2.1.0 and later.
''' '''
return libvlc_media_get_tracks_info(self) return libvlc_media_tracks_get(self, tracks)
def player_new_from_media(self): def player_new_from_media(self):
'''Create a Media Player object from a Media. '''Create a Media Player object from a Media.
@ -2255,7 +2211,7 @@ class MediaListPlayer(_Ctype):
return libvlc_media_list_player_play(self) return libvlc_media_list_player_play(self)
def pause(self): def pause(self):
'''Pause media list. '''Toggle pause (or resume) media list.
''' '''
return libvlc_media_list_player_pause(self) return libvlc_media_list_player_pause(self)
@ -2681,13 +2637,14 @@ class MediaPlayer(_Ctype):
return libvlc_media_player_set_time(self, i_time) return libvlc_media_player_set_time(self, i_time)
def get_position(self): def get_position(self):
'''Get movie position. '''Get movie position as percentage between 0.0 and 1.0.
@return: movie position, or -1. in case of error. @return: movie position, or -1. in case of error.
''' '''
return libvlc_media_player_get_position(self) return libvlc_media_player_get_position(self)
def set_position(self, f_pos): def set_position(self, f_pos):
'''Set movie position. This has no effect if playback is not enabled. '''Set movie position as percentage between 0.0 and 1.0.
This has no effect if playback is not enabled.
This might not work depending on the underlying input format and protocol. This might not work depending on the underlying input format and protocol.
@param f_pos: the position. @param f_pos: the position.
''' '''
@ -2968,13 +2925,13 @@ class MediaPlayer(_Ctype):
def video_get_track(self): def video_get_track(self):
'''Get current video track. '''Get current video track.
@return: the video track (int) or -1 if none. @return: the video track ID (int) or -1 if no active input.
''' '''
return libvlc_video_get_track(self) return libvlc_video_get_track(self)
def video_set_track(self, i_track): def video_set_track(self, i_track):
'''Set video track. '''Set video track.
@param i_track: the track (int). @param i_track: the track ID (i_id field from track description).
@return: 0 on success, -1 if out of range. @return: 0 on success, -1 if out of range.
''' '''
return libvlc_video_set_track(self, i_track) return libvlc_video_set_track(self, i_track)
@ -3084,33 +3041,30 @@ class MediaPlayer(_Ctype):
return libvlc_video_set_adjust_float(self, option, value) return libvlc_video_set_adjust_float(self, option, value)
def audio_output_set(self, psz_name): def audio_output_set(self, psz_name):
'''Set the audio output. '''Sets the audio output.
Change will be applied after stop and play. @note: Any change will take be effect only after playback is stopped and
restarted. Audio output cannot be changed while playing.
@param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
@return: 0 if function succeded, -1 on error. @return: 0 if function succeded, -1 on error.
''' '''
return libvlc_audio_output_set(self, psz_name) return libvlc_audio_output_set(self, psz_name)
def audio_output_device_set(self, psz_audio_output, psz_device_id): def audio_output_device_set(self, psz_audio_output, psz_device_id):
'''Set audio output device. Changes are only effective after stop and play. '''Configures an explicit audio output device for a given audio output plugin.
A list of possible devices can be obtained with
L{audio_output_device_list_get}().
@note: This function does not select the specified audio output plugin.
L{audio_output_set}() is used for that purpose.
@warning: The syntax for the device parameter depends on the audio output.
This is not portable. Only use this function if you know what you are doing.
Some audio outputs do not support this function (e.g. PulseAudio, WASAPI).
Some audio outputs require further parameters (e.g. ALSA: channels map).
@param psz_audio_output: - name of audio output, See L{AudioOutput}. @param psz_audio_output: - name of audio output, See L{AudioOutput}.
@param psz_device_id: device. @param psz_device_id: device.
@return: Nothing. Errors are ignored.
''' '''
return libvlc_audio_output_device_set(self, psz_audio_output, psz_device_id) return libvlc_audio_output_device_set(self, psz_audio_output, psz_device_id)
def audio_output_get_device_type(self):
'''Get current audio device type. Device type describes something like
character of output sound - stereo sound, 2.1, 5.1 etc.
@return: the audio devices type See libvlc_audio_output_device_types_t.
'''
return libvlc_audio_output_get_device_type(self)
def audio_output_set_device_type(self, device_type):
'''Set current audio device type.
@param device_type: the audio device type,
'''
return libvlc_audio_output_set_device_type(self, device_type)
def audio_toggle_mute(self): def audio_toggle_mute(self):
'''Toggle mute status. '''Toggle mute status.
''' '''
@ -3118,13 +3072,13 @@ class MediaPlayer(_Ctype):
def audio_get_mute(self): def audio_get_mute(self):
'''Get current mute status. '''Get current mute status.
@return: the mute status (boolean) \libvlc_return_bool. @return: the mute status (boolean) if defined, -1 if undefined/unapplicable.
''' '''
return libvlc_audio_get_mute(self) return libvlc_audio_get_mute(self)
def audio_set_mute(self, status): def audio_set_mute(self, status):
'''Set mute status. '''Set mute status.
@param status: If status is true then mute, otherwise unmute. @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute.
''' '''
return libvlc_audio_set_mute(self, status) return libvlc_audio_set_mute(self, status)
@ -3149,13 +3103,13 @@ class MediaPlayer(_Ctype):
def audio_get_track(self): def audio_get_track(self):
'''Get current audio track. '''Get current audio track.
@return: the audio track (int), or -1 if none. @return: the audio track ID or -1 if no active input.
''' '''
return libvlc_audio_get_track(self) return libvlc_audio_get_track(self)
def audio_set_track(self, i_track): def audio_set_track(self, i_track):
'''Set current audio track. '''Set current audio track.
@param i_track: the track (int). @param i_track: the track ID (i_id field from track description).
@return: 0 on success, -1 on error. @return: 0 on success, -1 on error.
''' '''
return libvlc_audio_set_track(self, i_track) return libvlc_audio_set_track(self, i_track)
@ -3397,112 +3351,6 @@ def libvlc_log_unsubscribe(sub):
None, ctypes.c_void_p) None, ctypes.c_void_p)
return f(sub) return f(sub)
def libvlc_get_log_verbosity(p_instance):
'''Always returns minus one.
This function is only provided for backward compatibility.
@param p_instance: ignored.
@return: always -1.
'''
f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \
_Cfunction('libvlc_get_log_verbosity', ((1,),), None,
ctypes.c_uint, Instance)
return f(p_instance)
def libvlc_set_log_verbosity(p_instance, level):
'''This function does nothing.
It is only provided for backward compatibility.
@param p_instance: ignored.
@param level: ignored.
'''
f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \
_Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None,
None, Instance, ctypes.c_uint)
return f(p_instance, level)
def libvlc_log_open(p_instance):
'''This function does nothing useful.
It is only provided for backward compatibility.
@param p_instance: libvlc instance.
@return: an unique pointer or NULL on error.
'''
f = _Cfunctions.get('libvlc_log_open', None) or \
_Cfunction('libvlc_log_open', ((1,),), class_result(Log),
ctypes.c_void_p, Instance)
return f(p_instance)
def libvlc_log_close(p_log):
'''Frees memory allocated by L{libvlc_log_open}().
@param p_log: libvlc log instance or NULL.
'''
f = _Cfunctions.get('libvlc_log_close', None) or \
_Cfunction('libvlc_log_close', ((1,),), None,
None, Log)
return f(p_log)
def libvlc_log_count(p_log):
'''Always returns zero.
This function is only provided for backward compatibility.
@param p_log: ignored.
@return: always zero.
'''
f = _Cfunctions.get('libvlc_log_count', None) or \
_Cfunction('libvlc_log_count', ((1,),), None,
ctypes.c_uint, Log)
return f(p_log)
def libvlc_log_clear(p_log):
'''This function does nothing.
It is only provided for backward compatibility.
@param p_log: ignored.
'''
f = _Cfunctions.get('libvlc_log_clear', None) or \
_Cfunction('libvlc_log_clear', ((1,),), None,
None, Log)
return f(p_log)
def libvlc_log_get_iterator(p_log):
'''This function does nothing useful.
It is only provided for backward compatibility.
@param p_log: ignored.
@return: an unique pointer or NULL on error or if the parameter was NULL.
'''
f = _Cfunctions.get('libvlc_log_get_iterator', None) or \
_Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator),
ctypes.c_void_p, Log)
return f(p_log)
def libvlc_log_iterator_free(p_iter):
'''Frees memory allocated by L{libvlc_log_get_iterator}().
@param p_iter: libvlc log iterator or NULL.
'''
f = _Cfunctions.get('libvlc_log_iterator_free', None) or \
_Cfunction('libvlc_log_iterator_free', ((1,),), None,
None, LogIterator)
return f(p_iter)
def libvlc_log_iterator_has_next(p_iter):
'''Always returns zero.
This function is only provided for backward compatibility.
@param p_iter: ignored.
@return: always zero.
'''
f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \
_Cfunction('libvlc_log_iterator_has_next', ((1,),), None,
ctypes.c_int, LogIterator)
return f(p_iter)
def libvlc_log_iterator_next(p_iter, p_buffer):
'''Always returns NULL.
This function is only provided for backward compatibility.
@param p_iter: libvlc log iterator or NULL.
@param p_buffer: ignored.
@return: always NULL.
'''
f = _Cfunctions.get('libvlc_log_iterator_next', None) or \
_Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None,
ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage))
return f(p_iter, p_buffer)
def libvlc_module_description_list_release(p_list): def libvlc_module_description_list_release(p_list):
'''Release a list of module descriptions. '''Release a list of module descriptions.
@param p_list: the list to be released. @param p_list: the list to be released.
@ -3615,11 +3463,13 @@ def libvlc_media_add_option(p_md, ppsz_options):
This option will be used to determine how the media_player will This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis. reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance @note: The options are listed in 'vlc --long-help' from the command line,
"--sout-all". Note that all options are not usable on medias: e.g. "-sout-all". Keep in mind that available options and their semantics
specifically, due to architectural issues, video-related options vary across LibVLC versions and builds.
such as text renderer options cannot be set on a single media. They @warning: Not all options affects L{Media} objects:
must be set on the whole libvlc instance instead. Specifically, due to architectural issues most audio and video options,
such as text renderer options, have no effects on an individual media.
These options must be set through L{libvlc_new}() instead.
@param p_md: the media descriptor. @param p_md: the media descriptor.
@param ppsz_options: the options (as a string). @param ppsz_options: the options (as a string).
''' '''
@ -3756,6 +3606,18 @@ def libvlc_media_get_stats(p_md, p_stats):
ctypes.c_int, Media, ctypes.POINTER(MediaStats)) ctypes.c_int, Media, ctypes.POINTER(MediaStats))
return f(p_md, p_stats) return f(p_md, p_stats)
def libvlc_media_subitems(p_md):
'''Get subitems of media descriptor object. This will increment
the reference count of supplied media descriptor object. Use
L{libvlc_media_list_release}() to decrement the reference counting.
@param p_md: media descriptor object.
@return: list of media descriptor subitems or NULL.
'''
f = _Cfunctions.get('libvlc_media_subitems', None) or \
_Cfunction('libvlc_media_subitems', ((1,),), class_result(MediaList),
ctypes.c_void_p, Media)
return f(p_md)
def libvlc_media_event_manager(p_md): def libvlc_media_event_manager(p_md):
'''Get event manager from media descriptor object. '''Get event manager from media descriptor object.
NOTE: this function doesn't increment reference counting. NOTE: this function doesn't increment reference counting.
@ -3783,7 +3645,7 @@ def libvlc_media_parse(p_md):
The method is synchronous. The method is synchronous.
See L{libvlc_media_parse_async} See L{libvlc_media_parse_async}
See L{libvlc_media_get_meta} See L{libvlc_media_get_meta}
See L{libvlc_media_get_tracks_info}. See libvlc_media_get_tracks_info.
@param p_md: media descriptor object. @param p_md: media descriptor object.
''' '''
f = _Cfunctions.get('libvlc_media_parse', None) or \ f = _Cfunctions.get('libvlc_media_parse', None) or \
@ -3801,7 +3663,7 @@ def libvlc_media_parse_async(p_md):
See L{libvlc_media_parse} See L{libvlc_media_parse}
See libvlc_MediaParsedChanged See libvlc_MediaParsedChanged
See L{libvlc_media_get_meta} See L{libvlc_media_get_meta}
See L{libvlc_media_get_tracks_info}. See libvlc_media_get_tracks_info.
@param p_md: media descriptor object. @param p_md: media descriptor object.
''' '''
f = _Cfunctions.get('libvlc_media_parse_async', None) or \ f = _Cfunctions.get('libvlc_media_parse_async', None) or \
@ -3843,19 +3705,31 @@ def libvlc_media_get_user_data(p_md):
ctypes.c_void_p, Media) ctypes.c_void_p, Media)
return f(p_md) return f(p_md)
def libvlc_media_get_tracks_info(p_md): def libvlc_media_tracks_get(p_md, tracks):
'''Get media descriptor's elementary streams description '''Get media descriptor's elementary streams description
Note, you need to call L{libvlc_media_parse}() or play the media at least once Note, you need to call L{libvlc_media_parse}() or play the media at least once
before calling this function. before calling this function.
Not doing this will result in an empty array. Not doing this will result in an empty array.
@param p_md: media descriptor object. @param p_md: media descriptor object.
@param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT]. @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed with L{libvlc_media_tracks_release}.
@return: the number of Elementary Streams. @return: the number of Elementary Streams (zero on error).
@version: LibVLC 2.1.0 and later.
''' '''
f = _Cfunctions.get('libvlc_media_get_tracks_info', None) or \ f = _Cfunctions.get('libvlc_media_tracks_get', None) or \
_Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), None, _Cfunction('libvlc_media_tracks_get', ((1,), (1,),), None,
ctypes.c_int, Media, ctypes.POINTER(ctypes.c_void_p)) ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaTrack)))
return f(p_md) return f(p_md, tracks)
def libvlc_media_tracks_release(p_tracks, i_count):
'''Release media descriptor's elementary streams description array.
@param p_tracks: tracks info array to release.
@param i_count: number of elements in the array.
@version: LibVLC 2.1.0 and later.
'''
f = _Cfunctions.get('libvlc_media_tracks_release', None) or \
_Cfunction('libvlc_media_tracks_release', ((1,), (1,),), None,
None, ctypes.POINTER(MediaTrack), ctypes.c_uint)
return f(p_tracks, i_count)
def libvlc_media_discoverer_new_from_name(p_inst, psz_name): def libvlc_media_discoverer_new_from_name(p_inst, psz_name):
'''Discover media service by name. '''Discover media service by name.
@ -4208,7 +4082,7 @@ def libvlc_media_list_player_play(p_mlp):
return f(p_mlp) return f(p_mlp)
def libvlc_media_list_player_pause(p_mlp): def libvlc_media_list_player_pause(p_mlp):
'''Pause media list. '''Toggle pause (or resume) media list.
@param p_mlp: media list player instance. @param p_mlp: media list player instance.
''' '''
f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \ f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \
@ -4673,7 +4547,7 @@ def libvlc_media_player_set_time(p_mi, i_time):
return f(p_mi, i_time) return f(p_mi, i_time)
def libvlc_media_player_get_position(p_mi): def libvlc_media_player_get_position(p_mi):
'''Get movie position. '''Get movie position as percentage between 0.0 and 1.0.
@param p_mi: the Media Player. @param p_mi: the Media Player.
@return: movie position, or -1. in case of error. @return: movie position, or -1. in case of error.
''' '''
@ -4683,7 +4557,8 @@ def libvlc_media_player_get_position(p_mi):
return f(p_mi) return f(p_mi)
def libvlc_media_player_set_position(p_mi, f_pos): def libvlc_media_player_set_position(p_mi, f_pos):
'''Set movie position. This has no effect if playback is not enabled. '''Set movie position as percentage between 0.0 and 1.0.
This has no effect if playback is not enabled.
This might not work depending on the underlying input format and protocol. This might not work depending on the underlying input format and protocol.
@param p_mi: the Media Player. @param p_mi: the Media Player.
@param f_pos: the position. @param f_pos: the position.
@ -4894,14 +4769,6 @@ def libvlc_track_description_list_release(p_track_description):
None, ctypes.POINTER(TrackDescription)) None, ctypes.POINTER(TrackDescription))
return f(p_track_description) return f(p_track_description)
def libvlc_track_description_release(p_track_description):
'''\deprecated Use L{libvlc_track_description_list_release} instead.
'''
f = _Cfunctions.get('libvlc_track_description_release', None) or \
_Cfunction('libvlc_track_description_release', ((1,),), None,
None, ctypes.POINTER(TrackDescription))
return f(p_track_description)
def libvlc_toggle_fullscreen(p_mi): def libvlc_toggle_fullscreen(p_mi):
'''Toggle fullscreen status on non-embedded video outputs. '''Toggle fullscreen status on non-embedded video outputs.
@warning: The same limitations applies to this function @warning: The same limitations applies to this function
@ -5219,7 +5086,7 @@ def libvlc_video_get_track_description(p_mi):
def libvlc_video_get_track(p_mi): def libvlc_video_get_track(p_mi):
'''Get current video track. '''Get current video track.
@param p_mi: media player. @param p_mi: media player.
@return: the video track (int) or -1 if none. @return: the video track ID (int) or -1 if no active input.
''' '''
f = _Cfunctions.get('libvlc_video_get_track', None) or \ f = _Cfunctions.get('libvlc_video_get_track', None) or \
_Cfunction('libvlc_video_get_track', ((1,),), None, _Cfunction('libvlc_video_get_track', ((1,),), None,
@ -5229,7 +5096,7 @@ def libvlc_video_get_track(p_mi):
def libvlc_video_set_track(p_mi, i_track): def libvlc_video_set_track(p_mi, i_track):
'''Set video track. '''Set video track.
@param p_mi: media player. @param p_mi: media player.
@param i_track: the track (int). @param i_track: the track ID (i_id field from track description).
@return: 0 on success, -1 if out of range. @return: 0 on success, -1 if out of range.
''' '''
f = _Cfunctions.get('libvlc_video_set_track', None) or \ f = _Cfunctions.get('libvlc_video_set_track', None) or \
@ -5394,7 +5261,7 @@ def libvlc_video_set_adjust_float(p_mi, option, value):
return f(p_mi, option, value) return f(p_mi, option, value)
def libvlc_audio_output_list_get(p_instance): def libvlc_audio_output_list_get(p_instance):
'''Get the list of available audio outputs. '''Gets the list of available audio outputs.
@param p_instance: libvlc instance. @param p_instance: libvlc instance.
@return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned.
''' '''
@ -5404,7 +5271,7 @@ def libvlc_audio_output_list_get(p_instance):
return f(p_instance) return f(p_instance)
def libvlc_audio_output_list_release(p_list): def libvlc_audio_output_list_release(p_list):
'''Free the list of available audio outputs. '''Frees the list of available audio outputs.
@param p_list: list with audio outputs for release. @param p_list: list with audio outputs for release.
''' '''
f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \ f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \
@ -5413,8 +5280,9 @@ def libvlc_audio_output_list_release(p_list):
return f(p_list) return f(p_list)
def libvlc_audio_output_set(p_mi, psz_name): def libvlc_audio_output_set(p_mi, psz_name):
'''Set the audio output. '''Sets the audio output.
Change will be applied after stop and play. @note: Any change will take be effect only after playback is stopped and
restarted. Audio output cannot be changed while playing.
@param p_mi: media player. @param p_mi: media player.
@param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
@return: 0 if function succeded, -1 on error. @return: 0 if function succeded, -1 on error.
@ -5424,77 +5292,59 @@ def libvlc_audio_output_set(p_mi, psz_name):
ctypes.c_int, MediaPlayer, ctypes.c_char_p) ctypes.c_int, MediaPlayer, ctypes.c_char_p)
return f(p_mi, psz_name) return f(p_mi, psz_name)
def libvlc_audio_output_device_count(p_instance, psz_audio_output): def libvlc_audio_output_device_list_get(p_instance, aout):
'''Get count of devices for audio output, these devices are hardware oriented '''Gets a list of audio output devices for a given audio output.
like analor or digital output of sound card. See L{libvlc_audio_output_device_set}().
@note: Not all audio outputs support this. In particular, an empty (NULL)
list of devices does B{not} imply that the specified audio output does
not work.
@note: The list might not be exhaustive.
@warning: Some audio output devices in the list might not actually work in
some circumstances. By default, it is recommended to not specify any
explicit audio device.
@param p_instance: libvlc instance. @param p_instance: libvlc instance.
@param psz_audio_output: - name of audio output, See L{AudioOutput}. @param psz_aout: audio output name (as returned by L{libvlc_audio_output_list_get}()).
@return: number of devices. @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{libvlc_audio_output_device_list_release}().
@version: LibVLC 2.1.0 or later.
''' '''
f = _Cfunctions.get('libvlc_audio_output_device_count', None) or \ f = _Cfunctions.get('libvlc_audio_output_device_list_get', None) or \
_Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), None, _Cfunction('libvlc_audio_output_device_list_get', ((1,), (1,),), None,
ctypes.c_int, Instance, ctypes.c_char_p) ctypes.POINTER(AudioOutputDevice), Instance, ctypes.c_char_p)
return f(p_instance, psz_audio_output) return f(p_instance, aout)
def libvlc_audio_output_device_longname(p_instance, psz_audio_output, i_device): def libvlc_audio_output_device_list_release(p_list):
'''Get long name of device, if not available short name given. '''Frees a list of available audio output devices.
@param p_instance: libvlc instance. @param p_list: list with audio outputs for release.
@param psz_audio_output: - name of audio output, See L{AudioOutput}. @version: LibVLC 2.1.0 or later.
@param i_device: device index.
@return: long name of device.
''' '''
f = _Cfunctions.get('libvlc_audio_output_device_longname', None) or \ f = _Cfunctions.get('libvlc_audio_output_device_list_release', None) or \
_Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), string_result, _Cfunction('libvlc_audio_output_device_list_release', ((1,),), None,
ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) None, ctypes.POINTER(AudioOutputDevice))
return f(p_instance, psz_audio_output, i_device) return f(p_list)
def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device):
'''Get id name of device.
@param p_instance: libvlc instance.
@param psz_audio_output: - name of audio output, See L{AudioOutput}.
@param i_device: device index.
@return: id name of device, use for setting device, need to be free after use.
'''
f = _Cfunctions.get('libvlc_audio_output_device_id', None) or \
_Cfunction('libvlc_audio_output_device_id', ((1,), (1,), (1,),), string_result,
ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int)
return f(p_instance, psz_audio_output, i_device)
def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id):
'''Set audio output device. Changes are only effective after stop and play. '''Configures an explicit audio output device for a given audio output plugin.
A list of possible devices can be obtained with
L{libvlc_audio_output_device_list_get}().
@note: This function does not select the specified audio output plugin.
L{libvlc_audio_output_set}() is used for that purpose.
@warning: The syntax for the device parameter depends on the audio output.
This is not portable. Only use this function if you know what you are doing.
Some audio outputs do not support this function (e.g. PulseAudio, WASAPI).
Some audio outputs require further parameters (e.g. ALSA: channels map).
@param p_mi: media player. @param p_mi: media player.
@param psz_audio_output: - name of audio output, See L{AudioOutput}. @param psz_audio_output: - name of audio output, See L{AudioOutput}.
@param psz_device_id: device. @param psz_device_id: device.
@return: Nothing. Errors are ignored.
''' '''
f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \ f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \
_Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None, _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None,
None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p)
return f(p_mi, psz_audio_output, psz_device_id) return f(p_mi, psz_audio_output, psz_device_id)
def libvlc_audio_output_get_device_type(p_mi):
'''Get current audio device type. Device type describes something like
character of output sound - stereo sound, 2.1, 5.1 etc.
@param p_mi: media player.
@return: the audio devices type See libvlc_audio_output_device_types_t.
'''
f = _Cfunctions.get('libvlc_audio_output_get_device_type', None) or \
_Cfunction('libvlc_audio_output_get_device_type', ((1,),), None,
ctypes.c_int, MediaPlayer)
return f(p_mi)
def libvlc_audio_output_set_device_type(p_mi, device_type):
'''Set current audio device type.
@param p_mi: vlc instance.
@param device_type: the audio device type,
'''
f = _Cfunctions.get('libvlc_audio_output_set_device_type', None) or \
_Cfunction('libvlc_audio_output_set_device_type', ((1,), (1,),), None,
None, MediaPlayer, ctypes.c_int)
return f(p_mi, device_type)
def libvlc_audio_toggle_mute(p_mi): def libvlc_audio_toggle_mute(p_mi):
'''Toggle mute status. '''Toggle mute status.
@param p_mi: media player. @param p_mi: media player @warning Toggling mute atomically is not always possible: On some platforms, other processes can mute the VLC audio playback stream asynchronously. Thus, there is a small race condition where toggling will not work. See also the limitations of L{libvlc_audio_set_mute}().
''' '''
f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \ f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \
_Cfunction('libvlc_audio_toggle_mute', ((1,),), None, _Cfunction('libvlc_audio_toggle_mute', ((1,),), None,
@ -5504,7 +5354,7 @@ def libvlc_audio_toggle_mute(p_mi):
def libvlc_audio_get_mute(p_mi): def libvlc_audio_get_mute(p_mi):
'''Get current mute status. '''Get current mute status.
@param p_mi: media player. @param p_mi: media player.
@return: the mute status (boolean) \libvlc_return_bool. @return: the mute status (boolean) if defined, -1 if undefined/unapplicable.
''' '''
f = _Cfunctions.get('libvlc_audio_get_mute', None) or \ f = _Cfunctions.get('libvlc_audio_get_mute', None) or \
_Cfunction('libvlc_audio_get_mute', ((1,),), None, _Cfunction('libvlc_audio_get_mute', ((1,),), None,
@ -5514,7 +5364,7 @@ def libvlc_audio_get_mute(p_mi):
def libvlc_audio_set_mute(p_mi, status): def libvlc_audio_set_mute(p_mi, status):
'''Set mute status. '''Set mute status.
@param p_mi: media player. @param p_mi: media player.
@param status: If status is true then mute, otherwise unmute. @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute.
''' '''
f = _Cfunctions.get('libvlc_audio_set_mute', None) or \ f = _Cfunctions.get('libvlc_audio_set_mute', None) or \
_Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None, _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None,
@ -5565,7 +5415,7 @@ def libvlc_audio_get_track_description(p_mi):
def libvlc_audio_get_track(p_mi): def libvlc_audio_get_track(p_mi):
'''Get current audio track. '''Get current audio track.
@param p_mi: media player. @param p_mi: media player.
@return: the audio track (int), or -1 if none. @return: the audio track ID or -1 if no active input.
''' '''
f = _Cfunctions.get('libvlc_audio_get_track', None) or \ f = _Cfunctions.get('libvlc_audio_get_track', None) or \
_Cfunction('libvlc_audio_get_track', ((1,),), None, _Cfunction('libvlc_audio_get_track', ((1,),), None,
@ -5575,7 +5425,7 @@ def libvlc_audio_get_track(p_mi):
def libvlc_audio_set_track(p_mi, i_track): def libvlc_audio_set_track(p_mi, i_track):
'''Set current audio track. '''Set current audio track.
@param p_mi: media player. @param p_mi: media player.
@param i_track: the track (int). @param i_track: the track ID (i_id field from track description).
@return: 0 on success, -1 on error. @return: 0 on success, -1 on error.
''' '''
f = _Cfunctions.get('libvlc_audio_set_track', None) or \ f = _Cfunctions.get('libvlc_audio_set_track', None) or \
@ -5933,11 +5783,14 @@ def libvlc_vlm_get_event_manager(p_instance):
return f(p_instance) return f(p_instance)
# 2 function(s) blacklisted: # 4 function(s) blacklisted:
# libvlc_audio_output_get_device_type
# libvlc_audio_output_set_device_type
# libvlc_printerr # libvlc_printerr
# libvlc_set_exit_handler # libvlc_set_exit_handler
# 17 function(s) not wrapped as methods: # 18 function(s) not wrapped as methods:
# libvlc_audio_output_device_list_release
# libvlc_audio_output_list_release # libvlc_audio_output_list_release
# libvlc_clearerr # libvlc_clearerr
# libvlc_clock # libvlc_clock
@ -5950,10 +5803,10 @@ def libvlc_vlm_get_event_manager(p_instance):
# libvlc_log_subscribe # libvlc_log_subscribe
# libvlc_log_subscribe_file # libvlc_log_subscribe_file
# libvlc_log_unsubscribe # libvlc_log_unsubscribe
# libvlc_media_tracks_release
# libvlc_module_description_list_release # libvlc_module_description_list_release
# libvlc_new # libvlc_new
# libvlc_track_description_list_release # libvlc_track_description_list_release
# libvlc_track_description_release
# libvlc_vprinterr # libvlc_vprinterr
# Start of footer.py # # Start of footer.py #
@ -6075,9 +5928,9 @@ if __name__ == '__main__':
print('Error: %s file not readable' % movie) print('Error: %s file not readable' % movie)
sys.exit(1) sys.exit(1)
instance = Instance() instance = Instance("--sub-source marq")
try: try:
media = instance.media_new(movie, 'sub-filter=marq') # load marqee option media = instance.media_new(movie)
except NameError: except NameError:
print('NameError: %s (%s vs LibVLC %s)' % (sys.exc_info()[1], print('NameError: %s (%s vs LibVLC %s)' % (sys.exc_info()[1],
__version__, __version__,
@ -6087,13 +5940,12 @@ if __name__ == '__main__':
player.set_media(media) player.set_media(media)
player.play() player.play()
# Some marquee examples. Marquee requires 'sub-filter=marq' in the # Some marquee examples. Marquee requires '--sub-source marq' in the
# media_new() call above. See also the Media.add_options method # Instance() call above. See <http://www.videolan.org/doc/play-howto/en/ch04.html>
# and <http://www.videolan.org/doc/play-howto/en/ch04.html>
player.video_set_marquee_int(VideoMarqueeOption.Enable, 1) player.video_set_marquee_int(VideoMarqueeOption.Enable, 1)
player.video_set_marquee_int(VideoMarqueeOption.Size, 24) # pixels player.video_set_marquee_int(VideoMarqueeOption.Size, 24) # pixels
player.video_set_marquee_int(VideoMarqueeOption.Position, Position.Bottom) player.video_set_marquee_int(VideoMarqueeOption.Position, Position.Bottom)
if True: # only one marquee can be specified if False: # only one marquee can be specified
player.video_set_marquee_int(VideoMarqueeOption.Timeout, 5000) # millisec, 0==forever player.video_set_marquee_int(VideoMarqueeOption.Timeout, 5000) # millisec, 0==forever
t = media.get_mrl() # movie t = media.get_mrl() # movie
else: # update marquee text periodically else: # update marquee text periodically

View File

@ -125,7 +125,6 @@ class VlcPlayer(MediaPlayer):
if Settings().value(u'advanced/hide mouse') and display.controller.isLive: if Settings().value(u'advanced/hide mouse') and display.controller.isLive:
command_line_options += u' --mouse-hide-timeout=0' command_line_options += u' --mouse-hide-timeout=0'
display.vlcInstance = vlc.Instance(command_line_options) display.vlcInstance = vlc.Instance(command_line_options)
display.vlcInstance.set_log_verbosity(2)
# creating an empty vlc media player # creating an empty vlc media player
display.vlcMediaPlayer = display.vlcInstance.media_player_new() display.vlcMediaPlayer = display.vlcInstance.media_player_new()
display.vlcWidget.resize(display.size()) display.vlcWidget.resize(display.size())

View File

@ -152,52 +152,52 @@ class ServiceManagerDialog(object):
# Add the bottom toolbar # Add the bottom toolbar
self.order_toolbar = OpenLPToolbar(self) self.order_toolbar = OpenLPToolbar(self)
action_list = ActionList.get_instance() 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', self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop',
text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', 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.'), 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', self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp',
text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), 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', self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown',
text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), 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', self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom',
text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', 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.'), 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', 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, 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) action_list.add_action(self.service_manager_list.down)
self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up',
text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', text=translate('OpenLP.ServiceManager', 'Move up'), can_shortcuts=True,
'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], tooltip=translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), visible=False,
triggers=self.on_move_selection_up) triggers=self.on_move_selection_up)
action_list.add_action(self.service_manager_list.up) action_list.add_action(self.service_manager_list.up)
self.order_toolbar.addSeparator() 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', text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), 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.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', text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png',
tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'),
shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) category=UiStrings().Service, triggers=self.onExpandAll)
self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', 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', text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png',
tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), 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.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', text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png',
tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), 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) triggers=self.make_live)
self.layout.addWidget(self.order_toolbar) self.layout.addWidget(self.order_toolbar)
# Connect up our signals and slots # Connect up our signals and slots

View File

@ -56,8 +56,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.setupUi(self) self.setupUi(self)
self.changedActions = {} self.changedActions = {}
self.action_list = ActionList.get_instance() self.action_list = ActionList.get_instance()
QtCore.QObject.connect(self.primaryPushButton, QtCore.SIGNAL(u'toggled(bool)'), self.dialog_was_shown = False
self.onPrimaryPushButtonClicked) QtCore.QObject.connect(self.primaryPushButton, QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked)
QtCore.QObject.connect(self.alternatePushButton, QtCore.SIGNAL(u'toggled(bool)'), QtCore.QObject.connect(self.alternatePushButton, QtCore.SIGNAL(u'toggled(bool)'),
self.onAlternatePushButtonClicked) self.onAlternatePushButtonClicked)
QtCore.QObject.connect(self.treeWidget, QtCore.QObject.connect(self.treeWidget,
@ -72,8 +72,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.onRestoreDefaultsClicked) self.onRestoreDefaultsClicked)
QtCore.QObject.connect(self.defaultRadioButton, QtCore.SIGNAL(u'clicked(bool)'), QtCore.QObject.connect(self.defaultRadioButton, QtCore.SIGNAL(u'clicked(bool)'),
self.onDefaultRadioButtonClicked) self.onDefaultRadioButtonClicked)
QtCore.QObject.connect(self.customRadioButton, QtCore.SIGNAL(u'clicked(bool)'), QtCore.QObject.connect(self.customRadioButton, QtCore.SIGNAL(u'clicked(bool)'), self.onCustomRadioButtonClicked)
self.onCustomRadioButtonClicked)
def keyPressEvent(self, event): def keyPressEvent(self, event):
""" """
@ -93,9 +92,12 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
""" """
if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked(): if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked():
return return
# Do not continue, as the event is for the dialog (close it).
if self.dialog_was_shown and event.key() in (QtCore.Qt.Key_Escape, QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
self.dialog_was_shown = False
return
key = event.key() key = event.key()
if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ if key in (QtCore.Qt.Key_Shift, QtCore.Qt.Key_Control, QtCore.Qt.Key_Meta, QtCore.Qt.Key_Alt):
key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt:
return return
key_string = QtGui.QKeySequence(key).toString() key_string = QtGui.QKeySequence(key).toString()
if event.modifiers() & QtCore.Qt.ControlModifier == QtCore.Qt.ControlModifier: if event.modifiers() & QtCore.Qt.ControlModifier == QtCore.Qt.ControlModifier:
@ -109,11 +111,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
key_sequence = QtGui.QKeySequence(key_string) key_sequence = QtGui.QKeySequence(key_string)
if self._validiate_shortcut(self._currentItemAction(), key_sequence): if self._validiate_shortcut(self._currentItemAction(), key_sequence):
if self.primaryPushButton.isChecked(): if self.primaryPushButton.isChecked():
self._adjustButton(self.primaryPushButton, self._adjustButton(self.primaryPushButton, False, text=key_sequence.toString())
False, text=key_sequence.toString())
elif self.alternatePushButton.isChecked(): elif self.alternatePushButton.isChecked():
self._adjustButton(self.alternatePushButton, self._adjustButton(self.alternatePushButton, False, text=key_sequence.toString())
False, text=key_sequence.toString())
def exec_(self): def exec_(self):
""" """
@ -147,8 +147,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def refreshShortcutList(self): def refreshShortcutList(self):
""" """
This refreshes the item's shortcuts shown in the list. Note, this This refreshes the item's shortcuts shown in the list. Note, this neither adds new actions nor removes old
neither adds new actions nor removes old actions. actions.
""" """
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget) iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
while iterator.value(): while iterator.value():
@ -204,21 +204,19 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
new_shortcuts = [] new_shortcuts = []
if shortcuts: if shortcuts:
new_shortcuts.append(shortcuts[0]) new_shortcuts.append(shortcuts[0])
new_shortcuts.append( new_shortcuts.append(QtGui.QKeySequence(self.alternatePushButton.text()))
QtGui.QKeySequence(self.alternatePushButton.text()))
self.changedActions[action] = new_shortcuts self.changedActions[action] = new_shortcuts
if not self.primaryPushButton.text(): if not self.primaryPushButton.text():
# When we do not have a primary shortcut, the just entered alternate # When we do not have a primary shortcut, the just entered alternate shortcut will automatically become the
# shortcut will automatically become the primary shortcut. That is # primary shortcut. That is why we have to adjust the primary button's text.
# why we have to adjust the primary button's text.
self.primaryPushButton.setText(self.alternatePushButton.text()) self.primaryPushButton.setText(self.alternatePushButton.text())
self.alternatePushButton.setText(u'') self.alternatePushButton.setText(u'')
self.refreshShortcutList() self.refreshShortcutList()
def onItemDoubleClicked(self, item, column): def onItemDoubleClicked(self, item, column):
""" """
A item has been double clicked. The ``primaryPushButton`` will be A item has been double clicked. The ``primaryPushButton`` will be checked and the item's shortcut will be
checked and the item's shortcut will be displayed. displayed.
""" """
action = self._currentItemAction(item) action = self._currentItemAction(item)
if action is None: if action is None:
@ -234,8 +232,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def onCurrentItemChanged(self, item=None, previousItem=None): def onCurrentItemChanged(self, item=None, previousItem=None):
""" """
A item has been pressed. We adjust the button's text to the action's A item has been pressed. We adjust the button's text to the action's shortcut which is encapsulate in the item.
shortcut which is encapsulate in the item.
""" """
action = self._currentItemAction(item) action = self._currentItemAction(item)
self.primaryPushButton.setEnabled(action is not None) self.primaryPushButton.setEnabled(action is not None)
@ -253,9 +250,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
if len(action.defaultShortcuts) == 2: if len(action.defaultShortcuts) == 2:
alternate_label_text = action.defaultShortcuts[1].toString() alternate_label_text = action.defaultShortcuts[1].toString()
shortcuts = self._actionShortcuts(action) shortcuts = self._actionShortcuts(action)
# We do not want to loose pending changes, that is why we have to # We do not want to loose pending changes, that is why we have to keep the text when, this function has not
# keep the text when, this function has not been triggered by a # been triggered by a signal.
# signal.
if item is None: if item is None:
primary_text = self.primaryPushButton.text() primary_text = self.primaryPushButton.text()
alternate_text = self.alternatePushButton.text() alternate_text = self.alternatePushButton.text()
@ -264,8 +260,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
elif len(shortcuts) == 2: elif len(shortcuts) == 2:
primary_text = shortcuts[0].toString() primary_text = shortcuts[0].toString()
alternate_text = shortcuts[1].toString() alternate_text = shortcuts[1].toString()
# When we are capturing a new shortcut, we do not want, the buttons to # When we are capturing a new shortcut, we do not want, the buttons to display the current shortcut.
# display the current shortcut.
if self.primaryPushButton.isChecked(): if self.primaryPushButton.isChecked():
primary_text = u'' primary_text = u''
if self.alternatePushButton.isChecked(): if self.alternatePushButton.isChecked():
@ -274,8 +269,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.alternatePushButton.setText(alternate_text) self.alternatePushButton.setText(alternate_text)
self.primaryLabel.setText(primary_label_text) self.primaryLabel.setText(primary_label_text)
self.alternateLabel.setText(alternate_label_text) self.alternateLabel.setText(alternate_label_text)
# We do not want to toggle and radio button, as the function has not # We do not want to toggle and radio button, as the function has not been triggered by a signal.
# been triggered by a signal.
if item is None: if item is None:
return return
if primary_label_text == primary_text and alternate_label_text == alternate_text: if primary_label_text == primary_text and alternate_label_text == alternate_text:
@ -303,8 +297,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def onDefaultRadioButtonClicked(self, toggled): def onDefaultRadioButtonClicked(self, toggled):
""" """
The default radio button has been clicked, which means we have to make The default radio button has been clicked, which means we have to make sure, that we use the default shortcuts
sure, that we use the default shortcuts for the action. for the action.
""" """
if not toggled: if not toggled:
return return
@ -325,9 +319,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def onCustomRadioButtonClicked(self, toggled): def onCustomRadioButtonClicked(self, toggled):
""" """
The custom shortcut radio button was clicked, thus we have to restore The custom shortcut radio button was clicked, thus we have to restore the custom shortcuts by calling those
the custom shortcuts by calling those functions triggered by button functions triggered by button clicks.
clicks.
""" """
if not toggled: if not toggled:
return return
@ -337,8 +330,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def save(self): def save(self):
""" """
Save the shortcuts. **Note**, that we do not have to load the shortcuts, Save the shortcuts. **Note**, that we do not have to load the shortcuts, as they are loaded in
as they are loaded in :class:`~openlp.core.utils.ActionList`. :class:`~openlp.core.utils.ActionList`.
""" """
settings = Settings() settings = Settings()
settings.beginGroup(u'shortcuts') settings.beginGroup(u'shortcuts')
@ -348,8 +341,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
continue continue
for action in category.actions: for action in category.actions:
if action in self.changedActions: if action in self.changedActions:
old_shortcuts = map(unicode, old_shortcuts = map(QtGui.QKeySequence.toString, action.shortcuts())
map(QtGui.QKeySequence.toString, action.shortcuts()))
action.setShortcuts(self.changedActions[action]) action.setShortcuts(self.changedActions[action])
self.action_list.update_shortcut_map(action, old_shortcuts) self.action_list.update_shortcut_map(action, old_shortcuts)
settings.setValue(action.objectName(), action.shortcuts()) settings.setValue(action.objectName(), action.shortcuts())
@ -367,13 +359,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
new_shortcuts = [] new_shortcuts = []
if action.defaultShortcuts: if action.defaultShortcuts:
new_shortcuts.append(action.defaultShortcuts[0]) new_shortcuts.append(action.defaultShortcuts[0])
# We have to check if the primary default shortcut is available. But # We have to check if the primary default shortcut is available. But we only have to check, if the action
# we only have to check, if the action has a default primary # has a default primary shortcut (an "empty" shortcut is always valid and if the action does not have a
# shortcut (an "empty" shortcut is always valid and if the action # default primary shortcut, then the alternative shortcut (not the default one) will become primary
# does not have a default primary shortcut, then the alternative # shortcut, thus the check will assume that an action were going to have the same shortcut twice.
# shortcut (not the default one) will become primary shortcut, thus
# the check will assume that an action were going to have the same
# shortcut twice.
if not self._validiate_shortcut(action, new_shortcuts[0]) and new_shortcuts[0] != shortcuts[0]: if not self._validiate_shortcut(action, new_shortcuts[0]) and new_shortcuts[0] != shortcuts[0]:
return return
if len(shortcuts) == 2: if len(shortcuts) == 2:
@ -405,9 +394,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def _validiate_shortcut(self, changing_action, key_sequence): def _validiate_shortcut(self, changing_action, key_sequence):
""" """
Checks if the given ``changing_action `` can use the given Checks if the given ``changing_action `` can use the given ``key_sequence``. Returns ``True`` if the
``key_sequence``. Returns ``True`` if the ``key_sequence`` can be used ``key_sequence`` can be used by the action, otherwise displays a dialog and returns ``False``.
by the action, otherwise displays a dialog and returns ``False``.
``changing_action`` ``changing_action``
The action which wants to use the ``key_sequence``. The action which wants to use the ``key_sequence``.
@ -429,27 +417,25 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
# Have the same parent, thus they cannot have the same shortcut. # Have the same parent, thus they cannot have the same shortcut.
if action.parent() is changing_action.parent(): if action.parent() is changing_action.parent():
is_valid = False is_valid = False
# The new shortcut is already assigned, but if both shortcuts # The new shortcut is already assigned, but if both shortcuts are only valid in a different widget the
# are only valid in a different widget the new shortcut is # new shortcut is vaild, because they will not interfere.
# vaild, because they will not interfere. if action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
is_valid = False is_valid = False
if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
is_valid = False is_valid = False
if not is_valid: if not is_valid:
self.main_window.warning_message( translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), self.main_window.warning_message(translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
translate('OpenLP.ShortcutListDialog', translate('OpenLP.ShortcutListDialog',
'The shortcut "%s" is already assigned to another action, please use a different shortcut.') % 'The shortcut "%s" is already assigned to another action, please use a different shortcut.') %
key_sequence.toString() key_sequence.toString()
) )
self.dialog_was_shown = True
return is_valid return is_valid
def _actionShortcuts(self, action): def _actionShortcuts(self, action):
""" """
This returns the shortcuts for the given ``action``, which also includes This returns the shortcuts for the given ``action``, which also includes those shortcuts which are not saved
those shortcuts which are not saved yet but already assigned (as changes yet but already assigned (as changes yre applied when closing the dialog).
are applied when closing the dialog).
""" """
if action in self.changedActions: if action in self.changedActions:
return self.changedActions[action] return self.changedActions[action]
@ -457,8 +443,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
def _currentItemAction(self, item=None): def _currentItemAction(self, item=None):
""" """
Returns the action of the given ``item``. If no item is given, we return Returns the action of the given ``item``. If no item is given, we return the action of the current item of
the action of the current item of the ``treeWidget``. the ``treeWidget``.
""" """
if item is None: if item is None:
item = self.treeWidget.currentItem() item = self.treeWidget.currentItem()
@ -487,3 +473,4 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
return self._main_window return self._main_window
main_window = property(_get_main_window) main_window = property(_get_main_window)

View File

@ -44,6 +44,14 @@ from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__) 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): class DisplayController(QtGui.QWidget):
""" """
@ -123,7 +131,7 @@ class SlideController(DisplayController):
self.keypress_queue = deque() self.keypress_queue = deque()
self.keypress_loop = False self.keypress_loop = False
self.category = UiStrings().LiveToolbar 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: else:
Registry().register(u'preview_controller', self) Registry().register(u'preview_controller', self)
self.typeLabel.setText(UiStrings().Preview) self.typeLabel.setText(UiStrings().Preview)
@ -167,13 +175,13 @@ class SlideController(DisplayController):
self.previousItem = create_action(self, u'previousItem_' + self.typePrefix, self.previousItem = create_action(self, u'previousItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png', text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png',
tooltip=translate('OpenLP.SlideController', 'Move to previous.'), tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.on_slide_selected_previous) category=self.category, triggers=self.on_slide_selected_previous)
self.toolbar.addAction(self.previousItem) self.toolbar.addAction(self.previousItem)
self.nextItem = create_action(self, u'nextItem_' + self.typePrefix, self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png', text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png',
tooltip=translate('OpenLP.SlideController', 'Move to next.'), tooltip=translate('OpenLP.SlideController', 'Move to next.'),
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.on_slide_selected_next_action) category=self.category, triggers=self.on_slide_selected_next_action)
self.toolbar.addAction(self.nextItem) self.toolbar.addAction(self.nextItem)
self.toolbar.addSeparator() self.toolbar.addSeparator()
@ -189,14 +197,14 @@ class SlideController(DisplayController):
self.toolbar.addToolbarWidget(self.hideMenu) self.toolbar.addToolbarWidget(self.hideMenu)
self.blankScreen = create_action(self, u'blankScreen', self.blankScreen = create_action(self, u'blankScreen',
text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', 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, can_shortcuts=True, category=self.category, triggers=self.onBlankDisplay)
self.themeScreen = create_action(self, u'themeScreen', self.themeScreen = create_action(self, u'themeScreen',
text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', 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, can_shortcuts=True, category=self.category,
triggers=self.onThemeDisplay) triggers=self.onThemeDisplay)
self.desktopScreen = create_action(self, u'desktopScreen', self.desktopScreen = create_action(self, u'desktopScreen',
text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png',
checked=False, shortcuts=[QtGui.QKeySequence(u'D')], category=self.category, checked=False, can_shortcuts=True, category=self.category,
triggers=self.onHideDisplay) triggers=self.onHideDisplay)
self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.setDefaultAction(self.blankScreen)
self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.blankScreen)
@ -224,10 +232,10 @@ class SlideController(DisplayController):
self.playSlidesMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) self.playSlidesMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar))
self.toolbar.addToolbarWidget(self.playSlidesMenu) self.toolbar.addToolbarWidget(self.playSlidesMenu)
self.playSlidesLoop = create_action(self, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, 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, can_shortcuts=True,
category=self.category, triggers=self.onPlaySlidesLoop) category=self.category, triggers=self.onPlaySlidesLoop)
self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, 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, can_shortcuts=True,
category=self.category, triggers=self.onPlaySlidesOnce) category=self.category, triggers=self.onPlaySlidesOnce)
if Settings().value(self.main_window.advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap: if Settings().value(self.main_window.advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap:
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
@ -266,7 +274,7 @@ class SlideController(DisplayController):
icon=u':/slides/media_playback_pause.png', text=translate('OpenLP.SlideController', 'Pause Audio'), icon=u':/slides/media_playback_pause.png', text=translate('OpenLP.SlideController', 'Pause Audio'),
tooltip=translate('OpenLP.SlideController', 'Pause audio.'), tooltip=translate('OpenLP.SlideController', 'Pause audio.'),
checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut, checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut,
shortcuts=[], triggers=self.onAudioPauseClicked) can_shortcuts=True, triggers=self.onAudioPauseClicked)
self.audioMenu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) self.audioMenu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar)
self.audioPauseItem.setMenu(self.audioMenu) self.audioPauseItem.setMenu(self.audioMenu)
self.audioPauseItem.setParent(self.toolbar) self.audioPauseItem.setParent(self.toolbar)
@ -275,20 +283,12 @@ class SlideController(DisplayController):
self.nextTrackItem = create_action(self, u'nextTrackItem', text=UiStrings().NextTrack, self.nextTrackItem = create_action(self, u'nextTrackItem', text=UiStrings().NextTrack,
icon=u':/slides/media_playback_next.png', icon=u':/slides/media_playback_next.png',
tooltip=translate('OpenLP.SlideController', 'Go to next audio track.'), tooltip=translate('OpenLP.SlideController', 'Go to next audio track.'),
category=self.category, shortcuts=[], triggers=self.onNextTrackClicked) category=self.category, can_shortcuts=True, triggers=self.onNextTrackClicked)
self.audioMenu.addAction(self.nextTrackItem) self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks')) self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks'))
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setStyleSheet( self.audioTimeLabel.setStyleSheet(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;'
)
self.audioTimeLabel.setObjectName(u'audioTimeLabel') self.audioTimeLabel.setObjectName(u'audioTimeLabel')
self.toolbar.addToolbarWidget(self.audioTimeLabel) self.toolbar.addToolbarWidget(self.audioTimeLabel)
self.toolbar.setWidgetVisible(self.audioList, False) self.toolbar.setWidgetVisible(self.audioList, False)
@ -334,25 +334,20 @@ class SlideController(DisplayController):
self.shortcutTimer = QtCore.QTimer() self.shortcutTimer = QtCore.QTimer()
self.shortcutTimer.setObjectName(u'shortcutTimer') self.shortcutTimer.setObjectName(u'shortcutTimer')
self.shortcutTimer.setSingleShot(True) self.shortcutTimer.setSingleShot(True)
shortcuts = [{u'key': u'V', u'configurable': True, shortcuts = [
u'text': translate('OpenLP.SlideController', 'Go to "Verse"')}, {u'key': u'V', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Verse"')},
{u'key': u'C', u'configurable': True, {u'key': u'C', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Chorus"')},
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'B', u'configurable': True,
u'text': translate('OpenLP.SlideController', 'Go to "Bridge"')},
{u'key': u'P', u'configurable': True, {u'key': u'P', u'configurable': True,
u'text': translate('OpenLP.SlideController', u'text': translate('OpenLP.SlideController', 'Go to "Pre-Chorus"')},
'Go to "Pre-Chorus"')}, {u'key': u'I', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Intro"')},
{u'key': u'I', u'configurable': True, {u'key': u'E', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Ending"')},
u'text': translate('OpenLP.SlideController', 'Go to "Intro"')}, {u'key': u'O', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Other"')}
{u'key': u'E', u'configurable': True, ]
u'text': translate('OpenLP.SlideController', 'Go to "Ending"')}, shortcuts.extend([{u'key': unicode(number)} for number in range(10)])
{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)]
self.previewListWidget.addActions([create_action(self, self.previewListWidget.addActions([create_action(self,
u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'),
shortcuts=[QtGui.QKeySequence(s[u'key'])], can_shortcuts=True,
context=QtCore.Qt.WidgetWithChildrenShortcut, context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category if s.get(u'configurable') else None, category=self.category if s.get(u'configurable') else None,
triggers=self._slideShortcutActivated) for s in shortcuts]) triggers=self._slideShortcutActivated) for s in shortcuts])
@ -451,15 +446,15 @@ class SlideController(DisplayController):
""" """
self.previousService = create_action(parent, u'previousService', self.previousService = create_action(parent, u'previousService',
text=translate('OpenLP.SlideController', 'Previous Service'), text=translate('OpenLP.SlideController', 'Previous Service'),
shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.servicePrevious) triggers=self.servicePrevious)
self.nextService = create_action(parent, 'nextService', self.nextService = create_action(parent, 'nextService',
text=translate('OpenLP.SlideController', 'Next Service'), text=translate('OpenLP.SlideController', 'Next Service'),
shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.serviceNext) triggers=self.serviceNext)
self.escapeItem = create_action(parent, 'escapeItem', self.escapeItem = create_action(parent, 'escapeItem',
text=translate('OpenLP.SlideController', 'Escape Item'), text=translate('OpenLP.SlideController', 'Escape Item'),
shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.liveEscape) triggers=self.liveEscape)
def liveEscape(self): def liveEscape(self):

View File

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

View File

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

View File

@ -106,7 +106,7 @@ class ImageMediaItem(MediaManagerItem):
delete_file(os.path.join(self.servicePath, text.text())) delete_file(os.path.join(self.servicePath, text.text()))
self.listView.takeItem(row) self.listView.takeItem(row)
self.main_window.incrementProgressBar() self.main_window.incrementProgressBar()
AppLocation.setValue(self.settingsSection + u'/images files', self.getFileList()) Settings.setValue(self.settingsSection + u'/images files', self.getFileList())
self.main_window.finishedProgressBar() self.main_window.finishedProgressBar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
self.listView.blockSignals(False) self.listView.blockSignals(False)

View File

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

View File

@ -0,0 +1,124 @@
"""
Package to test the openlp.core.utils.actions package.
"""
import os
from tempfile import mkstemp
from unittest import TestCase
from PyQt4 import QtGui, QtCore
from openlp.core.lib import Settings
from openlp.core.utils import ActionList
class TestActionList(TestCase):
def setUp(self):
"""
Prepare the tests
"""
self.action_list = ActionList.get_instance()
self.settings = Settings()
fd, self.ini_file = mkstemp(u'.ini')
self.settings.set_filename(self.ini_file)
self.settings.beginGroup(u'shortcuts')
def tearDown(self):
"""
Clean up
"""
self.settings.endGroup()
os.unlink(self.ini_file)
def test_add_action_same_parent(self):
"""
ActionList test - Tests the add_action method. The actions have the same parent, the same shortcuts and both
have the QtCore.Qt.WindowShortcut shortcut context set.
"""
# GIVEN: Two actions with the same shortcuts.
parent = QtCore.QObject()
action1 = QtGui.QAction(parent)
action1.setObjectName(u'action1')
action_with_same_shortcuts1 = QtGui.QAction(parent)
action_with_same_shortcuts1.setObjectName(u'action_with_same_shortcuts1')
# Add default shortcuts to Settings class.
default_shortcuts = {
u'shortcuts/action1': [QtGui.QKeySequence(u'a'), QtGui.QKeySequence(u'b')],
u'shortcuts/action_with_same_shortcuts1': [QtGui.QKeySequence(u'b'), QtGui.QKeySequence(u'a')]
}
Settings.extend_default_settings(default_shortcuts)
# WHEN: Add the two actions to the action list.
self.action_list.add_action(action1, u'example_category')
self.action_list.add_action(action_with_same_shortcuts1, u'example_category')
# Remove the actions again.
self.action_list.remove_action(action1, u'example_category')
self.action_list.remove_action(action_with_same_shortcuts1, u'example_category')
# THEN: As both actions have the same shortcuts, they should be removed from one action.
assert len(action1.shortcuts()) == 2, u'The action should have two shortcut assigned.'
assert len(action_with_same_shortcuts1.shortcuts()) == 0, u'The action should not have a shortcut assigned.'
def test_add_action_different_parent(self):
"""
ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
both have the QtCore.Qt.WindowShortcut shortcut context set.
"""
# GIVEN: Two actions with the same shortcuts.
parent = QtCore.QObject()
action2 = QtGui.QAction(parent)
action2.setObjectName(u'action2')
second_parent = QtCore.QObject()
action_with_same_shortcuts2 = QtGui.QAction(second_parent)
action_with_same_shortcuts2.setObjectName(u'action_with_same_shortcuts2')
# Add default shortcuts to Settings class.
default_shortcuts = {
u'shortcuts/action2': [QtGui.QKeySequence(u'c'), QtGui.QKeySequence(u'd')],
u'shortcuts/action_with_same_shortcuts2': [QtGui.QKeySequence(u'd'), QtGui.QKeySequence(u'c')]
}
Settings.extend_default_settings(default_shortcuts)
# WHEN: Add the two actions to the action list.
self.action_list.add_action(action2, u'example_category')
self.action_list.add_action(action_with_same_shortcuts2, u'example_category')
# Remove the actions again.
self.action_list.remove_action(action2, u'example_category')
self.action_list.remove_action(action_with_same_shortcuts2, u'example_category')
# THEN: As both actions have the same shortcuts, they should be removed from one action.
assert len(action2.shortcuts()) == 2, u'The action should have two shortcut assigned.'
assert len(action_with_same_shortcuts2.shortcuts()) == 0, u'The action should not have a shortcut assigned.'
def test_add_action_different_context(self):
"""
ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
both have the QtCore.Qt.WidgetShortcut shortcut context set.
"""
# GIVEN: Two actions with the same shortcuts.
parent = QtCore.QObject()
action3 = QtGui.QAction(parent)
action3.setObjectName(u'action3')
action3.setShortcutContext(QtCore.Qt.WidgetShortcut)
second_parent = QtCore.QObject()
action_with_same_shortcuts3 = QtGui.QAction(second_parent)
action_with_same_shortcuts3.setObjectName(u'action_with_same_shortcuts3')
action_with_same_shortcuts3.setShortcutContext(QtCore.Qt.WidgetShortcut)
# Add default shortcuts to Settings class.
default_shortcuts = {
u'shortcuts/action3': [QtGui.QKeySequence(u'e'), QtGui.QKeySequence(u'f')],
u'shortcuts/action_with_same_shortcuts3': [QtGui.QKeySequence(u'e'), QtGui.QKeySequence(u'f')]
}
Settings.extend_default_settings(default_shortcuts)
# WHEN: Add the two actions to the action list.
self.action_list.add_action(action3, u'example_category2')
self.action_list.add_action(action_with_same_shortcuts3, u'example_category2')
# Remove the actions again.
self.action_list.remove_action(action3, u'example_category2')
self.action_list.remove_action(action_with_same_shortcuts3, u'example_category2')
# THEN: Both action should keep their shortcuts.
assert len(action3.shortcuts()) == 2, u'The action should have two shortcut assigned.'
assert len(action_with_same_shortcuts3.shortcuts()) == 2, u'The action should have two shortcuts assigned.'