From eb121abb12590f992707325902cda92459ddb940 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 15:38:30 +0100 Subject: [PATCH 1/7] attempt to fix bug 768495 Fixes: https://launchpad.net/bugs/768495 --- openlp/core/utils/actions.py | 57 +++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 86ee69a48..36c1c2e78 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,6 +188,7 @@ class ActionList(object): actions or categories. """ instance = None + action_map = {} def __init__(self): self.categories = CategoryList() @@ -226,17 +227,41 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - if category is None: - # Stop here, as this action is not configurable. - return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() + settings.endGroup() + if not shortcuts: + action.setShortcuts([]) + return + shortcuts = map(unicode, shortcuts) + # Check the alternate shortcut first, to avoid problems when the + # alternate shortcut becomes the primary shortcut after removing the + # (initial) primary shortcut due to confllicts. + if len(shortcuts) == 2: + existing_actions = ActionList.action_map.get(shortcuts[1], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.action_map.get(shortcuts[1], []) + actions.append(action) + ActionList.action_map[shortcuts[1]] = actions + else: + shortcuts.remove(shortcuts[1]) + # Check the primary shortcut. + existing_actions = ActionList.action_map.get(shortcuts[0], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.action_map.get(shortcuts[0], []) + actions.append(action) + ActionList.action_map[shortcuts[0]] = actions + else: + shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) - settings.endGroup() def remove_action(self, action, category=None): """ @@ -279,6 +304,30 @@ class ActionList(object): return self.categories.add(name, weight) + def _shortcut_available(self, existing_actions, action): + """ + Checks if the given ``action`` may use its assigned shortcut(s) or not. + Returns ``True`` or ``False. + + ``existing_actions`` + A list of actions which already use a particular shortcut. + + ``action`` + The action which wants to use a particular shortcut. + """ + for existing_action in existing_actions: + if action is existing_action: + continue + if existing_action.parent() is action.parent(): + return False + if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + if action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + return True + class CategoryOrder(object): """ From 5bfc101f0978acb6b5a0ae4410e4ae5ced9f8de2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 16:09:03 +0100 Subject: [PATCH 2/7] changed name --- openlp/core/utils/actions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 36c1c2e78..525a18f37 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,7 +188,7 @@ class ActionList(object): actions or categories. """ instance = None - action_map = {} + shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -241,23 +241,23 @@ class ActionList(object): # alternate shortcut becomes the primary shortcut after removing the # (initial) primary shortcut due to confllicts. if len(shortcuts) == 2: - existing_actions = ActionList.action_map.get(shortcuts[1], []) + existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) # Check for conflicts with other actions considering the shortcut # context. if self._shortcut_available(existing_actions, action): - actions = ActionList.action_map.get(shortcuts[1], []) + actions = ActionList.shortcut_map.get(shortcuts[1], []) actions.append(action) - ActionList.action_map[shortcuts[1]] = actions + ActionList.shortcut_map[shortcuts[1]] = actions else: shortcuts.remove(shortcuts[1]) # Check the primary shortcut. - existing_actions = ActionList.action_map.get(shortcuts[0], []) + existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) # Check for conflicts with other actions considering the shortcut # context. if self._shortcut_available(existing_actions, action): - actions = ActionList.action_map.get(shortcuts[0], []) + actions = ActionList.shortcut_map.get(shortcuts[0], []) actions.append(action) - ActionList.action_map[shortcuts[0]] = actions + ActionList.shortcut_map[shortcuts[0]] = actions else: shortcuts.remove(shortcuts[0]) action.setShortcuts( @@ -269,7 +269,7 @@ class ActionList(object): automatically removed. ``action`` - The QAction object to be removed. + The ``QAction`` object to be removed. ``category`` The name (unicode string) of the category, which contains the From f34ae80eec59edff957c5a78401d397019d01697 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 19:01:36 +0100 Subject: [PATCH 3/7] fixed bug 887313 Fixes: https://launchpad.net/bugs/887313 --- openlp/core/ui/printserviceform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index c08b6293e..4d1dc71c8 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -402,6 +402,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.endGroup() def update_song_usage(self): + # Only continue when we include the song's text. + if not self.slideTextCheckBox.isChecked(): + return for index, item in enumerate(self.serviceManager.serviceItems): # Trigger Audit requests Receiver.send_message(u'print_service_started', From 5b67d36b3cc91c94ffde82adfba1ab4c9d37350d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 3 Dec 2011 20:23:46 +0200 Subject: [PATCH 4/7] Fix problem where importing new song databases now does not work. Fixes: https://launchpad.net/bugs/863845 --- openlp/plugins/songs/lib/olpimport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 75e149fad..29d03a136 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -39,7 +39,7 @@ from openlp.core.lib import translate from openlp.core.lib.db import BaseModel from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song -from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile +from openlp.plugins.songs.lib.db import Author, Book, Song, Topic, MediaFile from songimport import SongImport log = logging.getLogger(__name__) @@ -143,7 +143,8 @@ class OpenLPSongImport(SongImport): secondary=source_media_files_songs_table) else: song_props['media_files'] = relation(OldMediaFile, - backref='songs') + backref='songs', primaryjoin=source_songs_table.c.id==OldMediaFile.song_id, + foreign_keys=[source_media_files_table.c.song_id]) try: class_mapper(OldAuthor) except UnmappedClassError: From b78bb1c7e60547814beb6da01b92cbd79a0743bc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 21:35:53 +0100 Subject: [PATCH 5/7] fixed tooltip strings --- openlp/core/ui/media/mediacontroller.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b05a7fe59..c4e3e7fa9 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -206,15 +206,15 @@ class MediaController(object): controller.mediabar = OpenLPToolbar(controller) controller.mediabar.addToolbarButton( u'media_playback_play', u':/slides/media_playback_start.png', - translate('OpenLP.SlideController', 'Start playing media'), + translate('OpenLP.SlideController', 'Start playing media.'), controller.sendToPlugins) controller.mediabar.addToolbarButton( u'media_playback_pause', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Pause playing media'), + translate('OpenLP.SlideController', 'Pause playing media.'), controller.sendToPlugins) controller.mediabar.addToolbarButton( u'media_playback_stop', u':/slides/media_playback_stop.png', - translate('OpenLP.SlideController', 'Stop playing media'), + translate('OpenLP.SlideController', 'Stop playing media.'), controller.sendToPlugins) # Build the seekSlider. controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) @@ -223,7 +223,7 @@ class MediaController(object): 'OpenLP.SlideController', 'Video position.')) controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) controller.seekSlider.setObjectName(u'seek_slider') - controller.mediabar.addToolbarWidget(u'Seek Slider', + controller.mediabar.addToolbarWidget(u'Seek Slider', controller.seekSlider) # Build the volumeSlider. controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) @@ -236,7 +236,7 @@ class MediaController(object): controller.volumeSlider.setValue(controller.media_info.volume) controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) controller.volumeSlider.setObjectName(u'volume_slider') - controller.mediabar.addToolbarWidget(u'Audio Volume', + controller.mediabar.addToolbarWidget(u'Audio Volume', controller.volumeSlider) control_panel.addWidget(controller.mediabar) controller.mediabar.setVisible(False) @@ -255,7 +255,7 @@ class MediaController(object): def setup_display(self, display): """ - After a new display is configured, all media related widget will be + After a new display is configured, all media related widget will be created too """ # clean up possible running old media files @@ -276,13 +276,13 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) - # Special controls: Here media type specific Controls will be enabled + # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO def resize(self, controller, display, player): """ - After Mainwindow changes or Splitter moved all related media widgets + After Mainwindow changes or Splitter moved all related media widgets have to be resized """ player.resize(display) @@ -389,7 +389,7 @@ class MediaController(object): def video_play(self, msg, status=True): """ Responds to the request to play a loaded video - + ``msg`` First element is the controller which should be used """ From def18307ccc9d1bb7b0c95d1eee4aaae65994900 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 3 Dec 2011 23:49:40 +0200 Subject: [PATCH 6/7] Avoid an error about something not being a Boolean. Fixes: https://launchpad.net/bugs/899532 --- openlp/plugins/songs/lib/olpimport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 29d03a136..99ca9e748 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -121,6 +121,7 @@ class OpenLPSongImport(SongImport): source_topics_table = source_meta.tables[u'topics'] source_authors_songs_table = source_meta.tables[u'authors_songs'] source_songs_topics_table = source_meta.tables[u'songs_topics'] + source_media_files_songs_table = None if has_media_files: source_media_files_table = source_meta.tables[u'media_files'] source_media_files_songs_table = \ @@ -137,7 +138,7 @@ class OpenLPSongImport(SongImport): secondary=source_songs_topics_table) } if has_media_files: - if source_media_files_songs_table: + if source_media_files_songs_table is not None: song_props['media_files'] = relation(OldMediaFile, backref='songs', secondary=source_media_files_songs_table) From 2016ce61ca220fdc7dcfe5445bb7d35966698657 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 4 Dec 2011 00:30:22 +0200 Subject: [PATCH 7/7] Sometimes the song_id column doesn't exist on the model, so we use the table instead. --- openlp/plugins/songs/lib/olpimport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 99ca9e748..d7a735033 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -144,8 +144,9 @@ class OpenLPSongImport(SongImport): secondary=source_media_files_songs_table) else: song_props['media_files'] = relation(OldMediaFile, - backref='songs', primaryjoin=source_songs_table.c.id==OldMediaFile.song_id, - foreign_keys=[source_media_files_table.c.song_id]) + backref='songs', + primaryjoin=source_songs_table.c.id == \ + source_media_files_table.c.song_id) try: class_mapper(OldAuthor) except UnmappedClassError: