From 3e1bdc7475f98e72207e2056a85e7a3f95800919 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 11 May 2011 23:32:25 +0100 Subject: [PATCH 01/18] More stageview changes --- openlp/core/lib/renderer.py | 4 +-- openlp/core/lib/serviceitem.py | 2 ++ openlp/plugins/remotes/html/stage.css | 6 ++-- openlp/plugins/remotes/html/stage.js | 37 ++++++++++++++++++------ openlp/plugins/remotes/lib/httpserver.py | 9 +++--- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bba85d176..98ae877b2 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -189,10 +189,10 @@ class Renderer(object): serviceItem.theme = theme_data if self.force_page: # make big page for theme edit dialog to get line count - serviceItem.add_from_text(u'', VERSE + VERSE + VERSE, FOOTER) + serviceItem.add_from_text(u'', VERSE + VERSE + VERSE) else: self.image_manager.del_image(theme_data.theme_name) - serviceItem.add_from_text(u'', VERSE, FOOTER) + serviceItem.add_from_text(u'', VERSE) serviceItem.renderer = self serviceItem.raw_footer = FOOTER serviceItem.render(True) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c1ae95b8b..95702f229 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -219,6 +219,8 @@ class ServiceItem(object): ``raw_slide`` The raw text of the slide. """ + if verse_tag: + verse_tag = verse_tag.upper() self.service_item_type = ServiceItemType.Text title = title.split(u'\n')[0] self._raw_frames.append( diff --git a/openlp/plugins/remotes/html/stage.css b/openlp/plugins/remotes/html/stage.css index a773c2393..73551b92e 100644 --- a/openlp/plugins/remotes/html/stage.css +++ b/openlp/plugins/remotes/html/stage.css @@ -30,12 +30,14 @@ body { #currentslide { font-size: 40pt; color: white; + padding-bottom: 0px; } #nextslide { - font-size: 30pt; + font-size: 40pt; color: grey; - padding-top: 25px; + padding-top: 0px; + padding-bottom: 0px; } #right { diff --git a/openlp/plugins/remotes/html/stage.js b/openlp/plugins/remotes/html/stage.js index 96e4c5a14..0c1c0ce63 100644 --- a/openlp/plugins/remotes/html/stage.js +++ b/openlp/plugins/remotes/html/stage.js @@ -46,15 +46,21 @@ window.OpenLP = { function (data, status) { OpenLP.currentSlides = data.results.slides; OpenLP.currentSlide = 0; + OpenLP.currentTags = Array(); var div = $("#verseorder"); div.html(""); + var tag = ""; + var tags = 0; for (idx in data.results.slides) { idx = parseInt(idx, 10); - div.append(" "); - var tag = data.results.slides[idx]["tag"]; - if (tag == 'None') - tag = idx; - $("#verseorder span").last().attr("id", "tag" + idx).text(tag); + var prevtag = tag; + tag = data.results.slides[idx]["tag"]; + if (tag != prevtag) { + tags = tags + 1; + div.append(" "); + $("#verseorder span").last().attr("id", "tag" + tags).text(tag); + } + OpenLP.currentTags[idx] = tags; if (data.results.slides[idx]["selected"]) OpenLP.currentSlide = idx; } @@ -64,17 +70,30 @@ window.OpenLP = { }, updateSlide: function() { $("#verseorder span").removeClass("currenttag"); - $("#tag" + OpenLP.currentSlide).addClass("currenttag"); - var text = OpenLP.currentSlides[OpenLP.currentSlide]["text"]; + $("#tag" + OpenLP.currentTags[OpenLP.currentSlide]).addClass("currenttag"); + var slide = OpenLP.currentSlides[OpenLP.currentSlide]; + var text = slide["text"]; text = text.replace(/\n/g, '
'); $("#currentslide").html(text); + text = ""; if (OpenLP.currentSlide < OpenLP.currentSlides.length - 1) { - text = OpenLP.currentSlides[OpenLP.currentSlide + 1]["text"]; + for (var idx = OpenLP.currentSlide + 1; idx < OpenLP.currentSlides.length; idx++) { + var prevslide = slide; + slide = OpenLP.currentSlides[idx]; + if (slide["tag"] != prevslide["tag"]) + text = text + '

'; + text = text + slide["text"]; + if (slide["tag"] != prevslide["tag"]) + text = text + '

'; + else + text = text + '
'; + } text = text.replace(/\n/g, '
'); $("#nextslide").html(text); } else - $("#nextslide").html("Next: " + OpenLP.nextSong); + text = '

Next: ' + OpenLP.nextSong + '

