diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 05c71e419..7680caf2c 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -127,7 +127,7 @@ sup { document.getElementById('footer').innerHTML = footertext; } - function show_text(newtext){ + function show_text(new_text){ var match = /-webkit-text-fill-color:[^;\"]+/gi; if(timer != null) clearTimeout(timer); @@ -142,57 +142,47 @@ sup { if(outline != null) txt = outline; if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){ - newtext = newtext.replace(/(\s| )+(?![^<]*>)/g, + new_text = new_text.replace(/(\s| )+(?![^<]*>)/g, function(match) { return '' + match + ''; }); - newtext = '' + newtext + ''; + new_text = '' + new_text + ''; } } - text_fade('lyricsmain', newtext); - text_fade('lyricsoutline', newtext); - text_fade('lyricsshadow', newtext.replace(match, '')); - if(text_opacity() == 1) return; - timer = setTimeout(function(){ - show_text(newtext); - }, 100); + text_fade('lyricsmain', new_text); + text_fade('lyricsoutline', new_text); + text_fade('lyricsshadow', new_text.replace(match, '')); } - function text_fade(id, newtext){ + function text_fade(id, new_text){ /* - Using -webkit-transition: opacity 1s linear; would have been preferred - but it isn't currently quick enough when animating multiple layers of - large areas of large text. Therefore do it manually as best we can. - Hopefully in the future we can revisit and do more interesting - transitions using -webkit-transition and -webkit-transform. - However we need to ensure interrupted transitions (quickly change 2 - slides) still looks pretty and is zippy. + Show the text. */ var text = document.getElementById(id); if(text == null) return; if(!transition){ - text.innerHTML = newtext; + text.innerHTML = new_text; return; } - if(newtext == text.innerHTML){ - text.style.opacity = parseFloat(text.style.opacity) + 0.3; - if(text.style.opacity > 0.7) - text.style.opacity = 1; - } else { - text.style.opacity = parseFloat(text.style.opacity) - 0.3; - if(text.style.opacity <= 0.1){ - text.innerHTML = newtext; - } - } + // Fade text out. 0.2 to minimize the time "nothing" is shown on the screen. + text.style.opacity = '0.2'; + // Fade new text in after the old text has finished fading out. + timer = window.setTimeout(function(){_show_text(text, new_text)}, 400); } - function text_opacity(){ - var text = document.getElementById('lyricsmain'); - return getComputedStyle(text, '').opacity; + function _show_text(text, new_text) { + /* + Helper function to show the new_text delayed. + */ + text.innerHTML = new_text; + text.style.opacity = '1'; + // Wait until the text is completely visible. We want to save the timer id, to be able to call + // clearTimeout(timer) when the text has changed before finishing fading. + timer = window.setTimeout(function(){timer = null;}, 400); } - function show_text_complete(){ - return (text_opacity() == 1); + function show_text_completed(){ + return (timer == null); } @@ -218,7 +208,7 @@ def build_html(item, screen, is_live, background, image=None, plugins=None): ``screen`` Current display information - ``islive`` + ``is_live`` Item is going live, rather than preview/theme building ``background`` @@ -336,6 +326,7 @@ def build_lyrics_css(item, webkit_ver): .lyricscell { display: table-cell; word-wrap: break-word; + -webkit-transition: opacity 0.4s ease; %s } .lyricsmain { diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index e8f14bbc5..a7388ddc1 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -148,7 +148,7 @@ class Plugin(QtCore.QObject): QtCore.QObject.__init__(self) self.name = name self.textStrings = {} - self.setPluginTextStrings() + self.set_plugin_text_strings() self.nameStrings = self.textStrings[StringContent.Name] if version: self.version = version @@ -311,7 +311,7 @@ class Plugin(QtCore.QObject): # Now save the list to the config using our Settings class. Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) - def usesTheme(self, theme): + def uses_theme(self, theme): """ Called to find out if a plugin is currently using a theme. @@ -319,7 +319,7 @@ class Plugin(QtCore.QObject): """ return False - def renameTheme(self, oldTheme, newTheme): + def rename_theme(self, oldTheme, newTheme): """ Renames a theme a plugin is using making the plugin use the new name. diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 9fcdd2786..076874e18 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -247,7 +247,7 @@ class Renderer(object): serviceItem.footer = footer serviceItem.render(True) if not self.force_page: - self.display.buildHtml(serviceItem) + self.display.build_html(serviceItem) raw_html = serviceItem.get_rendered_frame(0) self.display.text(raw_html, False) preview = self.display.preview() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 58d832101..0dd990b55 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -68,7 +68,7 @@ class Display(QtGui.QGraphicsView): self.parent = lambda: parent else: QtGui.QGraphicsView.__init__(self, parent) - self.isLive = live + self.is_live = live self.controller = controller self.screen = {} # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with @@ -82,40 +82,37 @@ class Display(QtGui.QGraphicsView): """ Set up and build the screen base """ - log.debug(u'Start Display base setup (live = %s)' % self.isLive) + log.debug(u'Start Display base setup (live = %s)' % self.is_live) self.setGeometry(self.screen[u'size']) log.debug(u'Setup webView') - self.webView = QtWebKit.QWebView(self) - self.webView.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height()) - self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) - palette = self.webView.palette() + self.web_view = QtWebKit.QWebView(self) + self.web_view.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height()) + self.web_view.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) + palette = self.web_view.palette() palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent) - self.webView.page().setPalette(palette) - self.webView.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False) - self.page = self.webView.page() + self.web_view.page().setPalette(palette) + self.web_view.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False) + self.page = self.web_view.page() self.frame = self.page.mainFrame() - if self.isLive and log.getEffectiveLevel() == logging.DEBUG: - self.webView.settings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) - QtCore.QObject.connect(self.webView, - QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded) + if self.is_live and log.getEffectiveLevel() == logging.DEBUG: + self.web_view.settings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) + self.web_view.loadFinished.connect(self.is_web_loaded) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.frame.setScrollBarPolicy(QtCore.Qt.Vertical, - QtCore.Qt.ScrollBarAlwaysOff) - self.frame.setScrollBarPolicy(QtCore.Qt.Horizontal, - QtCore.Qt.ScrollBarAlwaysOff) + self.frame.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) + self.frame.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) def resizeEvent(self, event): """ React to resizing of this display """ - self.webView.setGeometry(0, 0, self.width(), self.height()) + self.web_view.setGeometry(0, 0, self.width(), self.height()) - def isWebLoaded(self): + def is_web_loaded(self): """ Called by webView event to show display is fully loaded """ - log.debug(u'Webloaded') + log.debug(u'is web loaded') self.webLoaded = True @@ -129,11 +126,11 @@ class MainDisplay(Display): """ Display.__init__(self, parent, live, controller) self.screens = ScreenList() - self.rebuildCSS = False - self.hideMode = None + self.rebuild_css = False + self.hide_mode = None self.override = {} self.retranslateUi() - self.mediaObject = None + self.media_object = None if live: self.audioPlayer = AudioPlayer(self) else: @@ -156,14 +153,14 @@ class MainDisplay(Display): self.setWindowState(QtCore.Qt.WindowFullScreen) self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) - self.setTransparency(False) - if self.isLive: + self.set_transparency(False) + if self.is_live: Registry().register_function(u'live_display_hide', self.hide_display) Registry().register_function(u'live_display_show', self.show_display) Registry().register_function(u'update_display_css', self.css_changed) Registry().register_function(u'config_updated', self.config_changed) - def setTransparency(self, enabled): + def set_transparency(self, enabled): """ Set the transparency of the window """ @@ -178,17 +175,17 @@ class MainDisplay(Display): """ We may need to rebuild the CSS on the live display. """ - self.rebuildCSS = True + self.rebuild_css = True def config_changed(self): """ Call the plugins to rebuild the Live display CSS as the screen has not been rebuild on exit of config. """ - if self.rebuildCSS and self.plugin_manager.plugins: + if self.rebuild_css and self.plugin_manager.plugins: for plugin in self.plugin_manager.plugins: plugin.refreshCss(self.frame) - self.rebuildCSS = False + self.rebuild_css = False def retranslateUi(self): """ @@ -200,11 +197,11 @@ class MainDisplay(Display): """ Set up and build the output screen """ - log.debug(u'Start MainDisplay setup (live = %s)' % self.isLive) + log.debug(u'Start MainDisplay setup (live = %s)' % self.is_live) self.screen = self.screens.current self.setVisible(False) Display.setup(self) - if self.isLive: + if self.is_live: # Build the initial frame. background_color = QtGui.QColor() background_color.setNamedColor(Settings().value(u'advanced/default color')) @@ -225,7 +222,7 @@ class MainDisplay(Display): splash_image) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(self.initialFrame) - self.webView.setHtml(build_html(serviceItem, self.screen, self.isLive, None, + self.web_view.setHtml(build_html(serviceItem, self.screen, self.is_live, None, plugins=self.plugin_manager.plugins)) self.__hideMouse() log.debug(u'Finished MainDisplay setup') @@ -288,7 +285,7 @@ class MainDisplay(Display): self.setVisible(False) self.setGeometry(self.screen[u'size']) - def directImage(self, path, background): + def direct_image(self, path, background): """ API for replacement backgrounds so Images are added directly to cache. """ @@ -299,7 +296,7 @@ class MainDisplay(Display): self.override[u'theme'] = self.serviceItem.themedata.background_filename self.image(path) # Update the preview frame. - if self.isLive: + if self.is_live: self.live_controller.updatePreview() return True @@ -316,9 +313,9 @@ class MainDisplay(Display): log.debug(u'image to display') image = self.image_manager.get_image_bytes(path, ImageSource.ImagePlugin) self.controller.media_controller.media_reset(self.controller) - self.displayImage(image) + self.display_image(image) - def displayImage(self, image): + def display_image(self, image): """ Display an image, as is. """ @@ -329,16 +326,16 @@ class MainDisplay(Display): js = u'show_image("");' self.frame.evaluateJavaScript(js) - def resetImage(self): + def reset_image(self): """ - Reset the backgound image to the service item image. Used after the + Reset the background image to the service item image. Used after the image plugin has changed the background. """ - log.debug(u'resetImage') + log.debug(u'reset_image') if hasattr(self, u'serviceItem'): - self.displayImage(self.serviceItem.bg_image_bytes) + self.display_image(self.serviceItem.bg_image_bytes) else: - self.displayImage(None) + self.display_image(None) # clear the cache self.override = {} @@ -346,24 +343,27 @@ class MainDisplay(Display): """ Generates a preview of the image displayed. """ - log.debug(u'preview for %s', self.isLive) + log.debug(u'preview for %s', self.is_live) + was_visible = self.isVisible() self.application.process_events() # We must have a service item to preview. - if self.isLive and hasattr(self, u'serviceItem'): + if self.is_live and hasattr(self, u'serviceItem'): # Wait for the fade to finish before geting the preview. # Important otherwise preview will have incorrect text if at all! if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition: - while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false': + while not self.frame.evaluateJavaScript(u'show_text_completed()'): self.application.process_events() # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! while not self.webLoaded: self.application.process_events() # if was hidden keep it hidden - if self.isLive: - if self.hideMode: - self.hide_display(self.hideMode) - else: + if self.is_live: + if self.hide_mode: + self.hide_display(self.hide_mode) + # Only continue if the visibility wasn't changed during method call. + elif was_visible == self.isVisible(): + # Single screen active if self.screens.display_count == 1: # Only make visible if setting enabled. @@ -373,12 +373,12 @@ class MainDisplay(Display): self.setVisible(True) return QtGui.QPixmap.grabWidget(self) - def buildHtml(self, serviceItem, image_path=u''): + def build_html(self, serviceItem, image_path=u''): """ Store the serviceItem and build the new HTML from it. Add the HTML to the display """ - log.debug(u'buildHtml') + log.debug(u'build_html') self.webLoaded = False self.initialFrame = None self.serviceItem = serviceItem @@ -396,30 +396,29 @@ class MainDisplay(Display): else: # replace the background background = self.image_manager.get_image_bytes(self.override[u'image'], ImageSource.ImagePlugin) - self.setTransparency(self.serviceItem.themedata.background_type == + self.set_transparency(self.serviceItem.themedata.background_type == BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes( - self.serviceItem.themedata.background_filename, - ImageSource.Theme + self.serviceItem.themedata.background_filename, ImageSource.Theme ) if image_path: image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) else: image_bytes = None - html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes, + html = build_html(self.serviceItem, self.screen, self.is_live, background, image_bytes, plugins=self.plugin_manager.plugins) log.debug(u'buildHtml - pre setHtml') - self.webView.setHtml(html) + self.web_view.setHtml(html) log.debug(u'buildHtml - post setHtml') if serviceItem.foot_text: self.footer(serviceItem.foot_text) # if was hidden keep it hidden - if self.hideMode and self.isLive and not serviceItem.is_media(): + if self.hide_mode and self.is_live and not serviceItem.is_media(): if Settings().value(u'general/auto unblank'): Registry().execute(u'slidecontroller_live_unblank') else: - self.hide_display(self.hideMode) + self.hide_display(self.hide_mode) self.__hideMouse() def footer(self, text): @@ -450,13 +449,12 @@ class MainDisplay(Display): if mode != HideMode.Screen: if self.isHidden(): self.setVisible(True) - self.webView.setVisible(True) - self.hideMode = mode + self.web_view.setVisible(True) + self.hide_mode = mode def show_display(self): """ - Show the stored layers so the screen reappears as it was - originally. + Show the stored layers so the screen reappears as it was originally. Make the stored images None to release memory. """ log.debug(u'show_display') @@ -467,9 +465,9 @@ class MainDisplay(Display): self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): self.setVisible(True) - self.hideMode = None + self.hide_mode = None # Trigger actions when display is active again. - if self.isLive: + if self.is_live: Registry().execute(u'live_display_active') def __hideMouse(self): @@ -543,38 +541,38 @@ class AudioPlayer(QtCore.QObject): self.currentIndex = -1 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, QtCore.SIGNAL(u'aboutToFinish()'), self.onAboutToFinish) - QtCore.QObject.connect(self.mediaObject, QtCore.SIGNAL(u'finished()'), self.onFinished) + self.media_object = Phonon.MediaObject() + self.media_object.setTickInterval(100) + self.audio_object = Phonon.AudioOutput(Phonon.VideoCategory) + Phonon.createPath(self.media_object, self.audio_object) + self.media_object.aboutToFinish.connect(self.on_about_to_finish) + self.media_object.finished.connect(self.on_finished) def __del__(self): """ Shutting down so clean up connections """ self.stop() - for path in self.mediaObject.outputPaths(): + for path in self.media_object.outputPaths(): path.disconnect() - def onAboutToFinish(self): + def on_about_to_finish(self): """ Just before the audio player finishes the current track, queue the next item in the playlist, if there is one. """ self.currentIndex += 1 if len(self.playlist) > self.currentIndex: - self.mediaObject.enqueue(self.playlist[self.currentIndex]) + self.media_object.enqueue(self.playlist[self.currentIndex]) - def onFinished(self): + def on_finished(self): """ When the audio track finishes. """ if self.repeat: log.debug(u'Repeat is enabled... here we go again!') - self.mediaObject.clearQueue() - self.mediaObject.clear() + self.media_object.clearQueue() + self.media_object.clear() self.currentIndex = -1 self.play() @@ -582,7 +580,7 @@ class AudioPlayer(QtCore.QObject): """ Connect the volume slider to the output channel. """ - slider.setAudioOutput(self.audioObject) + slider.setAudioOutput(self.audio_object) def reset(self): """ @@ -591,7 +589,7 @@ class AudioPlayer(QtCore.QObject): self.currentIndex = -1 self.playlist = [] self.stop() - self.mediaObject.clear() + self.media_object.clear() def play(self): """ @@ -599,24 +597,24 @@ class AudioPlayer(QtCore.QObject): """ log.debug(u'AudioPlayer.play() called') if self.currentIndex == -1: - self.onAboutToFinish() - self.mediaObject.play() + self.on_about_to_finish() + self.media_object.play() def pause(self): """ Pause the Audio """ log.debug(u'AudioPlayer.pause() called') - self.mediaObject.pause() + self.media_object.pause() def stop(self): """ Stop the Audio and clean up """ log.debug(u'AudioPlayer.stop() called') - self.mediaObject.stop() + self.media_object.stop() - def addToPlaylist(self, filenames): + def add_to_playlist(self, filenames): """ Add another file to the playlist. @@ -633,31 +631,30 @@ class AudioPlayer(QtCore.QObject): """ if not self.repeat and self.currentIndex + 1 >= len(self.playlist): return - isPlaying = self.mediaObject.state() == Phonon.PlayingState + isPlaying = self.media_object.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.mediaObject.enqueue(self.playlist[self.currentIndex]) + self.media_object.clearQueue() + self.media_object.clear() + self.media_object.enqueue(self.playlist[self.currentIndex]) if isPlaying: - self.mediaObject.play() + self.media_object.play() - def goTo(self, index): + def go_to(self, index): """ Go to a particular track in the list """ - isPlaying = self.mediaObject.state() == Phonon.PlayingState - self.mediaObject.clearQueue() - self.mediaObject.clear() + isPlaying = self.media_object.state() == Phonon.PlayingState + self.media_object.clearQueue() + self.media_object.clear() self.currentIndex = index - self.mediaObject.enqueue(self.playlist[self.currentIndex]) + self.media_object.enqueue(self.playlist[self.currentIndex]) if isPlaying: - self.mediaObject.play() + self.media_object.play() - #@todo is this used? def connectSlot(self, signal, slot): """ - Connect a slot to a signal on the media object + Connect a slot to a signal on the media object. Used by slidecontroller to connect to audio object. """ - QtCore.QObject.connect(self.mediaObject, signal, slot) + QtCore.QObject.connect(self.media_object, signal, slot) \ No newline at end of file diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 550ffc156..0194fc2ca 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -489,7 +489,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Settings().remove_obsolete_settings() self.serviceNotSaved = False self.aboutForm = AboutForm(self) - self.media_controller = MediaController(self) + self.media_controller = MediaController() self.settingsForm = SettingsForm(self) self.formattingTagForm = FormattingTagForm(self) self.shortcutForm = ShortcutListForm(self) @@ -536,9 +536,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Registry().register_function(u'openlp_version_check', self.version_notice) Registry().register_function(u'config_screen_changed', self.screen_changed) self.renderer = Renderer() - # Create the displays as all necessary components are loaded. - self.preview_controller.screenSizeChanged() - self.live_controller.screenSizeChanged() log.info(u'Load data from Settings') if Settings().value(u'advanced/save current plugin'): savedPlugin = Settings().value(u'advanced/current media plugin') diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 301e48f1a..baa52d404 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -61,8 +61,8 @@ class MediaSlider(QtGui.QSlider): """ Override event to allow hover time to be displayed. """ - timevalue = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()) - self.setToolTip(u'%s' % datetime.timedelta(seconds=int(timevalue / 1000))) + time_value = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()) + self.setToolTip(u'%s' % datetime.timedelta(seconds=int(time_value / 1000))) QtGui.QSlider.mouseMoveEvent(self, event) def mousePressEvent(self, event): @@ -88,21 +88,20 @@ class MediaController(object): slidecontroller or plugin which built them. ControllerType is the class containing the key values. - mediaPlayers are an array of media players keyed on player name. + media_players are an array of media players keyed on player name. - currentMediaPlayer is an array of player instances keyed on ControllerType. + current_media_players is an array of player instances keyed on ControllerType. """ - def __init__(self, parent): + def __init__(self): """ Constructor """ - self.mainWindow = parent Registry().register(u'media_controller', self) Registry().register_function(u'bootstrap_initialise', self.check_available_media_players) - self.mediaPlayers = {} + self.media_players = {} self.displayControllers = {} - self.currentMediaPlayer = {} + self.current_media_players = {} # Timer for video state self.timer = QtCore.QTimer() self.timer.setInterval(200) @@ -127,22 +126,22 @@ class MediaController(object): Set the active players and available media files """ savedPlayers = get_media_players()[0] - for player in self.mediaPlayers.keys(): - self.mediaPlayers[player].isActive = player in savedPlayers + for player in self.media_players.keys(): + self.media_players[player].isActive = player in savedPlayers def _generate_extensions_lists(self): """ Set the active players and available media files """ self.audio_extensions_list = [] - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: for item in player.audio_extensions_list: if not item in self.audio_extensions_list: self.audio_extensions_list.append(item) self.service_manager.supported_suffixes(item[2:]) self.video_extensions_list = [] - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: for item in player.video_extensions_list: if item not in self.video_extensions_list: @@ -157,16 +156,14 @@ class MediaController(object): ``player`` Individual player class which has been enabled """ - self.mediaPlayers[player.name] = player + self.media_players[player.name] = player def check_available_media_players(self): """ Check to see if we have any media Player's available. """ log.debug(u'_check_available_media_players') - controller_dir = os.path.join( - AppLocation.get_directory(AppLocation.AppDir), - u'core', u'ui', u'media') + controller_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), u'core', u'ui', u'media') for filename in os.listdir(controller_dir): if filename.endswith(u'player.py') and not filename == 'mediaplayer.py': path = os.path.join(controller_dir, filename) @@ -183,13 +180,13 @@ class MediaController(object): for player_class in player_classes: player = player_class(self) self.register_players(player) - if not self.mediaPlayers: + if not self.media_players: return False savedPlayers, overriddenPlayer = get_media_players() - invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers - if not mediaPlayer in self.mediaPlayers or not self.mediaPlayers[mediaPlayer].check_available()] - if invalidMediaPlayers: - for invalidPlayer in invalidMediaPlayers: + invalid_media_players = [mediaPlayer for mediaPlayer in savedPlayers + if not mediaPlayer in self.media_players or not self.media_players[mediaPlayer].check_available()] + if invalid_media_players: + for invalidPlayer in invalid_media_players: savedPlayers.remove(invalidPlayer) set_media_players(savedPlayers, overriddenPlayer) self._set_active_players() @@ -201,22 +198,22 @@ class MediaController(object): Check if there is a running media Player and do updating stuff (e.g. update the UI) """ - if not self.currentMediaPlayer.keys(): + if not self.current_media_players.keys(): self.timer.stop() else: any_active = False - for source in self.currentMediaPlayer.keys(): + for source in self.current_media_players.keys(): display = self._define_display(self.displayControllers[source]) - self.currentMediaPlayer[source].resize(display) - self.currentMediaPlayer[source].update_ui(display) - if self.currentMediaPlayer[source].state == MediaState.Playing: + self.current_media_players[source].resize(display) + self.current_media_players[source].update_ui(display) + if self.current_media_players[source].state == MediaState.Playing: any_active = True # There are still any active players - no need to stop timer. if any_active: return # no players are active anymore - for source in self.currentMediaPlayer.keys(): - if self.currentMediaPlayer[source].state != MediaState.Paused: + for source in self.current_media_players.keys(): + if self.current_media_players[source].state != MediaState.Paused: display = self._define_display(self.displayControllers[source]) display.controller.seekSlider.setSliderPosition(0) self.timer.stop() @@ -226,7 +223,7 @@ class MediaController(object): Add css style sheets to htmlbuilder """ css = u'' - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: css += player.get_media_display_css() return css @@ -236,7 +233,7 @@ class MediaController(object): Add javascript functions to htmlbuilder """ js = u'' - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: js += player.get_media_display_javascript() return js @@ -246,7 +243,7 @@ class MediaController(object): Add html code to htmlbuilder """ html = u'' - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: html += player.get_media_display_html() return html @@ -258,7 +255,7 @@ class MediaController(object): ``controller`` The controller where a player will be placed """ - self.displayControllers[controller.controllerType] = controller + self.displayControllers[controller.controller_type] = controller self.setup_generic_controls(controller) def setup_generic_controls(self, controller): @@ -273,13 +270,13 @@ class MediaController(object): controller.mediabar = OpenLPToolbar(controller) 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) + tooltip=translate('OpenLP.SlideController', 'Start playing media.'), triggers=controller.send_to_plugins) 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) + tooltip=translate('OpenLP.SlideController', 'Pause playing media.'), triggers=controller.send_to_plugins) controller.mediabar.addToolbarAction(u'playbackStop', text=u'media_playback_stop', icon=u':/slides/media_playback_stop.png', - tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), triggers=controller.sendToPlugins) + tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), triggers=controller.send_to_plugins) # Build the seekSlider. controller.seekSlider = MediaSlider(QtCore.Qt.Horizontal, self, controller) controller.seekSlider.setMaximum(1000) @@ -301,15 +298,15 @@ class MediaController(object): controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) controller.volumeSlider.setObjectName(u'volumeSlider') controller.mediabar.addToolbarWidget(controller.volumeSlider) - controller.controllerLayout.addWidget(controller.mediabar) + controller.controller_layout.addWidget(controller.mediabar) controller.mediabar.setVisible(False) # Signals - QtCore.QObject.connect(controller.seekSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) - QtCore.QObject.connect(controller.volumeSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) + controller.seekSlider.valueChanged.connect(controller.send_to_plugins) + controller.volumeSlider.valueChanged.connect(controller.send_to_plugins) def setup_display(self, display, preview): """ - After a new display is configured, all media related widget will be + After a new display is configured, all media related widgets will be created too ``display`` @@ -323,11 +320,11 @@ class MediaController(object): # update player status self._set_active_players() display.hasAudio = True - if display.isLive and preview: + if display.is_live and preview: return if preview: display.hasAudio = False - for player in self.mediaPlayers.values(): + for player in self.media_players.values(): if player.isActive: player.setup(display) @@ -344,10 +341,10 @@ class MediaController(object): """ # Generic controls controller.mediabar.setVisible(value) - if controller.isLive and controller.display: - if self.currentMediaPlayer and value: - if self.currentMediaPlayer[controller.controllerType] != self.mediaPlayers[u'webkit']: - controller.display.setTransparency(False) + if controller.is_live and controller.display: + if self.current_media_players and value: + if self.current_media_players[controller.controller_type] != self.media_players[u'webkit']: + controller.display.set_transparency(False) def resize(self, display, player): """ @@ -388,7 +385,7 @@ class MediaController(object): controller.media_info.is_background = videoBehindText controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path()) display = self._define_display(controller) - if controller.isLive: + if controller.is_live: isValid = self._check_file_type(controller, display, serviceItem) display.override[u'theme'] = u'' display.override[u'video'] = True @@ -399,7 +396,7 @@ class MediaController(object): else: controller.media_info.start_time = serviceItem.start_time controller.media_info.end_time = serviceItem.end_time - elif controller.previewDisplay: + elif controller.preview_display: isValid = self._check_file_type(controller, display, serviceItem) if not isValid: # Media could not be loaded correctly @@ -407,12 +404,12 @@ class MediaController(object): translate('MediaPlugin.MediaItem', 'Unsupported File')) return False # dont care about actual theme, set a black background - if controller.isLive and not controller.media_info.is_background: + if controller.is_live and not controller.media_info.is_background: display.frame.evaluateJavaScript(u'show_video( "setBackBoard", null, null, null,"visible");') # now start playing - Preview is autoplay! autoplay = False # Preview requested - if not controller.isLive: + if not controller.is_live: autoplay = True # Visible or background requested or Service Item wants to autostart elif not hidden or controller.media_info.is_background or serviceItem.will_auto_start: @@ -426,7 +423,7 @@ class MediaController(object): translate('MediaPlugin.MediaItem', 'Unsupported File')) return False self.set_controls_visible(controller, True) - log.debug(u'use %s controller' % self.currentMediaPlayer[controller.controllerType]) + log.debug(u'use %s controller' % self.current_media_players[controller.controller_type]) return True def media_length(self, serviceItem): @@ -443,7 +440,7 @@ class MediaController(object): controller.media_info = MediaInfo() controller.media_info.volume = 0 controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path()) - display = controller.previewDisplay + display = controller._display if not self._check_file_type(controller, display, serviceItem): # Media could not be loaded correctly critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'), @@ -455,7 +452,7 @@ class MediaController(object): return False serviceItem.set_media_length(controller.media_info.length) self.media_stop(controller) - log.debug(u'use %s controller' % self.currentMediaPlayer[controller.controllerType]) + log.debug(u'use %s controller' % self.current_media_players[controller.controller_type]) return True def _check_file_type(self, controller, display, serviceItem): @@ -474,27 +471,27 @@ class MediaController(object): if controller.media_info.file_info.isFile(): suffix = u'*.%s' % controller.media_info.file_info.suffix().lower() for title in usedPlayers: - player = self.mediaPlayers[title] + player = self.media_players[title] if suffix in player.video_extensions_list: if not controller.media_info.is_background or controller.media_info.is_background and \ player.canBackground: self.resize(display, player) if player.load(display): - self.currentMediaPlayer[controller.controllerType] = player + self.current_media_players[controller.controller_type] = player controller.media_info.media_type = MediaType.Video return True if suffix in player.audio_extensions_list: if player.load(display): - self.currentMediaPlayer[controller.controllerType] = player + self.current_media_players[controller.controller_type] = player controller.media_info.media_type = MediaType.Audio return True else: for title in usedPlayers: - player = self.mediaPlayers[title] + player = self.media_players[title] if player.canFolder: self.resize(display, player) if player.load(display): - self.currentMediaPlayer[controller.controllerType] = player + self.current_media_players[controller.controller_type] = player controller.media_info.media_type = MediaType.Video return True # no valid player found @@ -521,7 +518,7 @@ class MediaController(object): controller.seekSlider.blockSignals(True) controller.volumeSlider.blockSignals(True) display = self._define_display(controller) - if not self.currentMediaPlayer[controller.controllerType].play(display): + if not self.current_media_players[controller.controller_type].play(display): controller.seekSlider.blockSignals(False) controller.volumeSlider.blockSignals(False) return False @@ -531,7 +528,7 @@ class MediaController(object): self.media_volume(controller, controller.media_info.volume) if status: display.frame.evaluateJavaScript(u'show_blank("desktop");') - self.currentMediaPlayer[controller.controllerType].set_visible(display, True) + self.current_media_players[controller.controller_type].set_visible(display, True) # Flash needs to be played and will not AutoPlay if controller.media_info.is_flash: controller.mediabar.actions[u'playbackPlay'].setVisible(True) @@ -540,9 +537,9 @@ class MediaController(object): controller.mediabar.actions[u'playbackPlay'].setVisible(False) controller.mediabar.actions[u'playbackPause'].setVisible(True) controller.mediabar.actions[u'playbackStop'].setVisible(True) - if controller.isLive: - if controller.hideMenu.defaultAction().isChecked(): - controller.hideMenu.defaultAction().trigger() + if controller.is_live: + if controller.hide_menu.defaultAction().isChecked(): + controller.hide_menu.defaultAction().trigger() # Start Timer for ui updates if not self.timer.isActive(): self.timer.start() @@ -569,7 +566,7 @@ class MediaController(object): """ log.debug(u'media_pause') display = self._define_display(controller) - self.currentMediaPlayer[controller.controllerType].pause(display) + self.current_media_players[controller.controller_type].pause(display) controller.mediabar.actions[u'playbackPlay'].setVisible(True) controller.mediabar.actions[u'playbackStop'].setVisible(True) controller.mediabar.actions[u'playbackPause'].setVisible(False) @@ -593,10 +590,10 @@ class MediaController(object): """ log.debug(u'media_stop') display = self._define_display(controller) - if controller.controllerType in self.currentMediaPlayer: + if controller.controller_type in self.current_media_players: display.frame.evaluateJavaScript(u'show_blank("black");') - self.currentMediaPlayer[controller.controllerType].stop(display) - self.currentMediaPlayer[controller.controllerType].set_visible(display, False) + self.current_media_players[controller.controller_type].stop(display) + self.current_media_players[controller.controller_type].set_visible(display, False) controller.seekSlider.setSliderPosition(0) controller.mediabar.actions[u'playbackPlay'].setVisible(True) controller.mediabar.actions[u'playbackStop'].setVisible(False) @@ -622,7 +619,7 @@ class MediaController(object): """ log.debug(u'media_volume %d' % volume) display = self._define_display(controller) - self.currentMediaPlayer[controller.controllerType].volume(display, volume) + self.current_media_players[controller.controller_type].volume(display, volume) controller.volumeSlider.setValue(volume) def media_seek_msg(self, msg): @@ -648,7 +645,7 @@ class MediaController(object): """ log.debug(u'media_seek') display = self._define_display(controller) - self.currentMediaPlayer[controller.controllerType].seek(display, seekVal) + self.current_media_players[controller.controller_type].seek(display, seekVal) def media_reset(self, controller): """ @@ -657,12 +654,12 @@ class MediaController(object): log.debug(u'media_reset') self.set_controls_visible(controller, False) display = self._define_display(controller) - if controller.controllerType in self.currentMediaPlayer: + if controller.controller_type in self.current_media_players: display.override = {} - self.currentMediaPlayer[controller.controllerType].reset(display) - self.currentMediaPlayer[controller.controllerType].set_visible(display, False) + self.current_media_players[controller.controller_type].reset(display) + self.current_media_players[controller.controller_type].set_visible(display, False) display.frame.evaluateJavaScript(u'show_video( "setBackBoard", null, null, null,"hidden");') - del self.currentMediaPlayer[controller.controllerType] + del self.current_media_players[controller.controller_type] def media_hide(self, msg): """ @@ -671,15 +668,14 @@ class MediaController(object): ``msg`` First element is the boolean for Live indication """ - isLive = msg[1] - if not isLive: + is_live = msg[1] + if not is_live: return - controller = self.mainWindow.liveController - display = self._define_display(controller) - if controller.controllerType in self.currentMediaPlayer and \ - self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing: - self.currentMediaPlayer[controller.controllerType].pause(display) - self.currentMediaPlayer[controller.controllerType].set_visible(display, False) + display = self._define_display(self.live_controller) + if self.live_controller.controller_type in self.current_media_players and \ + self.current_media_players[self.live_controller.controller_type].state == MediaState.Playing: + self.current_media_players[self.live_controller.controller_type].pause(display) + self.current_media_players[self.live_controller.controller_type].set_visible(display, False) def media_blank(self, msg): """ @@ -689,16 +685,15 @@ class MediaController(object): First element is the boolean for Live indication Second element is the hide mode """ - isLive = msg[1] + is_live = msg[1] hide_mode = msg[2] - if not isLive: + if not is_live: return Registry().execute(u'live_display_hide', hide_mode) - controller = self.mainWindow.liveController - display = self._define_display(controller) - if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing: - self.currentMediaPlayer[controller.controllerType].pause(display) - self.currentMediaPlayer[controller.controllerType].set_visible(display, False) + display = self._define_display(self.live_controller) + if self.current_media_players[self.live_controller.controller_type].state == MediaState.Playing: + self.current_media_players[self.live_controller.controller_type].pause(display) + self.current_media_players[self.live_controller.controller_type].set_visible(display, False) def media_unblank(self, msg): """ @@ -709,15 +704,14 @@ class MediaController(object): Second element is the boolean for Live indication """ Registry().execute(u'live_display_show') - isLive = msg[1] - if not isLive: + is_live = msg[1] + if not is_live: return - controller = self.mainWindow.liveController - display = self._define_display(controller) - if controller.controllerType in self.currentMediaPlayer and \ - self.currentMediaPlayer[controller.controllerType].state != MediaState.Playing: - if self.currentMediaPlayer[controller.controllerType].play(display): - self.currentMediaPlayer[controller.controllerType].set_visible(display, True) + display = self._define_display(self.live_controller) + if self.live_controller.controller_type in self.current_media_players and \ + self.current_media_players[self.live_controller.controller_type].state != MediaState.Playing: + if self.current_media_players[self.live_controller.controller_type].play(display): + self.current_media_players[self.live_controller.controller_type].set_visible(display, True) # Start Timer for ui updates if not self.timer.isActive(): self.timer.start() @@ -737,9 +731,9 @@ class MediaController(object): ``controller`` Controller to be used """ - if controller.isLive: + if controller.is_live: return controller.display - return controller.previewDisplay + return controller.preview_display def _get_service_manager(self): """ @@ -750,3 +744,13 @@ class MediaController(object): return self._service_manager service_manager = property(_get_service_manager) + + def _get_live_controller(self): + """ + Adds the live controller to the class dynamically + """ + if not hasattr(self, u'_live_controller'): + self._live_controller = Registry().get(u'live_controller') + return self._live_controller + + live_controller = property(_get_live_controller) diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index 920aef376..8551d1679 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -55,7 +55,7 @@ class PlayerTab(SettingsTab): """ Constructor """ - self.mediaPlayers = self.media_controller.mediaPlayers + self.media_players = self.media_controller.media_players self.savedUsedPlayers = None self.iconPath = u':/media/multimedia-player.png' player_translated = translate('OpenLP.PlayerTab', 'Players') @@ -171,7 +171,7 @@ class PlayerTab(SettingsTab): self.playerCheckBoxes[u'%s' % player].setEnabled(False) else: self.playerCheckBoxes[u'%s' % player].setEnabled(True) - self.playerOrderlistWidget.addItem(self.mediaPlayers[unicode(player)].original_name) + self.playerOrderlistWidget.addItem(self.media_players[unicode(player)].original_name) def onUpButtonClicked(self): """ @@ -237,8 +237,8 @@ class PlayerTab(SettingsTab): Late setup for players as the MediaController has to be initialised first. """ - for key, player in self.mediaPlayers.iteritems(): - player = self.mediaPlayers[key] + for key, player in self.media_players.iteritems(): + player = self.media_players[key] checkbox = MediaQCheckBox(self.mediaPlayerGroupBox) checkbox.setEnabled(player.available) checkbox.setObjectName(player.name + u'CheckBox') @@ -258,8 +258,8 @@ class PlayerTab(SettingsTab): """ Translations for players is dependent on their setup as well """ - for key in self.mediaPlayers: - player = self.mediaPlayers[key] + for key in self.media_players: + player = self.media_players[key] checkbox = self.playerCheckBoxes[player.name] checkbox.setPlayerName(player.name) if player.available: diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2d3fdcd39..6b195bc6e 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -122,7 +122,7 @@ class VlcPlayer(MediaPlayer): command_line_options = u'--no-video-title-show' if not display.hasAudio: command_line_options += u' --no-audio --no-video-title-show' - if Settings().value(u'advanced/hide mouse') and display.controller.isLive: + if Settings().value(u'advanced/hide mouse') and display.controller.is_live: command_line_options += u' --mouse-hide-timeout=0' display.vlcInstance = vlc.Instance(command_line_options) # creating an empty vlc media player diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 963e4e6f7..4898912f0 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -307,8 +307,8 @@ class WebkitPlayer(MediaPlayer): """ Set up the player """ - display.webView.resize(display.size()) - display.webView.raise_() + display.web_view.resize(display.size()) + display.web_view.raise_() self.hasOwnWidget = False def check_available(self): @@ -333,7 +333,7 @@ class WebkitPlayer(MediaPlayer): loop = u'true' else: loop = u'false' - display.webView.setVisible(True) + display.web_view.setVisible(True) if controller.media_info.file_info.suffix() == u'swf': controller.media_info.is_flash = True js = u'show_flash("load","%s");' % (path.replace(u'\\', u'\\\\')) @@ -346,14 +346,14 @@ class WebkitPlayer(MediaPlayer): """ Resize the player """ - display.webView.resize(display.size()) + display.web_view.resize(display.size()) def play(self, display): """ Play a video """ controller = display.controller - display.webLoaded = True + display.web_loaded = True length = 0 start_time = 0 if self.state != MediaState.Paused and controller.media_info.start_time > 0: @@ -368,7 +368,7 @@ class WebkitPlayer(MediaPlayer): # TODO add playing check and get the correct media length controller.media_info.length = length self.state = MediaState.Playing - display.webView.raise_() + display.web_view.raise_() return True def pause(self, display): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2a428cb5b..fe28080f9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1413,7 +1413,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be displayed as the plugin required to display it is missing or inactive')) - self.application.set_normal_cursor() + self.application.set_normal_cursor() def remote_edit(self): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9287c6f12..a0d750896 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -57,16 +57,16 @@ class DisplayController(QtGui.QWidget): """ Controller is a general display controller widget. """ - def __init__(self, parent, isLive=False): + def __init__(self, parent, is_live=False): """ Set up the general Controller. """ QtGui.QWidget.__init__(self, parent) - self.isLive = isLive + self.is_live = is_live self.display = None - self.controllerType = DisplayControllerType.Plugin + self.controller_type = DisplayControllerType.Plugin - def sendToPlugins(self, *args): + def send_to_plugins(self, *args): """ This is the generic function to send signal for control widgets, created from within other plugins @@ -82,174 +82,175 @@ class SlideController(DisplayController): SlideController is the slide controller widget. This widget is what the user uses to control the displaying of verses/slides/etc on the screen. """ - def __init__(self, parent, isLive=False): + def __init__(self, parent, is_live=False): """ Set up the Slide Controller. """ - DisplayController.__init__(self, parent, isLive) + DisplayController.__init__(self, parent, is_live) + Registry().register_function(u'bootstrap_post_set_up', self.screenSizeChanged) self.screens = ScreenList() try: self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height()) except ZeroDivisionError: self.ratio = 1 - self.loopList = [ - u'playSlidesMenu', - u'loopSeparator', - u'delaySpinBox' + self.loop_list = [ + u'play_slides_menu', + u'loop_separator', + u'delay_spin_box' ] - self.audioList = [ - u'audioPauseItem', - u'audioTimeLabel' + self.audio_list = [ + u'audio_pause_item', + u'audio_time_label' ] - self.wideMenu = [ - u'blankScreenButton', - u'themeScreenButton', - u'desktopScreenButton' + self.wide_menu = [ + u'blank_screen_button', + u'theme_screen_button', + u'desktop_screen_button' ] - self.hideMenuList = [ - u'hideMenu' + self.narrow_menu = [ + u'hide_menu' ] self.timer_id = 0 - self.songEdit = False - self.selectedRow = 0 - self.serviceItem = None + self.song_edit = False + self.selected_row = 0 + self.service_item = None self.slide_limits = None self.update_slide_limits() self.panel = QtGui.QWidget(parent.controlSplitter) self.slideList = {} # Layout for holding panel - self.panelLayout = QtGui.QVBoxLayout(self.panel) - self.panelLayout.setSpacing(0) - self.panelLayout.setMargin(0) + self.panel_layout = QtGui.QVBoxLayout(self.panel) + self.panel_layout.setSpacing(0) + self.panel_layout.setMargin(0) # Type label for the top of the slide controller - self.typeLabel = QtGui.QLabel(self.panel) - if self.isLive: + self.type_label = QtGui.QLabel(self.panel) + if self.is_live: Registry().register(u'live_controller', self) - self.typeLabel.setText(UiStrings().Live) + self.type_label.setText(UiStrings().Live) self.split = 1 - self.typePrefix = u'live' + self.type_prefix = u'live' self.keypress_queue = deque() self.keypress_loop = False self.category = UiStrings().LiveToolbar ActionList.get_instance().add_category(unicode(self.category), CategoryOrder.standard_toolbar) else: Registry().register(u'preview_controller', self) - self.typeLabel.setText(UiStrings().Preview) + self.type_label.setText(UiStrings().Preview) self.split = 0 - self.typePrefix = u'preview' + self.type_prefix = 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) + self.type_label.setStyleSheet(u'font-weight: bold; font-size: 12pt;') + self.type_label.setAlignment(QtCore.Qt.AlignCenter) + self.panel_layout.addWidget(self.type_label) # Splitter self.splitter = QtGui.QSplitter(self.panel) self.splitter.setOrientation(QtCore.Qt.Vertical) - self.panelLayout.addWidget(self.splitter) + self.panel_layout.addWidget(self.splitter) # Actual controller section self.controller = QtGui.QWidget(self.splitter) self.controller.setGeometry(QtCore.QRect(0, 0, 100, 536)) self.controller.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum)) - self.controllerLayout = QtGui.QVBoxLayout(self.controller) - self.controllerLayout.setSpacing(0) - self.controllerLayout.setMargin(0) + self.controller_layout = QtGui.QVBoxLayout(self.controller) + self.controller_layout.setSpacing(0) + self.controller_layout.setMargin(0) # Controller list view - self.previewListWidget = QtGui.QTableWidget(self.controller) - self.previewListWidget.setColumnCount(1) - self.previewListWidget.horizontalHeader().setVisible(False) - self.previewListWidget.setColumnWidth(0, self.controller.width()) - self.previewListWidget.isLive = self.isLive - self.previewListWidget.setObjectName(u'previewListWidget') - self.previewListWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) - self.previewListWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) - self.previewListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) - self.previewListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.previewListWidget.setAlternatingRowColors(True) - self.controllerLayout.addWidget(self.previewListWidget) + self.preview_list_widget = QtGui.QTableWidget(self.controller) + self.preview_list_widget.setColumnCount(1) + self.preview_list_widget.horizontalHeader().setVisible(False) + self.preview_list_widget.setColumnWidth(0, self.controller.width()) + self.preview_list_widget.is_live = self.is_live + self.preview_list_widget.setObjectName(u'preview_list_widget') + self.preview_list_widget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) + self.preview_list_widget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) + self.preview_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.preview_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.preview_list_widget.setAlternatingRowColors(True) + self.controller_layout.addWidget(self.preview_list_widget) # Build the full toolbar self.toolbar = OpenLPToolbar(self) - sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizeToolbarPolicy.setHorizontalStretch(0) - sizeToolbarPolicy.setVerticalStretch(0) - sizeToolbarPolicy.setHeightForWidth(self.toolbar.sizePolicy().hasHeightForWidth()) - self.toolbar.setSizePolicy(sizeToolbarPolicy) - self.previousItem = create_action(self, u'previousItem_' + self.typePrefix, + size_toolbar_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + size_toolbar_policy.setHorizontalStretch(0) + size_toolbar_policy.setVerticalStretch(0) + size_toolbar_policy.setHeightForWidth(self.toolbar.sizePolicy().hasHeightForWidth()) + self.toolbar.setSizePolicy(size_toolbar_policy) + self.previous_item = create_action(self, u'previousItem_' + self.type_prefix, text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.on_slide_selected_previous) - self.toolbar.addAction(self.previousItem) - self.nextItem = create_action(self, u'nextItem_' + self.typePrefix, + self.toolbar.addAction(self.previous_item) + self.nextItem = create_action(self, u'nextItem_' + self.type_prefix, text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.on_slide_selected_next_action) self.toolbar.addAction(self.nextItem) self.toolbar.addSeparator() - self.controllerType = DisplayControllerType.Preview - if self.isLive: - self.controllerType = DisplayControllerType.Live + self.controller_type = DisplayControllerType.Preview + if self.is_live: + self.controller_type = DisplayControllerType.Live # 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.hideMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar)) - self.toolbar.addToolbarWidget(self.hideMenu) - self.blankScreen = create_action(self, u'blankScreen', + self.hide_menu = QtGui.QToolButton(self.toolbar) + self.hide_menu.setObjectName(u'hide_menu') + self.hide_menu.setText(translate('OpenLP.SlideController', 'Hide')) + self.hide_menu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) + self.hide_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar)) + self.toolbar.addToolbarWidget(self.hide_menu) + self.blank_screen = create_action(self, u'blankScreen', text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.onBlankDisplay) - self.themeScreen = create_action(self, u'themeScreen', + self.theme_screen = create_action(self, u'themeScreen', text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.onThemeDisplay) - self.desktopScreen = create_action(self, u'desktopScreen', + self.desktop_screen = create_action(self, u'desktopScreen', text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png', checked=False, can_shortcuts=True, 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.hide_menu.setDefaultAction(self.blank_screen) + self.hide_menu.menu().addAction(self.blank_screen) + self.hide_menu.menu().addAction(self.theme_screen) + self.hide_menu.menu().addAction(self.desktop_screen) # Wide menu of display control buttons. - self.blankScreenButton = QtGui.QToolButton(self.toolbar) - self.blankScreenButton.setObjectName(u'blankScreenButton') - self.toolbar.addToolbarWidget(self.blankScreenButton) - self.blankScreenButton.setDefaultAction(self.blankScreen) - self.themeScreenButton = QtGui.QToolButton(self.toolbar) - self.themeScreenButton.setObjectName(u'themeScreenButton') - self.toolbar.addToolbarWidget(self.themeScreenButton) - self.themeScreenButton.setDefaultAction(self.themeScreen) - self.desktopScreenButton = QtGui.QToolButton(self.toolbar) - self.desktopScreenButton.setObjectName(u'desktopScreenButton') - self.toolbar.addToolbarWidget(self.desktopScreenButton) - self.desktopScreenButton.setDefaultAction(self.desktopScreen) - self.toolbar.addToolbarAction(u'loopSeparator', separator=True) + self.blank_screen_button = QtGui.QToolButton(self.toolbar) + self.blank_screen_button.setObjectName(u'blank_screen_button') + self.toolbar.addToolbarWidget(self.blank_screen_button) + self.blank_screen_button.setDefaultAction(self.blank_screen) + self.theme_screen_button = QtGui.QToolButton(self.toolbar) + self.theme_screen_button.setObjectName(u'theme_screen_button') + self.toolbar.addToolbarWidget(self.theme_screen_button) + self.theme_screen_button.setDefaultAction(self.theme_screen) + self.desktop_screen_button = QtGui.QToolButton(self.toolbar) + self.desktop_screen_button.setObjectName(u'desktop_screen_button') + self.toolbar.addToolbarWidget(self.desktop_screen_button) + self.desktop_screen_button.setDefaultAction(self.desktop_screen) + self.toolbar.addToolbarAction(u'loop_separator', separator=True) # 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.playSlidesMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) - self.toolbar.addToolbarWidget(self.playSlidesMenu) - self.playSlidesLoop = create_action(self, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, + self.play_slides_menu = QtGui.QToolButton(self.toolbar) + self.play_slides_menu.setObjectName(u'play_slides_menu') + self.play_slides_menu.setText(translate('OpenLP.SlideController', 'Play Slides')) + self.play_slides_menu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) + self.play_slides_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) + self.toolbar.addToolbarWidget(self.play_slides_menu) + self.play_slides_loop = create_action(self, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=u':/media/media_time.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.onPlaySlidesLoop) - self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, + self.play_slides_once = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.onPlaySlidesOnce) if Settings().value(self.main_window.advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap: - self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) + self.play_slides_menu.setDefaultAction(self.play_slides_loop) else: - self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) - self.playSlidesMenu.menu().addAction(self.playSlidesLoop) - self.playSlidesMenu.menu().addAction(self.playSlidesOnce) + self.play_slides_menu.setDefaultAction(self.play_slides_once) + self.play_slides_menu.menu().addAction(self.play_slides_loop) + self.play_slides_menu.menu().addAction(self.play_slides_once) # Loop Delay Spinbox - self.delaySpinBox = QtGui.QSpinBox() - self.delaySpinBox.setObjectName(u'delaySpinBox') - self.delaySpinBox.setRange(1, 180) - self.delaySpinBox.setSuffix(UiStrings().Seconds) - self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds.')) - self.toolbar.addToolbarWidget(self.delaySpinBox) + self.delay_spin_box = QtGui.QSpinBox() + self.delay_spin_box.setObjectName(u'delay_spin_box') + self.delay_spin_box.setRange(1, 180) + self.delay_spin_box.setSuffix(UiStrings().Seconds) + self.delay_spin_box.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds.')) + self.toolbar.addToolbarWidget(self.delay_spin_box) else: self.toolbar.addToolbarAction(u'goLive', icon=u':/general/general_live.png', tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.onGoLive) @@ -258,27 +259,27 @@ class SlideController(DisplayController): 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) - self.controllerLayout.addWidget(self.toolbar) + self.controller_layout.addWidget(self.toolbar) # Build the Media Toolbar self.media_controller.register_controller(self) - if self.isLive: + if self.is_live: # 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.songMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Go To'), self.toolbar)) - self.toolbar.addToolbarWidget(self.songMenu) + self.song_menu = QtGui.QToolButton(self.toolbar) + self.song_menu.setObjectName(u'song_menu') + self.song_menu.setText(translate('OpenLP.SlideController', 'Go To')) + self.song_menu.setPopupMode(QtGui.QToolButton.InstantPopup) + self.song_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Go To'), self.toolbar)) + self.toolbar.addToolbarWidget(self.song_menu) # Stuff for items with background audio. - self.audioPauseItem = self.toolbar.addToolbarAction(u'audioPauseItem', + self.audio_pause_item = self.toolbar.addToolbarAction(u'audioPauseItem', icon=u':/slides/media_playback_pause.png', text=translate('OpenLP.SlideController', 'Pause Audio'), tooltip=translate('OpenLP.SlideController', 'Pause audio.'), checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut, can_shortcuts=True, triggers=self.onAudioPauseClicked) self.audioMenu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) - self.audioPauseItem.setMenu(self.audioMenu) - self.audioPauseItem.setParent(self.toolbar) - self.toolbar.widgetForAction(self.audioPauseItem).setPopupMode( + self.audio_pause_item.setMenu(self.audioMenu) + self.audio_pause_item.setParent(self.toolbar) + self.toolbar.widgetForAction(self.audio_pause_item).setPopupMode( QtGui.QToolButton.MenuButtonPopup) self.nextTrackItem = create_action(self, u'nextTrackItem', text=UiStrings().NextTrack, icon=u':/slides/media_playback_next.png', @@ -286,35 +287,35 @@ class SlideController(DisplayController): category=self.category, can_shortcuts=True, triggers=self.onNextTrackClicked) self.audioMenu.addAction(self.nextTrackItem) self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks')) - self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) - self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) - self.audioTimeLabel.setStyleSheet(AUDIO_TIME_LABEL_STYLESHEET) - self.audioTimeLabel.setObjectName(u'audioTimeLabel') - self.toolbar.addToolbarWidget(self.audioTimeLabel) - self.toolbar.setWidgetVisible(self.audioList, False) + self.audio_time_label = QtGui.QLabel(u' 00:00 ', self.toolbar) + self.audio_time_label.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) + self.audio_time_label.setStyleSheet(AUDIO_TIME_LABEL_STYLESHEET) + self.audio_time_label.setObjectName(u'audio_time_label') + self.toolbar.addToolbarWidget(self.audio_time_label) + self.toolbar.setWidgetVisible(self.audio_list, False) self.toolbar.setWidgetVisible([u'songMenu'], False) # Screen preview area - self.previewFrame = QtGui.QFrame(self.splitter) - self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) - self.previewFrame.setMinimumHeight(100) - self.previewFrame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored, + self.preview_frame = QtGui.QFrame(self.splitter) + self.preview_frame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) + self.preview_frame.setMinimumHeight(100) + self.preview_frame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Label)) - self.previewFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.previewFrame.setFrameShadow(QtGui.QFrame.Sunken) - self.previewFrame.setObjectName(u'previewFrame') - self.grid = QtGui.QGridLayout(self.previewFrame) + self.preview_frame.setFrameShape(QtGui.QFrame.StyledPanel) + self.preview_frame.setFrameShadow(QtGui.QFrame.Sunken) + self.preview_frame.setObjectName(u'preview_frame') + self.grid = QtGui.QGridLayout(self.preview_frame) self.grid.setMargin(8) self.grid.setObjectName(u'grid') - self.slideLayout = QtGui.QVBoxLayout() - self.slideLayout.setSpacing(0) - self.slideLayout.setMargin(0) - self.slideLayout.setObjectName(u'SlideLayout') - self.previewDisplay = Display(self, self.isLive, self) - self.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300)) - self.previewDisplay.screen = {u'size': self.previewDisplay.geometry()} - self.previewDisplay.setup() - self.slideLayout.insertWidget(0, self.previewDisplay) - self.previewDisplay.hide() + self.slide_layout = QtGui.QVBoxLayout() + self.slide_layout.setSpacing(0) + self.slide_layout.setMargin(0) + self.slide_layout.setObjectName(u'SlideLayout') + self.preview_display = Display(self, self.is_live, self) + self.preview_display.setGeometry(QtCore.QRect(0, 0, 300, 300)) + self.preview_display.screen = {u'size': self.preview_display.geometry()} + self.preview_display.setup() + self.slide_layout.insertWidget(0, self.preview_display) + self.preview_display.hide() # Actual preview screen self.slidePreview = QtGui.QLabel(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) @@ -327,9 +328,9 @@ class SlideController(DisplayController): self.slidePreview.setLineWidth(1) self.slidePreview.setScaledContents(True) self.slidePreview.setObjectName(u'slidePreview') - self.slideLayout.insertWidget(0, self.slidePreview) - self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) - if self.isLive: + self.slide_layout.insertWidget(0, self.slidePreview) + self.grid.addLayout(self.slide_layout, 0, 0, 1, 1) + if self.is_live: self.current_shortcut = u'' self.shortcutTimer = QtCore.QTimer() self.shortcutTimer.setObjectName(u'shortcutTimer') @@ -345,7 +346,7 @@ class SlideController(DisplayController): {u'key': u'O', u'configurable': True, u'text': translate('OpenLP.SlideController', 'Go to "Other"')} ] shortcuts.extend([{u'key': unicode(number)} for number in range(10)]) - self.previewListWidget.addActions([create_action(self, + self.preview_list_widget.addActions([create_action(self, u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, @@ -355,28 +356,28 @@ class SlideController(DisplayController): self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), self._slideShortcutActivated) # Signals - QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) - if self.isLive: + QtCore.QObject.connect(self.preview_list_widget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) + if self.is_live: Registry().register_function(u'slidecontroller_live_spin_delay', self.receive_spin_delay) Registry().register_function(u'slidecontroller_toggle_display', self.toggle_display) - self.toolbar.setWidgetVisible(self.loopList, False) - self.toolbar.setWidgetVisible(self.wideMenu, False) + self.toolbar.setWidgetVisible(self.loop_list, False) + self.toolbar.setWidgetVisible(self.wide_menu, False) else: - QtCore.QObject.connect(self.previewListWidget, + QtCore.QObject.connect(self.preview_list_widget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onGoLiveClick) self.toolbar.setWidgetVisible([u'editSong'], False) - if self.isLive: + if self.is_live: self.setLiveHotkeys(self) - self.__addActionsToWidget(self.previewListWidget) + self.__addActionsToWidget(self.preview_list_widget) else: - self.previewListWidget.addActions([self.nextItem, self.previousItem]) - Registry().register_function(u'slidecontroller_%s_stop_loop' % self.typePrefix, self.on_stop_loop) - Registry().register_function(u'slidecontroller_%s_next' % self.typePrefix, self.on_slide_selected_next) - Registry().register_function(u'slidecontroller_%s_previous' % self.typePrefix, self.on_slide_selected_previous) - Registry().register_function(u'slidecontroller_%s_change' % self.typePrefix, self.on_slide_change) - Registry().register_function(u'slidecontroller_%s_set' % self.typePrefix, self.on_slide_selected_index) - Registry().register_function(u'slidecontroller_%s_blank' % self.typePrefix, self.on_slide_blank) - Registry().register_function(u'slidecontroller_%s_unblank' % self.typePrefix, self.on_slide_unblank) + self.preview_list_widget.addActions([self.nextItem, self.previous_item]) + Registry().register_function(u'slidecontroller_%s_stop_loop' % self.type_prefix, self.on_stop_loop) + Registry().register_function(u'slidecontroller_%s_next' % self.type_prefix, self.on_slide_selected_next) + Registry().register_function(u'slidecontroller_%s_previous' % self.type_prefix, self.on_slide_selected_previous) + Registry().register_function(u'slidecontroller_%s_change' % self.type_prefix, self.on_slide_change) + Registry().register_function(u'slidecontroller_%s_set' % self.type_prefix, self.on_slide_selected_index) + Registry().register_function(u'slidecontroller_%s_blank' % self.type_prefix, self.on_slide_blank) + Registry().register_function(u'slidecontroller_%s_unblank' % self.type_prefix, self.on_slide_unblank) Registry().register_function(u'slidecontroller_update_slide_limits', self.update_slide_limits) def _slideShortcutActivated(self): @@ -519,11 +520,11 @@ class SlideController(DisplayController): # rebuild display as screen size changed if self.display: self.display.close() - self.display = MainDisplay(self, self.isLive, self) + self.display = MainDisplay(self, self.is_live, self) self.display.setup() - if self.isLive: + if self.is_live: 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.on_audio_time_remaining) # The SlidePreview's ratio. try: self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height()) @@ -531,12 +532,12 @@ class SlideController(DisplayController): self.ratio = 1 self.media_controller.setup_display(self.display, False) self.previewSizeChanged() - self.previewDisplay.setup() - serviceItem = ServiceItem() - self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive, + self.preview_display.setup() + service_item = ServiceItem() + self.preview_display.web_view.setHtml(build_html(service_item, self.preview_display.screen, None, self.is_live, plugins=self.plugin_manager.plugins)) - self.media_controller.setup_display(self.previewDisplay, True) - if self.serviceItem: + self.media_controller.setup_display(self.preview_display, True) + if self.service_item: self.refreshServiceItem() def __addActionsToWidget(self, widget): @@ -544,7 +545,7 @@ class SlideController(DisplayController): Add actions to the widget specified by `widget` """ widget.addActions([ - self.previousItem, self.nextItem, + self.previous_item, self.nextItem, self.previousService, self.nextService, self.escapeItem]) @@ -554,49 +555,48 @@ class SlideController(DisplayController): splitters is moved or when the screen size is changed. Note, that this method is (also) called frequently from the mainwindow *paintEvent*. """ - if self.ratio < float(self.previewFrame.width()) / float(self.previewFrame.height()): + if self.ratio < float(self.preview_frame.width()) / float(self.preview_frame.height()): # We have to take the height as limit. - max_height = self.previewFrame.height() - self.grid.margin() * 2 + max_height = self.preview_frame.height() - self.grid.margin() * 2 self.slidePreview.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height)) - self.previewDisplay.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height)) - self.previewDisplay.screen = { - u'size': self.previewDisplay.geometry()} + self.preview_display.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height)) + self.preview_display.screen = { + u'size': self.preview_display.geometry()} else: # We have to take the width as limit. - max_width = self.previewFrame.width() - self.grid.margin() * 2 + max_width = self.preview_frame.width() - self.grid.margin() * 2 self.slidePreview.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) - self.previewDisplay.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) - self.previewDisplay.screen = { - u'size': self.previewDisplay.geometry()} + self.preview_display.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) + self.preview_display.screen = { + u'size': self.preview_display.geometry()} # Make sure that the frames have the correct size. - self.previewListWidget.setColumnWidth(0, - self.previewListWidget.viewport().size().width()) - if self.serviceItem: + self.preview_list_widget.setColumnWidth(0, self.preview_list_widget.viewport().size().width()) + if self.service_item: # Sort out songs, bibles, etc. - if self.serviceItem.is_text(): - self.previewListWidget.resizeRowsToContents() + if self.service_item.is_text(): + self.preview_list_widget.resizeRowsToContents() else: # Sort out image heights. width = self.main_window.controlSplitter.sizes()[self.split] - for framenumber in range(len(self.serviceItem.get_frames())): - self.previewListWidget.setRowHeight(framenumber, width / self.ratio) + for framenumber in range(len(self.service_item.get_frames())): + self.preview_list_widget.setRowHeight(framenumber, width / self.ratio) self.onControllerSizeChanged(self.controller.width(), self.controller.height()) def onControllerSizeChanged(self, width, height): """ Change layout of display control buttons on controller size change """ - if self.isLive: + if self.is_live: # Space used by the toolbar. - used_space = self.toolbar.size().width() + self.hideMenu.size().width() + used_space = self.toolbar.size().width() + self.hide_menu.size().width() # The + 40 is needed to prevent flickering. This can be considered a "buffer". - if width > used_space + 40 and self.hideMenu.isVisible(): - self.toolbar.setWidgetVisible(self.hideMenuList, False) - self.toolbar.setWidgetVisible(self.wideMenu) + if width > used_space + 40 and self.hide_menu.isVisible(): + self.toolbar.setWidgetVisible(self.narrow_menu, False) + self.toolbar.setWidgetVisible(self.wide_menu) # The - 40 is needed to prevent flickering. This can be considered a "buffer". - elif width < used_space - 40 and not self.hideMenu.isVisible(): - self.toolbar.setWidgetVisible(self.wideMenu, False) - self.toolbar.setWidgetVisible(self.hideMenuList) + elif width < used_space - 40 and not self.hide_menu.isVisible(): + self.toolbar.setWidgetVisible(self.wide_menu, False) + self.toolbar.setWidgetVisible(self.narrow_menu) def onSongBarHandler(self): """ @@ -609,9 +609,9 @@ class SlideController(DisplayController): def receive_spin_delay(self, value): """ - Adjusts the value of the ``delaySpinBox`` to the given one. + Adjusts the value of the ``delay_spin_box`` to the given one. """ - self.delaySpinBox.setValue(int(value)) + self.delay_spin_box.setValue(int(value)) def update_slide_limits(self): """ @@ -624,7 +624,7 @@ class SlideController(DisplayController): Allows the toolbars to be reconfigured based on Controller Type and ServiceItem Type """ - if self.isLive: + if self.is_live: self.enableLiveToolBar(item) else: self.enablePreviewToolBar(item) @@ -637,22 +637,22 @@ class SlideController(DisplayController): # See bug #791050 self.toolbar.hide() self.mediabar.hide() - self.songMenu.hide() - self.toolbar.setWidgetVisible(self.loopList, False) + self.song_menu.hide() + self.toolbar.setWidgetVisible(self.loop_list, False) self.toolbar.setWidgetVisible([u'songMenu'], False) # Reset the button - self.playSlidesOnce.setChecked(False) - self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png')) - self.playSlidesLoop.setChecked(False) - self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) + self.play_slides_once.setChecked(False) + self.play_slides_once.setIcon(build_icon(u':/media/media_time.png')) + self.play_slides_loop.setChecked(False) + self.play_slides_loop.setIcon(build_icon(u':/media/media_time.png')) if item.is_text(): if Settings().value(self.main_window.songsSettingsSection + u'/display songbar') and self.slideList: self.toolbar.setWidgetVisible([u'songMenu'], True) if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1: - self.toolbar.setWidgetVisible(self.loopList) + self.toolbar.setWidgetVisible(self.loop_list) if item.is_media(): self.mediabar.show() - self.previousItem.setVisible(not item.is_media()) + self.previous_item.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 @@ -671,7 +671,7 @@ class SlideController(DisplayController): self.toolbar.setWidgetVisible([u'editSong']) elif item.is_media(): self.mediabar.show() - self.previousItem.setVisible(not item.is_media()) + self.previous_item.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 @@ -681,31 +681,31 @@ class SlideController(DisplayController): """ Method to update the service item if the screen has changed """ - log.debug(u'refreshServiceItem live = %s' % self.isLive) - if self.serviceItem.is_text() or self.serviceItem.is_image(): - item = self.serviceItem + log.debug(u'refreshServiceItem live = %s' % self.is_live) + if self.service_item.is_text() or self.service_item.is_image(): + item = self.service_item item.render() - self._processItem(item, self.selectedRow) + self._processItem(item, self.selected_row) def add_service_item(self, item): """ Method to install the service item into the controller Called by plugins """ - log.debug(u'add_service_item live = %s' % self.isLive) + log.debug(u'add_service_item live = %s' % self.is_live) item.render() slideno = 0 - if self.songEdit: - slideno = self.selectedRow - self.songEdit = False + if self.song_edit: + slideno = self.selected_row + self.song_edit = False self._processItem(item, slideno) def replaceServiceManagerItem(self, item): """ Replacement item following a remote edit """ - if item == self.serviceItem: - self._processItem(item, self.previewListWidget.currentRow()) + if item == self.service_item: + self._processItem(item, self.preview_list_widget.currentRow()) def addServiceManagerItem(self, item, slideno): """ @@ -713,74 +713,74 @@ class SlideController(DisplayController): request the correct toolbar for the plugin. Called by ServiceManager """ - log.debug(u'addServiceManagerItem live = %s' % self.isLive) + log.debug(u'addServiceManagerItem live = %s' % self.is_live) # If no valid slide number is specified we take the first one, but we # remember the initial value to see if we should reload the song or not slidenum = slideno if slideno == -1: slidenum = 0 # If service item is the same as the current one, only change slide - if slideno >= 0 and item == self.serviceItem: + if slideno >= 0 and item == self.service_item: self.__checkUpdateSelectedSlide(slidenum) self.slideSelected() else: self._processItem(item, slidenum) - if self.isLive and item.auto_play_slides_loop and item.timed_slide_interval > 0: - self.playSlidesLoop.setChecked(item.auto_play_slides_loop) - self.delaySpinBox.setValue(int(item.timed_slide_interval)) + if self.is_live and item.auto_play_slides_loop and item.timed_slide_interval > 0: + self.play_slides_loop.setChecked(item.auto_play_slides_loop) + self.delay_spin_box.setValue(int(item.timed_slide_interval)) self.onPlaySlidesLoop() - elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0: - self.playSlidesOnce.setChecked(item.auto_play_slides_once) - self.delaySpinBox.setValue(int(item.timed_slide_interval)) + elif self.is_live and item.auto_play_slides_once and item.timed_slide_interval > 0: + self.play_slides_once.setChecked(item.auto_play_slides_once) + self.delay_spin_box.setValue(int(item.timed_slide_interval)) self.onPlaySlidesOnce() - def _processItem(self, serviceItem, slideno): + def _processItem(self, service_item, slideno): """ Loads a ServiceItem into the system from ServiceManager Display the slide number passed """ - log.debug(u'processManagerItem live = %s' % self.isLive) + log.debug(u'processManagerItem live = %s' % self.is_live) self.on_stop_loop() - old_item = self.serviceItem + old_item = self.service_item # take a copy not a link to the servicemanager copy. - self.serviceItem = copy.copy(serviceItem) - if old_item and self.isLive and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay): + self.service_item = copy.copy(service_item) + if old_item and self.is_live and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay): self._resetBlank() - Registry().execute(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, self.hideMode(), slideno]) + Registry().execute(u'%s_start' % service_item.name.lower(), [service_item, self.is_live, self.hide_mode(), slideno]) self.slideList = {} width = self.main_window.controlSplitter.sizes()[self.split] - self.previewListWidget.clear() - self.previewListWidget.setRowCount(0) - self.previewListWidget.setColumnWidth(0, width) - if self.isLive: - self.songMenu.menu().clear() + self.preview_list_widget.clear() + self.preview_list_widget.setRowCount(0) + self.preview_list_widget.setColumnWidth(0, width) + if self.is_live: + self.song_menu.menu().clear() self.display.audioPlayer.reset() self.setAudioItemsVisibility(False) - self.audioPauseItem.setChecked(False) + self.audio_pause_item.setChecked(False) # If the current item has background audio - if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio): + if self.service_item.is_capable(ItemCapabilities.HasBackgroundAudio): log.debug(u'Starting to play...') - self.display.audioPlayer.addToPlaylist(self.serviceItem.background_audio) + self.display.audioPlayer.add_to_playlist(self.service_item.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])) + for counter in range(len(self.service_item.background_audio)): + action = self.trackMenu.addAction(os.path.basename(self.service_item.background_audio[counter])) action.setData(counter) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), self.onTrackTriggered) self.display.audioPlayer.repeat = Settings().value( self.main_window.generalSettingsSection + u'/audio repeat list') if Settings().value(self.main_window.generalSettingsSection + u'/audio start paused'): - self.audioPauseItem.setChecked(True) + self.audio_pause_item.setChecked(True) self.display.audioPlayer.pause() else: self.display.audioPlayer.play() self.setAudioItemsVisibility(True) row = 0 text = [] - for framenumber, frame in enumerate(self.serviceItem.get_frames()): - self.previewListWidget.setRowCount(self.previewListWidget.rowCount() + 1) + for framenumber, frame in enumerate(self.service_item.get_frames()): + self.preview_list_widget.setRowCount(self.preview_list_widget.rowCount() + 1) item = QtGui.QTableWidgetItem() slideHeight = 0 - if self.serviceItem.is_text(): + if self.service_item.is_text(): if frame[u'verseTag']: # These tags are already translated. verse_def = frame[u'verseTag'] @@ -789,9 +789,8 @@ class SlideController(DisplayController): row = two_line_def if verse_def not in self.slideList: self.slideList[verse_def] = framenumber - if self.isLive: - self.songMenu.menu().addAction(verse_def, - self.onSongBarHandler) + if self.is_live: + self.song_menu.menu().addAction(verse_def, self.onSongBarHandler) else: row += 1 self.slideList[unicode(row)] = row - 1 @@ -799,61 +798,61 @@ class SlideController(DisplayController): else: label = QtGui.QLabel() label.setMargin(4) - if serviceItem.is_media(): + if service_item.is_media(): label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) else: label.setScaledContents(True) - if self.serviceItem.is_command(): + if self.service_item.is_command(): label.setPixmap(QtGui.QPixmap(frame[u'image'])) else: # If current slide set background to image if framenumber == slideno: - self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'], + self.service_item.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'], ImageSource.ImagePlugin) image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin) label.setPixmap(QtGui.QPixmap.fromImage(image)) - self.previewListWidget.setCellWidget(framenumber, 0, label) + self.preview_list_widget.setCellWidget(framenumber, 0, label) slideHeight = width * (1 / self.ratio) row += 1 self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) - self.previewListWidget.setItem(framenumber, 0, item) + self.preview_list_widget.setItem(framenumber, 0, item) if slideHeight: - self.previewListWidget.setRowHeight(framenumber, slideHeight) - self.previewListWidget.setVerticalHeaderLabels(text) - if self.serviceItem.is_text(): - self.previewListWidget.resizeRowsToContents() - self.previewListWidget.setColumnWidth(0, - self.previewListWidget.viewport().size().width()) + self.preview_list_widget.setRowHeight(framenumber, slideHeight) + self.preview_list_widget.setVerticalHeaderLabels(text) + if self.service_item.is_text(): + self.preview_list_widget.resizeRowsToContents() + self.preview_list_widget.setColumnWidth(0, + self.preview_list_widget.viewport().size().width()) self.__updatePreviewSelection(slideno) - self.enableToolBar(serviceItem) + self.enableToolBar(service_item) # Pass to display for viewing. # Postpone image build, we need to do this later to avoid the theme # flashing on the screen - if not self.serviceItem.is_image(): - self.display.buildHtml(self.serviceItem) - if serviceItem.is_media(): - self.onMediaStart(serviceItem) + if not self.service_item.is_image(): + self.display.build_html(self.service_item) + if service_item.is_media(): + self.onMediaStart(service_item) self.slideSelected(True) - self.previewListWidget.setFocus() + self.preview_list_widget.setFocus() if old_item: # Close the old item after the new one is opened # This avoids the service theme/desktop flashing on screen # However opening a new item of the same type will automatically # close the previous, so make sure we don't close the new one. - if old_item.is_command() and not serviceItem.is_command(): - Registry().execute(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive]) - if old_item.is_media() and not serviceItem.is_media(): + if old_item.is_command() and not service_item.is_command(): + Registry().execute(u'%s_stop' % old_item.name.lower(), [old_item, self.is_live]) + if old_item.is_media() and not service_item.is_media(): self.onMediaClose() - Registry().execute(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) + Registry().execute(u'slidecontroller_%s_started' % self.type_prefix, [service_item]) def __updatePreviewSelection(self, slideno): """ Utility method to update the selected slide in the list. """ - if slideno > self.previewListWidget.rowCount(): - self.previewListWidget.selectRow( - self.previewListWidget.rowCount() - 1) + if slideno > self.preview_list_widget.rowCount(): + self.preview_list_widget.selectRow( + self.preview_list_widget.rowCount() - 1) else: self.__checkUpdateSelectedSlide(slideno) @@ -863,10 +862,10 @@ class SlideController(DisplayController): Go to the requested slide """ index = int(message[0]) - if not self.serviceItem: + if not self.service_item: return - if self.serviceItem.is_command(): - Registry().execute(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index]) + if self.service_item.is_command(): + Registry().execute(u'%s_slide' % self.service_item.name.lower(), [self.service_item, self.is_live, index]) self.updatePreview() else: self.__checkUpdateSelectedSlide(index) @@ -876,7 +875,7 @@ class SlideController(DisplayController): """ Allow the main display to blank the main display at startup time """ - log.debug(u'mainDisplaySetBackground live = %s' % self.isLive) + log.debug(u'mainDisplaySetBackground live = %s' % self.is_live) display_type = Settings().value(self.main_window.generalSettingsSection + u'/screen blank') if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display): # Order done to handle initial conversion @@ -908,12 +907,12 @@ class SlideController(DisplayController): Handle the blank screen button actions """ if checked is None: - checked = self.blankScreen.isChecked() + checked = self.blank_screen.isChecked() log.debug(u'onBlankDisplay %s' % checked) - self.hideMenu.setDefaultAction(self.blankScreen) - self.blankScreen.setChecked(checked) - self.themeScreen.setChecked(False) - self.desktopScreen.setChecked(False) + self.hide_menu.setDefaultAction(self.blank_screen) + self.blank_screen.setChecked(checked) + self.theme_screen.setChecked(False) + self.desktop_screen.setChecked(False) if checked: Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'blanked') else: @@ -927,12 +926,12 @@ class SlideController(DisplayController): Handle the Theme screen button """ if checked is None: - checked = self.themeScreen.isChecked() + checked = self.theme_screen.isChecked() log.debug(u'onThemeDisplay %s' % checked) - self.hideMenu.setDefaultAction(self.themeScreen) - self.blankScreen.setChecked(False) - self.themeScreen.setChecked(checked) - self.desktopScreen.setChecked(False) + self.hide_menu.setDefaultAction(self.theme_screen) + self.blank_screen.setChecked(False) + self.theme_screen.setChecked(checked) + self.desktop_screen.setChecked(False) if checked: Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'themed') else: @@ -946,12 +945,12 @@ class SlideController(DisplayController): Handle the Hide screen button """ if checked is None: - checked = self.desktopScreen.isChecked() + checked = self.desktop_screen.isChecked() log.debug(u'onHideDisplay %s' % checked) - self.hideMenu.setDefaultAction(self.desktopScreen) - self.blankScreen.setChecked(False) - self.themeScreen.setChecked(False) - self.desktopScreen.setChecked(checked) + self.hide_menu.setDefaultAction(self.desktop_screen) + self.blank_screen.setChecked(False) + self.theme_screen.setChecked(False) + self.desktop_screen.setChecked(checked) if checked: Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'hidden') else: @@ -964,18 +963,18 @@ class SlideController(DisplayController): """ Blank/Hide the display screen within a plugin if required. """ - hide_mode = self.hideMode() + hide_mode = self.hide_mode() log.debug(u'blankPlugin %s ', hide_mode) - if self.serviceItem is not None: + if self.service_item is not None: if hide_mode: - if not self.serviceItem.is_command(): + if not self.service_item.is_command(): Registry().execute(u'live_display_hide', hide_mode) - Registry().execute(u'%s_blank' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive, hide_mode]) + Registry().execute(u'%s_blank' % self.service_item.name.lower(), + [self.service_item, self.is_live, hide_mode]) else: - if not self.serviceItem.is_command(): + if not self.service_item.is_command(): Registry().execute(u'live_display_show') - Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_unblank' % self.service_item.name.lower(), [self.service_item, self.is_live]) else: if hide_mode: Registry().execute(u'live_display_hide', hide_mode) @@ -987,14 +986,14 @@ class SlideController(DisplayController): Tell the plugin to hide the display screen. """ log.debug(u'hidePlugin %s ', hide) - if self.serviceItem is not None: + if self.service_item is not None: if hide: Registry().execute(u'live_display_hide', HideMode.Screen) - Registry().execute(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_hide' % self.service_item.name.lower(), [self.service_item, self.is_live]) else: - if not self.serviceItem.is_command(): + if not self.service_item.is_command(): Registry().execute(u'live_display_show') - Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_unblank' % self.service_item.name.lower(), [self.service_item, self.is_live]) else: if hide: Registry().execute(u'live_display_hide', HideMode.Screen) @@ -1012,28 +1011,28 @@ class SlideController(DisplayController): Generate the preview when you click on a slide. if this is the Live Controller also display on the screen """ - row = self.previewListWidget.currentRow() - self.selectedRow = 0 - if -1 < row < self.previewListWidget.rowCount(): - if self.serviceItem.is_command(): - if self.isLive and not start: - Registry().execute(u'%s_slide' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive, row]) + row = self.preview_list_widget.currentRow() + self.selected_row = 0 + if -1 < row < self.preview_list_widget.rowCount(): + if self.service_item.is_command(): + if self.is_live and not start: + Registry().execute(u'%s_slide' % self.service_item.name.lower(), + [self.service_item, self.is_live, row]) else: - to_display = self.serviceItem.get_rendered_frame(row) - if self.serviceItem.is_text(): + to_display = self.service_item.get_rendered_frame(row) + if self.service_item.is_text(): self.display.text(to_display) else: if start: - self.display.buildHtml(self.serviceItem, to_display) + self.display.build_html(self.service_item, to_display) else: self.display.image(to_display) # reset the store used to display first image - self.serviceItem.bg_image_bytes = None + self.service_item.bg_image_bytes = None self.updatePreview() - self.selectedRow = row + self.selected_row = row self.__checkUpdateSelectedSlide(row) - Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row) + Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row) self.display.setFocus() def on_slide_change(self, row): @@ -1042,7 +1041,7 @@ class SlideController(DisplayController): """ self.__checkUpdateSelectedSlide(row) self.updatePreview() - Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row) + Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row) def updatePreview(self): """ @@ -1050,8 +1049,8 @@ class SlideController(DisplayController): using *Blank to Theme*. """ log.debug(u'updatePreview %s ' % self.screens.current[u'primary']) - if not self.screens.current[u'primary'] and self.serviceItem and \ - self.serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay): + if not self.screens.current[u'primary'] and self.service_item and \ + self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay): # Grab now, but try again in a couple of seconds if slide change # is slow QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) @@ -1079,26 +1078,26 @@ class SlideController(DisplayController): """ Go to the next slide. """ - if not self.serviceItem: + if not self.service_item: return - Registry().execute(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - if self.serviceItem.is_command() and self.isLive: + Registry().execute(u'%s_next' % self.service_item.name.lower(), [self.service_item, self.is_live]) + if self.service_item.is_command() and self.is_live: self.updatePreview() else: - row = self.previewListWidget.currentRow() + 1 - if row == self.previewListWidget.rowCount(): + row = self.preview_list_widget.currentRow() + 1 + if row == self.preview_list_widget.rowCount(): if wrap is None: if self.slide_limits == SlideLimits.Wrap: row = 0 - elif self.isLive and self.slide_limits == SlideLimits.Next: + elif self.is_live and self.slide_limits == SlideLimits.Next: self.serviceNext() return else: - row = self.previewListWidget.rowCount() - 1 + row = self.preview_list_widget.rowCount() - 1 elif wrap: row = 0 else: - row = self.previewListWidget.rowCount() - 1 + row = self.preview_list_widget.rowCount() - 1 self.__checkUpdateSelectedSlide(row) self.slideSelected() @@ -1106,17 +1105,17 @@ class SlideController(DisplayController): """ Go to the previous slide. """ - if not self.serviceItem: + if not self.service_item: return - Registry().execute(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - if self.serviceItem.is_command() and self.isLive: + Registry().execute(u'%s_previous' % self.service_item.name.lower(), [self.service_item, self.is_live]) + if self.service_item.is_command() and self.is_live: self.updatePreview() else: - row = self.previewListWidget.currentRow() - 1 + row = self.preview_list_widget.currentRow() - 1 if row == -1: if self.slide_limits == SlideLimits.Wrap: - row = self.previewListWidget.rowCount() - 1 - elif self.isLive and self.slide_limits == SlideLimits.Next: + row = self.preview_list_widget.rowCount() - 1 + elif self.is_live and self.slide_limits == SlideLimits.Next: self.keypress_queue.append(ServiceItemAction.PreviousLastSlide) self._process_queue() return @@ -1129,16 +1128,16 @@ class SlideController(DisplayController): """ Check if this slide has been updated """ - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem(self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + if row + 1 < self.preview_list_widget.rowCount(): + self.preview_list_widget.scrollToItem(self.preview_list_widget.item(row + 1, 0)) + self.preview_list_widget.selectRow(row) def onToggleLoop(self): """ Toggles the loop state. """ - hide_mode = self.hideMode() - if hide_mode is None and (self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked()): + hide_mode = self.hide_mode() + if hide_mode is None and (self.play_slides_loop.isChecked() or self.play_slides_once.isChecked()): self.onStartLoop() else: self.on_stop_loop() @@ -1147,8 +1146,8 @@ class SlideController(DisplayController): """ Start the timer loop running and store the timer id """ - if self.previewListWidget.rowCount() > 1: - self.timer_id = self.startTimer(int(self.delaySpinBox.value()) * 1000) + if self.preview_list_widget.rowCount() > 1: + self.timer_id = self.startTimer(int(self.delay_spin_box.value()) * 1000) def on_stop_loop(self): """ @@ -1163,20 +1162,20 @@ class SlideController(DisplayController): Start or stop 'Play Slides in Loop' """ if checked is None: - checked = self.playSlidesLoop.isChecked() + checked = self.play_slides_loop.isChecked() else: - self.playSlidesLoop.setChecked(checked) + self.play_slides_loop.setChecked(checked) log.debug(u'onPlaySlidesLoop %s' % checked) if checked: - self.playSlidesLoop.setIcon(build_icon(u':/media/media_stop.png')) - self.playSlidesLoop.setText(UiStrings().StopPlaySlidesInLoop) - self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png')) - self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd) - self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) - self.playSlidesOnce.setChecked(False) + self.play_slides_loop.setIcon(build_icon(u':/media/media_stop.png')) + self.play_slides_loop.setText(UiStrings().StopPlaySlidesInLoop) + self.play_slides_once.setIcon(build_icon(u':/media/media_time.png')) + self.play_slides_once.setText(UiStrings().PlaySlidesToEnd) + self.play_slides_menu.setDefaultAction(self.play_slides_loop) + self.play_slides_once.setChecked(False) else: - self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) - self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop) + self.play_slides_loop.setIcon(build_icon(u':/media/media_time.png')) + self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop) self.onToggleLoop() def onPlaySlidesOnce(self, checked=None): @@ -1184,33 +1183,33 @@ class SlideController(DisplayController): Start or stop 'Play Slides to End' """ if checked is None: - checked = self.playSlidesOnce.isChecked() + checked = self.play_slides_once.isChecked() else: - self.playSlidesOnce.setChecked(checked) + self.play_slides_once.setChecked(checked) log.debug(u'onPlaySlidesOnce %s' % checked) if checked: - self.playSlidesOnce.setIcon(build_icon(u':/media/media_stop.png')) - self.playSlidesOnce.setText(UiStrings().StopPlaySlidesToEnd) - self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) - self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop) - self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) - self.playSlidesLoop.setChecked(False) + self.play_slides_once.setIcon(build_icon(u':/media/media_stop.png')) + self.play_slides_once.setText(UiStrings().StopPlaySlidesToEnd) + self.play_slides_loop.setIcon(build_icon(u':/media/media_time.png')) + self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop) + self.play_slides_menu.setDefaultAction(self.play_slides_once) + self.play_slides_loop.setChecked(False) else: - self.playSlidesOnce.setIcon(build_icon(u':/media/media_time')) - self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd) + self.play_slides_once.setIcon(build_icon(u':/media/media_time')) + self.play_slides_once.setText(UiStrings().PlaySlidesToEnd) self.onToggleLoop() def setAudioItemsVisibility(self, visible): """ Set the visibility of the audio stuff """ - self.toolbar.setWidgetVisible(self.audioList, visible) + self.toolbar.setWidgetVisible(self.audio_list, visible) def onAudioPauseClicked(self, checked): """ Pause the audio player """ - if not self.audioPauseItem.isVisible(): + if not self.audio_pause_item.isVisible(): return if checked: self.display.audioPlayer.pause() @@ -1222,14 +1221,14 @@ class SlideController(DisplayController): If the timer event is for this window select next slide """ if event.timerId() == self.timer_id: - self.on_slide_selected_next(self.playSlidesLoop.isChecked()) + self.on_slide_selected_next(self.play_slides_loop.isChecked()) def onEditSong(self): """ From the preview display requires the service Item to be editied """ - self.songEdit = True - new_item = Registry().get(self.serviceItem.name).onRemoteEdit(self.serviceItem.edit_id, True) + self.song_edit = True + new_item = Registry().get(self.service_item.name).onRemoteEdit(self.service_item.edit_id, True) if new_item: self.add_service_item(new_item) @@ -1237,8 +1236,8 @@ class SlideController(DisplayController): """ From the preview display request the Item to be added to service """ - if self.serviceItem: - self.service_manager.add_service_item(self.serviceItem) + if self.service_item: + self.service_manager.add_service_item(self.service_item) def onGoLiveClick(self): """ @@ -1247,9 +1246,9 @@ class SlideController(DisplayController): if Settings().value(u'advanced/double click live'): # Live and Preview have issues if we have video or presentations # playing in both at the same time. - if self.serviceItem.is_command(): - Registry().execute(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - if self.serviceItem.is_media(): + if self.service_item.is_command(): + Registry().execute(u'%s_stop' % self.service_item.name.lower(), [self.service_item, self.is_live]) + if self.service_item.is_media(): self.onMediaClose() self.onGoLive() @@ -1257,21 +1256,21 @@ class SlideController(DisplayController): """ If preview copy slide item to live controller from Preview Controller """ - row = self.previewListWidget.currentRow() - if -1 < row < self.previewListWidget.rowCount(): - if self.serviceItem.from_service: - self.service_manager.preview_live(self.serviceItem.unique_identifier, row) + row = self.preview_list_widget.currentRow() + if -1 < row < self.preview_list_widget.rowCount(): + if self.service_item.from_service: + self.service_manager.preview_live(self.service_item.unique_identifier, row) else: - self.live_controller.addServiceManagerItem(self.serviceItem, row) + self.live_controller.addServiceManagerItem(self.service_item, row) def onMediaStart(self, item): """ Respond to the arrival of a media service item """ log.debug(u'SlideController onMediaStart') - self.media_controller.video(self.controllerType, item, self.hideMode()) - if not self.isLive: - self.previewDisplay.show() + self.media_controller.video(self.controller_type, item, self.hide_mode()) + if not self.is_live: + self.preview_display.show() self.slidePreview.hide() def onMediaClose(self): @@ -1280,7 +1279,7 @@ class SlideController(DisplayController): """ log.debug(u'SlideController onMediaClose') self.media_controller.media_reset(self) - self.previewDisplay.hide() + self.preview_display.hide() self.slidePreview.show() def _resetBlank(self): @@ -1288,7 +1287,7 @@ class SlideController(DisplayController): Used by command items which provide their own displays to reset the screen hide attributes """ - hide_mode = self.hideMode() + hide_mode = self.hide_mode() if hide_mode == HideMode.Blank: self.onBlankDisplay(True) elif hide_mode == HideMode.Theme: @@ -1298,17 +1297,17 @@ class SlideController(DisplayController): else: self.hidePlugin(False) - def hideMode(self): + def hide_mode(self): """ Determine what the hide mode should be according to the blank button """ - if not self.isLive: + if not self.is_live: return None - elif self.blankScreen.isChecked(): + elif self.blank_screen.isChecked(): return HideMode.Blank - elif self.themeScreen.isChecked(): + elif self.theme_screen.isChecked(): return HideMode.Theme - elif self.desktopScreen.isChecked(): + elif self.desktop_screen.isChecked(): return HideMode.Screen else: return None @@ -1319,21 +1318,21 @@ class SlideController(DisplayController): """ self.display.audioPlayer.next() - def onAudioTimeRemaining(self, time): + def on_audio_time_remaining(self, time): """ Update how much time is remaining """ seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 minutes = seconds // 60 seconds %= 60 - self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) + self.audio_time_label.setText(u' %02d:%02d ' % (minutes, seconds)) def onTrackTriggered(self): """ Start playing a track """ action = self.sender() - self.display.audioPlayer.goTo(action.data()) + self.display.audioPlayer.go_to(action.data()) def _get_plugin_manager(self): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f2973f2cf..5943dfa19 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -253,8 +253,8 @@ class ThemeManager(QtGui.QWidget): self.cloneThemeData(old_theme_data, new_theme_name) self.delete_theme(old_theme_name) for plugin in self.plugin_manager.plugins: - if plugin.usesTheme(old_theme_name): - plugin.renameTheme(old_theme_name, new_theme_name) + if plugin.uses_theme(old_theme_name): + plugin.rename_theme(old_theme_name, new_theme_name) self.renderer.update_theme(new_theme_name, old_theme_name) self.load_themes() @@ -280,8 +280,7 @@ class ThemeManager(QtGui.QWidget): save_to = None save_from = None if theme_data.background_type == u'image': - save_to = os.path.join(self.path, new_theme_name, - os.path.split(unicode(theme_data.background_filename))[1]) + save_to = os.path.join(self.path, new_theme_name, os.path.split(unicode(theme_data.background_filename))[1]) save_from = theme_data.background_filename theme_data.theme_name = new_theme_name theme_data.extend_image_filename(self.path) @@ -407,7 +406,7 @@ class ThemeManager(QtGui.QWidget): theme_file = os.path.join(self.path, theme_file) self.unzip_theme(theme_file, self.path) delete_file(theme_file) - files = AppLocation.get_files(self.settingsSection, u'.otz') + files = AppLocation.get_files(self.settingsSection, u'.png') # No themes have been found so create one if not files: theme = ThemeXML() @@ -748,7 +747,7 @@ class ThemeManager(QtGui.QWidget): # check for use in the system else where. if testPlugin: for plugin in self.plugin_manager.plugins: - if plugin.usesTheme(theme): + if plugin.uses_theme(theme): critical_error_message_box(translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'Theme %s is used in the %s plugin.') % (theme, plugin.name)) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index ebab5e6e1..3dfc32257 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -185,7 +185,7 @@ class AlertsPlugin(Plugin): '
The alert plugin controls the displaying of nursery alerts on the display screen.') return about_text - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 8fcbaebc1..dcf3bc1b3 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -164,7 +164,7 @@ class BiblePlugin(Plugin): 'verses from different sources during the service.') return about_text - def usesTheme(self, theme): + def uses_theme(self, theme): """ Called to find out if the bible plugin is currently using a theme. Returns ``True`` if the theme is being used, otherwise returns @@ -172,7 +172,7 @@ class BiblePlugin(Plugin): """ return unicode(self.settingsTab.bible_theme) == theme - def renameTheme(self, oldTheme, newTheme): + def rename_theme(self, oldTheme, newTheme): """ Rename the theme the bible plugin is using making the plugin use the new name. @@ -187,7 +187,7 @@ class BiblePlugin(Plugin): self.settingsTab.bible_theme = newTheme self.settingsTab.save() - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index d80b8929d..9cf43dc37 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -73,7 +73,7 @@ class CustomPlugin(Plugin): 'the same way songs are. This plugin provides greater freedom over the songs plugin.') return about_text - def usesTheme(self, theme): + def uses_theme(self, theme): """ Called to find out if the custom plugin is currently using a theme. @@ -83,7 +83,7 @@ class CustomPlugin(Plugin): return True return False - def renameTheme(self, oldTheme, newTheme): + def rename_theme(self, oldTheme, newTheme): """ Renames a theme the custom plugin is using making the plugin use the new name. @@ -94,12 +94,12 @@ class CustomPlugin(Plugin): ``newTheme`` The new name the plugin should now use. """ - customsUsingTheme = self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == oldTheme) - for custom in customsUsingTheme: + customs_using_theme = self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == oldTheme) + for custom in customs_using_theme: custom.theme_name = newTheme self.manager.save_object(custom) - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 1972228d2..3a73dab18 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -32,84 +32,86 @@ from PyQt4 import QtGui from openlp.core.lib import UiStrings, build_icon, translate from openlp.core.lib.ui import create_button_box, create_button -class Ui_CustomEditDialog(object): - def setupUi(self, customEditDialog): - customEditDialog.setObjectName(u'customEditDialog') - customEditDialog.resize(450, 350) - customEditDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) - self.dialogLayout = QtGui.QVBoxLayout(customEditDialog) - self.dialogLayout.setObjectName(u'dialog_layout') - self.titleLayout = QtGui.QHBoxLayout() - self.titleLayout.setObjectName(u'titleLayout') - self.titleLabel = QtGui.QLabel(customEditDialog) - self.titleLabel.setObjectName(u'titleLabel') - self.titleLayout.addWidget(self.titleLabel) - self.titleEdit = QtGui.QLineEdit(customEditDialog) - self.titleLabel.setBuddy(self.titleEdit) - self.titleEdit.setObjectName(u'titleEdit') - self.titleLayout.addWidget(self.titleEdit) - self.dialogLayout.addLayout(self.titleLayout) - self.centralLayout = QtGui.QHBoxLayout() - self.centralLayout.setObjectName(u'centralLayout') - self.slideListView = QtGui.QListWidget(customEditDialog) - self.slideListView.setAlternatingRowColors(True) - self.slideListView.setObjectName(u'slideListView') - self.centralLayout.addWidget(self.slideListView) - self.buttonLayout = QtGui.QVBoxLayout() - self.buttonLayout.setObjectName(u'buttonLayout') - self.addButton = QtGui.QPushButton(customEditDialog) - self.addButton.setObjectName(u'addButton') - self.buttonLayout.addWidget(self.addButton) - self.editButton = QtGui.QPushButton(customEditDialog) - self.editButton.setEnabled(False) - self.editButton.setObjectName(u'editButton') - self.buttonLayout.addWidget(self.editButton) - self.editAllButton = QtGui.QPushButton(customEditDialog) - self.editAllButton.setObjectName(u'editAllButton') - self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = create_button(customEditDialog, u'deleteButton', role=u'delete', - click=customEditDialog.onDeleteButtonClicked) - self.deleteButton.setEnabled(False) - self.buttonLayout.addWidget(self.deleteButton) - self.buttonLayout.addStretch() - self.upButton = create_button(customEditDialog, u'upButton', role=u'up', enabled=False, - click=customEditDialog.onUpButtonClicked) - self.downButton = create_button(customEditDialog, u'downButton', role=u'down', enabled=False, - click=customEditDialog.onDownButtonClicked) - self.buttonLayout.addWidget(self.upButton) - self.buttonLayout.addWidget(self.downButton) - self.centralLayout.addLayout(self.buttonLayout) - self.dialogLayout.addLayout(self.centralLayout) - self.bottomFormLayout = QtGui.QFormLayout() - self.bottomFormLayout.setObjectName(u'bottomFormLayout') - self.themeLabel = QtGui.QLabel(customEditDialog) - self.themeLabel.setObjectName(u'themeLabel') - self.themeComboBox = QtGui.QComboBox(customEditDialog) - self.themeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) - self.themeComboBox.setObjectName(u'themeComboBox') - self.themeLabel.setBuddy(self.themeComboBox) - self.bottomFormLayout.addRow(self.themeLabel, self.themeComboBox) - self.creditLabel = QtGui.QLabel(customEditDialog) - self.creditLabel.setObjectName(u'creditLabel') - self.creditEdit = QtGui.QLineEdit(customEditDialog) - self.creditEdit.setObjectName(u'creditEdit') - self.creditLabel.setBuddy(self.creditEdit) - self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) - self.dialogLayout.addLayout(self.bottomFormLayout) - self.previewButton = QtGui.QPushButton() - self.button_box = create_button_box(customEditDialog, u'button_box', [u'cancel', u'save'], [self.previewButton]) - self.dialogLayout.addWidget(self.button_box) - self.retranslateUi(customEditDialog) - def retranslateUi(self, customEditDialog): - customEditDialog.setWindowTitle(translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) - self.titleLabel.setText(translate('CustomPlugin.EditCustomForm', '&Title:')) - self.addButton.setText(UiStrings().Add) - self.addButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Add a new slide at bottom.')) - self.editButton.setText(UiStrings().Edit) - self.editButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit the selected slide.')) - self.editAllButton.setText(translate('CustomPlugin.EditCustomForm', 'Ed&it All')) - self.editAllButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit all the slides at once.')) - self.themeLabel.setText(translate('CustomPlugin.EditCustomForm', 'The&me:')) - self.creditLabel.setText(translate('CustomPlugin.EditCustomForm', '&Credits:')) - self.previewButton.setText(UiStrings().SaveAndPreview) +class Ui_CustomEditDialog(object): + def setupUi(self, custom_edit_dialog): + custom_edit_dialog.setObjectName(u'custom_edit_dialog') + custom_edit_dialog.resize(450, 350) + custom_edit_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) + self.dialog_layout = QtGui.QVBoxLayout(custom_edit_dialog) + self.dialog_layout.setObjectName(u'dialog_layout') + self.title_layout = QtGui.QHBoxLayout() + self.title_layout.setObjectName(u'title_layout') + self.title_label = QtGui.QLabel(custom_edit_dialog) + self.title_label.setObjectName(u'title_label') + self.title_layout.addWidget(self.title_label) + self.title_edit = QtGui.QLineEdit(custom_edit_dialog) + self.title_label.setBuddy(self.title_edit) + self.title_edit.setObjectName(u'title_edit') + self.title_layout.addWidget(self.title_edit) + self.dialog_layout.addLayout(self.title_layout) + self.central_layout = QtGui.QHBoxLayout() + self.central_layout.setObjectName(u'central_layout') + self.slide_list_view = QtGui.QListWidget(custom_edit_dialog) + self.slide_list_view.setAlternatingRowColors(True) + self.slide_list_view.setObjectName(u'slide_list_view') + self.central_layout.addWidget(self.slide_list_view) + self.button_layout = QtGui.QVBoxLayout() + self.button_layout.setObjectName(u'button_layout') + self.add_button = QtGui.QPushButton(custom_edit_dialog) + self.add_button.setObjectName(u'add_button') + self.button_layout.addWidget(self.add_button) + self.edit_button = QtGui.QPushButton(custom_edit_dialog) + self.edit_button.setEnabled(False) + self.edit_button.setObjectName(u'edit_button') + self.button_layout.addWidget(self.edit_button) + self.edit_all_button = QtGui.QPushButton(custom_edit_dialog) + self.edit_all_button.setObjectName(u'edit_all_button') + self.button_layout.addWidget(self.edit_all_button) + self.delete_button = create_button(custom_edit_dialog, u'delete_button', role=u'delete', + click=custom_edit_dialog.on_delete_button_clicked) + self.delete_button.setEnabled(False) + self.button_layout.addWidget(self.delete_button) + self.button_layout.addStretch() + self.up_button = create_button(custom_edit_dialog, u'up_button', role=u'up', enabled=False, + click=custom_edit_dialog.on_up_button_clicked) + self.down_button = create_button(custom_edit_dialog, u'down_button', role=u'down', enabled=False, + click=custom_edit_dialog.on_down_button_clicked) + self.button_layout.addWidget(self.up_button) + self.button_layout.addWidget(self.down_button) + self.central_layout.addLayout(self.button_layout) + self.dialog_layout.addLayout(self.central_layout) + self.bottom_form_layout = QtGui.QFormLayout() + self.bottom_form_layout.setObjectName(u'bottom_form_layout') + self.theme_label = QtGui.QLabel(custom_edit_dialog) + self.theme_label.setObjectName(u'theme_label') + self.theme_combo_box = QtGui.QComboBox(custom_edit_dialog) + self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.theme_combo_box.setObjectName(u'theme_combo_box') + self.theme_label.setBuddy(self.theme_combo_box) + self.bottom_form_layout.addRow(self.theme_label, self.theme_combo_box) + self.credit_label = QtGui.QLabel(custom_edit_dialog) + self.credit_label.setObjectName(u'credit_label') + self.credit_edit = QtGui.QLineEdit(custom_edit_dialog) + self.credit_edit.setObjectName(u'credit_edit') + self.credit_label.setBuddy(self.credit_edit) + self.bottom_form_layout.addRow(self.credit_label, self.credit_edit) + self.dialog_layout.addLayout(self.bottom_form_layout) + self.preview_button = QtGui.QPushButton() + self.button_box = create_button_box(custom_edit_dialog, u'button_box', [u'cancel', u'save'], + [self.preview_button]) + self.dialog_layout.addWidget(self.button_box) + self.retranslateUi(custom_edit_dialog) + + def retranslateUi(self, custom_edit_dialog): + custom_edit_dialog.setWindowTitle(translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) + self.title_label.setText(translate('CustomPlugin.EditCustomForm', '&Title:')) + self.add_button.setText(UiStrings().Add) + self.add_button.setToolTip(translate('CustomPlugin.EditCustomForm', 'Add a new slide at bottom.')) + self.edit_button.setText(UiStrings().Edit) + self.edit_button.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit the selected slide.')) + self.edit_all_button.setText(translate('CustomPlugin.EditCustomForm', 'Ed&it All')) + self.edit_all_button.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit all the slides at once.')) + self.theme_label.setText(translate('CustomPlugin.EditCustomForm', 'The&me:')) + self.credit_label.setText(translate('CustomPlugin.EditCustomForm', '&Credits:')) + self.preview_button.setText(UiStrings().SaveAndPreview) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index cea17da5f..135535a8f 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -29,7 +29,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import Registry, translate from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box @@ -56,14 +56,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.mediaitem = mediaitem self.setupUi(self) # Create other objects and forms. - self.editSlideForm = EditCustomSlideForm(self) + self.edit_slide_form = EditCustomSlideForm(self) # Connecting signals and slots - self.previewButton.clicked.connect(self.on_preview_button_clicked) - self.addButton.clicked.connect(self.on_add_button_clicked) - self.editButton.clicked.connect(self.on_edit_button_clicked) - self.editAllButton.clicked.connect(self.on_edit_all_button_clicked) - self.slideListView.currentRowChanged.connect(self.on_current_row_changed) - self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) + self.preview_button.clicked.connect(self.on_preview_button_clicked) + self.add_button.clicked.connect(self.on_add_button_clicked) + self.edit_button.clicked.connect(self.on_edit_button_clicked) + self.edit_all_button.clicked.connect(self.on_edit_all_button_clicked) + self.slide_list_view.currentRowChanged.connect(self.on_current_row_changed) + self.slide_list_view.doubleClicked.connect(self.on_edit_button_clicked) Registry().register_function(u'theme_update_list', self.load_themes) def load_themes(self, theme_list): @@ -73,11 +73,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): ``theme_list`` The list of themes to load. """ - self.themeComboBox.clear() - self.themeComboBox.addItem(u'') - self.themeComboBox.addItems(theme_list) + self.theme_combo_box.clear() + self.theme_combo_box.addItem(u'') + self.theme_combo_box.addItems(theme_list) - def loadCustom(self, id, preview=False): + def load_custom(self, id, preview=False): """ Called when editing or creating a new custom. @@ -88,111 +88,111 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): States whether the custom is edited while being previewed in the preview panel. """ - self.slideListView.clear() + self.slide_list_view.clear() if id == 0: - self.customSlide = CustomSlide() - self.titleEdit.setText(u'') - self.creditEdit.setText(u'') - self.themeComboBox.setCurrentIndex(0) + self.custom_slide = CustomSlide() + self.title_edit.set_text(u'') + self.credit_edit.set_text(u'') + self.theme_combo_box.setCurrentIndex(0) else: - self.customSlide = self.manager.get_object(CustomSlide, id) - self.titleEdit.setText(self.customSlide.title) - self.creditEdit.setText(self.customSlide.credits) - customXML = CustomXMLParser(self.customSlide.text) - slideList = customXML.get_verses() - for slide in slideList: - self.slideListView.addItem(slide[1]) - theme = self.customSlide.theme_name - find_and_set_in_combo_box(self.themeComboBox, theme) - self.titleEdit.setFocus() + self.custom_slide = self.manager.get_object(CustomSlide, id) + self.title_edit.setText(self.custom_slide.title) + self.credit_edit.setText(self.custom_slide.credits) + custom_XML = CustomXMLParser(self.custom_slide.text) + slide_list = custom_XML.get_verses() + for slide in slide_list: + self.slide_list_view.addItem(slide[1]) + theme = self.custom_slide.theme_name + find_and_set_in_combo_box(self.theme_combo_box, theme) + self.title_edit.setFocus() # If not preview hide the preview button. - self.previewButton.setVisible(preview) + self.preview_button.setVisible(preview) def accept(self): """ Override the QDialog method to check if the custom slide has been saved before closing the dialog. """ log.debug(u'accept') - if self.saveCustom(): + if self.save_custom(): QtGui.QDialog.accept(self) - def saveCustom(self): + def save_custom(self): """ Saves the custom. """ if not self._validate(): return False sxml = CustomXMLBuilder() - for count in range(self.slideListView.count()): - sxml.add_verse_to_lyrics(u'custom', unicode(count + 1), self.slideListView.item(count).text()) - self.customSlide.title = self.titleEdit.text() - self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8') - self.customSlide.credits = self.creditEdit.text() - self.customSlide.theme_name = self.themeComboBox.currentText() - success = self.manager.save_object(self.customSlide) - self.mediaitem.autoSelectId = self.customSlide.id + for count in range(self.slide_list_view.count()): + sxml.add_verse_to_lyrics(u'custom', unicode(count + 1), self.slide_list_view.item(count).text()) + self.custom_slide.title = self.title_edit.text() + self.custom_slide.text = unicode(sxml.extract_xml(), u'utf-8') + self.custom_slide.credits = self.credit_edit.text() + self.custom_slide.theme_name = self.theme_combo_box.currentText() + success = self.manager.save_object(self.custom_slide) + self.mediaitem.autoSelectId = self.custom_slide.id return success - def onUpButtonClicked(self): + def on_up_button_clicked(self): """ Move a slide up in the list when the "Up" button is clicked. """ - selectedRow = self.slideListView.currentRow() + selectedRow = self.slide_list_view.currentRow() if selectedRow != 0: - qw = self.slideListView.takeItem(selectedRow) - self.slideListView.insertItem(selectedRow - 1, qw) - self.slideListView.setCurrentRow(selectedRow - 1) + qw = self.slide_list_view.takeItem(selectedRow) + self.slide_list_view.insertItem(selectedRow - 1, qw) + self.slide_list_view.setCurrentRow(selectedRow - 1) - def onDownButtonClicked(self): + def on_down_button_clicked(self): """ Move a slide down in the list when the "Down" button is clicked. """ - selectedRow = self.slideListView.currentRow() + selectedRow = self.slide_list_view.currentRow() # zero base arrays - if selectedRow != self.slideListView.count() - 1: - qw = self.slideListView.takeItem(selectedRow) - self.slideListView.insertItem(selectedRow + 1, qw) - self.slideListView.setCurrentRow(selectedRow + 1) + if selectedRow != self.slide_list_view.count() - 1: + qw = self.slide_list_view.takeItem(selectedRow) + self.slide_list_view.insertItem(selectedRow + 1, qw) + self.slide_list_view.setCurrentRow(selectedRow + 1) def on_add_button_clicked(self): """ Add a new blank slide. """ - self.editSlideForm.setText(u'') - if self.editSlideForm.exec_(): - self.slideListView.addItems(self.editSlideForm.getText()) + self.edit_slide_form.set_text(u'') + if self.edit_slide_form.exec_(): + self.slide_list_view.addItems(self.edit_slide_form.get_text()) def on_edit_button_clicked(self): """ Edit the currently selected slide. """ - self.editSlideForm.setText(self.slideListView.currentItem().text()) - if self.editSlideForm.exec_(): - self.updateSlideList(self.editSlideForm.getText()) + self.edit_slide_form.set_text(self.slide_list_view.currentItem().text()) + if self.edit_slide_form.exec_(): + self.update_slide_list(self.edit_slide_form.get_text()) def on_edit_all_button_clicked(self): """ Edits all slides. """ slide_text = u'' - for row in range(self.slideListView.count()): - item = self.slideListView.item(row) + for row in range(self.slide_list_view.count()): + item = self.slide_list_view.item(row) slide_text += item.text() - if row != self.slideListView.count() - 1: + if row != self.slide_list_view.count() - 1: slide_text += u'\n[===]\n' - self.editSlideForm.setText(slide_text) - if self.editSlideForm.exec_(): - self.updateSlideList(self.editSlideForm.getText(), True) + self.edit_slide_form.set_text(slide_text) + if self.edit_slide_form.exec_(): + self.update_slide_list(self.edit_slide_form.get_text(), True) def on_preview_button_clicked(self): """ Save the custom item and preview it. """ log.debug(u'onPreview') - if self.saveCustom(): + if self.save_custom(): Registry().execute(u'custom_preview') - def updateSlideList(self, slides, edit_all=False): + def update_slide_list(self, slides, edit_all=False): """ Updates the slide list after editing slides. @@ -203,60 +203,59 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Indicates if all slides or only one slide has been edited. """ if edit_all: - self.slideListView.clear() - self.slideListView.addItems(slides) + self.slide_list_view.clear() + self.slide_list_view.addItems(slides) else: old_slides = [] - old_row = self.slideListView.currentRow() + old_row = self.slide_list_view.currentRow() # Create a list with all (old/unedited) slides. - old_slides = [self.slideListView.item(row).text() for row in - range(self.slideListView.count())] - self.slideListView.clear() + old_slides = [self.slide_list_view.item(row).text() for row in range(self.slide_list_view.count())] + self.slide_list_view.clear() old_slides.pop(old_row) # Insert all slides to make the old_slides list complete. for slide in slides: old_slides.insert(old_row, slide) - self.slideListView.addItems(old_slides) - self.slideListView.repaint() + self.slide_list_view.addItems(old_slides) + self.slide_list_view.repaint() - def onDeleteButtonClicked(self): + def on_delete_button_clicked(self): """ Removes the current row from the list. """ - self.slideListView.takeItem(self.slideListView.currentRow()) - self.on_current_row_changed(self.slideListView.currentRow()) + self.slide_list_view.takeItem(self.slide_list_view.currentRow()) + self.on_current_row_changed(self.slide_list_view.currentRow()) def on_current_row_changed(self, row): """ - Called when the *slideListView*'s current row has been changed. This + Called when the *slide_list_view*'s current row has been changed. This enables or disables buttons which require an slide to act on. ``row`` The row (int). If there is no current row, the value is -1. """ if row == -1: - self.deleteButton.setEnabled(False) - self.editButton.setEnabled(False) - self.upButton.setEnabled(False) - self.downButton.setEnabled(False) + self.delete_button.setEnabled(False) + self.edit_button.setEnabled(False) + self.up_button.setEnabled(False) + self.down_button.setEnabled(False) else: - self.deleteButton.setEnabled(True) - self.editButton.setEnabled(True) + self.delete_button.setEnabled(True) + self.edit_button.setEnabled(True) # Decide if the up/down buttons should be enabled or not. - self.downButton.setEnabled(self.slideListView.count() - 1 != row) - self.upButton.setEnabled(row != 0) + self.down_button.setEnabled(self.slide_list_view.count() - 1 != row) + self.up_button.setEnabled(row != 0) def _validate(self): """ Checks whether a custom is valid or not. """ # We must have a title. - if not self.titleEdit.displayText(): - self.titleEdit.setFocus() + if not self.title_edit.displayText(): + self.title_edit.setFocus() critical_error_message_box(message=translate('CustomPlugin.EditCustomForm', 'You need to type in a title.')) return False # We must have at least one slide. - if self.slideListView.count() == 0: + if self.slide_list_view.count() == 0: critical_error_message_box(message=translate('CustomPlugin.EditCustomForm', 'You need to add at least one slide')) return False diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 972759e7c..0551d5792 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -33,24 +33,25 @@ from openlp.core.lib import SpellTextEdit, UiStrings, translate from openlp.core.lib.ui import create_button, create_button_box class Ui_CustomSlideEditDialog(object): - def setupUi(self, customSlideEditDialog): - customSlideEditDialog.setObjectName(u'customSlideEditDialog') - customSlideEditDialog.resize(350, 300) - self.dialogLayout = QtGui.QVBoxLayout(customSlideEditDialog) - self.slideTextEdit = SpellTextEdit(self) - self.slideTextEdit.setObjectName(u'slideTextEdit') - self.dialogLayout.addWidget(self.slideTextEdit) - self.splitButton = create_button(customSlideEditDialog, u'splitButton', icon=u':/general/general_add.png') - self.insertButton = create_button(customSlideEditDialog, u'insertButton', icon=u':/general/general_add.png') - self.button_box = create_button_box(customSlideEditDialog, u'button_box', [u'cancel', u'save'], - [self.splitButton, self.insertButton]) - self.dialogLayout.addWidget(self.button_box) - self.retranslateUi(customSlideEditDialog) + def setupUi(self, custom_slide_edit_dialog): + custom_slide_edit_dialog.setObjectName(u'custom_slide_edit_dialog') + custom_slide_edit_dialog.resize(350, 300) + self.dialog_layout = QtGui.QVBoxLayout(custom_slide_edit_dialog) + self.slide_text_edit = SpellTextEdit(self) + self.slide_text_edit.setObjectName(u'slide_text_edit') + self.dialog_layout.addWidget(self.slide_text_edit) + self.split_button = create_button(custom_slide_edit_dialog, u'splitButton', icon=u':/general/general_add.png') + self.insert_button = create_button(custom_slide_edit_dialog, u'insertButton', + icon=u':/general/general_add.png') + self.button_box = create_button_box(custom_slide_edit_dialog, u'button_box', [u'cancel', u'save'], + [self.split_button, self.insert_button]) + self.dialog_layout.addWidget(self.button_box) + self.retranslateUi(custom_slide_edit_dialog) - def retranslateUi(self, customSlideEditDialog): - customSlideEditDialog.setWindowTitle(translate('CustomPlugin.EditVerseForm', 'Edit Slide')) - self.splitButton.setText(UiStrings().Split) - self.splitButton.setToolTip(UiStrings().SplitToolTip) - self.insertButton.setText(translate('CustomPlugin.EditCustomForm', 'Insert Slide')) - self.insertButton.setToolTip(translate('CustomPlugin.EditCustomForm', + def retranslateUi(self, custom_slide_edit_dialog): + custom_slide_edit_dialog.setWindowTitle(translate('CustomPlugin.EditVerseForm', 'Edit Slide')) + self.split_button.setText(UiStrings().Split) + self.split_button.setToolTip(UiStrings().SplitToolTip) + self.insert_button.setText(translate('CustomPlugin.EditCustomForm', 'Insert Slide')) + self.insert_button.setToolTip(translate('CustomPlugin.EditCustomForm', 'Split a slide into two by inserting a slide splitter.')) diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index 7e489317a..3ad6341b7 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -50,51 +50,49 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): super(EditCustomSlideForm, self).__init__(parent) self.setupUi(self) # Connecting signals and slots - QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked) - QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked) + self.insert_button.clicked.connect(self.on_insert_button_clicked) + self.split_button.clicked.connect(self.on_split_button_clicked) - def setText(self, text): + def set_text(self, text): """ - Set the text for slideTextEdit. + Set the text for slide_text_edit. ``text`` The text (unicode). """ - self.slideTextEdit.clear() + self.slide_text_edit.clear() if text: - self.slideTextEdit.setPlainText(text) - self.slideTextEdit.setFocus() + self.slide_text_edit.setPlainText(text) + self.slide_text_edit.setFocus() - def getText(self): + def get_text(self): """ Returns a list with all slides. """ - return self.slideTextEdit.toPlainText().split(u'\n[===]\n') + return self.slide_text_edit.toPlainText().split(u'\n[===]\n') - def onInsertButtonClicked(self): + def on_insert_button_clicked(self): """ Adds a slide split at the cursor. """ - self.insertSingleLineTextAtCursor(u'[===]') - self.slideTextEdit.setFocus() + self.insert_single_line_text_at_cursor(u'[===]') + self.slide_text_edit.setFocus() - def onSplitButtonClicked(self): + def on_split_button_clicked(self): """ Adds an optional split at cursor. """ - self.insertSingleLineTextAtCursor(u'[---]') - self.slideTextEdit.setFocus() + self.insert_single_line_text_at_cursor(u'[---]') + self.slide_text_edit.setFocus() - def insertSingleLineTextAtCursor(self, text): + def insert_single_line_text_at_cursor(self, text): """ Adds ``text`` in a single line at the cursor position. """ - full_text = self.slideTextEdit.toPlainText() - position = self.slideTextEdit.textCursor().position() + full_text = self.slide_text_edit.toPlainText() + position = self.slide_text_edit.textCursor().position() if position and full_text[position - 1] != u'\n': text = u'\n' + text if position == len(full_text) or full_text[position] != u'\n': text += u'\n' - self.slideTextEdit.insertPlainText(text) - -#lint:enable + self.slide_text_edit.insertPlainText(text) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index ba57a6fc2..696de25e3 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -45,38 +45,36 @@ class CustomTab(SettingsTab): def setupUi(self): self.setObjectName(u'CustomTab') SettingsTab.setupUi(self) - self.customModeGroupBox = QtGui.QGroupBox(self.leftColumn) - self.customModeGroupBox.setObjectName(u'customModeGroupBox') - self.customModeLayout = QtGui.QFormLayout(self.customModeGroupBox) - self.customModeLayout.setObjectName(u'customModeLayout') - self.displayFooterCheckBox = QtGui.QCheckBox(self.customModeGroupBox) - self.displayFooterCheckBox.setObjectName(u'displayFooterCheckBox') - self.customModeLayout.addRow(self.displayFooterCheckBox) - self.add_from_service_checkbox = QtGui.QCheckBox(self.customModeGroupBox) + self.custom_mode_group_box = QtGui.QGroupBox(self.leftColumn) + self.custom_mode_group_box.setObjectName(u'custom_mode_group_box') + self.custom_mode_layout = QtGui.QFormLayout(self.custom_mode_group_box) + self.custom_mode_layout.setObjectName(u'custom_mode_layout') + self.display_footer_check_box = QtGui.QCheckBox(self.custom_mode_group_box) + self.display_footer_check_box.setObjectName(u'display_footer_check_box') + self.custom_mode_layout.addRow(self.display_footer_check_box) + self.add_from_service_checkbox = QtGui.QCheckBox(self.custom_mode_group_box) self.add_from_service_checkbox.setObjectName(u'add_from_service_checkbox') - self.customModeLayout.addRow(self.add_from_service_checkbox) - self.leftLayout.addWidget(self.customModeGroupBox) + self.custom_mode_layout.addRow(self.add_from_service_checkbox) + self.leftLayout.addWidget(self.custom_mode_group_box) self.leftLayout.addStretch() self.rightLayout.addStretch() - QtCore.QObject.connect(self.displayFooterCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onDisplayFooterCheckBoxChanged) - QtCore.QObject.connect(self.add_from_service_checkbox, QtCore.SIGNAL(u'stateChanged(int)'), - self.on_add_from_service_check_box_changed) + self.display_footer_check_box.stateChanged.connect(self.on_display_footer_check_box_changed) + self.add_from_service_checkbox.stateChanged.connect(self.on_add_from_service_check_box_changed) def retranslateUi(self): - self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab', 'Custom Display')) - self.displayFooterCheckBox.setText(translate('CustomPlugin.CustomTab', 'Display footer')) + self.custom_mode_group_box.setTitle(translate('CustomPlugin.CustomTab', 'Custom Display')) + self.display_footer_check_box.setText(translate('CustomPlugin.CustomTab', 'Display footer')) self.add_from_service_checkbox.setText(translate('CustomPlugin.CustomTab', 'Import missing custom slides from service files')) - def onDisplayFooterCheckBoxChanged(self, check_state): + def on_display_footer_check_box_changed(self, check_state): """ Toggle the setting for displaying the footer. """ - self.displayFooter = False + self.display_footer = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: - self.displayFooter = True + self.display_footer = True def on_add_from_service_check_box_changed(self, check_state): self.update_load = (check_state == QtCore.Qt.Checked) @@ -84,15 +82,15 @@ class CustomTab(SettingsTab): def load(self): settings = Settings() settings.beginGroup(self.settingsSection) - self.displayFooter = settings.value(u'display footer') + self.display_footer = settings.value(u'display footer') self.update_load = settings.value(u'add custom from service') - self.displayFooterCheckBox.setChecked(self.displayFooter) + self.display_footer_check_box.setChecked(self.display_footer) self.add_from_service_checkbox.setChecked(self.update_load) settings.endGroup() def save(self): settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'display footer', self.displayFooter) + settings.setValue(u'display footer', self.display_footer) settings.setValue(u'add custom from service', self.update_load) settings.endGroup() diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index b5e46ccf1..a49ceb76e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -114,7 +114,7 @@ class CustomMediaItem(MediaManagerItem): # active trigger it and clean up so it will not update again. def onNewClick(self): - self.edit_custom_form.loadCustom(0) + self.edit_custom_form.load_custom(0) self.edit_custom_form.exec_() self.onClearTextButtonClick() self.onSelectionChange() @@ -128,7 +128,7 @@ class CustomMediaItem(MediaManagerItem): custom_id = int(custom_id) valid = self.manager.get_object(CustomSlide, custom_id) if valid: - self.edit_custom_form.loadCustom(custom_id, preview) + self.edit_custom_form.load_custom(custom_id, preview) if self.edit_custom_form.exec_() == QtGui.QDialog.Accepted: self.remoteTriggered = True self.remoteCustom = custom_id @@ -148,7 +148,7 @@ class CustomMediaItem(MediaManagerItem): if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() item_id = item.data(QtCore.Qt.UserRole) - self.edit_custom_form.loadCustom(item_id, False) + self.edit_custom_form.load_custom(item_id, False) self.edit_custom_form.exec_() self.autoSelectId = -1 self.onSearchTextButtonClicked() diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 250fd485a..380d3823d 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -89,7 +89,7 @@ class ImagePlugin(Plugin): log.debug(u'Importing images list from old config: %s' % files_from_config) self.mediaItem.save_new_images_list(files_from_config) - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index f42d042c7..fd06a1f9a 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -561,7 +561,7 @@ class ImageMediaItem(MediaManagerItem): Called to reset the Live background with the image selected, """ self.resetAction.setVisible(False) - self.live_controller.display.resetImage() + self.live_controller.display.reset_image() def live_theme_changed(self): """ @@ -582,7 +582,7 @@ class ImageMediaItem(MediaManagerItem): return filename = bitem.data(0, QtCore.Qt.UserRole).filename if os.path.exists(filename): - if self.live_controller.display.directImage(filename, background): + if self.live_controller.display.direct_image(filename, background): self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index c9584652e..306ab54ea 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -61,16 +61,16 @@ class MediaMediaItem(MediaManagerItem): self.singleServiceItem = False self.hasSearch = True self.mediaObject = None - self.displayController = DisplayController(parent) - self.displayController.controllerLayout = QtGui.QVBoxLayout() - self.media_controller.register_controller(self.displayController) - self.media_controller.set_controls_visible(self.displayController, False) - self.displayController.previewDisplay = Display(self.displayController, False, self.displayController) - self.displayController.previewDisplay.hide() - self.displayController.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300)) - self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()} - self.displayController.previewDisplay.setup() - self.media_controller.setup_display(self.displayController.previewDisplay, False) + self.display_controller = DisplayController(parent) + self.display_controller.controller_layout = QtGui.QVBoxLayout() + self.media_controller.register_controller(self.display_controller) + self.media_controller.set_controls_visible(self.display_controller, False) + self.display_controller.preview_display = Display(self.display_controller, False, self.display_controller) + self.display_controller.preview_display.hide() + self.display_controller.preview_display.setGeometry(QtCore.QRect(0, 0, 300, 300)) + self.display_controller.preview_display.screen = {u'size': self.display_controller.preview_display.geometry()} + self.display_controller.preview_display.setup() + self.media_controller.setup_display(self.display_controller.preview_display, False) Registry().register_function(u'video_background_replaced', self.video_background_replaced) Registry().register_function(u'mediaitem_media_rebuild', self.rebuild_players) Registry().register_function(u'config_screen_changed', self.display_setup) @@ -214,7 +214,7 @@ class MediaMediaItem(MediaManagerItem): u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles) def display_setup(self): - self.media_controller.setup_display(self.displayController.previewDisplay, False) + self.media_controller.setup_display(self.display_controller.previewDisplay, False) def populateDisplayTypes(self): """ @@ -226,11 +226,11 @@ class MediaMediaItem(MediaManagerItem): self.displayTypeComboBox.blockSignals(True) self.displayTypeComboBox.clear() usedPlayers, overridePlayer = get_media_players() - mediaPlayers = self.media_controller.mediaPlayers + media_players = self.media_controller.media_players currentIndex = 0 for player in usedPlayers: # load the drop down selection - self.displayTypeComboBox.addItem(mediaPlayers[player].original_name) + self.displayTypeComboBox.addItem(media_players[player].original_name) if overridePlayer == player: currentIndex = len(self.displayTypeComboBox) if self.displayTypeComboBox.count() > 1: diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index bb463b857..f1f98423a 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -66,7 +66,7 @@ class MediaPlugin(Plugin): '
The media plugin provides playback of audio and video.') return about_text - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index fb4e9f446..d9df64f6d 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -156,7 +156,7 @@ class PresentationPlugin(Plugin): 'available to the user in a drop down box.') return about_text - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 77aae2f87..22172e6e8 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -129,6 +129,7 @@ from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) + class HttpResponse(object): """ A simple object to encapsulate a pseudo-http response. @@ -178,7 +179,7 @@ class HttpServer(object): self.server.listen(QtNetwork.QHostAddress(address), port) Registry().register_function(u'slidecontroller_live_changed', self.slide_change) Registry().register_function(u'slidecontroller_live_started', self.item_change) - QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection) + self.server.newConnection.connect(self.new_connection) log.debug(u'TCP listening on port %d' % port) def slide_change(self, row): @@ -245,8 +246,8 @@ class HttpConnection(object): (r'^/api/(.*)/live$', self.go_live), (r'^/api/(.*)/add$', self.add_to_service) ] - QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'), self.ready_read) - QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), self.disconnected) + self.socket.readyRead.connect(self.ready_read) + self.socket.disconnected.connect(self.disconnected) self.translate() def _get_service_items(self): @@ -389,13 +390,12 @@ class HttpConnection(object): u'service': self.service_manager.service_id, u'slide': self.parent.current_slide or 0, u'item': self.parent.current_item.unique_identifier if self.parent.current_item else u'', - u'twelve':Settings().value(u'remotes/twelve hour'), - u'blank': self.live_controller.blankScreen.isChecked(), - u'theme': self.live_controller.themeScreen.isChecked(), - u'display': self.live_controller.desktopScreen.isChecked() + u'twelve': Settings().value(u'remotes/twelve hour'), + u'blank': self.live_controller.blank_screen.isChecked(), + u'theme': self.live_controller.theme_screen.isChecked(), + u'display': self.live_controller.desktop_screen.isChecked() } - return HttpResponse(json.dumps({u'results': result}), - {u'Content-Type': u'application/json'}) + return HttpResponse(json.dumps({u'results': result}), {u'Content-Type': u'application/json'}) def display(self, action): """ @@ -426,18 +426,17 @@ class HttpConnection(object): return HttpResponse(json.dumps({u'results': {u'success': success}}), {u'Content-Type': u'application/json'}) - def controller(self, type, action): + def controller(self, display_type, action): """ Perform an action on the slide controller. - ``type`` - This is the type of slide controller, either ``preview`` or - ``live``. + ``display_type`` + This is the type of slide controller, either ``preview`` or ``live``. ``action`` The action to perform. """ - event = u'slidecontroller_%s_%s' % (type, action) + event = u'slidecontroller_%s_%s' % (display_type, action) if action == u'text': current_item = self.parent.current_item data = [] @@ -473,10 +472,15 @@ class HttpConnection(object): else: Registry().execute(event) json_data = {u'results': {u'success': True}} - return HttpResponse(json.dumps(json_data), - {u'Content-Type': u'application/json'}) + return HttpResponse(json.dumps(json_data), {u'Content-Type': u'application/json'}) def service(self, action): + """ + Handles requests for service items + + ``action`` + The action to perform. + """ event = u'servicemanager_%s' % action if action == u'list': return HttpResponse(json.dumps({u'results': {u'items': self._get_service_items()}}), @@ -491,8 +495,7 @@ class HttpConnection(object): Registry().execute(event, data[u'request'][u'id']) else: Registry().execute(event) - return HttpResponse(json.dumps({u'results': {u'success': True}}), - {u'Content-Type': u'application/json'}) + return HttpResponse(json.dumps({u'results': {u'success': True}}), {u'Content-Type': u'application/json'}) def pluginInfo(self, action): """ @@ -507,15 +510,13 @@ class HttpConnection(object): for plugin in self.plugin_manager.plugins: if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])]) - return HttpResponse( - json.dumps({u'results': {u'items': searches}}), - {u'Content-Type': u'application/json'}) + return HttpResponse(json.dumps({u'results': {u'items': searches}}), {u'Content-Type': u'application/json'}) - def search(self, type): + def search(self, plugin_name): """ Return a list of items that match the search text. - ``type`` + ``plugin`` The plugin name to search in. """ try: @@ -523,36 +524,35 @@ class HttpConnection(object): except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') text = urllib.unquote(text) - plugin = self.plugin_manager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(plugin_name) if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: results = plugin.mediaItem.search(text, False) else: results = [] - return HttpResponse(json.dumps({u'results': {u'items': results}}), - {u'Content-Type': u'application/json'}) + return HttpResponse(json.dumps({u'results': {u'items': results}}), {u'Content-Type': u'application/json'}) - def go_live(self, type): + def go_live(self, plugin_name): """ - Go live on an item of type ``type``. + Go live on an item of type ``plugin``. """ try: id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') - plugin = self.plugin_manager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(plugin_name) if plugin.status == PluginStatus.Active and plugin.mediaItem: plugin.mediaItem.goLive(id, remote=True) return HttpResponse(code=u'200 OK') - def add_to_service(self, type): + def add_to_service(self, plugin_name): """ - Add item of type ``type`` to the end of the service. + Add item of type ``plugin_name`` to the end of the service. """ try: id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') - plugin = self.plugin_manager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(plugin_name) if plugin.status == PluginStatus.Active and plugin.mediaItem: item_id = plugin.mediaItem.createItemFromId(id) plugin.mediaItem.addToService(item_id, remote=True) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 38b8753ab..bc8a1f308 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -45,117 +45,115 @@ class RemoteTab(SettingsTab): def setupUi(self): self.setObjectName(u'RemoteTab') SettingsTab.setupUi(self) - self.serverSettingsGroupBox = QtGui.QGroupBox(self.leftColumn) - self.serverSettingsGroupBox.setObjectName(u'serverSettingsGroupBox') - self.serverSettingsLayout = QtGui.QFormLayout(self.serverSettingsGroupBox) - self.serverSettingsLayout.setObjectName(u'serverSettingsLayout') - self.addressLabel = QtGui.QLabel(self.serverSettingsGroupBox) - self.addressLabel.setObjectName(u'addressLabel') - self.addressEdit = QtGui.QLineEdit(self.serverSettingsGroupBox) - self.addressEdit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - self.addressEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp( + self.server_settings_group_box = QtGui.QGroupBox(self.leftColumn) + self.server_settings_group_box.setObjectName(u'server_settings_group_box') + self.server_settings_layout = QtGui.QFormLayout(self.server_settings_group_box) + self.server_settings_layout.setObjectName(u'server_settings_layout') + self.address_label = QtGui.QLabel(self.server_settings_group_box) + self.address_label.setObjectName(u'address_label') + self.address_edit = QtGui.QLineEdit(self.server_settings_group_box) + self.address_edit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp( u'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self)) - self.addressEdit.setObjectName(u'addressEdit') - QtCore.QObject.connect(self.addressEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls) - self.serverSettingsLayout.addRow(self.addressLabel, self.addressEdit) - self.twelveHourCheckBox = QtGui.QCheckBox(self.serverSettingsGroupBox) - self.twelveHourCheckBox.setObjectName(u'twelveHourCheckBox') - self.serverSettingsLayout.addRow(self.twelveHourCheckBox) - self.portLabel = QtGui.QLabel(self.serverSettingsGroupBox) - self.portLabel.setObjectName(u'portLabel') - self.portSpinBox = QtGui.QSpinBox(self.serverSettingsGroupBox) - self.portSpinBox.setMaximum(32767) - self.portSpinBox.setObjectName(u'portSpinBox') - QtCore.QObject.connect(self.portSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.setUrls) - self.serverSettingsLayout.addRow(self.portLabel, self.portSpinBox) - self.remoteUrlLabel = QtGui.QLabel(self.serverSettingsGroupBox) - self.remoteUrlLabel.setObjectName(u'remoteUrlLabel') - self.remoteUrl = QtGui.QLabel(self.serverSettingsGroupBox) - self.remoteUrl.setObjectName(u'remoteUrl') - self.remoteUrl.setOpenExternalLinks(True) - self.serverSettingsLayout.addRow(self.remoteUrlLabel, self.remoteUrl) - self.stageUrlLabel = QtGui.QLabel(self.serverSettingsGroupBox) - self.stageUrlLabel.setObjectName(u'stageUrlLabel') - self.stageUrl = QtGui.QLabel(self.serverSettingsGroupBox) - self.stageUrl.setObjectName(u'stageUrl') - self.stageUrl.setOpenExternalLinks(True) - self.serverSettingsLayout.addRow(self.stageUrlLabel, self.stageUrl) - self.leftLayout.addWidget(self.serverSettingsGroupBox) - self.androidAppGroupBox = QtGui.QGroupBox(self.rightColumn) - self.androidAppGroupBox.setObjectName(u'androidAppGroupBox') - self.rightLayout.addWidget(self.androidAppGroupBox) - self.qrLayout = QtGui.QVBoxLayout(self.androidAppGroupBox) - self.qrLayout.setObjectName(u'qrLayout') - self.qrCodeLabel = QtGui.QLabel(self.androidAppGroupBox) - self.qrCodeLabel.setPixmap(QtGui.QPixmap(u':/remotes/android_app_qr.png')) - self.qrCodeLabel.setAlignment(QtCore.Qt.AlignCenter) - self.qrCodeLabel.setObjectName(u'qrCodeLabel') - self.qrLayout.addWidget(self.qrCodeLabel) - self.qrDescriptionLabel = QtGui.QLabel(self.androidAppGroupBox) - self.qrDescriptionLabel.setObjectName(u'qrDescriptionLabel') - self.qrDescriptionLabel.setOpenExternalLinks(True) - self.qrDescriptionLabel.setWordWrap(True) - self.qrLayout.addWidget(self.qrDescriptionLabel) + self.address_edit.setObjectName(u'address_edit') + self.server_settings_layout.addRow(self.address_label, self.address_edit) + self.twelve_hour_check_box = QtGui.QCheckBox(self.server_settings_group_box) + self.twelve_hour_check_box.setObjectName(u'twelve_hour_check_box') + self.server_settings_layout.addRow(self.twelve_hour_check_box) + self.port_label = QtGui.QLabel(self.server_settings_group_box) + self.port_label.setObjectName(u'port_label') + self.port_spin_box = QtGui.QSpinBox(self.server_settings_group_box) + self.port_spin_box.setMaximum(32767) + self.port_spin_box.setObjectName(u'port_spin_box') + self.server_settings_layout.addRow(self.port_label, self.port_spin_box) + self.remote_url_label = QtGui.QLabel(self.server_settings_group_box) + self.remote_url_label.setObjectName(u'remote_url_label') + self.remote_url = QtGui.QLabel(self.server_settings_group_box) + self.remote_url.setObjectName(u'remote_url') + self.remote_url.setOpenExternalLinks(True) + self.server_settings_layout.addRow(self.remote_url_label, self.remote_url) + self.stage_url_label = QtGui.QLabel(self.server_settings_group_box) + self.stage_url_label.setObjectName(u'stage_url_label') + self.stage_url = QtGui.QLabel(self.server_settings_group_box) + self.stage_url.setObjectName(u'stage_url') + self.stage_url.setOpenExternalLinks(True) + self.server_settings_layout.addRow(self.stage_url_label, self.stage_url) + self.leftLayout.addWidget(self.server_settings_group_box) + self.android_app_group_box = QtGui.QGroupBox(self.rightColumn) + self.android_app_group_box.setObjectName(u'android_app_group_box') + self.rightLayout.addWidget(self.android_app_group_box) + self.qr_layout = QtGui.QVBoxLayout(self.android_app_group_box) + self.qr_layout.setObjectName(u'qr_layout') + self.qr_code_label = QtGui.QLabel(self.android_app_group_box) + self.qr_code_label.setPixmap(QtGui.QPixmap(u':/remotes/android_app_qr.png')) + self.qr_code_label.setAlignment(QtCore.Qt.AlignCenter) + self.qr_code_label.setObjectName(u'qr_code_label') + self.qr_layout.addWidget(self.qr_code_label) + self.qr_description_label = QtGui.QLabel(self.android_app_group_box) + self.qr_description_label.setObjectName(u'qr_description_label') + self.qr_description_label.setOpenExternalLinks(True) + self.qr_description_label.setWordWrap(True) + self.qr_layout.addWidget(self.qr_description_label) self.leftLayout.addStretch() self.rightLayout.addStretch() - QtCore.QObject.connect(self.twelveHourCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onTwelveHourCheckBoxChanged) + self.twelve_hour_check_box.stateChanged.connect(self.onTwelveHourCheckBoxChanged) + self.address_edit.textChanged.connect(self.set_urls) + self.port_spin_box.valueChanged.connect(self.set_urls) def retranslateUi(self): - self.serverSettingsGroupBox.setTitle( - translate('RemotePlugin.RemoteTab', 'Server Settings')) - self.addressLabel.setText(translate('RemotePlugin.RemoteTab', 'Serve on IP address:')) - self.portLabel.setText(translate('RemotePlugin.RemoteTab', 'Port number:')) - self.remoteUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Remote URL:')) - self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Stage view URL:')) - self.twelveHourCheckBox.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format')) - self.androidAppGroupBox.setTitle(translate('RemotePlugin.RemoteTab', 'Android App')) - self.qrDescriptionLabel.setText(translate('RemotePlugin.RemoteTab', + self.server_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Server Settings')) + self.address_label.setText(translate('RemotePlugin.RemoteTab', 'Serve on IP address:')) + self.port_label.setText(translate('RemotePlugin.RemoteTab', 'Port number:')) + self.remote_url_label.setText(translate('RemotePlugin.RemoteTab', 'Remote URL:')) + self.stage_url_label.setText(translate('RemotePlugin.RemoteTab', 'Stage view URL:')) + self.twelve_hour_check_box.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format')) + self.android_app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Android App')) + self.qr_description_label.setText(translate('RemotePlugin.RemoteTab', 'Scan the QR code or click download to install the ' 'Android app from Google Play.')) - def setUrls(self): - ipAddress = u'localhost' - if self.addressEdit.text() == ZERO_URL: - ifaces = QtNetwork.QNetworkInterface.allInterfaces() - for iface in ifaces: - if not iface.isValid(): + def set_urls(self): + ip_address = u'localhost' + if self.address_edit.text() == ZERO_URL: + interfaces = QtNetwork.QNetworkInterface.allInterfaces() + for interface in interfaces: + if not interface.isValid(): continue - if not (iface.flags() & (QtNetwork.QNetworkInterface.IsUp | QtNetwork.QNetworkInterface.IsRunning)): + if not (interface.flags() & (QtNetwork.QNetworkInterface.IsUp | QtNetwork.QNetworkInterface.IsRunning)): continue - for addr in iface.addressEntries(): - ip = addr.ip() + for address in interface.addressEntries(): + ip = address.ip() if ip.protocol() == 0 and ip != QtNetwork.QHostAddress.LocalHost: - ipAddress = ip + ip_address = ip break else: - ipAddress = self.addressEdit.text() - url = u'http://%s:%s/' % (ipAddress, self.portSpinBox.value()) - self.remoteUrl.setText(u'%s' % (url, url)) + ip_address = self.address_edit.text() + url = u'http://%s:%s/' % (ip_address, self.port_spin_box.value()) + self.remote_url.setText(u'%s' % (url, url)) url += u'stage' - self.stageUrl.setText(u'%s' % (url, url)) + self.stage_url.setText(u'%s' % (url, url)) def load(self): - self.portSpinBox.setValue(Settings().value(self.settingsSection + u'/port')) - self.addressEdit.setText(Settings().value(self.settingsSection + u'/ip address')) - self.twelveHour = Settings().value(self.settingsSection + u'/twelve hour') - self.twelveHourCheckBox.setChecked(self.twelveHour) - self.setUrls() + self.port_spin_box.setValue(Settings().value(self.settingsSection + u'/port')) + self.address_edit.setText(Settings().value(self.settingsSection + u'/ip address')) + self.twelve_hour = Settings().value(self.settingsSection + u'/twelve hour') + self.twelve_hour_check_box.setChecked(self.twelve_hour) + self.set_urls() def save(self): changed = False - if Settings().value(self.settingsSection + u'/ip address') != self.addressEdit.text() or \ - Settings().value(self.settingsSection + u'/port') != self.portSpinBox.value(): + if Settings().value(self.settingsSection + u'/ip address') != self.address_edit.text() or \ + Settings().value(self.settingsSection + u'/port') != self.port_spin_box.value(): changed = True - Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value()) - Settings().setValue(self.settingsSection + u'/ip address', self.addressEdit.text()) - Settings().setValue(self.settingsSection + u'/twelve hour', self.twelveHour) + Settings().setValue(self.settingsSection + u'/port', self.port_spin_box.value()) + Settings().setValue(self.settingsSection + u'/ip address', self.address_edit.text()) + Settings().setValue(self.settingsSection + u'/twelve hour', self.twelve_hour) if changed: Registry().register_function(u'remotes_config_updated') def onTwelveHourCheckBoxChanged(self, check_state): - self.twelveHour = False + self.twelve_hour = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: - self.twelveHour = True + self.twelve_hour = True diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index e028dfcbb..b31e53bb1 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -38,7 +38,7 @@ __default_settings__ = { u'remotes/twelve hour': True, u'remotes/port': 4316, u'remotes/ip address': u'0.0.0.0' - } +} class RemotesPlugin(Plugin): @@ -81,7 +81,7 @@ class RemotesPlugin(Plugin): 'browser or through the remote API.') return about_text - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 501ee7eea..694fd1028 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -923,6 +923,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.verse_order) except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) + raise def _get_plugin_manager(self): """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 74a5ce216..ac8be3680 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -176,7 +176,7 @@ class SongsPlugin(Plugin): return translate('SongsPlugin', 'Songs Plugin' '
The songs plugin provides the ability to display and manage songs.') - def usesTheme(self, theme): + def uses_theme(self, theme): """ Called to find out if the song plugin is currently using a theme. @@ -186,7 +186,7 @@ class SongsPlugin(Plugin): return True return False - def renameTheme(self, oldTheme, newTheme): + def rename_theme(self, oldTheme, newTheme): """ Renames a theme the song plugin is using making the plugin use the new name. @@ -209,7 +209,7 @@ class SongsPlugin(Plugin): importer.register(self.mediaItem.importWizard) return importer - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index e51debc02..df7e4c8cc 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -219,7 +219,7 @@ class SongUsagePlugin(Plugin): '
This plugin tracks the usage of songs in services.') return about_text - def setPluginTextStrings(self): + def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 8527373dc..9bbce1359 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -7,7 +7,7 @@ from datetime import datetime, timedelta from mock import MagicMock, patch from openlp.core.lib import str_to_bool, translate, check_directory_exists, get_text_file_string, build_icon, \ - image_to_byte, check_item_selected, validate_thumb, create_separated_list + image_to_byte, check_item_selected, validate_thumb, create_separated_list, expand_tags class TestLib(TestCase): @@ -299,6 +299,45 @@ class TestLib(TestCase): MockedQtGui.QMessageBox.information.assert_called_with(u'parent', u'mocked translate', 'message') assert not result, u'The result should be False' + def expand_tags_test(self): + """ + Test the expand_tags() method. + """ + with patch(u'openlp.core.lib.FormattingTags.get_html_tags') as mocked_get_tags: + # GIVEN: Mocked get_html_tags() method. + mocked_get_tags.return_value = [ + { + u'desc': u'Black', + u'start tag': u'{b}', + u'start html': u'', + u'end tag': u'{/b}', u'end html': u'', u'protected': True, + u'temporary': False + }, + { + u'desc': u'Yellow', + u'start tag': u'{y}', + u'start html': u'', + u'end tag': u'{/y}', u'end html': u'', u'protected': True, + u'temporary': False + }, + { + u'desc': u'Green', + u'start tag': u'{g}', + u'start html': u'', + u'end tag': u'{/g}', u'end html': u'', u'protected': True, + u'temporary': False + } + ] + string_to_pass = u'{b}black{/b}{y}yellow{/y}' + wanted_string = u'black' + \ + 'yellow' + + # WHEN: Replace the tags. + result_string = expand_tags(string_to_pass) + + # THEN: The strings should be identical. + assert result_string == wanted_string, u'The strings should be identical.' + def validate_thumb_file_does_not_exist_test(self): """ Test the validate_thumb() function when the thumbnail does not exist diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index e5589b4ba..d50ddc978 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -216,12 +216,15 @@ class TestServiceItem(TestCase): assert service_item.get_frame_path(0) == test_file, u'The frame path should match the full path to the image' assert service_item.get_frame_title(0) == image_name, u'The frame title should match the image name' assert service_item.get_display_title() == image_name, u'The display title should match the first image name' - assert service_item.is_image() is True, u'This service item is an Image' - assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, u'This service item can be Maintained' - assert service_item.is_capable(ItemCapabilities.CanPreview) is True, u'This service item can be Previewed' - assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'This service item can be made to Loop' + assert service_item.is_image() is True, u'This service item should be of an "image" type' + assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \ + u'This service item should be able to be Maintained' + assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \ + u'This service item should be able to be be Previewed' + assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \ + u'This service item should be able to be run in a can be made to Loop' assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \ - u'This service item can have new items added' + u'This service item should be able to have new items added to it' def serviceitem_load_image_from_local_service_test(self): """ @@ -256,11 +259,14 @@ class TestServiceItem(TestCase): assert service_item.get_display_title().lower() == service_item.name, \ u'The plugin name should match the display title, as there are > 1 Images' assert service_item.is_image() is True, u'This service item should be of an "image" type' - assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, u'This service item can be Maintained' - assert service_item.is_capable(ItemCapabilities.CanPreview) is True, u'This service item can be Previewed' - assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'This service item can be made to Loop' + assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \ + u'This service item should be able to be Maintained' + assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \ + u'This service item should be able to be be Previewed' + assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \ + u'This service item should be able to be run in a can be made to Loop' assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \ - u'This service item can have new items added' + u'This service item should be able to have new items added to it' def convert_file_service_item(self, name): service_file = os.path.join(TEST_PATH, name)