From 95147c996bbe478c39b72fe72c4c4ecaaed3f61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Thu, 15 Dec 2011 05:45:30 +0200 Subject: [PATCH 01/46] Fix #304, catch AttributeError together with XML syntax error (which is true in wider meaning of syntax, I think). --- openlp/plugins/songs/lib/openlyricsimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index f3639fc3b..42d075c51 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -70,6 +70,6 @@ class OpenLyricsImport(SongImport): parsed_file = etree.parse(open(file_path, u'r'), parser) xml = unicode(etree.tostring(parsed_file)) self.openLyrics.xml_to_song(xml) - except etree.XMLSyntaxError: + except etree.XMLSyntaxError, AttributeError: log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) From 235e8c6fcfb8e6fa7e8d4c4eb334e6d5b633dd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Thu, 15 Dec 2011 13:53:51 +0200 Subject: [PATCH 02/46] Use generated exceptions instead to make more specific errors. --- openlp/plugins/songs/lib/openlyricsimport.py | 5 ++++- openlp/plugins/songs/lib/xml.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 42d075c51..784a16b72 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -70,6 +70,9 @@ class OpenLyricsImport(SongImport): parsed_file = etree.parse(open(file_path, u'r'), parser) xml = unicode(etree.tostring(parsed_file)) self.openLyrics.xml_to_song(xml) - except etree.XMLSyntaxError, AttributeError: + except etree.XMLSyntaxError: log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) + except Exception as values: + log.exception(u'%s in file %s' % (values[0], file_path)) + self.logError(file_path, SongStrings.XMLSyntaxError) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index b16db7e94..578e66c98 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -673,9 +673,16 @@ class OpenLyrics(object): sxml = SongXML() verses = {} verse_def_list = [] - lyrics = song_xml.lyrics + try: + lyrics = song_xml.lyrics + except AttributeError: + raise Exception('XML error, missing lyrics item') + try: + verses = lyrics.verse + except AttributeError: + raise Exception('XML error, missing verse item') # Loop over the "verse" elements. - for verse in lyrics.verse: + for verse in verses: text = u'' # Loop over the "lines" elements. for lines in verse.lines: From 28fa03b7cdd4f5f829acbba46148bb791909bdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Sat, 17 Dec 2011 19:26:59 +0200 Subject: [PATCH 03/46] Use OpenLyricsException instead. --- openlp/plugins/songs/lib/openlyricsimport.py | 11 ++++++++--- openlp/plugins/songs/lib/xml.py | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 784a16b72..37ff2ed98 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -38,6 +38,7 @@ from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib import OpenLyrics +from openlp.plugins.songs.lib.xml import OpenLyricsException log = logging.getLogger(__name__) @@ -73,6 +74,10 @@ class OpenLyricsImport(SongImport): except etree.XMLSyntaxError: log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) - except Exception as values: - log.exception(u'%s in file %s' % (values[0], file_path)) - self.logError(file_path, SongStrings.XMLSyntaxError) + except OpenLyricsException as exception: + log.exception(u'OpenLyricsException of type %s: %s in file %s' + % (exception.type, exception.message, file_path)) + if exception.type is 'XML': + self.logError(file_path, SongStrings.XMLSyntaxError) + else: + self.logError(file_path, exception.message) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 578e66c98..df545bee1 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,11 +676,11 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise Exception('XML error, missing lyrics item') + raise OpenLyricsException('XML', 'missing lyrics item') try: verses = lyrics.verse except AttributeError: - raise Exception('XML error, missing verse item') + raise OpenLyricsException('XML', 'missing verse item') # Loop over the "verse" elements. for verse in verses: text = u'' @@ -798,3 +798,15 @@ class OpenLyrics(object): """ return etree.tostring(xml, encoding=u'UTF-8', xml_declaration=True, pretty_print=True) + + +class OpenLyricsException(Exception): + """ + By now raised only in case of missing lyrics or verse element in XML. + """ + def __init__(self, exception_type, message): + self.type = exception_type + self.message = message + + def __str__(self): + return "%s: %s" % (self.type, self.message) From 86df7d9734cf86d70ddf5e300a90a01417d229d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Sat, 17 Dec 2011 19:47:08 +0200 Subject: [PATCH 04/46] Name it rather OpenLyricsError --- openlp/plugins/songs/lib/openlyricsimport.py | 4 ++-- openlp/plugins/songs/lib/xml.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 37ff2ed98..c13b89de8 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -38,7 +38,7 @@ from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib import OpenLyrics -from openlp.plugins.songs.lib.xml import OpenLyricsException +from openlp.plugins.songs.lib.xml import OpenLyricsError log = logging.getLogger(__name__) @@ -74,7 +74,7 @@ class OpenLyricsImport(SongImport): except etree.XMLSyntaxError: log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) - except OpenLyricsException as exception: + except OpenLyricsError as exception: log.exception(u'OpenLyricsException of type %s: %s in file %s' % (exception.type, exception.message, file_path)) if exception.type is 'XML': diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index df545bee1..af1e6689e 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,11 +676,11 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsException('XML', 'missing lyrics item') + raise OpenLyricsError('XML', 'missing lyrics item') try: verses = lyrics.verse except AttributeError: - raise OpenLyricsException('XML', 'missing verse item') + raise OpenLyricsError('XML', 'missing verse item') # Loop over the "verse" elements. for verse in verses: text = u'' @@ -800,7 +800,7 @@ class OpenLyrics(object): xml_declaration=True, pretty_print=True) -class OpenLyricsException(Exception): +class OpenLyricsError(Exception): """ By now raised only in case of missing lyrics or verse element in XML. """ From dca74bd1448cdc5676dd4e72307c317cd6eb7ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Sat, 17 Dec 2011 23:17:53 +0200 Subject: [PATCH 05/46] Style, no "is" to compare strings. --- openlp/plugins/songs/lib/openlyricsimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index c13b89de8..cc4759d50 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -77,7 +77,7 @@ class OpenLyricsImport(SongImport): except OpenLyricsError as exception: log.exception(u'OpenLyricsException of type %s: %s in file %s' % (exception.type, exception.message, file_path)) - if exception.type is 'XML': + if exception.type == 'XML': self.logError(file_path, SongStrings.XMLSyntaxError) else: self.logError(file_path, exception.message) From d14a316309a9c9a809dcb6568c35eee342f1a5b5 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 16 Feb 2012 23:08:30 +0200 Subject: [PATCH 06/46] Added repeating of the background audio track list. Migrated the songs plugin configuration tab to use the proper camelCase names. --- openlp/core/ui/generaltab.py | 11 +++- openlp/core/ui/maindisplay.py | 12 +++- openlp/core/ui/slidecontroller.py | 30 ++++++++-- openlp/plugins/songs/lib/songstab.py | 90 ++++++++++++++-------------- 4 files changed, 91 insertions(+), 52 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index d515fc501..b1d44b3dd 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -175,6 +175,9 @@ class GeneralTab(SettingsTab): self.startPausedCheckBox = QtGui.QCheckBox(self.audioGroupBox) self.startPausedCheckBox.setObjectName(u'startPausedCheckBox') self.audioLayout.addWidget(self.startPausedCheckBox) + self.repeatListCheckBox = QtGui.QCheckBox(self.audioGroupBox) + self.repeatListCheckBox.setObjectName(u'repeatListCheckBox') + self.audioLayout.addWidget(self.repeatListCheckBox) self.rightLayout.addWidget(self.audioGroupBox) self.rightLayout.addStretch() # Signals and slots @@ -251,6 +254,8 @@ class GeneralTab(SettingsTab): translate('OpenLP.GeneralTab', 'Background Audio')) self.startPausedCheckBox.setText( translate('OpenLP.GeneralTab', 'Start background audio paused')) + self.repeatListCheckBox.setText( + translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ @@ -298,6 +303,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0]) self.startPausedCheckBox.setChecked(settings.value( u'audio start paused', QtCore.QVariant(True)).toBool()) + self.repeatListCheckBox.setChecked(settings.value( + u'audio repeat list', QtCore.QVariant(False)).toBool()) settings.endGroup() self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked()) @@ -350,7 +357,9 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.overrideCheckBox.isChecked())) settings.setValue(u'audio start paused', QtCore.QVariant(self.startPausedCheckBox.isChecked())) - settings.endGroup() + settings.setValue(u'audio repeat list', + QtCore.QVariant(self.repeatListCheckBox.isChecked())) + settings.endGroup() # On save update the screens as well self.postSetUp(True) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 971a9903f..f1a94138c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -493,11 +493,14 @@ class AudioPlayer(QtCore.QObject): QtCore.QObject.__init__(self, parent) self.currentIndex = -1 self.playlist = [] + self.repeat = False self.mediaObject = Phonon.MediaObject() self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self.audioObject) QtCore.QObject.connect(self.mediaObject, QtCore.SIGNAL(u'aboutToFinish()'), self.onAboutToFinish) + QtCore.QObject.connect(self.mediaObject, + QtCore.SIGNAL(u'finished()'), self.onFinished) def __del__(self): """ @@ -516,6 +519,14 @@ class AudioPlayer(QtCore.QObject): if len(self.playlist) > self.currentIndex: self.mediaObject.enqueue(self.playlist[self.currentIndex]) + def onFinished(self): + if self.repeat: + log.debug(u'Repeat is enabled... here we go again!') + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex = -1 + self.play() + def connectVolumeSlider(self, slider): slider.setAudioOutput(self.audioObject) @@ -562,4 +573,3 @@ class AudioPlayer(QtCore.QObject): filenames = [filenames] for filename in filenames: self.playlist.append(Phonon.MediaSource(filename)) - diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f0fc363b7..75ce23996 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -279,11 +279,26 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Go To'), self.toolbar)) self.toolbar.makeWidgetsInvisible([u'Song Menu']) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarButton( - u'Pause Audio', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Pause audio.'), - self.onAudioPauseClicked, True) + self.audioPauseItem = QtGui.QToolButton(self.toolbar) + self.audioPauseItem.setIcon(QtGui.QIcon(u':/slides/media_playback_pause.png')) + #u'Pause Audio', , + self.audioPauseItem.setText(translate('OpenLP.SlideController', + 'Pause audio.')) + self.audioPauseItem.setCheckable(True) + self.toolbar.addToolbarWidget(u'Pause Audio', self.audioPauseItem) + QtCore.QObject.connect(self.audioPauseItem, + QtCore.SIGNAL(u'clicked(bool)'), self.onAudioPauseClicked) self.audioPauseItem.setVisible(False) + audioMenu = QtGui.QMenu( + translate('OpenLP.SlideController', 'Background Audio'), + self.toolbar) + trackMenu = audioMenu.addMenu( + translate('OpenLP.SlideController', 'Tracks')) + trackMenu.addAction('first song') + trackMenu.addAction('second song') + trackMenu.addAction('third song') + self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup) + self.audioPauseItem.setMenu(audioMenu) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -715,7 +730,7 @@ class SlideController(Controller): Adjusts the value of the ``delaySpinBox`` to the given one. """ self.delaySpinBox.setValue(int(value)) - + def updateSlideLimits(self): """ Updates the Slide Limits variable from the settings. @@ -860,10 +875,15 @@ class SlideController(Controller): self.display.audioPlayer.reset() self.setAudioItemsVisibility(False) self.audioPauseItem.setChecked(False) + # If the current item has background audio if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio): log.debug(u'Starting to play...') self.display.audioPlayer.addToPlaylist( self.serviceItem.background_audio) + self.display.audioPlayer.repeat = QtCore.QSettings().value( + self.parent().generalSettingsSection + \ + u'/audio repeat list', + QtCore.QVariant(False)).toBool() if QtCore.QSettings().value( self.parent().generalSettingsSection + \ u'/audio start paused', diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index e662cee78..5da2a2a3c 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -33,56 +33,56 @@ class SongsTab(SettingsTab): """ SongsTab is the Songs settings tab in the settings dialog. """ - def __init__(self, parent, title, visible_title, icon_path): - SettingsTab.__init__(self, parent, title, visible_title, icon_path) - def setupUi(self): + """ + Set up the configuration tab UI. + """ self.setObjectName(u'SongsTab') SettingsTab.setupUi(self) - self.SongsModeGroupBox = QtGui.QGroupBox(self.leftColumn) - self.SongsModeGroupBox.setObjectName(u'SongsModeGroupBox') - self.SongsModeLayout = QtGui.QVBoxLayout(self.SongsModeGroupBox) - self.SongsModeLayout.setObjectName(u'SongsModeLayout') - self.SearchAsTypeCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) - self.SearchAsTypeCheckBox.setObjectName(u'SearchAsTypeCheckBox') - self.SongsModeLayout.addWidget(self.SearchAsTypeCheckBox) - self.SongBarActiveCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) - self.SongBarActiveCheckBox.setObjectName(u'SongBarActiveCheckBox') - self.SongsModeLayout.addWidget(self.SongBarActiveCheckBox) - self.SongUpdateOnEditCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) - self.SongUpdateOnEditCheckBox.setObjectName(u'SongUpdateOnEditCheckBox') - self.SongsModeLayout.addWidget(self.SongUpdateOnEditCheckBox) - self.SongAddFromServiceCheckBox = QtGui.QCheckBox( - self.SongsModeGroupBox) - self.SongAddFromServiceCheckBox.setObjectName( - u'SongAddFromServiceCheckBox') - self.SongsModeLayout.addWidget(self.SongAddFromServiceCheckBox) - self.leftLayout.addWidget(self.SongsModeGroupBox) + self.modeGroupBox = QtGui.QGroupBox(self.leftColumn) + self.modeGroupBox.setObjectName(u'modeGroupBox') + self.modeLayout = QtGui.QVBoxLayout(self.modeGroupBox) + self.modeLayout.setObjectName(u'modeLayout') + self.searchAsTypeCheckBox = QtGui.QCheckBox(self.modeGroupBox) + self.searchAsTypeCheckBox.setObjectName(u'SearchAsTypeCheckBox') + self.modeLayout.addWidget(self.searchAsTypeCheckBox) + self.toolBarActiveCheckBox = QtGui.QCheckBox(self.modeGroupBox) + self.toolBarActiveCheckBox.setObjectName(u'toolBarActiveCheckBox') + self.modeLayout.addWidget(self.toolBarActiveCheckBox) + self.updateOnEditCheckBox = QtGui.QCheckBox(self.modeGroupBox) + self.updateOnEditCheckBox.setObjectName(u'updateOnEditCheckBox') + self.modeLayout.addWidget(self.updateOnEditCheckBox) + self.addFromServiceCheckBox = QtGui.QCheckBox( + self.modeGroupBox) + self.addFromServiceCheckBox.setObjectName( + u'addFromServiceCheckBox') + self.modeLayout.addWidget(self.addFromServiceCheckBox) + self.leftLayout.addWidget(self.modeGroupBox) self.leftLayout.addStretch() self.rightLayout.addStretch() - QtCore.QObject.connect(self.SearchAsTypeCheckBox, + QtCore.QObject.connect(self.searchAsTypeCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onSearchAsTypeCheckBoxChanged) - QtCore.QObject.connect(self.SongBarActiveCheckBox, + QtCore.QObject.connect(self.toolBarActiveCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onSongBarActiveCheckBoxChanged) - QtCore.QObject.connect(self.SongUpdateOnEditCheckBox, + self.onToolBarActiveCheckBoxChanged) + QtCore.QObject.connect(self.updateOnEditCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onSongUpdateOnEditCheckBoxChanged) - QtCore.QObject.connect(self.SongAddFromServiceCheckBox, + self.onUpdateOnEditCheckBoxChanged) + QtCore.QObject.connect(self.addFromServiceCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onSongAddFromServiceCheckBoxChanged) + self.onAddFromServiceCheckBoxChanged) def retranslateUi(self): - self.SongsModeGroupBox.setTitle( + self.modeGroupBox.setTitle( translate('SongsPlugin.SongsTab', 'Songs Mode')) - self.SearchAsTypeCheckBox.setText( + self.searchAsTypeCheckBox.setText( translate('SongsPlugin.SongsTab', 'Enable search as you type')) - self.SongBarActiveCheckBox.setText(translate('SongsPlugin.SongsTab', + self.toolBarActiveCheckBox.setText(translate('SongsPlugin.SongsTab', 'Display verses on live tool bar')) - self.SongUpdateOnEditCheckBox.setText( + self.updateOnEditCheckBox.setText( translate('SongsPlugin.SongsTab', 'Update service from song edit')) - self.SongAddFromServiceCheckBox.setText( + self.addFromServiceCheckBox.setText( translate('SongsPlugin.SongsTab', 'Add missing songs when opening service')) @@ -92,19 +92,19 @@ class SongsTab(SettingsTab): if check_state == QtCore.Qt.Checked: self.song_search = True - def onSongBarActiveCheckBoxChanged(self, check_state): - self.song_bar = False + def onToolBarActiveCheckBoxChanged(self, check_state): + self.tool_bar = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: - self.song_bar = True + self.tool_bar = True - def onSongUpdateOnEditCheckBoxChanged(self, check_state): + def onUpdateOnEditCheckBoxChanged(self, check_state): self.update_edit = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: self.update_edit = True - def onSongAddFromServiceCheckBoxChanged(self, check_state): + def onAddFromServiceCheckBoxChanged(self, check_state): self.update_load = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: @@ -115,23 +115,23 @@ class SongsTab(SettingsTab): settings.beginGroup(self.settingsSection) self.song_search = settings.value( u'search as type', QtCore.QVariant(False)).toBool() - self.song_bar = settings.value( + self.tool_bar = settings.value( u'display songbar', QtCore.QVariant(True)).toBool() self.update_edit = settings.value( u'update service on edit', QtCore.QVariant(False)).toBool() self.update_load = settings.value( u'add song from service', QtCore.QVariant(True)).toBool() - self.SearchAsTypeCheckBox.setChecked(self.song_search) - self.SongBarActiveCheckBox.setChecked(self.song_bar) - self.SongUpdateOnEditCheckBox.setChecked(self.update_edit) - self.SongAddFromServiceCheckBox.setChecked(self.update_load) + self.searchAsTypeCheckBox.setChecked(self.song_search) + self.toolBarActiveCheckBox.setChecked(self.tool_bar) + self.updateOnEditCheckBox.setChecked(self.update_edit) + self.addFromServiceCheckBox.setChecked(self.update_load) settings.endGroup() def save(self): settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) - settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) + settings.setValue(u'display songbar', QtCore.QVariant(self.tool_bar)) settings.setValue(u'update service on edit', QtCore.QVariant(self.update_edit)) settings.setValue(u'add song from service', From 8fa7dcf0807ae974d7938ba02d8c35e43fda7c55 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 25 Feb 2012 01:26:10 +0200 Subject: [PATCH 07/46] Add the last two remaining outstanding items, the "next track" and the time remaining. Fixes: https://launchpad.net/bugs/845692 --- openlp/core/lib/ui.py | 1 + openlp/core/ui/maindisplay.py | 22 +++++++++++++--- openlp/core/ui/slidecontroller.py | 44 ++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 72bdd8b0c..2922200e3 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -93,6 +93,7 @@ class UiStrings(object): self.New = translate('OpenLP.Ui', 'New') self.NewService = translate('OpenLP.Ui', 'New Service') self.NewTheme = translate('OpenLP.Ui', 'New Theme') + self.NextTrack = translate('OpenLP.Ui', 'Next Track') self.NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular') self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f1a94138c..684382e21 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -30,7 +30,6 @@ and play multimedia within OpenLP. """ import cgi import logging -import os import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL @@ -136,12 +135,12 @@ class MainDisplay(Display): QtCore.Qt.WindowStaysOnTopHint if QtCore.QSettings().value(u'advanced/x11 bypass wm', QtCore.QVariant(True)).toBool(): - windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint + windowFlags |= QtCore.Qt.X11BypassWindowManagerHint # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen # stay always on top on Mac OS X. For details see bug 906926. # It needs more investigation to fix it properly. if sys.platform == 'darwin': - windowFlags = windowFlags | QtCore.Qt.SplashScreen + windowFlags |= QtCore.Qt.SplashScreen self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setTransparency(True) @@ -495,6 +494,7 @@ class AudioPlayer(QtCore.QObject): self.playlist = [] self.repeat = False self.mediaObject = Phonon.MediaObject() + self.mediaObject.setTickInterval(100) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self.audioObject) QtCore.QObject.connect(self.mediaObject, @@ -573,3 +573,19 @@ class AudioPlayer(QtCore.QObject): filenames = [filenames] for filename in filenames: self.playlist.append(Phonon.MediaSource(filename)) + + def next(self): + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex += 1 + if len(self.playlist) <= self.currentIndex: + if self.repeat: + self.currentIndex = 0 + else: + self.currentIndex = -1 + if self.currentIndex >= 0: + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + self.mediaObject.play() + + def connectSlot(self, signal, slot): + QtCore.QObject.connect(self.mediaObject, signal, slot) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 75ce23996..d8f6bd1a9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -33,7 +33,7 @@ from collections import deque from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ - translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem + translate, build_icon, build_html, PluginManager, ServiceItem from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.lib import SlideLimits, ServiceItemAction from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList @@ -277,10 +277,10 @@ class SlideController(Controller): self.toolbar.addToolbarWidget(u'Song Menu', self.songMenu) self.songMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Go To'), self.toolbar)) - self.toolbar.makeWidgetsInvisible([u'Song Menu']) # Stuff for items with background audio. self.audioPauseItem = QtGui.QToolButton(self.toolbar) - self.audioPauseItem.setIcon(QtGui.QIcon(u':/slides/media_playback_pause.png')) + self.audioPauseItem.setIcon( + QtGui.QIcon(u':/slides/media_playback_pause.png')) #u'Pause Audio', , self.audioPauseItem.setText(translate('OpenLP.SlideController', 'Pause audio.')) @@ -289,16 +289,27 @@ class SlideController(Controller): QtCore.QObject.connect(self.audioPauseItem, QtCore.SIGNAL(u'clicked(bool)'), self.onAudioPauseClicked) self.audioPauseItem.setVisible(False) - audioMenu = QtGui.QMenu( + self.audioMenu = QtGui.QMenu( translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) - trackMenu = audioMenu.addMenu( + self.nextTrackItem = shortcut_action(self.audioMenu, + 'nextTrackItem', [], self.onNextTrackClicked, None, None, + unicode(UiStrings().LiveToolbar)) + self.nextTrackItem.setText(translate('OpenLP.SlideController', 'Next Track')) + self.audioMenu.addAction(self.nextTrackItem) + self.trackMenu = self.audioMenu.addMenu( translate('OpenLP.SlideController', 'Tracks')) - trackMenu.addAction('first song') - trackMenu.addAction('second song') - trackMenu.addAction('third song') + self.trackMenu.addAction('first song') + self.trackMenu.addAction('second song') + self.trackMenu.addAction('third song') self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup) - self.audioPauseItem.setMenu(audioMenu) + self.audioPauseItem.setMenu(self.audioMenu) + self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) + self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) + self.audioTimeLabel.setStyleSheet(u'background-color: palette(background); border-top-color: palette(shadow); border-left-color: palette(shadow); border-bottom-color: palette(light); border-right-color: palette(light); border-radius: 3px; border-style: inset; border-width: 1; font-family: monospace; margin: 2px;') + self.audioTimeLabel.setObjectName(u'audioTimeLabel') + self.toolbar.addToolbarWidget(u'Time Remaining', self.audioTimeLabel) + self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -657,6 +668,7 @@ class SlideController(Controller): self.display.setup() if self.isLive: self.__addActionsToWidget(self.display) + self.display.audioPlayer.connectSlot(QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining) # The SlidePreview's ratio. try: self.ratio = float(self.screens.current[u'size'].width()) / \ @@ -1333,7 +1345,10 @@ class SlideController(Controller): self.onToggleLoop() def setAudioItemsVisibility(self, visible): - self.audioPauseItem.setVisible(visible) + if visible: + self.toolbar.makeWidgetsVisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) + else: + self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) def onAudioPauseClicked(self, checked): if not self.audioPauseItem.isVisible(): @@ -1444,3 +1459,12 @@ class SlideController(Controller): return HideMode.Screen else: return None + + def onNextTrackClicked(self): + self.display.audioPlayer.next() + + def onAudioTimeRemaining(self, time): + seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 + minutes = seconds // 60 + seconds = seconds % 60 + self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) From d681afb2b4b2838d56619e689163b04b1255a0ed Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 25 Feb 2012 02:01:24 +0200 Subject: [PATCH 08/46] Added an icon in for the Next button, and added in direct-to-track skipping too. Fixes: https://launchpad.net/bugs/845692 --- openlp/core/ui/maindisplay.py | 19 +++++++- openlp/core/ui/slidecontroller.py | 58 ++++++++++++++++------- resources/images/media_playback_next.png | Bin 0 -> 506 bytes resources/images/openlp-2.qrc | 1 + 4 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 resources/images/media_playback_next.png diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 684382e21..fb45ecff0 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -575,6 +575,7 @@ class AudioPlayer(QtCore.QObject): self.playlist.append(Phonon.MediaSource(filename)) def next(self): + isPlaying = self.mediaObject.state() == Phonon.PlayingState self.mediaObject.clearQueue() self.mediaObject.clear() self.currentIndex += 1 @@ -585,7 +586,23 @@ class AudioPlayer(QtCore.QObject): self.currentIndex = -1 if self.currentIndex >= 0: self.mediaObject.enqueue(self.playlist[self.currentIndex]) - self.mediaObject.play() + if isPlaying: + self.mediaObject.play() + + def goTo(self, index): + isPlaying = self.mediaObject.state() == Phonon.PlayingState + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex = index + if len(self.playlist) <= self.currentIndex: + if self.repeat: + self.currentIndex = 0 + else: + self.currentIndex = -1 + if self.currentIndex >= 0: + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + if isPlaying: + self.mediaObject.play() def connectSlot(self, signal, slot): QtCore.QObject.connect(self.mediaObject, signal, slot) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d8f6bd1a9..ade6b4bc4 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -46,9 +46,10 @@ class SlideList(QtGui.QTableWidget): Customised version of QTableWidget which can respond to keyboard events. """ - def __init__(self, parent=None, name=None): + def __init__(self, parent=None): QtGui.QTableWidget.__init__(self, parent.controller) + class Controller(QtGui.QWidget): """ Controller is a general controller widget. @@ -293,23 +294,33 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) self.nextTrackItem = shortcut_action(self.audioMenu, - 'nextTrackItem', [], self.onNextTrackClicked, None, None, - unicode(UiStrings().LiveToolbar)) - self.nextTrackItem.setText(translate('OpenLP.SlideController', 'Next Track')) + u'nextTrackItem', [], self.onNextTrackClicked, + u':/slides/media_playback_next.png', + category=unicode(UiStrings().LiveToolbar)) + self.nextTrackItem.setText( + translate('OpenLP.SlideController', 'Next Track')) self.audioMenu.addAction(self.nextTrackItem) self.trackMenu = self.audioMenu.addMenu( translate('OpenLP.SlideController', 'Tracks')) - self.trackMenu.addAction('first song') - self.trackMenu.addAction('second song') - self.trackMenu.addAction('third song') self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup) self.audioPauseItem.setMenu(self.audioMenu) self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) - self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) - self.audioTimeLabel.setStyleSheet(u'background-color: palette(background); border-top-color: palette(shadow); border-left-color: palette(shadow); border-bottom-color: palette(light); border-right-color: palette(light); border-radius: 3px; border-style: inset; border-width: 1; font-family: monospace; margin: 2px;') + self.audioTimeLabel.setAlignment( + QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) + self.audioTimeLabel.setStyleSheet( + u'background-color: palette(background); ' + u'border-top-color: palette(shadow); ' + u'border-left-color: palette(shadow); ' + u'border-bottom-color: palette(light); ' + u'border-right-color: palette(light); ' + u'border-radius: 3px; border-style: inset; ' + u'border-width: 1; font-family: monospace; margin: 2px;' + ) self.audioTimeLabel.setObjectName(u'audioTimeLabel') - self.toolbar.addToolbarWidget(u'Time Remaining', self.audioTimeLabel) - self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) + self.toolbar.addToolbarWidget( + u'Time Remaining', self.audioTimeLabel) + self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', + u'Time Remaining']) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -570,7 +581,7 @@ class SlideController(Controller): # Reset the shortcut. self.current_shortcut = u'' - def setPreviewHotkeys(self, parent=None): + def setPreviewHotkeys(self): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() @@ -647,7 +658,7 @@ class SlideController(Controller): self.keypress_loop = True keypressCommand = self.keypress_queue.popleft() if keypressCommand == ServiceItemAction.Previous: - Receiver.send_message('servicemanager_previous_item', None) + Receiver.send_message('servicemanager_previous_item') elif keypressCommand == ServiceItemAction.PreviousLastSlide: # Go to the last slide of the previous item Receiver.send_message('servicemanager_previous_item', u'last slide') @@ -680,7 +691,7 @@ class SlideController(Controller): self.previewDisplay.setup() serviceItem = ServiceItem() self.previewDisplay.webView.setHtml(build_html(serviceItem, - self.previewDisplay.screen, None, self.isLive, None, + self.previewDisplay.screen, None, self.isLive, plugins=PluginManager.get_instance().plugins)) self.mediaController.setup_display(self.previewDisplay) if self.serviceItem: @@ -892,6 +903,14 @@ class SlideController(Controller): log.debug(u'Starting to play...') self.display.audioPlayer.addToPlaylist( self.serviceItem.background_audio) + self.trackMenu.clear() + for counter in range(len(self.serviceItem.background_audio)): + action = self.trackMenu.addAction(os.path.basename( + self.serviceItem.background_audio[counter])) + action.setData(counter) + QtCore.QObject.connect(action, + QtCore.SIGNAL(u'triggered(bool)'), + self.onTrackTriggered) self.display.audioPlayer.repeat = QtCore.QSettings().value( self.parent().generalSettingsSection + \ u'/audio repeat list', @@ -947,7 +966,7 @@ class SlideController(Controller): self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) - if slideHeight != 0: + if not slideHeight: self.previewListWidget.setRowHeight(framenumber, slideHeight) self.previewListWidget.setVerticalHeaderLabels(text) if self.serviceItem.is_text(): @@ -1149,7 +1168,7 @@ class SlideController(Controller): else: Receiver.send_message(u'live_display_show') - def onSlideSelected(self, start=False): + def onSlideSelected(self): """ Slide selected in controller """ @@ -1466,5 +1485,10 @@ class SlideController(Controller): def onAudioTimeRemaining(self, time): seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 minutes = seconds // 60 - seconds = seconds % 60 + seconds %= 60 self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) + + def onTrackTriggered(self): + action = self.sender() + index = action.data().toInt()[0] + self.display.audioPlayer.goTo(index) diff --git a/resources/images/media_playback_next.png b/resources/images/media_playback_next.png new file mode 100644 index 0000000000000000000000000000000000000000..0d22924eef18d1f675d39e9c1468682f47365f5a GIT binary patch literal 506 zcmVMzCV_|S* zE^l&Yo9;Xs0004bNklPHu8N*UY6P4s` zVoj6z5W7`$3L^Rz8)eWJ2x3qkLcDl+8P$3TJFJagzh4L;#9`?m%etMslV{z7?64$+ z5Ftb-*-P8QrY#*ETbkO#y|j}E5n?B4_clFpr0<&(Ume-DsomR2M2J?p?zu0%8~E!& z;fGVttZStr($dDT<=A__{4+5zHc~jVWn-9@Vl7+p(NAx^atzp1SLj=^wjayg6`vJe z+V#*I7g#ZEabo4 zQA=k%b*3;fHZe9*cx_fK6(Q!6T5raxzHqLoy+I)a<`IIOF{_oABo&%w-$tV_5c6?07*qoM6N<$g1p4kZvX%Q literal 0 HcmV?d00001 diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index dc444d445..1b833a4db 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -68,6 +68,7 @@ media_playback_start.png media_playback_stop.png media_playback_pause.png + media_playback_next.png openlp-logo-16x16.png From 476ba8eb1b6298791e74e2be1cc85068e3916e6e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 25 Feb 2012 13:11:59 +0200 Subject: [PATCH 09/46] Fixed the copyright in the patch file which someone else missed. Regenerated the resource file. Fixed the copyright in the translation_utils.py script which someone else missed. Removed an unnecessary comment. --- openlp/core/ui/slidecontroller.py | 1 - scripts/resources.patch | 12 ++++++------ scripts/translation_utils.py | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 23f9ffc3c..04cb2b4a3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -282,7 +282,6 @@ class SlideController(Controller): self.audioPauseItem = QtGui.QToolButton(self.toolbar) self.audioPauseItem.setIcon( QtGui.QIcon(u':/slides/media_playback_pause.png')) - #u'Pause Audio', , self.audioPauseItem.setText(translate('OpenLP.SlideController', 'Pause audio.')) self.audioPauseItem.setCheckable(True) diff --git a/scripts/resources.patch b/scripts/resources.patch index 3697a705a..8fa2edbe1 100644 --- a/scripts/resources.patch +++ b/scripts/resources.patch @@ -12,12 +12,12 @@ +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # -+# Copyright (c) 2008-2011 Raoul Snyman # -+# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -+# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # -+# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -+# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode # -+# Woldsund # ++# Copyright (c) 2008-2012 Raoul Snyman # ++# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # ++# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # ++# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # ++# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # ++# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index 812258fe2..b60d7d425 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -5,12 +5,12 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode # -# Woldsund # +# Copyright (c) 2008-2012 Raoul Snyman # +# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # +# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # +# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # From ef4b69c50f29e869fee3a7ac9a6994df504c2883 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 25 Feb 2012 15:39:12 +0200 Subject: [PATCH 10/46] Fixed some long lines. --- openlp/core/ui/slidecontroller.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 04cb2b4a3..f7be9a191 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -678,7 +678,8 @@ class SlideController(Controller): self.display.setup() if self.isLive: self.__addActionsToWidget(self.display) - self.display.audioPlayer.connectSlot(QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining) + self.display.audioPlayer.connectSlot( + QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining) # The SlidePreview's ratio. try: self.ratio = float(self.screens.current[u'size'].width()) / \ @@ -1364,9 +1365,11 @@ class SlideController(Controller): def setAudioItemsVisibility(self, visible): if visible: - self.toolbar.makeWidgetsVisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) + self.toolbar.makeWidgetsVisible( + [u'Song Menu', u'Pause Audio', u'Time Remaining']) else: - self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining']) + self.toolbar.makeWidgetsInvisible( + [u'Song Menu', u'Pause Audio', u'Time Remaining']) def onAudioPauseClicked(self, checked): if not self.audioPauseItem.isVisible(): From ee3da316828a4aefad2f12e1119014d0814778c2 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 26 Feb 2012 16:15:00 +0100 Subject: [PATCH 11/46] Check for Qt version before calling QtCore.QLocale().createSeparatedList --- openlp/core/lib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d1e3b5308..4403ac8ec 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -328,7 +328,7 @@ def create_separated_list(stringlist): ``stringlist`` List of unicode strings """ - if Qt.PYQT_VERSION_STR >= u'4.9': + if Qt.PYQT_VERSION_STR >= u'4.9' and Qt.qVersion() >= u'4.8': return unicode(QtCore.QLocale().createSeparatedList(stringlist)) if not stringlist: return u'' From 44a57843151d1a8e975bc7b76258240b4f36a5a5 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 26 Feb 2012 21:43:59 +0100 Subject: [PATCH 12/46] Merge all QAction creation methods in openlp.core.lib.ui --- openlp/core/lib/ui.py | 155 +++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 72bdd8b0c..685701d42 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -280,102 +280,105 @@ def create_up_down_push_button_set(parent): QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) return up_button, down_button -def base_action(parent, name, category=None): +def create_action(parent, name, text=u'', icon=None, tooltip=u'', statustip=u'', + checked=None, enabled=True, visible=True, shortcuts=None, + context=QtCore.Qt.WindowShortcut, category=None, trigger=None): """ - Return the most basic action with the object name set. + Return an action with the object name set and the given parameters. + Parameters with default values are not set in case they stay unchanged. + + ``parent`` + A QtCore.QObject or ``None`` for the actions parent. + + ``name`` + A string which is set as object name. + + ``text`` + A string for the action text. + + ``icon`` + Either a QIcon, a resource string, or a file location string for the + action icon. + + ``tooltip`` + A string for the action tool tip. + + ``statustip`` + A string for the action status tip. + + ``checked`` + Either ``None`` for a not checkable action or bool for the state. + + ``enabled`` + False in case the action should be disabled. + + ``visible`` + False in case the action should be hidden. + + ``shortcuts`` + A QList (or a list of strings) which are set as shortcuts. + + ``context`` + A context for the shortcut execution (only will be set if ``shortcuts`` + is not None) ``category`` The category the action should be listed in the shortcut dialog. If you not wish, that this action is added to the shortcut dialog, then do not state any. + + ``trigger`` + A slot which is connected to the actions ``triggered()`` slot. """ action = QtGui.QAction(parent) action.setObjectName(name) - if category is not None: - action_list = ActionList.get_instance() - action_list.add_action(action, category) - return action - -def checkable_action(parent, name, checked=None, category=None): - """ - Return a standard action with the checkable attribute set. - """ - action = base_action(parent, name, category) - action.setCheckable(True) - if checked is not None: - action.setChecked(checked) - return action - -def icon_action(parent, name, icon, checked=None, category=None): - """ - Return a standard action with an icon. - """ - if checked is not None: - action = checkable_action(parent, name, checked, category) - else: - action = base_action(parent, name, category) - action.setIcon(build_icon(icon)) - return action - -def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, - category=None, context=QtCore.Qt.WindowShortcut): - """ - Return a shortcut enabled action. - """ - action = QtGui.QAction(parent) - action.setObjectName(name) + if text: + action.setText(text) if icon is not None: action.setIcon(build_icon(icon)) + if tooltip: + action.setToolTip(tooltip) + if statustip: + action.setStatusTip(statustip) if checked is not None: action.setCheckable(True) action.setChecked(checked) - if shortcuts: - action.setShortcuts(shortcuts) - action.setShortcutContext(context) - action_list = ActionList.get_instance() - action_list.add_action(action, category) - QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), function) - return action - -def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, - context=QtCore.Qt.WidgetShortcut): - """ - Utility method to help build context menus. - - ``base`` - The parent menu to add this menu item to - - ``icon`` - An icon for this action - - ``text`` - The text to display for this action - - ``slot`` - The code to run when this action is triggered - - ``shortcuts`` - The action's shortcuts. - - ``category`` - The category the shortcut should be listed in the shortcut dialog. If - left to ``None``, then the action will be hidden in the shortcut dialog. - - ``context`` - The context the shortcut is valid. - """ - action = QtGui.QAction(text, base) - if icon: - action.setIcon(build_icon(icon)) - QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), slot) + if not enabled: + action.setEnabled(enabled) + if not visible: + action.setVisible(visible) if shortcuts is not None: action.setShortcuts(shortcuts) action.setShortcutContext(context) + if category is not None: action_list = ActionList.get_instance() - action_list.add_action(action) - base.addAction(action) + action_list.add_action(action, category) + if trigger is not None: + QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), + trigger) return action +def base_action(parent, name, category=None): + return create_action(parent, name, category=category) + +def checkable_action(parent, name, checked=None, category=None): + return create_action(parent, name, checked=bool(checked), category=category) + +def icon_action(parent, name, icon, checked=None, category=None): + return create_action(parent, name, icon=icon, checked=checked, + category=category) + +def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, + category=None, context=QtCore.Qt.WindowShortcut): + return create_action(parent, name, icon=icon, checked=checked, + shortcuts=shortcuts, context=context, category=category, + trigger=function) + +def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, + context=QtCore.Qt.WidgetShortcut): + return create_action(parent=base, name=u'', icon=icon, text=text, + trigger=slot, shortcuts=shortcuts, category=category, context=context) + def context_menu(base, icon, text): """ Utility method to help build context menus. From 3a6a402b567e7885a9bbf3d3da4358b0a2d402ef Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 26 Feb 2012 22:09:22 +0100 Subject: [PATCH 13/46] use Python methods instead of Qt --- openlp/core/ui/exceptionform.py | 2 +- openlp/core/ui/mainwindow.py | 6 +++--- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index d2469c092..0dde063c4 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -150,7 +150,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): translate('OpenLP.ExceptionForm', 'Text files (*.txt *.log *.text)')) if filename: - filename = unicode(QtCore.QDir.toNativeSeparators(filename)) + filename = unicode(filename).replace(u'/', os.path.sep) SettingsManager.set_last_dir(self.settingsSection, os.path.dirname( filename)) report_text = report_text % self._createReport() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 947c1318d..6b3cf81fb 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1378,14 +1378,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): recentFileCount = QtCore.QSettings().value( u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0] existingRecentFiles = [recentFile for recentFile in self.recentFiles - if QtCore.QFile.exists(recentFile)] + if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] self.recentFilesMenu.clear() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) action = base_action(self, u'') - action.setText(u'&%d %s' % - (fileId + 1, QtCore.QFileInfo(filename).fileName())) + action.setText(u'&%d %s' % (fileId + 1, + os.path.splitext(os.path.basename(unicode(filename)))[0])) action.setData(QtCore.QVariant(filename)) self.connect(action, QtCore.SIGNAL(u'triggered()'), self.serviceManagerContents.onRecentServiceClicked) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2217dc168..84083af13 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -683,7 +683,7 @@ class ServiceManager(QtGui.QWidget): 'File is not a valid service.\n' 'The content encoding is not UTF-8.')) continue - osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) + osfile = ucsfile.replace(u'/', os.path.sep) if not osfile.startswith(u'audio'): osfile = os.path.split(osfile)[1] log.debug(u'Extract file: %s', osfile) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 3585e5c97..8b2524845 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -544,7 +544,7 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme file contains non utf-8 filename' u' "%s"' % name.decode(u'utf-8', u'replace')) raise Exception(u'validation') - uname = unicode(QtCore.QDir.toNativeSeparators(uname)) + uname = uname.replace(u'/', os.path.sep) splitname = uname.split(os.path.sep) if splitname[-1] == u'' or len(splitname) == 1: # is directory or preview file From 2592d6f698cbddffcfe84b7b73f358b8041123cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 26 Feb 2012 22:27:05 +0100 Subject: [PATCH 14/46] add possibility to search for songbook and songnumber --- openlp/plugins/songs/lib/mediaitem.py | 39 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ab95d794f..62a48521c 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -43,7 +43,7 @@ from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \ clean_string -from openlp.plugins.songs.lib.db import Author, Song, MediaFile +from openlp.plugins.songs.lib.db import Author, Song, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) @@ -56,7 +56,8 @@ class SongSearch(object): Titles = 2 Lyrics = 3 Authors = 4 - Themes = 5 + Books = 5 + Themes = 6 class SongMediaItem(MediaManagerItem): @@ -158,6 +159,8 @@ class SongMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Lyrics')), (SongSearch.Authors, u':/songs/song_search_author.png', SongStrings.Authors), + (SongSearch.Books, u':/songs/song_book_edit.png', + SongStrings.SongBooks), (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes) ]) self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( @@ -196,6 +199,19 @@ class SongMediaItem(MediaManagerItem): Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc()) self.displayResultsAuthor(search_results) + elif search_type == SongSearch.Books: + log.debug(u'Books Search') + search_results = self.plugin.manager.get_all_objects(Book, + Book.name.like(u'%' + search_keywords + u'%'), + Book.name.asc()) + song_number = False + if not search_results: + search_keywords = search_keywords.rpartition(' ') + search_results = self.plugin.manager.get_all_objects(Book, + Book.name.like(u'%' + search_keywords[0] + u'%'), + Book.name.asc()) + song_number = re.sub(r'[^0-9]', u'', search_keywords[2]) + self.displayResultsBook(search_results, song_number) elif search_type == SongSearch.Themes: log.debug(u'Theme Search') search_results = self.plugin.manager.get_all_objects(Song, @@ -270,6 +286,25 @@ class SongMediaItem(MediaManagerItem): song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) self.listView.addItem(song_name) + def displayResultsBook(self, searchresults, song_number=False): + log.debug(u'display results Book') + self.listView.clear() + for book in searchresults: + songs = sorted(book.songs, key=lambda song: int( + re.sub(r'[^0-9]', u' ', song.song_number).partition(' ')[0]) + if len(re.sub(r'[^\w]', ' ', song.song_number)) else 0) + for song in songs: + # Do not display temporary songs + if song.temporary: + continue + if song_number and not song_number in song.song_number: + continue + song_detail = u'%s - %s (%s)' % (book.name, song.song_number, + song.title) + song_name = QtGui.QListWidgetItem(song_detail) + song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) + self.listView.addItem(song_name) + def onClearTextButtonClick(self): """ Clear the search text. From b56d8d2a061aa52511cab2763c64230b42fc65e6 Mon Sep 17 00:00:00 2001 From: Rastislav Pecik Date: Mon, 27 Feb 2012 01:42:35 +0100 Subject: [PATCH 15/46] Fixed connection to mysql to use UTF8 encoding. Fixes: https://launchpad.net/bugs/941692 --- openlp/core/lib/db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index d7ca10f0f..30b41a6b5 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -193,6 +193,12 @@ class Manager(object): else: self.db_url = u'sqlite:///%s/%s.sqlite' % ( AppLocation.get_section_data_path(plugin_name), plugin_name) + elif db_type == u'mysql' : + self.db_url = u'%s://%s:%s@%s/%s?charset=utf8' % (db_type, + urlquote(unicode(settings.value(u'db username').toString())), + urlquote(unicode(settings.value(u'db password').toString())), + urlquote(unicode(settings.value(u'db hostname').toString())), + urlquote(unicode(settings.value(u'db database').toString()))) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, urlquote(unicode(settings.value(u'db username').toString())), From c024e9e47d989855418f3e20aa564fa1a6b1b889 Mon Sep 17 00:00:00 2001 From: Rastislav Pecik Date: Mon, 27 Feb 2012 19:18:52 +0100 Subject: [PATCH 16/46] Exported mysql charset settings to configuration files and cleaned up the code --- openlp/core/lib/db.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 30b41a6b5..36823b118 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -193,18 +193,18 @@ class Manager(object): else: self.db_url = u'sqlite:///%s/%s.sqlite' % ( AppLocation.get_section_data_path(plugin_name), plugin_name) - elif db_type == u'mysql' : - self.db_url = u'%s://%s:%s@%s/%s?charset=utf8' % (db_type, - urlquote(unicode(settings.value(u'db username').toString())), - urlquote(unicode(settings.value(u'db password').toString())), - urlquote(unicode(settings.value(u'db hostname').toString())), - urlquote(unicode(settings.value(u'db database').toString()))) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, urlquote(unicode(settings.value(u'db username').toString())), urlquote(unicode(settings.value(u'db password').toString())), urlquote(unicode(settings.value(u'db hostname').toString())), urlquote(unicode(settings.value(u'db database').toString()))) + if db_type == u'mysql': + db_encoding = unicode( + settings.value(u'db encoding').toString()) + if db_encoding == "": + db_encoding = u'utf8' + self.db_url += u'?charset=%s' % (urlquote(db_encoding)) settings.endGroup() if upgrade_mod: db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod) From d77534dc346c71a44ef9a6d5fc0fb57e13148382 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Mon, 27 Feb 2012 18:41:24 +0000 Subject: [PATCH 17/46] Fixes 439 on the support tracker --- openlp/core/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9fa5bcd77..67d624b6b 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -400,7 +400,7 @@ def clean_filename(filename): """ if not isinstance(filename, unicode): filename = unicode(filename, u'utf-8') - return re.sub(r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') + return re.sub(r'[/\\?*|<>\[\]":<>+%\n]+', u'_', filename).strip(u'_') def delete_file(file_path_name): """ From fe5f3c887491621dec4c98b4f83cddeee201a39f Mon Sep 17 00:00:00 2001 From: M2j Date: Mon, 27 Feb 2012 19:58:34 +0100 Subject: [PATCH 18/46] make use of **kwargs in action creation methods --- openlp/core/lib/ui.py | 88 +++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 685701d42..7cbacf030 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -280,18 +280,15 @@ def create_up_down_push_button_set(parent): QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) return up_button, down_button -def create_action(parent, name, text=u'', icon=None, tooltip=u'', statustip=u'', - checked=None, enabled=True, visible=True, shortcuts=None, - context=QtCore.Qt.WindowShortcut, category=None, trigger=None): +def create_action(parent, name, **kwargs): """ Return an action with the object name set and the given parameters. - Parameters with default values are not set in case they stay unchanged. ``parent`` - A QtCore.QObject or ``None`` for the actions parent. + A QtCore.QObject for the actions parent (required). ``name`` - A string which is set as object name. + A string which is set as object name (required). ``text`` A string for the action text. @@ -307,7 +304,7 @@ def create_action(parent, name, text=u'', icon=None, tooltip=u'', statustip=u'', A string for the action status tip. ``checked`` - Either ``None`` for a not checkable action or bool for the state. + A bool for the state. If ``None`` the Action is not checkable. ``enabled`` False in case the action should be disabled. @@ -319,65 +316,66 @@ def create_action(parent, name, text=u'', icon=None, tooltip=u'', statustip=u'', A QList (or a list of strings) which are set as shortcuts. ``context`` - A context for the shortcut execution (only will be set if ``shortcuts`` - is not None) + A context for the shortcut execution (only will be set together with + ``shortcuts``). ``category`` - The category the action should be listed in the shortcut dialog. If you - not wish, that this action is added to the shortcut dialog, then do not - state any. + A category the action should be listed in the shortcut dialog. - ``trigger`` - A slot which is connected to the actions ``triggered()`` slot. + ``triggers`` + A slot which is connected to the actions ``triggered()`` slot. """ action = QtGui.QAction(parent) action.setObjectName(name) - if text: - action.setText(text) - if icon is not None: - action.setIcon(build_icon(icon)) - if tooltip: - action.setToolTip(tooltip) - if statustip: - action.setStatusTip(statustip) - if checked is not None: + if kwargs.get(u'text'): + action.setText(kwargs[u'text']) + if kwargs.get(u'icon'): + action.setIcon(build_icon(kwargs[u'icon'])) + if kwargs.get('tooltip'): + action.setToolTip(kwargs['tooltip']) + if kwargs.get('statustip'): + action.setStatusTip(kwargs['statustip']) + if kwargs.get('checked') is not None: action.setCheckable(True) - action.setChecked(checked) - if not enabled: - action.setEnabled(enabled) - if not visible: - action.setVisible(visible) - if shortcuts is not None: - action.setShortcuts(shortcuts) - action.setShortcutContext(context) - if category is not None: + action.setChecked(kwargs['checked']) + if not kwargs.get('enabled'): + action.setEnabled(False) + if not kwargs.get('visible'): + action.setVisible(False) + if kwargs.get('shortcuts'): + action.setShortcuts(kwargs['shortcuts']) + action.setShortcutContext(kwargs.get('context', + QtCore.Qt.WindowShortcut)) + if kwargs.get('category'): action_list = ActionList.get_instance() - action_list.add_action(action, category) - if trigger is not None: + action_list.add_action(action, kwargs['category']) + if kwargs.get('triggers'): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), - trigger) + kwargs['triggers']) return action -def base_action(parent, name, category=None): - return create_action(parent, name, category=category) +def base_action(parent, name, category=None, **kwargs): + return create_action(parent, name, category=None, **kwargs) -def checkable_action(parent, name, checked=None, category=None): - return create_action(parent, name, checked=bool(checked), category=category) +def checkable_action(parent, name, checked=None, category=None, **kwargs): + return create_action(parent, name, checked=bool(checked), category=category, + **kwargs) -def icon_action(parent, name, icon, checked=None, category=None): +def icon_action(parent, name, icon, checked=None, category=None, **kwargs): return create_action(parent, name, icon=icon, checked=checked, - category=category) + category=category, **kwargs) def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, - category=None, context=QtCore.Qt.WindowShortcut): + category=None, context=QtCore.Qt.WindowShortcut, **kwargs): return create_action(parent, name, icon=icon, checked=checked, shortcuts=shortcuts, context=context, category=category, - trigger=function) + triggers=function, **kwargs) def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, - context=QtCore.Qt.WidgetShortcut): + context=QtCore.Qt.WidgetShortcut, **kwargs): return create_action(parent=base, name=u'', icon=icon, text=text, - trigger=slot, shortcuts=shortcuts, category=category, context=context) + triggers=slot, shortcuts=shortcuts, category=category, context=context, + **kwargs) def context_menu(base, icon, text): """ From 95c8f8fe5a3e54dd89ca910410e98cafee21aa9e Mon Sep 17 00:00:00 2001 From: M2j Date: Tue, 28 Feb 2012 00:44:35 +0100 Subject: [PATCH 19/46] removed base_action, checkable_action, icon_action, and shortcut_action --- openlp/core/lib/searchedit.py | 9 +- openlp/core/lib/spelltextedit.py | 7 +- openlp/core/lib/ui.py | 60 +++-- openlp/core/ui/mainwindow.py | 240 ++++++++++---------- openlp/core/ui/slidecontroller.py | 228 ++++++++++--------- openlp/plugins/alerts/alertsplugin.py | 16 +- openlp/plugins/bibles/bibleplugin.py | 17 +- openlp/plugins/songs/songsplugin.py | 42 ++-- openlp/plugins/songusage/songusageplugin.py | 38 ++-- 9 files changed, 323 insertions(+), 334 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index c212dcc24..5d117e3d1 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon -from openlp.core.lib.ui import icon_action +from openlp.core.lib.ui import create_action log = logging.getLogger(__name__) @@ -150,12 +150,9 @@ class SearchEdit(QtGui.QLineEdit): menu = QtGui.QMenu(self) first = None for identifier, icon, title in items: - action = icon_action(menu, u'', icon) - action.setText(title) - action.setData(QtCore.QVariant(identifier)) + action = create_action(menu, u'', text=title, icon=icon, + data=identifier, triggers=self._onMenuActionTriggered) menu.addAction(action) - QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), - self._onMenuActionTriggered) if first is None: first = action self._currentSearchType = identifier diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 38077a590..310c219b5 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -40,7 +40,7 @@ except ImportError: from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, FormattingTags -from openlp.core.lib.ui import checkable_action +from openlp.core.lib.ui import create_action log = logging.getLogger(__name__) @@ -90,9 +90,8 @@ class SpellTextEdit(QtGui.QPlainTextEdit): lang_menu = QtGui.QMenu( translate('OpenLP.SpellTextEdit', 'Language:')) for lang in enchant.list_languages(): - action = checkable_action( - lang_menu, lang, lang == self.dictionary.tag) - action.setText(lang) + action = create_action(lang_menu, lang, text=lang, + checked=lang == self.dictionary.tag) lang_menu.addAction(action) popupMenu.insertSeparator(popupMenu.actions()[0]) popupMenu.insertMenu(popupMenu.actions()[0], lang_menu) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 7cbacf030..58527b102 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -312,6 +312,9 @@ def create_action(parent, name, **kwargs): ``visible`` False in case the action should be hidden. + ``data`` + Data which is set as QVariant type. + ``shortcuts`` A QList (or a list of strings) which are set as shortcuts. @@ -328,49 +331,38 @@ def create_action(parent, name, **kwargs): action = QtGui.QAction(parent) action.setObjectName(name) if kwargs.get(u'text'): - action.setText(kwargs[u'text']) + action.setText(kwargs.pop(u'text')) if kwargs.get(u'icon'): - action.setIcon(build_icon(kwargs[u'icon'])) - if kwargs.get('tooltip'): - action.setToolTip(kwargs['tooltip']) - if kwargs.get('statustip'): - action.setStatusTip(kwargs['statustip']) - if kwargs.get('checked') is not None: + action.setIcon(build_icon(kwargs.pop(u'icon'))) + if kwargs.get(u'tooltip'): + action.setToolTip(kwargs.pop(u'tooltip')) + if kwargs.get(u'statustip'): + action.setStatusTip(kwargs.pop(u'statustip')) + if kwargs.get(u'checked') is not None: action.setCheckable(True) - action.setChecked(kwargs['checked']) - if not kwargs.get('enabled'): + action.setChecked(kwargs.pop(u'checked')) + if not kwargs.pop(u'enabled', True): action.setEnabled(False) - if not kwargs.get('visible'): + if not kwargs.pop(u'visible', True): action.setVisible(False) - if kwargs.get('shortcuts'): - action.setShortcuts(kwargs['shortcuts']) - action.setShortcutContext(kwargs.get('context', + if u'data' in kwargs: + action.setData(QtCore.QVariant(kwargs.pop(u'data'))) + if kwargs.get(u'shortcuts'): + action.setShortcuts(kwargs.pop(u'shortcuts')) + action.setShortcutContext(kwargs.pop(u'context', QtCore.Qt.WindowShortcut)) - if kwargs.get('category'): + if kwargs.get(u'category'): action_list = ActionList.get_instance() - action_list.add_action(action, kwargs['category']) - if kwargs.get('triggers'): + action_list.add_action(action, kwargs.pop(u'category')) + if kwargs.get(u'triggers'): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), - kwargs['triggers']) + kwargs.pop(u'triggers')) + for key in kwargs.keys(): + if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked', + u'shortcuts', u'context', u'category', u'triggers']: + log.warn(u'Parameter %s was not consumed in create_action().', key) return action -def base_action(parent, name, category=None, **kwargs): - return create_action(parent, name, category=None, **kwargs) - -def checkable_action(parent, name, checked=None, category=None, **kwargs): - return create_action(parent, name, checked=bool(checked), category=category, - **kwargs) - -def icon_action(parent, name, icon, checked=None, category=None, **kwargs): - return create_action(parent, name, icon=icon, checked=checked, - category=category, **kwargs) - -def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, - category=None, context=QtCore.Qt.WindowShortcut, **kwargs): - return create_action(parent, name, icon=icon, checked=checked, - shortcuts=shortcuts, context=context, category=category, - triggers=function, **kwargs) - def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, context=QtCore.Qt.WidgetShortcut, **kwargs): return create_action(parent=base, name=u'', icon=icon, text=text, diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6b3cf81fb..1f28beee5 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -36,8 +36,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \ PluginManager, Receiver, translate, ImageManager, PluginStatus -from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ - icon_action, shortcut_action +from openlp.core.lib.ui import UiStrings, create_action from openlp.core.lib import SlideLimits from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ @@ -179,75 +178,84 @@ class Ui_MainWindow(object): action_list = ActionList.get_instance() action_list.add_category(unicode(UiStrings().File), CategoryOrder.standardMenu) - self.fileNewItem = shortcut_action(mainWindow, u'fileNewItem', - [QtGui.QKeySequence(u'Ctrl+N')], - self.serviceManagerContents.onNewServiceClicked, - u':/general/general_new.png', category=unicode(UiStrings().File)) - self.fileOpenItem = shortcut_action(mainWindow, u'fileOpenItem', - [QtGui.QKeySequence(u'Ctrl+O')], - self.serviceManagerContents.onLoadServiceClicked, - u':/general/general_open.png', category=unicode(UiStrings().File)) - self.fileSaveItem = shortcut_action(mainWindow, u'fileSaveItem', - [QtGui.QKeySequence(u'Ctrl+S')], - self.serviceManagerContents.saveFile, - u':/general/general_save.png', category=unicode(UiStrings().File)) - self.fileSaveAsItem = shortcut_action(mainWindow, u'fileSaveAsItem', - [QtGui.QKeySequence(u'Ctrl+Shift+S')], - self.serviceManagerContents.saveFileAs, - category=unicode(UiStrings().File)) - self.printServiceOrderItem = shortcut_action(mainWindow, - u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], - self.serviceManagerContents.printServiceOrder, - category=unicode(UiStrings().File)) - self.fileExitItem = shortcut_action(mainWindow, u'fileExitItem', - [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, - u':/system/system_exit.png', category=unicode(UiStrings().File)) + self.fileNewItem = create_action(mainWindow, u'fileNewItem', + icon=u':/general/general_new.png', + shortcuts=[QtGui.QKeySequence(u'Ctrl+N')], + category=unicode(UiStrings().File), + triggers=self.serviceManagerContents.onNewServiceClicked) + self.fileOpenItem = create_action(mainWindow, u'fileOpenItem', + icon=u':/general/general_open.png', + shortcuts=[QtGui.QKeySequence(u'Ctrl+O')], + category=unicode(UiStrings().File), + triggers=self.serviceManagerContents.onLoadServiceClicked) + self.fileSaveItem = create_action(mainWindow, u'fileSaveItem', + icon=u':/general/general_save.png', + shortcuts=[QtGui.QKeySequence(u'Ctrl+S')], + category=unicode(UiStrings().File), + triggers=self.serviceManagerContents.saveFile) + self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem', + shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')], + category=unicode(UiStrings().File), + triggers=self.serviceManagerContents.saveFileAs) + self.printServiceOrderItem = create_action(mainWindow, + u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')], + category=unicode(UiStrings().File), + triggers=self.serviceManagerContents.printServiceOrder) + self.fileExitItem = create_action(mainWindow, u'fileExitItem', + icon=u':/system/system_exit.png', + shortcuts=[QtGui.QKeySequence(u'Alt+F4')], + category=unicode(UiStrings().File), + triggers=mainWindow.close) action_list.add_category(unicode(UiStrings().Import), CategoryOrder.standardMenu) - self.importThemeItem = base_action( - mainWindow, u'importThemeItem', unicode(UiStrings().Import)) - self.importLanguageItem = base_action( - mainWindow, u'importLanguageItem')#, unicode(UiStrings().Import)) + self.importThemeItem = create_action(mainWindow, + u'importThemeItem', category=unicode(UiStrings().Import)) + self.importLanguageItem = create_action(mainWindow, + u'importLanguageItem')#, category=unicode(UiStrings().Import)) action_list.add_category(unicode(UiStrings().Export), CategoryOrder.standardMenu) - self.exportThemeItem = base_action( - mainWindow, u'exportThemeItem', unicode(UiStrings().Export)) - self.exportLanguageItem = base_action( - mainWindow, u'exportLanguageItem')#, unicode(UiStrings().Export)) + self.exportThemeItem = create_action(mainWindow, + u'exportThemeItem', category=unicode(UiStrings().Export)) + self.exportLanguageItem = create_action(mainWindow, + u'exportLanguageItem')#, category=unicode(UiStrings().Export)) action_list.add_category(unicode(UiStrings().View), CategoryOrder.standardMenu) - self.viewMediaManagerItem = shortcut_action(mainWindow, - u'viewMediaManagerItem', [QtGui.QKeySequence(u'F8')], - self.toggleMediaManager, u':/system/system_mediamanager.png', - self.mediaManagerDock.isVisible(), unicode(UiStrings().View)) - self.viewThemeManagerItem = shortcut_action(mainWindow, - u'viewThemeManagerItem', [QtGui.QKeySequence(u'F10')], - self.toggleThemeManager, u':/system/system_thememanager.png', - self.themeManagerDock.isVisible(), unicode(UiStrings().View)) - self.viewServiceManagerItem = shortcut_action(mainWindow, - u'viewServiceManagerItem', [QtGui.QKeySequence(u'F9')], - self.toggleServiceManager, u':/system/system_servicemanager.png', - self.serviceManagerDock.isVisible(), unicode(UiStrings().View)) - self.viewPreviewPanel = shortcut_action(mainWindow, - u'viewPreviewPanel', [QtGui.QKeySequence(u'F11')], - self.setPreviewPanelVisibility, checked=previewVisible, - category=unicode(UiStrings().View)) - self.viewLivePanel = shortcut_action(mainWindow, u'viewLivePanel', - [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, - checked=liveVisible, category=unicode(UiStrings().View)) - self.lockPanel = shortcut_action(mainWindow, u'lockPanel', - None, self.setLockPanel, - checked=panelLocked, category=None) + self.viewMediaManagerItem = create_action(mainWindow, + u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], + icon=u':/system/system_mediamanager.png', + checked=self.mediaManagerDock.isVisible(), + category=unicode(UiStrings().View), + triggers=self.toggleMediaManager) + self.viewThemeManagerItem = create_action(mainWindow, + u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')], + icon=u':/system/system_thememanager.png', + checked=self.themeManagerDock.isVisible(), + category=unicode(UiStrings().View), + triggers=self.toggleThemeManager) + self.viewServiceManagerItem = create_action(mainWindow, + u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')], + icon=u':/system/system_servicemanager.png', + checked=self.serviceManagerDock.isVisible(), + category=unicode(UiStrings().View), + triggers=self.toggleServiceManager) + self.viewPreviewPanel = create_action(mainWindow, u'viewPreviewPanel', + shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible, + category=unicode(UiStrings().View), + triggers=self.setPreviewPanelVisibility) + self.viewLivePanel = create_action(mainWindow, u'viewLivePanel', + shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible, + category=unicode(UiStrings().View), + triggers=self.setLivePanelVisibility) + self.lockPanel = create_action(mainWindow, u'lockPanel', + checked=panelLocked, triggers=self.setLockPanel) action_list.add_category(unicode(UiStrings().ViewMode), CategoryOrder.standardMenu) - self.modeDefaultItem = checkable_action( - mainWindow, u'modeDefaultItem', - category=unicode(UiStrings().ViewMode)) - self.modeSetupItem = checkable_action( - mainWindow, u'modeSetupItem', - category=unicode(UiStrings().ViewMode)) - self.modeLiveItem = checkable_action( - mainWindow, u'modeLiveItem', True, unicode(UiStrings().ViewMode)) + self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', + checked=False, category=unicode(UiStrings().ViewMode)) + self.modeSetupItem = create_action(mainWindow, u'modeSetupItem', + checked=False, category=unicode(UiStrings().ViewMode)) + self.modeLiveItem = create_action(mainWindow, u'modeLiveItem', + checked=True, category=unicode(UiStrings().ViewMode)) self.modeGroup = QtGui.QActionGroup(mainWindow) self.modeGroup.addAction(self.modeDefaultItem) self.modeGroup.addAction(self.modeSetupItem) @@ -255,25 +263,28 @@ class Ui_MainWindow(object): self.modeDefaultItem.setChecked(True) action_list.add_category(unicode(UiStrings().Tools), CategoryOrder.standardMenu) - self.toolsAddToolItem = icon_action(mainWindow, u'toolsAddToolItem', - u':/tools/tools_add.png', category=unicode(UiStrings().Tools)) - self.toolsOpenDataFolder = icon_action(mainWindow, - u'toolsOpenDataFolder', u':/general/general_open.png', + self.toolsAddToolItem = create_action(mainWindow, + u'toolsAddToolItem', icon=u':/tools/tools_add.png', category=unicode(UiStrings().Tools)) - self.toolsFirstTimeWizard = icon_action(mainWindow, - u'toolsFirstTimeWizard', u':/general/general_revert.png', + self.toolsOpenDataFolder = create_action(mainWindow, + u'toolsOpenDataFolder', icon=u':/general/general_open.png', category=unicode(UiStrings().Tools)) - self.updateThemeImages = base_action(mainWindow, + self.toolsFirstTimeWizard = create_action(mainWindow, + u'toolsFirstTimeWizard', icon=u':/general/general_revert.png', + category=unicode(UiStrings().Tools)) + self.updateThemeImages = create_action(mainWindow, u'updateThemeImages', category=unicode(UiStrings().Tools)) action_list.add_category(unicode(UiStrings().Settings), CategoryOrder.standardMenu) - self.settingsPluginListItem = shortcut_action(mainWindow, - u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], - self.onPluginItemClicked, u':/system/settings_plugin_list.png', - category=unicode(UiStrings().Settings)) + self.settingsPluginListItem = create_action(mainWindow, + u'settingsPluginListItem', + icon=u':/system/settings_plugin_list.png', + shortcuts=[QtGui.QKeySequence(u'Alt+F7')], + category=unicode(UiStrings().Settings), + triggers=self.onPluginItemClicked) # i18n Language Items - self.autoLanguageItem = checkable_action(mainWindow, - u'autoLanguageItem', LanguageManager.auto_language) + self.autoLanguageItem = create_action(mainWindow, u'autoLanguageItem', + checked=LanguageManager.auto_language) self.languageGroup = QtGui.QActionGroup(mainWindow) self.languageGroup.setExclusive(True) self.languageGroup.setObjectName(u'languageGroup') @@ -281,44 +292,46 @@ class Ui_MainWindow(object): qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() for key in sorted(qmList.keys()): - languageItem = checkable_action( - mainWindow, key, qmList[key] == savedLanguage) + languageItem = create_action(mainWindow, key, + checked=qmList[key] == savedLanguage) add_actions(self.languageGroup, [languageItem]) - self.settingsShortcutsItem = icon_action(mainWindow, + self.settingsShortcutsItem = create_action(mainWindow, u'settingsShortcutsItem', - u':/system/system_configure_shortcuts.png', + icon=u':/system/system_configure_shortcuts.png', category=unicode(UiStrings().Settings)) # Formatting Tags were also known as display tags. - self.formattingTagItem = icon_action(mainWindow, - u'displayTagItem', u':/system/tag_editor.png', + self.formattingTagItem = create_action(mainWindow, + u'displayTagItem', icon=u':/system/tag_editor.png', category=unicode(UiStrings().Settings)) - self.settingsConfigureItem = icon_action(mainWindow, - u'settingsConfigureItem', u':/system/system_settings.png', + self.settingsConfigureItem = create_action(mainWindow, + u'settingsConfigureItem', icon=u':/system/system_settings.png', category=unicode(UiStrings().Settings)) - self.settingsImportItem = base_action(mainWindow, + self.settingsImportItem = create_action(mainWindow, u'settingsImportItem', category=unicode(UiStrings().Settings)) - self.settingsExportItem = base_action(mainWindow, + self.settingsExportItem = create_action(mainWindow, u'settingsExportItem', category=unicode(UiStrings().Settings)) action_list.add_category(unicode(UiStrings().Help), CategoryOrder.standardMenu) - self.aboutItem = shortcut_action(mainWindow, u'aboutItem', - [QtGui.QKeySequence(u'Ctrl+F1')], self.onAboutItemClicked, - u':/system/system_about.png', category=unicode(UiStrings().Help)) + self.aboutItem = create_action(mainWindow, u'aboutItem', + icon=u':/system/system_about.png', + shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')], + category=unicode(UiStrings().Help), + triggers=self.onAboutItemClicked) if os.name == u'nt': self.localHelpFile = os.path.join( AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') - self.offlineHelpItem = shortcut_action( - mainWindow, u'offlineHelpItem', [QtGui.QKeySequence(u'F1')], - self.onOfflineHelpClicked, - u':/system/system_help_contents.png', - category=unicode(UiStrings().Help)) - self.onlineHelpItem = shortcut_action( - mainWindow, u'onlineHelpItem', - [QtGui.QKeySequence(u'Alt+F1')], self.onOnlineHelpClicked, - u':/system/system_online_help.png', - category=unicode(UiStrings().Help)) - self.webSiteItem = base_action( - mainWindow, u'webSiteItem', category=unicode(UiStrings().Help)) + self.offlineHelpItem = create_action(mainWindow, u'offlineHelpItem', + icon=u':/system/system_help_contents.png', + shortcuts=[QtGui.QKeySequence(u'F1')], + category=unicode(UiStrings().Help), + triggers=self.onOfflineHelpClicked) + self.onlineHelpItem = create_action(mainWindow, u'onlineHelpItem', + icon=u':/system/system_online_help.png', + shortcuts=[QtGui.QKeySequence(u'Alt+F1')], + category=unicode(UiStrings().Help), + triggers=self.onOnlineHelpClicked) + self.webSiteItem = create_action(mainWindow, + u'webSiteItem', category=unicode(UiStrings().Help)) add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem)) add_actions(self.fileExportMenu, (self.settingsExportItem, None, @@ -1383,22 +1396,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.recentFilesMenu.clear() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) - action = base_action(self, u'') - action.setText(u'&%d %s' % (fileId + 1, - os.path.splitext(os.path.basename(unicode(filename)))[0])) - action.setData(QtCore.QVariant(filename)) - self.connect(action, QtCore.SIGNAL(u'triggered()'), - self.serviceManagerContents.onRecentServiceClicked) + action = create_action(self, u'', + text=u'&%d %s' % (fileId + 1, os.path.splitext(os.path.basename( + unicode(filename)))[0]), data=filename, + triggers=self.serviceManagerContents.onRecentServiceClicked) self.recentFilesMenu.addAction(action) - clearRecentFilesAction = base_action(self, u'') - clearRecentFilesAction.setText( - translate('OpenLP.MainWindow', 'Clear List', - 'Clear List of recent files')) - clearRecentFilesAction.setStatusTip( - translate('OpenLP.MainWindow', 'Clear the list of recent files.')) + clearRecentFilesAction = create_action(self, u'', + text=translate('OpenLP.MainWindow', 'Clear List', + 'Clear List of recent files'), + statustip=translate('OpenLP.MainWindow', + 'Clear the list of recent files.'), + enabled=not self.recentFiles.isEmpty(), + triggers=self.recentFiles.clear) add_actions(self.recentFilesMenu, (None, clearRecentFilesAction)) - self.connect(clearRecentFilesAction, QtCore.SIGNAL(u'triggered()'), - self.recentFiles.clear) clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty()) def addRecentFile(self, filename): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 0275f4d11..62e79b1c1 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem -from openlp.core.lib.ui import UiStrings, shortcut_action +from openlp.core.lib.ui import UiStrings, create_action from openlp.core.lib import SlideLimits, ServiceItemAction from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList from openlp.core.utils.actions import ActionList, CategoryOrder @@ -191,24 +191,24 @@ class SlideController(Controller): self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu) self.hideMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Hide'), self.toolbar)) - self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen', - [QtCore.Qt.Key_Period], self.onBlankDisplay, - u':/slides/slide_blank.png', False, - unicode(UiStrings().LiveToolbar)) - self.blankScreen.setText( - translate('OpenLP.SlideController', 'Blank Screen')) - self.themeScreen = shortcut_action(self.hideMenu, u'themeScreen', - [QtGui.QKeySequence(u'T')], self.onThemeDisplay, - u':/slides/slide_theme.png', False, - unicode(UiStrings().LiveToolbar)) - self.themeScreen.setText( - translate('OpenLP.SlideController', 'Blank to Theme')) - self.desktopScreen = shortcut_action(self.hideMenu, - u'desktopScreen', [QtGui.QKeySequence(u'D')], - self.onHideDisplay, u':/slides/slide_desktop.png', False, - unicode(UiStrings().LiveToolbar)) - self.desktopScreen.setText( - translate('OpenLP.SlideController', 'Show Desktop')) + self.blankScreen = create_action(self.hideMenu, u'blankScreen', + text=translate('OpenLP.SlideController', 'Blank Screen'), + icon=u':/slides/slide_blank.png', checked=False, + shortcuts=[QtCore.Qt.Key_Period], + category=unicode(UiStrings().LiveToolbar), + triggers=self.onBlankDisplay) + self.themeScreen = create_action(self.hideMenu, u'themeScreen', + text=translate('OpenLP.SlideController', 'Blank to Theme'), + icon=u':/slides/slide_theme.png', checked=False, + shortcuts=[QtGui.QKeySequence(u'T')], + category=unicode(UiStrings().LiveToolbar), + triggers=self.onThemeDisplay) + self.desktopScreen = create_action(self.hideMenu, u'desktopScreen', + text=translate('OpenLP.SlideController', 'Show Desktop'), + icon=u':/slides/slide_desktop.png', checked=False, + shortcuts=[QtGui.QKeySequence(u'D')], + category=unicode(UiStrings().LiveToolbar), + triggers=self.onHideDisplay) self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) @@ -224,16 +224,16 @@ class SlideController(Controller): self.playSlidesMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) - self.playSlidesLoop = shortcut_action(self.playSlidesMenu, - u'playSlidesLoop', [], self.onPlaySlidesLoop, - u':/media/media_time.png', False, - unicode(UiStrings().LiveToolbar)) - self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop) - self.playSlidesOnce = shortcut_action(self.playSlidesMenu, - u'playSlidesOnce', [], self.onPlaySlidesOnce, - u':/media/media_time.png', False, - unicode(UiStrings().LiveToolbar)) - self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd) + self.playSlidesLoop = create_action(self.playSlidesMenu, + u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, + icon=u':/media/media_time.png', checked=False, shortcuts=[], + category=unicode(UiStrings().LiveToolbar), + triggers=self.onPlaySlidesLoop) + self.playSlidesOnce = create_action(self.playSlidesMenu, + u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, + icon=u':/media/media_time.png', checked=False, shortcuts=[], + category=unicode(UiStrings().LiveToolbar), + triggers=self.onPlaySlidesOnce) if QtCore.QSettings().value(self.parent().generalSettingsSection + u'/enable slide loop', QtCore.QVariant(True)).toBool(): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) @@ -328,78 +328,88 @@ class SlideController(Controller): self.shortcutTimer = QtCore.QTimer() self.shortcutTimer.setObjectName(u'shortcutTimer') self.shortcutTimer.setSingleShot(True) - self.verseShortcut = shortcut_action(self, u'verseShortcut', - [QtGui.QKeySequence(u'V')], self.slideShortcutActivated, + self.verseShortcut = create_action(self, u'verseShortcut', + text=translate('OpenLP.SlideController', 'Go to "Verse"'), + shortcuts=[QtGui.QKeySequence(u'V')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Verse"')) - self.shortcut0 = shortcut_action(self, u'0', - [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut1 = shortcut_action(self, u'1', - [QtGui.QKeySequence(u'1')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut2 = shortcut_action(self, u'2', - [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut3 = shortcut_action(self, u'3', - [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut4 = shortcut_action(self, u'4', - [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut5 = shortcut_action(self, u'5', - [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut6 = shortcut_action(self, u'6', - [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut7 = shortcut_action(self, u'7', - [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut8 = shortcut_action(self, u'8', - [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.shortcut9 = shortcut_action(self, u'9', - [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.chorusShortcut = shortcut_action(self, u'chorusShortcut', - [QtGui.QKeySequence(u'C')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.shortcut0 = create_action(self, u'0', + shortcuts=[QtGui.QKeySequence(u'0')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut1 = create_action(self, u'1', + shortcuts=[QtGui.QKeySequence(u'1')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut2 = create_action(self, u'2', + shortcuts=[QtGui.QKeySequence(u'2')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut3 = create_action(self, u'3', + shortcuts=[QtGui.QKeySequence(u'3')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut4 = create_action(self, u'4', + shortcuts=[QtGui.QKeySequence(u'4')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut5 = create_action(self, u'5', + shortcuts=[QtGui.QKeySequence(u'5')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut6 = create_action(self, u'6', + shortcuts=[QtGui.QKeySequence(u'6')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut7 = create_action(self, u'7', + shortcuts=[QtGui.QKeySequence(u'7')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut8 = create_action(self, u'8', + shortcuts=[QtGui.QKeySequence(u'8')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.shortcut9 = create_action(self, u'9', + shortcuts=[QtGui.QKeySequence(u'9')], + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.slideShortcutActivated) + self.chorusShortcut = create_action(self, u'chorusShortcut', + text=translate('OpenLP.SlideController', 'Go to "Chorus"'), + shortcuts=[QtGui.QKeySequence(u'C')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.chorusShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Chorus"')) - self.bridgeShortcut = shortcut_action(self, u'bridgeShortcut', - [QtGui.QKeySequence(u'B')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.bridgeShortcut = create_action(self, u'bridgeShortcut', + text=translate('OpenLP.SlideController', 'Go to "Bridge"'), + shortcuts=[QtGui.QKeySequence(u'B')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.bridgeShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Bridge"')) - self.preChorusShortcut = shortcut_action(self, u'preChorusShortcut', - [QtGui.QKeySequence(u'P')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.preChorusShortcut = create_action(self, u'preChorusShortcut', + text=translate('OpenLP.SlideController', 'Go to "Pre-Chorus"'), + shortcuts=[QtGui.QKeySequence(u'P')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.preChorusShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Pre-Chorus"')) - self.introShortcut = shortcut_action(self, u'introShortcut', - [QtGui.QKeySequence(u'I')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.introShortcut = create_action(self, u'introShortcut', + text=translate('OpenLP.SlideController', 'Go to "Intro"'), + shortcuts=[QtGui.QKeySequence(u'I')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.introShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Intro"')) - self.endingShortcut = shortcut_action(self, u'endingShortcut', - [QtGui.QKeySequence(u'E')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.endingShortcut = create_action(self, u'endingShortcut', + text=translate('OpenLP.SlideController', 'Go to "Ending"'), + shortcuts=[QtGui.QKeySequence(u'E')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.endingShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Ending"')) - self.otherShortcut = shortcut_action(self, u'otherShortcut', - [QtGui.QKeySequence(u'O')], self.slideShortcutActivated, + triggers=self.slideShortcutActivated) + self.otherShortcut = create_action(self, u'otherShortcut', + text=translate('OpenLP.SlideController', 'Go to "Other"'), + shortcuts=[QtGui.QKeySequence(u'O')], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.otherShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Other"')) + triggers=self.slideShortcutActivated) self.previewListWidget.addActions([ self.shortcut0, self.shortcut1, self.shortcut2, self.shortcut3, self.shortcut4, self.shortcut5, self.shortcut6, self.shortcut7, @@ -559,24 +569,24 @@ class SlideController(Controller): unicode(UiStrings().LiveToolbar), CategoryOrder.standardToolbar) action_list.add_action(self.previousItem) action_list.add_action(self.nextItem) - self.previousService = shortcut_action(parent, u'previousService', - [QtCore.Qt.Key_Left], self.servicePrevious, + self.previousService = create_action(parent, u'previousService', + text=translate('OpenLP.SlideController', 'Previous Service'), + shortcuts=[QtCore.Qt.Key_Left], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.previousService.setText( - translate('OpenLP.SlideController', 'Previous Service')) - self.nextService = shortcut_action(parent, 'nextService', - [QtCore.Qt.Key_Right], self.serviceNext, + triggers=self.servicePrevious) + self.nextService = create_action(parent, 'nextService', + text=translate('OpenLP.SlideController', 'Next Service'), + shortcuts=[QtCore.Qt.Key_Right], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.nextService.setText( - translate('OpenLP.SlideController', 'Next Service')) - self.escapeItem = shortcut_action(parent, 'escapeItem', - [QtCore.Qt.Key_Escape], self.liveEscape, + triggers=self.serviceNext) + self.escapeItem = create_action(parent, 'escapeItem', + text=translate('OpenLP.SlideController', 'Escape Item'), + shortcuts=[QtCore.Qt.Key_Escape], + context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar), - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.escapeItem.setText( - translate('OpenLP.SlideController', 'Escape Item')) + triggers=self.liveEscape) def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e67ef0686..d680ef713 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager -from openlp.core.lib.ui import icon_action, UiStrings +from openlp.core.lib.ui import create_action, UiStrings from openlp.core.lib.theme import VerticalType from openlp.core.utils.actions import ActionList from openlp.plugins.alerts.lib import AlertsManager, AlertsTab @@ -133,16 +133,12 @@ class AlertsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem', - u':/plugins/plugin_alerts.png') - self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert')) - self.toolsAlertItem.setStatusTip( - translate('AlertsPlugin', 'Show an alert message.')) - self.toolsAlertItem.setShortcut(u'F7') + self.toolsAlertItem = create_action(tools_menu, u'toolsAlertItem', + text=translate('AlertsPlugin', '&Alert'), + icon=u':/plugins/plugin_alerts.png', + statustip=translate('AlertsPlugin', 'Show an alert message.'), + visible=False, shortcuts=u'F7', triggers=self.onAlertsTrigger) self.serviceManager.mainwindow.toolsMenu.addAction(self.toolsAlertItem) - QtCore.QObject.connect(self.toolsAlertItem, - QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger) - self.toolsAlertItem.setVisible(False) def initialise(self): log.info(u'Alerts Initialising') diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 2f9a4fd6d..97b3b9a5a 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate -from openlp.core.lib.ui import base_action, UiStrings +from openlp.core.lib.ui import create_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem from openlp.plugins.bibles.forms import BibleUpgradeForm @@ -93,19 +93,16 @@ class BiblePlugin(Plugin): self.onToolsUpgradeItemTriggered() def addImportMenuItem(self, import_menu): - self.importBibleItem = base_action(import_menu, u'importBibleItem') - self.importBibleItem.setText(translate('BiblesPlugin', '&Bible')) + self.importBibleItem = create_action(import_menu, u'importBibleItem', + text=translate('BiblesPlugin', '&Bible'), visible=False, + triggers=self.onBibleImportClick) import_menu.addAction(self.importBibleItem) - # signals and slots - QtCore.QObject.connect(self.importBibleItem, - QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick) - self.importBibleItem.setVisible(False) def addExportMenuItem(self, export_menu): - self.exportBibleItem = base_action(export_menu, u'exportBibleItem') - self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible')) + self.exportBibleItem = create_action(export_menu, u'exportBibleItem', + text=translate('BiblesPlugin', '&Bible'), + visible=False) export_menu.addAction(self.exportBibleItem) - self.exportBibleItem.setVisible(False) def addToolsMenuItem(self, tools_menu): """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 59fc2920b..890db1b4e 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ Receiver from openlp.core.lib.db import Manager -from openlp.core.lib.ui import UiStrings, base_action, icon_action +from openlp.core.lib.ui import UiStrings, create_action from openlp.core.utils.actions import ActionList from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \ SongsTab @@ -93,14 +93,12 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.songImportItem = base_action(import_menu, u'songImportItem') - self.songImportItem.setText(translate('SongsPlugin', '&Song')) - self.songImportItem.setToolTip(translate('SongsPlugin', - 'Import songs using the import wizard.')) + self.songImportItem = create_action(import_menu, u'songImportItem', + text=translate('SongsPlugin', '&Song'), + tooltip=translate('SongsPlugin', + 'Import songs using the import wizard.'), + triggers=self.onSongImportItemClicked) import_menu.addAction(self.songImportItem) - # Signals and slots - QtCore.QObject.connect(self.songImportItem, - QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked) def addExportMenuItem(self, export_menu): """ @@ -112,14 +110,12 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.songExportItem = base_action(export_menu, u'songExportItem') - self.songExportItem.setText(translate('SongsPlugin', '&Song')) - self.songExportItem.setToolTip(translate('SongsPlugin', - 'Exports songs using the export wizard.')) + self.songExportItem = create_action(export_menu, u'songExportItem', + text=translate('SongsPlugin', '&Song'), + tooltip=translate('SongsPlugin', + 'Exports songs using the export wizard.'), + triggers=self.onSongExportItemClicked) export_menu.addAction(self.songExportItem) - # Signals and slots - QtCore.QObject.connect(self.songExportItem, - QtCore.SIGNAL(u'triggered()'), self.onSongExportItemClicked) def addToolsMenuItem(self, tools_menu): """ @@ -131,17 +127,13 @@ class SongsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem', - u':/plugins/plugin_songs.png') - self.toolsReindexItem.setText( - translate('SongsPlugin', '&Re-index Songs')) - self.toolsReindexItem.setStatusTip( - translate('SongsPlugin', 'Re-index the songs database to improve ' - 'searching and ordering.')) + self.toolsReindexItem = create_action(tools_menu, u'toolsReindexItem', + text=translate('SongsPlugin', '&Re-index Songs'), + icon=u':/plugins/plugin_songs.png', + statustip=translate('SongsPlugin', + 'Re-index the songs database to improve searching and ordering.'), + visible=False, triggers=self.onToolsReindexItemTriggered) tools_menu.addAction(self.toolsReindexItem) - QtCore.QObject.connect(self.toolsReindexItem, - QtCore.SIGNAL(u'triggered()'), self.onToolsReindexItemTriggered) - self.toolsReindexItem.setVisible(False) def onToolsReindexItemTriggered(self): """ diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index ec6187b0f..157929f2f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \ translate from openlp.core.lib.db import Manager -from openlp.core.lib.ui import base_action, shortcut_action +from openlp.core.lib.ui import create_action from openlp.core.utils.actions import ActionList from openlp.plugins.songusage.forms import SongUsageDetailForm, \ SongUsageDeleteForm @@ -73,24 +73,24 @@ class SongUsagePlugin(Plugin): self.songUsageMenu.setTitle(translate( 'SongUsagePlugin', '&Song Usage Tracking')) # SongUsage Delete - self.songUsageDelete = base_action(tools_menu, u'songUsageDelete') - self.songUsageDelete.setText(translate('SongUsagePlugin', - '&Delete Tracking Data')) - self.songUsageDelete.setStatusTip(translate('SongUsagePlugin', - 'Delete song usage data up to a specified date.')) + self.songUsageDelete = create_action(tools_menu, u'songUsageDelete', + text=translate('SongUsagePlugin', '&Delete Tracking Data'), + statustip=translate('SongUsagePlugin', + 'Delete song usage data up to a specified date.'), + triggers=self.onSongUsageDelete) # SongUsage Report - self.songUsageReport = base_action(tools_menu, u'songUsageReport') - self.songUsageReport.setText( - translate('SongUsagePlugin', '&Extract Tracking Data')) - self.songUsageReport.setStatusTip( - translate('SongUsagePlugin', 'Generate a report on song usage.')) + self.songUsageReport = create_action(tools_menu, u'songUsageReport', + text=translate('SongUsagePlugin', '&Extract Tracking Data'), + statustip=translate('SongUsagePlugin', + 'Generate a report on song usage.'), + triggers=self.onSongUsageReport) # SongUsage activation - self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus', - [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False) - self.songUsageStatus.setText(translate( - 'SongUsagePlugin', 'Toggle Tracking')) - self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', - 'Toggle the tracking of song usage.')) + self.songUsageStatus = create_action(tools_menu, u'songUsageStatus', + text=translate('SongUsagePlugin', 'Toggle Tracking'), + statustip=translate('SongUsagePlugin', + 'Toggle the tracking of song usage.'), checked=False, + shortcuts=[QtCore.Qt.Key_F4], + triggers=self.toggleSongUsageState) # Add Menus together self.toolsMenu.addAction(self.songUsageMenu.menuAction()) self.songUsageMenu.addAction(self.songUsageStatus) @@ -114,10 +114,6 @@ class SongUsagePlugin(Plugin): QtCore.QObject.connect(self.songUsageActiveButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState) - QtCore.QObject.connect(self.songUsageDelete, - QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) - QtCore.QObject.connect(self.songUsageReport, - QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport) self.songUsageMenu.menuAction().setVisible(False) def initialise(self): From d13ec2184a4e422ada81ee56c02ce2456e434a0f Mon Sep 17 00:00:00 2001 From: M2j Date: Tue, 28 Feb 2012 10:24:42 +0100 Subject: [PATCH 20/46] concentrate action creation in slide controller --- openlp/core/lib/ui.py | 11 +- openlp/core/ui/firsttimelanguageform.py | 4 +- openlp/core/ui/slidecontroller.py | 156 ++++++------------------ openlp/plugins/bibles/bibleplugin.py | 15 +-- 4 files changed, 50 insertions(+), 136 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 58527b102..7cc63d4a9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -364,10 +364,11 @@ def create_action(parent, name, **kwargs): return action def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, - context=QtCore.Qt.WidgetShortcut, **kwargs): - return create_action(parent=base, name=u'', icon=icon, text=text, - triggers=slot, shortcuts=shortcuts, category=category, context=context, - **kwargs) + context=QtCore.Qt.WidgetShortcut): + action = create_action(parent=base, name=u'', text=text, icon=icon, + shortcuts=shortcuts, context=context, category=category, triggers=slot) + base.addAction(action) + return action def context_menu(base, icon, text): """ @@ -393,7 +394,7 @@ def context_menu_separator(base): ``base`` The menu object to add the separator to """ - action = QtGui.QAction(u'', base) + action = QtGui.QAction(base) action.setSeparator(True) base.addAction(action) return action diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 3ffbc1b00..aac501191 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -27,6 +27,7 @@ from PyQt4 import QtGui +from openlp.core.lib.ui import create_action from openlp.core.utils import LanguageManager from firsttimelanguagedialog import Ui_FirstTimeLanguageDialog @@ -55,8 +56,7 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): LanguageManager.set_language(False, False) else: LanguageManager.auto_language = False - action = QtGui.QAction(None) - action.setObjectName(unicode(self.languageComboBox.currentText())) + action = create_action(None, self.languageComboBox.currentText()) LanguageManager.set_language(action, False) return QtGui.QDialog.accept(self) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 62e79b1c1..59fdf8bec 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -328,96 +328,29 @@ class SlideController(Controller): self.shortcutTimer = QtCore.QTimer() self.shortcutTimer.setObjectName(u'shortcutTimer') self.shortcutTimer.setSingleShot(True) - self.verseShortcut = create_action(self, u'verseShortcut', - text=translate('OpenLP.SlideController', 'Go to "Verse"'), - shortcuts=[QtGui.QKeySequence(u'V')], + shortcuts = [{u'key': u'V', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Verse"')}, + {u'key': u'C', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Chorus"')}, + {u'key': u'B', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Bridge"')}, + {u'key': u'P', u'configurable': True, + u'text': translate('OpenLP.SlideController', + 'Go to "Pre-Chorus"')}, + {u'key': u'I', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Intro"')}, + {u'key': u'E', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Ending"')}, + {u'key': u'O', u'configurable': True, + u'text': translate('OpenLP.SlideController', 'Go to "Other"')}] + shortcuts += [{u'key': unicode(number)} for number in range(0, 10)] + self.previewListWidget.addActions([create_action(self, + u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), + shortcuts=[QtGui.QKeySequence(s[u'key'])], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.shortcut0 = create_action(self, u'0', - shortcuts=[QtGui.QKeySequence(u'0')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut1 = create_action(self, u'1', - shortcuts=[QtGui.QKeySequence(u'1')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut2 = create_action(self, u'2', - shortcuts=[QtGui.QKeySequence(u'2')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut3 = create_action(self, u'3', - shortcuts=[QtGui.QKeySequence(u'3')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut4 = create_action(self, u'4', - shortcuts=[QtGui.QKeySequence(u'4')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut5 = create_action(self, u'5', - shortcuts=[QtGui.QKeySequence(u'5')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut6 = create_action(self, u'6', - shortcuts=[QtGui.QKeySequence(u'6')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut7 = create_action(self, u'7', - shortcuts=[QtGui.QKeySequence(u'7')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut8 = create_action(self, u'8', - shortcuts=[QtGui.QKeySequence(u'8')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.shortcut9 = create_action(self, u'9', - shortcuts=[QtGui.QKeySequence(u'9')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.slideShortcutActivated) - self.chorusShortcut = create_action(self, u'chorusShortcut', - text=translate('OpenLP.SlideController', 'Go to "Chorus"'), - shortcuts=[QtGui.QKeySequence(u'C')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.bridgeShortcut = create_action(self, u'bridgeShortcut', - text=translate('OpenLP.SlideController', 'Go to "Bridge"'), - shortcuts=[QtGui.QKeySequence(u'B')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.preChorusShortcut = create_action(self, u'preChorusShortcut', - text=translate('OpenLP.SlideController', 'Go to "Pre-Chorus"'), - shortcuts=[QtGui.QKeySequence(u'P')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.introShortcut = create_action(self, u'introShortcut', - text=translate('OpenLP.SlideController', 'Go to "Intro"'), - shortcuts=[QtGui.QKeySequence(u'I')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.endingShortcut = create_action(self, u'endingShortcut', - text=translate('OpenLP.SlideController', 'Go to "Ending"'), - shortcuts=[QtGui.QKeySequence(u'E')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.otherShortcut = create_action(self, u'otherShortcut', - text=translate('OpenLP.SlideController', 'Go to "Other"'), - shortcuts=[QtGui.QKeySequence(u'O')], - context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.slideShortcutActivated) - self.previewListWidget.addActions([ - self.shortcut0, self.shortcut1, self.shortcut2, self.shortcut3, - self.shortcut4, self.shortcut5, self.shortcut6, self.shortcut7, - self.shortcut8, self.shortcut9, self.verseShortcut, - self.chorusShortcut, self.bridgeShortcut, - self.preChorusShortcut, self.introShortcut, self.endingShortcut, - self.otherShortcut - ]) + category=unicode(UiStrings().LiveToolbar) \ + if s.get(u'configurable') else None, + triggers=self.slideShortcutActivated) for s in shortcuts]) QtCore.QObject.connect( self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), self.slideShortcutActivated) @@ -486,52 +419,37 @@ class SlideController(Controller): SONGS_PLUGIN_AVAILABLE = True except ImportError: SONGS_PLUGIN_AVAILABLE = False - verse_type = unicode(self.sender().objectName()) - if verse_type.startswith(u'verseShortcut'): - if SONGS_PLUGIN_AVAILABLE: + verse_type = \ + unicode(self.sender().objectName())[len(u'shortcutAction_'):] + if SONGS_PLUGIN_AVAILABLE: + if verse_type == u'V': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Verse] - else: - self.current_shortcut = u'V' - elif verse_type.startswith(u'chorusShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'C': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Chorus] - else: - self.current_shortcut = u'C' - elif verse_type.startswith(u'bridgeShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'B': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Bridge] - else: - self.current_shortcut = u'B' - elif verse_type.startswith(u'preChorusShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'P': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.PreChorus] - else: - self.current_shortcut = u'P' - elif verse_type.startswith(u'introShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'I': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Intro] - else: - self.current_shortcut = u'I' - elif verse_type.startswith(u'endingShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'E': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Ending] - else: - self.current_shortcut = u'E' - elif verse_type.startswith(u'otherShortcut'): - if SONGS_PLUGIN_AVAILABLE: + elif verse_type == u'O': self.current_shortcut = \ VerseType.TranslatedTags[VerseType.Other] - else: - self.current_shortcut = u'O' + elif verse_type.isnumeric(): + self.current_shortcut += verse_type + self.current_shortcut = self.current_shortcut.upper() elif verse_type.isnumeric(): self.current_shortcut += verse_type - self.current_shortcut = self.current_shortcut.upper() + else: + self.current_shortcut = verse_type keys = self.slideList.keys() matches = [match for match in keys if match.startswith(self.current_shortcut)] diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 97b3b9a5a..be20cf154 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -114,17 +114,12 @@ class BiblePlugin(Plugin): use it as their parent. """ log.debug(u'add tools menu') - self.toolsUpgradeItem = QtGui.QAction(tools_menu) - self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem') - self.toolsUpgradeItem.setText( - translate('BiblesPlugin', '&Upgrade older Bibles')) - self.toolsUpgradeItem.setStatusTip( - translate('BiblesPlugin', 'Upgrade the Bible databases to the ' - 'latest format.')) + self.toolsUpgradeItem = create_action(tools_menu, u'toolsUpgradeItem', + text=translate('BiblesPlugin', '&Upgrade older Bibles'), + statustip=translate('BiblesPlugin', + 'Upgrade the Bible databases to the latest format.'), + visible=False, triggers=self.onToolsUpgradeItemTriggered) tools_menu.addAction(self.toolsUpgradeItem) - QtCore.QObject.connect(self.toolsUpgradeItem, - QtCore.SIGNAL(u'triggered()'), self.onToolsUpgradeItemTriggered) - self.toolsUpgradeItem.setVisible(False) def onToolsUpgradeItemTriggered(self): """ From fe2966ac9e8ac414ff77d98e17bb8df7d5c82b08 Mon Sep 17 00:00:00 2001 From: M2j Date: Tue, 28 Feb 2012 10:47:34 +0100 Subject: [PATCH 21/46] make slideShortcutActivated private --- openlp/core/ui/slidecontroller.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 59fdf8bec..182007acb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -350,10 +350,10 @@ class SlideController(Controller): context=QtCore.Qt.WidgetWithChildrenShortcut, category=unicode(UiStrings().LiveToolbar) \ if s.get(u'configurable') else None, - triggers=self.slideShortcutActivated) for s in shortcuts]) + triggers=self._slideShortcutActivated) for s in shortcuts]) QtCore.QObject.connect( self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), - self.slideShortcutActivated) + self._slideShortcutActivated) # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) @@ -403,7 +403,7 @@ class SlideController(Controller): QtCore.SIGNAL(u'slidecontroller_update_slide_limits'), self.updateSlideLimits) - def slideShortcutActivated(self): + def _slideShortcutActivated(self): """ Called, when a shortcut has been activated to jump to a chorus, verse, etc. @@ -419,8 +419,9 @@ class SlideController(Controller): SONGS_PLUGIN_AVAILABLE = True except ImportError: SONGS_PLUGIN_AVAILABLE = False - verse_type = \ - unicode(self.sender().objectName())[len(u'shortcutAction_'):] + sender_name = unicode(self.sender().objectName()) + verse_type = sender_name[15:] \ + if sender_name[:15] == u'shortcutAction_' else u'' if SONGS_PLUGIN_AVAILABLE: if verse_type == u'V': self.current_shortcut = \ @@ -448,7 +449,7 @@ class SlideController(Controller): self.current_shortcut = self.current_shortcut.upper() elif verse_type.isnumeric(): self.current_shortcut += verse_type - else: + elif verse_type: self.current_shortcut = verse_type keys = self.slideList.keys() matches = [match for match in keys @@ -458,7 +459,7 @@ class SlideController(Controller): self.current_shortcut = u'' self.__checkUpdateSelectedSlide(self.slideList[matches[0]]) self.slideSelected() - elif verse_type != u'shortcutTimer': + elif sender_name != u'shortcutTimer': # Start the time as we did not have any match. self.shortcutTimer.start(350) else: From 6ec167ed83b13f84f3307194509f7634d03a008f Mon Sep 17 00:00:00 2001 From: Rastislav Pecik Date: Tue, 28 Feb 2012 12:12:52 +0100 Subject: [PATCH 22/46] QSettings.value() now uses second argument for default value, which is utf8 --- openlp/core/lib/db.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 36823b118..a4a047497 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -201,9 +201,7 @@ class Manager(object): urlquote(unicode(settings.value(u'db database').toString()))) if db_type == u'mysql': db_encoding = unicode( - settings.value(u'db encoding').toString()) - if db_encoding == "": - db_encoding = u'utf8' + settings.value(u'db encoding', u'utf8').toString()) self.db_url += u'?charset=%s' % (urlquote(db_encoding)) settings.endGroup() if upgrade_mod: From 271c4ef1a41a18b18707d6d4509ee5069eee93b9 Mon Sep 17 00:00:00 2001 From: Rastislav Pecik Date: Tue, 28 Feb 2012 12:30:30 +0100 Subject: [PATCH 23/46] using QtCore.QVariant object as a second argument in settings.value method --- openlp/core/lib/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index a4a047497..6eff984c3 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -201,7 +201,7 @@ class Manager(object): urlquote(unicode(settings.value(u'db database').toString()))) if db_type == u'mysql': db_encoding = unicode( - settings.value(u'db encoding', u'utf8').toString()) + settings.value(u'db encoding', QtCore.QVariant(u'utf8')).toString()) self.db_url += u'?charset=%s' % (urlquote(db_encoding)) settings.endGroup() if upgrade_mod: From 8818256b2a99d0b8a3805495ff47232a6ad054f0 Mon Sep 17 00:00:00 2001 From: Rastislav Pecik Date: Tue, 28 Feb 2012 15:06:14 +0100 Subject: [PATCH 24/46] Fixed code according to mrege proposal comments --- openlp/core/lib/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 6eff984c3..436ea82de 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -201,8 +201,8 @@ class Manager(object): urlquote(unicode(settings.value(u'db database').toString()))) if db_type == u'mysql': db_encoding = unicode( - settings.value(u'db encoding', QtCore.QVariant(u'utf8')).toString()) - self.db_url += u'?charset=%s' % (urlquote(db_encoding)) + settings.value(u'db encoding', u'utf8').toString()) + self.db_url += u'?charset=%s' % urlquote(db_encoding) settings.endGroup() if upgrade_mod: db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod) From 299b80734583bc9c0c23b62a255cd2666ca95e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 29 Feb 2012 13:00:05 +0100 Subject: [PATCH 25/46] add language auto detection for osis bible files --- openlp/plugins/bibles/lib/osis.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 3fac48f19..400aaff7c 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -53,6 +53,7 @@ class OSISBible(BibleDB): self.filename = kwargs[u'filename'] fbibles = None self.books = {} + self.language_regex = re.compile(r'(.*?)') self.verse_regex = re.compile( r'(.*?)') self.note_regex = re.compile(r'(.*?)') @@ -107,14 +108,25 @@ class OSISBible(BibleDB): finally: if detect_file: detect_file.close() - # Set meta language_id - language_id = self.get_language(bible_name) - if not language_id: - log.exception(u'Importing books from "%s" failed' % self.filename) - return False try: osis = codecs.open(self.filename, u'r', details['encoding']) repl = replacement + # Set meta language_id + for file_record in osis: + if self.stop_import_flag: + break + match = self.language_regex.search(file_record) + if match: + language = BiblesResourcesDB.get_language(match.group(1)) + if language: + self.create_meta(u'language_id', language[u'id']) + else: + language_id = self.get_language(bible_name) + if not language_id: + log.exception(u'Importing books from "%s" failed' + % self.filename) + return False + break for file_record in osis: if self.stop_import_flag: break From 16d1125e84a22d70d6dc819a6b73f50a870abc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 29 Feb 2012 13:05:27 +0100 Subject: [PATCH 26/46] small fix --- openlp/plugins/bibles/lib/osis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 400aaff7c..defaca85c 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -119,7 +119,8 @@ class OSISBible(BibleDB): if match: language = BiblesResourcesDB.get_language(match.group(1)) if language: - self.create_meta(u'language_id', language[u'id']) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) else: language_id = self.get_language(bible_name) if not language_id: From 45e0d83600c65228f43b5fd96e7acc010bea41b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 1 Mar 2012 19:09:47 +0100 Subject: [PATCH 27/46] fix and improve auto detecting language in osis bible files --- openlp/plugins/bibles/lib/osis.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index defaca85c..4afee912d 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -111,28 +111,29 @@ class OSISBible(BibleDB): try: osis = codecs.open(self.filename, u'r', details['encoding']) repl = replacement - # Set meta language_id + language_id = False for file_record in osis: if self.stop_import_flag: break - match = self.language_regex.search(file_record) + # Try to find the bible language + if not language_id: + language_match = self.language_regex.search(file_record) + if language_match: + language = BiblesResourcesDB.get_language( + language_match.group(1)) + if language: + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) + continue + match = self.verse_regex.search(file_record) if match: - language = BiblesResourcesDB.get_language(match.group(1)) - if language: - language_id = language[u'id'] - self.create_meta(u'language_id', language_id) - else: + # Set meta language_id if not detected till now + if not language_id: language_id = self.get_language(bible_name) if not language_id: log.exception(u'Importing books from "%s" failed' % self.filename) return False - break - for file_record in osis: - if self.stop_import_flag: - break - match = self.verse_regex.search(file_record) - if match: match_count += 1 book = match.group(1) chapter = int(match.group(2)) From 6d909c64eb353ba7ff8c679a43c0a5bcbcb0b1ef Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 2 Mar 2012 11:22:52 +0100 Subject: [PATCH 28/46] unified remaining action creation methods (addToolbarButton, context_menu_action, context_menu_separator) --- openlp/core/lib/mediamanageritem.py | 117 ++++++------- openlp/core/lib/toolbar.py | 64 ++----- openlp/core/lib/ui.py | 37 ++-- openlp/core/ui/mainwindow.py | 74 ++++---- openlp/core/ui/media/mediacontroller.py | 27 +-- openlp/core/ui/servicemanager.py | 218 +++++++++++------------- openlp/core/ui/slidecontroller.py | 81 ++++----- openlp/core/ui/thememanager.py | 95 +++++------ openlp/plugins/images/lib/mediaitem.py | 10 +- openlp/plugins/media/lib/mediaitem.py | 10 +- openlp/plugins/songs/lib/mediaitem.py | 17 +- 11 files changed, 322 insertions(+), 428 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index d7b15a0cb..992286686 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -36,8 +36,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ StringContent, build_icon, translate, Receiver, ListWidgetWithDnD from openlp.core.lib.searchedit import SearchEdit -from openlp.core.lib.ui import UiStrings, context_menu_action, \ - context_menu_separator, critical_error_message_box +from openlp.core.lib.ui import UiStrings, create_widget_action, \ + critical_error_message_box log = logging.getLogger(__name__) @@ -147,36 +147,13 @@ class MediaManagerItem(QtGui.QWidget): self.toolbar = OpenLPToolbar(self) self.pageLayout.addWidget(self.toolbar) - def addToolbarButton( - self, title, tooltip, icon, slot=None, checkable=False): + def addToolbarButton(self, name, **kwargs): """ - A method to help developers easily add a button to the toolbar. - - ``title`` - The title of the button. - - ``tooltip`` - The tooltip to be displayed when the mouse hovers over the - button. - - ``icon`` - The icon of the button. This can be an instance of QIcon, or a - string containing either the absolute path to the image, or an - internal resource path starting with ':/'. - - ``slot`` - The method to call when the button is clicked. - - ``checkable`` - If *True* the button has two, *off* and *on*, states. Default is - *False*, which means the buttons has only one state. + A method to help developers easily add a button to the toolbar. For + details please have a look at OpenLPToolbar.addToolbarButton() and + openlp.core.lib.ui.create_action(). """ - # NB different order (when I broke this out, I didn't want to - # break compatability), but it makes sense for the icon to - # come before the tooltip (as you have to have an icon, but - # not neccesarily a tooltip) - return self.toolbar.addToolbarButton(title, icon, tooltip, slot, - checkable) + return self.toolbar.addToolbarButton(name, **kwargs) def addToolbarSeparator(self): """ @@ -208,40 +185,40 @@ class MediaManagerItem(QtGui.QWidget): toolbar_actions = [] ## Import Button ## if self.hasImportIcon: - toolbar_actions.append([StringContent.Import, + toolbar_actions.append([u'Import', StringContent.Import, u':/general/general_import.png', self.onImportClick]) ## Load Button ## if self.hasFileIcon: - toolbar_actions.append([StringContent.Load, + toolbar_actions.append([u'Load', StringContent.Load, u':/general/general_open.png', self.onFileClick]) ## New Button ## if self.hasNewIcon: - toolbar_actions.append([StringContent.New, + toolbar_actions.append([u'New', StringContent.New, u':/general/general_new.png', self.onNewClick]) ## Edit Button ## if self.hasEditIcon: - toolbar_actions.append([StringContent.Edit, + toolbar_actions.append([u'Edit', StringContent.Edit, u':/general/general_edit.png', self.onEditClick]) ## Delete Button ## if self.hasDeleteIcon: - toolbar_actions.append([StringContent.Delete, + toolbar_actions.append([u'Delete', StringContent.Delete, u':/general/general_delete.png', self.onDeleteClick]) ## Preview ## - toolbar_actions.append([StringContent.Preview, + toolbar_actions.append([u'Preview', StringContent.Preview, u':/general/general_preview.png', self.onPreviewClick]) ## Live Button ## - toolbar_actions.append([StringContent.Live, + toolbar_actions.append([u'Live', StringContent.Live, u':/general/general_live.png', self.onLiveClick]) ## Add to service Button ## - toolbar_actions.append([StringContent.Service, + toolbar_actions.append([u'Service', StringContent.Service, u':/general/general_add.png', self.onAddClick]) for action in toolbar_actions: if action[0] == StringContent.Preview: self.addToolbarSeparator() - self.addToolbarButton( - self.plugin.getString(action[0])[u'title'], - self.plugin.getString(action[0])[u'tooltip'], - action[1], action[2]) + self.addToolbarButton(u'%s%sAction' % (self.plugin.name, action[0]), + text=self.plugin.getString(action[1])[u'title'], icon=action[2], + tooltip=self.plugin.getString(action[1])[u'tooltip'], + triggers=action[3]) def addListViewToToolBar(self): """ @@ -259,35 +236,37 @@ class MediaManagerItem(QtGui.QWidget): # define and add the context menu self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) if self.hasEditIcon: - context_menu_action( - self.listView, u':/general/general_edit.png', - self.plugin.getString(StringContent.Edit)[u'title'], - self.onEditClick) - context_menu_separator(self.listView) + create_widget_action(self.listView, + text=self.plugin.getString(StringContent.Edit)[u'title'], + icon=u':/general/general_edit.png', + triggers=self.onEditClick) + create_widget_action(self.listView, separator=True) if self.hasDeleteIcon: - context_menu_action( - self.listView, u':/general/general_delete.png', - self.plugin.getString(StringContent.Delete)[u'title'], - self.onDeleteClick, [QtCore.Qt.Key_Delete]) - context_menu_separator(self.listView) - context_menu_action( - self.listView, u':/general/general_preview.png', - self.plugin.getString(StringContent.Preview)[u'title'], - self.onPreviewClick, [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) - context_menu_action( - self.listView, u':/general/general_live.png', - self.plugin.getString(StringContent.Live)[u'title'], - self.onLiveClick, [QtCore.Qt.ShiftModifier + QtCore.Qt.Key_Enter, - QtCore.Qt.ShiftModifier + QtCore.Qt.Key_Return]) - context_menu_action( - self.listView, u':/general/general_add.png', - self.plugin.getString(StringContent.Service)[u'title'], - self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal]) + create_widget_action(self.listView, + text=self.plugin.getString(StringContent.Delete)[u'title'], + icon=u':/general/general_delete.png', + shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteClick) + create_widget_action(self.listView, separator=True) + create_widget_action(self.listView, + text=self.plugin.getString(StringContent.Preview)[u'title'], + icon=u':/general/general_preview.png', + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], + triggers=self.onPreviewClick) + create_widget_action(self.listView, + text=self.plugin.getString(StringContent.Live)[u'title'], + icon=u':/general/general_live.png', + shortcuts=[QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter, + QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return], + triggers=self.onLiveClick) + create_widget_action(self.listView, + text=self.plugin.getString(StringContent.Service)[u'title'], + icon=u':/general/general_add.png', + shortcuts=[QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal], + triggers=self.onAddClick) if self.addToServiceItem: - context_menu_action( - self.listView, u':/general/general_add.png', - translate('OpenLP.MediaManagerItem', - '&Add to selected Service Item'), self.onAddEditClick) + create_widget_action(self.listView, text=translate( + 'OpenLP.MediaManagerItem', '&Add to selected Service Item'), + icon=u':/general/general_add.png', triggers=self.onAddEditClick) self.addCustomContextActions() # Create the context menu and add all actions from the listView. self.menu = QtGui.QMenu() diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 1418b501a..4fae1aebd 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -32,6 +32,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon +from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) @@ -51,58 +52,21 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions = {} log.debug(u'Init done for %s' % parent.__class__.__name__) - def addToolbarButton(self, title, icon, tooltip=None, slot=None, - checkable=False, shortcuts=None, context=QtCore.Qt.WidgetShortcut): + def addToolbarButton(self, name, **kwargs): """ - A method to help developers easily add a button to the toolbar. - - ``title`` - The title of the button. - - ``icon`` - The icon of the button. This can be an instance of QIcon, or a - string containing either the absolute path to the image, or an - internal resource path starting with ':/'. - - ``tooltip`` - A hint or tooltip for this button. - - ``slot`` - The method to run when this button is clicked. - - ``checkable`` - If *True* the button has two, *off* and *on*, states. Default is - *False*, which means the buttons has only one state. - - ``shortcuts`` - The list of shortcuts for this action - - ``context`` - Specify the context in which this shortcut is valid + A method to help developers easily add a button to the toolbar. A new + QAction is created by calling ``create_action()``. The action is added + to the toolbar and the toolbar is set as parent. For more details please + look at openlp.core.lib.ui.create_action() """ - if icon: - actionIcon = build_icon(icon) - if slot and not checkable: - newAction = self.addAction(actionIcon, title, slot) - else: - newAction = self.addAction(actionIcon, title) - self.icons[title] = actionIcon - else: - newAction = QtGui.QAction(title, self) - self.addAction(newAction) - QtCore.QObject.connect(newAction, - QtCore.SIGNAL(u'triggered()'), slot) - if tooltip: - newAction.setToolTip(tooltip) - if checkable: - newAction.setCheckable(True) - QtCore.QObject.connect(newAction, - QtCore.SIGNAL(u'toggled(bool)'), slot) - self.actions[title] = newAction - if shortcuts is not None: - newAction.setShortcuts(shortcuts) - newAction.setShortcutContext(context) - return newAction + action = create_widget_action(self, name, **kwargs) + # The ObjectNames should be used as keys. So translators can't break + # anything. + title = kwargs.get(u'text', u'') + self.actions[title] = action + if u'icon' in kwargs: + self.icons[title] = action.icon() + return action def addToolbarSeparator(self, handle): """ diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 7cc63d4a9..347946337 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -312,6 +312,9 @@ def create_action(parent, name, **kwargs): ``visible`` False in case the action should be hidden. + ``separator`` + True in case the action will be considered a separator. + ``data`` Data which is set as QVariant type. @@ -345,15 +348,17 @@ def create_action(parent, name, **kwargs): action.setEnabled(False) if not kwargs.pop(u'visible', True): action.setVisible(False) + if kwargs.pop(u'separator', False): + action.setSeparator(True) if u'data' in kwargs: action.setData(QtCore.QVariant(kwargs.pop(u'data'))) if kwargs.get(u'shortcuts'): action.setShortcuts(kwargs.pop(u'shortcuts')) - action.setShortcutContext(kwargs.pop(u'context', - QtCore.Qt.WindowShortcut)) + if kwargs.get(u'context') is not None: + action.setShortcutContext(kwargs.pop(u'context')) if kwargs.get(u'category'): action_list = ActionList.get_instance() - action_list.add_action(action, kwargs.pop(u'category')) + action_list.add_action(action, unicode(kwargs.pop(u'category'))) if kwargs.get(u'triggers'): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), kwargs.pop(u'triggers')) @@ -363,11 +368,15 @@ def create_action(parent, name, **kwargs): log.warn(u'Parameter %s was not consumed in create_action().', key) return action -def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, - context=QtCore.Qt.WidgetShortcut): - action = create_action(parent=base, name=u'', text=text, icon=icon, - shortcuts=shortcuts, context=context, category=category, triggers=slot) - base.addAction(action) +def create_widget_action(parent, name=u'', **kwargs): + """ + Return a new QAction by calling ``create_action(parent, name, **kwargs)``. + The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action + is added to the parents action list. + """ + kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut) + action = create_action(parent, name, **kwargs) + parent.addAction(action) return action def context_menu(base, icon, text): @@ -387,18 +396,6 @@ def context_menu(base, icon, text): action.setIcon(build_icon(icon)) return action -def context_menu_separator(base): - """ - Add a separator to a context menu - - ``base`` - The menu object to add the separator to - """ - action = QtGui.QAction(base) - action.setSeparator(True) - base.addAction(action) - return action - def add_widget_completer(cache, widget): """ Adds a text autocompleter to a widget. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1f28beee5..74b258d50 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -181,81 +181,75 @@ class Ui_MainWindow(object): self.fileNewItem = create_action(mainWindow, u'fileNewItem', icon=u':/general/general_new.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+N')], - category=unicode(UiStrings().File), + category=UiStrings().File, triggers=self.serviceManagerContents.onNewServiceClicked) self.fileOpenItem = create_action(mainWindow, u'fileOpenItem', icon=u':/general/general_open.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+O')], - category=unicode(UiStrings().File), + category=UiStrings().File, triggers=self.serviceManagerContents.onLoadServiceClicked) self.fileSaveItem = create_action(mainWindow, u'fileSaveItem', icon=u':/general/general_save.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+S')], - category=unicode(UiStrings().File), + category=UiStrings().File, triggers=self.serviceManagerContents.saveFile) self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')], - category=unicode(UiStrings().File), + category=UiStrings().File, triggers=self.serviceManagerContents.saveFileAs) self.printServiceOrderItem = create_action(mainWindow, u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')], - category=unicode(UiStrings().File), + category=UiStrings().File, triggers=self.serviceManagerContents.printServiceOrder) self.fileExitItem = create_action(mainWindow, u'fileExitItem', icon=u':/system/system_exit.png', shortcuts=[QtGui.QKeySequence(u'Alt+F4')], - category=unicode(UiStrings().File), - triggers=mainWindow.close) + category=UiStrings().File, triggers=mainWindow.close) action_list.add_category(unicode(UiStrings().Import), CategoryOrder.standardMenu) self.importThemeItem = create_action(mainWindow, - u'importThemeItem', category=unicode(UiStrings().Import)) + u'importThemeItem', category=UiStrings().Import) self.importLanguageItem = create_action(mainWindow, - u'importLanguageItem')#, category=unicode(UiStrings().Import)) + u'importLanguageItem')#, category=UiStrings().Import) action_list.add_category(unicode(UiStrings().Export), CategoryOrder.standardMenu) self.exportThemeItem = create_action(mainWindow, - u'exportThemeItem', category=unicode(UiStrings().Export)) + u'exportThemeItem', category=UiStrings().Export) self.exportLanguageItem = create_action(mainWindow, - u'exportLanguageItem')#, category=unicode(UiStrings().Export)) + u'exportLanguageItem')#, category=UiStrings().Export) action_list.add_category(unicode(UiStrings().View), CategoryOrder.standardMenu) self.viewMediaManagerItem = create_action(mainWindow, u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], icon=u':/system/system_mediamanager.png', checked=self.mediaManagerDock.isVisible(), - category=unicode(UiStrings().View), - triggers=self.toggleMediaManager) + category=UiStrings().View, triggers=self.toggleMediaManager) self.viewThemeManagerItem = create_action(mainWindow, u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')], icon=u':/system/system_thememanager.png', checked=self.themeManagerDock.isVisible(), - category=unicode(UiStrings().View), - triggers=self.toggleThemeManager) + category=UiStrings().View, triggers=self.toggleThemeManager) self.viewServiceManagerItem = create_action(mainWindow, u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')], icon=u':/system/system_servicemanager.png', checked=self.serviceManagerDock.isVisible(), - category=unicode(UiStrings().View), - triggers=self.toggleServiceManager) + category=UiStrings().View, triggers=self.toggleServiceManager) self.viewPreviewPanel = create_action(mainWindow, u'viewPreviewPanel', shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible, - category=unicode(UiStrings().View), - triggers=self.setPreviewPanelVisibility) + category=UiStrings().View, triggers=self.setPreviewPanelVisibility) self.viewLivePanel = create_action(mainWindow, u'viewLivePanel', shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible, - category=unicode(UiStrings().View), - triggers=self.setLivePanelVisibility) + category=UiStrings().View, triggers=self.setLivePanelVisibility) self.lockPanel = create_action(mainWindow, u'lockPanel', checked=panelLocked, triggers=self.setLockPanel) action_list.add_category(unicode(UiStrings().ViewMode), CategoryOrder.standardMenu) self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', - checked=False, category=unicode(UiStrings().ViewMode)) + checked=False, category=UiStrings().ViewMode) self.modeSetupItem = create_action(mainWindow, u'modeSetupItem', - checked=False, category=unicode(UiStrings().ViewMode)) + checked=False, category=UiStrings().ViewMode) self.modeLiveItem = create_action(mainWindow, u'modeLiveItem', - checked=True, category=unicode(UiStrings().ViewMode)) + checked=True, category=UiStrings().ViewMode) self.modeGroup = QtGui.QActionGroup(mainWindow) self.modeGroup.addAction(self.modeDefaultItem) self.modeGroup.addAction(self.modeSetupItem) @@ -265,23 +259,22 @@ class Ui_MainWindow(object): CategoryOrder.standardMenu) self.toolsAddToolItem = create_action(mainWindow, u'toolsAddToolItem', icon=u':/tools/tools_add.png', - category=unicode(UiStrings().Tools)) + category=UiStrings().Tools) self.toolsOpenDataFolder = create_action(mainWindow, u'toolsOpenDataFolder', icon=u':/general/general_open.png', - category=unicode(UiStrings().Tools)) + category=UiStrings().Tools) self.toolsFirstTimeWizard = create_action(mainWindow, u'toolsFirstTimeWizard', icon=u':/general/general_revert.png', - category=unicode(UiStrings().Tools)) + category=UiStrings().Tools) self.updateThemeImages = create_action(mainWindow, - u'updateThemeImages', category=unicode(UiStrings().Tools)) + u'updateThemeImages', category=UiStrings().Tools) action_list.add_category(unicode(UiStrings().Settings), CategoryOrder.standardMenu) self.settingsPluginListItem = create_action(mainWindow, u'settingsPluginListItem', icon=u':/system/settings_plugin_list.png', shortcuts=[QtGui.QKeySequence(u'Alt+F7')], - category=unicode(UiStrings().Settings), - triggers=self.onPluginItemClicked) + category=UiStrings().Settings, triggers=self.onPluginItemClicked) # i18n Language Items self.autoLanguageItem = create_action(mainWindow, u'autoLanguageItem', checked=LanguageManager.auto_language) @@ -298,40 +291,37 @@ class Ui_MainWindow(object): self.settingsShortcutsItem = create_action(mainWindow, u'settingsShortcutsItem', icon=u':/system/system_configure_shortcuts.png', - category=unicode(UiStrings().Settings)) + category=UiStrings().Settings) # Formatting Tags were also known as display tags. self.formattingTagItem = create_action(mainWindow, u'displayTagItem', icon=u':/system/tag_editor.png', - category=unicode(UiStrings().Settings)) + category=UiStrings().Settings) self.settingsConfigureItem = create_action(mainWindow, u'settingsConfigureItem', icon=u':/system/system_settings.png', - category=unicode(UiStrings().Settings)) + category=UiStrings().Settings) self.settingsImportItem = create_action(mainWindow, - u'settingsImportItem', category=unicode(UiStrings().Settings)) + u'settingsImportItem', category=UiStrings().Settings) self.settingsExportItem = create_action(mainWindow, - u'settingsExportItem', category=unicode(UiStrings().Settings)) + u'settingsExportItem', category=UiStrings().Settings) action_list.add_category(unicode(UiStrings().Help), CategoryOrder.standardMenu) self.aboutItem = create_action(mainWindow, u'aboutItem', icon=u':/system/system_about.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')], - category=unicode(UiStrings().Help), - triggers=self.onAboutItemClicked) + category=UiStrings().Help, triggers=self.onAboutItemClicked) if os.name == u'nt': self.localHelpFile = os.path.join( AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') self.offlineHelpItem = create_action(mainWindow, u'offlineHelpItem', icon=u':/system/system_help_contents.png', shortcuts=[QtGui.QKeySequence(u'F1')], - category=unicode(UiStrings().Help), - triggers=self.onOfflineHelpClicked) + category=UiStrings().Help, triggers=self.onOfflineHelpClicked) self.onlineHelpItem = create_action(mainWindow, u'onlineHelpItem', icon=u':/system/system_online_help.png', shortcuts=[QtGui.QKeySequence(u'Alt+F1')], - category=unicode(UiStrings().Help), - triggers=self.onOnlineHelpClicked) + category=UiStrings().Help, triggers=self.onOnlineHelpClicked) self.webSiteItem = create_action(mainWindow, - u'webSiteItem', category=unicode(UiStrings().Help)) + u'webSiteItem', category=UiStrings().Help) add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem)) add_actions(self.fileExportMenu, (self.settingsExportItem, None, diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 9c44f1693..3bb9da6a0 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -204,18 +204,21 @@ class MediaController(object): controller.media_info = MediaInfo() # Build a Media ToolBar controller.mediabar = OpenLPToolbar(controller) - controller.mediabar.addToolbarButton( - u'media_playback_play', u':/slides/media_playback_start.png', - 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.'), - controller.sendToPlugins) - controller.mediabar.addToolbarButton( - u'media_playback_stop', u':/slides/media_playback_stop.png', - translate('OpenLP.SlideController', 'Stop playing media.'), - controller.sendToPlugins) + controller.mediabar.addToolbarButton(u'playbackPlay', + text=u'media_playback_play', + icon=u':/slides/media_playback_start.png', + tooltip=translate('OpenLP.SlideController', 'Start playing media.'), + triggers=controller.sendToPlugins) + controller.mediabar.addToolbarButton(u'playbackPause', + text=u'media_playback_pause', + icon=u':/slides/media_playback_pause.png', + tooltip=translate('OpenLP.SlideController', 'Pause playing media.'), + triggers=controller.sendToPlugins) + controller.mediabar.addToolbarButton(u'playbackStop', + text=u'media_playback_stop', + icon=u':/slides/media_playback_stop.png', + tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), + triggers=controller.sendToPlugins) # Build the seekSlider. controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) controller.seekSlider.setMaximum(1000) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 84083af13..03fad5dae 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -41,7 +41,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ ItemCapabilities, SettingsManager, translate, str_to_bool from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ - context_menu_action, context_menu_separator, find_and_set_in_combo_box + create_widget_action, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, split_filename @@ -117,17 +117,18 @@ class ServiceManager(QtGui.QWidget): self.layout.setMargin(0) # Create the top toolbar self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarButton( - UiStrings().NewService, u':/general/general_new.png', - UiStrings().CreateService, self.onNewServiceClicked) - self.toolbar.addToolbarButton( - UiStrings().OpenService, u':/general/general_open.png', - translate('OpenLP.ServiceManager', 'Load an existing service.'), - self.onLoadServiceClicked) - self.toolbar.addToolbarButton( - UiStrings().SaveService, u':/general/general_save.png', - translate('OpenLP.ServiceManager', 'Save this service.'), - self.saveFile) + self.toolbar.addToolbarButton(u'newService', + text=UiStrings().NewService, icon=u':/general/general_new.png', + tooltip=UiStrings().CreateService, + triggers=self.onNewServiceClicked) + self.toolbar.addToolbarButton(u'openService', + text=UiStrings().OpenService, icon=u':/general/general_open.png', + tooltip=translate('OpenLP.ServiceManager', + 'Load an existing service.'), triggers=self.onLoadServiceClicked) + self.toolbar.addToolbarButton(u'saveService', + text=UiStrings().SaveService, icon=u':/general/general_save.png', + tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), + triggers=self.saveFile) self.toolbar.addSeparator() self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) self.themeLabel.setMargin(3) @@ -168,99 +169,77 @@ class ServiceManager(QtGui.QWidget): self.layout.addWidget(self.serviceManagerList) # Add the bottom toolbar self.orderToolbar = OpenLPToolbar(self) - self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move to &top'), - u':/services/service_top.png', - translate('OpenLP.ServiceManager', - 'Move item to the top of the service.'), - self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) - self.serviceManagerList.moveTop.setObjectName(u'moveTop') action_list = ActionList.get_instance() action_list.add_category( unicode(UiStrings().Service), CategoryOrder.standardToolbar) - action_list.add_action( - self.serviceManagerList.moveTop, unicode(UiStrings().Service)) + self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton( + u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'), + icon=u':/services/service_top.png', tooltip=translate( + 'OpenLP.ServiceManager', 'Move item to the top of the service.'), + shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, + triggers=self.onServiceTop) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move &up'), - u':/services/service_up.png', - translate('OpenLP.ServiceManager', + u'moveUp', text=translate('OpenLP.ServiceManager', 'Move &up'), + icon=u':/services/service_up.png', + tooltip=translate( 'OpenLP.ServiceManager', 'Move item up one position in the service.'), - self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp]) - self.serviceManagerList.moveUp.setObjectName(u'moveUp') - action_list.add_action( - self.serviceManagerList.moveUp, unicode(UiStrings().Service)) + shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, + triggers=self.onServiceUp) self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move &down'), - u':/services/service_down.png', - translate('OpenLP.ServiceManager', + u'moveDown', text=translate('OpenLP.ServiceManager', 'Move &down'), + icon=u':/services/service_down.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), - self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) - self.serviceManagerList.moveDown.setObjectName(u'moveDown') - action_list.add_action( - self.serviceManagerList.moveDown, unicode(UiStrings().Service)) + shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, + triggers=self.onServiceDown) self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move to &bottom'), - u':/services/service_bottom.png', - translate('OpenLP.ServiceManager', - 'Move item to the end of the service.'), - self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) - self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') - action_list.add_action( - self.serviceManagerList.moveBottom, unicode(UiStrings().Service)) + u'moveBottom', + text=translate('OpenLP.ServiceManager', 'Move to &bottom'), + icon=u':/services/service_bottom.png', tooltip=translate( + 'OpenLP.ServiceManager', 'Move item to the end of the service.'), + shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, + triggers=self.onServiceEnd) self.serviceManagerList.down = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move &down'), - None, - translate('OpenLP.ServiceManager', - 'Moves the selection down the window.'), - self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) - self.serviceManagerList.down.setObjectName(u'down') + u'down', text=translate('OpenLP.ServiceManager', 'Move &down'), + tooltip=translate('OpenLP.ServiceManager', + 'Moves the selection down the window.'), visible=False, + shortcuts=[QtCore.Qt.Key_Down], triggers=self.onMoveSelectionDown) action_list.add_action(self.serviceManagerList.down) - self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Move up'), - None, - translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), - self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) - self.serviceManagerList.up.setObjectName(u'up') + u'up', text=translate('OpenLP.ServiceManager', 'Move up'), + tooltip=translate('OpenLP.ServiceManager', + 'Moves the selection up the window.'), visible=False, + shortcuts=[QtCore.Qt.Key_Up], triggers=self.onMoveSelectionUp) action_list.add_action(self.serviceManagerList.up) - self.serviceManagerList.up.setVisible(False) self.orderToolbar.addSeparator() self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', '&Delete From Service'), - u':/general/general_delete.png', - translate('OpenLP.ServiceManager', + u'delete', + text=translate('OpenLP.ServiceManager', '&Delete From Service'), + icon=u':/general/general_delete.png', + tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), - self.onDeleteFromService) + triggers=self.onDeleteFromService) self.orderToolbar.addSeparator() self.serviceManagerList.expand = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', '&Expand all'), - u':/services/service_expand_all.png', - translate('OpenLP.ServiceManager', - 'Expand all the service items.'), - self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus]) - self.serviceManagerList.expand.setObjectName(u'expand') - action_list.add_action( - self.serviceManagerList.expand, unicode(UiStrings().Service)) + u'expand', text=translate('OpenLP.ServiceManager', '&Expand all'), + icon=u':/services/service_expand_all.png', tooltip=translate( + 'OpenLP.ServiceManager', 'Expand all the service items.'), + shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, + triggers=self.onExpandAll) self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', '&Collapse all'), - u':/services/service_collapse_all.png', - translate('OpenLP.ServiceManager', - 'Collapse all the service items.'), - self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) - self.serviceManagerList.collapse.setObjectName(u'collapse') - action_list.add_action( - self.serviceManagerList.collapse, unicode(UiStrings().Service)) + u'collapse', + text=translate('OpenLP.ServiceManager', '&Collapse all'), + icon=u':/services/service_collapse_all.png', tooltip=translate( + 'OpenLP.ServiceManager', 'Collapse all the service items.'), + shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, + triggers=self.onCollapseAll) self.orderToolbar.addSeparator() self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( - translate('OpenLP.ServiceManager', 'Go Live'), - u':/general/general_live.png', - translate('OpenLP.ServiceManager', - 'Send the selected item to Live.'), self.makeLive, - shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) - self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') - action_list.add_action( - self.serviceManagerList.makeLive, unicode(UiStrings().Service)) + u'makeLive', text=translate('OpenLP.ServiceManager', 'Go Live'), + icon=u':/general/general_live.png', tooltip=translate( + 'OpenLP.ServiceManager', 'Send the selected item to Live.'), + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], + category=UiStrings().Service, triggers=self.makeLive) self.layout.addWidget(self.orderToolbar) # Connect up our signals and slots QtCore.QObject.connect(self.themeComboBox, @@ -305,34 +284,32 @@ class ServiceManager(QtGui.QWidget): self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) # build the context menu self.menu = QtGui.QMenu() - self.editAction = context_menu_action( - self.menu, u':/general/general_edit.png', - translate('OpenLP.ServiceManager', '&Edit Item'), self.remoteEdit) - self.maintainAction = context_menu_action( - self.menu, u':/general/general_edit.png', - translate('OpenLP.ServiceManager', '&Reorder Item'), - self.onServiceItemEditForm) - self.notesAction = context_menu_action( - self.menu, u':/services/service_notes.png', - translate('OpenLP.ServiceManager', '&Notes'), - self.onServiceItemNoteForm) - self.timeAction = context_menu_action( - self.menu, u':/media/media_time.png', - translate('OpenLP.ServiceManager', '&Start Time'), - self.onStartTimeForm) - self.deleteAction = context_menu_action( - self.menu, u':/general/general_delete.png', - translate('OpenLP.ServiceManager', '&Delete From Service'), - self.onDeleteFromService) - context_menu_separator(self.menu) - self.previewAction = context_menu_action( - self.menu, u':/general/general_preview.png', - translate('OpenLP.ServiceManager', 'Show &Preview'), - self.makePreview) - self.liveAction = context_menu_action( - self.menu, u':/general/general_live.png', - translate('OpenLP.ServiceManager', 'Show &Live'), self.makeLive) - context_menu_separator(self.menu) + self.editAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', '&Edit Item'), + icon=u':/general/general_edit.png', triggers=self.remoteEdit) + self.maintainAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', '&Reorder Item'), + icon=u':/general/general_edit.png', + triggers=self.onServiceItemEditForm) + self.notesAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', '&Notes'), + icon=u':/services/service_notes.png', + triggers=self.onServiceItemNoteForm) + self.timeAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', '&Start Time'), + icon=u':/media/media_time.png', triggers=self.onStartTimeForm) + self.deleteAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', '&Delete From Service'), + icon=u':/general/general_delete.png', + triggers=self.onDeleteFromService) + self.menu.addSeparator() + self.previewAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', 'Show &Preview'), + icon=u':/general/general_preview.png', triggers=self.makePreview) + self.liveAction = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', 'Show &Live'), + icon=u':/general/general_live.png', triggers=self.makeLive) + self.menu.addSeparator() self.themeMenu = QtGui.QMenu( translate('OpenLP.ServiceManager', '&Change Item Theme')) self.menu.addMenu(self.themeMenu) @@ -1450,19 +1427,16 @@ class ServiceManager(QtGui.QWidget): themeGroup.setObjectName(u'themeGroup') # Create a "Default" theme, which allows the user to reset the item's # theme to the service theme or global theme. - defaultTheme = context_menu_action(self.themeMenu, None, - UiStrings().Default, self.onThemeChangeAction) - defaultTheme.setCheckable(True) + defaultTheme = create_widget_action(self.themeMenu, + text=UiStrings().Default, checked=False, + triggers=self.onThemeChangeAction) self.themeMenu.setDefaultAction(defaultTheme) themeGroup.addAction(defaultTheme) - context_menu_separator(self.themeMenu) + self.themeMenu.addSeparator() for theme in theme_list: self.themeComboBox.addItem(theme) - themeAction = context_menu_action(self.themeMenu, None, theme, - self.onThemeChangeAction) - themeAction.setObjectName(theme) - themeAction.setCheckable(True) - themeGroup.addAction(themeAction) + themeGroup.addAction(create_widget_action(self.themeMenu, theme, + text=theme, checked=False, triggers=self.onThemeChangeAction)) find_and_set_in_combo_box(self.themeComboBox, self.service_theme) self.mainwindow.renderer.set_service_theme(self.service_theme) self.regenerateServiceItems() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 182007acb..c4c3e5adb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -168,20 +168,18 @@ class SlideController(Controller): sizeToolbarPolicy.setHeightForWidth( self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(sizeToolbarPolicy) - self.previousItem = self.toolbar.addToolbarButton( - u'Previous Slide', - u':/slides/slide_previous.png', - translate('OpenLP.SlideController', 'Move to previous.'), - self.onSlideSelectedPrevious, + self.previousItem = self.toolbar.addToolbarButton(u'previousItem', + text=u'Previous Slide', icon=u':/slides/slide_previous.png', + tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.nextItem = self.toolbar.addToolbarButton( - u'Next Slide', - u':/slides/slide_next.png', - translate('OpenLP.SlideController', 'Move to next.'), - self.onSlideSelectedNext, + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.onSlideSelectedPrevious) + self.nextItem = self.toolbar.addToolbarButton(u'nextItem', + text=u'Next Slide', icon=u':/slides/slide_next.png', + tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], - context=QtCore.Qt.WidgetWithChildrenShortcut) + context=QtCore.Qt.WidgetWithChildrenShortcut, + triggers=self.onSlideSelectedNext) self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: # Hide Menu @@ -195,20 +193,17 @@ class SlideController(Controller): text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, shortcuts=[QtCore.Qt.Key_Period], - category=unicode(UiStrings().LiveToolbar), - triggers=self.onBlankDisplay) + category=UiStrings().LiveToolbar, triggers=self.onBlankDisplay) self.themeScreen = create_action(self.hideMenu, u'themeScreen', text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', checked=False, shortcuts=[QtGui.QKeySequence(u'T')], - category=unicode(UiStrings().LiveToolbar), - triggers=self.onThemeDisplay) + category=UiStrings().LiveToolbar, triggers=self.onThemeDisplay) self.desktopScreen = create_action(self.hideMenu, u'desktopScreen', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', checked=False, shortcuts=[QtGui.QKeySequence(u'D')], - category=unicode(UiStrings().LiveToolbar), - triggers=self.onHideDisplay) + category=UiStrings().LiveToolbar, triggers=self.onHideDisplay) self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) @@ -227,12 +222,12 @@ class SlideController(Controller): self.playSlidesLoop = create_action(self.playSlidesMenu, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=unicode(UiStrings().LiveToolbar), + category=UiStrings().LiveToolbar, triggers=self.onPlaySlidesLoop) self.playSlidesOnce = create_action(self.playSlidesMenu, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=unicode(UiStrings().LiveToolbar), + category=UiStrings().LiveToolbar, triggers=self.onPlaySlidesOnce) if QtCore.QSettings().value(self.parent().generalSettingsSection + u'/enable slide loop', QtCore.QVariant(True)).toBool(): @@ -249,23 +244,22 @@ class SlideController(Controller): self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds.')) else: - self.toolbar.addToolbarButton( + self.toolbar.addToolbarButton(u'goLive', # Does not need translating - control string. - u'Go Live', u':/general/general_live.png', - translate('OpenLP.SlideController', 'Move to live.'), - self.onGoLive) - self.toolbar.addToolbarButton( + text=u'Go Live', icon=u':/general/general_live.png', + tooltip=translate('OpenLP.SlideController', 'Move to live.'), + triggers=self.onGoLive) + self.toolbar.addToolbarButton(u'addToService', # Does not need translating - control string. - u'Add to Service', u':/general/general_add.png', - translate('OpenLP.SlideController', 'Add to Service.'), - self.onPreviewAddToService) + text=u'Add to Service', icon=u':/general/general_add.png', + tooltip=translate('OpenLP.SlideController', 'Add to Service.'), + triggers=self.onPreviewAddToService) self.toolbar.addToolbarSeparator(u'Close Separator') - self.toolbar.addToolbarButton( + self.toolbar.addToolbarButton(u'editSong', # Does not need translating - control string. - u'Edit Song', u':/general/general_edit.png', - translate('OpenLP.SlideController', - 'Edit and reload song preview.'), - self.onEditSong) + text=u'Edit Song', icon=u':/general/general_edit.png', + tooltip=translate('OpenLP.SlideController', + 'Edit and reload song preview.'), triggers=self.onEditSong) self.controllerLayout.addWidget(self.toolbar) # Build the Media Toolbar self.mediaController.add_controller_items(self, self.controllerLayout) @@ -279,11 +273,11 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Go To'), self.toolbar)) self.toolbar.makeWidgetsInvisible([u'Song Menu']) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarButton( - u'Pause Audio', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Pause audio.'), - self.onAudioPauseClicked, True) - self.audioPauseItem.setVisible(False) + self.audioPauseItem = self.toolbar.addToolbarButton(u'audioPause', + text=u'Pause Audio', icon=u':/slides/media_playback_pause.png', + tooltip=translate('OpenLP.SlideController', 'Pause audio.'), + checked=False, visible=False, + triggers=self.onAudioPauseClicked) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -348,7 +342,7 @@ class SlideController(Controller): u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), shortcuts=[QtGui.QKeySequence(s[u'key'])], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar) \ + category=UiStrings().LiveToolbar \ if s.get(u'configurable') else None, triggers=self._slideShortcutActivated) for s in shortcuts]) QtCore.QObject.connect( @@ -492,20 +486,17 @@ class SlideController(Controller): text=translate('OpenLP.SlideController', 'Previous Service'), shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.servicePrevious) + category=UiStrings().LiveToolbar, triggers=self.servicePrevious) self.nextService = create_action(parent, 'nextService', text=translate('OpenLP.SlideController', 'Next Service'), shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.serviceNext) + category=UiStrings().LiveToolbar, triggers=self.serviceNext) self.escapeItem = create_action(parent, 'escapeItem', text=translate('OpenLP.SlideController', 'Escape Item'), shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=unicode(UiStrings().LiveToolbar), - triggers=self.liveEscape) + category=UiStrings().LiveToolbar, triggers=self.liveEscape) def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 8b2524845..62d1a7d94 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -41,7 +41,7 @@ from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \ from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \ BackgroundGradientType from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ - context_menu_action, context_menu_separator + create_widget_action from openlp.core.theme import Theme from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding @@ -64,32 +64,32 @@ class ThemeManager(QtGui.QWidget): self.layout.setMargin(0) self.layout.setObjectName(u'layout') self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarButton(UiStrings().NewTheme, - u':/themes/theme_new.png', - translate('OpenLP.ThemeManager', 'Create a new theme.'), - self.onAddTheme) - self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Edit Theme'), - u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', 'Edit a theme.'), - self.onEditTheme) - self.deleteToolbarAction = self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Delete Theme'), - u':/general/general_delete.png', - translate('OpenLP.ThemeManager', 'Delete a theme.'), - self.onDeleteTheme) - self.toolbar.addSeparator() - self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Import Theme'), - u':/general/general_import.png', - translate('OpenLP.ThemeManager', 'Import a theme.'), - self.onImportTheme) - self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Export Theme'), - u':/general/general_export.png', - translate('OpenLP.ThemeManager', 'Export a theme.'), - self.onExportTheme) self.toolbar.setObjectName(u'toolbar') + self.toolbar.addToolbarButton(u'newTheme', + text=UiStrings().NewTheme, icon=u':/themes/theme_new.png', + tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'), + triggers=self.onAddTheme) + self.toolbar.addToolbarButton(u'editTheme', + text=translate('OpenLP.ThemeManager', 'Edit Theme'), + icon=u':/themes/theme_edit.png', + tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'), + triggers=self.onEditTheme) + self.deleteToolbarAction = self.toolbar.addToolbarButton(u'deleteTheme', + text=translate('OpenLP.ThemeManager', 'Delete Theme'), + icon=u':/general/general_delete.png', + tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'), + triggers=self.onDeleteTheme) + self.toolbar.addSeparator() + self.toolbar.addToolbarButton(u'importTheme', + text=translate('OpenLP.ThemeManager', 'Import Theme'), + icon=u':/general/general_import.png', + tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'), + triggers=self.onImportTheme) + self.toolbar.addToolbarButton(u'exportTheme', + text=translate('OpenLP.ThemeManager', 'Export Theme'), + icon=u':/general/general_export.png', + tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'), + triggers=self.onExportTheme) self.layout.addWidget(self.toolbar) self.themeWidget = QtGui.QWidgetAction(self.toolbar) self.themeWidget.setObjectName(u'themeWidget') @@ -105,29 +105,26 @@ class ThemeManager(QtGui.QWidget): self.contextMenu) # build the context menu self.menu = QtGui.QMenu() - self.editAction = context_menu_action( - self.menu, u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Edit Theme'), self.onEditTheme) - self.copyAction = context_menu_action( - self.menu, u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Copy Theme'), self.onCopyTheme) - self.renameAction = context_menu_action( - self.menu, u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Rename Theme'), - self.onRenameTheme) - self.deleteAction = context_menu_action( - self.menu, u':/general/general_delete.png', - translate('OpenLP.ThemeManager', '&Delete Theme'), - self.onDeleteTheme) - context_menu_separator(self.menu) - self.globalAction = context_menu_action( - self.menu, u':/general/general_export.png', - translate('OpenLP.ThemeManager', 'Set As &Global Default'), - self.changeGlobalFromScreen) - self.exportAction = context_menu_action( - self.menu, u':/general/general_export.png', - translate('OpenLP.ThemeManager', '&Export Theme'), - self.onExportTheme) + self.editAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', '&Edit Theme'), + icon=u':/themes/theme_edit.png', triggers=self.onEditTheme) + self.copyAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', '&Copy Theme'), + icon=u':/themes/theme_edit.png', triggers=self.onCopyTheme) + self.renameAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', '&Rename Theme'), + icon=u':/themes/theme_edit.png', triggers=self.onRenameTheme) + self.deleteAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', '&Delete Theme'), + icon=u':/general/general_delete.png', triggers=self.onDeleteTheme) + self.menu.addSeparator() + self.globalAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', 'Set As &Global Default'), + icon=u':/general/general_export.png', + triggers=self.changeGlobalFromScreen) + self.exportAction = create_widget_action(self.menu, + text=translate('OpenLP.ThemeManager', '&Export Theme'), + icon=u':/general/general_export.png', triggers=self.onExportTheme) # Signals QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 92779b991..c7b6829bb 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -89,11 +89,11 @@ class ImageMediaItem(MediaManagerItem): self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): - self.replaceAction = self.addToolbarButton(u'', u'', - u':/slides/slide_blank.png', self.onReplaceClick, False) - self.resetAction = self.addToolbarButton(u'', u'', - u':/system/system_close.png', self.onResetClick, False) - self.resetAction.setVisible(False) + self.replaceAction = self.addToolbarButton(u'replaceAction', + icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) + self.resetAction = self.addToolbarButton(u'resetAction', + icon=u':/system/system_close.png', visible=False, + triggers=self.onResetClick) def onDeleteClick(self): """ diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 111a86209..6199903de 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -118,11 +118,11 @@ class MediaMediaItem(MediaManagerItem): def addEndHeaderBar(self): # Replace backgrounds do not work at present so remove functionality. - self.replaceAction = self.addToolbarButton(u'', u'', - u':/slides/slide_blank.png', self.onReplaceClick, False) - self.resetAction = self.addToolbarButton(u'', u'', - u':/system/system_close.png', self.onResetClick, False) - self.resetAction.setVisible(False) + self.replaceAction = self.addToolbarButton(u'replaceAction', + icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) + self.resetAction = self.addToolbarButton(u'resetAction', + icon=u':/system/system_close.png', visible=False, + triggers=self.onResetClick) self.mediaWidget = QtGui.QWidget(self) self.mediaWidget.setObjectName(u'mediaWidget') self.displayLayout = QtGui.QFormLayout(self.mediaWidget) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ab95d794f..b01acdb89 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -36,8 +36,7 @@ from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ translate, check_item_selected, PluginStatus, create_separated_list -from openlp.core.lib.ui import UiStrings, context_menu_action, \ - context_menu_separator +from openlp.core.lib.ui import UiStrings, create_action, create_widget_action from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm @@ -100,8 +99,9 @@ class SongMediaItem(MediaManagerItem): def addEndHeaderBar(self): self.addToolbarSeparator() ## Song Maintenance Button ## - self.maintenanceAction = self.addToolbarButton(u'', u'', - ':/songs/song_maintenance.png', self.onSongMaintenanceClick) + self.maintenanceAction = self.addToolbarButton(u'maintenanceAction', + icon=':/songs/song_maintenance.png', + triggers=self.onSongMaintenanceClick) self.addSearchToToolBar() # Signals and slots QtCore.QObject.connect(Receiver.get_receiver(), @@ -121,11 +121,10 @@ class SongMediaItem(MediaManagerItem): self.onSearchTextButtonClick) def addCustomContextActions(self): - context_menu_separator(self.listView) - context_menu_action( - self.listView, u':/general/general_clone.png', - translate('OpenLP.MediaManagerItem', - '&Clone'), self.onCloneClick) + create_widget_action(self.listView, separator=True) + create_widget_action(self.listView, + text=translate('OpenLP.MediaManagerItem', '&Clone'), + icon=u':/general/general_clone.png', triggers=self.onCloneClick) def onFocus(self): self.searchTextEdit.setFocus() From 45de016abbac6d70cba4a6a53c5b2fac4d9ae639 Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 2 Mar 2012 13:11:13 +0100 Subject: [PATCH 29/46] derive OpenLPToolbar().actions keys from object names to prevent collisions in case translators translate different strings same. --- openlp/core/lib/toolbar.py | 66 ++++++++---------------- openlp/core/ui/media/mediacontroller.py | 10 ++-- openlp/core/ui/servicemanager.py | 13 ++--- openlp/core/ui/slidecontroller.py | 68 ++++++++++++------------- 4 files changed, 63 insertions(+), 94 deletions(-) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 4fae1aebd..8b50081db 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -47,76 +47,50 @@ class OpenLPToolbar(QtGui.QToolBar): """ QtGui.QToolBar.__init__(self, parent) # useful to be able to reuse button icons... - self.icons = {} self.setIconSize(QtCore.QSize(20, 20)) self.actions = {} log.debug(u'Init done for %s' % parent.__class__.__name__) def addToolbarButton(self, name, **kwargs): """ - A method to help developers easily add a button to the toolbar. A new - QAction is created by calling ``create_action()``. The action is added - to the toolbar and the toolbar is set as parent. For more details please - look at openlp.core.lib.ui.create_action() + A method to help developers easily add a button to the toolbar. + A new QAction is created by calling ``create_action()``. The action is + added to the toolbar and the toolbar is set as parent. + For more details please look at openlp.core.lib.ui.create_action() """ action = create_widget_action(self, name, **kwargs) - # The ObjectNames should be used as keys. So translators can't break - # anything. - title = kwargs.get(u'text', u'') - self.actions[title] = action - if u'icon' in kwargs: - self.icons[title] = action.icon() + self.actions[name] = action return action def addToolbarSeparator(self, handle): """ - Add a Separator bar to the toolbar and store it's Handle + Add a separator bar and store it's handle. """ action = self.addSeparator() self.actions[handle] = action - def addToolbarWidget(self, handle, widget): + def addToolbarWidget(self, widget): """ - Add a Widget to the toolbar and store it's Handle + Add a widget and store it's handle under the widgets object name. """ action = self.addWidget(widget) - self.actions[handle] = action + self.actions[unicode(widget.objectName())] = action - def getIconFromTitle(self, title): + def setWidgetVisible(self, widgets, visible=True): """ - Search through the list of icons for an icon with a particular title, - and return that icon. + Set the visibitity for a widget or a list of widgets. - ``title`` - The title of the icon to search for. - """ - title = QtCore.QString(title) - try: - if self.icons[title]: - return self.icons[title] - except KeyError: - log.exception(u'getIconFromTitle - no icon for %s' % title) - return QtGui.QIcon() + ``widget`` + A list of string with widget object names. - def makeWidgetsInvisible(self, widgets): + ``visible`` + The new state as bool. """ - Hide a set of widgets. - - ``widgets`` - The list of names of widgets to be hidden. - """ - for widget in widgets: - self.actions[widget].setVisible(False) - - def makeWidgetsVisible(self, widgets): - """ - Show a set of widgets. - - ``widgets`` - The list of names of widgets to be shown. - """ - for widget in widgets: - self.actions[widget].setVisible(True) + for handle in widgets: + if handle in self.actions: + self.actions[handle].setVisible(visible) + else: + log.warn(u'No handle "%s" in actions list.', unicode(handle)) def addPushButton(self, image_file=None, text=u''): """ diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 3bb9da6a0..ba9d5a6e5 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -226,9 +226,8 @@ class MediaController(object): controller.seekSlider.setToolTip(translate( '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.seekSlider) + controller.seekSlider.setObjectName(u'seekSlider') + controller.mediabar.addToolbarWidget(controller.seekSlider) # Build the volumeSlider. controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) controller.volumeSlider.setTickInterval(10) @@ -240,9 +239,8 @@ class MediaController(object): 'OpenLP.SlideController', 'Audio Volume.')) 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.volumeSlider) + controller.volumeSlider.setObjectName(u'volumeSlider') + controller.mediabar.addToolbarWidget(controller.volumeSlider) control_panel.addWidget(controller.mediabar) controller.mediabar.setVisible(False) # Signals diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 03fad5dae..593806079 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -133,7 +133,7 @@ class ServiceManager(QtGui.QWidget): self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) self.themeLabel.setMargin(3) self.themeLabel.setObjectName(u'themeLabel') - self.toolbar.addToolbarWidget(u'ThemeLabel', self.themeLabel) + self.toolbar.addToolbarWidget(self.themeLabel) self.themeComboBox = QtGui.QComboBox(self.toolbar) self.themeComboBox.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) @@ -142,7 +142,7 @@ class ServiceManager(QtGui.QWidget): self.themeComboBox.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) self.themeComboBox.setObjectName(u'themeComboBox') - self.toolbar.addToolbarWidget(u'ThemeWidget', self.themeComboBox) + self.toolbar.addToolbarWidget(self.themeComboBox) self.toolbar.setObjectName(u'toolbar') self.layout.addWidget(self.toolbar) # Create the service manager list @@ -1120,12 +1120,9 @@ class ServiceManager(QtGui.QWidget): sure the theme combo box is in the correct state. """ log.debug(u'themeChange') - if self.mainwindow.renderer.theme_level == ThemeLevel.Global: - self.toolbar.actions[u'ThemeLabel'].setVisible(False) - self.toolbar.actions[u'ThemeWidget'].setVisible(False) - else: - self.toolbar.actions[u'ThemeLabel'].setVisible(True) - self.toolbar.actions[u'ThemeWidget'].setVisible(True) + visible = self.mainwindow.renderer.theme_level == ThemeLevel.Global + self.themeLabel.setVisible(visible) + self.themeComboBox.setVisible(visible) def regenerateServiceItems(self): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c4c3e5adb..e0ea398bb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -91,16 +91,16 @@ class SlideController(Controller): self.imageManager = self.parent().imageManager self.mediaController = self.parent().mediaController self.loopList = [ - u'Play Slides Menu', - u'Loop Separator', - u'Image SpinBox' + u'playSlidesMenu', + u'loopSeparator', + u'delaySpinBox' ] self.songEditList = [ - u'Edit Song', + u'editSong', ] self.nextPreviousList = [ - u'Previous Slide', - u'Next Slide' + u'previousItem', + u'nextItem' ] self.timer_id = 0 self.songEdit = False @@ -169,13 +169,13 @@ class SlideController(Controller): self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(sizeToolbarPolicy) self.previousItem = self.toolbar.addToolbarButton(u'previousItem', - text=u'Previous Slide', icon=u':/slides/slide_previous.png', + icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, triggers=self.onSlideSelectedPrevious) self.nextItem = self.toolbar.addToolbarButton(u'nextItem', - text=u'Next Slide', icon=u':/slides/slide_next.png', + icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, @@ -184,11 +184,12 @@ class SlideController(Controller): if self.isLive: # Hide Menu self.hideMenu = QtGui.QToolButton(self.toolbar) + self.hideMenu.setObjectName(u'hideMenu') self.hideMenu.setText(translate('OpenLP.SlideController', 'Hide')) self.hideMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) - self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu) self.hideMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Hide'), self.toolbar)) + self.toolbar.addToolbarWidget(self.hideMenu) self.blankScreen = create_action(self.hideMenu, u'blankScreen', text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, @@ -208,17 +209,17 @@ class SlideController(Controller): self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) - self.toolbar.addToolbarSeparator(u'Loop Separator') + self.toolbar.addToolbarSeparator(u'loopSeparator') # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) + self.playSlidesMenu.setObjectName(u'playSlidesMenu') self.playSlidesMenu.setText(translate('OpenLP.SlideController', 'Play Slides')) self.playSlidesMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) - self.toolbar.addToolbarWidget(u'Play Slides Menu', - self.playSlidesMenu) self.playSlidesMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) + self.toolbar.addToolbarWidget(self.playSlidesMenu) self.playSlidesLoop = create_action(self.playSlidesMenu, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, shortcuts=[], @@ -238,26 +239,24 @@ class SlideController(Controller): self.playSlidesMenu.menu().addAction(self.playSlidesOnce) # Loop Delay Spinbox self.delaySpinBox = QtGui.QSpinBox() + self.delaySpinBox.setObjectName(u'delaySpinBox') self.delaySpinBox.setRange(1, 180) - self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox) self.delaySpinBox.setSuffix(UiStrings().Seconds) self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds.')) + self.toolbar.addToolbarWidget(self.delaySpinBox) else: self.toolbar.addToolbarButton(u'goLive', - # Does not need translating - control string. - text=u'Go Live', icon=u':/general/general_live.png', + icon=u':/general/general_live.png', tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.onGoLive) self.toolbar.addToolbarButton(u'addToService', - # Does not need translating - control string. - text=u'Add to Service', icon=u':/general/general_add.png', + icon=u':/general/general_add.png', tooltip=translate('OpenLP.SlideController', 'Add to Service.'), triggers=self.onPreviewAddToService) self.toolbar.addToolbarSeparator(u'Close Separator') self.toolbar.addToolbarButton(u'editSong', - # Does not need translating - control string. - text=u'Edit Song', icon=u':/general/general_edit.png', + icon=u':/general/general_edit.png', tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong) self.controllerLayout.addWidget(self.toolbar) @@ -266,12 +265,13 @@ class SlideController(Controller): if self.isLive: # Build the Song Toolbar self.songMenu = QtGui.QToolButton(self.toolbar) + self.songMenu.setObjectName(u'songMenu') self.songMenu.setText(translate('OpenLP.SlideController', 'Go To')) self.songMenu.setPopupMode(QtGui.QToolButton.InstantPopup) - self.toolbar.addToolbarWidget(u'Song Menu', self.songMenu) self.songMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Go To'), self.toolbar)) - self.toolbar.makeWidgetsInvisible([u'Song Menu']) + self.songMenu.hide() + self.toolbar.addToolbarWidget(self.songMenu) # Stuff for items with background audio. self.audioPauseItem = self.toolbar.addToolbarButton(u'audioPause', text=u'Pause Audio', icon=u':/slides/media_playback_pause.png', @@ -358,12 +358,12 @@ class SlideController(Controller): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_toggle_display'), self.toggleDisplay) - self.toolbar.makeWidgetsInvisible(self.loopList) + self.toolbar.setWidgetVisible(self.loopList, False) else: QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onGoLiveClick) - self.toolbar.makeWidgetsInvisible(self.songEditList) + self.toolbar.setWidgetVisible(self.songEditList, False) if self.isLive: self.setLiveHotkeys(self) self.__addActionsToWidget(self.previewListWidget) @@ -661,9 +661,9 @@ class SlideController(Controller): # Work-around for OS X, hide and then show the toolbar # See bug #791050 self.toolbar.hide() - self.mediabar.setVisible(False) - self.toolbar.makeWidgetsInvisible([u'Song Menu']) - self.toolbar.makeWidgetsInvisible(self.loopList) + self.mediabar.hide() + self.songMenu.hide() + self.toolbar.setWidgetVisible(self.loopList, False) # Reset the button self.playSlidesOnce.setChecked(False) self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png')) @@ -673,17 +673,17 @@ class SlideController(Controller): if QtCore.QSettings().value( self.parent().songsSettingsSection + u'/display songbar', QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: - self.toolbar.makeWidgetsVisible([u'Song Menu']) + self.songMenu.show() if item.is_capable(ItemCapabilities.CanLoop) and \ len(item.get_frames()) > 1: - self.toolbar.makeWidgetsVisible(self.loopList) + self.toolbar.setWidgetVisible(self.loopList) if item.is_media(): self.mediabar.setVisible(True) - self.toolbar.makeWidgetsInvisible(self.nextPreviousList) + self.toolbar.setWidgetVisible(self.nextPreviousList, False) else: # Work-around for OS X, hide and then show the toolbar # See bug #791050 - self.toolbar.makeWidgetsVisible(self.nextPreviousList) + self.toolbar.setWidgetVisible(self.nextPreviousList) self.toolbar.show() def enablePreviewToolBar(self, item): @@ -694,16 +694,16 @@ class SlideController(Controller): # See bug #791050 self.toolbar.hide() self.mediabar.setVisible(False) - self.toolbar.makeWidgetsInvisible(self.songEditList) + self.toolbar.setWidgetVisible(self.songEditList, False) if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin: - self.toolbar.makeWidgetsVisible(self.songEditList) + self.toolbar.setWidgetVisible(self.songEditList) elif item.is_media(): self.mediabar.setVisible(True) - self.toolbar.makeWidgetsInvisible(self.nextPreviousList) + self.toolbar.setWidgetVisible(self.nextPreviousList, False) if not item.is_media(): # Work-around for OS X, hide and then show the toolbar # See bug #791050 - self.toolbar.makeWidgetsVisible(self.nextPreviousList) + self.toolbar.setWidgetVisible(self.nextPreviousList) self.toolbar.show() def refreshServiceItem(self): From 87e70fa2dcb953ad6db2fa91f83841cee15d5cbf Mon Sep 17 00:00:00 2001 From: rimach Date: Sat, 3 Mar 2012 00:08:24 +0100 Subject: [PATCH 30/46] fix --- openlp/core/ui/media/mediacontroller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 9c44f1693..6ef7185bc 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -100,8 +100,7 @@ class MediaController(object): Register each media Player controller (Webkit, Phonon, etc) and store for later use """ - if controller.check_available(): - self.mediaPlayers[controller.name] = controller + self.mediaPlayers[controller.name] = controller def check_available_media_players(self): """ @@ -134,7 +133,8 @@ class MediaController(object): QtCore.QVariant(u'webkit')).toString()) savedPlayers = playerSettings.split(u',') invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ - if not mediaPlayer in self.mediaPlayers] + if not mediaPlayer in self.mediaPlayers or \ + self.mediaPlayers[mediaPlayer].check_available() == False] if len(invalidMediaPlayers) > 0: for invalidPlayer in invalidMediaPlayers: savedPlayers.remove(invalidPlayer) From 0b15238245d19fb5dbebd11c786e1e3a556d00ac Mon Sep 17 00:00:00 2001 From: Samuel Findlay Date: Sat, 3 Mar 2012 16:13:48 +1100 Subject: [PATCH 31/46] fixed bug #944510 'web remote doesn't scale to screen' Fixes: https://launchpad.net/bugs/944510 --- openlp/plugins/remotes/html/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index fb88ee0dc..7a2da3bea 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -27,6 +27,7 @@ --> + ${app_title} From 277de83b683455971cc65fc94d8652e7c9b7e13c Mon Sep 17 00:00:00 2001 From: M2j Date: Sat, 3 Mar 2012 14:38:20 +0100 Subject: [PATCH 32/46] Bug #943919: Make shortcuts for "Move to Previous/Next" in live slide controller configurable. --- openlp/core/lib/mediamanageritem.py | 19 ++----- openlp/core/lib/toolbar.py | 22 +------- openlp/core/ui/media/mediacontroller.py | 6 +-- openlp/core/ui/servicemanager.py | 26 +++++----- openlp/core/ui/slidecontroller.py | 69 +++++++++++-------------- openlp/core/ui/thememanager.py | 10 ++-- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 4 +- openlp/plugins/songs/lib/mediaitem.py | 6 +-- 10 files changed, 63 insertions(+), 105 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 992286686..cb77f45ad 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -147,20 +147,6 @@ class MediaManagerItem(QtGui.QWidget): self.toolbar = OpenLPToolbar(self) self.pageLayout.addWidget(self.toolbar) - def addToolbarButton(self, name, **kwargs): - """ - A method to help developers easily add a button to the toolbar. For - details please have a look at OpenLPToolbar.addToolbarButton() and - openlp.core.lib.ui.create_action(). - """ - return self.toolbar.addToolbarButton(name, **kwargs) - - def addToolbarSeparator(self): - """ - A very simple method to add a separator to the toolbar. - """ - self.toolbar.addSeparator() - def setupUi(self): """ This method sets up the interface on the button. Plugin @@ -214,8 +200,9 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_add.png', self.onAddClick]) for action in toolbar_actions: if action[0] == StringContent.Preview: - self.addToolbarSeparator() - self.addToolbarButton(u'%s%sAction' % (self.plugin.name, action[0]), + self.toolbar.addSeparator() + self.toolbar.addToolbarAction( + u'%s%sAction' % (self.plugin.name, action[0]), text=self.plugin.getString(action[1])[u'title'], icon=action[2], tooltip=self.plugin.getString(action[1])[u'tooltip'], triggers=action[3]) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 8b50081db..0fc693041 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -51,7 +51,7 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions = {} log.debug(u'Init done for %s' % parent.__class__.__name__) - def addToolbarButton(self, name, **kwargs): + def addToolbarAction(self, name, **kwargs): """ A method to help developers easily add a button to the toolbar. A new QAction is created by calling ``create_action()``. The action is @@ -62,13 +62,6 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions[name] = action return action - def addToolbarSeparator(self, handle): - """ - Add a separator bar and store it's handle. - """ - action = self.addSeparator() - self.actions[handle] = action - def addToolbarWidget(self, widget): """ Add a widget and store it's handle under the widgets object name. @@ -88,18 +81,7 @@ class OpenLPToolbar(QtGui.QToolBar): """ for handle in widgets: if handle in self.actions: - self.actions[handle].setVisible(visible) + self.actions[handle].setVisible(visible) else: log.warn(u'No handle "%s" in actions list.', unicode(handle)) - def addPushButton(self, image_file=None, text=u''): - """ - Adds a push button to the toolbar. - - Returns the push button - """ - push_button = QtGui.QPushButton(build_icon(image_file), text) - push_button.setCheckable(True) - push_button.setFlat(True) - self.addWidget(push_button) - return push_button diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index ba9d5a6e5..b28497906 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -204,17 +204,17 @@ class MediaController(object): controller.media_info = MediaInfo() # Build a Media ToolBar controller.mediabar = OpenLPToolbar(controller) - controller.mediabar.addToolbarButton(u'playbackPlay', + controller.mediabar.addToolbarAction(u'playbackPlay', text=u'media_playback_play', icon=u':/slides/media_playback_start.png', tooltip=translate('OpenLP.SlideController', 'Start playing media.'), triggers=controller.sendToPlugins) - controller.mediabar.addToolbarButton(u'playbackPause', + controller.mediabar.addToolbarAction(u'playbackPause', text=u'media_playback_pause', icon=u':/slides/media_playback_pause.png', tooltip=translate('OpenLP.SlideController', 'Pause playing media.'), triggers=controller.sendToPlugins) - controller.mediabar.addToolbarButton(u'playbackStop', + controller.mediabar.addToolbarAction(u'playbackStop', text=u'media_playback_stop', icon=u':/slides/media_playback_stop.png', tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 593806079..033558ca6 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -117,15 +117,15 @@ class ServiceManager(QtGui.QWidget): self.layout.setMargin(0) # Create the top toolbar self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarButton(u'newService', + self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', tooltip=UiStrings().CreateService, triggers=self.onNewServiceClicked) - self.toolbar.addToolbarButton(u'openService', + self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.onLoadServiceClicked) - self.toolbar.addToolbarButton(u'saveService', + self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.saveFile) @@ -172,47 +172,47 @@ class ServiceManager(QtGui.QWidget): action_list = ActionList.get_instance() action_list.add_category( unicode(UiStrings().Service), CategoryOrder.standardToolbar) - self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction( u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item to the top of the service.'), shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) - self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction( u'moveUp', text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item up one position in the service.'), shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) - self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction( u'moveDown', text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) - self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction( u'moveBottom', text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item to the end of the service.'), shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) - self.serviceManagerList.down = self.orderToolbar.addToolbarButton( + self.serviceManagerList.down = self.orderToolbar.addToolbarAction( u'down', text=translate('OpenLP.ServiceManager', 'Move &down'), tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Down], triggers=self.onMoveSelectionDown) action_list.add_action(self.serviceManagerList.down) - self.serviceManagerList.up = self.orderToolbar.addToolbarButton( + self.serviceManagerList.up = self.orderToolbar.addToolbarAction( u'up', text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], triggers=self.onMoveSelectionUp) action_list.add_action(self.serviceManagerList.up) self.orderToolbar.addSeparator() - self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( + self.serviceManagerList.delete = self.orderToolbar.addToolbarAction( u'delete', text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', @@ -220,13 +220,13 @@ class ServiceManager(QtGui.QWidget): 'Delete the selected item from the service.'), triggers=self.onDeleteFromService) self.orderToolbar.addSeparator() - self.serviceManagerList.expand = self.orderToolbar.addToolbarButton( + self.serviceManagerList.expand = self.orderToolbar.addToolbarAction( u'expand', text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', tooltip=translate( 'OpenLP.ServiceManager', 'Expand all the service items.'), shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) - self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( + self.serviceManagerList.collapse = self.orderToolbar.addToolbarAction( u'collapse', text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', tooltip=translate( @@ -234,7 +234,7 @@ class ServiceManager(QtGui.QWidget): shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) self.orderToolbar.addSeparator() - self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( + self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction( u'makeLive', text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', tooltip=translate( 'OpenLP.ServiceManager', 'Send the selected item to Live.'), diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e0ea398bb..d0f645494 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -122,10 +122,14 @@ class SlideController(Controller): self.typePrefix = u'live' self.keypress_queue = deque() self.keypress_loop = False + self.category = UiStrings().LiveToolbar + ActionList.get_instance().add_category( + unicode(self.category, CategoryOrder.standardToolbar) else: self.typeLabel.setText(UiStrings().Preview) self.split = 0 self.typePrefix = u'preview' + self.category = None self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;') self.typeLabel.setAlignment(QtCore.Qt.AlignCenter) self.panelLayout.addWidget(self.typeLabel) @@ -168,19 +172,23 @@ class SlideController(Controller): sizeToolbarPolicy.setHeightForWidth( self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(sizeToolbarPolicy) - self.previousItem = self.toolbar.addToolbarButton(u'previousItem', + self.previousItem = self.toolbar.addToolbarAction( + u'previousItem_' + self.typePrefix, + text=translate('OpenLP.SlideController', 'Previous Item'), icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.onSlideSelectedPrevious) - self.nextItem = self.toolbar.addToolbarButton(u'nextItem', + category=self.category, triggers=self.onSlideSelectedPrevious) + self.nextItem = self.toolbar.addToolbarAction( + u'nextItem_' + self.typePrefix, + text=translate('OpenLP.SlideController', 'Next Item'), icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.onSlideSelectedNext) - self.toolbar.addToolbarSeparator(u'Close Separator') + category=self.category, triggers=self.onSlideSelectedNext) + self.toolbar.addSeparator() if self.isLive: # Hide Menu self.hideMenu = QtGui.QToolButton(self.toolbar) @@ -194,22 +202,22 @@ class SlideController(Controller): text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, shortcuts=[QtCore.Qt.Key_Period], - category=UiStrings().LiveToolbar, triggers=self.onBlankDisplay) + category=self.category, triggers=self.onBlankDisplay) self.themeScreen = create_action(self.hideMenu, u'themeScreen', text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', checked=False, shortcuts=[QtGui.QKeySequence(u'T')], - category=UiStrings().LiveToolbar, triggers=self.onThemeDisplay) + category=self.category, triggers=self.onThemeDisplay) self.desktopScreen = create_action(self.hideMenu, u'desktopScreen', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', checked=False, shortcuts=[QtGui.QKeySequence(u'D')], - category=UiStrings().LiveToolbar, triggers=self.onHideDisplay) + category=self.category, triggers=self.onHideDisplay) self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) - self.toolbar.addToolbarSeparator(u'loopSeparator') + self.toolbar.addToolbarAction(u'loopSeparator', separator=True) # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) self.playSlidesMenu.setObjectName(u'playSlidesMenu') @@ -223,13 +231,11 @@ class SlideController(Controller): self.playSlidesLoop = create_action(self.playSlidesMenu, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=UiStrings().LiveToolbar, - triggers=self.onPlaySlidesLoop) + category=self.category, triggers=self.onPlaySlidesLoop) self.playSlidesOnce = create_action(self.playSlidesMenu, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=UiStrings().LiveToolbar, - triggers=self.onPlaySlidesOnce) + category=self.category, triggers=self.onPlaySlidesOnce) if QtCore.QSettings().value(self.parent().generalSettingsSection + u'/enable slide loop', QtCore.QVariant(True)).toBool(): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) @@ -246,16 +252,16 @@ class SlideController(Controller): 'Delay between slides in seconds.')) self.toolbar.addToolbarWidget(self.delaySpinBox) else: - self.toolbar.addToolbarButton(u'goLive', + self.toolbar.addToolbarAction(u'goLive', icon=u':/general/general_live.png', tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.onGoLive) - self.toolbar.addToolbarButton(u'addToService', + self.toolbar.addToolbarAction(u'addToService', icon=u':/general/general_add.png', tooltip=translate('OpenLP.SlideController', 'Add to Service.'), triggers=self.onPreviewAddToService) - self.toolbar.addToolbarSeparator(u'Close Separator') - self.toolbar.addToolbarButton(u'editSong', + self.toolbar.addSeparator() + self.toolbar.addToolbarAction(u'editSong', icon=u':/general/general_edit.png', tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong) @@ -273,7 +279,7 @@ class SlideController(Controller): self.songMenu.hide() self.toolbar.addToolbarWidget(self.songMenu) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarButton(u'audioPause', + self.audioPauseItem = self.toolbar.addToolbarAction(u'audioPause', text=u'Pause Audio', icon=u':/slides/media_playback_pause.png', tooltip=translate('OpenLP.SlideController', 'Pause audio.'), checked=False, visible=False, @@ -342,8 +348,7 @@ class SlideController(Controller): u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), shortcuts=[QtGui.QKeySequence(s[u'key'])], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar \ - if s.get(u'configurable') else None, + category=self.category if s.get(u'configurable') else None, triggers=self._slideShortcutActivated) for s in shortcuts]) QtCore.QObject.connect( self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), @@ -368,10 +373,8 @@ class SlideController(Controller): self.setLiveHotkeys(self) self.__addActionsToWidget(self.previewListWidget) else: - self.setPreviewHotkeys() self.previewListWidget.addActions( - [self.nextItem, - self.previousItem]) + [self.nextItem, self.previousItem]) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop) @@ -467,36 +470,22 @@ class SlideController(Controller): # Reset the shortcut. self.current_shortcut = u'' - def setPreviewHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemPreview') - self.nextItem.setObjectName(u'nextItemPreview') - action_list = ActionList.get_instance() - action_list.add_action(self.previousItem) - action_list.add_action(self.nextItem) - def setLiveHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemLive') - self.nextItem.setObjectName(u'nextItemLive') - action_list = ActionList.get_instance() - action_list.add_category( - unicode(UiStrings().LiveToolbar), CategoryOrder.standardToolbar) - action_list.add_action(self.previousItem) - action_list.add_action(self.nextItem) self.previousService = create_action(parent, u'previousService', text=translate('OpenLP.SlideController', 'Previous Service'), shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.servicePrevious) + category=self.category, triggers=self.servicePrevious) self.nextService = create_action(parent, 'nextService', text=translate('OpenLP.SlideController', 'Next Service'), shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.serviceNext) + category=self.category, triggers=self.serviceNext) self.escapeItem = create_action(parent, 'escapeItem', text=translate('OpenLP.SlideController', 'Escape Item'), shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.liveEscape) + category=self.category, triggers=self.liveEscape) def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 62d1a7d94..1a7ce7963 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -65,27 +65,27 @@ class ThemeManager(QtGui.QWidget): self.layout.setObjectName(u'layout') self.toolbar = OpenLPToolbar(self) self.toolbar.setObjectName(u'toolbar') - self.toolbar.addToolbarButton(u'newTheme', + self.toolbar.addToolbarAction(u'newTheme', text=UiStrings().NewTheme, icon=u':/themes/theme_new.png', tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'), triggers=self.onAddTheme) - self.toolbar.addToolbarButton(u'editTheme', + self.toolbar.addToolbarAction(u'editTheme', text=translate('OpenLP.ThemeManager', 'Edit Theme'), icon=u':/themes/theme_edit.png', tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'), triggers=self.onEditTheme) - self.deleteToolbarAction = self.toolbar.addToolbarButton(u'deleteTheme', + self.deleteToolbarAction = self.toolbar.addToolbarAction(u'deleteTheme', text=translate('OpenLP.ThemeManager', 'Delete Theme'), icon=u':/general/general_delete.png', tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'), triggers=self.onDeleteTheme) self.toolbar.addSeparator() - self.toolbar.addToolbarButton(u'importTheme', + self.toolbar.addToolbarAction(u'importTheme', text=translate('OpenLP.ThemeManager', 'Import Theme'), icon=u':/general/general_import.png', tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'), triggers=self.onImportTheme) - self.toolbar.addToolbarButton(u'exportTheme', + self.toolbar.addToolbarAction(u'exportTheme', text=translate('OpenLP.ThemeManager', 'Export Theme'), icon=u':/general/general_export.png', tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'), diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 584f22e7b..443c95f56 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -68,7 +68,7 @@ class CustomMediaItem(MediaManagerItem): self.manager = plugin.manager def addEndHeaderBar(self): - self.addToolbarSeparator() + self.toolbar.addSeparator() self.addSearchToToolBar() # Signals and slots QtCore.QObject.connect(self.searchTextEdit, diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index c7b6829bb..80d6360a8 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -89,9 +89,9 @@ class ImageMediaItem(MediaManagerItem): self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): - self.replaceAction = self.addToolbarButton(u'replaceAction', + self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction', icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) - self.resetAction = self.addToolbarButton(u'resetAction', + self.resetAction = self.toolbar.addToolbarAction(u'resetAction', icon=u':/system/system_close.png', visible=False, triggers=self.onResetClick) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 6199903de..76dbd0fe9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -118,9 +118,9 @@ class MediaMediaItem(MediaManagerItem): def addEndHeaderBar(self): # Replace backgrounds do not work at present so remove functionality. - self.replaceAction = self.addToolbarButton(u'replaceAction', + self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction', icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) - self.resetAction = self.addToolbarButton(u'resetAction', + self.resetAction = self.toolbar.addToolbarAction(u'resetAction', icon=u':/system/system_close.png', visible=False, triggers=self.onResetClick) self.mediaWidget = QtGui.QWidget(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b01acdb89..eeaace513 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -97,10 +97,10 @@ class SongMediaItem(MediaManagerItem): self.plugin.manager.save_object(song, True) def addEndHeaderBar(self): - self.addToolbarSeparator() + self.toolbar.addSeparator() ## Song Maintenance Button ## - self.maintenanceAction = self.addToolbarButton(u'maintenanceAction', - icon=':/songs/song_maintenance.png', + self.maintenanceAction = self.toolbar.addToolbarAction( + u'maintenanceAction', icon=':/songs/song_maintenance.png', triggers=self.onSongMaintenanceClick) self.addSearchToToolBar() # Signals and slots From 587850bb5993d4702af66cc61b5f55387c04af58 Mon Sep 17 00:00:00 2001 From: M2j Date: Sat, 3 Mar 2012 14:52:57 +0100 Subject: [PATCH 33/46] Bug #943919: Make shortcuts for "Move to Previous/Next" in live slide controller configurable. --- openlp/core/lib/mediamanageritem.py | 19 ++----- openlp/core/lib/searchedit.py | 5 +- openlp/core/lib/toolbar.py | 22 +------- openlp/core/ui/media/mediacontroller.py | 6 +-- openlp/core/ui/servicemanager.py | 26 +++++----- openlp/core/ui/slidecontroller.py | 69 +++++++++++-------------- openlp/core/ui/thememanager.py | 10 ++-- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 4 +- openlp/plugins/songs/lib/mediaitem.py | 6 +-- 11 files changed, 65 insertions(+), 108 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 992286686..cb77f45ad 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -147,20 +147,6 @@ class MediaManagerItem(QtGui.QWidget): self.toolbar = OpenLPToolbar(self) self.pageLayout.addWidget(self.toolbar) - def addToolbarButton(self, name, **kwargs): - """ - A method to help developers easily add a button to the toolbar. For - details please have a look at OpenLPToolbar.addToolbarButton() and - openlp.core.lib.ui.create_action(). - """ - return self.toolbar.addToolbarButton(name, **kwargs) - - def addToolbarSeparator(self): - """ - A very simple method to add a separator to the toolbar. - """ - self.toolbar.addSeparator() - def setupUi(self): """ This method sets up the interface on the button. Plugin @@ -214,8 +200,9 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_add.png', self.onAddClick]) for action in toolbar_actions: if action[0] == StringContent.Preview: - self.addToolbarSeparator() - self.addToolbarButton(u'%s%sAction' % (self.plugin.name, action[0]), + self.toolbar.addSeparator() + self.toolbar.addToolbarAction( + u'%s%sAction' % (self.plugin.name, action[0]), text=self.plugin.getString(action[1])[u'title'], icon=action[2], tooltip=self.plugin.getString(action[1])[u'tooltip'], triggers=action[3]) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 5d117e3d1..933dee43b 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon -from openlp.core.lib.ui import create_action +from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) @@ -150,9 +150,8 @@ class SearchEdit(QtGui.QLineEdit): menu = QtGui.QMenu(self) first = None for identifier, icon, title in items: - action = create_action(menu, u'', text=title, icon=icon, + action = create_widget_action(menu, text=title, icon=icon, data=identifier, triggers=self._onMenuActionTriggered) - menu.addAction(action) if first is None: first = action self._currentSearchType = identifier diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 8b50081db..0fc693041 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -51,7 +51,7 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions = {} log.debug(u'Init done for %s' % parent.__class__.__name__) - def addToolbarButton(self, name, **kwargs): + def addToolbarAction(self, name, **kwargs): """ A method to help developers easily add a button to the toolbar. A new QAction is created by calling ``create_action()``. The action is @@ -62,13 +62,6 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions[name] = action return action - def addToolbarSeparator(self, handle): - """ - Add a separator bar and store it's handle. - """ - action = self.addSeparator() - self.actions[handle] = action - def addToolbarWidget(self, widget): """ Add a widget and store it's handle under the widgets object name. @@ -88,18 +81,7 @@ class OpenLPToolbar(QtGui.QToolBar): """ for handle in widgets: if handle in self.actions: - self.actions[handle].setVisible(visible) + self.actions[handle].setVisible(visible) else: log.warn(u'No handle "%s" in actions list.', unicode(handle)) - def addPushButton(self, image_file=None, text=u''): - """ - Adds a push button to the toolbar. - - Returns the push button - """ - push_button = QtGui.QPushButton(build_icon(image_file), text) - push_button.setCheckable(True) - push_button.setFlat(True) - self.addWidget(push_button) - return push_button diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index ba9d5a6e5..b28497906 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -204,17 +204,17 @@ class MediaController(object): controller.media_info = MediaInfo() # Build a Media ToolBar controller.mediabar = OpenLPToolbar(controller) - controller.mediabar.addToolbarButton(u'playbackPlay', + controller.mediabar.addToolbarAction(u'playbackPlay', text=u'media_playback_play', icon=u':/slides/media_playback_start.png', tooltip=translate('OpenLP.SlideController', 'Start playing media.'), triggers=controller.sendToPlugins) - controller.mediabar.addToolbarButton(u'playbackPause', + controller.mediabar.addToolbarAction(u'playbackPause', text=u'media_playback_pause', icon=u':/slides/media_playback_pause.png', tooltip=translate('OpenLP.SlideController', 'Pause playing media.'), triggers=controller.sendToPlugins) - controller.mediabar.addToolbarButton(u'playbackStop', + controller.mediabar.addToolbarAction(u'playbackStop', text=u'media_playback_stop', icon=u':/slides/media_playback_stop.png', tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 593806079..033558ca6 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -117,15 +117,15 @@ class ServiceManager(QtGui.QWidget): self.layout.setMargin(0) # Create the top toolbar self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarButton(u'newService', + self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', tooltip=UiStrings().CreateService, triggers=self.onNewServiceClicked) - self.toolbar.addToolbarButton(u'openService', + self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.onLoadServiceClicked) - self.toolbar.addToolbarButton(u'saveService', + self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.saveFile) @@ -172,47 +172,47 @@ class ServiceManager(QtGui.QWidget): action_list = ActionList.get_instance() action_list.add_category( unicode(UiStrings().Service), CategoryOrder.standardToolbar) - self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction( u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item to the top of the service.'), shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) - self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction( u'moveUp', text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item up one position in the service.'), shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) - self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction( u'moveDown', text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) - self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( + self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction( u'moveBottom', text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', tooltip=translate( 'OpenLP.ServiceManager', 'Move item to the end of the service.'), shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) - self.serviceManagerList.down = self.orderToolbar.addToolbarButton( + self.serviceManagerList.down = self.orderToolbar.addToolbarAction( u'down', text=translate('OpenLP.ServiceManager', 'Move &down'), tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Down], triggers=self.onMoveSelectionDown) action_list.add_action(self.serviceManagerList.down) - self.serviceManagerList.up = self.orderToolbar.addToolbarButton( + self.serviceManagerList.up = self.orderToolbar.addToolbarAction( u'up', text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], triggers=self.onMoveSelectionUp) action_list.add_action(self.serviceManagerList.up) self.orderToolbar.addSeparator() - self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( + self.serviceManagerList.delete = self.orderToolbar.addToolbarAction( u'delete', text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', @@ -220,13 +220,13 @@ class ServiceManager(QtGui.QWidget): 'Delete the selected item from the service.'), triggers=self.onDeleteFromService) self.orderToolbar.addSeparator() - self.serviceManagerList.expand = self.orderToolbar.addToolbarButton( + self.serviceManagerList.expand = self.orderToolbar.addToolbarAction( u'expand', text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', tooltip=translate( 'OpenLP.ServiceManager', 'Expand all the service items.'), shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) - self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( + self.serviceManagerList.collapse = self.orderToolbar.addToolbarAction( u'collapse', text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', tooltip=translate( @@ -234,7 +234,7 @@ class ServiceManager(QtGui.QWidget): shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) self.orderToolbar.addSeparator() - self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( + self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction( u'makeLive', text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', tooltip=translate( 'OpenLP.ServiceManager', 'Send the selected item to Live.'), diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e0ea398bb..d55f80d2e 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -122,10 +122,14 @@ class SlideController(Controller): self.typePrefix = u'live' self.keypress_queue = deque() self.keypress_loop = False + self.category = UiStrings().LiveToolbar + ActionList.get_instance().add_category( + unicode(self.category), CategoryOrder.standardToolbar) else: self.typeLabel.setText(UiStrings().Preview) self.split = 0 self.typePrefix = u'preview' + self.category = None self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;') self.typeLabel.setAlignment(QtCore.Qt.AlignCenter) self.panelLayout.addWidget(self.typeLabel) @@ -168,19 +172,23 @@ class SlideController(Controller): sizeToolbarPolicy.setHeightForWidth( self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(sizeToolbarPolicy) - self.previousItem = self.toolbar.addToolbarButton(u'previousItem', + self.previousItem = self.toolbar.addToolbarAction( + u'previousItem_' + self.typePrefix, + text=translate('OpenLP.SlideController', 'Previous Item'), icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.onSlideSelectedPrevious) - self.nextItem = self.toolbar.addToolbarButton(u'nextItem', + category=self.category, triggers=self.onSlideSelectedPrevious) + self.nextItem = self.toolbar.addToolbarAction( + u'nextItem_' + self.typePrefix, + text=translate('OpenLP.SlideController', 'Next Item'), icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, - triggers=self.onSlideSelectedNext) - self.toolbar.addToolbarSeparator(u'Close Separator') + category=self.category, triggers=self.onSlideSelectedNext) + self.toolbar.addSeparator() if self.isLive: # Hide Menu self.hideMenu = QtGui.QToolButton(self.toolbar) @@ -194,22 +202,22 @@ class SlideController(Controller): text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, shortcuts=[QtCore.Qt.Key_Period], - category=UiStrings().LiveToolbar, triggers=self.onBlankDisplay) + category=self.category, triggers=self.onBlankDisplay) self.themeScreen = create_action(self.hideMenu, u'themeScreen', text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', checked=False, shortcuts=[QtGui.QKeySequence(u'T')], - category=UiStrings().LiveToolbar, triggers=self.onThemeDisplay) + category=self.category, triggers=self.onThemeDisplay) self.desktopScreen = create_action(self.hideMenu, u'desktopScreen', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', checked=False, shortcuts=[QtGui.QKeySequence(u'D')], - category=UiStrings().LiveToolbar, triggers=self.onHideDisplay) + category=self.category, triggers=self.onHideDisplay) self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) - self.toolbar.addToolbarSeparator(u'loopSeparator') + self.toolbar.addToolbarAction(u'loopSeparator', separator=True) # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) self.playSlidesMenu.setObjectName(u'playSlidesMenu') @@ -223,13 +231,11 @@ class SlideController(Controller): self.playSlidesLoop = create_action(self.playSlidesMenu, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=UiStrings().LiveToolbar, - triggers=self.onPlaySlidesLoop) + category=self.category, triggers=self.onPlaySlidesLoop) self.playSlidesOnce = create_action(self.playSlidesMenu, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], - category=UiStrings().LiveToolbar, - triggers=self.onPlaySlidesOnce) + category=self.category, triggers=self.onPlaySlidesOnce) if QtCore.QSettings().value(self.parent().generalSettingsSection + u'/enable slide loop', QtCore.QVariant(True)).toBool(): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) @@ -246,16 +252,16 @@ class SlideController(Controller): 'Delay between slides in seconds.')) self.toolbar.addToolbarWidget(self.delaySpinBox) else: - self.toolbar.addToolbarButton(u'goLive', + self.toolbar.addToolbarAction(u'goLive', icon=u':/general/general_live.png', tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.onGoLive) - self.toolbar.addToolbarButton(u'addToService', + self.toolbar.addToolbarAction(u'addToService', icon=u':/general/general_add.png', tooltip=translate('OpenLP.SlideController', 'Add to Service.'), triggers=self.onPreviewAddToService) - self.toolbar.addToolbarSeparator(u'Close Separator') - self.toolbar.addToolbarButton(u'editSong', + self.toolbar.addSeparator() + self.toolbar.addToolbarAction(u'editSong', icon=u':/general/general_edit.png', tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong) @@ -273,7 +279,7 @@ class SlideController(Controller): self.songMenu.hide() self.toolbar.addToolbarWidget(self.songMenu) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarButton(u'audioPause', + self.audioPauseItem = self.toolbar.addToolbarAction(u'audioPause', text=u'Pause Audio', icon=u':/slides/media_playback_pause.png', tooltip=translate('OpenLP.SlideController', 'Pause audio.'), checked=False, visible=False, @@ -342,8 +348,7 @@ class SlideController(Controller): u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), shortcuts=[QtGui.QKeySequence(s[u'key'])], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar \ - if s.get(u'configurable') else None, + category=self.category if s.get(u'configurable') else None, triggers=self._slideShortcutActivated) for s in shortcuts]) QtCore.QObject.connect( self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), @@ -368,10 +373,8 @@ class SlideController(Controller): self.setLiveHotkeys(self) self.__addActionsToWidget(self.previewListWidget) else: - self.setPreviewHotkeys() self.previewListWidget.addActions( - [self.nextItem, - self.previousItem]) + [self.nextItem, self.previousItem]) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop) @@ -467,36 +470,22 @@ class SlideController(Controller): # Reset the shortcut. self.current_shortcut = u'' - def setPreviewHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemPreview') - self.nextItem.setObjectName(u'nextItemPreview') - action_list = ActionList.get_instance() - action_list.add_action(self.previousItem) - action_list.add_action(self.nextItem) - def setLiveHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemLive') - self.nextItem.setObjectName(u'nextItemLive') - action_list = ActionList.get_instance() - action_list.add_category( - unicode(UiStrings().LiveToolbar), CategoryOrder.standardToolbar) - action_list.add_action(self.previousItem) - action_list.add_action(self.nextItem) self.previousService = create_action(parent, u'previousService', text=translate('OpenLP.SlideController', 'Previous Service'), shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.servicePrevious) + category=self.category, triggers=self.servicePrevious) self.nextService = create_action(parent, 'nextService', text=translate('OpenLP.SlideController', 'Next Service'), shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.serviceNext) + category=self.category, triggers=self.serviceNext) self.escapeItem = create_action(parent, 'escapeItem', text=translate('OpenLP.SlideController', 'Escape Item'), shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=UiStrings().LiveToolbar, triggers=self.liveEscape) + category=self.category, triggers=self.liveEscape) def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 62d1a7d94..1a7ce7963 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -65,27 +65,27 @@ class ThemeManager(QtGui.QWidget): self.layout.setObjectName(u'layout') self.toolbar = OpenLPToolbar(self) self.toolbar.setObjectName(u'toolbar') - self.toolbar.addToolbarButton(u'newTheme', + self.toolbar.addToolbarAction(u'newTheme', text=UiStrings().NewTheme, icon=u':/themes/theme_new.png', tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'), triggers=self.onAddTheme) - self.toolbar.addToolbarButton(u'editTheme', + self.toolbar.addToolbarAction(u'editTheme', text=translate('OpenLP.ThemeManager', 'Edit Theme'), icon=u':/themes/theme_edit.png', tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'), triggers=self.onEditTheme) - self.deleteToolbarAction = self.toolbar.addToolbarButton(u'deleteTheme', + self.deleteToolbarAction = self.toolbar.addToolbarAction(u'deleteTheme', text=translate('OpenLP.ThemeManager', 'Delete Theme'), icon=u':/general/general_delete.png', tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'), triggers=self.onDeleteTheme) self.toolbar.addSeparator() - self.toolbar.addToolbarButton(u'importTheme', + self.toolbar.addToolbarAction(u'importTheme', text=translate('OpenLP.ThemeManager', 'Import Theme'), icon=u':/general/general_import.png', tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'), triggers=self.onImportTheme) - self.toolbar.addToolbarButton(u'exportTheme', + self.toolbar.addToolbarAction(u'exportTheme', text=translate('OpenLP.ThemeManager', 'Export Theme'), icon=u':/general/general_export.png', tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'), diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 584f22e7b..443c95f56 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -68,7 +68,7 @@ class CustomMediaItem(MediaManagerItem): self.manager = plugin.manager def addEndHeaderBar(self): - self.addToolbarSeparator() + self.toolbar.addSeparator() self.addSearchToToolBar() # Signals and slots QtCore.QObject.connect(self.searchTextEdit, diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index c7b6829bb..80d6360a8 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -89,9 +89,9 @@ class ImageMediaItem(MediaManagerItem): self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): - self.replaceAction = self.addToolbarButton(u'replaceAction', + self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction', icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) - self.resetAction = self.addToolbarButton(u'resetAction', + self.resetAction = self.toolbar.addToolbarAction(u'resetAction', icon=u':/system/system_close.png', visible=False, triggers=self.onResetClick) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 6199903de..76dbd0fe9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -118,9 +118,9 @@ class MediaMediaItem(MediaManagerItem): def addEndHeaderBar(self): # Replace backgrounds do not work at present so remove functionality. - self.replaceAction = self.addToolbarButton(u'replaceAction', + self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction', icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) - self.resetAction = self.addToolbarButton(u'resetAction', + self.resetAction = self.toolbar.addToolbarAction(u'resetAction', icon=u':/system/system_close.png', visible=False, triggers=self.onResetClick) self.mediaWidget = QtGui.QWidget(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b01acdb89..eeaace513 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -97,10 +97,10 @@ class SongMediaItem(MediaManagerItem): self.plugin.manager.save_object(song, True) def addEndHeaderBar(self): - self.addToolbarSeparator() + self.toolbar.addSeparator() ## Song Maintenance Button ## - self.maintenanceAction = self.addToolbarButton(u'maintenanceAction', - icon=':/songs/song_maintenance.png', + self.maintenanceAction = self.toolbar.addToolbarAction( + u'maintenanceAction', icon=':/songs/song_maintenance.png', triggers=self.onSongMaintenanceClick) self.addSearchToToolBar() # Signals and slots From 5d6db957e166c3aa4d5f1e3b27b302efb1c0853e Mon Sep 17 00:00:00 2001 From: rimach Date: Sat, 3 Mar 2012 23:36:46 +0100 Subject: [PATCH 34/46] fix --- openlp/core/ui/media/mediacontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 6ef7185bc..3beffbf36 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -134,7 +134,7 @@ class MediaController(object): savedPlayers = playerSettings.split(u',') invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ if not mediaPlayer in self.mediaPlayers or \ - self.mediaPlayers[mediaPlayer].check_available() == False] + not self.mediaPlayers[mediaPlayer].check_available()] if len(invalidMediaPlayers) > 0: for invalidPlayer in invalidMediaPlayers: savedPlayers.remove(invalidPlayer) From e59e71748094b682ebc0bc92b8ca756c36af6821 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 4 Mar 2012 20:05:15 +0200 Subject: [PATCH 35/46] Hopefully fix the next button when things are on repeat. --- openlp/core/ui/maindisplay.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index fb45ecff0..b0a18537b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -575,34 +575,26 @@ class AudioPlayer(QtCore.QObject): self.playlist.append(Phonon.MediaSource(filename)) def next(self): + if not self.repeat and self.currentIndex + 1 == len(self.playlist): + return isPlaying = self.mediaObject.state() == Phonon.PlayingState + self.currentIndex += 1 + if self.repeat and self.currentIndex == len(self.playlist): + self.currentIndex = 0 self.mediaObject.clearQueue() self.mediaObject.clear() - self.currentIndex += 1 - if len(self.playlist) <= self.currentIndex: - if self.repeat: - self.currentIndex = 0 - else: - self.currentIndex = -1 - if self.currentIndex >= 0: - self.mediaObject.enqueue(self.playlist[self.currentIndex]) - if isPlaying: - self.mediaObject.play() + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + if isPlaying: + self.mediaObject.play() def goTo(self, index): isPlaying = self.mediaObject.state() == Phonon.PlayingState self.mediaObject.clearQueue() self.mediaObject.clear() self.currentIndex = index - if len(self.playlist) <= self.currentIndex: - if self.repeat: - self.currentIndex = 0 - else: - self.currentIndex = -1 - if self.currentIndex >= 0: - self.mediaObject.enqueue(self.playlist[self.currentIndex]) - if isPlaying: - self.mediaObject.play() + self.mediaObject.enqueue(self.playlist[self.currentIndex]) + if isPlaying: + self.mediaObject.play() def connectSlot(self, signal, slot): QtCore.QObject.connect(self.mediaObject, signal, slot) From 970e6c5564042e5f6b7b013fd1aad85db23ae6e8 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 4 Mar 2012 20:06:49 +0100 Subject: [PATCH 36/46] correct parenting of shortcut actions in slide controller --- openlp/core/ui/slidecontroller.py | 61 ++++++++++++++----------------- openlp/core/utils/actions.py | 25 ++++++++++--- 2 files changed, 47 insertions(+), 39 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d55f80d2e..002ab0eb6 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -98,10 +98,6 @@ class SlideController(Controller): self.songEditList = [ u'editSong', ] - self.nextPreviousList = [ - u'previousItem', - u'nextItem' - ] self.timer_id = 0 self.songEdit = False self.selectedRow = 0 @@ -172,22 +168,23 @@ class SlideController(Controller): sizeToolbarPolicy.setHeightForWidth( self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(sizeToolbarPolicy) - self.previousItem = self.toolbar.addToolbarAction( + self.previousItem = create_action(self, u'previousItem_' + self.typePrefix, - text=translate('OpenLP.SlideController', 'Previous Item'), + text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.onSlideSelectedPrevious) - self.nextItem = self.toolbar.addToolbarAction( - u'nextItem_' + self.typePrefix, - text=translate('OpenLP.SlideController', 'Next Item'), + self.toolbar.addAction(self.previousItem) + self.nextItem = create_action(self, u'nextItem_' + self.typePrefix, + text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.onSlideSelectedNext) + self.toolbar.addAction(self.nextItem) self.toolbar.addSeparator() if self.isLive: # Hide Menu @@ -198,17 +195,17 @@ class SlideController(Controller): self.hideMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Hide'), self.toolbar)) self.toolbar.addToolbarWidget(self.hideMenu) - self.blankScreen = create_action(self.hideMenu, u'blankScreen', + self.blankScreen = create_action(self, u'blankScreen', text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, shortcuts=[QtCore.Qt.Key_Period], category=self.category, triggers=self.onBlankDisplay) - self.themeScreen = create_action(self.hideMenu, u'themeScreen', + self.themeScreen = create_action(self, u'themeScreen', text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', checked=False, shortcuts=[QtGui.QKeySequence(u'T')], category=self.category, triggers=self.onThemeDisplay) - self.desktopScreen = create_action(self.hideMenu, u'desktopScreen', + self.desktopScreen = create_action(self, u'desktopScreen', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', checked=False, shortcuts=[QtGui.QKeySequence(u'D')], @@ -228,12 +225,12 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) self.toolbar.addToolbarWidget(self.playSlidesMenu) - self.playSlidesLoop = create_action(self.playSlidesMenu, - u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, + self.playSlidesLoop = create_action(self, u'playSlidesLoop', + text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesLoop) - self.playSlidesOnce = create_action(self.playSlidesMenu, - u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, + self.playSlidesOnce = create_action(self, u'playSlidesOnce', + text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesOnce) if QtCore.QSettings().value(self.parent().generalSettingsSection + @@ -667,12 +664,11 @@ class SlideController(Controller): len(item.get_frames()) > 1: self.toolbar.setWidgetVisible(self.loopList) if item.is_media(): - self.mediabar.setVisible(True) - self.toolbar.setWidgetVisible(self.nextPreviousList, False) - else: - # Work-around for OS X, hide and then show the toolbar - # See bug #791050 - self.toolbar.setWidgetVisible(self.nextPreviousList) + self.mediabar.show() + self.previousItem.setVisible(not item.is_media()) + self.nextItem.setVisible(not item.is_media()) + # Work-around for OS X, hide and then show the toolbar + # See bug #791050 self.toolbar.show() def enablePreviewToolBar(self, item): @@ -682,17 +678,16 @@ class SlideController(Controller): # Work-around for OS X, hide and then show the toolbar # See bug #791050 self.toolbar.hide() - self.mediabar.setVisible(False) + self.mediabar.hide() self.toolbar.setWidgetVisible(self.songEditList, False) if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin: self.toolbar.setWidgetVisible(self.songEditList) elif item.is_media(): - self.mediabar.setVisible(True) - self.toolbar.setWidgetVisible(self.nextPreviousList, False) - if not item.is_media(): - # Work-around for OS X, hide and then show the toolbar - # See bug #791050 - self.toolbar.setWidgetVisible(self.nextPreviousList) + self.mediabar.show() + self.previousItem.setVisible(not item.is_media()) + self.nextItem.setVisible(not item.is_media()) + # Work-around for OS X, hide and then show the toolbar + # See bug #791050 self.toolbar.show() def refreshServiceItem(self): @@ -824,7 +819,7 @@ class SlideController(Controller): self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) - if slideHeight != 0: + if slideHeight: self.previewListWidget.setRowHeight(framenumber, slideHeight) self.previewListWidget.setVerticalHeaderLabels(text) if self.serviceItem.is_text(): @@ -1039,7 +1034,7 @@ class SlideController(Controller): """ row = self.previewListWidget.currentRow() self.selectedRow = 0 - if row > -1 and row < self.previewListWidget.rowCount(): + if -1 < row < self.previewListWidget.rowCount(): if self.serviceItem.is_command(): if self.isLive and not start: Receiver.send_message( @@ -1175,7 +1170,7 @@ class SlideController(Controller): """ Stop the timer loop running """ - if self.timer_id != 0: + if self.timer_id: self.killTimer(self.timer_id) self.timer_id = 0 @@ -1276,7 +1271,7 @@ class SlideController(Controller): If preview copy slide item to live """ row = self.previewListWidget.currentRow() - if row > -1 and row < self.previewListWidget.rowCount(): + if -1 < row < self.previewListWidget.rowCount(): if self.serviceItem.from_service: Receiver.send_message('servicemanager_preview_live', u'%s:%s' % (self.serviceItem._uuid, row)) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index d363f1426..26f96de37 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -281,7 +281,7 @@ class ActionList(object): return self.categories[category].actions.remove(action) # Remove empty categories. - if len(self.categories[category].actions) == 0: + if not self.categories[category].actions: self.categories.remove(category) shortcuts = map(unicode, map(QtGui.QKeySequence.toString, action.shortcuts())) @@ -354,18 +354,31 @@ class ActionList(object): ``action`` The action which wants to use a particular shortcut. """ + local = action.shortcutContext() in \ + [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] + affected_actions = filter(lambda a: isinstance(a, QtGui.QAction), + self.getAllChildObjects(action.parent())) if local else [] for existing_action in existing_actions: if action is existing_action: continue - if existing_action.parent() is action.parent(): + if not local or existing_action in affected_actions: 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 - if action.shortcutContext() in [QtCore.Qt.WindowShortcut, - QtCore.Qt.ApplicationShortcut]: + elif action in self.getAllChildObjects(existing_action.parent()): return False return True + + def getAllChildObjects(self, qobject): + """ + Goes recursively through the children of ``qobject`` and returns a list + of all child objects. + """ + children = [child for child in qobject.children()] + for child in qobject.children(): + children.append(self.getAllChildObjects(child)) + return children class CategoryOrder(object): From e5a316ba2dab39565aac4ebbaf929921d31a66ce Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 5 Mar 2012 19:40:16 +0000 Subject: [PATCH 37/46] Transparency fixes --- openlp/core/ui/maindisplay.py | 5 ++++- openlp/core/ui/media/mediacontroller.py | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 971a9903f..67d5f2c6c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -38,6 +38,7 @@ from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ translate, PluginManager, expand_tags +from openlp.core.lib.theme import BackgroundType from openlp.core.ui import HideMode, ScreenList, AlertLocation @@ -144,7 +145,7 @@ class MainDisplay(Display): windowFlags = windowFlags | QtCore.Qt.SplashScreen self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) - self.setTransparency(True) + self.setTransparency(False) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) @@ -388,6 +389,8 @@ class MainDisplay(Display): # replace the background background = self.imageManager. \ get_image_bytes(self.override[u'image']) + self.setTransparency(self.serviceItem.themedata.background_type == + BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 3beffbf36..8a1a8e260 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -282,8 +282,6 @@ class MediaController(object): if self.curDisplayMediaPlayer and value: if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: controller.display.setTransparency(False) - else: - controller.display.setTransparency(True) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO From 0e95ffe55fa7af2b535faa56f9edbac5ebce09ba Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Mon, 5 Mar 2012 22:22:36 +0000 Subject: [PATCH 38/46] remove .encode hopefully to fix http://support.openlp.org/issues/442 --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 3585e5c97..dd116eee0 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -159,7 +159,7 @@ class ThemeManager(QtGui.QWidget): encoding = get_filesystem_encoding() files = SettingsManager.get_files(self.settingsSection, u'.otz') for file in files: - file = os.path.join(self.path, file).encode(encoding) + file = os.path.join(self.path, file) self.unzipTheme(file, self.path) delete_file(file) Receiver.send_message(u'cursor_normal') From 0c391385d04c2dd035577acbb6b3bb85989a05bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Mar 2012 21:02:26 +0200 Subject: [PATCH 39/46] Capitalize error messages. --- openlp/plugins/songs/lib/xml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index af1e6689e..6cab1d11b 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,11 +676,11 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsError('XML', 'missing lyrics item') + raise OpenLyricsError('XML', 'Missing lyrics item') try: verses = lyrics.verse except AttributeError: - raise OpenLyricsError('XML', 'missing verse item') + raise OpenLyricsError('XML', 'Missing verse item') # Loop over the "verse" elements. for verse in verses: text = u'' From 14e9f76304c75904a7fcdaac7b16ee2a24eab1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Mar 2012 21:56:49 +0200 Subject: [PATCH 40/46] Make user strings more specific and translatable. --- openlp/plugins/songs/lib/openlyricsimport.py | 5 +---- openlp/plugins/songs/lib/xml.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index cc4759d50..fcebefb78 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -77,7 +77,4 @@ class OpenLyricsImport(SongImport): except OpenLyricsError as exception: log.exception(u'OpenLyricsException of type %s: %s in file %s' % (exception.type, exception.message, file_path)) - if exception.type == 'XML': - self.logError(file_path, SongStrings.XMLSyntaxError) - else: - self.logError(file_path, exception.message) + self.logError(file_path, exception.display_message) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 6cab1d11b..66c75d762 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,11 +676,17 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item') + raise OpenLyricsError('XML', 'Missing lyrics item', + unicode(translate('OpenLP.OpenLyricsImportError', + 'XML tree is missing tag. ' + 'It is not valid OpenLyrics file.'))) try: verses = lyrics.verse except AttributeError: - raise OpenLyricsError('XML', 'Missing verse item') + raise OpenLyricsError('XML', 'Missing lyrics item', + unicode(translate('OpenLP.OpenLyricsImportError', + 'XML tree is missing tag. ' + 'It is not valid OpenLyrics file.'))) # Loop over the "verse" elements. for verse in verses: text = u'' @@ -804,9 +810,10 @@ class OpenLyricsError(Exception): """ By now raised only in case of missing lyrics or verse element in XML. """ - def __init__(self, exception_type, message): + def __init__(self, exception_type, message, display_message): self.type = exception_type self.message = message + self.display_message = display_message def __str__(self): return "%s: %s" % (self.type, self.message) From 2b28482b8b08f23df6ff3b909864d1281b5e0d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Mar 2012 22:03:18 +0200 Subject: [PATCH 41/46] Forgot to import translate function. --- openlp/plugins/songs/lib/xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 7f65d8746..81e12d49b 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -66,7 +66,7 @@ import re from lxml import etree, objectify -from openlp.core.lib import FormattingTags +from openlp.core.lib import FormattingTags, translate from openlp.plugins.songs.lib import clean_song, VerseType from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.core.utils import get_application_version From 247114c65625a747b6efb5ae9bd5512b247ce696 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 7 Mar 2012 17:25:39 +0000 Subject: [PATCH 42/46] Revisited Words of Worship importer. A few tweeks, some to make it more robust, and to provide more information to the user. --- openlp/plugins/songs/lib/wowimport.py | 42 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/wowimport.py index 1ea43b22a..c6b7039ab 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/wowimport.py @@ -31,6 +31,7 @@ Worship songs into the OpenLP database. import os import logging +from openlp.core.lib import translate from openlp.plugins.songs.lib.songimport import SongImport BLOCK_TYPES = (u'V', u'C', u'B') @@ -52,18 +53,19 @@ class WowImport(SongImport): * A block can be a verse, chorus or bridge. File Header: - Bytes are counted from one, i.e. the first byte is byte 1. These bytes, - up to the 56 byte, can change but no real meaning has been found. The + Bytes are counted from one, i.e. the first byte is byte 1. The first 19 + bytes should be "WoW File \\nSong Words" The bytes after this and up to + the 56th byte, can change but no real meaning has been found. The 56th byte specifies how many blocks there are. The first block starts with byte 83 after the "CSongDoc::CBlock" declaration. Blocks: Each block has a starting header, some lines of text, and an ending - footer. Each block starts with 4 bytes, the first byte specifies how - many lines are in that block, the next three bytes are null bytes. + footer. Each block starts with a 32 bit number, which specifies how + many lines are in that block. - Each block ends with 4 bytes, the first of which defines what type of - block it is, and the rest which are null bytes: + Each block ends with a 32 bit number, which defines what type of + block it is: * ``NUL`` (0x00) - Verse * ``SOH`` (0x01) - Chorus @@ -76,7 +78,6 @@ class WowImport(SongImport): Each line starts with a byte which specifies how long that line is, the line text, and ends with a null byte. - Footer: The footer follows on after the last block, the first byte specifies the length of the author text, followed by the author text, if @@ -107,22 +108,28 @@ class WowImport(SongImport): for file in self.importSource: if self.stopImportFlag: return - file_name = os.path.split(file)[1] - # Get the song title - self.title = file_name.rpartition(u'.')[0] + self.setDefaults() song_data = open(file, 'rb') if song_data.read(19) != u'WoW File\nSong Words': - self.logError(file) + self.logError(file, unicode( + translate('SongsPlugin.WordsofWorshipSongImport', + 'Invalid Words of Worship song file. Missing \ +"Wow File\\nSong Words" header.'))) continue # Seek to byte which stores number of blocks in the song song_data.seek(56) no_of_blocks = ord(song_data.read(1)) + song_data.seek(66) + if song_data.read(16) != u'CSongDoc::CBlock': + self.logError(file, unicode( + translate('SongsPlugin.WordsofWorshipSongImport', + 'Invalid Words of Worship song file. Missing \ +"CSongDoc::CBlock" string.'))) + continue # Seek to the beging of the first block song_data.seek(82) for block in range(no_of_blocks): - self.linesToRead = ord(song_data.read(1)) - # Skip 3 nulls to the beginnig of the 1st line - song_data.seek(3, os.SEEK_CUR) + self.linesToRead = ord(song_data.read(4)[:1]) block_text = u'' while self.linesToRead: self.lineText = unicode( @@ -132,9 +139,7 @@ class WowImport(SongImport): block_text += u'\n' block_text += self.lineText self.linesToRead -= 1 - block_type = BLOCK_TYPES[ord(song_data.read(1))] - # Skip 3 nulls at the end of the block - song_data.seek(3, os.SEEK_CUR) + block_type = BLOCK_TYPES[ord(song_data.read(4)[:1])] # Blocks are seperated by 2 bytes, skip them, but not if # this is the last block! if block + 1 < no_of_blocks: @@ -150,6 +155,9 @@ class WowImport(SongImport): if copyright_length: self.addCopyright(unicode( song_data.read(copyright_length), u'cp1252')) + file_name = os.path.split(file)[1] + # Get the song title + self.title = file_name.rpartition(u'.')[0] song_data.close() if not self.finish(): self.logError(file) From 499f51bd2b0c1a4413c94591a2b6c117643b7794 Mon Sep 17 00:00:00 2001 From: rimach Date: Thu, 8 Mar 2012 23:14:59 +0100 Subject: [PATCH 43/46] change Button layout, fix issue if no item selected and choose down button --- openlp/core/ui/media/vlc.py | 849 ++++----------------------- openlp/plugins/media/lib/mediatab.py | 59 +- 2 files changed, 137 insertions(+), 771 deletions(-) diff --git a/openlp/core/ui/media/vlc.py b/openlp/core/ui/media/vlc.py index 720e27826..c39bb3856 100644 --- a/openlp/core/ui/media/vlc.py +++ b/openlp/core/ui/media/vlc.py @@ -47,7 +47,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Tue Sep 13 17:50:18 2011" +build_date = "Tue Jan 17 12:20:48 2012" # Internal guard to prevent internal classes to be directly # instanciated. @@ -56,7 +56,7 @@ _internal_guard = object() def find_lib(): dll = None plugin_path = None - if sys.platform.startswith('linux') or sys.platform.startswith('freeBSD'): + if sys.platform.startswith('linux'): p = find_library('vlc') try: dll = ctypes.CDLL(p) @@ -127,6 +127,7 @@ try: _Ints = (int, long) except NameError: # no long in Python 3+ _Ints = int +_Seqs = (list, tuple) # Default instance. It is used to instanciate classes directly in the # OO-wrapper. @@ -140,19 +141,24 @@ def get_default_instance(): _default_instance = Instance() return _default_instance -_Seqs = (list, tuple) - _Cfunctions = {} # from LibVLC __version__ +_Globals = globals() # sys.modules[__name__].__dict__ def _Cfunction(name, flags, errcheck, *types): """(INTERNAL) New ctypes function binding. """ - if hasattr(dll, name): + if hasattr(dll, name) and name in _Globals: p = ctypes.CFUNCTYPE(*types) f = p((name, dll), flags) if errcheck is not None: f.errcheck = errcheck - _Cfunctions[name] = f + # replace the Python function + # in this module, but only when + # running as python -O or -OO + if __debug__: + _Cfunctions[name] = f + else: + _Globals[name] = f return f raise NameError('no function %r' % (name,)) @@ -172,6 +178,18 @@ def _Constructor(cls, ptr=_internal_guard): return None return _Cobject(cls, ctypes.c_void_p(ptr)) +class _Cstruct(ctypes.Structure): + """(INTERNAL) Base class for ctypes structures. + """ + _fields_ = [] # list of 2-tuples ('name', ctyptes.) + + def __str__(self): + l = [' %s:\t%s' % (n, getattr(self, n)) for n, _ in self._fields_] + return '\n'.join([self.__class__.__name__] + l) + + def __repr__(self): + return '%s.%s' % (self.__class__.__module__, self) + class _Ctype(object): """(INTERNAL) Base class for ctypes. """ @@ -265,6 +283,7 @@ class EventType(_Enum): 271: 'MediaPlayerTitleChanged', 272: 'MediaPlayerSnapshotTaken', 273: 'MediaPlayerLengthChanged', + 274: 'MediaPlayerVout', 0x200: 'MediaListItemAdded', 513: 'MediaListWillAddItem', 514: 'MediaListItemDeleted', @@ -325,6 +344,7 @@ EventType.MediaPlayerSnapshotTaken = EventType(272) EventType.MediaPlayerStopped = EventType(262) EventType.MediaPlayerTimeChanged = EventType(267) EventType.MediaPlayerTitleChanged = EventType(271) +EventType.MediaPlayerVout = EventType(274) EventType.MediaStateChanged = EventType(5) EventType.MediaSubItemAdded = EventType(1) EventType.VlmMediaAdded = EventType(0x600) @@ -560,21 +580,18 @@ AudioOutputChannel.Stereo = AudioOutputChannel(1) # From libvlc_structures.h -class AudioOutput(ctypes.Structure): +class AudioOutput(_Cstruct): def __str__(self): return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.description) - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - AudioOutput._fields_ = [ # recursive struct - ('name', ctypes.c_char_p), - ('description', ctypes.c_char_p), - ('next', ctypes.POINTER(AudioOutput)), + ('name', ctypes.c_char_p), + ('description', ctypes.c_char_p), + ('next', ctypes.POINTER(AudioOutput)), ] -class LogMessage(ctypes.Structure): +class LogMessage(_Cstruct): _fields_ = [ ('size', ctypes.c_uint ), ('severity', ctypes.c_int ), @@ -591,16 +608,13 @@ class LogMessage(ctypes.Structure): def __str__(self): return '%s(%d:%s): %s' % (self.__class__.__name__, self.severity, self.type, self.message) - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - -class MediaEvent(ctypes.Structure): +class MediaEvent(_Cstruct): _fields_ = [ ('media_name', ctypes.c_char_p), ('instance_name', ctypes.c_char_p), ] -class MediaStats(ctypes.Structure): +class MediaStats(_Cstruct): _fields_ = [ ('read_bytes', ctypes.c_int ), ('input_bitrate', ctypes.c_float), @@ -619,14 +633,7 @@ class MediaStats(ctypes.Structure): ('send_bitrate', ctypes.c_float), ] - def __str__(self): - l = [' %s:\t%s' % (n, getattr(self, n)) for n, t in self._fields_] - return '\n'.join([self.__class__.__name__] + l) - - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - -class MediaTrackInfo(ctypes.Structure): +class MediaTrackInfo(_Cstruct): _fields_ = [ ('codec', ctypes.c_uint32), ('id', ctypes.c_int ), @@ -637,14 +644,7 @@ class MediaTrackInfo(ctypes.Structure): ('rate_or_width', ctypes.c_uint ), ] - def __str__(self): - l = [" %s:\t%s" % (n, getattr(self, n)) for n, t in self._fields_] - return "\n".join([self.__class__.__name__] + l) - - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - -class PlaylistItem(ctypes.Structure): +class PlaylistItem(_Cstruct): _fields_ = [ ('id', ctypes.c_int ), ('uri', ctypes.c_char_p), @@ -654,9 +654,6 @@ class PlaylistItem(ctypes.Structure): def __str__(self): return '%s #%d %s (uri %s)' % (self.__class__.__name__, self.id, self.name, self.uri) - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - class Position(object): """Enum-like, immutable window position constants. @@ -680,7 +677,7 @@ class Position(object): def __setattr__(self, *unused): #PYCHOK expected raise TypeError('immutable constants') -class Rectangle(ctypes.Structure): +class Rectangle(_Cstruct): _fields_ = [ ('top', ctypes.c_int), ('left', ctypes.c_int), @@ -688,18 +685,15 @@ class Rectangle(ctypes.Structure): ('right', ctypes.c_int), ] -class TrackDescription(ctypes.Structure): +class TrackDescription(_Cstruct): def __str__(self): return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name) - def __repr__(self): - return '%s.%s' % (self.__class__.__module__, self.__str__()) - TrackDescription._fields_ = [ # recursive struct - ('id', ctypes.c_int ), - ('name', ctypes.c_char_p), - ('next', ctypes.POINTER(TrackDescription)), + ('id', ctypes.c_int ), + ('name', ctypes.c_char_p), + ('next', ctypes.POINTER(TrackDescription)), ] def track_description_list(head): @@ -712,7 +706,11 @@ def track_description_list(head): item = item.contents r.append((item.id, item.name)) item = item.next - libvlc_track_description_release(head) + try: + libvlc_track_description_release(head) + except NameError: + libvlc_track_description_list_release(head) + return r class EventUnion(ctypes.Union): @@ -735,23 +733,24 @@ class EventUnion(ctypes.Union): ('media_event', MediaEvent ), ] -class Event(ctypes.Structure): +class Event(_Cstruct): _fields_ = [ ('type', EventType ), ('object', ctypes.c_void_p), ('u', EventUnion ), ] -class ModuleDescription(ctypes.Structure): +class ModuleDescription(_Cstruct): + def __str__(self): return '%s %s (%s)' % (self.__class__.__name__, self.shortname, self.name) ModuleDescription._fields_ = [ # recursive struct - ('name', ctypes.c_char_p), + ('name', ctypes.c_char_p), ('shortname', ctypes.c_char_p), - ('longname', ctypes.c_char_p), - ('help', ctypes.c_char_p), - ('next', ctypes.POINTER(ModuleDescription)), + ('longname', ctypes.c_char_p), + ('help', ctypes.c_char_p), + ('next', ctypes.POINTER(ModuleDescription)), ] def module_description_list(head): @@ -2486,6 +2485,25 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_subtitle_file(self, psz_subtitle) + def video_get_spu_delay(self): + '''Get the current subtitle delay. Positive values means subtitles are being + displayed later, negative values earlier. + @return: time (in microseconds) the display of subtitles is being delayed. + @version: LibVLC 1.2.0 or later. + ''' + return libvlc_video_get_spu_delay(self) + + def video_set_spu_delay(self, i_delay): + '''Set the subtitle delay. This affects the timing of when the subtitle will + be displayed. Positive values result in subtitles being displayed later, + while negative values will result in subtitles being displayed earlier. + The subtitle delay will be reset to zero each time the media changes. + @param i_delay: time (in microseconds) the display of subtitles should be delayed. + @return: 0 on success, -1 on error. + @version: LibVLC 1.2.0 or later. + ''' + return libvlc_video_set_spu_delay(self, i_delay) + def video_get_crop_geometry(self): '''Get current crop filter geometry. @return: the crop filter geometry or NULL if unset. @@ -2756,9 +2774,6 @@ def libvlc_errmsg(): f = _Cfunctions.get('libvlc_errmsg', None) or \ _Cfunction('libvlc_errmsg', (), None, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_errmsg - libvlc_errmsg = f return f() def libvlc_clearerr(): @@ -2769,9 +2784,6 @@ def libvlc_clearerr(): f = _Cfunctions.get('libvlc_clearerr', None) or \ _Cfunction('libvlc_clearerr', (), None, None) - if not __debug__: # i.e. python -O or -OO - global libvlc_clearerr - libvlc_clearerr = f return f() def libvlc_new(argc, argv): @@ -2786,9 +2798,6 @@ def libvlc_new(argc, argv): f = _Cfunctions.get('libvlc_new', None) or \ _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance), ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p)) - if not __debug__: # i.e. python -O or -OO - global libvlc_new - libvlc_new = f return f(argc, argv) def libvlc_release(p_instance): @@ -2799,9 +2808,6 @@ def libvlc_release(p_instance): f = _Cfunctions.get('libvlc_release', None) or \ _Cfunction('libvlc_release', ((1,),), None, None, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_release - libvlc_release = f return f(p_instance) def libvlc_retain(p_instance): @@ -2812,9 +2818,6 @@ def libvlc_retain(p_instance): f = _Cfunctions.get('libvlc_retain', None) or \ _Cfunction('libvlc_retain', ((1,),), None, None, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_retain - libvlc_retain = f return f(p_instance) def libvlc_add_intf(p_instance, name): @@ -2826,9 +2829,6 @@ def libvlc_add_intf(p_instance, name): f = _Cfunctions.get('libvlc_add_intf', None) or \ _Cfunction('libvlc_add_intf', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_add_intf - libvlc_add_intf = f return f(p_instance, name) def libvlc_wait(p_instance): @@ -2839,9 +2839,6 @@ def libvlc_wait(p_instance): f = _Cfunctions.get('libvlc_wait', None) or \ _Cfunction('libvlc_wait', ((1,),), None, None, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_wait - libvlc_wait = f return f(p_instance) def libvlc_set_user_agent(p_instance, name, http): @@ -2855,9 +2852,6 @@ def libvlc_set_user_agent(p_instance, name, http): f = _Cfunctions.get('libvlc_set_user_agent', None) or \ _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), None, None, Instance, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_set_user_agent - libvlc_set_user_agent = f return f(p_instance, name, http) def libvlc_get_version(): @@ -2868,9 +2862,6 @@ def libvlc_get_version(): f = _Cfunctions.get('libvlc_get_version', None) or \ _Cfunction('libvlc_get_version', (), None, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_get_version - libvlc_get_version = f return f() def libvlc_get_compiler(): @@ -2881,9 +2872,6 @@ def libvlc_get_compiler(): f = _Cfunctions.get('libvlc_get_compiler', None) or \ _Cfunction('libvlc_get_compiler', (), None, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_get_compiler - libvlc_get_compiler = f return f() def libvlc_get_changeset(): @@ -2894,9 +2882,6 @@ def libvlc_get_changeset(): f = _Cfunctions.get('libvlc_get_changeset', None) or \ _Cfunction('libvlc_get_changeset', (), None, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_get_changeset - libvlc_get_changeset = f return f() def libvlc_free(ptr): @@ -2908,9 +2893,6 @@ def libvlc_free(ptr): f = _Cfunctions.get('libvlc_free', None) or \ _Cfunction('libvlc_free', ((1,),), None, None, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_free - libvlc_free = f return f(ptr) def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data): @@ -2924,9 +2906,6 @@ def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data): f = _Cfunctions.get('libvlc_event_attach', None) or \ _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), None, ctypes.c_int, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_event_attach - libvlc_event_attach = f return f(p_event_manager, i_event_type, f_callback, user_data) def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data): @@ -2939,9 +2918,6 @@ def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data): f = _Cfunctions.get('libvlc_event_detach', None) or \ _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), None, None, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_event_detach - libvlc_event_detach = f return f(p_event_manager, i_event_type, f_callback, p_user_data) def libvlc_event_type_name(event_type): @@ -2951,9 +2927,6 @@ def libvlc_event_type_name(event_type): f = _Cfunctions.get('libvlc_event_type_name', None) or \ _Cfunction('libvlc_event_type_name', ((1,),), None, ctypes.c_char_p, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_event_type_name - libvlc_event_type_name = f return f(event_type) def libvlc_get_log_verbosity(p_instance): @@ -2965,9 +2938,6 @@ def libvlc_get_log_verbosity(p_instance): f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \ _Cfunction('libvlc_get_log_verbosity', ((1,),), None, ctypes.c_uint, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_get_log_verbosity - libvlc_get_log_verbosity = f return f(p_instance) def libvlc_set_log_verbosity(p_instance, level): @@ -2979,9 +2949,6 @@ def libvlc_set_log_verbosity(p_instance, level): f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \ _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None, None, Instance, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_set_log_verbosity - libvlc_set_log_verbosity = f return f(p_instance, level) def libvlc_log_open(p_instance): @@ -2993,9 +2960,6 @@ def libvlc_log_open(p_instance): f = _Cfunctions.get('libvlc_log_open', None) or \ _Cfunction('libvlc_log_open', ((1,),), class_result(Log), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_open - libvlc_log_open = f return f(p_instance) def libvlc_log_close(p_log): @@ -3005,9 +2969,6 @@ def libvlc_log_close(p_log): f = _Cfunctions.get('libvlc_log_close', None) or \ _Cfunction('libvlc_log_close', ((1,),), None, None, Log) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_close - libvlc_log_close = f return f(p_log) def libvlc_log_count(p_log): @@ -3019,9 +2980,6 @@ def libvlc_log_count(p_log): f = _Cfunctions.get('libvlc_log_count', None) or \ _Cfunction('libvlc_log_count', ((1,),), None, ctypes.c_uint, Log) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_count - libvlc_log_count = f return f(p_log) def libvlc_log_clear(p_log): @@ -3032,9 +2990,6 @@ def libvlc_log_clear(p_log): f = _Cfunctions.get('libvlc_log_clear', None) or \ _Cfunction('libvlc_log_clear', ((1,),), None, None, Log) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_clear - libvlc_log_clear = f return f(p_log) def libvlc_log_get_iterator(p_log): @@ -3046,9 +3001,6 @@ def libvlc_log_get_iterator(p_log): f = _Cfunctions.get('libvlc_log_get_iterator', None) or \ _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator), ctypes.c_void_p, Log) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_get_iterator - libvlc_log_get_iterator = f return f(p_log) def libvlc_log_iterator_free(p_iter): @@ -3058,9 +3010,6 @@ def libvlc_log_iterator_free(p_iter): f = _Cfunctions.get('libvlc_log_iterator_free', None) or \ _Cfunction('libvlc_log_iterator_free', ((1,),), None, None, LogIterator) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_iterator_free - libvlc_log_iterator_free = f return f(p_iter) def libvlc_log_iterator_has_next(p_iter): @@ -3072,9 +3021,6 @@ def libvlc_log_iterator_has_next(p_iter): f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \ _Cfunction('libvlc_log_iterator_has_next', ((1,),), None, ctypes.c_int, LogIterator) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_iterator_has_next - libvlc_log_iterator_has_next = f return f(p_iter) def libvlc_log_iterator_next(p_iter, p_buffer): @@ -3087,9 +3033,6 @@ def libvlc_log_iterator_next(p_iter, p_buffer): f = _Cfunctions.get('libvlc_log_iterator_next', None) or \ _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None, ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage)) - if not __debug__: # i.e. python -O or -OO - global libvlc_log_iterator_next - libvlc_log_iterator_next = f return f(p_iter, p_buffer) def libvlc_module_description_list_release(p_list): @@ -3099,9 +3042,6 @@ def libvlc_module_description_list_release(p_list): f = _Cfunctions.get('libvlc_module_description_list_release', None) or \ _Cfunction('libvlc_module_description_list_release', ((1,),), None, None, ctypes.POINTER(ModuleDescription)) - if not __debug__: # i.e. python -O or -OO - global libvlc_module_description_list_release - libvlc_module_description_list_release = f return f(p_list) def libvlc_audio_filter_list_get(p_instance): @@ -3112,9 +3052,6 @@ def libvlc_audio_filter_list_get(p_instance): f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \ _Cfunction('libvlc_audio_filter_list_get', ((1,),), None, ctypes.POINTER(ModuleDescription), Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_filter_list_get - libvlc_audio_filter_list_get = f return f(p_instance) def libvlc_video_filter_list_get(p_instance): @@ -3125,9 +3062,6 @@ def libvlc_video_filter_list_get(p_instance): f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \ _Cfunction('libvlc_video_filter_list_get', ((1,),), None, ctypes.POINTER(ModuleDescription), Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_filter_list_get - libvlc_video_filter_list_get = f return f(p_instance) def libvlc_clock(): @@ -3141,9 +3075,6 @@ def libvlc_clock(): f = _Cfunctions.get('libvlc_clock', None) or \ _Cfunction('libvlc_clock', (), None, ctypes.c_int64) - if not __debug__: # i.e. python -O or -OO - global libvlc_clock - libvlc_clock = f return f() def libvlc_media_new_location(p_instance, psz_mrl): @@ -3161,9 +3092,6 @@ def libvlc_media_new_location(p_instance, psz_mrl): f = _Cfunctions.get('libvlc_media_new_location', None) or \ _Cfunction('libvlc_media_new_location', ((1,), (1,),), class_result(Media), ctypes.c_void_p, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_new_location - libvlc_media_new_location = f return f(p_instance, psz_mrl) def libvlc_media_new_path(p_instance, path): @@ -3176,9 +3104,6 @@ def libvlc_media_new_path(p_instance, path): f = _Cfunctions.get('libvlc_media_new_path', None) or \ _Cfunction('libvlc_media_new_path', ((1,), (1,),), class_result(Media), ctypes.c_void_p, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_new_path - libvlc_media_new_path = f return f(p_instance, path) def libvlc_media_new_fd(p_instance, fd): @@ -3203,9 +3128,6 @@ def libvlc_media_new_fd(p_instance, fd): f = _Cfunctions.get('libvlc_media_new_fd', None) or \ _Cfunction('libvlc_media_new_fd', ((1,), (1,),), class_result(Media), ctypes.c_void_p, Instance, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_new_fd - libvlc_media_new_fd = f return f(p_instance, fd) def libvlc_media_new_as_node(p_instance, psz_name): @@ -3218,9 +3140,6 @@ def libvlc_media_new_as_node(p_instance, psz_name): f = _Cfunctions.get('libvlc_media_new_as_node', None) or \ _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), class_result(Media), ctypes.c_void_p, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_new_as_node - libvlc_media_new_as_node = f return f(p_instance, psz_name) def libvlc_media_add_option(p_md, ppsz_options): @@ -3235,9 +3154,6 @@ def libvlc_media_add_option(p_md, ppsz_options): f = _Cfunctions.get('libvlc_media_add_option', None) or \ _Cfunction('libvlc_media_add_option', ((1,), (1,),), None, None, Media, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_add_option - libvlc_media_add_option = f return f(p_md, ppsz_options) def libvlc_media_add_option_flag(p_md, ppsz_options, i_flags): @@ -3253,9 +3169,6 @@ def libvlc_media_add_option_flag(p_md, ppsz_options, i_flags): f = _Cfunctions.get('libvlc_media_add_option_flag', None) or \ _Cfunction('libvlc_media_add_option_flag', ((1,), (1,), (1,),), None, None, Media, ctypes.c_char_p, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_add_option_flag - libvlc_media_add_option_flag = f return f(p_md, ppsz_options, i_flags) def libvlc_media_retain(p_md): @@ -3267,9 +3180,6 @@ def libvlc_media_retain(p_md): f = _Cfunctions.get('libvlc_media_retain', None) or \ _Cfunction('libvlc_media_retain', ((1,),), None, None, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_retain - libvlc_media_retain = f return f(p_md) def libvlc_media_release(p_md): @@ -3283,9 +3193,6 @@ def libvlc_media_release(p_md): f = _Cfunctions.get('libvlc_media_release', None) or \ _Cfunction('libvlc_media_release', ((1,),), None, None, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_release - libvlc_media_release = f return f(p_md) def libvlc_media_get_mrl(p_md): @@ -3296,9 +3203,6 @@ def libvlc_media_get_mrl(p_md): f = _Cfunctions.get('libvlc_media_get_mrl', None) or \ _Cfunction('libvlc_media_get_mrl', ((1,),), string_result, ctypes.c_void_p, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_mrl - libvlc_media_get_mrl = f return f(p_md) def libvlc_media_duplicate(p_md): @@ -3308,9 +3212,6 @@ def libvlc_media_duplicate(p_md): f = _Cfunctions.get('libvlc_media_duplicate', None) or \ _Cfunction('libvlc_media_duplicate', ((1,),), class_result(Media), ctypes.c_void_p, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_duplicate - libvlc_media_duplicate = f return f(p_md) def libvlc_media_get_meta(p_md, e_meta): @@ -3329,9 +3230,6 @@ def libvlc_media_get_meta(p_md, e_meta): f = _Cfunctions.get('libvlc_media_get_meta', None) or \ _Cfunction('libvlc_media_get_meta', ((1,), (1,),), string_result, ctypes.c_void_p, Media, Meta) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_meta - libvlc_media_get_meta = f return f(p_md, e_meta) def libvlc_media_set_meta(p_md, e_meta, psz_value): @@ -3344,9 +3242,6 @@ def libvlc_media_set_meta(p_md, e_meta, psz_value): f = _Cfunctions.get('libvlc_media_set_meta', None) or \ _Cfunction('libvlc_media_set_meta', ((1,), (1,), (1,),), None, None, Media, Meta, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_set_meta - libvlc_media_set_meta = f return f(p_md, e_meta, psz_value) def libvlc_media_save_meta(p_md): @@ -3357,9 +3252,6 @@ def libvlc_media_save_meta(p_md): f = _Cfunctions.get('libvlc_media_save_meta', None) or \ _Cfunction('libvlc_media_save_meta', ((1,),), None, ctypes.c_int, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_save_meta - libvlc_media_save_meta = f return f(p_md) def libvlc_media_get_state(p_md): @@ -3375,9 +3267,6 @@ def libvlc_media_get_state(p_md): f = _Cfunctions.get('libvlc_media_get_state', None) or \ _Cfunction('libvlc_media_get_state', ((1,),), None, State, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_state - libvlc_media_get_state = f return f(p_md) def libvlc_media_get_stats(p_md, p_stats): @@ -3389,9 +3278,6 @@ def libvlc_media_get_stats(p_md, p_stats): f = _Cfunctions.get('libvlc_media_get_stats', None) or \ _Cfunction('libvlc_media_get_stats', ((1,), (1,),), None, ctypes.c_int, Media, ctypes.POINTER(MediaStats)) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_stats - libvlc_media_get_stats = f return f(p_md, p_stats) def libvlc_media_event_manager(p_md): @@ -3403,9 +3289,6 @@ def libvlc_media_event_manager(p_md): f = _Cfunctions.get('libvlc_media_event_manager', None) or \ _Cfunction('libvlc_media_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_event_manager - libvlc_media_event_manager = f return f(p_md) def libvlc_media_get_duration(p_md): @@ -3416,9 +3299,6 @@ def libvlc_media_get_duration(p_md): f = _Cfunctions.get('libvlc_media_get_duration', None) or \ _Cfunction('libvlc_media_get_duration', ((1,),), None, ctypes.c_longlong, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_duration - libvlc_media_get_duration = f return f(p_md) def libvlc_media_parse(p_md): @@ -3433,9 +3313,6 @@ def libvlc_media_parse(p_md): f = _Cfunctions.get('libvlc_media_parse', None) or \ _Cfunction('libvlc_media_parse', ((1,),), None, None, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_parse - libvlc_media_parse = f return f(p_md) def libvlc_media_parse_async(p_md): @@ -3454,9 +3331,6 @@ def libvlc_media_parse_async(p_md): f = _Cfunctions.get('libvlc_media_parse_async', None) or \ _Cfunction('libvlc_media_parse_async', ((1,),), None, None, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_parse_async - libvlc_media_parse_async = f return f(p_md) def libvlc_media_is_parsed(p_md): @@ -3468,9 +3342,6 @@ def libvlc_media_is_parsed(p_md): f = _Cfunctions.get('libvlc_media_is_parsed', None) or \ _Cfunction('libvlc_media_is_parsed', ((1,),), None, ctypes.c_int, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_is_parsed - libvlc_media_is_parsed = f return f(p_md) def libvlc_media_set_user_data(p_md, p_new_user_data): @@ -3483,9 +3354,6 @@ def libvlc_media_set_user_data(p_md, p_new_user_data): f = _Cfunctions.get('libvlc_media_set_user_data', None) or \ _Cfunction('libvlc_media_set_user_data', ((1,), (1,),), None, None, Media, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_set_user_data - libvlc_media_set_user_data = f return f(p_md, p_new_user_data) def libvlc_media_get_user_data(p_md): @@ -3497,9 +3365,6 @@ def libvlc_media_get_user_data(p_md): f = _Cfunctions.get('libvlc_media_get_user_data', None) or \ _Cfunction('libvlc_media_get_user_data', ((1,),), None, ctypes.c_void_p, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_user_data - libvlc_media_get_user_data = f return f(p_md) def libvlc_media_get_tracks_info(p_md): @@ -3514,9 +3379,6 @@ def libvlc_media_get_tracks_info(p_md): f = _Cfunctions.get('libvlc_media_get_tracks_info', None) or \ _Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), None, ctypes.c_int, Media, ctypes.POINTER(ctypes.c_void_p)) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_get_tracks_info - libvlc_media_get_tracks_info = f return f(p_md) def libvlc_media_discoverer_new_from_name(p_inst, psz_name): @@ -3528,9 +3390,6 @@ def libvlc_media_discoverer_new_from_name(p_inst, psz_name): f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \ _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer), ctypes.c_void_p, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_new_from_name - libvlc_media_discoverer_new_from_name = f return f(p_inst, psz_name) def libvlc_media_discoverer_release(p_mdis): @@ -3541,9 +3400,6 @@ def libvlc_media_discoverer_release(p_mdis): f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \ _Cfunction('libvlc_media_discoverer_release', ((1,),), None, None, MediaDiscoverer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_release - libvlc_media_discoverer_release = f return f(p_mdis) def libvlc_media_discoverer_localized_name(p_mdis): @@ -3554,9 +3410,6 @@ def libvlc_media_discoverer_localized_name(p_mdis): f = _Cfunctions.get('libvlc_media_discoverer_localized_name', None) or \ _Cfunction('libvlc_media_discoverer_localized_name', ((1,),), string_result, ctypes.c_void_p, MediaDiscoverer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_localized_name - libvlc_media_discoverer_localized_name = f return f(p_mdis) def libvlc_media_discoverer_media_list(p_mdis): @@ -3567,9 +3420,6 @@ def libvlc_media_discoverer_media_list(p_mdis): f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \ _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList), ctypes.c_void_p, MediaDiscoverer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_media_list - libvlc_media_discoverer_media_list = f return f(p_mdis) def libvlc_media_discoverer_event_manager(p_mdis): @@ -3580,9 +3430,6 @@ def libvlc_media_discoverer_event_manager(p_mdis): f = _Cfunctions.get('libvlc_media_discoverer_event_manager', None) or \ _Cfunction('libvlc_media_discoverer_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, MediaDiscoverer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_event_manager - libvlc_media_discoverer_event_manager = f return f(p_mdis) def libvlc_media_discoverer_is_running(p_mdis): @@ -3593,9 +3440,6 @@ def libvlc_media_discoverer_is_running(p_mdis): f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \ _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None, ctypes.c_int, MediaDiscoverer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_discoverer_is_running - libvlc_media_discoverer_is_running = f return f(p_mdis) def libvlc_media_library_new(p_instance): @@ -3606,9 +3450,6 @@ def libvlc_media_library_new(p_instance): f = _Cfunctions.get('libvlc_media_library_new', None) or \ _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_library_new - libvlc_media_library_new = f return f(p_instance) def libvlc_media_library_release(p_mlib): @@ -3620,9 +3461,6 @@ def libvlc_media_library_release(p_mlib): f = _Cfunctions.get('libvlc_media_library_release', None) or \ _Cfunction('libvlc_media_library_release', ((1,),), None, None, MediaLibrary) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_library_release - libvlc_media_library_release = f return f(p_mlib) def libvlc_media_library_retain(p_mlib): @@ -3634,9 +3472,6 @@ def libvlc_media_library_retain(p_mlib): f = _Cfunctions.get('libvlc_media_library_retain', None) or \ _Cfunction('libvlc_media_library_retain', ((1,),), None, None, MediaLibrary) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_library_retain - libvlc_media_library_retain = f return f(p_mlib) def libvlc_media_library_load(p_mlib): @@ -3647,9 +3482,6 @@ def libvlc_media_library_load(p_mlib): f = _Cfunctions.get('libvlc_media_library_load', None) or \ _Cfunction('libvlc_media_library_load', ((1,),), None, ctypes.c_int, MediaLibrary) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_library_load - libvlc_media_library_load = f return f(p_mlib) def libvlc_media_library_media_list(p_mlib): @@ -3660,9 +3492,6 @@ def libvlc_media_library_media_list(p_mlib): f = _Cfunctions.get('libvlc_media_library_media_list', None) or \ _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList), ctypes.c_void_p, MediaLibrary) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_library_media_list - libvlc_media_library_media_list = f return f(p_mlib) def libvlc_media_list_new(p_instance): @@ -3673,9 +3502,6 @@ def libvlc_media_list_new(p_instance): f = _Cfunctions.get('libvlc_media_list_new', None) or \ _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_new - libvlc_media_list_new = f return f(p_instance) def libvlc_media_list_release(p_ml): @@ -3685,9 +3511,6 @@ def libvlc_media_list_release(p_ml): f = _Cfunctions.get('libvlc_media_list_release', None) or \ _Cfunction('libvlc_media_list_release', ((1,),), None, None, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_release - libvlc_media_list_release = f return f(p_ml) def libvlc_media_list_retain(p_ml): @@ -3697,9 +3520,6 @@ def libvlc_media_list_retain(p_ml): f = _Cfunctions.get('libvlc_media_list_retain', None) or \ _Cfunction('libvlc_media_list_retain', ((1,),), None, None, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_retain - libvlc_media_list_retain = f return f(p_ml) def libvlc_media_list_set_media(p_ml, p_md): @@ -3712,9 +3532,6 @@ def libvlc_media_list_set_media(p_ml, p_md): f = _Cfunctions.get('libvlc_media_list_set_media', None) or \ _Cfunction('libvlc_media_list_set_media', ((1,), (1,),), None, None, MediaList, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_set_media - libvlc_media_list_set_media = f return f(p_ml, p_md) def libvlc_media_list_media(p_ml): @@ -3727,9 +3544,6 @@ def libvlc_media_list_media(p_ml): f = _Cfunctions.get('libvlc_media_list_media', None) or \ _Cfunction('libvlc_media_list_media', ((1,),), class_result(Media), ctypes.c_void_p, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_media - libvlc_media_list_media = f return f(p_ml) def libvlc_media_list_add_media(p_ml, p_md): @@ -3742,9 +3556,6 @@ def libvlc_media_list_add_media(p_ml, p_md): f = _Cfunctions.get('libvlc_media_list_add_media', None) or \ _Cfunction('libvlc_media_list_add_media', ((1,), (1,),), None, ctypes.c_int, MediaList, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_add_media - libvlc_media_list_add_media = f return f(p_ml, p_md) def libvlc_media_list_insert_media(p_ml, p_md, i_pos): @@ -3758,9 +3569,6 @@ def libvlc_media_list_insert_media(p_ml, p_md, i_pos): f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \ _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None, ctypes.c_int, MediaList, Media, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_insert_media - libvlc_media_list_insert_media = f return f(p_ml, p_md, i_pos) def libvlc_media_list_remove_index(p_ml, i_pos): @@ -3773,9 +3581,6 @@ def libvlc_media_list_remove_index(p_ml, i_pos): f = _Cfunctions.get('libvlc_media_list_remove_index', None) or \ _Cfunction('libvlc_media_list_remove_index', ((1,), (1,),), None, ctypes.c_int, MediaList, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_remove_index - libvlc_media_list_remove_index = f return f(p_ml, i_pos) def libvlc_media_list_count(p_ml): @@ -3787,9 +3592,6 @@ def libvlc_media_list_count(p_ml): f = _Cfunctions.get('libvlc_media_list_count', None) or \ _Cfunction('libvlc_media_list_count', ((1,),), None, ctypes.c_int, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_count - libvlc_media_list_count = f return f(p_ml) def libvlc_media_list_item_at_index(p_ml, i_pos): @@ -3802,9 +3604,6 @@ def libvlc_media_list_item_at_index(p_ml, i_pos): f = _Cfunctions.get('libvlc_media_list_item_at_index', None) or \ _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), class_result(Media), ctypes.c_void_p, MediaList, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_item_at_index - libvlc_media_list_item_at_index = f return f(p_ml, i_pos) def libvlc_media_list_index_of_item(p_ml, p_md): @@ -3818,9 +3617,6 @@ def libvlc_media_list_index_of_item(p_ml, p_md): f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \ _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None, ctypes.c_int, MediaList, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_index_of_item - libvlc_media_list_index_of_item = f return f(p_ml, p_md) def libvlc_media_list_is_readonly(p_ml): @@ -3831,9 +3627,6 @@ def libvlc_media_list_is_readonly(p_ml): f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \ _Cfunction('libvlc_media_list_is_readonly', ((1,),), None, ctypes.c_int, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_is_readonly - libvlc_media_list_is_readonly = f return f(p_ml) def libvlc_media_list_lock(p_ml): @@ -3843,9 +3636,6 @@ def libvlc_media_list_lock(p_ml): f = _Cfunctions.get('libvlc_media_list_lock', None) or \ _Cfunction('libvlc_media_list_lock', ((1,),), None, None, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_lock - libvlc_media_list_lock = f return f(p_ml) def libvlc_media_list_unlock(p_ml): @@ -3856,9 +3646,6 @@ def libvlc_media_list_unlock(p_ml): f = _Cfunctions.get('libvlc_media_list_unlock', None) or \ _Cfunction('libvlc_media_list_unlock', ((1,),), None, None, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_unlock - libvlc_media_list_unlock = f return f(p_ml) def libvlc_media_list_event_manager(p_ml): @@ -3870,9 +3657,6 @@ def libvlc_media_list_event_manager(p_ml): f = _Cfunctions.get('libvlc_media_list_event_manager', None) or \ _Cfunction('libvlc_media_list_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_event_manager - libvlc_media_list_event_manager = f return f(p_ml) def libvlc_media_list_player_new(p_instance): @@ -3883,9 +3667,6 @@ def libvlc_media_list_player_new(p_instance): f = _Cfunctions.get('libvlc_media_list_player_new', None) or \ _Cfunction('libvlc_media_list_player_new', ((1,),), class_result(MediaListPlayer), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_new - libvlc_media_list_player_new = f return f(p_instance) def libvlc_media_list_player_release(p_mlp): @@ -3899,9 +3680,6 @@ def libvlc_media_list_player_release(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_release', None) or \ _Cfunction('libvlc_media_list_player_release', ((1,),), None, None, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_release - libvlc_media_list_player_release = f return f(p_mlp) def libvlc_media_list_player_retain(p_mlp): @@ -3912,9 +3690,6 @@ def libvlc_media_list_player_retain(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_retain', None) or \ _Cfunction('libvlc_media_list_player_retain', ((1,),), None, None, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_retain - libvlc_media_list_player_retain = f return f(p_mlp) def libvlc_media_list_player_event_manager(p_mlp): @@ -3925,9 +3700,6 @@ def libvlc_media_list_player_event_manager(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_event_manager', None) or \ _Cfunction('libvlc_media_list_player_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_event_manager - libvlc_media_list_player_event_manager = f return f(p_mlp) def libvlc_media_list_player_set_media_player(p_mlp, p_mi): @@ -3938,9 +3710,6 @@ def libvlc_media_list_player_set_media_player(p_mlp, p_mi): f = _Cfunctions.get('libvlc_media_list_player_set_media_player', None) or \ _Cfunction('libvlc_media_list_player_set_media_player', ((1,), (1,),), None, None, MediaListPlayer, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_set_media_player - libvlc_media_list_player_set_media_player = f return f(p_mlp, p_mi) def libvlc_media_list_player_set_media_list(p_mlp, p_mlist): @@ -3951,9 +3720,6 @@ def libvlc_media_list_player_set_media_list(p_mlp, p_mlist): f = _Cfunctions.get('libvlc_media_list_player_set_media_list', None) or \ _Cfunction('libvlc_media_list_player_set_media_list', ((1,), (1,),), None, None, MediaListPlayer, MediaList) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_set_media_list - libvlc_media_list_player_set_media_list = f return f(p_mlp, p_mlist) def libvlc_media_list_player_play(p_mlp): @@ -3963,9 +3729,6 @@ def libvlc_media_list_player_play(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_play', None) or \ _Cfunction('libvlc_media_list_player_play', ((1,),), None, None, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_play - libvlc_media_list_player_play = f return f(p_mlp) def libvlc_media_list_player_pause(p_mlp): @@ -3975,9 +3738,6 @@ def libvlc_media_list_player_pause(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \ _Cfunction('libvlc_media_list_player_pause', ((1,),), None, None, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_pause - libvlc_media_list_player_pause = f return f(p_mlp) def libvlc_media_list_player_is_playing(p_mlp): @@ -3988,9 +3748,6 @@ def libvlc_media_list_player_is_playing(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \ _Cfunction('libvlc_media_list_player_is_playing', ((1,),), None, ctypes.c_int, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_is_playing - libvlc_media_list_player_is_playing = f return f(p_mlp) def libvlc_media_list_player_get_state(p_mlp): @@ -4001,9 +3758,6 @@ def libvlc_media_list_player_get_state(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_get_state', None) or \ _Cfunction('libvlc_media_list_player_get_state', ((1,),), None, State, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_get_state - libvlc_media_list_player_get_state = f return f(p_mlp) def libvlc_media_list_player_play_item_at_index(p_mlp, i_index): @@ -4015,9 +3769,6 @@ def libvlc_media_list_player_play_item_at_index(p_mlp, i_index): f = _Cfunctions.get('libvlc_media_list_player_play_item_at_index', None) or \ _Cfunction('libvlc_media_list_player_play_item_at_index', ((1,), (1,),), None, ctypes.c_int, MediaListPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_play_item_at_index - libvlc_media_list_player_play_item_at_index = f return f(p_mlp, i_index) def libvlc_media_list_player_play_item(p_mlp, p_md): @@ -4029,9 +3780,6 @@ def libvlc_media_list_player_play_item(p_mlp, p_md): f = _Cfunctions.get('libvlc_media_list_player_play_item', None) or \ _Cfunction('libvlc_media_list_player_play_item', ((1,), (1,),), None, ctypes.c_int, MediaListPlayer, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_play_item - libvlc_media_list_player_play_item = f return f(p_mlp, p_md) def libvlc_media_list_player_stop(p_mlp): @@ -4041,9 +3789,6 @@ def libvlc_media_list_player_stop(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_stop', None) or \ _Cfunction('libvlc_media_list_player_stop', ((1,),), None, None, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_stop - libvlc_media_list_player_stop = f return f(p_mlp) def libvlc_media_list_player_next(p_mlp): @@ -4054,9 +3799,6 @@ def libvlc_media_list_player_next(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_next', None) or \ _Cfunction('libvlc_media_list_player_next', ((1,),), None, ctypes.c_int, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_next - libvlc_media_list_player_next = f return f(p_mlp) def libvlc_media_list_player_previous(p_mlp): @@ -4067,9 +3809,6 @@ def libvlc_media_list_player_previous(p_mlp): f = _Cfunctions.get('libvlc_media_list_player_previous', None) or \ _Cfunction('libvlc_media_list_player_previous', ((1,),), None, ctypes.c_int, MediaListPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_previous - libvlc_media_list_player_previous = f return f(p_mlp) def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode): @@ -4080,9 +3819,6 @@ def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode): f = _Cfunctions.get('libvlc_media_list_player_set_playback_mode', None) or \ _Cfunction('libvlc_media_list_player_set_playback_mode', ((1,), (1,),), None, None, MediaListPlayer, PlaybackMode) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_list_player_set_playback_mode - libvlc_media_list_player_set_playback_mode = f return f(p_mlp, e_mode) def libvlc_media_player_new(p_libvlc_instance): @@ -4093,9 +3829,6 @@ def libvlc_media_player_new(p_libvlc_instance): f = _Cfunctions.get('libvlc_media_player_new', None) or \ _Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_new - libvlc_media_player_new = f return f(p_libvlc_instance) def libvlc_media_player_new_from_media(p_md): @@ -4106,9 +3839,6 @@ def libvlc_media_player_new_from_media(p_md): f = _Cfunctions.get('libvlc_media_player_new_from_media', None) or \ _Cfunction('libvlc_media_player_new_from_media', ((1,),), class_result(MediaPlayer), ctypes.c_void_p, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_new_from_media - libvlc_media_player_new_from_media = f return f(p_md) def libvlc_media_player_release(p_mi): @@ -4122,9 +3852,6 @@ def libvlc_media_player_release(p_mi): f = _Cfunctions.get('libvlc_media_player_release', None) or \ _Cfunction('libvlc_media_player_release', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_release - libvlc_media_player_release = f return f(p_mi) def libvlc_media_player_retain(p_mi): @@ -4135,9 +3862,6 @@ def libvlc_media_player_retain(p_mi): f = _Cfunctions.get('libvlc_media_player_retain', None) or \ _Cfunction('libvlc_media_player_retain', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_retain - libvlc_media_player_retain = f return f(p_mi) def libvlc_media_player_set_media(p_mi, p_md): @@ -4149,9 +3873,6 @@ def libvlc_media_player_set_media(p_mi, p_md): f = _Cfunctions.get('libvlc_media_player_set_media', None) or \ _Cfunction('libvlc_media_player_set_media', ((1,), (1,),), None, None, MediaPlayer, Media) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_media - libvlc_media_player_set_media = f return f(p_mi, p_md) def libvlc_media_player_get_media(p_mi): @@ -4162,9 +3883,6 @@ def libvlc_media_player_get_media(p_mi): f = _Cfunctions.get('libvlc_media_player_get_media', None) or \ _Cfunction('libvlc_media_player_get_media', ((1,),), class_result(Media), ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_media - libvlc_media_player_get_media = f return f(p_mi) def libvlc_media_player_event_manager(p_mi): @@ -4175,9 +3893,6 @@ def libvlc_media_player_event_manager(p_mi): f = _Cfunctions.get('libvlc_media_player_event_manager', None) or \ _Cfunction('libvlc_media_player_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_event_manager - libvlc_media_player_event_manager = f return f(p_mi) def libvlc_media_player_is_playing(p_mi): @@ -4188,9 +3903,6 @@ def libvlc_media_player_is_playing(p_mi): f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \ _Cfunction('libvlc_media_player_is_playing', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_is_playing - libvlc_media_player_is_playing = f return f(p_mi) def libvlc_media_player_play(p_mi): @@ -4201,9 +3913,6 @@ def libvlc_media_player_play(p_mi): f = _Cfunctions.get('libvlc_media_player_play', None) or \ _Cfunction('libvlc_media_player_play', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_play - libvlc_media_player_play = f return f(p_mi) def libvlc_media_player_set_pause(mp, do_pause): @@ -4215,9 +3924,6 @@ def libvlc_media_player_set_pause(mp, do_pause): f = _Cfunctions.get('libvlc_media_player_set_pause', None) or \ _Cfunction('libvlc_media_player_set_pause', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_pause - libvlc_media_player_set_pause = f return f(mp, do_pause) def libvlc_media_player_pause(p_mi): @@ -4227,9 +3933,6 @@ def libvlc_media_player_pause(p_mi): f = _Cfunctions.get('libvlc_media_player_pause', None) or \ _Cfunction('libvlc_media_player_pause', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_pause - libvlc_media_player_pause = f return f(p_mi) def libvlc_media_player_stop(p_mi): @@ -4239,9 +3942,6 @@ def libvlc_media_player_stop(p_mi): f = _Cfunctions.get('libvlc_media_player_stop', None) or \ _Cfunction('libvlc_media_player_stop', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_stop - libvlc_media_player_stop = f return f(p_mi) def libvlc_video_set_format(mp, chroma, width, height, pitch): @@ -4259,9 +3959,6 @@ def libvlc_video_set_format(mp, chroma, width, height, pitch): f = _Cfunctions.get('libvlc_video_set_format', None) or \ _Cfunction('libvlc_video_set_format', ((1,), (1,), (1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_format - libvlc_video_set_format = f return f(mp, chroma, width, height, pitch) def libvlc_media_player_set_nsobject(p_mi, drawable): @@ -4293,9 +3990,6 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): f = _Cfunctions.get('libvlc_media_player_set_nsobject', None) or \ _Cfunction('libvlc_media_player_set_nsobject', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_nsobject - libvlc_media_player_set_nsobject = f return f(p_mi, drawable) def libvlc_media_player_get_nsobject(p_mi): @@ -4306,9 +4000,6 @@ def libvlc_media_player_get_nsobject(p_mi): f = _Cfunctions.get('libvlc_media_player_get_nsobject', None) or \ _Cfunction('libvlc_media_player_get_nsobject', ((1,),), None, ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_nsobject - libvlc_media_player_get_nsobject = f return f(p_mi) def libvlc_media_player_set_agl(p_mi, drawable): @@ -4319,9 +4010,6 @@ def libvlc_media_player_set_agl(p_mi, drawable): f = _Cfunctions.get('libvlc_media_player_set_agl', None) or \ _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint32) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_agl - libvlc_media_player_set_agl = f return f(p_mi, drawable) def libvlc_media_player_get_agl(p_mi): @@ -4332,9 +4020,6 @@ def libvlc_media_player_get_agl(p_mi): f = _Cfunctions.get('libvlc_media_player_get_agl', None) or \ _Cfunction('libvlc_media_player_get_agl', ((1,),), None, ctypes.c_uint32, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_agl - libvlc_media_player_get_agl = f return f(p_mi) def libvlc_media_player_set_xwindow(p_mi, drawable): @@ -4352,9 +4037,6 @@ def libvlc_media_player_set_xwindow(p_mi, drawable): f = _Cfunctions.get('libvlc_media_player_set_xwindow', None) or \ _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint32) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_xwindow - libvlc_media_player_set_xwindow = f return f(p_mi, drawable) def libvlc_media_player_get_xwindow(p_mi): @@ -4368,9 +4050,6 @@ def libvlc_media_player_get_xwindow(p_mi): f = _Cfunctions.get('libvlc_media_player_get_xwindow', None) or \ _Cfunction('libvlc_media_player_get_xwindow', ((1,),), None, ctypes.c_uint32, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_xwindow - libvlc_media_player_get_xwindow = f return f(p_mi) def libvlc_media_player_set_hwnd(p_mi, drawable): @@ -4383,9 +4062,6 @@ def libvlc_media_player_set_hwnd(p_mi, drawable): f = _Cfunctions.get('libvlc_media_player_set_hwnd', None) or \ _Cfunction('libvlc_media_player_set_hwnd', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_void_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_hwnd - libvlc_media_player_set_hwnd = f return f(p_mi, drawable) def libvlc_media_player_get_hwnd(p_mi): @@ -4398,9 +4074,6 @@ def libvlc_media_player_get_hwnd(p_mi): f = _Cfunctions.get('libvlc_media_player_get_hwnd', None) or \ _Cfunction('libvlc_media_player_get_hwnd', ((1,),), None, ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_hwnd - libvlc_media_player_get_hwnd = f return f(p_mi) def libvlc_audio_set_format(mp, format, rate, channels): @@ -4416,9 +4089,6 @@ def libvlc_audio_set_format(mp, format, rate, channels): f = _Cfunctions.get('libvlc_audio_set_format', None) or \ _Cfunction('libvlc_audio_set_format', ((1,), (1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_format - libvlc_audio_set_format = f return f(mp, format, rate, channels) def libvlc_media_player_get_length(p_mi): @@ -4429,9 +4099,6 @@ def libvlc_media_player_get_length(p_mi): f = _Cfunctions.get('libvlc_media_player_get_length', None) or \ _Cfunction('libvlc_media_player_get_length', ((1,),), None, ctypes.c_longlong, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_length - libvlc_media_player_get_length = f return f(p_mi) def libvlc_media_player_get_time(p_mi): @@ -4442,9 +4109,6 @@ def libvlc_media_player_get_time(p_mi): f = _Cfunctions.get('libvlc_media_player_get_time', None) or \ _Cfunction('libvlc_media_player_get_time', ((1,),), None, ctypes.c_longlong, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_time - libvlc_media_player_get_time = f return f(p_mi) def libvlc_media_player_set_time(p_mi, i_time): @@ -4456,9 +4120,6 @@ def libvlc_media_player_set_time(p_mi, i_time): f = _Cfunctions.get('libvlc_media_player_set_time', None) or \ _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_longlong) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_time - libvlc_media_player_set_time = f return f(p_mi, i_time) def libvlc_media_player_get_position(p_mi): @@ -4469,9 +4130,6 @@ def libvlc_media_player_get_position(p_mi): f = _Cfunctions.get('libvlc_media_player_get_position', None) or \ _Cfunction('libvlc_media_player_get_position', ((1,),), None, ctypes.c_float, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_position - libvlc_media_player_get_position = f return f(p_mi) def libvlc_media_player_set_position(p_mi, f_pos): @@ -4483,9 +4141,6 @@ def libvlc_media_player_set_position(p_mi, f_pos): f = _Cfunctions.get('libvlc_media_player_set_position', None) or \ _Cfunction('libvlc_media_player_set_position', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_float) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_position - libvlc_media_player_set_position = f return f(p_mi, f_pos) def libvlc_media_player_set_chapter(p_mi, i_chapter): @@ -4496,9 +4151,6 @@ def libvlc_media_player_set_chapter(p_mi, i_chapter): f = _Cfunctions.get('libvlc_media_player_set_chapter', None) or \ _Cfunction('libvlc_media_player_set_chapter', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_chapter - libvlc_media_player_set_chapter = f return f(p_mi, i_chapter) def libvlc_media_player_get_chapter(p_mi): @@ -4509,9 +4161,6 @@ def libvlc_media_player_get_chapter(p_mi): f = _Cfunctions.get('libvlc_media_player_get_chapter', None) or \ _Cfunction('libvlc_media_player_get_chapter', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_chapter - libvlc_media_player_get_chapter = f return f(p_mi) def libvlc_media_player_get_chapter_count(p_mi): @@ -4522,9 +4171,6 @@ def libvlc_media_player_get_chapter_count(p_mi): f = _Cfunctions.get('libvlc_media_player_get_chapter_count', None) or \ _Cfunction('libvlc_media_player_get_chapter_count', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_chapter_count - libvlc_media_player_get_chapter_count = f return f(p_mi) def libvlc_media_player_will_play(p_mi): @@ -4535,9 +4181,6 @@ def libvlc_media_player_will_play(p_mi): f = _Cfunctions.get('libvlc_media_player_will_play', None) or \ _Cfunction('libvlc_media_player_will_play', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_will_play - libvlc_media_player_will_play = f return f(p_mi) def libvlc_media_player_get_chapter_count_for_title(p_mi, i_title): @@ -4549,9 +4192,6 @@ def libvlc_media_player_get_chapter_count_for_title(p_mi, i_title): f = _Cfunctions.get('libvlc_media_player_get_chapter_count_for_title', None) or \ _Cfunction('libvlc_media_player_get_chapter_count_for_title', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_chapter_count_for_title - libvlc_media_player_get_chapter_count_for_title = f return f(p_mi, i_title) def libvlc_media_player_set_title(p_mi, i_title): @@ -4562,9 +4202,6 @@ def libvlc_media_player_set_title(p_mi, i_title): f = _Cfunctions.get('libvlc_media_player_set_title', None) or \ _Cfunction('libvlc_media_player_set_title', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_title - libvlc_media_player_set_title = f return f(p_mi, i_title) def libvlc_media_player_get_title(p_mi): @@ -4575,9 +4212,6 @@ def libvlc_media_player_get_title(p_mi): f = _Cfunctions.get('libvlc_media_player_get_title', None) or \ _Cfunction('libvlc_media_player_get_title', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_title - libvlc_media_player_get_title = f return f(p_mi) def libvlc_media_player_get_title_count(p_mi): @@ -4588,9 +4222,6 @@ def libvlc_media_player_get_title_count(p_mi): f = _Cfunctions.get('libvlc_media_player_get_title_count', None) or \ _Cfunction('libvlc_media_player_get_title_count', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_title_count - libvlc_media_player_get_title_count = f return f(p_mi) def libvlc_media_player_previous_chapter(p_mi): @@ -4600,9 +4231,6 @@ def libvlc_media_player_previous_chapter(p_mi): f = _Cfunctions.get('libvlc_media_player_previous_chapter', None) or \ _Cfunction('libvlc_media_player_previous_chapter', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_previous_chapter - libvlc_media_player_previous_chapter = f return f(p_mi) def libvlc_media_player_next_chapter(p_mi): @@ -4612,9 +4240,6 @@ def libvlc_media_player_next_chapter(p_mi): f = _Cfunctions.get('libvlc_media_player_next_chapter', None) or \ _Cfunction('libvlc_media_player_next_chapter', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_next_chapter - libvlc_media_player_next_chapter = f return f(p_mi) def libvlc_media_player_get_rate(p_mi): @@ -4627,9 +4252,6 @@ def libvlc_media_player_get_rate(p_mi): f = _Cfunctions.get('libvlc_media_player_get_rate', None) or \ _Cfunction('libvlc_media_player_get_rate', ((1,),), None, ctypes.c_float, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_rate - libvlc_media_player_get_rate = f return f(p_mi) def libvlc_media_player_set_rate(p_mi, rate): @@ -4641,9 +4263,6 @@ def libvlc_media_player_set_rate(p_mi, rate): f = _Cfunctions.get('libvlc_media_player_set_rate', None) or \ _Cfunction('libvlc_media_player_set_rate', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_float) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_set_rate - libvlc_media_player_set_rate = f return f(p_mi, rate) def libvlc_media_player_get_state(p_mi): @@ -4654,9 +4273,6 @@ def libvlc_media_player_get_state(p_mi): f = _Cfunctions.get('libvlc_media_player_get_state', None) or \ _Cfunction('libvlc_media_player_get_state', ((1,),), None, State, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_state - libvlc_media_player_get_state = f return f(p_mi) def libvlc_media_player_get_fps(p_mi): @@ -4667,9 +4283,6 @@ def libvlc_media_player_get_fps(p_mi): f = _Cfunctions.get('libvlc_media_player_get_fps', None) or \ _Cfunction('libvlc_media_player_get_fps', ((1,),), None, ctypes.c_float, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_get_fps - libvlc_media_player_get_fps = f return f(p_mi) def libvlc_media_player_has_vout(p_mi): @@ -4680,9 +4293,6 @@ def libvlc_media_player_has_vout(p_mi): f = _Cfunctions.get('libvlc_media_player_has_vout', None) or \ _Cfunction('libvlc_media_player_has_vout', ((1,),), None, ctypes.c_uint, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_has_vout - libvlc_media_player_has_vout = f return f(p_mi) def libvlc_media_player_is_seekable(p_mi): @@ -4693,9 +4303,6 @@ def libvlc_media_player_is_seekable(p_mi): f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \ _Cfunction('libvlc_media_player_is_seekable', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_is_seekable - libvlc_media_player_is_seekable = f return f(p_mi) def libvlc_media_player_can_pause(p_mi): @@ -4706,9 +4313,6 @@ def libvlc_media_player_can_pause(p_mi): f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \ _Cfunction('libvlc_media_player_can_pause', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_can_pause - libvlc_media_player_can_pause = f return f(p_mi) def libvlc_media_player_next_frame(p_mi): @@ -4718,9 +4322,6 @@ def libvlc_media_player_next_frame(p_mi): f = _Cfunctions.get('libvlc_media_player_next_frame', None) or \ _Cfunction('libvlc_media_player_next_frame', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_next_frame - libvlc_media_player_next_frame = f return f(p_mi) def libvlc_media_player_navigate(p_mi, navigate): @@ -4732,21 +4333,23 @@ def libvlc_media_player_navigate(p_mi, navigate): f = _Cfunctions.get('libvlc_media_player_navigate', None) or \ _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_media_player_navigate - libvlc_media_player_navigate = f return f(p_mi, navigate) -def libvlc_track_description_release(p_track_description): +def libvlc_track_description_list_release(p_track_description): '''Release (free) L{TrackDescription}. @param p_track_description: the structure to release. ''' + f = _Cfunctions.get('libvlc_track_description_list_release', None) or \ + _Cfunction('libvlc_track_description_list_release', ((1,),), None, + None, ctypes.POINTER(TrackDescription)) + 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)) - if not __debug__: # i.e. python -O or -OO - global libvlc_track_description_release - libvlc_track_description_release = f return f(p_track_description) def libvlc_toggle_fullscreen(p_mi): @@ -4758,9 +4361,6 @@ def libvlc_toggle_fullscreen(p_mi): f = _Cfunctions.get('libvlc_toggle_fullscreen', None) or \ _Cfunction('libvlc_toggle_fullscreen', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_toggle_fullscreen - libvlc_toggle_fullscreen = f return f(p_mi) def libvlc_set_fullscreen(p_mi, b_fullscreen): @@ -4777,9 +4377,6 @@ def libvlc_set_fullscreen(p_mi, b_fullscreen): f = _Cfunctions.get('libvlc_set_fullscreen', None) or \ _Cfunction('libvlc_set_fullscreen', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_set_fullscreen - libvlc_set_fullscreen = f return f(p_mi, b_fullscreen) def libvlc_get_fullscreen(p_mi): @@ -4790,9 +4387,6 @@ def libvlc_get_fullscreen(p_mi): f = _Cfunctions.get('libvlc_get_fullscreen', None) or \ _Cfunction('libvlc_get_fullscreen', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_get_fullscreen - libvlc_get_fullscreen = f return f(p_mi) def libvlc_video_set_key_input(p_mi, on): @@ -4810,9 +4404,6 @@ def libvlc_video_set_key_input(p_mi, on): f = _Cfunctions.get('libvlc_video_set_key_input', None) or \ _Cfunction('libvlc_video_set_key_input', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_key_input - libvlc_video_set_key_input = f return f(p_mi, on) def libvlc_video_set_mouse_input(p_mi, on): @@ -4827,9 +4418,6 @@ def libvlc_video_set_mouse_input(p_mi, on): f = _Cfunctions.get('libvlc_video_set_mouse_input', None) or \ _Cfunction('libvlc_video_set_mouse_input', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_mouse_input - libvlc_video_set_mouse_input = f return f(p_mi, on) def libvlc_video_get_size(p_mi, num): @@ -4841,9 +4429,6 @@ def libvlc_video_get_size(p_mi, num): f = _Cfunctions.get('libvlc_video_get_size', None) or \ _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_size - libvlc_video_get_size = f return f(p_mi, num) def libvlc_video_get_cursor(p_mi, num): @@ -4865,9 +4450,6 @@ def libvlc_video_get_cursor(p_mi, num): f = _Cfunctions.get('libvlc_video_get_cursor', None) or \ _Cfunction('libvlc_video_get_cursor', ((1,), (1,), (2,), (2,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_cursor - libvlc_video_get_cursor = f return f(p_mi, num) def libvlc_video_get_scale(p_mi): @@ -4879,9 +4461,6 @@ def libvlc_video_get_scale(p_mi): f = _Cfunctions.get('libvlc_video_get_scale', None) or \ _Cfunction('libvlc_video_get_scale', ((1,),), None, ctypes.c_float, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_scale - libvlc_video_get_scale = f return f(p_mi) def libvlc_video_set_scale(p_mi, f_factor): @@ -4896,9 +4475,6 @@ def libvlc_video_set_scale(p_mi, f_factor): f = _Cfunctions.get('libvlc_video_set_scale', None) or \ _Cfunction('libvlc_video_set_scale', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_float) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_scale - libvlc_video_set_scale = f return f(p_mi, f_factor) def libvlc_video_get_aspect_ratio(p_mi): @@ -4909,9 +4485,6 @@ def libvlc_video_get_aspect_ratio(p_mi): f = _Cfunctions.get('libvlc_video_get_aspect_ratio', None) or \ _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), string_result, ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_aspect_ratio - libvlc_video_get_aspect_ratio = f return f(p_mi) def libvlc_video_set_aspect_ratio(p_mi, psz_aspect): @@ -4922,9 +4495,6 @@ def libvlc_video_set_aspect_ratio(p_mi, psz_aspect): f = _Cfunctions.get('libvlc_video_set_aspect_ratio', None) or \ _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_aspect_ratio - libvlc_video_set_aspect_ratio = f return f(p_mi, psz_aspect) def libvlc_video_get_spu(p_mi): @@ -4935,9 +4505,6 @@ def libvlc_video_get_spu(p_mi): f = _Cfunctions.get('libvlc_video_get_spu', None) or \ _Cfunction('libvlc_video_get_spu', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_spu - libvlc_video_get_spu = f return f(p_mi) def libvlc_video_get_spu_count(p_mi): @@ -4948,9 +4515,6 @@ def libvlc_video_get_spu_count(p_mi): f = _Cfunctions.get('libvlc_video_get_spu_count', None) or \ _Cfunction('libvlc_video_get_spu_count', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_spu_count - libvlc_video_get_spu_count = f return f(p_mi) def libvlc_video_get_spu_description(p_mi): @@ -4961,9 +4525,6 @@ def libvlc_video_get_spu_description(p_mi): f = _Cfunctions.get('libvlc_video_get_spu_description', None) or \ _Cfunction('libvlc_video_get_spu_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_spu_description - libvlc_video_get_spu_description = f return f(p_mi) def libvlc_video_set_spu(p_mi, i_spu): @@ -4975,9 +4536,6 @@ def libvlc_video_set_spu(p_mi, i_spu): f = _Cfunctions.get('libvlc_video_set_spu', None) or \ _Cfunction('libvlc_video_set_spu', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_spu - libvlc_video_set_spu = f return f(p_mi, i_spu) def libvlc_video_set_subtitle_file(p_mi, psz_subtitle): @@ -4989,11 +4547,35 @@ def libvlc_video_set_subtitle_file(p_mi, psz_subtitle): f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \ _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_subtitle_file - libvlc_video_set_subtitle_file = f return f(p_mi, psz_subtitle) +def libvlc_video_get_spu_delay(p_mi): + '''Get the current subtitle delay. Positive values means subtitles are being + displayed later, negative values earlier. + @param p_mi: media player. + @return: time (in microseconds) the display of subtitles is being delayed. + @version: LibVLC 1.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \ + _Cfunction('libvlc_video_get_spu_delay', ((1,),), None, + ctypes.c_int64, MediaPlayer) + return f(p_mi) + +def libvlc_video_set_spu_delay(p_mi, i_delay): + '''Set the subtitle delay. This affects the timing of when the subtitle will + be displayed. Positive values result in subtitles being displayed later, + while negative values will result in subtitles being displayed earlier. + The subtitle delay will be reset to zero each time the media changes. + @param p_mi: media player. + @param i_delay: time (in microseconds) the display of subtitles should be delayed. + @return: 0 on success, -1 on error. + @version: LibVLC 1.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \ + _Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int64) + return f(p_mi, i_delay) + def libvlc_video_get_title_description(p_mi): '''Get the description of available titles. @param p_mi: the media player. @@ -5002,9 +4584,6 @@ def libvlc_video_get_title_description(p_mi): f = _Cfunctions.get('libvlc_video_get_title_description', None) or \ _Cfunction('libvlc_video_get_title_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_title_description - libvlc_video_get_title_description = f return f(p_mi) def libvlc_video_get_chapter_description(p_mi, i_title): @@ -5016,9 +4595,6 @@ def libvlc_video_get_chapter_description(p_mi, i_title): f = _Cfunctions.get('libvlc_video_get_chapter_description', None) or \ _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_chapter_description - libvlc_video_get_chapter_description = f return f(p_mi, i_title) def libvlc_video_get_crop_geometry(p_mi): @@ -5029,9 +4605,6 @@ def libvlc_video_get_crop_geometry(p_mi): f = _Cfunctions.get('libvlc_video_get_crop_geometry', None) or \ _Cfunction('libvlc_video_get_crop_geometry', ((1,),), string_result, ctypes.c_void_p, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_crop_geometry - libvlc_video_get_crop_geometry = f return f(p_mi) def libvlc_video_set_crop_geometry(p_mi, psz_geometry): @@ -5042,9 +4615,6 @@ def libvlc_video_set_crop_geometry(p_mi, psz_geometry): f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \ _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_crop_geometry - libvlc_video_set_crop_geometry = f return f(p_mi, psz_geometry) def libvlc_video_get_teletext(p_mi): @@ -5055,9 +4625,6 @@ def libvlc_video_get_teletext(p_mi): f = _Cfunctions.get('libvlc_video_get_teletext', None) or \ _Cfunction('libvlc_video_get_teletext', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_teletext - libvlc_video_get_teletext = f return f(p_mi) def libvlc_video_set_teletext(p_mi, i_page): @@ -5068,9 +4635,6 @@ def libvlc_video_set_teletext(p_mi, i_page): f = _Cfunctions.get('libvlc_video_set_teletext', None) or \ _Cfunction('libvlc_video_set_teletext', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_teletext - libvlc_video_set_teletext = f return f(p_mi, i_page) def libvlc_toggle_teletext(p_mi): @@ -5080,9 +4644,6 @@ def libvlc_toggle_teletext(p_mi): f = _Cfunctions.get('libvlc_toggle_teletext', None) or \ _Cfunction('libvlc_toggle_teletext', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_toggle_teletext - libvlc_toggle_teletext = f return f(p_mi) def libvlc_video_get_track_count(p_mi): @@ -5093,9 +4654,6 @@ def libvlc_video_get_track_count(p_mi): f = _Cfunctions.get('libvlc_video_get_track_count', None) or \ _Cfunction('libvlc_video_get_track_count', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_track_count - libvlc_video_get_track_count = f return f(p_mi) def libvlc_video_get_track_description(p_mi): @@ -5106,9 +4664,6 @@ def libvlc_video_get_track_description(p_mi): f = _Cfunctions.get('libvlc_video_get_track_description', None) or \ _Cfunction('libvlc_video_get_track_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_track_description - libvlc_video_get_track_description = f return f(p_mi) def libvlc_video_get_track(p_mi): @@ -5119,9 +4674,6 @@ def libvlc_video_get_track(p_mi): f = _Cfunctions.get('libvlc_video_get_track', None) or \ _Cfunction('libvlc_video_get_track', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_track - libvlc_video_get_track = f return f(p_mi) def libvlc_video_set_track(p_mi, i_track): @@ -5133,9 +4685,6 @@ def libvlc_video_set_track(p_mi, i_track): f = _Cfunctions.get('libvlc_video_set_track', None) or \ _Cfunction('libvlc_video_set_track', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_track - libvlc_video_set_track = f return f(p_mi, i_track) def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height): @@ -5152,9 +4701,6 @@ def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height): f = _Cfunctions.get('libvlc_video_take_snapshot', None) or \ _Cfunction('libvlc_video_take_snapshot', ((1,), (1,), (1,), (1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_take_snapshot - libvlc_video_take_snapshot = f return f(p_mi, num, psz_filepath, i_width, i_height) def libvlc_video_set_deinterlace(p_mi, psz_mode): @@ -5165,9 +4711,6 @@ def libvlc_video_set_deinterlace(p_mi, psz_mode): f = _Cfunctions.get('libvlc_video_set_deinterlace', None) or \ _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_deinterlace - libvlc_video_set_deinterlace = f return f(p_mi, psz_mode) def libvlc_video_get_marquee_int(p_mi, option): @@ -5178,9 +4721,6 @@ def libvlc_video_get_marquee_int(p_mi, option): f = _Cfunctions.get('libvlc_video_get_marquee_int', None) or \ _Cfunction('libvlc_video_get_marquee_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_marquee_int - libvlc_video_get_marquee_int = f return f(p_mi, option) def libvlc_video_get_marquee_string(p_mi, option): @@ -5191,9 +4731,6 @@ def libvlc_video_get_marquee_string(p_mi, option): f = _Cfunctions.get('libvlc_video_get_marquee_string', None) or \ _Cfunction('libvlc_video_get_marquee_string', ((1,), (1,),), string_result, ctypes.c_void_p, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_marquee_string - libvlc_video_get_marquee_string = f return f(p_mi, option) def libvlc_video_set_marquee_int(p_mi, option, i_val): @@ -5207,9 +4744,6 @@ def libvlc_video_set_marquee_int(p_mi, option, i_val): f = _Cfunctions.get('libvlc_video_set_marquee_int', None) or \ _Cfunction('libvlc_video_set_marquee_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_marquee_int - libvlc_video_set_marquee_int = f return f(p_mi, option, i_val) def libvlc_video_set_marquee_string(p_mi, option, psz_text): @@ -5221,9 +4755,6 @@ def libvlc_video_set_marquee_string(p_mi, option, psz_text): f = _Cfunctions.get('libvlc_video_set_marquee_string', None) or \ _Cfunction('libvlc_video_set_marquee_string', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_marquee_string - libvlc_video_set_marquee_string = f return f(p_mi, option, psz_text) def libvlc_video_get_logo_int(p_mi, option): @@ -5234,9 +4765,6 @@ def libvlc_video_get_logo_int(p_mi, option): f = _Cfunctions.get('libvlc_video_get_logo_int', None) or \ _Cfunction('libvlc_video_get_logo_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_logo_int - libvlc_video_get_logo_int = f return f(p_mi, option) def libvlc_video_set_logo_int(p_mi, option, value): @@ -5251,9 +4779,6 @@ def libvlc_video_set_logo_int(p_mi, option, value): f = _Cfunctions.get('libvlc_video_set_logo_int', None) or \ _Cfunction('libvlc_video_set_logo_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_logo_int - libvlc_video_set_logo_int = f return f(p_mi, option, value) def libvlc_video_set_logo_string(p_mi, option, psz_value): @@ -5266,9 +4791,6 @@ def libvlc_video_set_logo_string(p_mi, option, psz_value): f = _Cfunctions.get('libvlc_video_set_logo_string', None) or \ _Cfunction('libvlc_video_set_logo_string', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_logo_string - libvlc_video_set_logo_string = f return f(p_mi, option, psz_value) def libvlc_video_get_adjust_int(p_mi, option): @@ -5280,9 +4802,6 @@ def libvlc_video_get_adjust_int(p_mi, option): f = _Cfunctions.get('libvlc_video_get_adjust_int', None) or \ _Cfunction('libvlc_video_get_adjust_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_adjust_int - libvlc_video_get_adjust_int = f return f(p_mi, option) def libvlc_video_set_adjust_int(p_mi, option, value): @@ -5298,9 +4817,6 @@ def libvlc_video_set_adjust_int(p_mi, option, value): f = _Cfunctions.get('libvlc_video_set_adjust_int', None) or \ _Cfunction('libvlc_video_set_adjust_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_adjust_int - libvlc_video_set_adjust_int = f return f(p_mi, option, value) def libvlc_video_get_adjust_float(p_mi, option): @@ -5312,9 +4828,6 @@ def libvlc_video_get_adjust_float(p_mi, option): f = _Cfunctions.get('libvlc_video_get_adjust_float', None) or \ _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), None, ctypes.c_float, MediaPlayer, ctypes.c_uint) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_get_adjust_float - libvlc_video_get_adjust_float = f return f(p_mi, option) def libvlc_video_set_adjust_float(p_mi, option, value): @@ -5328,9 +4841,6 @@ def libvlc_video_set_adjust_float(p_mi, option, value): f = _Cfunctions.get('libvlc_video_set_adjust_float', None) or \ _Cfunction('libvlc_video_set_adjust_float', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_float) - if not __debug__: # i.e. python -O or -OO - global libvlc_video_set_adjust_float - libvlc_video_set_adjust_float = f return f(p_mi, option, value) def libvlc_audio_output_list_get(p_instance): @@ -5341,9 +4851,6 @@ def libvlc_audio_output_list_get(p_instance): f = _Cfunctions.get('libvlc_audio_output_list_get', None) or \ _Cfunction('libvlc_audio_output_list_get', ((1,),), None, ctypes.POINTER(AudioOutput), Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_list_get - libvlc_audio_output_list_get = f return f(p_instance) def libvlc_audio_output_list_release(p_list): @@ -5353,9 +4860,6 @@ def libvlc_audio_output_list_release(p_list): f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \ _Cfunction('libvlc_audio_output_list_release', ((1,),), None, None, ctypes.POINTER(AudioOutput)) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_list_release - libvlc_audio_output_list_release = f return f(p_list) def libvlc_audio_output_set(p_mi, psz_name): @@ -5368,9 +4872,6 @@ def libvlc_audio_output_set(p_mi, psz_name): f = _Cfunctions.get('libvlc_audio_output_set', None) or \ _Cfunction('libvlc_audio_output_set', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_set - libvlc_audio_output_set = f return f(p_mi, psz_name) def libvlc_audio_output_device_count(p_instance, psz_audio_output): @@ -5383,9 +4884,6 @@ def libvlc_audio_output_device_count(p_instance, psz_audio_output): f = _Cfunctions.get('libvlc_audio_output_device_count', None) or \ _Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_device_count - libvlc_audio_output_device_count = f return f(p_instance, psz_audio_output) def libvlc_audio_output_device_longname(p_instance, psz_audio_output, i_device): @@ -5398,9 +4896,6 @@ def libvlc_audio_output_device_longname(p_instance, psz_audio_output, i_device): f = _Cfunctions.get('libvlc_audio_output_device_longname', None) or \ _Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), string_result, ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_device_longname - libvlc_audio_output_device_longname = f return f(p_instance, psz_audio_output, i_device) def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device): @@ -5413,9 +4908,6 @@ def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device): 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) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_device_id - libvlc_audio_output_device_id = f return f(p_instance, psz_audio_output, i_device) def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): @@ -5427,9 +4919,6 @@ def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \ _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_device_set - libvlc_audio_output_device_set = f return f(p_mi, psz_audio_output, psz_device_id) def libvlc_audio_output_get_device_type(p_mi): @@ -5441,9 +4930,6 @@ def libvlc_audio_output_get_device_type(p_mi): f = _Cfunctions.get('libvlc_audio_output_get_device_type', None) or \ _Cfunction('libvlc_audio_output_get_device_type', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_get_device_type - libvlc_audio_output_get_device_type = f return f(p_mi) def libvlc_audio_output_set_device_type(p_mi, device_type): @@ -5454,9 +4940,6 @@ def libvlc_audio_output_set_device_type(p_mi, 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) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_output_set_device_type - libvlc_audio_output_set_device_type = f return f(p_mi, device_type) def libvlc_audio_toggle_mute(p_mi): @@ -5466,9 +4949,6 @@ def libvlc_audio_toggle_mute(p_mi): f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \ _Cfunction('libvlc_audio_toggle_mute', ((1,),), None, None, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_toggle_mute - libvlc_audio_toggle_mute = f return f(p_mi) def libvlc_audio_get_mute(p_mi): @@ -5479,9 +4959,6 @@ def libvlc_audio_get_mute(p_mi): f = _Cfunctions.get('libvlc_audio_get_mute', None) or \ _Cfunction('libvlc_audio_get_mute', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_mute - libvlc_audio_get_mute = f return f(p_mi) def libvlc_audio_set_mute(p_mi, status): @@ -5492,9 +4969,6 @@ def libvlc_audio_set_mute(p_mi, status): f = _Cfunctions.get('libvlc_audio_set_mute', None) or \ _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_mute - libvlc_audio_set_mute = f return f(p_mi, status) def libvlc_audio_get_volume(p_mi): @@ -5505,9 +4979,6 @@ def libvlc_audio_get_volume(p_mi): f = _Cfunctions.get('libvlc_audio_get_volume', None) or \ _Cfunction('libvlc_audio_get_volume', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_volume - libvlc_audio_get_volume = f return f(p_mi) def libvlc_audio_set_volume(p_mi, i_volume): @@ -5519,9 +4990,6 @@ def libvlc_audio_set_volume(p_mi, i_volume): f = _Cfunctions.get('libvlc_audio_set_volume', None) or \ _Cfunction('libvlc_audio_set_volume', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_volume - libvlc_audio_set_volume = f return f(p_mi, i_volume) def libvlc_audio_get_track_count(p_mi): @@ -5532,9 +5000,6 @@ def libvlc_audio_get_track_count(p_mi): f = _Cfunctions.get('libvlc_audio_get_track_count', None) or \ _Cfunction('libvlc_audio_get_track_count', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_track_count - libvlc_audio_get_track_count = f return f(p_mi) def libvlc_audio_get_track_description(p_mi): @@ -5545,9 +5010,6 @@ def libvlc_audio_get_track_description(p_mi): f = _Cfunctions.get('libvlc_audio_get_track_description', None) or \ _Cfunction('libvlc_audio_get_track_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_track_description - libvlc_audio_get_track_description = f return f(p_mi) def libvlc_audio_get_track(p_mi): @@ -5558,9 +5020,6 @@ def libvlc_audio_get_track(p_mi): f = _Cfunctions.get('libvlc_audio_get_track', None) or \ _Cfunction('libvlc_audio_get_track', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_track - libvlc_audio_get_track = f return f(p_mi) def libvlc_audio_set_track(p_mi, i_track): @@ -5572,9 +5031,6 @@ def libvlc_audio_set_track(p_mi, i_track): f = _Cfunctions.get('libvlc_audio_set_track', None) or \ _Cfunction('libvlc_audio_set_track', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_track - libvlc_audio_set_track = f return f(p_mi, i_track) def libvlc_audio_get_channel(p_mi): @@ -5585,9 +5041,6 @@ def libvlc_audio_get_channel(p_mi): f = _Cfunctions.get('libvlc_audio_get_channel', None) or \ _Cfunction('libvlc_audio_get_channel', ((1,),), None, ctypes.c_int, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_channel - libvlc_audio_get_channel = f return f(p_mi) def libvlc_audio_set_channel(p_mi, channel): @@ -5599,9 +5052,6 @@ def libvlc_audio_set_channel(p_mi, channel): f = _Cfunctions.get('libvlc_audio_set_channel', None) or \ _Cfunction('libvlc_audio_set_channel', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_channel - libvlc_audio_set_channel = f return f(p_mi, channel) def libvlc_audio_get_delay(p_mi): @@ -5613,9 +5063,6 @@ def libvlc_audio_get_delay(p_mi): f = _Cfunctions.get('libvlc_audio_get_delay', None) or \ _Cfunction('libvlc_audio_get_delay', ((1,),), None, ctypes.c_int64, MediaPlayer) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_get_delay - libvlc_audio_get_delay = f return f(p_mi) def libvlc_audio_set_delay(p_mi, i_delay): @@ -5628,9 +5075,6 @@ def libvlc_audio_set_delay(p_mi, i_delay): f = _Cfunctions.get('libvlc_audio_set_delay', None) or \ _Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int64) - if not __debug__: # i.e. python -O or -OO - global libvlc_audio_set_delay - libvlc_audio_set_delay = f return f(p_mi, i_delay) def libvlc_vlm_release(p_instance): @@ -5640,9 +5084,6 @@ def libvlc_vlm_release(p_instance): f = _Cfunctions.get('libvlc_vlm_release', None) or \ _Cfunction('libvlc_vlm_release', ((1,),), None, None, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_release - libvlc_vlm_release = f return f(p_instance) def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): @@ -5660,9 +5101,6 @@ def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_opti f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \ _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_add_broadcast - libvlc_vlm_add_broadcast = f return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux): @@ -5679,9 +5117,6 @@ def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \ _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_add_vod - libvlc_vlm_add_vod = f return f(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux) def libvlc_vlm_del_media(p_instance, psz_name): @@ -5693,9 +5128,6 @@ def libvlc_vlm_del_media(p_instance, psz_name): f = _Cfunctions.get('libvlc_vlm_del_media', None) or \ _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_del_media - libvlc_vlm_del_media = f return f(p_instance, psz_name) def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled): @@ -5708,9 +5140,6 @@ def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled): f = _Cfunctions.get('libvlc_vlm_set_enabled', None) or \ _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_set_enabled - libvlc_vlm_set_enabled = f return f(p_instance, psz_name, b_enabled) def libvlc_vlm_set_output(p_instance, psz_name, psz_output): @@ -5723,9 +5152,6 @@ def libvlc_vlm_set_output(p_instance, psz_name, psz_output): f = _Cfunctions.get('libvlc_vlm_set_output', None) or \ _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_set_output - libvlc_vlm_set_output = f return f(p_instance, psz_name, psz_output) def libvlc_vlm_set_input(p_instance, psz_name, psz_input): @@ -5739,9 +5165,6 @@ def libvlc_vlm_set_input(p_instance, psz_name, psz_input): f = _Cfunctions.get('libvlc_vlm_set_input', None) or \ _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_set_input - libvlc_vlm_set_input = f return f(p_instance, psz_name, psz_input) def libvlc_vlm_add_input(p_instance, psz_name, psz_input): @@ -5754,9 +5177,6 @@ def libvlc_vlm_add_input(p_instance, psz_name, psz_input): f = _Cfunctions.get('libvlc_vlm_add_input', None) or \ _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_add_input - libvlc_vlm_add_input = f return f(p_instance, psz_name, psz_input) def libvlc_vlm_set_loop(p_instance, psz_name, b_loop): @@ -5769,9 +5189,6 @@ def libvlc_vlm_set_loop(p_instance, psz_name, b_loop): f = _Cfunctions.get('libvlc_vlm_set_loop', None) or \ _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_set_loop - libvlc_vlm_set_loop = f return f(p_instance, psz_name, b_loop) def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux): @@ -5784,9 +5201,6 @@ def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux): f = _Cfunctions.get('libvlc_vlm_set_mux', None) or \ _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_set_mux - libvlc_vlm_set_mux = f return f(p_instance, psz_name, psz_mux) def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): @@ -5805,9 +5219,6 @@ def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_optio f = _Cfunctions.get('libvlc_vlm_change_media', None) or \ _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_change_media - libvlc_vlm_change_media = f return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop) def libvlc_vlm_play_media(p_instance, psz_name): @@ -5819,9 +5230,6 @@ def libvlc_vlm_play_media(p_instance, psz_name): f = _Cfunctions.get('libvlc_vlm_play_media', None) or \ _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_play_media - libvlc_vlm_play_media = f return f(p_instance, psz_name) def libvlc_vlm_stop_media(p_instance, psz_name): @@ -5833,9 +5241,6 @@ def libvlc_vlm_stop_media(p_instance, psz_name): f = _Cfunctions.get('libvlc_vlm_stop_media', None) or \ _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_stop_media - libvlc_vlm_stop_media = f return f(p_instance, psz_name) def libvlc_vlm_pause_media(p_instance, psz_name): @@ -5847,9 +5252,6 @@ def libvlc_vlm_pause_media(p_instance, psz_name): f = _Cfunctions.get('libvlc_vlm_pause_media', None) or \ _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_pause_media - libvlc_vlm_pause_media = f return f(p_instance, psz_name) def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage): @@ -5862,9 +5264,6 @@ def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage): f = _Cfunctions.get('libvlc_vlm_seek_media', None) or \ _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_seek_media - libvlc_vlm_seek_media = f return f(p_instance, psz_name, f_percentage) def libvlc_vlm_show_media(p_instance, psz_name): @@ -5883,9 +5282,6 @@ def libvlc_vlm_show_media(p_instance, psz_name): f = _Cfunctions.get('libvlc_vlm_show_media', None) or \ _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result, ctypes.c_void_p, Instance, ctypes.c_char_p) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_show_media - libvlc_vlm_show_media = f return f(p_instance, psz_name) def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance): @@ -5898,9 +5294,6 @@ def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_position', None) or \ _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), None, ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_position - libvlc_vlm_get_media_instance_position = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance): @@ -5913,9 +5306,6 @@ def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_time', None) or \ _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_time - libvlc_vlm_get_media_instance_time = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance): @@ -5928,9 +5318,6 @@ def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_length', None) or \ _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_length - libvlc_vlm_get_media_instance_length = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance): @@ -5943,9 +5330,6 @@ def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_rate', None) or \ _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_rate - libvlc_vlm_get_media_instance_rate = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance): @@ -5959,9 +5343,6 @@ def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_title', None) or \ _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_title - libvlc_vlm_get_media_instance_title = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance): @@ -5975,9 +5356,6 @@ def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_chapter', None) or \ _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_chapter - libvlc_vlm_get_media_instance_chapter = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance): @@ -5991,9 +5369,6 @@ def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance): f = _Cfunctions.get('libvlc_vlm_get_media_instance_seekable', None) or \ _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_media_instance_seekable - libvlc_vlm_get_media_instance_seekable = f return f(p_instance, psz_name, i_instance) def libvlc_vlm_get_event_manager(p_instance): @@ -6005,21 +5380,20 @@ def libvlc_vlm_get_event_manager(p_instance): f = _Cfunctions.get('libvlc_vlm_get_event_manager', None) or \ _Cfunction('libvlc_vlm_get_event_manager', ((1,),), class_result(EventManager), ctypes.c_void_p, Instance) - if not __debug__: # i.e. python -O or -OO - global libvlc_vlm_get_event_manager - libvlc_vlm_get_event_manager = f return f(p_instance) -# 6 function(s) blacklisted: +# 8 function(s) blacklisted: # libvlc_audio_set_callbacks # libvlc_audio_set_format_callbacks # libvlc_audio_set_volume_callback +# libvlc_printerr # libvlc_set_exit_handler # libvlc_video_set_callbacks # libvlc_video_set_format_callbacks +# libvlc_vprinterr -# 12 function(s) not wrapped as methods: +# 13 function(s) not wrapped as methods: # libvlc_audio_output_list_release # libvlc_clearerr # libvlc_clock @@ -6031,6 +5405,7 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_get_version # libvlc_module_description_list_release # libvlc_new +# libvlc_track_description_list_release # libvlc_track_description_release # Start of footer.py # diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index aed6b96cc..069df669e 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, Receiver -from openlp.core.lib.ui import UiStrings +from openlp.core.lib.ui import UiStrings, create_up_down_push_button_set class MediaTab(SettingsTab): """ @@ -57,7 +57,7 @@ class MediaTab(SettingsTab): self.leftLayout.addWidget(self.mediaPlayerGroupBox) self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn) self.playerOrderGroupBox.setObjectName(u'playerOrderGroupBox') - self.playerOrderLayout = QtGui.QVBoxLayout(self.playerOrderGroupBox) + self.playerOrderLayout = QtGui.QHBoxLayout(self.playerOrderGroupBox) self.playerOrderLayout.setObjectName(u'playerOrderLayout') self.playerOrderlistWidget = QtGui.QListWidget( \ self.playerOrderGroupBox) @@ -76,18 +76,15 @@ class MediaTab(SettingsTab): QtGui.QAbstractItemView.NoEditTriggers) self.playerOrderlistWidget.setObjectName(u'playerOrderlistWidget') self.playerOrderLayout.addWidget(self.playerOrderlistWidget) - self.orderingButtonsWidget = QtGui.QWidget(self.playerOrderGroupBox) - self.orderingButtonsWidget.setObjectName(u'orderingButtonsWidget') - self.orderingButtonLayout = QtGui.QHBoxLayout( \ - self.orderingButtonsWidget) + self.orderingButtonLayout = QtGui.QVBoxLayout() self.orderingButtonLayout.setObjectName(u'orderingButtonLayout') - self.orderingDownButton = QtGui.QPushButton(self.orderingButtonsWidget) - self.orderingDownButton.setObjectName(u'orderingDownButton') - self.orderingButtonLayout.addWidget(self.orderingDownButton) - self.orderingUpButton = QtGui.QPushButton(self.playerOrderGroupBox) - self.orderingUpButton.setObjectName(u'orderingUpButton') + self.orderingButtonLayout.addStretch(1) + self.orderingUpButton, self.orderingDownButton = \ + create_up_down_push_button_set(self) self.orderingButtonLayout.addWidget(self.orderingUpButton) - self.playerOrderLayout.addWidget(self.orderingButtonsWidget) + self.orderingButtonLayout.addWidget(self.orderingDownButton) + self.orderingButtonLayout.addStretch(1) + self.playerOrderLayout.addLayout(self.orderingButtonLayout) self.leftLayout.addWidget(self.playerOrderGroupBox) self.advancedGroupBox = QtGui.QGroupBox(self.leftColumn) self.advancedGroupBox.setObjectName(u'advancedGroupBox') @@ -105,10 +102,6 @@ class MediaTab(SettingsTab): QtCore.QObject.connect(checkbox, QtCore.SIGNAL(u'stateChanged(int)'), self.onPlayerCheckBoxChanged) - QtCore.QObject.connect(self.orderingUpButton, - QtCore.SIGNAL(u'pressed()'), self.onOrderingUpButtonPressed) - QtCore.QObject.connect(self.orderingDownButton, - QtCore.SIGNAL(u'pressed()'), self.onOrderingDownButtonPressed) def retranslateUi(self): self.mediaPlayerGroupBox.setTitle( @@ -124,10 +117,6 @@ class MediaTab(SettingsTab): '%s (unavailable)')) % player.name) self.playerOrderGroupBox.setTitle( translate('MediaPlugin.MediaTab', 'Player Order')) - self.orderingDownButton.setText( - translate('MediaPlugin.MediaTab', 'Down')) - self.orderingUpButton.setText( - translate('MediaPlugin.MediaTab', 'Up')) self.advancedGroupBox.setTitle(UiStrings().Advanced) self.overridePlayerCheckBox.setText( translate('MediaPlugin.MediaTab', @@ -154,21 +143,23 @@ class MediaTab(SettingsTab): self.playerCheckBoxes[u'%s' % player].setEnabled(True) self.playerOrderlistWidget.addItem(player) - def onOrderingUpButtonPressed(self): - currentRow = self.playerOrderlistWidget.currentRow() - if currentRow > 0: - item = self.playerOrderlistWidget.takeItem(currentRow) - self.playerOrderlistWidget.insertItem(currentRow - 1, item) - self.playerOrderlistWidget.setCurrentRow(currentRow - 1) - self.usedPlayers.move(currentRow, currentRow - 1) + def onUpButtonClicked(self): + row = self.playerOrderlistWidget.currentRow() + if row <= 0: + return + item = self.playerOrderlistWidget.takeItem(row) + self.playerOrderlistWidget.insertItem(row - 1, item) + self.playerOrderlistWidget.setCurrentRow(row - 1) + self.usedPlayers.move(row, row - 1) - def onOrderingDownButtonPressed(self): - currentRow = self.playerOrderlistWidget.currentRow() - if currentRow < self.playerOrderlistWidget.count() - 1: - item = self.playerOrderlistWidget.takeItem(currentRow) - self.playerOrderlistWidget.insertItem(currentRow + 1, item) - self.playerOrderlistWidget.setCurrentRow(currentRow + 1) - self.usedPlayers.move(currentRow, currentRow + 1) + def onDownButtonClicked(self): + row = self.playerOrderlistWidget.currentRow() + if row == -1 or row > self.playerOrderlistWidget.count() - 1: + return + item = self.playerOrderlistWidget.takeItem(row) + self.playerOrderlistWidget.insertItem(row + 1, item) + self.playerOrderlistWidget.setCurrentRow(row + 1) + self.usedPlayers.move(row, row + 1) def load(self): if self.savedUsedPlayers: From 9be2fef0c8f8ba746d90a532d472c35f43402335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 9 Mar 2012 08:19:39 +0200 Subject: [PATCH 44/46] Added error type back the right way, shorter error messages. --- openlp/plugins/songs/lib/openlyricsimport.py | 4 +-- openlp/plugins/songs/lib/xml.py | 29 ++++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 76f074e06..43a6bc51b 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -75,6 +75,6 @@ class OpenLyricsImport(SongImport): log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) except OpenLyricsError as exception: - log.exception(u'OpenLyricsException of type %s: %s in file %s' - % (exception.type, exception.message, file_path)) + log.exception(u'OpenLyricsException %d in file %s: %s' + % (exception.type, file_path, exception.log_message)) self.logError(file_path, exception.display_message) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 81e12d49b..4ed3f97d0 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,17 +676,17 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item', + raise OpenLyricsError(OpenLyricsError.LyricsError, + ' tag is missing.', unicode(translate('OpenLP.OpenLyricsImportError', - 'XML tree is missing tag. ' - 'It is not valid OpenLyrics file.'))) + ' tag is missing.'))) try: verses = lyrics.verse except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item', + raise OpenLyricsError(OpenLyricsError.VerseError, + ' tag is missing.', unicode(translate('OpenLP.OpenLyricsImportError', - 'XML tree is missing tag. ' - 'It is not valid OpenLyrics file.'))) + ' tag is missing.'))) # Loop over the "verse" elements. for verse in verses: text = u'' @@ -807,13 +807,12 @@ class OpenLyrics(object): class OpenLyricsError(Exception): - """ - By now raised only in case of missing lyrics or verse element in XML. - """ - def __init__(self, exception_type, message, display_message): - self.type = exception_type - self.message = message - self.display_message = display_message + # XML tree is missing the lyrics tag + LyricsError = 1 + # XML tree has no verse tags + VerseError = 2 - def __str__(self): - return "%s: %s" % (self.type, self.message) + def __init__(self, type, log_message, display_message): + self.type = type + self.log_message = log_message + self.display_message = display_message From 82890844239917c6cd9c25f3c97629ef23592770 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 9 Mar 2012 21:42:29 +0000 Subject: [PATCH 45/46] changed indentation on the strings --- openlp/plugins/songs/lib/wowimport.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/wowimport.py index c6b7039ab..625dd8de2 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/wowimport.py @@ -113,8 +113,8 @@ class WowImport(SongImport): if song_data.read(19) != u'WoW File\nSong Words': self.logError(file, unicode( translate('SongsPlugin.WordsofWorshipSongImport', - 'Invalid Words of Worship song file. Missing \ -"Wow File\\nSong Words" header.'))) + ('Invalid Words of Worship song file. Missing ' + '"Wow File\\nSong Words" header.')))) continue # Seek to byte which stores number of blocks in the song song_data.seek(56) @@ -123,8 +123,8 @@ class WowImport(SongImport): if song_data.read(16) != u'CSongDoc::CBlock': self.logError(file, unicode( translate('SongsPlugin.WordsofWorshipSongImport', - 'Invalid Words of Worship song file. Missing \ -"CSongDoc::CBlock" string.'))) + ('Invalid Words of Worship song file. Missing ' + '"CSongDoc::CBlock" string.')))) continue # Seek to the beging of the first block song_data.seek(82) From e8a1d7591ee4ee948e3507e21e72d1e6a51418ca Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 10 Mar 2012 18:36:59 +0000 Subject: [PATCH 46/46] Fix a few typos --- openlp/core/ui/advancedtab.py | 2 +- openlp/core/ui/media/mediacontroller.py | 10 +++++----- openlp/plugins/media/lib/mediatab.py | 2 +- openlp/plugins/presentations/lib/presentationtab.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 210dabdd2..72cd36771 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -357,7 +357,7 @@ class AdvancedTab(SettingsTab): translate('OpenLP.GeneralTab', '&Next Item')) self.nextItemLabel.setText( translate('OpenLP.GeneralTab', 'Up and down arrow keys ' - 'advance to the the next or previous Service Item from the ' + 'advance to the next or previous Service Item from the ' 'top and bottom slides of each Service Item.')) def load(self): diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 8a1a8e260..1abdceb2b 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -47,7 +47,7 @@ class MediaController(object): self.parent = parent self.mediaPlayers = {} self.controller = [] - self.overridenPlayer = '' + self.overriddenPlayer = '' self.curDisplayMediaPlayer = {} # Timer for video state self.timer = QtCore.QTimer() @@ -365,8 +365,8 @@ class MediaController(object): usedPlayers = playerSettings.split(u',') if QtCore.QSettings().value(u'media/override player', QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: - if self.overridenPlayer != '': - usedPlayers = [self.overridenPlayer] + if self.overriddenPlayer != '': + usedPlayers = [self.overriddenPlayer] if controller.media_info.file_info.isFile(): suffix = u'*.%s' % \ controller.media_info.file_info.suffix().toLower() @@ -581,9 +581,9 @@ class MediaController(object): QtCore.QVariant(u'webkit')).toString()) usedPlayers = playerSettings.split(u',') if override_player in usedPlayers: - self.overridenPlayer = override_player + self.overriddenPlayer = override_player else: - self.overridenPlayer = '' + self.overriddenPlayer = '' def finalise(self): self.timer.stop() diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index aed6b96cc..6ae042d2f 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -131,7 +131,7 @@ class MediaTab(SettingsTab): self.advancedGroupBox.setTitle(UiStrings().Advanced) self.overridePlayerCheckBox.setText( translate('MediaPlugin.MediaTab', - 'Allow media player to be overriden')) + 'Allow media player to be overridden')) def onPlayerCheckBoxChanged(self, check_state): player = self.sender().text() diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 93174b3da..1b9fa04d9 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -85,7 +85,7 @@ class PresentationTab(SettingsTab): self.AdvancedGroupBox.setTitle(UiStrings().Advanced) self.OverrideAppCheckBox.setText( translate('PresentationPlugin.PresentationTab', - 'Allow presentation application to be overriden')) + 'Allow presentation application to be overridden')) def setControllerText(self, checkbox, controller): if checkbox.isEnabled():