'; + $("#nextslide").html(text); }, updateClock: function() { var div = $("#clock"); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 790175965..6e5c2c0b6 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -115,7 +115,6 @@ import os import urlparse import re from pprint import pformat -from lxml import html try: import json @@ -402,9 +401,11 @@ class HttpConnection(object): for index, frame in enumerate(current_item.get_frames()): item = {} if current_item.is_text(): - item[u'tag'] = unicode(frame[u'verseTag']) - text = unicode(frame[u'html'].replace('
', '\n')) - item[u'text'] = html.fromstring(text).text_content() + if frame[u'verseTag']: + item[u'tag'] = unicode(frame[u'verseTag']) + else: + item[u'tag'] = unicode(index) + item[u'text'] = unicode(frame[u'text']) item[u'html'] = unicode(frame[u'html']) else: item[u'tag'] = unicode(index) From e940279b34c792480d15658370eb495a8ab52eb2 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 12 May 2011 00:16:53 +0100 Subject: [PATCH 02/18] More stageview changes --- openlp/core/ui/slidecontroller.py | 2 +- openlp/plugins/remotes/lib/httpserver.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index fdbf184b5..7623faa9b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -616,7 +616,7 @@ class SlideController(QtGui.QWidget): if frame[u'verseTag']: # These tags are already translated. verse_def = frame[u'verseTag'] - verse_def = u'%s%s' % (verse_def[0].upper(), verse_def[1:]) + verse_def = u'%s%s' % (verse_def[0], verse_def[1:]) two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:]) row = two_line_def if self.isLive: diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 6e5c2c0b6..20005840c 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -404,11 +404,11 @@ class HttpConnection(object): if frame[u'verseTag']: item[u'tag'] = unicode(frame[u'verseTag']) else: - item[u'tag'] = unicode(index) + item[u'tag'] = unicode(index + 1) item[u'text'] = unicode(frame[u'text']) item[u'html'] = unicode(frame[u'html']) else: - item[u'tag'] = unicode(index) + item[u'tag'] = unicode(index + 1) item[u'text'] = u'' item[u'html'] = u'' item[u'selected'] = (self.parent.current_slide == index) From d1c1f38407cf41449913e9bb36e2d7c24d08ba0c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 12 May 2011 17:36:06 +0200 Subject: [PATCH 03/18] r1534 From 4778bfd781e9765cf18555244e288f715574bf78 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 12 May 2011 17:44:20 +0200 Subject: [PATCH 04/18] disable drops for search edit --- openlp/core/lib/searchedit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index b524855ba..fc007227e 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -62,6 +62,7 @@ class SearchEdit(QtGui.QLineEdit): self._onSearchEditTextChanged ) self._updateStyleSheet() + self.setAcceptDrops(False) def _updateStyleSheet(self): """ From 4e870ed705987481e11bfe62c511a1744b98a8e5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 12 May 2011 17:50:20 +0200 Subject: [PATCH 05/18] only allow drag if an item is selected --- openlp/core/lib/listwidgetwithdnd.py | 3 +++ openlp/core/ui/servicemanager.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index c45b4cc9d..2419d1a35 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -49,6 +49,9 @@ class ListWidgetWithDnD(QtGui.QListWidget): if event.buttons() != QtCore.Qt.LeftButton: event.ignore() return + if not self.selectedItems(): + event.ignore() + return drag = QtGui.QDrag(self) mimeData = QtCore.QMimeData() drag.setMimeData(mimeData) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b5e8bbc54..9031a0b1a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -73,6 +73,9 @@ class ServiceManagerList(QtGui.QTreeWidget): if event.buttons() != QtCore.Qt.LeftButton: event.ignore() return + if not self.selectedItems(): + event.ignore() + return drag = QtGui.QDrag(self) mimeData = QtCore.QMimeData() drag.setMimeData(mimeData) From ef5c4bc7d413369cc771b9325a4be285f86cd89a Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 12 May 2011 22:55:45 +0100 Subject: [PATCH 06/18] Detect repeat verses --- openlp/plugins/remotes/html/stage.js | 47 +++++++++++++++++++++------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/remotes/html/stage.js b/openlp/plugins/remotes/html/stage.js index 0c1c0ce63..8ca041366 100644 --- a/openlp/plugins/remotes/html/stage.js +++ b/openlp/plugins/remotes/html/stage.js @@ -51,24 +51,50 @@ window.OpenLP = { div.html(""); var tag = ""; var tags = 0; - for (idx in data.results.slides) { - idx = parseInt(idx, 10); + var lastChange = 0; + $.each(data.results.slides, function(idx, slide) { var prevtag = tag; - tag = data.results.slides[idx]["tag"]; + tag = slide["tag"]; if (tag != prevtag) { + // If the tag has changed, add new one to the list + lastChange = idx; tags = tags + 1; div.append(" "); $("#verseorder span").last().attr("id", "tag" + tags).text(tag); } + else { + if ((slide["text"] == data.results.slides[lastChange]["text"]) && + (data.results.slides.length > idx + (idx - lastChange))) { + // If the tag hasn't changed, check to see if the same verse + // has been repeated consecutively. Note the verse may have been + // split over several slides, so search through. If so, repeat the tag. + var match = true; + for (var idx2 = 0; idx2 < idx - lastChange; idx2++) { + if(data.results.slides[lastChange + idx2]["text"] != data.results.slides[idx + idx2]["text"]) { + match = false; + break; + } + } + if (match) { + lastChange = idx; + tags = tags + 1; + div.append(" "); + $("#verseorder span").last().attr("id", "tag" + tags).text(tag); + } + } + } OpenLP.currentTags[idx] = tags; - if (data.results.slides[idx]["selected"]) + if (slide["selected"]) OpenLP.currentSlide = idx; - } + }) OpenLP.loadService(); } ); }, updateSlide: function() { + // Show the current slide on top. Any trailing slides for the same verse + // are shown too underneath in grey. + // Then leave a blank line between following verses $("#verseorder span").removeClass("currenttag"); $("#tag" + OpenLP.currentTags[OpenLP.currentSlide]).addClass("currenttag"); var slide = OpenLP.currentSlides[OpenLP.currentSlide]; @@ -78,12 +104,10 @@ window.OpenLP = { text = ""; if (OpenLP.currentSlide < OpenLP.currentSlides.length - 1) { for (var idx = OpenLP.currentSlide + 1; idx < OpenLP.currentSlides.length; idx++) { - var prevslide = slide; - slide = OpenLP.currentSlides[idx]; - if (slide["tag"] != prevslide["tag"]) + if (OpenLP.currentTags[idx] != OpenLP.currentTags[idx - 1]) text = text + '

'; - text = text + slide["text"]; - if (slide["tag"] != prevslide["tag"]) + text = text + OpenLP.currentSlides[idx]["text"]; + if (OpenLP.currentTags[idx] != OpenLP.currentTags[idx - 1]) text = text + '

'; else text = text + '
'; @@ -91,9 +115,10 @@ window.OpenLP = { text = text.replace(/\n/g, '
'); $("#nextslide").html(text); } - else + else { text = '

Next: ' + OpenLP.nextSong + '

'; $("#nextslide").html(text); + } }, updateClock: function() { var div = $("#clock"); From be413a688c507863e2d9f20eb6d068480949e81a Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Thu, 12 May 2011 21:23:01 -0400 Subject: [PATCH 07/18] modified: resources/windows/OpenLP-2.0.iss scripts/windows-builder.py --- resources/windows/OpenLP-2.0.iss | 2 +- scripts/windows-builder.py | 38 ++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/resources/windows/OpenLP-2.0.iss b/resources/windows/OpenLP-2.0.iss index 8cc8a4aa7..9f193b0e8 100644 --- a/resources/windows/OpenLP-2.0.iss +++ b/resources/windows/OpenLP-2.0.iss @@ -69,7 +69,7 @@ Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs [Icons] Name: {group}\{#AppName}; Filename: {app}\{#AppExeName} Name: {group}\{#AppName} (Debug); Filename: {app}\{#AppExeName}; Parameters: -l debug -Name: {group}\{#AppName} Help; Filename: {app}\{#AppName}.chm +Name: {group}\{#AppName} Help; Filename: {app}\{#AppName}.chm; Check: FileExists(ExpandConstant('{app}\{#AppName}.chm')) Name: {group}\{cm:ProgramOnTheWeb,{#AppName}}; Filename: {#AppURL} Name: {group}\{cm:UninstallProgram,{#AppName}}; Filename: {uninstallexe} Name: {commondesktop}\{#AppName}; Filename: {app}\{#AppExeName}; Tasks: desktopicon diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index 0271f80b8..27798a850 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -53,7 +53,8 @@ UPX add that directory to your PATH environment variable. Sphinx - This is used to build the documentation + This is used to build the documentation. The documentation trunk must be at + the same directory level as Openlp trunk and named "documentation" HTML Help Workshop This is used to create the help file @@ -99,6 +100,7 @@ windows-builder.py import os import sys from shutil import copy +from shutil import rmtree from subprocess import Popen, PIPE python_exe = sys.executable @@ -108,12 +110,14 @@ sphinx_exe = os.path.join(os.path.split(python_exe)[0], u'Scripts', u'sphinx-build.exe') hhc_exe = os.path.join(os.getenv(u'PROGRAMFILES'), 'HTML Help Workshop', u'hhc.exe') -vcbuild_exe = os.path.join(os.getenv(u'PROGRAMFILES'), +vcbuild_exe = os.path.join(os.getenv(u'PROGRAMFILES'), u'Microsoft Visual Studio 9.0', u'VC', u'vcpackages', u'vcbuild.exe') # Base paths script_path = os.path.split(os.path.abspath(__file__))[0] branch_path = os.path.abspath(os.path.join(script_path, u'..')) +doc_branch_path = os.path.abspath(os.path.join(script_path, u'..', + u'..',u'documentation')) site_packages = os.path.join(os.path.split(python_exe)[0], u'Lib', u'site-packages') @@ -125,7 +129,9 @@ i18n_utils = os.path.join(script_path, u'translation_utils.py') # Paths source_path = os.path.join(branch_path, u'openlp') -manual_path = os.path.join(branch_path, u'documentation', u'manual') +manual_path = os.path.join(doc_branch_path, u'manual') +manual_build_path = os.path.join(manual_path, u'build') +helpfile_path = os.path.join(manual_build_path, u'htmlhelp') i18n_path = os.path.join(branch_path, u'resources', u'i18n') winres_path = os.path.join(branch_path, u'resources', u'windows') build_path = os.path.join(branch_path, u'build', u'pyi.win32', u'OpenLP') @@ -219,6 +225,12 @@ def copy_windows_files(): os.path.join(dist_path, u'OpenLP.ico')) copy(os.path.join(winres_path, u'LICENSE.txt'), os.path.join(dist_path, u'LICENSE.txt')) + if os.path.isfile(os.path.join(helpfile_path, u'Openlp.chm')): + print u' Windows help file found' + copy(os.path.join(helpfile_path,u'Openlp.chm'), + os.path.join(dist_path, u'Openlp.chm')) + else: + print u' WARNING ---- Windows help file not found ---- WARNING' def update_translations(): print u'Updating translations...' @@ -253,6 +265,9 @@ def compile_translations(): os.path.join(dist_path, u'i18n', filename)) def run_sphinx(): + print u'Deleting previous manual build...',manual_build_path + if os.path.exists(manual_build_path): + rmtree(manual_build_path) print u'Running Sphinx...' os.chdir(manual_path) sphinx = Popen((sphinx_exe, u'-b', u'htmlhelp', u'-d', u'build/doctrees', @@ -265,7 +280,7 @@ def run_sphinx(): def run_htmlhelp(): print u'Running HTML Help Workshop...' - os.chdir(os.path.join(manual_path, u'build', u'htmlhelp')) + os.chdir(os.path.join(manual_build_path, u'htmlhelp')) hhc = Popen((hhc_exe, u'OpenLP.chm'), stdout=PIPE) output, error = hhc.communicate() code = hhc.wait() @@ -273,9 +288,6 @@ def run_htmlhelp(): print u'Exit code:', code print output raise Exception(u'Error running HTML Help Workshop') - else: - copy(os.path.join(manual_path, u'build', 'htmlhelp', u'OpenLP.chm'), - os.path.join(dist_path, u'OpenLP.chm')) def run_innosetup(): print u'Running Inno Setup...' @@ -306,6 +318,8 @@ def main(): print "Source path:", source_path print "\"dist\" path:", dist_path print "PyInstaller:", pyi_build + print "Documentation branch path:", doc_branch_path + print "Help file build path;", helpfile_path print "Inno Setup path:", innosetup_exe print "Windows resources:", winres_path print "VCBuild path:", vcbuild_exe @@ -324,11 +338,17 @@ def main(): write_version_file() copy_enchant() copy_plugins() + if os.path.exists(manual_path): + run_sphinx() + run_htmlhelp() + else: + print u' ' + print u' WARNING ---- Documentation Trunk not found ---- WARNING' + print u' --- Windows Help file will not be included in build ---' + print u' ' copy_windows_files() update_translations() compile_translations() - run_sphinx() - run_htmlhelp() run_innosetup() print "Done." From a4fa470817ab76421433f6e7249aad5f9aad9d8d Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Fri, 13 May 2011 07:45:41 -0400 Subject: [PATCH 08/18] modified: scripts/windows-builder.py --- scripts/windows-builder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index 27798a850..8f2dc0171 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -117,7 +117,7 @@ vcbuild_exe = os.path.join(os.getenv(u'PROGRAMFILES'), script_path = os.path.split(os.path.abspath(__file__))[0] branch_path = os.path.abspath(os.path.join(script_path, u'..')) doc_branch_path = os.path.abspath(os.path.join(script_path, u'..', - u'..',u'documentation')) + u'..', u'documentation')) site_packages = os.path.join(os.path.split(python_exe)[0], u'Lib', u'site-packages') @@ -227,7 +227,7 @@ def copy_windows_files(): os.path.join(dist_path, u'LICENSE.txt')) if os.path.isfile(os.path.join(helpfile_path, u'Openlp.chm')): print u' Windows help file found' - copy(os.path.join(helpfile_path,u'Openlp.chm'), + copy(os.path.join(helpfile_path, u'Openlp.chm'), os.path.join(dist_path, u'Openlp.chm')) else: print u' WARNING ---- Windows help file not found ---- WARNING' @@ -265,7 +265,7 @@ def compile_translations(): os.path.join(dist_path, u'i18n', filename)) def run_sphinx(): - print u'Deleting previous manual build...',manual_build_path + print u'Deleting previous manual build...', manual_build_path if os.path.exists(manual_build_path): rmtree(manual_build_path) print u'Running Sphinx...' From d4f7bf1e0a5b015913b03803e7843e10cdeddda8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 14:55:04 +0200 Subject: [PATCH 09/18] --- openlp/core/lib/mediamanageritem.py | 34 ++++++++++++++++++++--------- openlp/core/lib/ui.py | 2 ++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index e5e8ed3b1..225d4023e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -238,13 +238,21 @@ class MediaManagerItem(QtGui.QWidget): self.plugin.getString(action[0])[u'tooltip'], action[1], action[2]) + def contextMenu(self, point): + item = self.listView.itemAt(point) + if item is None: + return + if not item.flags() & QtCore.Qt.ItemIsSelectable: + return + self.menu.exec_(self.listView.mapToGlobal(point)) + def addListViewToToolBar(self): """ Creates the main widget for listing items the media item is tracking """ # Add the List widget self.listView = ListWidgetWithDnD(self, self.plugin.name) - self.listView.uniformItemSizes = True + self.listView.setUniformItemSizes(True) self.listView.setSpacing(1) self.listView.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) @@ -254,43 +262,46 @@ class MediaManagerItem(QtGui.QWidget): # Add to pageLayout self.pageLayout.addWidget(self.listView) # define and add the context menu - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.menu = QtGui.QMenu() + # Create the actions. All actions are automatically added to the + # listView. if self.hasEditIcon: - self.listView.addAction( + self.menu.addAction( context_menu_action( self.listView, u':/general/general_edit.png', self.plugin.getString(StringContent.Edit)[u'title'], self.onEditClick, context=QtCore.Qt.WidgetShortcut)) - self.listView.addAction(context_menu_separator(self.listView)) + self.menu.addAction(context_menu_separator(self.listView)) if self.hasDeleteIcon: - self.listView.addAction( + self.menu.addAction( context_menu_action( self.listView, u':/general/general_delete.png', self.plugin.getString(StringContent.Delete)[u'title'], self.onDeleteClick, [QtCore.Qt.Key_Delete], context=QtCore.Qt.WidgetShortcut)) - self.listView.addAction(context_menu_separator(self.listView)) - self.listView.addAction( + self.menu.addAction(context_menu_separator(self.listView)) + self.menu.addAction( context_menu_action( self.listView, u':/general/general_preview.png', self.plugin.getString(StringContent.Preview)[u'title'], self.onPreviewClick, [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)) - self.listView.addAction( + self.menu.addAction( context_menu_action( self.listView, u':/general/general_live.png', self.plugin.getString(StringContent.Live)[u'title'], self.onLiveClick, [QtCore.Qt.ShiftModifier + \ QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \ QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)) - self.listView.addAction( + self.menu.addAction( context_menu_action( self.listView, u':/general/general_add.png', self.plugin.getString(StringContent.Service)[u'title'], self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal], context=QtCore.Qt.WidgetShortcut)) if self.addToServiceItem: - self.listView.addAction( + self.menu.addAction( context_menu_action( self.listView, u':/general/general_add.png', translate('OpenLP.MediaManagerItem', @@ -302,6 +313,9 @@ class MediaManagerItem(QtGui.QWidget): QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'itemSelectionChanged()'), self.onSelectionChange) + QtCore.QObject.connect(self.listView, + QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.contextMenu) def initialise(self): """ diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index e8be32a92..3fdf9642d 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -364,6 +364,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, action.setShortcutContext(context) action_list = ActionList.get_instance() action_list.add_action(action) + base.addAction(action) return action def context_menu(base, icon, text): @@ -392,6 +393,7 @@ def context_menu_separator(base): """ action = QtGui.QAction(u'', base) action.setSeparator(True) + base.addAction(action) return action def add_widget_completer(cache, widget): From 07b704677abd00283f7c3941e57a2edede9eccd4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 15:58:17 +0200 Subject: [PATCH 10/18] --- openlp/core/lib/ui.py | 6 +-- openlp/core/ui/servicemanager.py | 76 ++++++++++++++------------------ 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 3fdf9642d..7350d8b74 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -331,7 +331,7 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, context=QtCore.Qt.WindowShortcut): """ - Utility method to help build context menus for plugins + Utility method to help build context menus. ``base`` The parent menu to add this menu item to @@ -350,7 +350,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, ``category`` The category the shortcut should be listed in the shortcut dialog. If - left to None, then the action will be hidden in the shortcut dialog. + left to ``None``, then the action will be hidden in the shortcut dialog. ``context`` The context the shortcut is valid. @@ -369,7 +369,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, def context_menu(base, icon, text): """ - Utility method to help build context menus for plugins + Utility method to help build context menus. ``base`` The parent object to add this menu to diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9031a0b1a..358877cc7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -36,7 +36,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ ItemCapabilities, SettingsManager, translate from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ - context_menu_action, find_and_set_in_combo_box + context_menu_action, context_menu_separator, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ @@ -301,31 +301,34 @@ class ServiceManager(QtGui.QWidget): self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) # build the context menu self.menu = QtGui.QMenu() - self.editAction = self.menu.addAction( - translate('OpenLP.ServiceManager', '&Edit Item')) - self.editAction.setIcon(build_icon(u':/general/general_edit.png')) - self.maintainAction = self.menu.addAction( - translate('OpenLP.ServiceManager', '&Reorder Item')) - self.maintainAction.setIcon(build_icon(u':/general/general_edit.png')) - self.notesAction = self.menu.addAction( - translate('OpenLP.ServiceManager', '&Notes')) - self.notesAction.setIcon(build_icon(u':/services/service_notes.png')) - self.timeAction = self.menu.addAction( - translate('OpenLP.ServiceManager', '&Start Time')) - self.timeAction.setIcon(build_icon(u':/media/media_time.png')) - self.deleteAction = self.menu.addAction( - translate('OpenLP.ServiceManager', '&Delete From Service')) - self.deleteAction.setIcon(build_icon(u':/general/general_delete.png')) - self.sep1 = self.menu.addAction(u'') - self.sep1.setSeparator(True) - self.previewAction = self.menu.addAction( - translate('OpenLP.ServiceManager', 'Show &Preview')) - self.previewAction.setIcon(build_icon(u':/general/general_preview.png')) - self.liveAction = self.menu.addAction( - translate('OpenLP.ServiceManager', 'Show &Live')) - self.liveAction.setIcon(build_icon(u':/general/general_live.png')) - self.sep2 = self.menu.addAction(u'') - self.sep2.setSeparator(True) + self.editAction = context_menu_action( + self.menu, u':/general/general_edit.png', + translate('OpenLP.ServiceManager', '&Edit Item'), self.remoteEdit) + self.maintainAction = context_menu_action( + self.menu, u':/general/general_edit.png', + translate('OpenLP.ServiceManager', '&Reorder Item'), + self.onServiceItemEditForm) + self.notesAction = context_menu_action( + self.menu, u':/services/service_notes.png', + translate('OpenLP.ServiceManager', '&Notes'), + self.onServiceItemNoteForm) + self.timeAction = context_menu_action( + self.menu, u':/media/media_time.png', + translate('OpenLP.ServiceManager', '&Start Time'), + self.onStartTimeForm) + self.deleteAction = context_menu_action( + self.menu, u':/general/general_delete.png', + translate('OpenLP.ServiceManager', '&Delete From Service'), + self.onDeleteFromService) + context_menu_separator(self.menu) + self.previewAction = context_menu_action( + self.menu, u':/general/general_preview.png', + translate('OpenLP.ServiceManager', 'Show &Preview'), + self.makePreview) + self.liveAction = context_menu_action( + self.menu, u':/general/general_live.png', + translate('OpenLP.ServiceManager', 'Show &Live'), self.makeLive) + context_menu_separator(self.menu) self.themeMenu = QtGui.QMenu( translate('OpenLP.ServiceManager', '&Change Item Theme')) self.menu.addMenu(self.themeMenu) @@ -675,20 +678,6 @@ class ServiceManager(QtGui.QWidget): if serviceItem[u'service_item'].is_text(): self.themeMenu.menuAction().setVisible(True) action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point)) - if action == self.editAction: - self.remoteEdit() - elif action == self.maintainAction: - self.onServiceItemEditForm() - elif action == self.deleteAction: - self.onDeleteFromService() - elif action == self.notesAction: - self.onServiceItemNoteForm() - elif action == self.timeAction: - self.onStartTimeForm() - elif action == self.previewAction: - self.makePreview() - elif action == self.liveAction: - self.makeLive() def onServiceItemNoteForm(self): item = self.findServiceItem()[0] @@ -840,7 +829,7 @@ class ServiceManager(QtGui.QWidget): correct state. """ pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] - self.serviceItems[pos -1 ][u'expanded'] = False + self.serviceItems[pos - 1][u'expanded'] = False def onExpandAll(self): """ @@ -1288,9 +1277,8 @@ class ServiceManager(QtGui.QWidget): self.themeComboBox.addItem(u'') for theme in theme_list: self.themeComboBox.addItem(theme) - action = context_menu_action(self.serviceManagerList, None, theme, - self.onThemeChangeAction, context=QtCore.Qt.WidgetShortcut) - self.themeMenu.addAction(action) + context_menu_action(self.themeMenu, None, theme, + self.onThemeChangeAction) find_and_set_in_combo_box(self.themeComboBox, self.service_theme) self.mainwindow.renderer.set_service_theme(self.service_theme) self.regenerateServiceItems() From 31cebdf4f7dcc6105fc110918a8f03dba74ed2e6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 17:34:56 +0200 Subject: [PATCH 11/18] added missing period --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b6085ea1e..4f349c998 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -258,7 +258,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Find:')) self.quickSearchButton.setText(UiStrings().Search) self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem', - 'Toggle to keep or clear the previous results')) + 'Toggle to keep or clear the previous results.')) self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version) self.advancedSecondLabel.setText( translate('BiblesPlugin.MediaItem', 'Second:')) From 1f4bc114a9e3d6368c92bdf1cd8c1e3894ffde61 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 21:44:34 +0200 Subject: [PATCH 12/18] Fixed traceback, when 'locked' and no dual bible selected. --- openlp/plugins/bibles/lib/mediaitem.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4f349c998..f8b23d3ec 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -587,7 +587,12 @@ class BibleMediaItem(MediaManagerItem): Check if the first item is a second bible item or not. """ bitem = self.listView.item(0) - item_second_bible = self._decodeQtObject(bitem, 'second_bible') + if not bitem.flags() & QtCore.Qt.ItemIsSelectable: + # The item is the "No Search Results" item. + self.listView.clear() + item_second_bible = None + else: + item_second_bible = self._decodeQtObject(bitem, 'second_bible') if item_second_bible and second_bible or not item_second_bible and \ not second_bible: self.displayResults(bible, second_bible) From b1979857e40878d77a25f14cf208f8550a3a77b0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 21:58:05 +0200 Subject: [PATCH 13/18] complete fix --- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f8b23d3ec..281f9bcc5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -590,7 +590,8 @@ class BibleMediaItem(MediaManagerItem): if not bitem.flags() & QtCore.Qt.ItemIsSelectable: # The item is the "No Search Results" item. self.listView.clear() - item_second_bible = None + self.displayResults(bible, second_bible) + return else: item_second_bible = self._decodeQtObject(bitem, 'second_bible') if item_second_bible and second_bible or not item_second_bible and \ From b04e688647f44c4163e3bb6c93ce87d8312095ff Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 13 May 2011 22:59:14 +0200 Subject: [PATCH 14/18] fixed attribute error --- openlp/plugins/presentations/lib/impresscontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index a67d8f818..b691c47ce 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -252,7 +252,7 @@ class ImpressDocument(PresentationDocument): window.setVisible(False) self.presentation = self.document.getPresentation() self.presentation.Display = \ - self.controller.plugin.renderer.screens.current_display + 1 + self.controller.plugin.renderer.screens.current[u'number'] + 1 self.control = None self.create_thumbnails() return True From 144ff29e9080cda45407c6828a250e76f2b0dd26 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 14 May 2011 13:48:15 +0200 Subject: [PATCH 15/18] fixed bug #744463 Fixes: https://launchpad.net/bugs/744463 --- openlp/core/ui/mainwindow.py | 3 +++ openlp/core/ui/splashscreen.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 11727f4ae..09e2ec9e7 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -672,12 +672,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 'The Main Display has been blanked out')) def onErrorMessage(self, data): + Receiver.send_message(u'close_splash') QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) def onWarningMessage(self, data): + Receiver.send_message(u'close_splash') QtGui.QMessageBox.warning(self, data[u'title'], data[u'message']) def onInformationMessage(self, data): + Receiver.send_message(u'close_splash') QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) def onHelpWebSiteClicked(self): diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 84aa1d7df..2bb516d00 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -23,6 +23,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from openlp.core.lib import Receiver from PyQt4 import QtCore, QtGui @@ -30,6 +31,8 @@ class SplashScreen(QtGui.QSplashScreen): def __init__(self): QtGui.QSplashScreen.__init__(self) self.setupUi() + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'close_splash'), self.close) def setupUi(self): self.setObjectName(u'splash_screen') From 3774bf2312a573683c38a8d7c8342582ae568315 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 14 May 2011 22:12:01 +0200 Subject: [PATCH 16/18] Added layout style to advanced tab. Made search edit focused on switch to quick tab. Reordered methods to: private, inherited, slots, additional. --- openlp/plugins/bibles/lib/mediaitem.py | 200 ++++++++++++++----------- 1 file changed, 111 insertions(+), 89 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 281f9bcc5..614beb32e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -67,6 +67,39 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles) + def __checkSecondBible(self, bible, second_bible): + """ + Check if the first item is a second bible item or not. + """ + bitem = self.listView.item(0) + if not bitem.flags() & QtCore.Qt.ItemIsSelectable: + # The item is the "No Search Results" item. + self.listView.clear() + self.displayResults(bible, second_bible) + return + else: + item_second_bible = self._decodeQtObject(bitem, 'second_bible') + if item_second_bible and second_bible or not item_second_bible and \ + not second_bible: + self.displayResults(bible, second_bible) + elif critical_error_message_box( + message=translate('BiblePlugin.MediaItem', + 'You cannot combine single and dual Bible verse search results. ' + 'Do you want to delete your search results and start a new ' + 'search?'), + parent=self, question=True) == QtGui.QMessageBox.Yes: + self.listView.clear() + self.displayResults(bible, second_bible) + + def _decodeQtObject(self, bitem, key): + reference = bitem.data(QtCore.Qt.UserRole) + if isinstance(reference, QtCore.QVariant): + reference = reference.toPyObject() + obj = reference[QtCore.QString(key)] + if isinstance(obj, QtCore.QVariant): + obj = obj.toPyObject() + return unicode(obj).strip() + def requiredIcons(self): MediaManagerItem.requiredIcons(self) self.hasImportIcon = True @@ -114,6 +147,12 @@ class BibleMediaItem(MediaManagerItem): secondComboBox = media_item_combo_box(tab, prefix + u'SecondComboBox') versionLabel.setBuddy(secondComboBox) layout.addWidget(secondComboBox, idx + 1, 1, 1, 2) + styleLabel = QtGui.QLabel(tab) + styleLabel.setObjectName(prefix + u'StyleLabel') + layout.addWidget(styleLabel, idx + 2, 0, QtCore.Qt.AlignRight) + styleComboBox = media_item_combo_box(tab, prefix + u'StyleComboBox') + styleComboBox.addItems([u'', u'', u'']) + layout.addWidget(styleComboBox, idx + 2, 1, 1, 2) searchButtonLayout = QtGui.QHBoxLayout() searchButtonLayout.setObjectName(prefix + u'SearchButtonLayout') searchButtonLayout.addStretch() @@ -125,7 +164,7 @@ class BibleMediaItem(MediaManagerItem): searchButton = QtGui.QPushButton(tab) searchButton.setObjectName(prefix + u'SearchButton') searchButtonLayout.addWidget(searchButton) - layout.addLayout(searchButtonLayout, idx + 2, 1, 1, 2) + layout.addLayout(searchButtonLayout, idx + 3, 1, 1, 2) self.pageLayout.addWidget(tab) tab.setVisible(False) QtCore.QObject.connect(lockButton, QtCore.SIGNAL(u'toggled(bool)'), @@ -134,6 +173,8 @@ class BibleMediaItem(MediaManagerItem): setattr(self, prefix + u'VersionComboBox', versionComboBox) setattr(self, prefix + u'SecondLabel', secondLabel) setattr(self, prefix + u'SecondComboBox', secondComboBox) + setattr(self, prefix + u'StyleLabel', styleLabel) + setattr(self, prefix + u'StyleComboBox', styleComboBox) setattr(self, prefix + u'LockButton', lockButton) setattr(self, prefix + u'SearchButtonLayout', searchButtonLayout) setattr(self, prefix + u'SearchButton', searchButton) @@ -154,14 +195,6 @@ class BibleMediaItem(MediaManagerItem): self.quickSearchEdit.setObjectName(u'quickSearchEdit') self.quickSearchLabel.setBuddy(self.quickSearchEdit) self.quickLayout.addWidget(self.quickSearchEdit, 0, 1, 1, 2) - self.quickLayoutLabel = QtGui.QLabel(self.quickTab) - self.quickLayoutLabel.setObjectName(u'quickClearLabel') - self.quickLayout.addWidget( - self.quickLayoutLabel, 1, 0, QtCore.Qt.AlignRight) - self.quickLayoutComboBox = media_item_combo_box(self.quickTab, - u'quickLayoutComboBox') - self.quickLayoutComboBox.addItems([u'', u'', u'']) - self.quickLayout.addWidget(self.quickLayoutComboBox, 1, 1, 1, 2) self.addSearchFields( u'quick', translate('BiblesPlugin.MediaItem', 'Quick')) self.quickTab.setVisible(True) @@ -218,8 +251,11 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(self.quickVersionComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter) QtCore.QObject.connect( - self.quickLayoutComboBox, QtCore.SIGNAL(u'activated(int)'), - self.onLayoutStyleComboBoxChanged) + self.quickStyleComboBox, QtCore.SIGNAL(u'activated(int)'), + self.onQuickStyleComboBoxChanged) + QtCore.QObject.connect( + self.advancedStyleComboBox, QtCore.SIGNAL(u'activated(int)'), + self.onAdvancedStyleComboBoxChanged) # Buttons QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton) @@ -247,21 +283,26 @@ class BibleMediaItem(MediaManagerItem): self.advancedSecondComboBox.setVisible(False) self.quickSecondLabel.setVisible(False) self.quickSecondComboBox.setVisible(False) - self.quickLayoutComboBox.setCurrentIndex(self.settings.layout_style) + self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style) + self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style) def retranslateUi(self): log.debug(u'retranslateUi') + self.quickSearchLabel.setText( + translate('BiblesPlugin.MediaItem', 'Find:')) self.quickVersionLabel.setText(u'%s:' % UiStrings().Version) self.quickSecondLabel.setText( translate('BiblesPlugin.MediaItem', 'Second:')) - self.quickSearchLabel.setText( - translate('BiblesPlugin.MediaItem', 'Find:')) - self.quickSearchButton.setText(UiStrings().Search) + self.quickStyleLabel.setText(UiStrings().LayoutStyle) + self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide, + UiStrings().VersePerSlide) + self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine, + UiStrings().VersePerLine) + self.quickStyleComboBox.setItemText(LayoutStyle.Continuous, + UiStrings().Continuous) self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Toggle to keep or clear the previous results.')) - self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version) - self.advancedSecondLabel.setText( - translate('BiblesPlugin.MediaItem', 'Second:')) + self.quickSearchButton.setText(UiStrings().Search) self.advancedBookLabel.setText( translate('BiblesPlugin.MediaItem', 'Book:')) self.advancedChapterLabel.setText( @@ -272,16 +313,19 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'From:')) self.advancedToLabel.setText( translate('BiblesPlugin.MediaItem', 'To:')) - self.advancedSearchButton.setText(UiStrings().Search) + self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version) + self.advancedSecondLabel.setText( + translate('BiblesPlugin.MediaItem', 'Second:')) + self.advancedStyleLabel.setText(UiStrings().LayoutStyle) + self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide, + UiStrings().VersePerSlide) + self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine, + UiStrings().VersePerLine) + self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous, + UiStrings().Continuous) self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Toggle to keep or clear the previous results.')) - self.quickLayoutLabel.setText(UiStrings().LayoutStyle) - self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide, - UiStrings().VersePerSlide) - self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerLine, - UiStrings().VersePerLine) - self.quickLayoutComboBox.setItemText(LayoutStyle.Continuous, - UiStrings().Continuous) + self.advancedSearchButton.setText(UiStrings().Search) def initialise(self): log.debug(u'bible manager initialise') @@ -303,28 +347,6 @@ class BibleMediaItem(MediaManagerItem): self.configUpdated() log.debug(u'bible manager initialise complete') - def onImportClick(self): - if not hasattr(self, u'import_wizard'): - self.import_wizard = BibleImportForm(self, self.parent.manager, - self.parent) - # If the import was not cancelled then reload. - if self.import_wizard.exec_(): - self.reloadBibles() - - def onSearchTabBarCurrentChanged(self, index): - if index == 0: - self.advancedTab.setVisible(False) - self.quickTab.setVisible(True) - else: - self.quickTab.setVisible(False) - self.advancedTab.setVisible(True) - - def onLockButtonToggled(self, checked): - if checked: - self.sender().setIcon(self.lockIcon) - else: - self.sender().setIcon(self.unlockIcon) - def loadBibles(self): log.debug(u'Loading Bibles') self.quickVersionComboBox.clear() @@ -422,6 +444,47 @@ class BibleMediaItem(MediaManagerItem): books.sort() add_widget_completer(books, self.quickSearchEdit) + def onImportClick(self): + if not hasattr(self, u'import_wizard'): + self.import_wizard = BibleImportForm(self, self.parent.manager, + self.parent) + # If the import was not cancelled then reload. + if self.import_wizard.exec_(): + self.reloadBibles() + + def onSearchTabBarCurrentChanged(self, index): + if index == 0: + self.advancedTab.setVisible(False) + self.quickTab.setVisible(True) + self.quickSearchEdit.setFocus() + else: + self.quickTab.setVisible(False) + self.advancedTab.setVisible(True) + + def onLockButtonToggled(self, checked): + if checked: + self.sender().setIcon(self.lockIcon) + else: + self.sender().setIcon(self.unlockIcon) + + def onQuickStyleComboBoxChanged(self): + self.settings.layout_style = self.quickStyleComboBox.currentIndex() + self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style) + self.settings.layoutStyleComboBox.setCurrentIndex( + self.settings.layout_style) + QtCore.QSettings().setValue( + self.settingsSection + u'/verse layout style', + QtCore.QVariant(self.settings.layout_style)) + + def onAdvancedStyleComboBoxChanged(self): + self.settings.layout_style = self.advancedStyleComboBox.currentIndex() + self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style) + self.settings.layoutStyleComboBox.setCurrentIndex( + self.settings.layout_style) + QtCore.QSettings().setValue( + self.settingsSection + u'/verse layout style', + QtCore.QVariant(self.settings.layout_style)) + def onAdvancedVersionComboBox(self): QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', QtCore.QVariant(self.advancedVersionComboBox.currentText())) @@ -582,30 +645,6 @@ class BibleMediaItem(MediaManagerItem): Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - def __checkSecondBible(self, bible, second_bible): - """ - Check if the first item is a second bible item or not. - """ - bitem = self.listView.item(0) - if not bitem.flags() & QtCore.Qt.ItemIsSelectable: - # The item is the "No Search Results" item. - self.listView.clear() - self.displayResults(bible, second_bible) - return - else: - item_second_bible = self._decodeQtObject(bitem, 'second_bible') - if item_second_bible and second_bible or not item_second_bible and \ - not second_bible: - self.displayResults(bible, second_bible) - elif critical_error_message_box( - message=translate('BiblePlugin.MediaItem', - 'You cannot combine single and dual Bible verse search results. ' - 'Do you want to delete your search results and start a new ' - 'search?'), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.listView.clear() - self.displayResults(bible, second_bible) - def displayResults(self, bible, second_bible=u''): """ Displays the search results in the media manager. All data needed for @@ -663,15 +702,6 @@ class BibleMediaItem(MediaManagerItem): self.search_results = {} self.second_search_results = {} - def _decodeQtObject(self, bitem, key): - reference = bitem.data(QtCore.Qt.UserRole) - if isinstance(reference, QtCore.QVariant): - reference = reference.toPyObject() - obj = reference[QtCore.QString(key)] - if isinstance(obj, QtCore.QVariant): - obj = obj.toPyObject() - return unicode(obj).strip() - def generateSlideData(self, service_item, item=None, xmlVersion=False): """ Generates and formats the slides for the service item as well as the @@ -866,11 +896,3 @@ class BibleMediaItem(MediaManagerItem): if self.settings.display_style == DisplayStyle.Square: return u'{su}[%s]{/su}' % verse_text return u'{su}%s{/su}' % verse_text - - def onLayoutStyleComboBoxChanged(self): - self.settings.layout_style = self.quickLayoutComboBox.currentIndex() - self.settings.layoutStyleComboBox.setCurrentIndex( - self.settings.layout_style) - QtCore.QSettings().setValue( - self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) From 6d1ec4ae108f50f83364c736153941e27e801536 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 15 May 2011 12:38:11 +0200 Subject: [PATCH 17/18] - prevent setting the loop delay spin box to 0 - Changed title for the stage view html --- openlp/core/ui/generaltab.py | 1 + openlp/core/ui/slidecontroller.py | 3 +-- openlp/plugins/remotes/html/stage.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index bd6a8e373..75cb8fa98 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -101,6 +101,7 @@ class GeneralTab(SettingsTab): self.timeoutLabel.setObjectName(u'timeoutLabel') self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox) self.timeoutSpinBox.setObjectName(u'timeoutSpinBox') + self.timeoutSpinBox.setRange(1, 180) self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox) self.leftLayout.addWidget(self.settingsGroupBox) self.leftLayout.addStretch() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 048b434ba..c298f897f 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -199,8 +199,7 @@ class SlideController(QtGui.QWidget): 'Start/Stop continuous loop')) self.addAction(self.toogleLoop) self.delaySpinBox = QtGui.QSpinBox() - self.delaySpinBox.setMinimum(1) - self.delaySpinBox.setMaximum(180) + self.delaySpinBox.setRange(1, 180) self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox) self.delaySpinBox.setSuffix(UiStrings().Seconds) self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', diff --git a/openlp/plugins/remotes/html/stage.html b/openlp/plugins/remotes/html/stage.html index 99090b6f9..9c74cc371 100644 --- a/openlp/plugins/remotes/html/stage.html +++ b/openlp/plugins/remotes/html/stage.html @@ -26,7 +26,7 @@ --> - OpenLP 2.0 Remote + OpenLP 2.0 Stage View From c728559862ae526c5c4ef44eb5c08629aa8cd420 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 15 May 2011 14:11:08 +0200 Subject: [PATCH 18/18] moved 'No Search Results' code --- openlp/core/lib/__init__.py | 22 ---------------------- openlp/core/lib/mediamanageritem.py | 15 ++++++++++++++- openlp/plugins/bibles/lib/mediaitem.py | 8 ++++---- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 1b001dfa7..27a34d54d 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -223,28 +223,6 @@ def resize_image(image, width, height, background=QtCore.Qt.black): painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) return new_image -def check_search_result(treeWidget, search_results): - """ - Checks if the given ``search_results`` is empty and adds a - "No Search Results" item to the given ``treeWidget``. - - ``treeWidget`` - The ``QTreeWidget`` where the "No Search Results" item should be added - to, if the ``search_results`` is empty. - - ``search_results`` - This can either be a list or a dict. - """ - if search_results or treeWidget.count(): - return - message = translate('OpenLP.MediaManagerItem', 'No Search Results') - item = QtGui.QListWidgetItem(message) - item.setFlags(QtCore.Qt.NoItemFlags) - font = QtGui.QFont() - font.setItalic(True) - item.setFont(font) - treeWidget.addItem(item) - def check_item_selected(list_widget, message): """ Check if a list item is selected so an action may be performed on it diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 99a42e3cf..9c1a84c99 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -244,7 +244,6 @@ class MediaManagerItem(QtGui.QWidget): """ # Add the List widget self.listView = ListWidgetWithDnD(self, self.plugin.name) - self.listView.setUniformItemSizes(True) self.listView.setSpacing(1) self.listView.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) @@ -552,6 +551,20 @@ class MediaManagerItem(QtGui.QWidget): """ pass + def check_search_result(self): + """ + Checks if the listView is empty and adds a "No Search Results" item. + """ + if self.listView.count(): + return + message = translate('OpenLP.MediaManagerItem', 'No Search Results') + item = QtGui.QListWidgetItem(message) + item.setFlags(QtCore.Qt.NoItemFlags) + font = QtGui.QFont() + font.setItalic(True) + item.setFont(font) + self.listView.addItem(item) + def _getIdOfItemToGenerate(self, item, remoteItem): """ Utility method to check items being submitted for slide generation. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 281f9bcc5..56821303a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, check_search_result + translate from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box @@ -63,7 +63,7 @@ class BibleMediaItem(MediaManagerItem): self.quickPreviewAllowed = True self.search_results = {} self.second_search_results = {} - check_search_result(self.listView, self.search_results) + self.check_search_result() QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles) @@ -537,7 +537,7 @@ class BibleMediaItem(MediaManagerItem): elif self.search_results: self.displayResults(bible, second_bible) self.advancedSearchButton.setEnabled(True) - check_search_result(self.listView, self.search_results) + self.check_search_result() Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') @@ -578,7 +578,7 @@ class BibleMediaItem(MediaManagerItem): elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) - check_search_result(self.listView, self.search_results) + self.check_search_result() Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3b014d4b0..8ac69392e 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, check_item_selected, PluginStatus, check_search_result + translate, check_item_selected, PluginStatus from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ @@ -199,7 +199,7 @@ class SongMediaItem(MediaManagerItem): search_results = self.parent.manager.get_all_objects(Song, Song.theme_name == search_keywords) self.displayResultsSong(search_results) - check_search_result(self.listView, search_results) + self.check_search_result() def onSongListLoad(self): """