From ddc2812ca241a93f7fc68d1ea65dd9530095c126 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 14 Jan 2011 18:33:48 +0100 Subject: [PATCH 001/104] removed file --- documentation/SongFormat.txt | 124 --------------------------------- openlp/plugins/songs/lib/db.py | 100 +++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 125 deletions(-) delete mode 100644 documentation/SongFormat.txt diff --git a/documentation/SongFormat.txt b/documentation/SongFormat.txt deleted file mode 100644 index 31b202dd6..000000000 --- a/documentation/SongFormat.txt +++ /dev/null @@ -1,124 +0,0 @@ -openlp.org 2.x Song Database Structure -======================================================================== - -Introduction ------------- -The song database in openlp.org 2.x is similar to the 1.x format. The -biggest differences are the addition of extra tables, and the use of -SQLite version 3. - -The song database contains the following tables: -- authors -- authors_songs -- song_books -- songs -- songs_topics -- topics - - -"authors" Table ---------------- -This table holds the names of all the authors. It has the following -columns: - -* id -* first_name -* last_name -* display_name - - -"authors_songs" Table ---------------------- -This is a bridging table between the "authors" and "songs" tables, which -serves to create a many-to-many relationship between the two tables. It -has the following columns: - -* author_id -* song_id - - -"song_books" Table ------------------- -The "song_books" table holds a list of books that a congregation gets -their songs from, or old hymnals now no longer used. This table has the -following columns: - -* id -* name -* publisher - - -"songs" Table -------------- -This table contains the songs, and each song has a list of attributes. -The "songs" table has the following columns: - -* id -* song_book_id -* title -* lyrics -* verse_order -* copyright -* comments -* ccli_number -* song_number -* theme_name -* search_title -* search_lyrics - - -"songs_topics" Table --------------------- -This is a bridging table between the "songs" and "topics" tables, which -serves to create a many-to-many relationship between the two tables. It -has the following columns: - -* song_id -* topic_id - - -"topics" Table --------------- -The topics table holds a selection of topics that songs can cover. This -is useful when a worship leader wants to select songs with a certain -theme. This table has the following columns: - -* id -* name - - -The lyrics definition (more or less similar to interformat to/from ChangingSong -The tags can also be used within the lyrics test. - -! Please note that this format has been checked at http://validator.w3.org/#validate_by_upload - - - Amazing Grace - - name of verse specific theme (optional) - any text (optional) - - Amazing grace, how ... - - - A b c - D e f - - ... - - - name of verse specific theme (optional) - any text (optional) - ... - - - - Erstaunliche Anmut - - Erstaunliche Anmut, wie - ... - - - ... - - diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index fc3aa06d1..14feca224 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -71,6 +71,104 @@ def init_schema(url): ``url`` The database to setup + + The song database is structured as follows:: + + The song database contains the following tables: + * authors + * authors_songs + * media_files + * media_files_songs + * song_books + * songs + * songs_topics + * topics + + + "authors" Table + --------------- + This table holds the names of all the authors. It has the following + columns: + + * id + * first_name + * last_name + * display_name + + + "authors_songs" Table + --------------------- + This is a bridging table between the "authors" and "songs" tables, which + serves to create a many-to-many relationship between the two tables. It + has the following columns: + + * author_id + * song_id + + "media_files" Table + ------------------- + + * id + * file_name + * type + + + "media_files_songs" Table + ------------------------- + + * media_file_id + * song_id + + + "song_books" Table + ------------------ + The "song_books" table holds a list of books that a congregation gets + their songs from, or old hymnals now no longer used. This table has the + following columns: + + * id + * name + * publisher + + + "songs" Table + ------------- + This table contains the songs, and each song has a list of attributes. + The "songs" table has the following columns: + + * id + * song_book_id + * title + * alternate_title + * lyrics + * verse_order + * copyright + * comments + * ccli_number + * song_number + * theme_name + * search_title + * search_lyrics + + + "songs_topics" Table + -------------------- + This is a bridging table between the "songs" and "topics" tables, which + serves to create a many-to-many relationship between the two tables. It + has the following columns: + + * song_id + * topic_id + + + "topics" Table + -------------- + The topics table holds a selection of topics that songs can cover. This + is useful when a worship leader wants to select songs with a certain + theme. This table has the following columns: + + * id + * name """ session, metadata = init_db(url) @@ -181,4 +279,4 @@ def init_schema(url): mapper(Topic, topics_table) metadata.create_all(checkfirst=True) - return session \ No newline at end of file + return session From 7ff2c27ad7433a71ea60ed8a201d76c64327e8ed Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 18 Jan 2011 17:42:59 +0100 Subject: [PATCH 002/104] cleaned doc --- openlp/plugins/songs/lib/db.py | 50 +++++++++++++--------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 14feca224..625466c09 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -39,6 +39,7 @@ class Author(BaseModel): """ pass + class Book(BaseModel): """ Book model @@ -47,34 +48,36 @@ class Book(BaseModel): return u'' % ( str(self.id), self.name, self.publisher) + class MediaFile(BaseModel): """ MediaFile model """ pass + class Song(BaseModel): """ Song model """ pass + class Topic(BaseModel): """ Topic model """ pass + def init_schema(url): """ - Setup the songs database connection and initialise the database schema + Setup the songs database connection and initialise the database schema. ``url`` The database to setup - The song database is structured as follows:: - - The song database contains the following tables: + The song database contains the following tables: * authors * authors_songs * media_files @@ -84,58 +87,47 @@ def init_schema(url): * songs_topics * topics - - "authors" Table + *authors* Table --------------- This table holds the names of all the authors. It has the following columns: - * id * first_name * last_name * display_name - - "authors_songs" Table + *authors_songs* Table --------------------- - This is a bridging table between the "authors" and "songs" tables, which + This is a bridging table between the *authors* and *songs* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * author_id * song_id - "media_files" Table + *media_files* Table ------------------- - * id * file_name * type - - "media_files_songs" Table + *media_files_songs* Table ------------------------- - * media_file_id * song_id - - "song_books" Table + *song_books* Table ------------------ - The "song_books" table holds a list of books that a congregation gets + The *song_books* table holds a list of books that a congregation gets their songs from, or old hymnals now no longer used. This table has the following columns: - * id * name * publisher - - "songs" Table + *songs* Table ------------- This table contains the songs, and each song has a list of attributes. - The "songs" table has the following columns: - + The *songs* table has the following columns: * id * song_book_id * title @@ -150,23 +142,19 @@ def init_schema(url): * search_title * search_lyrics - - "songs_topics" Table + *songs_topics* Table -------------------- - This is a bridging table between the "songs" and "topics" tables, which + This is a bridging table between the *songs* and *topics* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * song_id * topic_id - - "topics" Table + *topics* Table -------------- The topics table holds a selection of topics that songs can cover. This is useful when a worship leader wants to select songs with a certain theme. This table has the following columns: - * id * name """ From 1cc7c9ec396de85c6dc0ef6c538553dbf65546fa Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 22 Jan 2011 12:21:43 +0000 Subject: [PATCH 003/104] Cleanups --- openlp/core/utils/__init__.py | 6 +++--- openlp/plugins/alerts/alertsplugin.py | 8 +++----- openlp/plugins/alerts/forms/alertform.py | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9dd133852..37bd02a4e 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -140,7 +140,7 @@ class AppLocation(object): return _get_os_dir_path(u'openlp', os.path.join(os.getenv(u'HOME'), u'Library', u'Application Support', u'openlp'), - None, os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) + os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) @staticmethod def get_data_path(): @@ -163,8 +163,8 @@ class AppLocation(object): os.makedirs(path) return path -def _get_os_dir_path(win_option, darwin_option, base_dir_option, - non_base_dir_option, dir_type=1): +def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, + dir_type=1): """ Return a path based on which OS and environment we are running in. """ diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 61be922d5..54478b2c3 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -45,16 +45,14 @@ class AlertsPlugin(Plugin): self.icon = build_icon(u':/plugins/plugin_alerts.png') self.alertsmanager = AlertsManager(self) self.manager = Manager(u'alerts', init_schema) - visible_name = self.getString(StringContent.VisibleName) - self.alertForm = AlertForm(self, visible_name[u'title']) + self.visible_name = self.getString(StringContent.VisibleName) + self.alertForm = AlertForm(self) def getSettingsTab(self): """ Return the settings tab for the Alerts plugin """ - visible_name = self.getString(StringContent.VisibleName) - self.alertsTab = AlertsTab(self, visible_name[u'title']) - return self.alertsTab + return AlertsTab(self, self.visible_name[u'title']) def addToolsMenuItem(self, tools_menu): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 1d6a566fd..f1a0f7fea 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -35,7 +35,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ Provide UI for the alert system """ - def __init__(self, plugin, visible_title): + def __init__(self, plugin): """ Initialise the alert form """ From 7fc5bea107417ba8db6b11c4223113c51abbae9c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 22 Jan 2011 17:50:32 +0000 Subject: [PATCH 004/104] Couple of cleanups --- openlp/plugins/alerts/alertsplugin.py | 3 ++- openlp/plugins/presentations/lib/impresscontroller.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 54478b2c3..443ec1e84 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -52,7 +52,8 @@ class AlertsPlugin(Plugin): """ Return the settings tab for the Alerts plugin """ - return AlertsTab(self, self.visible_name[u'title']) + self.alertsTab = AlertsTab(self, self.visible_name[u'title']) + return self.alertsTab def addToolsMenuItem(self, tools_menu): """ diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 6ca67c2ae..f12d36dc8 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -171,11 +171,11 @@ class ImpressController(PresentationController): desktop = self.get_com_desktop() #Sometimes we get a failure and desktop is None if not desktop: - log.exception(u'Failed to terminate OpenOffice') + log.exception(u'Failed to find an OpenOffice desktop to terminate') return docs = desktop.getComponents() if docs.hasElements(): - log.debug(u'OpenOffice not terminated') + log.debug(u'OpenOffice not terminated as docs are still open') else: try: desktop.terminate() From 09aee63cd204ef23a816db15f05171533ca325d6 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 23 Jan 2011 00:27:29 +0000 Subject: [PATCH 005/104] Fix Windows AppLocation (Bug #706396) --- openlp/core/utils/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 37bd02a4e..22781f769 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -137,10 +137,7 @@ class AppLocation(object): os.path.split(openlp.__file__)[0]) return os.path.join(app_path, u'i18n') else: - return _get_os_dir_path(u'openlp', - os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp'), - os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) + return _get_os_dir_path(dir_type) @staticmethod def get_data_path(): @@ -163,16 +160,16 @@ class AppLocation(object): os.makedirs(path) return path -def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, - dir_type=1): +def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. """ if sys.platform == u'win32': - return os.path.join(os.getenv(u'APPDATA'), win_option) + return os.path.join(os.getenv(u'APPDATA', u'openlp') elif sys.platform == u'darwin': if dir_type == AppLocation.DataDir: - return os.path.join(darwin_option, u'Data') + return os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp', u'Data') return darwin_option else: if XDG_BASE_AVAILABLE: @@ -183,7 +180,7 @@ def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, elif dir_type == AppLocation.CacheDir: return os.path.join(BaseDirectory.xdg_cache_home, u'openlp') else: - return non_base_dir_option + return os.path.join(os.getenv(u'HOME'), u'.openlp') def _get_frozen_path(frozen_option, non_frozen_option): """ From 01826ddda8408f7c485220cb1b970ed0afc6071d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 23 Jan 2011 00:46:51 +0000 Subject: [PATCH 006/104] Fix fix --- openlp/core/utils/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 22781f769..37cbd7a63 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -165,12 +165,13 @@ def _get_os_dir_path(dir_type): Return a path based on which OS and environment we are running in. """ if sys.platform == u'win32': - return os.path.join(os.getenv(u'APPDATA', u'openlp') + return os.path.join(os.getenv(u'APPDATA'), u'openlp') elif sys.platform == u'darwin': if dir_type == AppLocation.DataDir: return os.path.join(os.getenv(u'HOME'), u'Library', u'Application Support', u'openlp', u'Data') - return darwin_option + return os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp') else: if XDG_BASE_AVAILABLE: if dir_type == AppLocation.ConfigDir: From 1df38b217db72bd82a751ec88af42de2f8c486a1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 23 Jan 2011 07:56:58 +0100 Subject: [PATCH 007/104] improved selection behaviour; clean ups --- openlp/core/ui/servicemanager.py | 126 +++++++++++++++---------------- 1 file changed, 60 insertions(+), 66 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b9f9fe53d..d1a3e6762 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -603,7 +603,7 @@ class ServiceManager(QtGui.QWidget): if self.serviceNoteForm.exec_(): self.serviceItems[item][u'service_item'].notes = \ self.serviceNoteForm.textEdit.toPlainText() - self.repaintServiceList(item, 0) + self.repaintServiceList(item, -1) def onServiceItemEditForm(self): item = self.findServiceItem()[0] @@ -615,8 +615,7 @@ class ServiceManager(QtGui.QWidget): def nextItem(self): """ - Called by the SlideController to select the - next service item + Called by the SlideController to select the next service item. """ if len(self.serviceManagerList.selectedItems()) == 0: return @@ -634,8 +633,7 @@ class ServiceManager(QtGui.QWidget): def previousItem(self): """ - Called by the SlideController to select the - previous service item + Called by the SlideController to select the previous service item. """ if len(self.serviceManagerList.selectedItems()) == 0: return @@ -654,13 +652,13 @@ class ServiceManager(QtGui.QWidget): def onSetItem(self, message): """ - Called by a signal to select a specific item + Called by a signal to select a specific item. """ self.setItem(int(message[0])) def setItem(self, index): """ - Makes a specific item in the service live + Makes a specific item in the service live. """ if index >= 0 and index < self.serviceManagerList.topLevelItemCount: item = self.serviceManagerList.topLevelItem(index) @@ -669,8 +667,7 @@ class ServiceManager(QtGui.QWidget): def onMoveSelectionUp(self): """ - Moves the selection up the window - Called by the up arrow + Moves the selection up the window. Called by the up arrow. """ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) tempItem = None @@ -695,8 +692,7 @@ class ServiceManager(QtGui.QWidget): def onMoveSelectionDown(self): """ - Moves the selection down the window - Called by the down arrow + Moves the selection down the window. Called by the down arrow. """ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) firstItem = None @@ -718,7 +714,7 @@ class ServiceManager(QtGui.QWidget): def onCollapseAll(self): """ - Collapse all the service items + Collapse all the service items. """ for item in self.serviceItems: item[u'expanded'] = False @@ -726,15 +722,15 @@ class ServiceManager(QtGui.QWidget): def collapsed(self, item): """ - Record if an item is collapsed - Used when repainting the list to get the correct state + Record if an item is collapsed. Used when repainting the list to get the + correct state. """ pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] self.serviceItems[pos -1 ][u'expanded'] = False def onExpandAll(self): """ - Collapse all the service items + Collapse all the service items. """ for item in self.serviceItems: item[u'expanded'] = True @@ -742,70 +738,68 @@ class ServiceManager(QtGui.QWidget): def expanded(self, item): """ - Record if an item is collapsed - Used when repainting the list to get the correct state + Record if an item is collapsed. Used when repainting the list to get the + correct state. """ pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] self.serviceItems[pos -1 ][u'expanded'] = True def onServiceTop(self): """ - Move the current ServiceItem to the top of the list + Move the current ServiceItem to the top of the list. """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if item < len(self.serviceItems) and item is not -1: temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(0, temp) - self.repaintServiceList(0, count) + self.repaintServiceList(0, child) self.setModified(True) def onServiceUp(self): """ - Move the current ServiceItem up in the list - Note move up means move to top of area ie 0. + Move the current ServiceItem one position up in the list. """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if item > 0: temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item - 1, temp) - self.repaintServiceList(item - 1, count) + self.repaintServiceList(item - 1, child) self.setModified(True) def onServiceDown(self): """ - Move the current ServiceItem down in the list - Note move down means move to bottom of area i.e len(). + Move the current ServiceItem one position down in the list. """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if item < len(self.serviceItems) and item is not -1: temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item + 1, temp) - self.repaintServiceList(item + 1, count) + self.repaintServiceList(item + 1, child) self.setModified(True) def onServiceEnd(self): """ - Move the current ServiceItem to the bottom of the list + Move the current ServiceItem to the bottom of the list. """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if item < len(self.serviceItems) and item is not -1: temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(len(self.serviceItems), temp) - self.repaintServiceList(len(self.serviceItems) - 1, count) + self.repaintServiceList(len(self.serviceItems) - 1, child) self.setModified(True) def onDeleteFromService(self): """ - Remove the current ServiceItem from the list + Remove the current ServiceItem from the list. """ item = self.findServiceItem()[0] - if item is not -1: + if item != -1: self.serviceItems.remove(self.serviceItems[item]) - self.repaintServiceList(0, 0) + self.repaintServiceList(item - 1, -1) self.setModified(True) def repaintServiceList(self, serviceItem, serviceItemChild): @@ -867,7 +861,7 @@ class ServiceManager(QtGui.QWidget): def validateItem(self, serviceItem): """ Validates the service item and if the suffix matches an accepted - one it allows the item to be displayed + one it allows the item to be displayed. """ if serviceItem.is_command(): type = serviceItem._raw_frames[0][u'title'].split(u'.')[1] @@ -876,7 +870,7 @@ class ServiceManager(QtGui.QWidget): def cleanUp(self): """ - Empties the servicePath of temporary files + Empties the servicePath of temporary files. """ for file in os.listdir(self.servicePath): file_path = os.path.join(self.servicePath, file) @@ -884,7 +878,7 @@ class ServiceManager(QtGui.QWidget): def onThemeComboBoxSelected(self, currentIndex): """ - Set the theme for the current service + Set the theme for the current service. """ log.debug(u'onThemeComboBoxSelected') self.service_theme = unicode(self.themeComboBox.currentText()) @@ -967,12 +961,12 @@ class ServiceManager(QtGui.QWidget): # if not passed set to config value if expand is None: expand = self.expandTabs - sitem = self.findServiceItem()[0] item.render() if replace: + sitem, child = self.findServiceItem() item.merge(self.serviceItems[sitem][u'service_item']) self.serviceItems[sitem][u'service_item'] = item - self.repaintServiceList(sitem, 0) + self.repaintServiceList(sitem, child) self.mainwindow.liveController.replaceServiceManagerItem(item) else: # nothing selected for dnd @@ -981,17 +975,17 @@ class ServiceManager(QtGui.QWidget): for inditem in item: self.serviceItems.append({u'service_item': inditem, u'order': len(self.serviceItems) + 1, - u'expanded':expand}) + u'expanded': expand}) else: self.serviceItems.append({u'service_item': item, u'order': len(self.serviceItems) + 1, - u'expanded':expand}) - self.repaintServiceList(len(self.serviceItems) + 1, 0) + u'expanded': expand}) + self.repaintServiceList(len(self.serviceItems) - 1, -1) else: self.serviceItems.insert(self.dropPosition, {u'service_item': item, u'order': self.dropPosition, - u'expanded':expand}) - self.repaintServiceList(self.dropPosition, 0) + u'expanded': expand}) + self.repaintServiceList(self.dropPosition, -1) # if rebuilding list make sure live is fixed. if rebuild: self.mainwindow.liveController.replaceServiceManagerItem(item) @@ -1002,15 +996,15 @@ class ServiceManager(QtGui.QWidget): """ Send the current item to the Preview slide controller """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if self.serviceItems[item][u'service_item'].is_valid: self.mainwindow.previewController.addServiceManagerItem( - self.serviceItems[item][u'service_item'], count) + self.serviceItems[item][u'service_item'], child) else: criticalErrorMessageBox( translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be ' - 'displayed as there is no handler to display it')) + 'displayed as there is no handler to display it')) def getServiceItem(self): """ @@ -1026,10 +1020,10 @@ class ServiceManager(QtGui.QWidget): """ Send the current item to the Live slide controller """ - item, count = self.findServiceItem() + item, child = self.findServiceItem() if self.serviceItems[item][u'service_item'].is_valid: self.mainwindow.liveController.addServiceManagerItem( - self.serviceItems[item][u'service_item'], count) + self.serviceItems[item][u'service_item'], child) if QtCore.QSettings().value( self.mainwindow.generalSettingsSection + u'/auto preview', QtCore.QVariant(False)).toBool(): @@ -1060,26 +1054,26 @@ class ServiceManager(QtGui.QWidget): def findServiceItem(self): """ - Finds a ServiceItem in the list and returns the position of the - serviceitem and its selected child item. For example, if the third child - item (in the Slidecontroller known as slide) in the second service item - is selected this will return:: + Finds the selected ServiceItem in the list and returns the position of + the serviceitem and its selected child item. For example, if the third + child item (in the Slidecontroller known as slide) in the second service + item is selected this will return:: (1, 2) """ items = self.serviceManagerList.selectedItems() - pos = 0 - count = -1 + serviceItem = 0 + serviceItemChild = -1 for item in items: parentitem = item.parent() if parentitem is None: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = item.data(0, QtCore.Qt.UserRole).toInt()[0] else: - pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - count = item.data(0, QtCore.Qt.UserRole).toInt()[0] - # adjust for zero based arrays - pos = pos - 1 - return pos, count + serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0] + # Adjust for zero based arrays. + serviceItem -= 1 + return serviceItem, serviceItemChild def dragEnterEvent(self, event): """ @@ -1105,7 +1099,7 @@ class ServiceManager(QtGui.QWidget): item = self.serviceManagerList.itemAt(event.pos()) # ServiceManager started the drag and drop if plugin == u'ServiceManager': - startpos, startCount = self.findServiceItem() + startpos, child = self.findServiceItem() # If no items selected if startpos == -1: return @@ -1116,7 +1110,7 @@ class ServiceManager(QtGui.QWidget): serviceItem = self.serviceItems[startpos] self.serviceItems.remove(serviceItem) self.serviceItems.insert(endpos, serviceItem) - self.repaintServiceList(endpos, startCount) + self.repaintServiceList(endpos, child) else: # we are not over anything so drop replace = False @@ -1182,9 +1176,9 @@ class ServiceManager(QtGui.QWidget): def listRequest(self, message=None): data = [] - curindex = self.findServiceItem()[0] - if curindex >= 0 and curindex < len(self.serviceItems): - curitem = self.serviceItems[curindex] + item = self.findServiceItem()[0] + if item >= 0 and item < len(self.serviceItems): + curitem = self.serviceItems[item] else: curitem = None for item in self.serviceItems: From a0746c08656334e6d27f1dc09bc768776b4df8da Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 08:25:21 +0000 Subject: [PATCH 008/104] Fix theme editor losing options --- openlp/core/ui/maindisplay.py | 8 +++++--- openlp/core/ui/themeform.py | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 911aeda10..b0280f19b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -67,6 +67,7 @@ class MainDisplay(DisplayWidget): self.isLive = live self.alertTab = None self.hideMode = None + self.override_image = None mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') self.setWindowIcon(mainIcon) self.retranslateUi() @@ -205,14 +206,15 @@ class MainDisplay(DisplayWidget): """ self.imageManager.add_image(name, path) self.image(name) + self.override_image = name def image(self, name): """ - Add an image as the background. The image is converted to a bytestream - on route. + Add an image as the background. The image has already been added + to the cache. `Image` - The Image to be displayed can be QImage or QPixmap + The name of the image to be displayed """ log.debug(u'image to display') image = self.imageManager.get_image_bytes(name) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 2db76063c..60c1b97bc 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -250,25 +250,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Change state as Outline check box changed """ - if state == QtCore.Qt.Checked: - self.theme.font_main_outline = True - else: - self.theme.font_main_outline = False - self.outlineColorButton.setEnabled(self.theme.font_main_outline) - self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline) - self.calculateLines() + if self.updateThemeAllowed: + if state == QtCore.Qt.Checked: + self.theme.font_main_outline = True + else: + self.theme.font_main_outline = False + self.outlineColorButton.setEnabled(self.theme.font_main_outline) + self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline) + self.calculateLines() def onShadowCheckCheckBoxStateChanged(self, state): """ Change state as Shadow check box changed """ - if state == QtCore.Qt.Checked: - self.theme.font_main_shadow = True - else: - self.theme.font_main_shadow = False - self.shadowColorButton.setEnabled(self.theme.font_main_shadow) - self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow) - self.calculateLines() + if self.updateThemeAllowed: + if state == QtCore.Qt.Checked: + self.theme.font_main_shadow = True + else: + self.theme.font_main_shadow = False + self.shadowColorButton.setEnabled(self.theme.font_main_shadow) + self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow) + self.calculateLines() def onMainPositionCheckBoxStateChanged(self, value): """ From 8252e504e191078676ea62723bb2b9fbe092b1ca Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 14:08:49 +0000 Subject: [PATCH 009/104] Preserve replacement backgrounds - start --- openlp/core/lib/htmlbuilder.py | 7 ++++-- openlp/core/ui/maindisplay.py | 44 +++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 86056f4b5..83f941d11 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -297,6 +297,7 @@ body { function show_text_complete(){ return (text_opacity()==1); } + @@ -314,7 +315,7 @@ body { """ -def build_html(item, screen, alert, islive): +def build_html(item, screen, alert, islive, background): """ Build the full web paged structure for display @@ -332,7 +333,9 @@ def build_html(item, screen, alert, islive): theme = item.themedata webkitvers = webkit_version() # Image generated and poked in - if item.bg_image_bytes: + if background: + image = u'src="data:image/png;base64,%s"' % background + elif item.bg_image_bytes: image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes else: image = u'style="display:none;"' diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index cfad9cd91..e9ef449fa 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -67,7 +67,7 @@ class MainDisplay(DisplayWidget): self.isLive = live self.alertTab = None self.hideMode = None - self.override_image = None + self.override = {} mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') self.setWindowIcon(mainIcon) self.retranslateUi() @@ -112,7 +112,7 @@ class MainDisplay(DisplayWidget): self.page = self.webView.page() self.frame = self.page.mainFrame() QtCore.QObject.connect(self.webView, - QtCore.SIGNAL(u'loadFinished(bool)'), self.isLoaded) + QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.frame.setScrollBarPolicy(QtCore.Qt.Vertical, @@ -138,14 +138,14 @@ class MainDisplay(DisplayWidget): painter_image.begin(initialFrame) painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white) painter_image.drawImage( - (self.screens.current[u'size'].width() - + (self.screens.current[u'size'].width() - splash_image.width()) / 2, (self.screens.current[u'size'].height() - splash_image.height()) / 2, splash_image) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, - self.parent.alertTab, self.isLive)) + self.parent.alertTab, self.isLive, None)) self.initialFrame = True # To display or not to display? if not self.screen[u'primary']: @@ -163,7 +163,7 @@ class MainDisplay(DisplayWidget): """ log.debug(u'text to display') # Wait for the webview to update before displaying text. - while not self.loaded: + while not self.webLoaded: Receiver.send_message(u'openlp_process_events') self.frame.evaluateJavaScript(u'show_text("%s")' % \ slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) @@ -205,7 +205,9 @@ class MainDisplay(DisplayWidget): """ self.imageManager.add_image(name, path) self.image(name) - self.override_image = name + if hasattr(self, u'serviceItem'): + self.override[u'image'] = name + self.override[u'theme'] = self.serviceItem.themedata.theme_name def image(self, name): """ @@ -315,7 +317,7 @@ class MainDisplay(DisplayWidget): Loads and starts a video to run with the option of sound """ log.debug(u'video') - self.loaded = True + self.webLoaded = True vol = float(volume)/float(10) if isBackground or not self.usePhonon: js = u'show_video("init", "%s", %s, true); show_video("play");' % \ @@ -335,12 +337,12 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'maindisplay_active') return self.preview() - def isLoaded(self): + def isWebLoaded(self): """ Called by webView event to show display is fully loaded """ - log.debug(u'loaded') - self.loaded = True + log.debug(u'Webloaded') + self.webLoaded = True def preview(self): """ @@ -359,7 +361,7 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'openlp_process_events') # Wait for the webview to update before geting the preview. # Important otherwise first preview will miss the background ! - while not self.loaded: + while not self.webLoaded: Receiver.send_message(u'openlp_process_events') # if was hidden keep it hidden if self.isLive: @@ -381,18 +383,32 @@ class MainDisplay(DisplayWidget): HTML to the display """ log.debug(u'buildHtml') - self.loaded = False + self.webLoaded = False self.initialFrame = False self.serviceItem = serviceItem + background = None + # We have an image override so keep the image till the theme changes + if self.override: + if self.override[u'theme'] != \ + serviceItem.themedata.theme_name: + Receiver.send_message(u'live_theme_changed') + self.override = {} + else: + background = self.imageManager. \ + get_image_bytes(self.override[u'image']) + # We have an video override so allow it to be stopped + if self.override and u'video' in self.override: + Receiver.send_message(u'video_background_replaced') + self.override = {} if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) html = build_html(self.serviceItem, self.screen, self.parent.alertTab, - self.isLive) + self.isLive, background) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml') - if serviceItem.foot_text and serviceItem.foot_text: + if serviceItem.foot_text: self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive: From 40717797927f8fcc8588f793977e40314cf70205 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 23 Jan 2011 14:33:50 +0000 Subject: [PATCH 010/104] Added the option to disable the update check on start up. (I think it defualts to false) --- openlp.pyw | 7 +++++-- openlp/core/ui/generaltab.py | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 017e12774..8d20080c9 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -194,7 +194,10 @@ class OpenLP(QtGui.QApplication): # now kill the splashscreen self.splash.finish(self.mainWindow) self.mainWindow.repaint() - VersionThread(self.mainWindow, app_version).start() + update_check = QtCore.QSettings().value( + u'general/update check', QtCore.QVariant(True)).toBool() + if update_check: + VersionThread(self.mainWindow, app_version).start() return self.exec_() def hookException(self, exctype, value, traceback): @@ -280,4 +283,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() \ No newline at end of file + main() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 773637481..686abcaaa 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -113,6 +113,9 @@ class GeneralTab(SettingsTab): self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') self.startupLayout.addWidget(self.showSplashCheckBox) + self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') + self.startupLayout.addWidget(self.checkForUpdatesCheckBox) self.leftLayout.addWidget(self.startupGroupBox) self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn) self.settingsGroupBox.setObjectName(u'settingsGroupBox') @@ -249,6 +252,8 @@ class GeneralTab(SettingsTab): 'Automatically open the last service')) self.showSplashCheckBox.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) + self.checkForUpdatesCheckBox.setText( + translate('OpenLP.GeneralTab', 'Check for updates')) self.settingsGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', @@ -317,6 +322,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(False)).toBool()) self.showSplashCheckBox.setChecked(settings.value(u'show splash', QtCore.QVariant(True)).toBool()) + self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', + QtCore.QVariant(True)).toBool()) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', QtCore.QVariant(False)).toBool()) self.timeoutSpinBox.setValue(settings.value(u'loop delay', @@ -363,6 +370,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.autoOpenCheckBox.isChecked())) settings.setValue(u'show splash', QtCore.QVariant(self.showSplashCheckBox.isChecked())) + settings.setValue(u'update check', + QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked())) settings.setValue(u'save prompt', QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked())) settings.setValue(u'auto preview', From 33a924a243f12d2fdcec6451ecd30271deadab1f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 15:36:15 +0000 Subject: [PATCH 011/104] Preserve replacement backgrounds - finish --- openlp/core/lib/htmlbuilder.py | 1 - openlp/core/ui/maindisplay.py | 13 ++++++++----- openlp/plugins/images/lib/mediaitem.py | 11 +++++++++-- openlp/plugins/media/lib/mediaitem.py | 11 ++++++++++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 83f941d11..ea830855c 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -297,7 +297,6 @@ body { function show_text_complete(){ return (text_opacity()==1); } - diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e9ef449fa..c0e5dd509 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -318,6 +318,9 @@ class MainDisplay(DisplayWidget): """ log.debug(u'video') self.webLoaded = True + # We are running a background theme + self.override[u'theme'] = u'' + self.override[u'video'] = True vol = float(volume)/float(10) if isBackground or not self.usePhonon: js = u'show_video("init", "%s", %s, true); show_video("play");' % \ @@ -389,17 +392,17 @@ class MainDisplay(DisplayWidget): background = None # We have an image override so keep the image till the theme changes if self.override: - if self.override[u'theme'] != \ + # We have an video override so allow it to be stopped + if u'video' in self.override: + Receiver.send_message(u'video_background_replaced') + self.override = {} + elif self.override[u'theme'] != \ serviceItem.themedata.theme_name: Receiver.send_message(u'live_theme_changed') self.override = {} else: background = self.imageManager. \ get_image_bytes(self.override[u'image']) - # We have an video override so allow it to be stopped - if self.override and u'video' in self.override: - Receiver.send_message(u'video_background_replaced') - self.override = {} if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index bd84219fb..4f976bd51 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \ - check_directory_exists + check_directory_exists, Receiver from openlp.core.ui import criticalErrorMessageBox from openlp.core.utils import AppLocation, delete_file, get_images_filter @@ -44,7 +44,6 @@ class ImageListView(BaseListWithDnD): self.PluginName = u'Images' BaseListWithDnD.__init__(self, parent) - class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. @@ -57,6 +56,8 @@ class ImageMediaItem(MediaManagerItem): # be instanced by the base MediaManagerItem. self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, self, icon) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) def retranslateUi(self): self.OnNewPrompt = translate('ImagePlugin.MediaItem', @@ -193,6 +194,12 @@ class ImageMediaItem(MediaManagerItem): self.resetAction.setVisible(False) self.parent.liveController.display.resetImage() + def liveThemeChanged(self): + """ + Triggered by the change of theme in the slide controller + """ + self.resetAction.setVisible(False) + def onReplaceClick(self): """ Called to replace Live backgound with the image selected. diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 121fa80a0..1b5d6b8d8 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - ItemCapabilities, SettingsManager, translate, check_item_selected + ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver from openlp.core.ui import criticalErrorMessageBox log = logging.getLogger(__name__) @@ -58,6 +58,9 @@ class MediaMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False self.serviceItemIconName = u':/media/image_clapperboard.png' + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'video_background_replaced'), + self.videobackgroundReplaced) def retranslateUi(self): self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') @@ -99,6 +102,12 @@ class MediaMediaItem(MediaManagerItem): self.resetAction.setVisible(False) self.parent.liveController.display.resetVideo() + def videobackgroundReplaced(self): + """ + Triggered by main display on change of serviceitem + """ + self.resetAction.setVisible(False) + def onReplaceClick(self): """ Called to replace Live backgound with the media selected. From 323cb4f001fee3e0d08e35f2330f73ae261919a6 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 23 Jan 2011 15:55:59 +0000 Subject: [PATCH 012/104] Description of check box changed --- openlp/core/ui/generaltab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 686abcaaa..edace883f 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -253,7 +253,7 @@ class GeneralTab(SettingsTab): self.showSplashCheckBox.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) self.checkForUpdatesCheckBox.setText( - translate('OpenLP.GeneralTab', 'Check for updates')) + translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settingsGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', From ed2d7355ed1e7375cd9c6d962c62f430ff589672 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 24 Jan 2011 17:26:13 +0000 Subject: [PATCH 013/104] Miss a reset --- openlp/core/ui/maindisplay.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c0e5dd509..3dfde8640 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -248,6 +248,7 @@ class MainDisplay(DisplayWidget): self.displayImage(self.serviceItem.bg_image_bytes) else: self.displayImage(None) + self.override = {} # Update the preview frame. Receiver.send_message(u'maindisplay_active') @@ -264,6 +265,7 @@ class MainDisplay(DisplayWidget): self.phononActive = False else: self.frame.evaluateJavaScript(u'show_video("close");') + self.override = {} # Update the preview frame. Receiver.send_message(u'maindisplay_active') From 03fc07cabf8dc38483e91ef8716cbfc675919813 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 25 Jan 2011 01:19:57 +0000 Subject: [PATCH 014/104] Fix for NGÜ bible --- openlp/plugins/bibles/resources/bibleserver.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/resources/bibleserver.csv b/openlp/plugins/bibles/resources/bibleserver.csv index c0d109f97..942d43116 100644 --- a/openlp/plugins/bibles/resources/bibleserver.csv +++ b/openlp/plugins/bibles/resources/bibleserver.csv @@ -19,7 +19,7 @@ IBS-fordítás (Új Károli), KAR King James Version, KJV Luther 1984, LUT Septuaginta, LXX -Neue Genfer Übersetzung, NGÜ +Neue Genfer Übersetzung, NGU New International Readers Version, NIRV New International Version, NIV Neues Leben, NL From c0eccc4b857e2bbbb38bc2fb48dbeea6fae3ed28 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 25 Jan 2011 04:42:15 +0000 Subject: [PATCH 015/104] Fix theme editing --- openlp/core/lib/mediamanageritem.py | 10 +++------- openlp/core/ui/themeform.py | 18 +++++------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5799a3f41..9565a9b37 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -98,13 +98,9 @@ class MediaManagerItem(QtGui.QWidget): visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) self.settingsSection = self.plugin.name.lower() - if isinstance(icon, QtGui.QIcon): - self.icon = icon - elif isinstance(icon, basestring): - self.icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - else: - self.icon = None + self.icon = None + if icon: + self.icon = build_icon(icon) self.toolbar = None self.remoteTriggered = None self.serviceItemIconName = None diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 60c1b97bc..43f1034f4 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -55,7 +55,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.thememanager = parent self.setupUi(self) self.registerFields() - self.accepted = False self.updateThemeAllowed = True QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), @@ -120,14 +119,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QObject.connect(self.mainFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.calculateLines) - QtCore.QObject.connect(self, QtCore.SIGNAL(u'accepted()'), self.accept) def setDefaults(self): """ Set up display at start of theme edit. """ self.restart() - self.accepted = False self.setBackgroundPageValues() self.setMainAreaPageValues() self.setFooterAreaPageValues() @@ -448,9 +445,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Background gradient Combo box has changed. """ - self.theme.background_direction = \ - BackgroundGradientType.to_string(index) - self.setBackgroundPageValues() + if self.updateThemeAllowed: + self.theme.background_direction = \ + BackgroundGradientType.to_string(index) + self.setBackgroundPageValues() def onColorButtonClicked(self): """ @@ -562,13 +560,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Lets save the them as Finish has been pressed """ - # Some reason getting double submission. - # Hack to stop it for now. - if self.accepted: - return # Save the theme name - self.theme.theme_name = \ - unicode(self.field(u'name').toString()) + self.theme.theme_name = unicode(self.field(u'name').toString()) if not self.theme.theme_name: criticalErrorMessageBox( translate('OpenLP.ThemeForm', 'Theme Name Missing'), @@ -592,7 +585,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): if not self.edit_mode and \ not self.thememanager.checkIfThemeExists(self.theme.theme_name): return - self.accepted = True self.thememanager.saveTheme(self.theme, saveFrom, saveTo) return QtGui.QDialog.accept(self) From f484286f8a0eff4a63793ed474ae5c1304579bbb Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 02:43:16 +0000 Subject: [PATCH 016/104] Few cleanups --- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/songs/lib/easislidesimport.py | 10 +++++----- openlp/plugins/songs/lib/importer.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 63c6954fb..85204ac7a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -92,7 +92,7 @@ class BibleFormat(object): return None @staticmethod - def list(): + def get_formats_list(): """ Return a list of the supported Bible formats. """ diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 64523fd3a..84e7a3841 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -314,11 +314,11 @@ class EasiSlidesImport(SongImport): pass def _listHas(self, lst, subitems): - for i in subitems: - if type(lst) == type({}) and lst.has_key(i): - lst = lst[i] - elif type(lst) == type([]) and i in lst: - lst = lst[i] + for subitem in subitems: + if isinstance(lst, dict) and lst.has_key(subitem): + lst = lst[subitem] + elif isinstance(lst, list) and subitem in lst: + lst = lst[subitem] else: return False return True diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 91d3d7e6f..6f566ff4f 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -105,7 +105,7 @@ class SongFormat(object): return None @staticmethod - def list(): + def get_formats_list(): """ Return a list of the supported song formats. """ From df9bd3b3a2cf37cdd7cca32f4111ec820e23fdba Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 16:05:55 +0000 Subject: [PATCH 017/104] Cleanup modified service messages --- openlp/core/ui/mainwindow.py | 15 +++------------ openlp/core/ui/servicemanager.py | 28 ++++++++++------------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index db9d4f9d5..d8bedade3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -563,10 +563,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.ServiceManagerContents.onLoadServiceClicked) QtCore.QObject.connect(self.FileSaveItem, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onSaveServiceClicked) + self.ServiceManagerContents.saveFile) QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onSaveServiceAsClicked) + self.ServiceManagerContents.saveFileAs) # i18n set signals for languages QtCore.QObject.connect(self.AutoLanguageItem, QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) @@ -807,15 +807,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Hook to close the main window and display windows on exit """ if self.ServiceManagerContents.isModified(): - ret = QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', 'Save Changes to Service?'), - translate('OpenLP.MainWindow', 'Your service has changed. ' - 'Do you want to save those changes?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Cancel | - QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Save), - QtGui.QMessageBox.Save) + ret = self.ServiceManagerContents.saveModifiedService() if ret == QtGui.QMessageBox.Save: if self.ServiceManagerContents.saveFile(): self.cleanUp() @@ -847,7 +839,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.cleanUp() event.accept() - def cleanUp(self): """ Runs all the cleanup code before OpenLP shuts down diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a3e6762..7f1d6493e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -108,7 +108,7 @@ class ServiceManager(QtGui.QWidget): translate('OpenLP.ServiceManager', 'Save Service'), u':/general/general_save.png', translate('OpenLP.ServiceManager', 'Save this service'), - self.onSaveServiceClicked) + self.saveFile) self.toolbar.addSeparator() self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager', 'Theme:'), self) @@ -361,12 +361,7 @@ class ServiceManager(QtGui.QWidget): Create a new service. """ if self.isModified(): - result = QtGui.QMessageBox.question(self.mainwindow, - translate('OpenLP.ServiceManager', 'Save Changes'), - translate('OpenLP.ServiceManager', 'The current service has ' - 'been modified, would you like to save it?'), - QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) + result = self.saveModifiedService() if result == QtGui.QMessageBox.Cancel: return False elif result == QtGui.QMessageBox.Save: @@ -376,12 +371,7 @@ class ServiceManager(QtGui.QWidget): def onLoadServiceClicked(self): if self.isModified(): - result = QtGui.QMessageBox.question(self.mainwindow, - translate('OpenLP.ServiceManager', 'Save Changes'), - translate('OpenLP.ServiceManager', 'The current service has ' - 'been modified, would you like to save it?'), - QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) + result = self.saveModifiedService() if result == QtGui.QMessageBox.Cancel: return False elif result == QtGui.QMessageBox.Save: @@ -397,11 +387,13 @@ class ServiceManager(QtGui.QWidget): split_filename(fileName)[0]) self.loadFile(fileName) - def onSaveServiceClicked(self): - self.saveFile() - - def onSaveServiceAsClicked(self): - self.saveFileAs() + def saveModifiedService(self): + return QtGui.QMessageBox.question(self.mainwindow, + translate('OpenLP.ServiceManager', 'Modified Service'), + translate('OpenLP.ServiceManager', 'The current service has ' + 'been modified. Would you like to save this service?'), + QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | + QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) def onRecentServiceClicked(self): sender = self.sender() From 51812f21de24aae47772c927a0b8c9643fd4fb57 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 17:13:26 +0000 Subject: [PATCH 018/104] Stop redefining builtins and docstrings --- openlp/core/lib/spelltextedit.py | 42 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 82391a0b3..44180a25c 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -47,13 +47,16 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Default dictionary based on the current locale. if ENCHANT_AVAILABLE: try: - self.dict = enchant.Dict() + self.dictionary = enchant.Dict() except DictNotFoundError: - self.dict = enchant.Dict(u'en_US') + self.dictionary = enchant.Dict(u'en_US') self.highlighter = Highlighter(self.document()) - self.highlighter.setDict(self.dict) + self.highlighter.spellingDictionary = self.dictionary def mousePressEvent(self, event): + """ + Handle mouse clicks within the text edit region. + """ if event.button() == QtCore.Qt.RightButton: # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. @@ -63,6 +66,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit): QtGui.QPlainTextEdit.mousePressEvent(self, event) def contextMenuEvent(self, event): + """ + Provide the context menu for the text edit region. + """ popupMenu = self.createStandardContextMenu() # Select the word under the cursor. cursor = self.textCursor() @@ -74,10 +80,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # suggestions if it is. if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): text = unicode(self.textCursor().selectedText()) - if not self.dict.check(text): + if not self.dictionary.check(text): spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) - for word in self.dict.suggest(text): + for word in self.dictionary.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correctWord) spell_menu.addAction(action) @@ -126,28 +132,32 @@ class SpellTextEdit(QtGui.QPlainTextEdit): cursor.insertText(html[u'start tag']) cursor.insertText(html[u'end tag']) -class Highlighter(QtGui.QSyntaxHighlighter): +class Highlighter(QtGui.QSyntaxHighlighter): + """ + Provides a text highlighter for pointing out spelling errors in text. + """ WORDS = u'(?iu)[\w\']+' def __init__(self, *args): QtGui.QSyntaxHighlighter.__init__(self, *args) - self.dict = None - - def setDict(self, dict): - self.dict = dict + self.spellingDictionary = None def highlightBlock(self, text): - if not self.dict: + """ + Highlight misspelt words in a block of text + """ + if not self.spellingDictionary: return text = unicode(text) - format = QtGui.QTextCharFormat() - format.setUnderlineColor(QtCore.Qt.red) - format.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline) + charFormat = QtGui.QTextCharFormat() + charFormat.setUnderlineColor(QtCore.Qt.red) + charFormat.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline) for word_object in re.finditer(self.WORDS, text): - if not self.dict.check(word_object.group()): + if not self.spellingDictionary.check(word_object.group()): self.setFormat(word_object.start(), - word_object.end() - word_object.start(), format) + word_object.end() - word_object.start(), charFormat) + class SpellAction(QtGui.QAction): """ From fbaa6678a975045e83a5d10cae8c186a9dd28518 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 26 Jan 2011 18:00:46 +0000 Subject: [PATCH 019/104] Up is Up and Down is Up ? --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a3e6762..14fe7a629 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -179,7 +179,7 @@ class ServiceManager(QtGui.QWidget): None, translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), - self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Up) + self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), From 934d26bd0adbee3cfdf6fe0c86c569e5fd3d814a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 18:14:46 +0000 Subject: [PATCH 020/104] Cleanup superfluous functions and import halting --- openlp/plugins/custom/lib/mediaitem.py | 5 +---- openlp/plugins/images/lib/mediaitem.py | 3 --- openlp/plugins/songs/lib/mediaitem.py | 3 --- openlp/plugins/songs/lib/oooimport.py | 9 +++------ openlp/plugins/songs/lib/sofimport.py | 6 +++--- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 304773ea5..9b8115956 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -68,9 +68,6 @@ class CustomMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - def initialise(self): self.loadCustomListView(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) @@ -182,4 +179,4 @@ class CustomMediaItem(MediaManagerItem): else: raw_footer.append(u'') service_item.raw_footer = raw_footer - return True \ No newline at end of file + return True diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 4f976bd51..d55735188 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -220,6 +220,3 @@ class ImageMediaItem(MediaManagerItem): unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' 'the image file "%s" no longer exists.')) % filename) - - def onPreviewClick(self): - MediaManagerItem.onPreviewClick(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 625f99f18..dc51f97f5 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -68,9 +68,6 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.whitespace = re.compile(r'\W+', re.UNICODE) - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - def addEndHeaderBar(self): self.addToolbarSeparator() ## Song Maintenance Button ## diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 45d1ce5b9..819a62d1e 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -66,11 +66,11 @@ class OooImport(SongImport): QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): - self.abort = False + self.stop_import_flag = False self.import_wizard.progressBar.setMaximum(0) self.start_ooo() for filename in self.filenames: - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) @@ -89,9 +89,6 @@ class OooImport(SongImport): self.import_wizard.incrementProgressBar(u'', 1) return True - def stop_import(self): - self.abort = True - def start_ooo(self): """ Start OpenOffice.org process @@ -180,7 +177,7 @@ class OooImport(SongImport): slides = doc.getDrawPages() text = u'' for slide_no in range(slides.getCount()): - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return slide = slides.getByIndex(slide_no) diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 8475b0824..82b89141f 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -76,10 +76,10 @@ class SofImport(OooImport): OooImport.__init__(self, master_manager, **kwargs) def do_import(self): - self.abort = False + self.stop_import_flag = False self.start_ooo() for filename in self.filenames: - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) @@ -101,7 +101,7 @@ class SofImport(OooImport): self.new_song() paragraphs = self.document.getText().createEnumeration() while paragraphs.hasMoreElements(): - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return paragraph = paragraphs.nextElement() From 0a52af1869cb20bad6eb339c1506e6f7261f93c8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 18:35:11 +0000 Subject: [PATCH 021/104] Refactor OOo song imports --- openlp/plugins/songs/lib/oooimport.py | 18 ++++++++++++------ openlp/plugins/songs/lib/sofimport.py | 22 +++++----------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 819a62d1e..32315130a 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -77,18 +77,24 @@ class OooImport(SongImport): if os.path.isfile(filename): self.open_ooo_file(filename) if self.document: - if self.document.supportsService( - "com.sun.star.presentation.PresentationDocument"): - self.process_pres() - if self.document.supportsService( - "com.sun.star.text.TextDocument"): - self.process_doc() + self.process_ooo_document() self.close_ooo_file() self.close_ooo() self.import_wizard.progressBar.setMaximum(1) self.import_wizard.incrementProgressBar(u'', 1) return True + def process_ooo_document(self): + """ + Handle the import process for OpenOffice files. This method facilitates + allowing subclasses to handle specific types of OpenOffice files. + """ + if self.document.supportsService( + "com.sun.star.presentation.PresentationDocument"): + self.process_pres() + if self.document.supportsService("com.sun.star.text.TextDocument"): + self.process_doc() + def start_ooo(self): """ Start OpenOffice.org process diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 82b89141f..96a514f85 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -75,23 +75,11 @@ class SofImport(OooImport): """ OooImport.__init__(self, master_manager, **kwargs) - def do_import(self): - self.stop_import_flag = False - self.start_ooo() - for filename in self.filenames: - if self.stop_import_flag: - self.import_wizard.incrementProgressBar(u'Import cancelled', 0) - return - filename = unicode(filename) - if os.path.isfile(filename): - self.open_ooo_file(filename) - if self.document: - self.process_sof_file() - self.close_ooo_file() - self.close_ooo() - self.import_wizard.progressBar.setMaximum(1) - self.import_wizard.incrementProgressBar(u'', 1) - return True + def process_ooo_document(self): + """ + Handle the import process for SoF files. + """ + self.process_sof_file() def process_sof_file(self): """ From a600e37a34fd2e8dcf9307a57ca7bd86d6363215 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 19:35:29 +0000 Subject: [PATCH 022/104] Remove duplicate definitions --- openlp/plugins/songs/lib/sofimport.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 96a514f85..cfb80caa3 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -39,9 +39,7 @@ from oooimport import OooImport if os.name == u'nt': BOLD = 150.0 ITALIC = 2 - PAGE_BEFORE = 4 - PAGE_AFTER = 5 - PAGE_BOTH = 6 + from oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH else: try: from com.sun.star.awt.FontWeight import BOLD @@ -306,7 +304,6 @@ class SofImport(OooImport): self.currentverse = u'' self.is_chorus = False - def uncap_text(self, text): """ Words in the title are in all capitals, so we lowercase them. From 6e435e47e642de5a4da068ef0157d036edefe5af Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 23:26:09 +0000 Subject: [PATCH 023/104] Remove a few redundancies --- openlp/plugins/bibles/lib/mediaitem.py | 3 --- openlp/plugins/images/lib/mediaitem.py | 1 - openlp/plugins/media/lib/mediaitem.py | 1 - openlp/plugins/songs/lib/songimport.py | 5 +---- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f5e7b3966..614990654 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -254,9 +254,6 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) - def addListViewToToolBar(self): - MediaManagerItem.addListViewToToolBar(self) - def configUpdated(self): log.debug(u'configUpdated') if QtCore.QSettings().value(self.settingsSection + u'/second bibles', diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index d55735188..73f5b80f0 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -96,7 +96,6 @@ class ImageMediaItem(MediaManagerItem): def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 1b5d6b8d8..e7beb81a9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -84,7 +84,6 @@ class MediaMediaItem(MediaManagerItem): def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index cab0aacf6..592aa7ac1 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -227,7 +227,7 @@ class SongImport(QtCore.QObject): self.versecounts[versetag[0]] = int(versetag[1:]) self.verses.append([versetag, versetext.rstrip(), lang]) self.verse_order_list.append(versetag) - if versetag.startswith(u'V') and self.contains_verse(u'C1'): + if versetag.startswith(u'V') and u'C1' in self.verse_order_list: self.verse_order_list.append(u'C1') def repeat_verse(self): @@ -236,9 +236,6 @@ class SongImport(QtCore.QObject): """ self.verse_order_list.append(self.verse_order_list[-1]) - def contains_verse(self, versetag): - return versetag in self.verse_order_list - def check_complete(self): """ Check the mandatory fields are entered (i.e. title and a verse) From 9211c49bb2aaa79afe037eb772d6183846918e60 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 03:13:43 +0000 Subject: [PATCH 024/104] Fix CSV bible imports part 1 --- openlp/plugins/bibles/lib/csvbible.py | 145 +++++++++++++++++++++----- openlp/plugins/bibles/lib/db.py | 8 +- 2 files changed, 127 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 8959167a6..87b08d8b8 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -23,7 +23,45 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The :mod:`cvsbible` modules provides a facility to import bibles from a set of +CSV files. +The module expects two mandatory files containing the books and the verses and +will accept an optional third file containing the testaments. + +The format of the testament file is: + + , + + For example: + + 1,Old Testament + 2,New Testament + +The format of the books file is: + + ,,, + + For example + + 1,1,Genesis,Gen + 2,1,Exodus,Exod + ... + 40,2,Matthew,Matt + +The format of the verses file is: + + ,,, + + For example: + + 1,1,1,"In the beginning God created the heaven and the earth." + 1,1,2,"And the earth was without form, and void; and darkness...." + +All CSV files are expected to use a comma (',') as the delimeter and double +quotes ('"') as the quote symbol. +""" import logging import chardet import csv @@ -39,68 +77,110 @@ class CSVBible(BibleDB): """ This class provides a specialisation for importing of CSV Bibles. """ - def __init__(self, parent, **kwargs): """ - Loads a Bible from a pair of CVS files passed in + Loads a Bible from a set of CVS files. This class assumes the files contain all the information and a clean bible is being loaded. """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + try: + self.testamentsfile = kwargs[u'testamentsfile'] + except KeyError: + self.testamentsfile = None self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + def setup_testaments(self): + """ + Overrides parent method so we can handle importing a testament file. + """ + if self.testamentsfile: + self.wizard.progressBar.setMinimum(0) + self.wizard.progressBar.setMaximum(2) + self.wizard.progressBar.setValue(0) + testaments_file = None + try: + details = get_file_encoding(self.testamentsfile) + testaments_file = open(self.testamentsfile, 'rb') + testaments_reader = csv.reader(testaments_file, delimiter=',', + quotechar='"') + for line in testaments_reader: + if self.stop_import_flag: + break + self.wizard.incrementProgressBar(unicode( + translate('BibleDB.Wizard', + 'Importing testaments... %s')) % + unicode(line[1], details['encoding']), 0) + self.save_object(Testament.populate( + name=unicode(line[1], details['encoding']))) + Receiver.send_message(u'openlp_process_events') + except (IOError, IndexError): + log.exception(u'Loading testaments from file failed') + finally: + if testaments_file: + testaments_file.close() + self.wizard.incrementProgressBar(unicode(translate( + 'BibleDB.Wizard', 'Importing testaments... done.')), 2) + else: + BibleDB.setup_testaments(self) + def do_import(self): + """ + Import the bible books and verses. + """ + self.wizard.progressBar.setValue(0) + self.wizard.progressBar.setMinimum(0) + self.wizard.progressBar.setMaximum(65) success = True books_file = None - book_ptr = None - verse_file = None + book_list = {} # Populate the Tables try: + details = get_file_encoding(self.booksfile) books_file = open(self.booksfile, 'r') - dialect = csv.Sniffer().sniff(books_file.read(1024)) - books_file.seek(0) - books_reader = csv.reader(books_file, dialect) + books_reader = csv.reader(books_file, delimiter=',', quotechar='"') for line in books_reader: - # cancel pressed if self.stop_import_flag: break - details = chardet.detect(line[1]) - self.create_book(unicode(line[1], details['encoding']), - line[2], int(line[0])) - Receiver.send_message(u'openlp_process_events') + self.wizard.incrementProgressBar(unicode( + translate('BibleDB.Wizard', 'Importing books... %s')) % + unicode(line[2], details['encoding'])) + self.create_book(unicode(line[2], details['encoding']), + unicode(line[3], details['encoding']), int(line[1])) + book_list[int(line[0])] = unicode(line[2], details['encoding']) + Receiver.send_message(u'openlp_process_events') except (IOError, IndexError): log.exception(u'Loading books from file failed') success = False finally: if books_file: books_file.close() - if not success: + if self.stop_import_flag or not success: return False + self.wizard.progressBar.setValue(0) + verse_file = None try: - verse_file = open(self.versesfile, 'r') - dialect = csv.Sniffer().sniff(verse_file.read(1024)) - verse_file.seek(0) - verse_reader = csv.reader(verse_file, dialect) + book_ptr = None + details = get_file_encoding(self.versesfile) + verse_file = open(self.versesfile, 'rb') + verse_reader = csv.reader(verse_file, delimiter=',', quotechar='"') for line in verse_reader: if self.stop_import_flag: - # cancel pressed break - details = chardet.detect(line[3]) - if book_ptr != line[0]: - book = self.get_book(line[0]) + if book_ptr != book_list[int(line[0])]: + book = self.get_book(book_list[int(line[0])]) book_ptr = book.name self.wizard.incrementProgressBar(unicode(translate( - 'BiblesPlugin.CSVImport', 'Importing %s %s...', - 'Importing ...')) % - (book.name, int(line[1]))) + 'BibleDB.Wizard', 'Importing verses from %s...', + 'Importing verses from ...')) % book.name) self.session.commit() self.create_verse(book.id, line[1], line[2], unicode(line[3], details['encoding'])) - Receiver.send_message(u'openlp_process_events') + Receiver.send_message(u'openlp_process_events') self.session.commit() except IOError: log.exception(u'Loading verses from file failed') @@ -112,3 +192,18 @@ class CSVBible(BibleDB): return False else: return success + +def get_file_encoding(filename): + """ + Utility function to get the file encoding. + """ + detect_file = None + try: + detect_file = open(filename, 'r') + details = chardet.detect(detect_file.read(1024)) + except IOError: + log.exception(u'Error detecting file encoding') + finally: + if detect_file: + detect_file.close() + return details diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index f442a9cd6..a9444d88b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -206,10 +206,16 @@ class BibleDB(QtCore.QObject, Manager): """ self.wizard = wizard self.create_meta(u'dbversion', u'2') + self.setup_testaments() + return self.name + + def setup_testaments(self): + """ + Initialise the testaments section of a bible with suitable defaults. + """ self.save_object(Testament.populate(name=u'Old Testament')) self.save_object(Testament.populate(name=u'New Testament')) self.save_object(Testament.populate(name=u'Apocrypha')) - return self.name def create_book(self, name, abbrev, testament=1): """ From a2894b850ff43c3c626ccb741a33ead8eba73e5e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Jan 2011 17:40:17 +0100 Subject: [PATCH 025/104] only allow to select one slide in the slidecontrollers --- openlp/core/ui/slidecontroller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 7266d197c..916bf68c3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -119,6 +119,8 @@ class SlideController(QtGui.QWidget): self.previewListWidget.isLive = self.isLive self.previewListWidget.setObjectName(u'PreviewListWidget') self.previewListWidget.setSelectionBehavior(1) + self.previewListWidget.setSelectionMode( + QtGui.QAbstractItemView.SingleSelection) self.previewListWidget.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self.previewListWidget.setHorizontalScrollBarPolicy( From c3699b294fc69a74d0bee39a459dd8aae0935539 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 16:45:23 +0000 Subject: [PATCH 026/104] Fix CSV bible imports part 2 --- .../plugins/bibles/forms/bibleimportform.py | 55 ++++++++++++++++--- openlp/plugins/bibles/lib/csvbible.py | 2 +- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index d3f41804b..3e43d19aa 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -124,9 +124,12 @@ class BibleImportForm(OpenLPWizard): QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOsisBrowseButtonClicked) + QtCore.QObject.connect(self.csvTestamentsButton, + QtCore.SIGNAL(u'clicked()'), + self.onCsvTestamentsBrowseButtonClicked) QtCore.QObject.connect(self.csvBooksButton, QtCore.SIGNAL(u'clicked()'), - self.onBooksBrowseButtonClicked) + self.onCsvBooksBrowseButtonClicked) QtCore.QObject.connect(self.csvVersesButton, QtCore.SIGNAL(u'clicked()'), self.onCsvVersesBrowseButtonClicked) @@ -187,6 +190,18 @@ class BibleImportForm(OpenLPWizard): self.csvLayout = QtGui.QFormLayout(self.csvWidget) self.csvLayout.setMargin(0) self.csvLayout.setObjectName(u'CsvLayout') + self.csvTestamentsLabel = QtGui.QLabel(self.csvWidget) + self.csvTestamentsLabel.setObjectName(u'CsvTestamentsLabel') + self.csvTestamentsLayout = QtGui.QHBoxLayout() + self.csvTestamentsLayout.setObjectName(u'CsvTestamentsLayout') + self.csvTestamentsEdit = QtGui.QLineEdit(self.csvWidget) + self.csvTestamentsEdit.setObjectName(u'CsvTestamentsEdit') + self.csvTestamentsLayout.addWidget(self.csvTestamentsEdit) + self.csvTestamentsButton = QtGui.QToolButton(self.csvWidget) + self.csvTestamentsButton.setIcon(self.openIcon) + self.csvTestamentsButton.setObjectName(u'CsvTestamentsButton') + self.csvTestamentsLayout.addWidget(self.csvTestamentsButton) + self.csvLayout.addRow(self.csvTestamentsLabel, self.csvTestamentsLayout) self.csvBooksLabel = QtGui.QLabel(self.csvWidget) self.csvBooksLabel.setObjectName(u'CsvBooksLabel') self.csvBooksLayout = QtGui.QHBoxLayout() @@ -213,7 +228,7 @@ class BibleImportForm(OpenLPWizard): self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.csvSpacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -389,6 +404,8 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'File location:')) self.osisFileLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'File location:')) + self.csvTestamentsLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Testaments location:')) self.csvBooksLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Books location:')) self.csvVersesLabel.setText( @@ -478,7 +495,16 @@ class BibleImportForm(OpenLPWizard): self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: - if not self.field(u'csv_booksfile').toString(): + if not self.field(u'csv_testamentsfile').toString(): + answer = criticalErrorMessageBox(translate( + 'BiblesPlugin.ImportWizardForm', 'No Testaments File'), + translate('BiblesPlugin.ImportWizardForm', + 'You have not specified a testaments file. Do you ' + 'want to proceed with the import?'), question=True) + if answer == QtGui.QMessageBox.No: + self.csvTestamentsEdit.setFocus() + return False + elif not self.field(u'csv_booksfile').toString(): criticalErrorMessageBox( translate('BiblesPlugin.ImportWizardForm', 'Invalid Books File'), @@ -572,7 +598,15 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'Open OSIS File'), self.osisFileEdit) - def onBooksBrowseButtonClicked(self): + def onCsvTestamentsBrowseButtonClicked(self): + """ + Show the file open dialog for the testaments CSV file. + """ + self.getFileName(translate('BiblesPlugin.ImportWizardForm', + 'Open Testaments CSV File'), self.csvTestamentsEdit, u'%s (*.csv)' + % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + + def onCsvBooksBrowseButtonClicked(self): """ Show the file open dialog for the books CSV file. """ @@ -613,12 +647,14 @@ class BibleImportForm(OpenLPWizard): """ self.selectPage.registerField(u'source_format', self.formatComboBox) self.selectPage.registerField(u'osis_location', self.osisFileEdit) + self.selectPage.registerField( + u'csv_testamentsfile', self.csvTestamentsEdit) self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit) self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit) self.selectPage.registerField(u'opensong_file', self.openSongFileEdit) self.selectPage.registerField(u'web_location', self.webSourceComboBox) - self.selectPage.registerField(u'web_biblename', - self.webTranslationComboBox) + self.selectPage.registerField( + u'web_biblename', self.webTranslationComboBox) self.selectPage.registerField(u'proxy_server', self.webServerEdit) self.selectPage.registerField(u'proxy_username', self.webUserEdit) self.selectPage.registerField(u'proxy_password', self.webPasswordEdit) @@ -641,6 +677,7 @@ class BibleImportForm(OpenLPWizard): self.cancelButton.setVisible(True) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) + self.setField(u'csv_testamentsfile', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) @@ -770,7 +807,8 @@ class BibleImportForm(OpenLPWizard): elif bible_type == BibleFormat.CSV: # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, - name=license_version, + name=license_version, testamentsfile=unicode( + self.field(u'csv_testamentsfile').toString()), booksfile=unicode(self.field(u'csv_booksfile').toString()), versefile=unicode(self.field(u'csv_versefile').toString()) ) @@ -795,8 +833,7 @@ class BibleImportForm(OpenLPWizard): bible = \ self.web_bible_list[WebDownload.Bibleserver][bible_version] importer = self.manager.import_bible( - BibleFormat.WebDownload, - name=license_version, + BibleFormat.WebDownload, name=license_version, download_source=WebDownload.get_name(download_location), download_name=bible, proxy_server=unicode(self.field(u'proxy_server').toString()), diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 87b08d8b8..58b4924c3 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -69,7 +69,7 @@ import csv from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB, Testament log = logging.getLogger(__name__) From 0831f733067e2e45bf068540815a6ff6ed7d7bf9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 16:55:49 +0000 Subject: [PATCH 027/104] CSV bible import progress bar tweaks --- openlp/plugins/bibles/lib/csvbible.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 58b4924c3..fd987dfdf 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -134,7 +134,7 @@ class CSVBible(BibleDB): """ self.wizard.progressBar.setValue(0) self.wizard.progressBar.setMinimum(0) - self.wizard.progressBar.setMaximum(65) + self.wizard.progressBar.setMaximum(66) success = True books_file = None book_list = {} @@ -162,6 +162,7 @@ class CSVBible(BibleDB): if self.stop_import_flag or not success: return False self.wizard.progressBar.setValue(0) + self.wizard.progressBar.setMaximum(67) verse_file = None try: book_ptr = None @@ -180,6 +181,8 @@ class CSVBible(BibleDB): self.session.commit() self.create_verse(book.id, line[1], line[2], unicode(line[3], details['encoding'])) + self.wizard.incrementProgressBar(translate('BibleDB.Wizard', + 'Importing verses... done.')) Receiver.send_message(u'openlp_process_events') self.session.commit() except IOError: From 3d510596e4cf95130b3dbf2a37a48e7886ae7984 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Jan 2011 17:59:15 +0100 Subject: [PATCH 028/104] make curosr busy when merging authors/topics/books --- .../songs/forms/songmaintenanceform.py | 200 ++++++++++-------- 1 file changed, 106 insertions(+), 94 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 93a01623e..6613a050b 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -278,117 +278,129 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorEditButtonClick(self): author_id = self._getCurrentItemId(self.authorsListWidget) - if author_id != -1: - author = self.manager.get_object(Author, author_id) - self.authorform.setAutoDisplayName(False) - self.authorform.firstNameEdit.setText(author.first_name) - self.authorform.lastNameEdit.setText(author.last_name) - self.authorform.displayEdit.setText(author.display_name) - # Save the author's first and last name as well as the display name - # for the case that they have to be restored. - temp_first_name = author.first_name - temp_last_name = author.last_name - temp_display_name = author.display_name - if self.authorform.exec_(False): - author.first_name = unicode( - self.authorform.firstNameEdit.text()) - author.last_name = unicode(self.authorform.lastNameEdit.text()) - author.display_name = unicode( - self.authorform.displayEdit.text()) - if self.checkAuthor(author, True): - if self.manager.save_object(author): - self.resetAuthors() - Receiver.send_message(u'songs_load_list') - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox(message=unicode(translate( - 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' - 'exists. Would you like to make songs with author %s use ' - 'the existing author %s?')) % (author.display_name, - temp_display_name, author.display_name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeAuthors(author) + if author_id == -1: + return + author = self.manager.get_object(Author, author_id) + self.authorform.setAutoDisplayName(False) + self.authorform.firstNameEdit.setText(author.first_name) + self.authorform.lastNameEdit.setText(author.last_name) + self.authorform.displayEdit.setText(author.display_name) + # Save the author's first and last name as well as the display name + # for the case that they have to be restored. + temp_first_name = author.first_name + temp_last_name = author.last_name + temp_display_name = author.display_name + if self.authorform.exec_(False): + author.first_name = unicode( + self.authorform.firstNameEdit.text()) + author.last_name = unicode(self.authorform.lastNameEdit.text()) + author.display_name = unicode( + self.authorform.displayEdit.text()) + if self.checkAuthor(author, True): + if self.manager.save_object(author): self.resetAuthors() Receiver.send_message(u'songs_load_list') else: - # We restore the author's old first and last name as well as - # his display name. - author.first_name = temp_first_name - author.last_name = temp_last_name - author.display_name = temp_display_name criticalErrorMessageBox( message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your modified author, because the ' - 'author already exists.')) + 'Could not save your changes.')) + elif criticalErrorMessageBox(message=unicode(translate( + 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' + 'exists. Would you like to make songs with author %s use ' + 'the existing author %s?')) % (author.display_name, + temp_display_name, author.display_name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeAuthors(author) + self.resetAuthors() + Receiver.send_message(u'songs_load_list') + Receiver.send_message(u'cursor_normal') + else: + # We restore the author's old first and last name as well as + # his display name. + author.first_name = temp_first_name + author.last_name = temp_last_name + author.display_name = temp_display_name + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your modified author, because the ' + 'author already exists.')) def onTopicEditButtonClick(self): topic_id = self._getCurrentItemId(self.topicsListWidget) - if topic_id != -1: - topic = self.manager.get_object(Topic, topic_id) - self.topicform.nameEdit.setText(topic.name) - # Save the topic's name for the case that he has to be restored. - temp_name = topic.name - if self.topicform.exec_(False): - topic.name = unicode(self.topicform.nameEdit.text()) - if self.checkTopic(topic, True): - if self.manager.save_object(topic): - self.resetTopics() - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', - 'The topic %s already exists. Would you like to make songs ' - 'with topic %s use the existing topic %s?')) % (topic.name, - temp_name, topic.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeTopics(topic) + if topic_id == -1: + return + topic = self.manager.get_object(Topic, topic_id) + self.topicform.nameEdit.setText(topic.name) + # Save the topic's name for the case that he has to be restored. + temp_name = topic.name + if self.topicform.exec_(False): + topic.name = unicode(self.topicform.nameEdit.text()) + if self.checkTopic(topic, True): + if self.manager.save_object(topic): self.resetTopics() else: - # We restore the topics's old name. - topic.name = temp_name criticalErrorMessageBox( message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your modified topic, because it ' - 'already exists.')) + 'Could not save your changes.')) + elif criticalErrorMessageBox( + message=unicode(translate('SongsPlugin.SongMaintenanceForm', + 'The topic %s already exists. Would you like to make songs ' + 'with topic %s use the existing topic %s?')) % (topic.name, + temp_name, topic.name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeTopics(topic) + self.resetTopics() + Receiver.send_message(u'cursor_normal') + else: + # We restore the topics's old name. + topic.name = temp_name + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your modified topic, because it ' + 'already exists.')) def onBookEditButtonClick(self): book_id = self._getCurrentItemId(self.booksListWidget) - if book_id != -1: - book = self.manager.get_object(Book, book_id) - if book.publisher is None: - book.publisher = u'' - self.bookform.nameEdit.setText(book.name) - self.bookform.publisherEdit.setText(book.publisher) - # Save the book's name and publisher for the case that they have to - # be restored. - temp_name = book.name - temp_publisher = book.publisher - if self.bookform.exec_(False): - book.name = unicode(self.bookform.nameEdit.text()) - book.publisher = unicode(self.bookform.publisherEdit.text()) - if self.checkBook(book, True): - if self.manager.save_object(book): - self.resetBooks() - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', - 'The book %s already exists. Would you like to make songs ' - 'with book %s use the existing book %s?')) % (book.name, - temp_name, book.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeBooks(book) + if book_id == -1: + return + book = self.manager.get_object(Book, book_id) + if book.publisher is None: + book.publisher = u'' + self.bookform.nameEdit.setText(book.name) + self.bookform.publisherEdit.setText(book.publisher) + # Save the book's name and publisher for the case that they have to + # be restored. + temp_name = book.name + temp_publisher = book.publisher + if self.bookform.exec_(False): + book.name = unicode(self.bookform.nameEdit.text()) + book.publisher = unicode(self.bookform.publisherEdit.text()) + if self.checkBook(book, True): + if self.manager.save_object(book): self.resetBooks() else: - # We restore the book's old name and publisher. - book.name = temp_name - book.publisher = temp_publisher + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your changes.')) + elif criticalErrorMessageBox( + message=unicode(translate('SongsPlugin.SongMaintenanceForm', + 'The book %s already exists. Would you like to make songs ' + 'with book %s use the existing book %s?')) % (book.name, + temp_name, book.name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeBooks(book) + self.resetBooks() + Receiver.send_message(u'cursor_normal') + else: + # We restore the book's old name and publisher. + book.name = temp_name + book.publisher = temp_publisher def mergeAuthors(self, old_author): """ From 139cf93541fd165a5b25b3e1d0dd6bbd5b15fbaa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 18:41:37 +0000 Subject: [PATCH 029/104] SongUsage cleanup --- openlp/core/lib/__init__.py | 2 +- .../songusage/forms/songusagedetaildialog.py | 5 ++- .../songusage/forms/songusagedetailform.py | 41 ++++++++++++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 76d7c0617..33280f83b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -315,7 +315,7 @@ def check_directory_exists(dir): ``dir`` Theme directory to make sure exists """ - log.debug(u'check_directory_exists') + log.debug(u'check_directory_exists %s' % dir) if not os.path.exists(dir): os.makedirs(dir) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 9383e147d..87d2d5ffe 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -60,10 +60,11 @@ class Ui_SongUsageDetailDialog(object): self.horizontalLayout.setObjectName(u'horizontalLayout') self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') + self.fileLineEdit.setReadOnly(True) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( - build_icon(u':/general/general_load.png')) + build_icon(u':/general/general_open.png')) self.saveFilePushButton.setObjectName(u'saveFilePushButton') self.horizontalLayout.addWidget(self.saveFilePushButton) self.verticalLayout4.addLayout(self.horizontalLayout) @@ -96,4 +97,4 @@ class Ui_SongUsageDetailDialog(object): translate('SongUsagePlugin.SongUsageDetailForm', 'to')) self.fileGroupBox.setTitle( translate('SongUsagePlugin.SongUsageDetailForm', - 'Report Location')) \ No newline at end of file + 'Report Location')) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 8588ddcff..88e3b1450 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate +from openlp.core.lib import SettingsManager, translate, check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -51,49 +51,68 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.setupUi(self) def initialise(self): + """ + We need to set up the screen + """ year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - toDate = QtCore.QDate(year, 8, 31) - fromDate = QtCore.QDate(year - 1, 9, 1) + toDate = QtCore.QSettings().value( + u'songusage/to date', + QtCore.QVariant(QtCore.QDate(year, 8, 31))).toDate() + fromDate = QtCore.QSettings().value( + u'songusage/from date', + QtCore.QVariant(QtCore.QDate(year - 1, 9, 1))).toDate() self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) def defineOutputLocation(self): + """ + Triggered when the Directory selection button is pressed + """ path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) path = unicode(path) - if path != u'': + if path: SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) self.fileLineEdit.setText(path) def accept(self): - log.debug(u'Detailed report generated') + """ + Ok was pressed so lets save the data and run the report + """ + log.debug(u'accept') + path = unicode(self.fileLineEdit.text()) + check_directory_exists(path) filename = unicode(translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt')) % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) + QtCore.QSettings().setValue(u'songusage/from date', + QtCore.QVariant(self.fromDate.selectedDate())) + QtCore.QSettings().setValue(u'songusage/to date', + QtCore.QVariant(self.toDate.selectedDate())) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), [SongUsageItem.usagedate, SongUsageItem.usagetime]) - outname = os.path.join(unicode(self.fileLineEdit.text()), filename) - file = None + outname = os.path.join(path, filename) + fileHandle = None try: - file = open(outname, u'w') + fileHandle = open(outname, u'w') for instance in usage: record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % ( instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) - file.write(record) + fileHandle.write(record.encode(u'utf-8')) except IOError: log.exception(u'Failed to write out song usage records') finally: - if file: - file.close() + if fileHandle: + fileHandle.close() self.close() From 8e7d29adf129c96d901ce753b9f10c71453ab46b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 19:46:55 +0000 Subject: [PATCH 030/104] Amend Service Item Title --- openlp/core/lib/serviceitem.py | 12 ++++++++++++ openlp/core/ui/servicemanager.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 276563eba..01a5623df 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -314,6 +314,18 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() + def get_title(self): + """ + Returns the title of the service item. + """ + if self.is_text(): + return self.title + else: + if len(self._raw_frames) > 1: + return self.title + else: + return self._raw_frames[0][u'title'] + def merge(self, other): """ Updates the _uuid with the value from the original one diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9470b419f..8ae844940 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.title) + treewidgetitem.setText(0, serviceitem.get_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.title) + data_item[u'title'] = unicode(service_item.get_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) From daf545bc06e5f36dc32b0e581f5db21f1e8d77fc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 07:53:21 +0000 Subject: [PATCH 031/104] Fix up service item display changes --- openlp/core/lib/serviceitem.py | 7 +++++-- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/presentations/lib/mediaitem.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 01a5623df..c74b89144 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -59,6 +59,7 @@ class ItemCapabilities(object): OnLoadUpdate = 8 AddIfNewItem = 9 ProvidesOwnDisplay = 10 + AllowsDetailedTitleDisplay = 11 class ServiceItem(object): @@ -314,14 +315,16 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() - def get_title(self): + def get_display_title(self): """ Returns the title of the service item. """ if self.is_text(): return self.title else: - if len(self._raw_frames) > 1: + if ItemCapabilities.AllowsDetailedTitleDisplay in self.capabilities: + return self._raw_frames[0][u'title'] + elif len(self._raw_frames) > 1: return self.title else: return self._raw_frames[0][u'title'] diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8ae844940..57a82722e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.get_title()) + treewidgetitem.setText(0, serviceitem.get_display_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.get_title()) + data_item[u'title'] = unicode(service_item.get_display_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e72d97be1..43cb3dab0 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -250,6 +250,7 @@ class PresentationMediaItem(MediaManagerItem): service_item.title = unicode(self.displayTypeComboBox.currentText()) service_item.shortname = unicode(self.displayTypeComboBox.currentText()) service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) + service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay) shortname = service_item.shortname if shortname: for item in items: From 5f46426f93f149ff6013513519073d3a76c3c9bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 08:26:14 +0000 Subject: [PATCH 032/104] More songusage cleanups --- openlp/plugins/songusage/forms/songusagedeleteform.py | 9 +++++++-- openlp/plugins/songusage/forms/songusagedetaildialog.py | 1 + openlp/plugins/songusage/forms/songusagedetailform.py | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index f83ec8c82..a4cfd84b7 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -26,7 +26,7 @@ from PyQt4 import QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, Receiver from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog @@ -55,4 +55,9 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): deleteDate = self.deleteCalendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate) - self.close() \ No newline at end of file + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDeleteForm', + 'Deletion Sucessful'), + u'message': translate('SongUsagePlugin.SongUsageDeleteForm', + 'All requested data has been deleted sucessfully. ')}) + self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 87d2d5ffe..ec1f69d7e 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -61,6 +61,7 @@ class Ui_SongUsageDetailDialog(object): self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') self.fileLineEdit.setReadOnly(True) + self.fileLineEdit.setEnabled(False) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 88e3b1450..f02820b0d 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,8 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate, check_directory_exists +from openlp.core.lib import SettingsManager, translate, Receiver, \ + check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -110,6 +111,12 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) fileHandle.write(record.encode(u'utf-8')) + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDetailForm', + 'Report Creation'), + u'message': unicode(translate( + 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' + 'has been sucessfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: From 003e572896a625e881dbf4cb3b0f08c0c70a38da Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 09:56:05 +0000 Subject: [PATCH 033/104] More Up / Down errors --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 57a82722e..22a873855 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -178,7 +178,7 @@ class ServiceManager(QtGui.QWidget): translate('OpenLP.ServiceManager', 'Move &down'), None, translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), + 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( From 336730d943fedac66ad9fe6de41696177bf99a12 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 10:01:29 +0000 Subject: [PATCH 034/104] Spellings --- openlp/plugins/songusage/forms/songusagedeleteform.py | 4 ++-- openlp/plugins/songusage/forms/songusagedetailform.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index a4cfd84b7..c03fe15a3 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -57,7 +57,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): SongUsageItem.usagedate <= deleteDate) Receiver.send_message(u'openlp_information_message', { u'title': translate('SongUsagePlugin.SongUsageDeleteForm', - 'Deletion Sucessful'), + 'Deletion Successful'), u'message': translate('SongUsagePlugin.SongUsageDeleteForm', - 'All requested data has been deleted sucessfully. ')}) + 'All requested data has been deleted successfully. ')}) self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index f02820b0d..ff8ec4858 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -116,7 +116,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): 'Report Creation'), u'message': unicode(translate( 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' - 'has been sucessfully created. ')) % outname}) + 'has been successfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: From 1083cf38be7fbd0767dcad7344c1caff345c5337 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 29 Jan 2011 20:39:16 +0100 Subject: [PATCH 035/104] started with service order sheet printing --- openlp/core/ui/mainwindow.py | 17 +++++++++++++++-- openlp/core/ui/servicemanager.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d8bedade3..ea11c7d99 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -175,6 +175,10 @@ class Ui_MainWindow(object): self.FileSaveAsItem = QtGui.QAction(mainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') + self.PrintServiceOrderItem = QtGui.QAction(mainWindow) + self.PrintServiceOrderItem.setObjectName(u'PrintServiceItem') + mainWindow.actionList.add_action( + self.PrintServiceOrderItem, u'Print Service Order') self.FileExitItem = QtGui.QAction(mainWindow) self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) self.FileExitItem.setObjectName(u'FileExitItem') @@ -302,8 +306,8 @@ class Ui_MainWindow(object): (self.ExportThemeItem, self.ExportLanguageItem)) self.FileMenuActions = (self.FileNewItem, self.FileOpenItem, self.FileSaveItem, self.FileSaveAsItem, None, - self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(), - self.FileExitItem) + self.PrintServiceOrderItem, None, self.FileImportMenu.menuAction(), + self.FileExportMenu.menuAction(), self.FileExitItem) add_actions(self.ViewModeMenu, (self.ModeDefaultItem, self.ModeSetupItem, self.ModeLiveItem)) add_actions(self.ViewMenu, (self.ViewModeMenu.menuAction(), @@ -381,6 +385,12 @@ class Ui_MainWindow(object): 'Save the current service under a new name.')) self.FileSaveAsItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+Shift+S')) + self.PrintServiceOrderItem.setText( + translate('OpenLP.MainWindow', 'Print Service Order')) + self.PrintServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', + 'Print the current Service Order.')) + self.PrintServiceOrderItem.setShortcut( + translate('OpenLP.MainWindow', 'Ctrl+P')) self.FileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) self.FileExitItem.setStatusTip( @@ -567,6 +577,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.saveFileAs) + QtCore.QObject.connect(self.PrintServiceOrderItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.printServiceOrder) # i18n set signals for languages QtCore.QObject.connect(self.AutoLanguageItem, QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 22a873855..ce400525e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1182,3 +1182,31 @@ class ServiceManager(QtGui.QWidget): data_item[u'selected'] = (item == curitem) data.append(data_item) Receiver.send_message(u'servicemanager_list_response', data) + + def printServiceOrder(self): + """ + Print a Service Order Sheet. + """ + # TODO: Add settings, consider footer. If saved service, print service + # file name. + printer = QtGui.QPrinter() + printer.setPaperSize(QtGui.QPrinter.A4) + text = u'

%s

' % translate('OpenLP.ServiceManager', + 'Service Order Sheet') + for item in self.serviceItems: + text += u'

' + item[u'service_item'].title + u'

' + if item[u'service_item'].is_text(): + for slide in item[u'service_item'].get_frames(): + text += u'

' + slide[u'text'] + u'

' + elif item[u'service_item'].is_image(): + # Get child title + pass + else: + # What to do with the other types? + pass + if item[u'service_item'].notes: + text += u'

%s ' % translate('OpenLP.ServiceManager', + 'Notes:') + item[u'service_item'].notes + u'

' + doc = QtGui.QTextDocument() + doc.setHtml(text) + doc.print_(printer) From 428edf28fb5abf3fea66b13aab61764fb7acc101 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:32:09 +0000 Subject: [PATCH 036/104] CSV testing named book format (v1?) --- openlp/plugins/bibles/lib/csvbible.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index fd987dfdf..33a5de714 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -172,8 +172,12 @@ class CSVBible(BibleDB): for line in verse_reader: if self.stop_import_flag: break - if book_ptr != book_list[int(line[0])]: - book = self.get_book(book_list[int(line[0])]) + try: + line_book = book_list[int(line[0])] + except ValueError: + line_book = unicode(line[0], details['encoding']) + if book_ptr != line_book: + book = self.get_book(line_book) book_ptr = book.name self.wizard.incrementProgressBar(unicode(translate( 'BibleDB.Wizard', 'Importing verses from %s...', From 780a8b8b39727c8daea1a418a79c6d71d82971e8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:43:07 +0000 Subject: [PATCH 037/104] Docstring update for CSV formats --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 33a5de714..677f99e6b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -50,14 +50,17 @@ The format of the books file is: ... 40,2,Matthew,Matt -The format of the verses file is: +There are two acceptable formats of the verses file. They are: ,,, + or + ,,, For example: 1,1,1,"In the beginning God created the heaven and the earth." - 1,1,2,"And the earth was without form, and void; and darkness...." + or + "Genesis",1,2,"And the earth was without form, and void; and...." All CSV files are expected to use a comma (',') as the delimeter and double quotes ('"') as the quote symbol. From 83ac7c6b297e5dd0a388d299195ad91b89b0b4f0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 10:27:12 +0000 Subject: [PATCH 038/104] Fix up theme override position bugs Fixes: https://launchpad.net/bugs/710065 --- openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/themeform.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3dfde8640..f6ecfc6fc 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,6 +244,7 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') + a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 43f1034f4..8d10f21fa 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -272,14 +272,18 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): def onMainPositionCheckBoxStateChanged(self, value): """ Change state as Main Area Position check box changed + NOTE the font_main_override is the inverse of the check box value """ - self.theme.font_main_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_main_override = not (value == QtCore.Qt.Checked) def onFooterPositionCheckBoxStateChanged(self, value): """ Change state as Footer Area Position check box changed + NOTE the font_footer_override is the inverse of the check box value """ - self.theme.font_footer_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_footer_override = not (value == QtCore.Qt.Checked) def exec_(self, edit=False): """ From 9c5d7e85912e00401db006ef07acf0d78247143d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 16:51:31 +0000 Subject: [PATCH 039/104] Remove debug --- openlp/core/ui/maindisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f6ecfc6fc..3dfde8640 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,7 +244,6 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') - a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: From ce49a8fe20ca5d2212fb56c1f5732358ecc435c3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jan 2011 20:19:24 +0100 Subject: [PATCH 040/104] print footer, display plugin icon --- openlp/core/ui/servicemanager.py | 43 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ce400525e..ab1d6b5c8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1187,26 +1187,31 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - # TODO: Add settings, consider footer. If saved service, print service - # file name. - printer = QtGui.QPrinter() - printer.setPaperSize(QtGui.QPrinter.A4) + # TODO: Add settings. + if not self.serviceItems: + return + printDialog = QtGui.QPrintDialog() + if not printDialog.exec_(): + return text = u'

%s

' % translate('OpenLP.ServiceManager', 'Service Order Sheet') for item in self.serviceItems: - text += u'

' + item[u'service_item'].title + u'

' - if item[u'service_item'].is_text(): - for slide in item[u'service_item'].get_frames(): + item = item[u'service_item'] + text += u'

%s

' % (item.icon, + item.get_display_title()) + if item.is_text(): + for slide in item.get_frames(): text += u'

' + slide[u'text'] + u'

' - elif item[u'service_item'].is_image(): - # Get child title - pass - else: - # What to do with the other types? - pass - if item[u'service_item'].notes: - text += u'

%s ' % translate('OpenLP.ServiceManager', - 'Notes:') + item[u'service_item'].notes + u'

' - doc = QtGui.QTextDocument() - doc.setHtml(text) - doc.print_(printer) + elif item.is_image(): + text += u'
    ' + for slide in range(len(item.get_frames())): + text += u'
  1. %s

  2. ' % item.get_frame_title(slide) + text += u'
' + if item.foot_text: + text += u'

%s

' % item.foot_text + if item.notes: + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), item.notes) + serviceDocument = QtGui.QTextDocument() + serviceDocument.setHtml(text) + serviceDocument.print_(printDialog.printer()) From 54a6963f892a9c66c04fa396620f6f375fafad04 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jan 2011 21:08:00 +0100 Subject: [PATCH 041/104] changed image title --- openlp/plugins/images/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 73f5b80f0..25d9811f1 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -142,7 +142,7 @@ class ImageMediaItem(MediaManagerItem): items = self.listView.selectedIndexes() if items: service_item.title = unicode( - translate('ImagePlugin.MediaItem', 'Image(s)')) + translate('ImagePlugin.MediaItem', 'Images')) service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) From b99961d669c9f71ac6d33a3d7e4411f4ad7444af Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 01:55:25 +0000 Subject: [PATCH 042/104] Fix BG Chinese bible (Bug #706211) --- openlp/plugins/bibles/lib/http.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b844bbe61..e004be9df 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -210,7 +210,8 @@ class BGExtract(object): cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, - cleaner=cleaner) + pre_parse_regex=r'', pre_parse_substitute='', + cleaner=cleaner) if not soup: return None Receiver.send_message(u'openlp_process_events') @@ -499,7 +500,8 @@ class HTTPBible(BibleDB): """ return HTTPBooks.get_verse_count(book, chapter) -def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): +def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, + pre_parse_substitute=None, cleaner=None): """ Gets a webpage and returns a parsed and optionally cleaned soup or None. @@ -509,6 +511,13 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): ``header`` An optional HTTP header to pass to the bible web server. + ``pre_parse_regex`` + A regular expression to run on the webpage. Allows manipulation of the + webpage before passing to BeautifulSoup for parsing. + + ``pre_parse_substitute`` + The text to replace any matches to the regular expression with. + ``cleaner`` An optional regex to use during webpage parsing. """ @@ -518,12 +527,15 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): if not page: send_error_message(u'download') return None + page_source = page.read() + if pre_parse_regex and pre_parse_substitute is not None: + page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source) soup = None try: if cleaner: - soup = BeautifulSoup(page, markupMassage=cleaner) + soup = BeautifulSoup(page_source, markupMassage=cleaner) else: - soup = BeautifulSoup(page) + soup = BeautifulSoup(page_source) except HTMLParseError: log.exception(u'BeautifulSoup could not parse the bible page.') if not soup: From 250107073e86d399d1b792d9b2d3087e4dca72c4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 02:43:37 +0000 Subject: [PATCH 043/104] Fix not quite ascii CSVs --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 677f99e6b..82872e15b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -186,8 +186,11 @@ class CSVBible(BibleDB): 'BibleDB.Wizard', 'Importing verses from %s...', 'Importing verses from ...')) % book.name) self.session.commit() - self.create_verse(book.id, line[1], line[2], - unicode(line[3], details['encoding'])) + try: + verse_text = unicode(line[3], details['encoding']) + except UnicodeError: + verse_text = unicode(line[3], u'cp1252') + self.create_verse(book.id, line[1], line[2], verse_text) self.wizard.incrementProgressBar(translate('BibleDB.Wizard', 'Importing verses... done.')) Receiver.send_message(u'openlp_process_events') From e8dce46cf95a65c144f4d183feac58f3c03f12bf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 18:00:56 +0100 Subject: [PATCH 044/104] --- openlp/core/lib/mediamanageritem.py | 6 +----- openlp/core/ui/servicemanager.py | 5 +++++ openlp/plugins/media/lib/mediaitem.py | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9565a9b37..7dd74efb0 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -103,7 +103,6 @@ class MediaManagerItem(QtGui.QWidget): self.icon = build_icon(icon) self.toolbar = None self.remoteTriggered = None - self.serviceItemIconName = None self.singleServiceItem = True self.pageLayout = QtGui.QVBoxLayout(self) self.pageLayout.setSpacing(0) @@ -525,10 +524,7 @@ class MediaManagerItem(QtGui.QWidget): Common method for generating a service item """ serviceItem = ServiceItem(self.parent) - if self.serviceItemIconName: - serviceItem.add_icon(self.serviceItemIconName) - else: - serviceItem.add_icon(self.parent.icon_path) + serviceItem.add_icon(self.parent.icon_path) if self.generateSlideData(serviceItem, item, xmlVersion): return serviceItem else: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ab1d6b5c8..085644b67 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1197,19 +1197,24 @@ class ServiceManager(QtGui.QWidget): 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] + # add the title text += u'

%s

' % (item.icon, item.get_display_title()) if item.is_text(): + # Add the text of the service item. for slide in item.get_frames(): text += u'

' + slide[u'text'] + u'

' elif item.is_image(): + # Add the image names of the service item. text += u'
    ' for slide in range(len(item.get_frames())): text += u'
  1. %s

  2. ' % item.get_frame_title(slide) text += u'
' if item.foot_text: + # add footer text += u'

%s

' % item.foot_text if item.notes: + # add notes text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', 'Notes:'), item.notes) serviceDocument = QtGui.QTextDocument() diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index e7beb81a9..c68b11c85 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -57,7 +57,6 @@ class MediaMediaItem(MediaManagerItem): u':/media/media_video.png').toImage() MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False - self.serviceItemIconName = u':/media/image_clapperboard.png' QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), self.videobackgroundReplaced) From 7b3f61e93b0096c9139f20cd0f3f10dedb69c619 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 20:35:35 +0100 Subject: [PATCH 045/104] added setting --- openlp/core/ui/advancedtab.py | 18 ++++++++++++++++++ openlp/core/ui/generaltab.py | 1 + openlp/core/ui/servicemanager.py | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 58b637bc2..10660a914 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -80,6 +80,16 @@ class AdvancedTab(SettingsTab): self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') self.hideMouseLayout.addWidget(self.hideMouseCheckBox) self.leftLayout.addWidget(self.hideMouseGroupBox) + self.serviceOrderGroupBox = QtGui.QGroupBox(self.leftColumn) + self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox') + self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox) + self.serviceOrderLayout.setObjectName(u'serviceOrderLayout') + self.detailedServicePrintCheckBox = QtGui.QCheckBox( + self.serviceOrderGroupBox) + self.detailedServicePrintCheckBox.setObjectName( + u'detailedServicePrintCheckBox') + self.serviceOrderLayout.addWidget(self.detailedServicePrintCheckBox) + self.leftLayout.addWidget(self.serviceOrderGroupBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox) @@ -129,6 +139,10 @@ class AdvancedTab(SettingsTab): 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide the mouse cursor when moved over the display window')) + self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', + 'Service Order Print')) + self.detailedServicePrintCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Included detailed information')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -164,6 +178,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) + self.detailedServicePrintCheckBox.setChecked(settings.value( + u'detailed service print', QtCore.QVariant(False)).toBool()) settings.endGroup() def save(self): @@ -184,6 +200,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) + settings.setValue(u'detailed service print', + QtCore.QVariant(self.detailedServicePrintCheckBox.isChecked())) settings.endGroup() # def onSharedCheckBoxChanged(self, checked): diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index edace883f..12353fed8 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -51,6 +51,7 @@ class ValidEdit(QtGui.QLineEdit): else: return self.text() + class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d99ccd2d5..6b0b84472 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1187,7 +1187,6 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - # TODO: Add settings. if not self.serviceItems: return printDialog = QtGui.QPrintDialog() @@ -1200,6 +1199,9 @@ class ServiceManager(QtGui.QWidget): # add the title text += u'

%s

' % (item.icon, item.get_display_title()) + if not QtCore.QSettings().value(u'advanced' + + u'/detailed service print', QtCore.QVariant(True)).toBool(): + continue if item.is_text(): # Add the text of the service item. for slide in item.get_frames(): From 6ac0f162a3522ffbf0015385029f41ad5b9ce961 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 21:39:55 +0100 Subject: [PATCH 046/104] removed white spaces --- openlp/core/lib/toolbar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index f2c7f1b0d..b1aa3d96f 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -73,13 +73,13 @@ class OpenLPToolbar(QtGui.QToolBar): ``checkable`` If *True* the button has two, *off* and *on*, states. Default is *False*, which means the buttons has only one state. - + ``shortcut`` The primary shortcut for this action - + ``alternate`` The alternate shortcut for this action - + ``context`` Specify the context in which this shortcut is valid """ From 9744d246d6399692156942d72d61b7695b260d5e Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 00:33:50 +0000 Subject: [PATCH 047/104] Deduplication --- openlp/core/lib/__init__.py | 14 ++++ openlp/core/lib/mediamanageritem.py | 22 ++++++ openlp/core/ui/serviceitemeditdialog.py | 10 +-- openlp/core/ui/serviceitemeditform.py | 27 ++++--- openlp/core/ui/servicenotedialog.py | 48 ------------- openlp/core/ui/servicenoteform.py | 22 ++++-- openlp/core/ui/slidecontroller.py | 31 ++++---- openlp/core/ui/themestab.py | 28 ++++---- openlp/plugins/bibles/lib/mediaitem.py | 43 +++++------ .../plugins/custom/forms/editcustomdialog.py | 11 +-- openlp/plugins/custom/forms/editcustomform.py | 2 +- .../custom/forms/editcustomslidedialog.py | 11 +-- openlp/plugins/custom/lib/mediaitem.py | 11 +-- .../presentations/lib/messagelistener.py | 2 +- openlp/plugins/songs/forms/authorsdialog.py | 12 +--- openlp/plugins/songs/forms/editsongdialog.py | 11 +-- openlp/plugins/songs/forms/editsongform.py | 22 +++--- openlp/plugins/songs/forms/editversedialog.py | 14 +--- openlp/plugins/songs/forms/songbookdialog.py | 12 +--- .../songs/forms/songmaintenanceform.py | 71 ++++++++----------- openlp/plugins/songs/forms/topicsdialog.py | 12 +--- openlp/plugins/songs/lib/easislidesimport.py | 50 +++++++------ openlp/plugins/songs/lib/mediaitem.py | 11 +-- 23 files changed, 205 insertions(+), 292 deletions(-) delete mode 100644 openlp/core/ui/servicenotedialog.py diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 33280f83b..ee2b68c91 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -319,6 +319,20 @@ def check_directory_exists(dir): if not os.path.exists(dir): os.makedirs(dir) +def dialogButtonsSaveCancel(parent): + """ + Return a standard dialog button box with save and cancel buttons. + """ + button_box = QtGui.QDialogButtonBox(parent) + button_box.setStandardButtons(QtGui.QDialogButtonBox.Save | + QtGui.QDialogButtonBox.Cancel) + button_box.setObjectName(u'%sButtonBox' % parent) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), + parent.accept) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), + parent.reject) + return button_box + from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \ BackgroundType, HorizontalType, VerticalType from displaytags import DisplayTags diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9565a9b37..f127cd998 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -540,3 +540,25 @@ class MediaManagerItem(QtGui.QWidget): individual service items need to be processed by the plugins """ pass + + def _getIdOfItemToGenerate(self, item, remoteItem): + """ + Utility method to check items being submitted for slide generation. + + ``item`` + The item to check. + + ``remoteItem`` + The id to assign if the slide generation was remotely triggered. + """ + if item is None: + if self.remoteTriggered is None: + item = self.listView.currentItem() + if item is None: + return False + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + else: + item_id = remoteItem + else: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + return item_id diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 3e1079ded..025a7d40c 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon +from openlp.core.lib import translate, build_icon, dialogButtonsSaveCancel class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -52,12 +52,8 @@ class Ui_ServiceItemEditDialog(object): self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) - self.buttonBox = QtGui.QDialogButtonBox(serviceItemEditDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2) - + self.dialogLayout.addWidget( + dialogButtonsSaveCancel(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index edd4ee29f..0621a44bd 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -46,10 +46,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtCore.SIGNAL(u'clicked()'), self.onItemDown) QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'), self.onItemDelete) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), self.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), self.reject) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -100,27 +96,30 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): """ Move the current row up in the list. """ - item = self.listWidget.currentItem() - if not item: - return - row = self.listWidget.row(item) - temp = self.itemList[row] - self.itemList.remove(self.itemList[row]) - self.itemList.insert(row - 1, temp) - self.loadData() - self.listWidget.setCurrentRow(row - 1) + self.__moveItem(u'up') def onItemDown(self): """ Move the current row down in the list """ + self.__moveItem(u'down') + + def __moveItem(self, direction=u''): + """ + Move the current item. + """ + if not direction: + return item = self.listWidget.currentItem() if not item: return row = self.listWidget.row(item) temp = self.itemList[row] self.itemList.remove(self.itemList[row]) - self.itemList.insert(row + 1, temp) + if direction == u'up': + self.itemList.insert(row - 1, temp) + else: + self.itemList.insert(row + 1, temp) self.loadData() self.listWidget.setCurrentRow(row + 1) diff --git a/openlp/core/ui/servicenotedialog.py b/openlp/core/ui/servicenotedialog.py deleted file mode 100644 index 9a45dae7c..000000000 --- a/openlp/core/ui/servicenotedialog.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate - -class Ui_ServiceNoteEdit(object): - def setupUi(self, serviceNoteEdit): - serviceNoteEdit.setObjectName(u'serviceNoteEdit') - self.dialogLayout = QtGui.QVBoxLayout(serviceNoteEdit) - self.dialogLayout.setObjectName(u'verticalLayout') - self.textEdit = QtGui.QTextEdit(serviceNoteEdit) - self.textEdit.setObjectName(u'textEdit') - self.dialogLayout.addWidget(self.textEdit) - self.buttonBox = QtGui.QDialogButtonBox(serviceNoteEdit) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) - self.retranslateUi(serviceNoteEdit) - QtCore.QMetaObject.connectSlotsByName(serviceNoteEdit) - - def retranslateUi(self, serviceNoteEdit): - serviceNoteEdit.setWindowTitle( - translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index de689e842..32e7dfe40 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,6 +26,7 @@ from PyQt4 import QtCore, QtGui +from openlp.core.lib import dialogButtonsSaveCancel, translate from servicenotedialog import Ui_ServiceNoteEdit class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): @@ -37,8 +38,19 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): Constructor """ QtGui.QDialog.__init__(self, parent) - self.setupUi(self) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - self.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - self.reject) \ No newline at end of file + self.setupUi() + self.retranslateUi() + + def setupUi(self): + self.setObjectName(u'serviceNoteEdit') + self.dialogLayout = QtGui.QVBoxLayout(self) + self.dialogLayout.setObjectName(u'verticalLayout') + self.textEdit = QtGui.QTextEdit(self) + self.textEdit.setObjectName(u'textEdit') + self.dialogLayout.addWidget(self.textEdit) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(self)) + QtCore.QMetaObject.connectSlotsByName(self) + + def retranslateUi(self): + self.setWindowTitle( + translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 916bf68c3..223624c4f 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -482,14 +482,7 @@ class SlideController(QtGui.QWidget): def onSongBarHandler(self): request = unicode(self.sender().text()) slideno = self.slideList[request] - if slideno > self.previewListWidget.rowCount(): - self.previewListWidget.selectRow( - self.previewListWidget.rowCount() - 1) - else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__updatePreviewSelection(slideno) self.onSlideSelected() def receiveSpinDelay(self, value): @@ -665,14 +658,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.resizeRowsToContents() self.previewListWidget.setColumnWidth(0, self.previewListWidget.viewport().size().width()) - if slideno > self.previewListWidget.rowCount(): - self.previewListWidget.selectRow( - self.previewListWidget.rowCount() - 1) - else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__updatePreviewSelection(slideno) self.enableToolBar(serviceItem) # Pass to display for viewing self.display.buildHtml(self.serviceItem) @@ -683,6 +669,19 @@ class SlideController(QtGui.QWidget): Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) + 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) + else: + if slideno + 1 < self.previewListWidget.rowCount(): + self.previewListWidget.scrollToItem( + self.previewListWidget.item(slideno + 1, 0)) + self.previewListWidget.selectRow(slideno) + def onTextRequest(self): """ Return the text for the current item in controller diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index a440a564e..441b95155 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -165,13 +165,7 @@ class ThemesTab(SettingsTab): self.global_theme = unicode(self.DefaultComboBox.currentText()) self.parent.renderManager.set_global_theme( self.global_theme, self.theme_level) - image = self.parent.ThemeManagerContents.getPreviewImage( - self.global_theme) - preview = QtGui.QPixmap(unicode(image)) - if not preview.isNull(): - preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) + self.__previewGlobalTheme() def updateThemeList(self, theme_list): """ @@ -198,10 +192,16 @@ class ThemesTab(SettingsTab): self.parent.renderManager.set_global_theme( self.global_theme, self.theme_level) if self.global_theme is not u'': - image = self.parent.ThemeManagerContents.getPreviewImage( - self.global_theme) - preview = QtGui.QPixmap(unicode(image)) - if not preview.isNull(): - preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) + self.__previewGlobalTheme() + + def __previewGlobalTheme(self): + """ + Utility method to update the global theme preview image. + """ + image = self.parent.ThemeManagerContents.getPreviewImage( + self.global_theme) + preview = QtGui.QPixmap(unicode(image)) + if not preview.isNull(): + preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) + self.DefaultListView.setPixmap(preview) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 614990654..009a19b60 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -525,19 +525,7 @@ class BibleMediaItem(MediaManagerItem): if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: - # 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 item_second_bible and second_bible or not item_second_bible and \ - not second_bible: - self.displayResults(bible, second_bible) - elif criticalErrorMessageBox( - message=translate('BiblePlugin.MediaItem', - 'You cannot combine single and second bible verses. 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) + self.__checkSecondBible() else: self.displayResults(bible, second_bible) Receiver.send_message(u'cursor_normal') @@ -577,24 +565,29 @@ class BibleMediaItem(MediaManagerItem): if self.quickClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: - bitem = self.listView.item(0) - 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 criticalErrorMessageBox( - message=translate('BiblePlugin.MediaItem', - 'You cannot combine single and second bible verses. 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) + self.__checkSecondBible() elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') + def __checkSecondBible(self): + """ + 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 item_second_bible and second_bible or not item_second_bible and \ + not second_bible: + self.displayResults(bible, second_bible) + elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + 'You cannot combine single and second bible verses. 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 diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index d778b1dfe..1703d3363 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -93,16 +93,9 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = QtGui.QDialogButtonBox(customEditDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(customEditDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - customEditDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - customEditDialog.closePressed) QtCore.QMetaObject.connectSlotsByName(customEditDialog) def retranslateUi(self, customEditDialog): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index ebc917e99..e274c2395 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -136,7 +136,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if preview: self.previewButton.setVisible(True) - def closePressed(self): + def reject(self): Receiver.send_message(u'custom_edit_clear') self.close() diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 1f4bf5b14..2f95e4755 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, SpellTextEdit +from openlp.core.lib import translate, SpellTextEdit, dialogButtonsSaveCancel class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -36,20 +36,13 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, QtGui.QDialogButtonBox.ActionRole) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customSlideEditDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - customSlideEditDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - customSlideEditDialog.reject) QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog) def retranslateUi(self, customSlideEditDialog): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 9b8115956..ec915b0a9 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -146,16 +146,7 @@ class CustomMediaItem(MediaManagerItem): raw_footer = [] slide = None theme = None - if item is None: - if self.remoteTriggered is None: - item = self.listView.currentItem() - if item is None: - return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - else: - item_id = self.remoteCustom - else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self._getIdOfItemToGenerate(item, self.remoteCustom) service_item.add_capability(ItemCapabilities.AllowsEdit) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 19abadf0d..4d926ad3d 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -116,7 +116,7 @@ class Controller(object): def last(self): """ - Based on the handler passed at startup triggers the first slide + Based on the handler passed at startup triggers the last slide """ log.debug(u'Live = %s, last' % self.is_live) if not self.is_live: diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 6f1c7f2a4..860e8b5ea 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import dialogButtonsSaveCancel, translate class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -55,17 +55,9 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.buttonBox = QtGui.QDialogButtonBox(authorsDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), authorsDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), authorsDialog.reject) QtCore.QMetaObject.connectSlotsByName(authorsDialog) def retranslateUi(self, authorsDialog): diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 675108af7..732f8e815 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -264,16 +264,9 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = QtGui.QDialogButtonBox(editSongDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), editSongDialog.closePressed) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), editSongDialog.accept) QtCore.QMetaObject.connectSlotsByName(editSongDialog) def retranslateUi(self, editSongDialog): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b36ea55e1..5e9fc1711 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -333,11 +333,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): author = Author.populate(first_name=text.rsplit(u' ', 1)[0], last_name=text.rsplit(u' ', 1)[1], display_name=text) self.manager.save_object(author) - author_item = QtGui.QListWidgetItem( - unicode(author.display_name)) - author_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(author.id)) - self.authorsListView.addItem(author_item) + self.__addAuthorToList(author) self.loadAuthors() self.authorsComboBox.setCurrentIndex(0) else: @@ -351,11 +347,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.')) else: - author_item = QtGui.QListWidgetItem(unicode( - author.display_name)) - author_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(author.id)) - self.authorsListView.addItem(author_item) + self.__addAuthorToList(author) self.authorsComboBox.setCurrentIndex(0) else: QtGui.QMessageBox.warning(self, @@ -365,6 +357,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'or type in a new author and click the "Add Author to ' 'Song" button to add the new author.')) + def __addAuthorToList(self, author): + """ + Add an author to the author list. + """ + author_item = QtGui.QListWidgetItem(unicode(author.display_name)) + author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + self.authorsListView.addItem(author_item) + def onAuthorsListViewPressed(self): if self.authorsListView.count() > 1: self.authorRemoveButton.setEnabled(True) @@ -653,7 +653,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.books = [] self.topics = [] - def closePressed(self): + def reject(self): """ Exit Dialog and do not save """ diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 1710d8b93..5680dd8f6 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, SpellTextEdit +from openlp.core.lib import build_icon, dialogButtonsSaveCancel, translate, \ + SpellTextEdit from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): @@ -59,17 +60,8 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.buttonBox = QtGui.QDialogButtonBox(editVerseDialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(editVerseDialog)) self.retranslateUi(editVerseDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - editVerseDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - editVerseDialog.reject) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) def retranslateUi(self, editVerseDialog): diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index 9b9da43bf..eb1220d66 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, dialogButtonsSaveCancel class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -49,17 +49,9 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.buttonBox = QtGui.QDialogButtonBox(songBookDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), songBookDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), songBookDialog.reject) QtCore.QMetaObject.connectSlotsByName(songBookDialog) def retranslateUi(self, songBookDialog): diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 6613a050b..2bc609ee2 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -310,12 +310,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'the existing author %s?')) % (author.display_name, temp_display_name, author.display_name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeAuthors(author) - self.resetAuthors() - Receiver.send_message(u'songs_load_list') - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(author, self.mergeAuthors, + self.resetAuthors) else: # We restore the author's old first and last name as well as # his display name. @@ -350,11 +346,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'with topic %s use the existing topic %s?')) % (topic.name, temp_name, topic.name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeTopics(topic) - self.resetTopics() - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(topic, self.mergeTopics, self.resetTopics) else: # We restore the topics's old name. topic.name = temp_name @@ -392,16 +384,23 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'with book %s use the existing book %s?')) % (book.name, temp_name, book.name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeBooks(book) - self.resetBooks() - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(book, self.mergeBooks, self.resetBooks) else: # We restore the book's old name and publisher. book.name = temp_name book.publisher = temp_publisher + def __mergeObjects(self, object, merge, reset): + """ + Utility method to merge two objects to leave one in the database. + """ + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + merge(object) + reset() + Receiver.send_message(u'songs_load_list') + Receiver.send_message(u'cursor_normal') + def mergeAuthors(self, old_author): """ Merges two authors into one author. @@ -508,42 +507,32 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorsListRowChanged(self, row): """ - Called when the *authorsListWidget* current's row has changed. - - ``row`` - The current row. If there is no current row, the value is -1 + Called when the *authorsListWidget*s current row has changed. """ - if row == -1: - self.authorsDeleteButton.setEnabled(False) - self.authorsEditButton.setEnabled(False) - else: - self.authorsDeleteButton.setEnabled(True) - self.authorsEditButton.setEnabled(True) + self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton) def onTopicsListRowChanged(self, row): """ - Called when the *booksListWidget* current's row has changed. - - ``row`` - The current row. If there is no current row, the value is -1. + Called when the *topicsListWidget*s current row has changed. """ - if row == -1: - self.topicsDeleteButton.setEnabled(False) - self.topicsEditButton.setEnabled(False) - else: - self.topicsDeleteButton.setEnabled(True) - self.topicsEditButton.setEnabled(True) + self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton) def onBooksListRowChanged(self, row): """ - Called when the *booksListWidget* current's row has changed. + Called when the *booksListWidget*s current row has changed. + """ + self.__rowChange(row, self.booksEditButton, self.booksDeleteButton) + + def __rowChange(self, row, editButton, deleteButton): + """ + Utility method to toggle if buttons are enabled. ``row`` The current row. If there is no current row, the value is -1. """ if row == -1: - self.booksDeleteButton.setEnabled(False) - self.booksEditButton.setEnabled(False) + deleteButton.setEnabled(False) + editButton.setEnabled(False) else: - self.booksDeleteButton.setEnabled(True) - self.booksEditButton.setEnabled(True) + deleteButton.setEnabled(True) + editButton.setEnabled(True) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index ca0bbed97..8b4ea60bb 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, dialogButtonsSaveCancel class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -43,17 +43,9 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.buttonBox = QtGui.QDialogButtonBox(topicsDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), topicsDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), topicsDialog.reject) QtCore.QMetaObject.connectSlotsByName(topicsDialog) def retranslateUi(self, topicsDialog): diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 84e7a3841..fe44c763a 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -133,30 +133,38 @@ class EasiSlidesImport(SongImport): pass def _add_copyright(self, song): + """ + Assign the copyright information from the import to the song being + created. + + ``song`` + The current song being imported. + """ copyright = [] - try: - copyright.append(unicode(song.Copyright).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding Copyright') - self._success = False - except AttributeError: - pass - try: - copyright.append(unicode(song.LicenceAdmin1).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding LicenceAdmin1') - self._success = False - except AttributeError: - pass - try: - copyright.append(unicode(song.LicenceAdmin2).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding LicenceAdmin2') - self._success = False - except AttributeError: - pass + self.__add_copyright_element(copyright, song.Copyright) + self.__add_copyright_element(copyright, song.LicenceAdmin1) + self.__add_copyright_element(copyright, song.LicenceAdmin2) self.add_copyright(u' '.join(copyright)) + def __add_copyright_element(self, copyright, element): + """ + Add a piece of copyright to the total copyright information for the + song. + + ``copyright`` + The array to add the information to. + + ``element`` + The imported variable to get the data from. + """ + try: + copyright.append(unicode(element).strip()) + except UnicodeDecodeError: + log.exception(u'Unicode error decoding %s' % element) + self._success = False + except AttributeError: + pass + def _parse_and_add_lyrics(self, song): try: lyrics = unicode(song.Contents).strip() diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index dc51f97f5..a62471c2d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -337,16 +337,7 @@ class SongMediaItem(MediaManagerItem): author_list = u'' author_audit = [] ccli = u'' - if item is None: - if self.remoteTriggered is None: - item = self.listView.currentItem() - if item is None: - return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - else: - item_id = self.remoteSong - else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self._getIdOfItemToGenerate(item, self.remoteSong) service_item.add_capability(ItemCapabilities.AllowsEdit) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) From f63b046d9bc62378e32f74896dfbfa5df9d6030d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 01:02:44 +0000 Subject: [PATCH 048/104] Fix silly incorrectly formatted name --- openlp/core/lib/__init__.py | 2 +- openlp/core/ui/serviceitemeditdialog.py | 4 ++-- openlp/core/ui/servicenoteform.py | 4 ++-- openlp/plugins/custom/forms/editcustomdialog.py | 4 ++-- openlp/plugins/custom/forms/editcustomslidedialog.py | 4 ++-- openlp/plugins/songs/forms/authorsdialog.py | 4 ++-- openlp/plugins/songs/forms/editsongdialog.py | 4 ++-- openlp/plugins/songs/forms/editversedialog.py | 4 ++-- openlp/plugins/songs/forms/songbookdialog.py | 4 ++-- openlp/plugins/songs/forms/topicsdialog.py | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ee2b68c91..f07d7c78d 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -319,7 +319,7 @@ def check_directory_exists(dir): if not os.path.exists(dir): os.makedirs(dir) -def dialogButtonsSaveCancel(parent): +def save_cancel_button_box(parent): """ Return a standard dialog button box with save and cancel buttons. """ diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 025a7d40c..0993c48b2 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon, dialogButtonsSaveCancel +from openlp.core.lib import translate, build_icon, save_cancel_button_box class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -53,7 +53,7 @@ class Ui_ServiceItemEditDialog(object): self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( - dialogButtonsSaveCancel(serviceItemEditDialog), 1, 0, 1, 2) + save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 32e7dfe40..215ff2b9d 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import dialogButtonsSaveCancel, translate +from openlp.core.lib import save_cancel_button_box, translate from servicenotedialog import Ui_ServiceNoteEdit class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): @@ -48,7 +48,7 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): self.textEdit = QtGui.QTextEdit(self) self.textEdit.setObjectName(u'textEdit') self.dialogLayout.addWidget(self.textEdit) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(self)) + self.dialogLayout.addWidget(save_cancel_button_box(self)) QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self): diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 1703d3363..3d5e3a3f7 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel +from openlp.core.lib import build_icon, translate, save_cancel_button_box class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -93,7 +93,7 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = dialogButtonsSaveCancel(customEditDialog) + self.buttonBox = save_cancel_button_box(customEditDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog) diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 2f95e4755..1325590d9 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, SpellTextEdit, dialogButtonsSaveCancel +from openlp.core.lib import translate, SpellTextEdit, save_cancel_button_box class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -36,7 +36,7 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = dialogButtonsSaveCancel(customSlideEditDialog) + self.buttonBox = save_cancel_button_box(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 860e8b5ea..daae83525 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import dialogButtonsSaveCancel, translate +from openlp.core.lib import translate, save_cancel_button_box class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -55,7 +55,7 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(authorsDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(authorsDialog) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 732f8e815..4714ab093 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel +from openlp.core.lib import build_icon, translate, save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -264,7 +264,7 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = dialogButtonsSaveCancel(editSongDialog) + self.buttonBox = save_cancel_button_box(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) QtCore.QMetaObject.connectSlotsByName(editSongDialog) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 5680dd8f6..d74da50d1 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, dialogButtonsSaveCancel, translate, \ +from openlp.core.lib import build_icon, save_cancel_button_box, translate, \ SpellTextEdit from openlp.plugins.songs.lib import VerseType @@ -60,7 +60,7 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(editVerseDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog)) self.retranslateUi(editVerseDialog) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index eb1220d66..757a629ab 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, dialogButtonsSaveCancel +from openlp.core.lib import translate, save_cancel_button_box class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -49,7 +49,7 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(songBookDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(songBookDialog) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index 8b4ea60bb..38c45407f 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, dialogButtonsSaveCancel +from openlp.core.lib import translate, save_cancel_button_box class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -43,7 +43,7 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(topicsDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(topicsDialog) From 807298df6025fe463c60b018d794619f8c59e4e3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 1 Feb 2011 06:04:49 +0000 Subject: [PATCH 049/104] Fix Theme to XML conversion for BOLD Fixes: https://launchpad.net/bugs/710265 --- openlp/core/lib/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 70517b34d..8d2c8f356 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -156,7 +156,7 @@ class VerticalType(object): Middle = 1 Bottom = 2 -boolean_list = [u'italics', u'override', u'outline', u'shadow', +boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow', u'slide_transition'] integer_list = [u'size', u'line_adjustment', u'x', u'height', u'y', From cfb263cd821338eff00d336c391aea2d858d0897 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 Feb 2011 07:27:19 +0100 Subject: [PATCH 050/104] --- openlp/core/ui/servicemanager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6b0b84472..d43e06fe7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1192,12 +1192,14 @@ class ServiceManager(QtGui.QWidget): printDialog = QtGui.QPrintDialog() if not printDialog.exec_(): return - text = u'

%s

' % translate('OpenLP.ServiceManager', + text = u'

%s

' % translate('OpenLP.ServiceManager', + 'Service Order Sheet') + text += u'%s' % translate('OpenLP.ServiceManager', 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] # add the title - text += u'

%s

' % (item.icon, + text += u'

%s

' % (item.icon, item.get_display_title()) if not QtCore.QSettings().value(u'advanced' + u'/detailed service print', QtCore.QVariant(True)).toBool(): From 40e9bb566b6b337fb9a38511a7296136ee6a5abc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 13:39:17 +0000 Subject: [PATCH 051/104] Fix variable passing --- openlp/plugins/bibles/lib/mediaitem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 009a19b60..de2649b31 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -525,7 +525,7 @@ class BibleMediaItem(MediaManagerItem): if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: - self.__checkSecondBible() + self.__checkSecondBible(bible, second_bible) else: self.displayResults(bible, second_bible) Receiver.send_message(u'cursor_normal') @@ -565,14 +565,14 @@ class BibleMediaItem(MediaManagerItem): if self.quickClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: - self.__checkSecondBible() + self.__checkSecondBible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - def __checkSecondBible(self): + def __checkSecondBible(self, bible, second_bible): """ Check if the first item is a second bible item or not. """ From 91540c221a753398641d267ad350f44df90b2eb9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 18:05:59 +0000 Subject: [PATCH 052/104] Cleanups and fix song edit form --- openlp/core/ui/mainwindow.py | 8 ++--- openlp/core/ui/servicenoteform.py | 3 +- openlp/core/ui/slidecontroller.py | 24 ++++++------- openlp/core/ui/themewizard.py | 34 +++++++++---------- openlp/plugins/songs/forms/editsongform.py | 8 +++-- .../songs/forms/songmaintenanceform.py | 8 ++--- openlp/plugins/songs/lib/easislidesimport.py | 16 ++++----- 7 files changed, 50 insertions(+), 51 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d8bedade3..b84801aff 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -87,10 +87,10 @@ class Ui_MainWindow(object): self.screens, True) previewVisible = QtCore.QSettings().value( u'user interface/preview panel', QtCore.QVariant(True)).toBool() - self.previewController.Panel.setVisible(previewVisible) + self.previewController.panel.setVisible(previewVisible) liveVisible = QtCore.QSettings().value(u'user interface/live panel', QtCore.QVariant(True)).toBool() - self.liveController.Panel.setVisible(liveVisible) + self.liveController.panel.setVisible(liveVisible) # Create menu self.MenuBar = QtGui.QMenuBar(mainWindow) self.MenuBar.setObjectName(u'MenuBar') @@ -926,7 +926,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ - self.previewController.Panel.setVisible(visible) + self.previewController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QVariant(visible)) self.ViewPreviewPanel.setChecked(visible) @@ -941,7 +941,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ - self.liveController.Panel.setVisible(visible) + self.liveController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/live panel', QtCore.QVariant(visible)) self.ViewLivePanel.setChecked(visible) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 215ff2b9d..5cb68d03f 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -27,9 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import save_cancel_button_box, translate -from servicenotedialog import Ui_ServiceNoteEdit -class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): +class ServiceNoteForm(QtGui.QDialog): """ This is the form that is used to edit the verses of the song. """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 223624c4f..ab8a656ff 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -77,14 +77,14 @@ class SlideController(QtGui.QWidget): self.selectedRow = 0 self.serviceItem = None self.alertTab = None - self.Panel = QtGui.QWidget(parent.ControlSplitter) + self.panel = QtGui.QWidget(parent.ControlSplitter) self.slideList = {} # Layout for holding panel - self.panelLayout = QtGui.QVBoxLayout(self.Panel) + self.panelLayout = QtGui.QVBoxLayout(self.panel) self.panelLayout.setSpacing(0) self.panelLayout.setMargin(0) # Type label for the top of the slide controller - self.typeLabel = QtGui.QLabel(self.Panel) + self.typeLabel = QtGui.QLabel(self.panel) if self.isLive: self.typeLabel.setText(translate('OpenLP.SlideController', 'Live')) self.split = 1 @@ -98,7 +98,7 @@ class SlideController(QtGui.QWidget): self.typeLabel.setAlignment(QtCore.Qt.AlignCenter) self.panelLayout.addWidget(self.typeLabel) # Splitter - self.splitter = QtGui.QSplitter(self.Panel) + self.splitter = QtGui.QSplitter(self.panel) self.splitter.setOrientation(QtCore.Qt.Vertical) self.panelLayout.addWidget(self.splitter) # Actual controller section @@ -185,13 +185,13 @@ class SlideController(QtGui.QWidget): u'Stop Loop', u':/media/media_stop.png', translate('OpenLP.SlideController', 'Stop continuous loop'), self.onStopLoop) - self.DelaySpinBox = QtGui.QSpinBox() - self.DelaySpinBox.setMinimum(1) - self.DelaySpinBox.setMaximum(180) - self.toolbar.addToolbarWidget(u'Image SpinBox', self.DelaySpinBox) - self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController', + self.delaySpinBox = QtGui.QSpinBox() + self.delaySpinBox.setMinimum(1) + self.delaySpinBox.setMaximum(180) + self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox) + self.delaySpinBox.setSuffix(translate('OpenLP.SlideController', 's')) - self.DelaySpinBox.setToolTip(translate('OpenLP.SlideController', + self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds')) else: self.toolbar.addToolbarSeparator(u'Close Separator') @@ -486,7 +486,7 @@ class SlideController(QtGui.QWidget): self.onSlideSelected() def receiveSpinDelay(self, value): - self.DelaySpinBox.setValue(int(value)) + self.delaySpinBox.setValue(int(value)) def enableToolBar(self, item): """ @@ -998,7 +998,7 @@ class SlideController(QtGui.QWidget): """ if self.previewListWidget.rowCount() > 1: self.timer_id = self.startTimer( - int(self.DelaySpinBox.value()) * 1000) + int(self.delaySpinBox.value()) * 1000) self.toolbar.actions[u'Stop Loop'].setVisible(True) self.toolbar.actions[u'Start Loop'].setVisible(False) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 50e8109c5..aba486960 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -29,12 +29,11 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon class Ui_ThemeWizard(object): - def setupUi(self, ThemeWizard): - ThemeWizard.setObjectName(u'OpenLP.ThemeWizard') - ThemeWizard.setModal(True) - ThemeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - ThemeWizard.setOptions( - QtGui.QWizard.IndependentPages | + def setupUi(self, themeWizard): + themeWizard.setObjectName(u'OpenLP.ThemeWizard') + themeWizard.setModal(True) + themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) + themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page self.welcomePage = QtGui.QWizardPage() @@ -52,7 +51,7 @@ class Ui_ThemeWizard(object): self.informationLabel.setObjectName(u'InformationLabel') self.welcomeLayout.addWidget(self.informationLabel) self.welcomeLayout.addStretch() - ThemeWizard.addPage(self.welcomePage) + themeWizard.addPage(self.welcomePage) # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') @@ -142,7 +141,7 @@ class Ui_ThemeWizard(object): self.imageSpacer) self.backgroundStack.addWidget(self.imageWidget) self.backgroundLayout.addLayout(self.backgroundStack) - ThemeWizard.addPage(self.backgroundPage) + themeWizard.addPage(self.backgroundPage) # Main Area Page self.mainAreaPage = QtGui.QWizardPage() self.mainAreaPage.setObjectName(u'MainAreaPage') @@ -225,7 +224,7 @@ class Ui_ThemeWizard(object): self.shadowSizeSpinBox.setObjectName(u'ShadowSizeSpinBox') self.shadowLayout.addWidget(self.shadowSizeSpinBox) self.mainAreaLayout.addRow(self.shadowCheckBox, self.shadowLayout) - ThemeWizard.addPage(self.mainAreaPage) + themeWizard.addPage(self.mainAreaPage) # Footer Area Page self.footerAreaPage = QtGui.QWizardPage() self.footerAreaPage.setObjectName(u'FooterAreaPage') @@ -251,7 +250,7 @@ class Ui_ThemeWizard(object): self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox') self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox) - ThemeWizard.addPage(self.footerAreaPage) + themeWizard.addPage(self.footerAreaPage) # Alignment Page self.alignmentPage = QtGui.QWizardPage() self.alignmentPage.setObjectName(u'AlignmentPage') @@ -276,7 +275,7 @@ class Ui_ThemeWizard(object): self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox') self.alignmentLayout.addRow(self.transitionsLabel, self.transitionsCheckBox) - ThemeWizard.addPage(self.alignmentPage) + themeWizard.addPage(self.alignmentPage) # Area Position Page self.areaPositionPage = QtGui.QWizardPage() self.areaPositionPage.setObjectName(u'AreaPositionPage') @@ -352,7 +351,7 @@ class Ui_ThemeWizard(object): self.footerPositionLayout.addRow(self.footerHeightLabel, self.footerHeightSpinBox) self.areaPositionLayout.addWidget(self.footerPositionGroupBox) - ThemeWizard.addPage(self.areaPositionPage) + themeWizard.addPage(self.areaPositionPage) # Preview Page self.previewPage = QtGui.QWizardPage() self.previewPage.setObjectName(u'PreviewPage') @@ -381,9 +380,8 @@ class Ui_ThemeWizard(object): self.previewBoxLabel.setObjectName(u'PreviewBoxLabel') self.previewAreaLayout.addWidget(self.previewBoxLabel) self.previewLayout.addWidget(self.previewArea) - ThemeWizard.addPage(self.previewPage) - - self.retranslateUi(ThemeWizard) + themeWizard.addPage(self.previewPage) + self.retranslateUi(themeWizard) QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.backgroundStack, QtCore.SLOT(u'setCurrentIndex(int)')) @@ -423,10 +421,10 @@ class Ui_ThemeWizard(object): QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerHeightSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QMetaObject.connectSlotsByName(ThemeWizard) + QtCore.QMetaObject.connectSlotsByName(themeWizard) - def retranslateUi(self, ThemeWizard): - ThemeWizard.setWindowTitle( + def retranslateUi(self, themeWizard): + themeWizard.setWindowTitle( translate('OpenLP.ThemeWizard', 'Theme Wizard')) self.titleLabel.setText( u'%s' % \ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 5e9fc1711..c3279e1a9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -648,6 +648,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Free up autocompletion memory on dialog exit """ + log.debug (u'SongEditForm.clearCaches') self.authors = [] self.themes = [] self.books = [] @@ -657,20 +658,21 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Exit Dialog and do not save """ + log.debug (u'SongEditForm.reject') Receiver.send_message(u'songs_edit_clear') self.clearCaches() - self.close() + QtGui.QDialog.reject(self) def accept(self): """ Exit Dialog and save song if valid """ - log.debug(u'accept') + log.debug(u'SongEditForm.accept') self.clearCaches() if self._validate_song(): self.saveSong() Receiver.send_message(u'songs_load_list') - self.close() + QtGui.QDialog.accept(self) def saveSong(self, preview=False): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 2bc609ee2..441182424 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -94,8 +94,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.typeListWidget.setFocus() return QtGui.QDialog.exec_(self) - def _getCurrentItemId(self, ListWidget): - item = ListWidget.currentItem() + def _getCurrentItemId(self, listWidget): + item = listWidget.currentItem() if item: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] return item_id @@ -390,13 +390,13 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher - def __mergeObjects(self, object, merge, reset): + def __mergeObjects(self, dbObject, merge, reset): """ Utility method to merge two objects to leave one in the database. """ Receiver.send_message(u'cursor_busy') Receiver.send_message(u'openlp_process_events') - merge(object) + merge(dbObject) reset() Receiver.send_message(u'songs_load_list') Receiver.send_message(u'cursor_normal') diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index fe44c763a..0b10ce428 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -140,25 +140,25 @@ class EasiSlidesImport(SongImport): ``song`` The current song being imported. """ - copyright = [] - self.__add_copyright_element(copyright, song.Copyright) - self.__add_copyright_element(copyright, song.LicenceAdmin1) - self.__add_copyright_element(copyright, song.LicenceAdmin2) - self.add_copyright(u' '.join(copyright)) + copyright_list = [] + self.__add_copyright_element(copyright_list, song.Copyright) + self.__add_copyright_element(copyright_list, song.LicenceAdmin1) + self.__add_copyright_element(copyright_list, song.LicenceAdmin2) + self.add_copyright(u' '.join(copyright_list)) - def __add_copyright_element(self, copyright, element): + def __add_copyright_element(self, copyright_list, element): """ Add a piece of copyright to the total copyright information for the song. - ``copyright`` + ``copyright_list`` The array to add the information to. ``element`` The imported variable to get the data from. """ try: - copyright.append(unicode(element).strip()) + copyright_list.append(unicode(element).strip()) except UnicodeDecodeError: log.exception(u'Unicode error decoding %s' % element) self._success = False From a31fda9463d270b433a900eba4a88b5fe29a58c4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 Feb 2011 19:22:48 +0100 Subject: [PATCH 053/104] fixed camelCase --- openlp/core/ui/mainwindow.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ea11c7d99..8477ccc24 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -175,10 +175,10 @@ class Ui_MainWindow(object): self.FileSaveAsItem = QtGui.QAction(mainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') - self.PrintServiceOrderItem = QtGui.QAction(mainWindow) - self.PrintServiceOrderItem.setObjectName(u'PrintServiceItem') + self.printServiceOrderItem = QtGui.QAction(mainWindow) + self.printServiceOrderItem.setObjectName(u'printServiceItem') mainWindow.actionList.add_action( - self.PrintServiceOrderItem, u'Print Service Order') + self.printServiceOrderItem, u'Print Service Order') self.FileExitItem = QtGui.QAction(mainWindow) self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) self.FileExitItem.setObjectName(u'FileExitItem') @@ -306,7 +306,7 @@ class Ui_MainWindow(object): (self.ExportThemeItem, self.ExportLanguageItem)) self.FileMenuActions = (self.FileNewItem, self.FileOpenItem, self.FileSaveItem, self.FileSaveAsItem, None, - self.PrintServiceOrderItem, None, self.FileImportMenu.menuAction(), + self.printServiceOrderItem, None, self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(), self.FileExitItem) add_actions(self.ViewModeMenu, (self.ModeDefaultItem, self.ModeSetupItem, self.ModeLiveItem)) @@ -385,11 +385,11 @@ class Ui_MainWindow(object): 'Save the current service under a new name.')) self.FileSaveAsItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+Shift+S')) - self.PrintServiceOrderItem.setText( + self.printServiceOrderItem.setText( translate('OpenLP.MainWindow', 'Print Service Order')) - self.PrintServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', + self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', 'Print the current Service Order.')) - self.PrintServiceOrderItem.setShortcut( + self.printServiceOrderItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+P')) self.FileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) @@ -577,7 +577,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.saveFileAs) - QtCore.QObject.connect(self.PrintServiceOrderItem, + QtCore.QObject.connect(self.printServiceOrderItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.printServiceOrder) # i18n set signals for languages From dd1f418f466492313d3614aea557dbce30427c3a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 19:16:51 +0000 Subject: [PATCH 054/104] Long line --- openlp/core/ui/advancedtab.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index db6efcf4c..f68131894 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -141,7 +141,8 @@ class AdvancedTab(SettingsTab): 'Hide the mouse cursor when moved over the display window')) self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Service Order Print')) - self.detailedServicePrintCheckBox.setText(translate('OpenLP.AdvancedTab', + self.detailedServicePrintCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Print slide texts and service item notes as well')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) From 5753afbca412c729bb0cf42a9d2b5ebcc0116c86 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 Feb 2011 21:23:41 +0100 Subject: [PATCH 055/104] fixed indent --- openlp/plugins/songs/lib/db.py | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 625466c09..fa42971b3 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -91,72 +91,72 @@ def init_schema(url): --------------- This table holds the names of all the authors. It has the following columns: - * id - * first_name - * last_name - * display_name + * id + * first_name + * last_name + * display_name *authors_songs* Table --------------------- This is a bridging table between the *authors* and *songs* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * author_id - * song_id + * author_id + * song_id *media_files* Table ------------------- - * id - * file_name - * type + * id + * file_name + * type *media_files_songs* Table ------------------------- - * media_file_id - * song_id + * media_file_id + * song_id *song_books* Table ------------------ The *song_books* table holds a list of books that a congregation gets their songs from, or old hymnals now no longer used. This table has the following columns: - * id - * name - * publisher + * id + * name + * publisher *songs* Table ------------- This table contains the songs, and each song has a list of attributes. The *songs* table has the following columns: - * id - * song_book_id - * title - * alternate_title - * lyrics - * verse_order - * copyright - * comments - * ccli_number - * song_number - * theme_name - * search_title - * search_lyrics + * id + * song_book_id + * title + * alternate_title + * lyrics + * verse_order + * copyright + * comments + * ccli_number + * song_number + * theme_name + * search_title + * search_lyrics *songs_topics* Table -------------------- This is a bridging table between the *songs* and *topics* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * song_id - * topic_id + * song_id + * topic_id *topics* Table -------------- The topics table holds a selection of topics that songs can cover. This is useful when a worship leader wants to select songs with a certain theme. This table has the following columns: - * id - * name + * id + * name """ session, metadata = init_db(url) From b28e073d5f3da9c0651cc5c4faffa67026d9ad66 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 00:33:13 +0000 Subject: [PATCH 056/104] Debugging aid for bad file errors --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 81599085b..084e95b5f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -526,7 +526,7 @@ class ServiceManager(QtGui.QWidget): 'File is not a valid service.')) log.exception(u'File contains no service data') except (IOError, NameError): - log.exception(u'Problem loading a service file') + log.exception(u'Problem loading service file %s' % filename) finally: if fileTo: fileTo.close() From 6568bd50393b293e83b8101db510e2b6cdaa8b20 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 01:40:36 +0000 Subject: [PATCH 057/104] Deduplicate wizards --- openlp/core/ui/themewizard.py | 18 ++----------- openlp/core/ui/wizard.py | 50 +++++++++++++++++------------------ 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index aba486960..fe5305454 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon +from openlp.core.ui.wizard import addWelcomePage class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -36,22 +37,7 @@ class Ui_ThemeWizard(object): themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(u':/wizards/wizard_createtheme.bmp')) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - themeWizard.addPage(self.welcomePage) + addWelcomePage(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index d3a0255b4..f57253d0e 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -63,36 +63,12 @@ class OpenLPWizard(QtGui.QWizard): self.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) - self.addWelcomePage(image) + addWelcomePage(self, image) self.addCustomPages() self.addProgressPage() self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(self) - def addWelcomePage(self, image): - """ - Add the opening welcome page to the wizard. - - ``image`` - A splash image for the wizard - """ - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(image)) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - self.addPage(self.welcomePage) - def addProgressPage(self): """ Add the progress page for the wizard. This page informs the user how @@ -169,3 +145,27 @@ class OpenLPWizard(QtGui.QWizard): self.finishButton.setVisible(True) self.cancelButton.setVisible(False) Receiver.send_message(u'openlp_process_events') + +def addWelcomePage(parent, image): + """ + Generate an opening welcome page for a wizard using a provided image. + + ``image`` + A splash image for the wizard. + """ + parent.welcomePage = QtGui.QWizardPage() + parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(image)) + parent.welcomePage.setObjectName(u'WelcomePage') + parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) + parent.welcomeLayout.setObjectName(u'WelcomeLayout') + parent.titleLabel = QtGui.QLabel(parent.welcomePage) + parent.titleLabel.setObjectName(u'TitleLabel') + parent.welcomeLayout.addWidget(parent.titleLabel) + parent.welcomeLayout.addSpacing(40) + parent.informationLabel = QtGui.QLabel(parent.welcomePage) + parent.informationLabel.setWordWrap(True) + parent.informationLabel.setObjectName(u'InformationLabel') + parent.welcomeLayout.addWidget(parent.informationLabel) + parent.welcomeLayout.addStretch() + parent.addPage(parent.welcomePage) From 0b36143ac291970ef222a5a841769dbcf992378d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 03:32:25 +0000 Subject: [PATCH 058/104] Slim down song importer UI --- openlp/plugins/songs/forms/songimportform.py | 154 +++++++------------ 1 file changed, 59 insertions(+), 95 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 3de251462..a5b0e713a 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -165,29 +165,29 @@ class SongImportForm(OpenLPWizard): self.formatStack = QtGui.QStackedLayout() self.formatStack.setObjectName(u'FormatStack') # OpenLP 2.0 - self.addSingleFileSelectItem(u'openLP2') + self.addFileSelectItem(u'openLP2', single_select=True) # openlp.org 1.x - self.addSingleFileSelectItem(u'openLP1', None, True) + self.addFileSelectItem(u'openLP1', None, True, True) # OpenLyrics - self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True) + self.addFileSelectItem(u'openLyrics', u'OpenLyrics', True) # Open Song - self.addMultiFileSelectItem(u'openSong', u'OpenSong') + self.addFileSelectItem(u'openSong', u'OpenSong') # Words of Worship - self.addMultiFileSelectItem(u'wordsOfWorship') + self.addFileSelectItem(u'wordsOfWorship') # CCLI File import - self.addMultiFileSelectItem(u'ccli') + self.addFileSelectItem(u'ccli') # Songs of Fellowship - self.addMultiFileSelectItem(u'songsOfFellowship', None, True) + self.addFileSelectItem(u'songsOfFellowship', None, True) # Generic Document/Presentation import - self.addMultiFileSelectItem(u'generic', None, True) + self.addFileSelectItem(u'generic', None, True) # EasySlides - self.addSingleFileSelectItem(u'easiSlides') + self.addFileSelectItem(u'easiSlides', single_select=True) # EasyWorship - self.addSingleFileSelectItem(u'ew') + self.addFileSelectItem(u'ew', single_select=True) # Words of Worship - self.addMultiFileSelectItem(u'songBeamer') + self.addFileSelectItem(u'songBeamer') # Commented out for future use. -# self.addSingleFileSelectItem(u'csv', u'CSV') +# self.addFileSelectItem(u'csv', u'CSV', single_select=True) self.sourceLayout.addLayout(self.formatStack) self.addPage(self.sourcePage) @@ -318,16 +318,6 @@ class SongImportForm(OpenLPWizard): self.openLP2FilenameLabel.minimumSizeHint().width()) self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openLP2FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openLP1FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.easiSlidesFormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Fixed) -# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, -# QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -791,52 +781,8 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.SongImportForm', 'Your song import failed.')) - def addSingleFileSelectItem(self, prefix, obj_prefix=None, - can_disable=False): - if not obj_prefix: - obj_prefix = prefix - page = QtGui.QWidget() - page.setObjectName(obj_prefix + u'Page') - if can_disable: - importWidget = self.disablableWidget(page, prefix, obj_prefix) - else: - importWidget = page - importLayout = QtGui.QFormLayout(importWidget) - importLayout.setMargin(0) - if can_disable: - importLayout.setObjectName(obj_prefix + u'ImportLayout') - else: - importLayout.setObjectName(obj_prefix + u'Layout') - filenameLabel = QtGui.QLabel(importWidget) - filenameLabel.setObjectName(obj_prefix + u'FilenameLabel') - fileLayout = QtGui.QHBoxLayout() - fileLayout.setObjectName(obj_prefix + u'FileLayout') - filenameEdit = QtGui.QLineEdit(importWidget) - filenameEdit.setObjectName(obj_prefix + u'FilenameEdit') - fileLayout.addWidget(filenameEdit) - browseButton = QtGui.QToolButton(importWidget) - browseButton.setIcon(self.openIcon) - browseButton.setObjectName(obj_prefix + u'BrowseButton') - fileLayout.addWidget(browseButton) - importLayout.addRow(filenameLabel, fileLayout) - formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer) - self.formatStack.addWidget(page) - setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FilenameLabel', filenameLabel) - setattr(self, prefix + u'FormLabelSpacer', formSpacer) - setattr(self, prefix + u'FileLayout', fileLayout) - setattr(self, prefix + u'FilenameEdit', filenameEdit) - setattr(self, prefix + u'BrowseButton', browseButton) - if can_disable: - setattr(self, prefix + u'ImportLayout', importLayout) - else: - setattr(self, prefix + u'Layout', importLayout) - self.formatComboBox.addItem(u'') - - def addMultiFileSelectItem(self, prefix, obj_prefix=None, - can_disable=False): + def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False, + single_select=False): if not obj_prefix: obj_prefix = prefix page = QtGui.QWidget() @@ -847,37 +793,55 @@ class SongImportForm(OpenLPWizard): importWidget = page importLayout = QtGui.QVBoxLayout(importWidget) importLayout.setMargin(0) - if can_disable: - importLayout.setObjectName(obj_prefix + u'ImportLayout') + importLayout.setObjectName(obj_prefix + u'ImportLayout') + if single_select: + fileLayout = QtGui.QHBoxLayout() + fileLayout.setObjectName(obj_prefix + u'FileLayout') + filenameLabel = QtGui.QLabel(importWidget) + filenameLabel.setObjectName(obj_prefix + u'FilenameLabel') + fileLayout.addWidget(filenameLabel) + filenameEdit = QtGui.QLineEdit(importWidget) + filenameEdit.setObjectName(obj_prefix + u'FilenameEdit') + fileLayout.addWidget(filenameEdit) + browseButton = QtGui.QToolButton(importWidget) + browseButton.setIcon(self.openIcon) + browseButton.setObjectName(obj_prefix + u'BrowseButton') + fileLayout.addWidget(browseButton) + formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Expanding) + importLayout.addLayout(fileLayout) + importLayout.addSpacerItem(formSpacer) else: - importLayout.setObjectName(obj_prefix + u'Layout') - fileListWidget = QtGui.QListWidget(importWidget) - fileListWidget.setSelectionMode( - QtGui.QAbstractItemView.ExtendedSelection) - fileListWidget.setObjectName(obj_prefix + u'FileListWidget') - importLayout.addWidget(fileListWidget) - buttonLayout = QtGui.QHBoxLayout() - buttonLayout.setObjectName(obj_prefix + u'ButtonLayout') - addButton = QtGui.QPushButton(importWidget) - addButton.setIcon(self.openIcon) - addButton.setObjectName(obj_prefix + u'AddButton') - buttonLayout.addWidget(addButton) - buttonLayout.addStretch() - removeButton = QtGui.QPushButton(importWidget) - removeButton.setIcon(self.deleteIcon) - removeButton.setObjectName(obj_prefix + u'RemoveButton') - buttonLayout.addWidget(removeButton) - importLayout.addLayout(buttonLayout) + fileListWidget = QtGui.QListWidget(importWidget) + fileListWidget.setSelectionMode( + QtGui.QAbstractItemView.ExtendedSelection) + fileListWidget.setObjectName(obj_prefix + u'FileListWidget') + importLayout.addWidget(fileListWidget) + buttonLayout = QtGui.QHBoxLayout() + buttonLayout.setObjectName(obj_prefix + u'ButtonLayout') + addButton = QtGui.QPushButton(importWidget) + addButton.setIcon(self.openIcon) + addButton.setObjectName(obj_prefix + u'AddButton') + buttonLayout.addWidget(addButton) + buttonLayout.addStretch() + removeButton = QtGui.QPushButton(importWidget) + removeButton.setIcon(self.deleteIcon) + removeButton.setObjectName(obj_prefix + u'RemoveButton') + buttonLayout.addWidget(removeButton) + importLayout.addLayout(buttonLayout) self.formatStack.addWidget(page) setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FileListWidget', fileListWidget) - setattr(self, prefix + u'ButtonLayout', buttonLayout) - setattr(self, prefix + u'AddButton', addButton) - setattr(self, prefix + u'RemoveButton', removeButton) - if can_disable: - setattr(self, prefix + u'ImportLayout', importLayout) + if single_select: + setattr(self, prefix + u'FilenameLabel', filenameLabel) + setattr(self, prefix + u'FileLayout', fileLayout) + setattr(self, prefix + u'FilenameEdit', filenameEdit) + setattr(self, prefix + u'BrowseButton', browseButton) else: - setattr(self, prefix + u'Layout', importLayout) + setattr(self, prefix + u'FileListWidget', fileListWidget) + setattr(self, prefix + u'ButtonLayout', buttonLayout) + setattr(self, prefix + u'AddButton', addButton) + setattr(self, prefix + u'RemoveButton', removeButton) + setattr(self, prefix + u'ImportLayout', importLayout) self.formatComboBox.addItem(u'') def disablableWidget(self, page, prefix, obj_prefix): From 078adca9367f7e2a3612483653daacb5f204ecd2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 04:35:26 +0000 Subject: [PATCH 059/104] Slim down song editer UI --- openlp/plugins/songs/forms/editsongdialog.py | 52 ++++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 4714ab093..b9b6e5baf 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -111,14 +111,8 @@ class Ui_EditSongDialog(object): self.authorsLayout.setObjectName(u'authorsLayout') self.authorAddLayout = QtGui.QHBoxLayout() self.authorAddLayout.setObjectName(u'authorAddLayout') - self.authorsComboBox = QtGui.QComboBox(self.authorsGroupBox) - self.authorsComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.authorsComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.authorsComboBox.setEditable(True) - self.authorsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.authorsComboBox.setObjectName(u'authorsComboBox') + self.authorsComboBox = editSongDialogComboBox( + self.authorsGroupBox, u'authorsComboBox') self.authorAddLayout.addWidget(self.authorsComboBox) self.authorAddButton = QtGui.QPushButton(self.authorsGroupBox) self.authorAddButton.setObjectName(u'authorAddButton') @@ -152,14 +146,8 @@ class Ui_EditSongDialog(object): self.topicsLayout.setObjectName(u'topicsLayout') self.topicAddLayout = QtGui.QHBoxLayout() self.topicAddLayout.setObjectName(u'topicAddLayout') - self.topicsComboBox = QtGui.QComboBox(self.topicsGroupBox) - self.topicsComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.topicsComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.topicsComboBox.setEditable(True) - self.topicsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.topicsComboBox.setObjectName(u'topicsComboBox') + self.topicsComboBox = editSongDialogComboBox( + self.topicsGroupBox, u'topicsComboBox') self.topicAddLayout.addWidget(self.topicsComboBox) self.topicAddButton = QtGui.QPushButton(self.topicsGroupBox) self.topicAddButton.setObjectName(u'topicAddButton') @@ -183,14 +171,8 @@ class Ui_EditSongDialog(object): self.songBookLayout.setObjectName(u'songBookLayout') self.songBookNameLabel = QtGui.QLabel(self.songBookGroupBox) self.songBookNameLabel.setObjectName(u'songBookNameLabel') - self.songBookComboBox = QtGui.QComboBox(self.songBookGroupBox) - self.songBookComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.songBookComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.songBookComboBox.setEditable(True) - self.songBookComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.songBookComboBox.setObjectName(u'songBookComboBox') + self.songBookComboBox = editSongDialogComboBox( + self.songBookGroupBox, u'songBookComboBox') self.songBookNameLabel.setBuddy(self.songBookComboBox) self.songBookLayout.addRow(self.songBookNameLabel, self.songBookComboBox) @@ -215,14 +197,8 @@ class Ui_EditSongDialog(object): self.themeGroupBox.setObjectName(u'themeGroupBox') self.themeLayout = QtGui.QHBoxLayout(self.themeGroupBox) self.themeLayout.setObjectName(u'themeLayout') - self.themeComboBox = QtGui.QComboBox(self.themeGroupBox) - self.themeComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.themeComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.themeComboBox.setEditable(True) - self.themeComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.themeComboBox.setObjectName(u'themeComboBox') + self.themeComboBox = editSongDialogComboBox( + self.themeGroupBox, u'themeComboBox') self.themeLayout.addWidget(self.themeComboBox) self.themeAddButton = QtGui.QPushButton(self.themeGroupBox) self.themeAddButton.setObjectName(u'themeAddButton') @@ -331,3 +307,15 @@ class Ui_EditSongDialog(object): self.songTabWidget.indexOf(self.themeTab), translate('SongsPlugin.EditSongForm', 'Theme, Copyright Info && Comments')) + +def editSongDialogComboBox(parent, name): + """ + Utility method to generate a standard combo box for this dialog. + """ + comboBox = QtGui.QComboBox(parent) + comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + comboBox.setEditable(True) + comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) + comboBox.setObjectName(name) + return comboBox From ceb64dd4770bb08d287313d4955eb8236b6916fc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 05:31:11 +0000 Subject: [PATCH 060/104] Slim mode setting --- openlp/core/ui/mainwindow.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b41bbf438..6f57861c4 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -771,34 +771,29 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Put OpenLP into "Default" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'default') - self.setViewMode(True, True, True, True, True) + self.setViewMode(True, True, True, True, True, u'default') def onModeSetupItemClicked(self): """ Put OpenLP into "Setup" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'setup') - self.setViewMode(True, True, False, True, False) + self.setViewMode(True, True, False, True, False, u'setup') def onModeLiveItemClicked(self): """ Put OpenLP into "Live" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'live') - self.setViewMode(False, True, False, False, True) + self.setViewMode(False, True, False, False, True, u'live') def setViewMode(self, media=True, service=True, theme=True, preview=True, - live=True): + live=True, mode=u''): """ Set OpenLP to a different view mode. """ + if mode: + settings = QtCore.QSettings() + settings.setValue(u'%s/view mode' % self.generalSettingsSection, + mode) self.MediaManagerDock.setVisible(media) self.ServiceManagerDock.setVisible(service) self.ThemeManagerDock.setVisible(theme) From 9fe4e6fc6daad22b6d31efcd8acac23e1fcb7233 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 2 Feb 2011 13:02:18 +0100 Subject: [PATCH 061/104] --- openlp/core/lib/mediamanageritem.py | 1 + openlp/core/lib/serviceitem.py | 4 ++++ openlp/plugins/images/lib/mediaitem.py | 1 + 3 files changed, 6 insertions(+) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7bbdb4f06..d2d70225c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -507,6 +507,7 @@ class MediaManagerItem(QtGui.QWidget): 'No Service Item Selected'), translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) + # Needs fixing. elif self.title.lower() == serviceItem.name.lower(): self.generateSlideData(serviceItem) self.parent.serviceManager.addServiceItem(serviceItem, diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c74b89144..299761689 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -314,6 +314,8 @@ class ServiceItem(object): self.add_from_command( path, text_image[u'title'], text_image[u'image'] ) self._new_item() + print self.shortname + print self.from_plugin def get_display_title(self): """ @@ -328,6 +330,8 @@ class ServiceItem(object): return self.title else: return self._raw_frames[0][u'title'] + print self.shortname + print self.from_plugin def merge(self, other): """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 25d9811f1..bc8a9b7e6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -182,6 +182,7 @@ class ImageMediaItem(MediaManagerItem): filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) (path, name) = os.path.split(filename) service_item.add_from_image(filename, name) + print self.shortname return True else: return False From 31a451274b46fa611fb327bdfc62dca2283107f0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 2 Feb 2011 14:22:43 +0100 Subject: [PATCH 062/104] fixed double white space --- openlp/core/lib/mediamanageritem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index ce8178f8e..39c37e2a9 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -245,7 +245,7 @@ class MediaManagerItem(QtGui.QWidget): preview_string[u'title'], preview_string[u'tooltip'], u':/general/general_preview.png', self.onPreviewClick) - ## Live Button ## + ## Live Button ## live_string = self.plugin.getString(StringContent.Live) self.addToolbarButton( live_string[u'title'], From 06897d40e1b14f2c88d0fdd2ca3e3708e927059e Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 15:52:17 +0000 Subject: [PATCH 063/104] Naming cleanups and docstrings --- openlp/core/lib/searchedit.py | 10 +++--- openlp/core/lib/theme.py | 52 +++++++++++++++++++++++--------- openlp/core/ui/servicemanager.py | 2 +- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index c69e1f15b..5e12dcefd 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -93,15 +93,15 @@ class SearchEdit(QtGui.QLineEdit): ``event`` The event that happened. """ - sz = self.clearButton.size() + size = self.clearButton.size() frameWidth = self.style().pixelMetric( QtGui.QStyle.PM_DefaultFrameWidth) - self.clearButton.move(self.rect().right() - frameWidth - sz.width(), - (self.rect().bottom() + 1 - sz.height()) / 2) + self.clearButton.move(self.rect().right() - frameWidth - size.width(), + (self.rect().bottom() + 1 - size.height()) / 2) if hasattr(self, u'menuButton'): - sz = self.menuButton.size() + size = self.menuButton.size() self.menuButton.move(self.rect().left() + frameWidth + 2, - (self.rect().bottom() + 1 - sz.height()) / 2) + (self.rect().bottom() + 1 - size.height()) / 2) def currentSearchType(self): """ diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 8d2c8f356..d119f19ff 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -91,21 +91,30 @@ class ThemeLevel(object): Song = 3 class BackgroundType(object): + """ + Type enumeration for backgrounds. + """ Solid = 0 Gradient = 1 Image = 2 @staticmethod - def to_string(type): - if type == BackgroundType.Solid: + def to_string(background_type): + """ + Return a string representation of a background type. + """ + if background_type == BackgroundType.Solid: return u'solid' - elif type == BackgroundType.Gradient: + elif background_type == BackgroundType.Gradient: return u'gradient' - elif type == BackgroundType.Image: + elif background_type == BackgroundType.Image: return u'image' @staticmethod def from_string(type_string): + """ + Return a background type for the given string. + """ if type_string == u'solid': return BackgroundType.Solid elif type_string == u'gradient': @@ -114,6 +123,9 @@ class BackgroundType(object): return BackgroundType.Image class BackgroundGradientType(object): + """ + Type enumeration for background gradients. + """ Horizontal = 0 Vertical = 1 Circular = 2 @@ -121,20 +133,26 @@ class BackgroundGradientType(object): LeftBottom = 4 @staticmethod - def to_string(type): - if type == BackgroundGradientType.Horizontal: + def to_string(gradient_type): + """ + Return a string representation of a background gradient type. + """ + if gradient_type == BackgroundGradientType.Horizontal: return u'horizontal' - elif type == BackgroundGradientType.Vertical: + elif gradient_type == BackgroundGradientType.Vertical: return u'vertical' - elif type == BackgroundGradientType.Circular: + elif gradient_type == BackgroundGradientType.Circular: return u'circular' - elif type == BackgroundGradientType.LeftTop: + elif gradient_type == BackgroundGradientType.LeftTop: return u'leftTop' - elif type == BackgroundGradientType.LeftBottom: + elif gradient_type == BackgroundGradientType.LeftBottom: return u'leftBottom' @staticmethod def from_string(type_string): + """ + Return a background gradient type for the given string. + """ if type_string == u'horizontal': return BackgroundGradientType.Horizontal elif type_string == u'vertical': @@ -147,19 +165,25 @@ class BackgroundGradientType(object): return BackgroundGradientType.LeftBottom class HorizontalType(object): + """ + Type enumeration for horizontal alignment. + """ Left = 0 Center = 1 Right = 2 class VerticalType(object): + """ + Type enumeration for vertical alignment. + """ Top = 0 Middle = 1 Bottom = 2 -boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow', +BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow', u'slide_transition'] -integer_list = [u'size', u'line_adjustment', u'x', u'height', u'y', +INTEGER_LIST = [u'size', u'line_adjustment', u'x', u'height', u'y', u'width', u'shadow_size', u'outline_size', u'horizontal_align', u'vertical_align', u'wrap_style'] @@ -514,9 +538,9 @@ class ThemeXML(object): return field = self._de_hump(element) tag = master + u'_' + field - if field in boolean_list: + if field in BOOLEAN_LIST: setattr(self, tag, str_to_bool(value)) - elif field in integer_list: + elif field in INTEGER_LIST: setattr(self, tag, int(value)) else: # make string value unicode diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 084e95b5f..9082c7a80 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -526,7 +526,7 @@ class ServiceManager(QtGui.QWidget): 'File is not a valid service.')) log.exception(u'File contains no service data') except (IOError, NameError): - log.exception(u'Problem loading service file %s' % filename) + log.exception(u'Problem loading service file %s' % fileName) finally: if fileTo: fileTo.close() From b1057a913433c3c79fa3af09ce213e51781318c8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 16:13:43 +0000 Subject: [PATCH 064/104] Fix custom edit (Bug #711934) --- openlp/plugins/custom/forms/editcustomform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e274c2395..60b313284 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -138,13 +138,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def reject(self): Receiver.send_message(u'custom_edit_clear') - self.close() + QtGui.QDialog.reject(self) def accept(self): log.debug(u'accept') if self.saveCustom(): Receiver.send_message(u'custom_load_list') - self.close() + QtGui.QDialog.accept(self) def saveCustom(self): """ From 64ab5c29b407e1d13eb4f6e638e04c8442f496f4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 19:17:48 +0000 Subject: [PATCH 065/104] Start UI component library - add_welcome_page --- openlp/core/lib/ui.py | 57 +++++++++++++++++++++++++++++++++++ openlp/core/ui/themewizard.py | 4 +-- openlp/core/ui/wizard.py | 27 ++--------------- 3 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 openlp/core/lib/ui.py diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py new file mode 100644 index 000000000..1b4ed206c --- /dev/null +++ b/openlp/core/lib/ui.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`ui` module provides standard UI components for OpenLP. +""" +import logging + +from PyQt4 import QtGui + +log = logging.getLogger(__name__) + +def add_welcome_page(parent, image): + """ + Generate an opening welcome page for a wizard using a provided image. + + ``image`` + A splash image for the wizard. + """ + parent.welcomePage = QtGui.QWizardPage() + parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(image)) + parent.welcomePage.setObjectName(u'WelcomePage') + parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) + parent.welcomeLayout.setObjectName(u'WelcomeLayout') + parent.titleLabel = QtGui.QLabel(parent.welcomePage) + parent.titleLabel.setObjectName(u'TitleLabel') + parent.welcomeLayout.addWidget(parent.titleLabel) + parent.welcomeLayout.addSpacing(40) + parent.informationLabel = QtGui.QLabel(parent.welcomePage) + parent.informationLabel.setWordWrap(True) + parent.informationLabel.setObjectName(u'InformationLabel') + parent.welcomeLayout.addWidget(parent.informationLabel) + parent.welcomeLayout.addStretch() + parent.addPage(parent.welcomePage) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index fe5305454..e8765b9e2 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.ui.wizard import addWelcomePage +from openlp.core.lib.ui import add_welcome_page class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -37,7 +37,7 @@ class Ui_ThemeWizard(object): themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page - addWelcomePage(themeWizard, u':/wizards/wizard_createtheme.bmp') + add_welcome_page(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index f57253d0e..2fa448db8 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -31,6 +31,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, Receiver +from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) @@ -63,7 +64,7 @@ class OpenLPWizard(QtGui.QWizard): self.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) - addWelcomePage(self, image) + add_welcome_page(self, image) self.addCustomPages() self.addProgressPage() self.retranslateUi() @@ -145,27 +146,3 @@ class OpenLPWizard(QtGui.QWizard): self.finishButton.setVisible(True) self.cancelButton.setVisible(False) Receiver.send_message(u'openlp_process_events') - -def addWelcomePage(parent, image): - """ - Generate an opening welcome page for a wizard using a provided image. - - ``image`` - A splash image for the wizard. - """ - parent.welcomePage = QtGui.QWizardPage() - parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(image)) - parent.welcomePage.setObjectName(u'WelcomePage') - parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) - parent.welcomeLayout.setObjectName(u'WelcomeLayout') - parent.titleLabel = QtGui.QLabel(parent.welcomePage) - parent.titleLabel.setObjectName(u'TitleLabel') - parent.welcomeLayout.addWidget(parent.titleLabel) - parent.welcomeLayout.addSpacing(40) - parent.informationLabel = QtGui.QLabel(parent.welcomePage) - parent.informationLabel.setWordWrap(True) - parent.informationLabel.setObjectName(u'InformationLabel') - parent.welcomeLayout.addWidget(parent.informationLabel) - parent.welcomeLayout.addStretch() - parent.addPage(parent.welcomePage) From 303433a20de625addf0d39a4f9c429da7ad48bbc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 19:30:06 +0000 Subject: [PATCH 066/104] UI library - save_cancel_button_box --- openlp/core/lib/__init__.py | 14 -------------- openlp/core/lib/ui.py | 14 ++++++++++++++ openlp/core/ui/serviceitemeditdialog.py | 3 ++- openlp/core/ui/servicenoteform.py | 3 ++- openlp/plugins/custom/forms/editcustomdialog.py | 3 ++- .../plugins/custom/forms/editcustomslidedialog.py | 3 ++- openlp/plugins/songs/forms/authorsdialog.py | 3 ++- openlp/plugins/songs/forms/editsongdialog.py | 3 ++- openlp/plugins/songs/forms/editversedialog.py | 4 ++-- openlp/plugins/songs/forms/songbookdialog.py | 3 ++- openlp/plugins/songs/forms/topicsdialog.py | 3 ++- 11 files changed, 32 insertions(+), 24 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index f07d7c78d..33280f83b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -319,20 +319,6 @@ def check_directory_exists(dir): if not os.path.exists(dir): os.makedirs(dir) -def save_cancel_button_box(parent): - """ - Return a standard dialog button box with save and cancel buttons. - """ - button_box = QtGui.QDialogButtonBox(parent) - button_box.setStandardButtons(QtGui.QDialogButtonBox.Save | - QtGui.QDialogButtonBox.Cancel) - button_box.setObjectName(u'%sButtonBox' % parent) - QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), - parent.accept) - QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), - parent.reject) - return button_box - from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \ BackgroundType, HorizontalType, VerticalType from displaytags import DisplayTags diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 1b4ed206c..faca42119 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -55,3 +55,17 @@ def add_welcome_page(parent, image): parent.welcomeLayout.addWidget(parent.informationLabel) parent.welcomeLayout.addStretch() parent.addPage(parent.welcomePage) + +def save_cancel_button_box(parent): + """ + Return a standard dialog button box with save and cancel buttons. + """ + button_box = QtGui.QDialogButtonBox(parent) + button_box.setStandardButtons( + QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) + button_box.setObjectName(u'%sButtonBox' % parent) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), + parent.accept) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), + parent.reject) + return button_box diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 0993c48b2..d4c86fa61 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon, save_cancel_button_box +from openlp.core.lib import translate, build_icon +from openlp.core.lib.ui import save_cancel_button_box class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 5cb68d03f..e659e50db 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import save_cancel_button_box, translate +from openlp.core.lib import translate +from openlp.core.lib.ui import save_cancel_button_box class ServiceNoteForm(QtGui.QDialog): """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 3d5e3a3f7..75717c082 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, save_cancel_button_box +from openlp.core.lib import build_icon, translate +from openlp.core.lib.ui import save_cancel_button_box class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 1325590d9..93bff68b8 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, SpellTextEdit, save_cancel_button_box +from openlp.core.lib import translate, SpellTextEdit +from openlp.core.lib.ui import save_cancel_button_box class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index daae83525..3fd3c5fef 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, save_cancel_button_box +from openlp.core.lib import translate +from openlp.core.lib.ui import save_cancel_button_box class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index b9b6e5baf..c44b42d46 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, save_cancel_button_box +from openlp.core.lib import build_icon, translate +from openlp.core.lib.ui import save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index d74da50d1..deaf952e2 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -26,8 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, save_cancel_button_box, translate, \ - SpellTextEdit +from openlp.core.lib import build_icon, translate, SpellTextEdit +from openlp.core.lib.ui import save_cancel_button_box from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index 757a629ab..fcd6bd364 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, save_cancel_button_box +from openlp.core.lib import translate +from openlp.core.lib.ui import save_cancel_button_box class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index 38c45407f..f2c9fdeba 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, save_cancel_button_box +from openlp.core.lib import translate +from openlp.core.lib.ui import save_cancel_button_box class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): From f4d25560e979b501ec4bf6b513e6b128106ba558 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 23:12:31 +0000 Subject: [PATCH 067/104] UI library - critical_error_message_box --- openlp/core/lib/ui.py | 33 +++++++++++++++-- openlp/core/ui/__init__.py | 34 ++---------------- openlp/core/ui/displaytagtab.py | 6 ++-- openlp/core/ui/servicemanager.py | 14 ++++---- openlp/core/ui/themeform.py | 6 ++-- openlp/core/ui/thememanager.py | 22 ++++++------ .../plugins/bibles/forms/bibleimportform.py | 20 +++++------ openlp/plugins/bibles/lib/db.py | 4 +-- openlp/plugins/bibles/lib/http.py | 8 ++--- openlp/plugins/bibles/lib/mediaitem.py | 8 +++-- openlp/plugins/custom/forms/editcustomform.py | 4 +-- openlp/plugins/images/lib/mediaitem.py | 6 ++-- openlp/plugins/media/lib/mediaitem.py | 6 ++-- openlp/plugins/presentations/lib/mediaitem.py | 10 +++--- openlp/plugins/songs/forms/authorsform.py | 10 +++--- openlp/plugins/songs/forms/editsongform.py | 15 ++++---- openlp/plugins/songs/forms/editverseform.py | 4 +-- openlp/plugins/songs/forms/songbookform.py | 4 +-- openlp/plugins/songs/forms/songimportform.py | 24 ++++++------- .../songs/forms/songmaintenanceform.py | 36 +++++++++---------- openlp/plugins/songs/forms/topicsform.py | 5 +-- 21 files changed, 143 insertions(+), 136 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index faca42119..f87ac68d1 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -28,7 +28,9 @@ The :mod:`ui` module provides standard UI components for OpenLP. """ import logging -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate log = logging.getLogger(__name__) @@ -68,4 +70,31 @@ def save_cancel_button_box(parent): parent.accept) QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), parent.reject) - return button_box + return button_box + +def critical_error_message_box(title=None, message=None, parent=None, + question=False): + """ + Provides a standard critical message box for errors that OpenLP displays + to users. + + ``title`` + The title for the message box. + + ``message`` + The message to display to the user. + + ``parent`` + The parent UI element to attach the dialog to. + + ``question`` + Should this message box question the user. + """ + error = translate('OpenLP.Ui', 'Error') + if question: + return QtGui.QMessageBox.critical(parent, error, message, + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) + data = {u'message': message} + data[u'title'] = title if title else error + return Receiver.send_message(u'openlp_error_message', data) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 80124c2be..eb0e89775 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -51,34 +51,6 @@ class HideMode(object): Theme = 2 Screen = 3 - -def criticalErrorMessageBox(title=None, message=None, parent=None, - question=False): - """ - Provides a standard critical message box for errors that OpenLP displays - to users. - - ``title`` - The title for the message box. - - ``message`` - The message to display to the user. - - ``parent`` - The parent UI element to attach the dialog to. - - ``question`` - Should this message box question the user. - """ - error = translate('OpenLP.Ui', 'Error') - if question: - return QtGui.QMessageBox.critical(parent, error, message, - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) - data = {u'message': message} - data[u'title'] = title if title else error - return Receiver.send_message(u'openlp_error_message', data) - from themeform import ThemeForm from filerenameform import FileRenameForm from maindisplay import MainDisplay @@ -99,6 +71,6 @@ from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager -__all__ = ['criticalErrorMessageBox', 'SplashScreen', 'AboutForm', - 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', - 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm'] +__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', + 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', + 'ServiceItemEditForm'] diff --git a/openlp/core/ui/displaytagtab.py b/openlp/core/ui/displaytagtab.py index 1c77084b9..983bc17a8 100644 --- a/openlp/core/ui/displaytagtab.py +++ b/openlp/core/ui/displaytagtab.py @@ -34,7 +34,7 @@ import cPickle from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, DisplayTags -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box class DisplayTagTab(SettingsTab): ''' @@ -276,7 +276,7 @@ class DisplayTagTab(SettingsTab): """ for html in DisplayTags.get_html_tags(): if self._strip(html[u'start tag']) == u'n': - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.DisplayTagTab', 'Update Error'), translate('OpenLP.DisplayTagTab', 'Tag "n" already defined.')) @@ -317,7 +317,7 @@ class DisplayTagTab(SettingsTab): for linenumber, html1 in enumerate(html_expands): if self._strip(html1[u'start tag']) == tag and \ linenumber != self.selected: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.DisplayTagTab', 'Update Error'), unicode(translate('OpenLP.DisplayTagTab', 'Tag %s already defined.')) % tag) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9082c7a80..ace678c75 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -36,8 +36,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \ ThemeLevel -from openlp.core.ui import criticalErrorMessageBox, ServiceNoteForm, \ - ServiceItemEditForm +from openlp.core.lib.ui import critical_error_message_box +from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename @@ -491,7 +491,7 @@ class ServiceManager(QtGui.QWidget): for file in zip.namelist(): ucsfile = file_is_unicode(file) if not ucsfile: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'File is not a valid service.\n' 'The content encoding is not UTF-8.')) @@ -521,7 +521,7 @@ class ServiceManager(QtGui.QWidget): serviceItem.name.lower(), serviceItem) delete_file(p_file) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'File is not a valid service.')) log.exception(u'File contains no service data') @@ -993,7 +993,7 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.previewController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) else: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be ' 'displayed as there is no handler to display it')) @@ -1027,7 +1027,7 @@ class ServiceManager(QtGui.QWidget): self.serviceItems[item][u'service_item'], 0) self.mainwindow.liveController.previewListWidget.setFocus() else: - criticalErrorMessageBox( + 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 ' @@ -1188,7 +1188,7 @@ class ServiceManager(QtGui.QWidget): Print a Service Order Sheet. """ if not self.serviceItems: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'There is no service item in this service.')) return diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 8d10f21fa..018df7597 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, BackgroundType, BackgroundGradientType, \ Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_images_filter from themewizard import Ui_ThemeWizard @@ -567,13 +567,13 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): # Save the theme name self.theme.theme_name = unicode(self.field(u'name').toString()) if not self.theme.theme_name: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Missing'), translate('OpenLP.ThemeForm', 'There is no name for this theme. Please enter one.')) return if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None': - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Invalid'), translate('OpenLP.ThemeForm', 'Invalid theme name. Please enter one.')) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index df1f1f775..f403d7441 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -32,11 +32,12 @@ import logging from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.ui import criticalErrorMessageBox, FileRenameForm, ThemeForm -from openlp.core.theme import Theme from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \ build_icon, Receiver, SettingsManager, translate, check_item_selected, \ BackgroundType, BackgroundGradientType, check_directory_exists +from openlp.core.lib.ui import critical_error_message_box +from openlp.core.theme import Theme +from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ get_filesystem_encoding @@ -359,7 +360,7 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() if item is None: - criticalErrorMessageBox(message=translate('OpenLP.ThemeManager', + critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return theme = unicode(item.data(QtCore.Qt.UserRole).toString()) @@ -386,7 +387,7 @@ class ThemeManager(QtGui.QWidget): 'Your theme has been successfully exported.')) except (IOError, OSError): log.exception(u'Export Theme Failed') - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Theme Export Failed'), translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.')) @@ -496,7 +497,7 @@ class ThemeManager(QtGui.QWidget): for file in zip.namelist(): ucsfile = file_is_unicode(file) if not ucsfile: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ThemeManager', 'File is not a valid theme.\n' 'The content encoding is not UTF-8.')) @@ -531,14 +532,14 @@ class ThemeManager(QtGui.QWidget): theme = self._createThemeFromXml(filexml, self.path) self.generateAndSaveImage(dir, themename, theme) else: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) log.exception(u'Theme file does not contain XML data %s' % filename) except (IOError, NameError): - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) @@ -558,7 +559,7 @@ class ThemeManager(QtGui.QWidget): """ theme_dir = os.path.join(self.path, themeName) if os.path.exists(theme_dir): - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'A theme with this name already exists.')) @@ -688,7 +689,7 @@ class ThemeManager(QtGui.QWidget): return False # should be the same unless default if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) return False @@ -696,7 +697,8 @@ class ThemeManager(QtGui.QWidget): if testPlugin: for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(theme): - criticalErrorMessageBox(translate('OpenLP.ThemeManager', + critical_error_message_box( + translate('OpenLP.ThemeManager', 'Validation Error'), unicode(translate('OpenLP.ThemeManager', 'Theme %s is used in the %s plugin.')) % \ diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 3e43d19aa..a2509ba97 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.db import delete_database -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -486,7 +486,7 @@ class BibleImportForm(OpenLPWizard): elif self.currentPage() == self.selectPage: if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Bible Location'), translate('BiblesPlugin.ImportWizardForm', @@ -496,7 +496,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: if not self.field(u'csv_testamentsfile').toString(): - answer = criticalErrorMessageBox(translate( + answer = critical_error_message_box(translate( 'BiblesPlugin.ImportWizardForm', 'No Testaments File'), translate('BiblesPlugin.ImportWizardForm', 'You have not specified a testaments file. Do you ' @@ -505,7 +505,7 @@ class BibleImportForm(OpenLPWizard): self.csvTestamentsEdit.setFocus() return False elif not self.field(u'csv_booksfile').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Books File'), translate('BiblesPlugin.ImportWizardForm', @@ -514,7 +514,7 @@ class BibleImportForm(OpenLPWizard): self.csvBooksEdit.setFocus() return False elif not self.field(u'csv_versefile').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Verse File'), translate('BiblesPlugin.ImportWizardForm', @@ -525,7 +525,7 @@ class BibleImportForm(OpenLPWizard): elif self.field(u'source_format').toInt()[0] == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid OpenSong Bible'), translate('BiblesPlugin.ImportWizardForm', @@ -535,7 +535,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Bible Location'), translate('BiblesPlugin.ImportWizardForm', @@ -549,7 +549,7 @@ class BibleImportForm(OpenLPWizard): license_copyright = \ unicode(self.field(u'license_copyright').toString()) if not license_version: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Empty Version Name'), translate('BiblesPlugin.ImportWizardForm', @@ -557,7 +557,7 @@ class BibleImportForm(OpenLPWizard): self.versionNameEdit.setFocus() return False elif not license_copyright: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Empty Copyright'), translate('BiblesPlugin.ImportWizardForm', @@ -566,7 +566,7 @@ class BibleImportForm(OpenLPWizard): self.copyrightEdit.setFocus() return False elif self.manager.exists(license_version): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import ' diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a9444d88b..b986b0d66 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -35,7 +35,7 @@ from sqlalchemy.orm.exc import UnmappedClassError from openlp.core.lib import translate from openlp.core.lib.db import BaseModel, init_db, Manager -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box log = logging.getLogger(__name__) @@ -361,7 +361,7 @@ class BibleDB(QtCore.QObject, Manager): verse_list.extend(verses) else: log.debug(u'OpenLP failed to find book %s', book) - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), translate('BiblesPlugin', 'No matching book ' 'could be found in this Bible. Check that you have ' diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index e004be9df..8db214140 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, Book @@ -431,7 +431,7 @@ class HTTPBible(BibleDB): if not db_book: book_details = HTTPBooks.get_book(book) if not book_details: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), translate('BiblesPlugin', 'No matching ' 'book could be found in this Bible. Check that you ' @@ -552,14 +552,14 @@ def send_error_message(error_type): The type of error that occured for the issue. """ if error_type == u'download': - criticalErrorMessageBox( + critical_error_message_box( translate('BiblePlugin.HTTPBible', 'Download Error'), translate('BiblePlugin.HTTPBible', 'There was a ' 'problem downloading your verse selection. Please check your ' 'Internet connection, and if this error continues to occur ' 'please consider reporting a bug.')) elif error_type == u'parse': - criticalErrorMessageBox( + critical_error_message_box( translate('BiblePlugin.HTTPBible', 'Parse Error'), translate('BiblePlugin.HTTPBible', 'There was a ' 'problem extracting your verse selection. If this error continues ' diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index de2649b31..c66b83dfc 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import get_reference_match @@ -387,7 +387,8 @@ class BibleMediaItem(MediaManagerItem): verse_count = self.parent.manager.get_verse_count(bible, book, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) - criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + critical_error_message_box( + message=translate('BiblePlugin.MediaItem', 'Bible not fully loaded')) else: self.advancedSearchButton.setEnabled(True) @@ -581,7 +582,8 @@ class BibleMediaItem(MediaManagerItem): if item_second_bible and second_bible or not item_second_bible and \ not second_bible: self.displayResults(bible, second_bible) - elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + elif critical_error_message_box( + message=translate('BiblePlugin.MediaItem', 'You cannot combine single and second bible verses. Do you ' 'want to delete your search results and start a new search?'), parent=self, question=True) == QtGui.QMessageBox.Yes: diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 60b313284..e8dfa20aa 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 openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.db import CustomSlide from editcustomdialog import Ui_CustomEditDialog @@ -152,7 +152,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ valid, message = self._validate() if not valid: - criticalErrorMessageBox(message=message) + critical_error_message_box(message=message) return False sxml = CustomXMLBuilder() sxml.new_document() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 25d9811f1..cbefc7171 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \ check_directory_exists, Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file, get_images_filter log = logging.getLogger(__name__) @@ -161,7 +161,7 @@ class ImageMediaItem(MediaManagerItem): items.remove(item) # We cannot continue, as all images do not exist. if not items: - criticalErrorMessageBox( + critical_error_message_box( translate('ImagePlugin.MediaItem', 'Missing Image(s)'), unicode(translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s')) % @@ -214,7 +214,7 @@ class ImageMediaItem(MediaManagerItem): self.parent.liveController.display.directImage(name, filename) self.resetAction.setVisible(True) else: - criticalErrorMessageBox( + critical_error_message_box( translate('ImagePlugin.MediaItem', 'Live Background Error'), unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index c68b11c85..ea1b679b4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box log = logging.getLogger(__name__) @@ -120,7 +120,7 @@ class MediaMediaItem(MediaManagerItem): self.parent.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: - criticalErrorMessageBox(translate('MediaPlugin.MediaItem', + critical_error_message_box(translate('MediaPlugin.MediaItem', 'Live Background Error'), unicode(translate('MediaPlugin.MediaItem', 'There was a problem replacing your background, ' @@ -144,7 +144,7 @@ class MediaMediaItem(MediaManagerItem): return True else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('MediaPlugin.MediaItem', 'Missing Media File'), unicode(translate('MediaPlugin.MediaItem', 'The file %s no longer exists.')) % filename) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 43cb3dab0..7b07a26c9 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ SettingsManager, translate, check_item_selected, Receiver, ItemCapabilities -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.presentations.lib import MessageListener log = logging.getLogger(__name__) @@ -181,7 +181,7 @@ class PresentationMediaItem(MediaManagerItem): filename = os.path.split(unicode(file))[1] if titles.count(filename) > 0: if not initialLoad: - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'File Exists'), translate('PresentationPlugin.MediaItem', @@ -205,7 +205,7 @@ class PresentationMediaItem(MediaManagerItem): if initialLoad: icon = build_icon(u':/general/general_delete.png') else: - criticalErrorMessageBox( + critical_error_message_box( self, translate('PresentationPlugin.MediaItem', 'Unsupported File'), translate('PresentationPlugin.MediaItem', @@ -278,7 +278,7 @@ class PresentationMediaItem(MediaManagerItem): return True else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), unicode(translate('PresentationPlugin.MediaItem', @@ -287,7 +287,7 @@ class PresentationMediaItem(MediaManagerItem): return False else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), unicode(translate('PresentationPlugin.MediaItem', diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 091618bde..3a37cf290 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui, QtCore from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): @@ -80,17 +80,19 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): def accept(self): if not self.firstNameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm', + critical_error_message_box( + message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.')) self.firstNameEdit.setFocus() return False elif not self.lastNameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm', + critical_error_message_box( + message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.')) self.lastNameEdit.setFocus() return False elif not self.displayEdit.text(): - if criticalErrorMessageBox( + if critical_error_message_box( message=translate('SongsPlugin.AuthorsForm', 'You have not set a display name for the ' 'author, combine the first and last names?'), diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c3279e1a9..bf94503ff 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib import SongXML, VerseType from openlp.plugins.songs.lib.db import Book, Song, Author, Topic @@ -255,7 +255,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.songBookNumberEdit.setText(self.song.song_number) else: self.songBookNumberEdit.setText(u'') - # lazy xml migration for now self.verseListWidget.clear() self.verseListWidget.setRowCount(0) @@ -343,7 +342,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): author = self.manager.get_object(Author, item_id) if self.authorsListView.findItems(unicode(author.display_name), QtCore.Qt.MatchExactly): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.')) else: @@ -400,7 +399,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): topic = self.manager.get_object(Topic, item_id) if self.topicsListView.findItems(unicode(topic.name), QtCore.Qt.MatchExactly): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.')) else: @@ -533,21 +532,21 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if not self.titleEdit.text(): self.songTabWidget.setCurrentIndex(0) self.titleEdit.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type in a song title.')) return False if self.verseListWidget.rowCount() == 0: self.songTabWidget.setCurrentIndex(0) self.verseListWidget.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type in at least one verse.')) return False if self.authorsListView.count() == 0: self.songTabWidget.setCurrentIndex(1) self.authorsListView.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to have an author for this song.')) return False @@ -575,7 +574,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): valid = verses.pop(0) for verse in verses: valid = valid + u', ' + verse - criticalErrorMessageBox( + critical_error_message_box( message=unicode(translate('SongsPlugin.EditSongForm', 'The verse order is invalid. There is no verse ' 'corresponding to %s. Valid entries are %s.')) % \ diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index c10e48cb7..e67e0733a 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.lib import VerseType, translate from editversedialog import Ui_EditVerseDialog @@ -168,7 +168,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): else: value = self.getVerse()[0].split(u'\n')[1] if len(value) == 0: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type some text in to the verse.')) return False diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 8341a7c4c..3f054fe8d 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): @@ -50,7 +50,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): def accept(self): if not self.nameEdit.text(): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.')) self.nameEdit.setFocus() diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index a5b0e713a..f1e1f82ed 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.plugins.songs.lib.importer import SongFormat @@ -329,7 +329,7 @@ class SongImportForm(OpenLPWizard): source_format = self.formatComboBox.currentIndex() if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenLP 2.0 Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -339,7 +339,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No openlp.org 1.x Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -349,7 +349,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLyrics: if self.openLyricsFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenLyrics Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -359,7 +359,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenSong Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -369,7 +369,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Words of Worship Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -379,7 +379,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No CCLI Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -389,7 +389,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Songs of Fellowship File Selected'), translate('SongsPlugin.ImportWizardForm', @@ -399,7 +399,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Document/Presentation Selected'), translate('SongsPlugin.ImportWizardForm', @@ -409,7 +409,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasiSlides: if self.easiSlidesFilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Easislides Songs file selected'), translate('SongsPlugin.ImportWizardForm', @@ -419,7 +419,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No EasyWorship Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -429,7 +429,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No SongBeamer File Selected'), translate('SongsPlugin.ImportWizardForm', diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 441182424..e98bc3a6f 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog @@ -108,14 +108,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if item_id != -1: item = self.manager.get_object(item_class, item_id) if item and len(item.songs) == 0: - if criticalErrorMessageBox(title=dlg_title, message=del_text, + if critical_error_message_box(title=dlg_title, message=del_text, parent=self, question=True) == QtGui.QMessageBox.Yes: self.manager.delete_object(item_class, item.id) reset_func() else: - criticalErrorMessageBox(dlg_title, err_text) + critical_error_message_box(dlg_title, err_text) else: - criticalErrorMessageBox(dlg_title, sel_text) + critical_error_message_box(dlg_title, sel_text) def resetAuthors(self): """ @@ -237,11 +237,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(author): self.resetAuthors() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your author.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This author already exists.')) @@ -252,11 +252,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(topic): self.resetTopics() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your topic.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This topic already exists.')) @@ -268,11 +268,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(book): self.resetBooks() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your book.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This book already exists.')) @@ -301,10 +301,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.resetAuthors() Receiver.send_message(u'songs_load_list') else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox(message=unicode(translate( + elif critical_error_message_box(message=unicode(translate( 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' 'exists. Would you like to make songs with author %s use ' 'the existing author %s?')) % (author.display_name, @@ -318,7 +318,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): author.first_name = temp_first_name author.last_name = temp_last_name author.display_name = temp_display_name - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your modified author, because the ' 'author already exists.')) @@ -337,10 +337,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(topic): self.resetTopics() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox( + elif critical_error_message_box( message=unicode(translate('SongsPlugin.SongMaintenanceForm', 'The topic %s already exists. Would you like to make songs ' 'with topic %s use the existing topic %s?')) % (topic.name, @@ -350,7 +350,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): else: # We restore the topics's old name. topic.name = temp_name - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your modified topic, because it ' 'already exists.')) @@ -375,10 +375,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(book): self.resetBooks() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox( + elif critical_error_message_box( message=unicode(translate('SongsPlugin.SongMaintenanceForm', 'The book %s already exists. Would you like to make songs ' 'with book %s use the existing book %s?')) % (book.name, diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 4ab2b63fa..792570c93 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): @@ -49,7 +49,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): def accept(self): if not self.nameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.TopicsForm', + critical_error_message_box( + message=translate('SongsPlugin.TopicsForm', 'You need to type in a topic name.')) self.nameEdit.setFocus() return False From e9ea8fd8cc382e40ebe348087e96fcdfeed24837 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 01:55:12 +0000 Subject: [PATCH 068/104] Dedupe song object checking --- .../songs/forms/songmaintenanceform.py | 53 ++++++------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index e98bc3a6f..737d63204 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -159,66 +159,43 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def checkAuthor(self, new_author, edit=False): """ Returns *False* if the given Author already exists, otherwise *True*. - - ``edit`` - If we edit an item, this should be *True*. """ authors = self.manager.get_all_objects(Author, and_(Author.first_name == new_author.first_name, Author.last_name == new_author.last_name, Author.display_name == new_author.display_name)) - # Check if this author already exists. - if len(authors) > 0: - # If we edit an existing Author, we need to make sure that we do - # not return False when nothing has changed. - if edit: - for author in authors: - if author.id != new_author.id: - return False - return True - else: - return False - else: - return True + return self.__checkObject(authors, new_author, edit) def checkTopic(self, new_topic, edit=False): """ Returns *False* if the given Topic already exists, otherwise *True*. - - ``edit`` - If we edit an item, this should be *True*. """ topics = self.manager.get_all_objects(Topic, Topic.name == new_topic.name) - if len(topics) > 0: - # If we edit an existing Topic, we need to make sure that we do - # not return False when nothing has changed. - if edit: - for topic in topics: - if topic.id != new_topic.id: - return False - return True - else: - return False - else: - return True + return self.__checkObject(topics, new_topic, edit) def checkBook(self, new_book, edit=False): """ Returns *False* if the given Topic already exists, otherwise *True*. - - ``edit`` - If we edit an item, this should be *True*. """ books = self.manager.get_all_objects(Book, and_(Book.name == new_book.name, Book.publisher == new_book.publisher)) - if len(books) > 0: - # If we edit an existing Book, we need to make sure that we do + return self.__checkObject(books, new_book, edit) + + def __checkObject(self, objects, new_object, edit): + """ + Utility method to check for an existing object. + + ``edit`` + If we edit an item, this should be *True*. + """ + if len(objects) > 0: + # If we edit an existing object, we need to make sure that we do # not return False when nothing has changed. if edit: - for book in books: - if book.id != new_book.id: + for object in objects: + if object.id != new_object.id: return False return True else: From 750a232311ecacfef4321caba8f92bff842a4d64 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 02:46:02 +0000 Subject: [PATCH 069/104] UI library - media_item_combo_box --- openlp/core/lib/ui.py | 10 +++ openlp/plugins/bibles/lib/mediaitem.py | 67 +++++-------------- openlp/plugins/presentations/lib/mediaitem.py | 10 +-- 3 files changed, 30 insertions(+), 57 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index f87ac68d1..8cfffef45 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -98,3 +98,13 @@ def critical_error_message_box(title=None, message=None, parent=None, data = {u'message': message} data[u'title'] = title if title else error return Receiver.send_message(u'openlp_error_message', data) + +def media_item_combo_box(parent, name): + """ + Provide a standard combo box for media items. + """ + combo = QtGui.QComboBox(parent) + combo.setObjectName(name) + combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + return combo diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c66b83dfc..26f45b6b3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import get_reference_match @@ -81,33 +81,21 @@ class BibleMediaItem(MediaManagerItem): self.quickLayout.setObjectName(u'quickLayout') self.quickVersionLabel = QtGui.QLabel(self.quickTab) self.quickVersionLabel.setObjectName(u'quickVersionLabel') - self.quickVersionComboBox = QtGui.QComboBox(self.quickTab) - self.quickVersionComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.quickVersionComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.quickVersionComboBox.setObjectName(u'quickVersionComboBox') + self.quickVersionComboBox = media_item_combo_box(self.quickTab, + u'quickVersionComboBox') self.quickVersionLabel.setBuddy(self.quickVersionComboBox) self.quickLayout.addRow(self.quickVersionLabel, self.quickVersionComboBox) self.quickSecondLabel = QtGui.QLabel(self.quickTab) self.quickSecondLabel.setObjectName(u'quickSecondLabel') - self.quickSecondComboBox = QtGui.QComboBox(self.quickTab) - self.quickSecondComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.quickSecondComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.quickSecondComboBox.setObjectName(u'quickSecondComboBox') + self.quickSecondComboBox = media_item_combo_box(self.quickTab, + u'quickSecondComboBox') self.quickSecondLabel.setBuddy(self.quickSecondComboBox) self.quickLayout.addRow(self.quickSecondLabel, self.quickSecondComboBox) self.quickSearchTypeLabel = QtGui.QLabel(self.quickTab) self.quickSearchTypeLabel.setObjectName(u'quickSearchTypeLabel') - self.quickSearchComboBox = QtGui.QComboBox(self.quickTab) - self.quickSearchComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.quickSearchComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.quickSearchComboBox.setObjectName(u'quickSearchComboBox') + self.quickSearchComboBox = media_item_combo_box(self.quickTab, + u'quickSearchComboBox') self.quickSearchTypeLabel.setBuddy(self.quickSearchComboBox) self.quickLayout.addRow(self.quickSearchTypeLabel, self.quickSearchComboBox) @@ -119,12 +107,8 @@ class BibleMediaItem(MediaManagerItem): self.quickLayout.addRow(self.quickSearchLabel, self.quickSearchEdit) self.quickClearLabel = QtGui.QLabel(self.quickTab) self.quickClearLabel.setObjectName(u'quickClearLabel') - self.quickClearComboBox = QtGui.QComboBox(self.quickTab) - self.quickClearComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.quickClearComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.quickClearComboBox.setObjectName(u'quickClearComboBox') + self.quickClearComboBox = media_item_combo_box(self.quickTab, + u'quickClearComboBox') self.quickLayout.addRow(self.quickClearLabel, self.quickClearComboBox) self.quickSearchButtonLayout = QtGui.QHBoxLayout() self.quickSearchButtonLayout.setObjectName(u'quickSearchButtonLayout') @@ -144,36 +128,24 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionLabel.setObjectName(u'advancedVersionLabel') self.advancedLayout.addWidget(self.advancedVersionLabel, 0, 0, QtCore.Qt.AlignRight) - self.advancedVersionComboBox = QtGui.QComboBox(self.advancedTab) - self.advancedVersionComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.advancedVersionComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.advancedVersionComboBox.setObjectName(u'advancedVersionComboBox') + self.advancedVersionComboBox = media_item_combo_box(self.advancedTab, + u'advancedVersionComboBox') self.advancedVersionLabel.setBuddy(self.advancedVersionComboBox) self.advancedLayout.addWidget(self.advancedVersionComboBox, 0, 1, 1, 2) self.advancedSecondLabel = QtGui.QLabel(self.advancedTab) self.advancedSecondLabel.setObjectName(u'advancedSecondLabel') self.advancedLayout.addWidget(self.advancedSecondLabel, 1, 0, QtCore.Qt.AlignRight) - self.advancedSecondComboBox = QtGui.QComboBox(self.advancedTab) - self.advancedSecondComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.advancedSecondComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.advancedSecondComboBox.setObjectName(u'advancedSecondComboBox') + self.advancedSecondComboBox = media_item_combo_box(self.advancedTab, + u'advancedSecondComboBox') self.advancedSecondLabel.setBuddy(self.advancedSecondComboBox) self.advancedLayout.addWidget(self.advancedSecondComboBox, 1, 1, 1, 2) self.advancedBookLabel = QtGui.QLabel(self.advancedTab) self.advancedBookLabel.setObjectName(u'advancedBookLabel') self.advancedLayout.addWidget(self.advancedBookLabel, 2, 0, QtCore.Qt.AlignRight) - self.advancedBookComboBox = QtGui.QComboBox(self.advancedTab) - self.advancedBookComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.advancedBookComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.advancedBookComboBox.setObjectName(u'advancedBookComboBox') + self.advancedBookComboBox = media_item_combo_box(self.advancedTab, + u'advancedBookComboBox') self.advancedBookLabel.setBuddy(self.advancedBookComboBox) self.advancedLayout.addWidget(self.advancedBookComboBox, 2, 1, 1, 2) self.advancedChapterLabel = QtGui.QLabel(self.advancedTab) @@ -202,17 +174,12 @@ class BibleMediaItem(MediaManagerItem): self.advancedToVerse = QtGui.QComboBox(self.advancedTab) self.advancedToVerse.setObjectName(u'advancedToVerse') self.advancedLayout.addWidget(self.advancedToVerse, 5, 2) - self.advancedClearLabel = QtGui.QLabel(self.quickTab) self.advancedClearLabel.setObjectName(u'advancedClearLabel') self.advancedLayout.addWidget(self.advancedClearLabel, 6, 0, QtCore.Qt.AlignRight) - self.advancedClearComboBox = QtGui.QComboBox(self.quickTab) - self.advancedClearComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.advancedClearComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.advancedClearComboBox.setObjectName(u'advancedClearComboBox') + self.advancedClearComboBox = media_item_combo_box(self.quickTab, + u'advancedClearComboBox') self.advancedClearLabel.setBuddy(self.advancedClearComboBox) self.advancedLayout.addWidget(self.advancedClearComboBox, 6, 1, 1, 2) self.advancedSearchButtonLayout = QtGui.QHBoxLayout() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 7b07a26c9..a0173cb27 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ SettingsManager, translate, check_item_selected, Receiver, ItemCapabilities -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box from openlp.plugins.presentations.lib import MessageListener log = logging.getLogger(__name__) @@ -116,12 +116,8 @@ class PresentationMediaItem(MediaManagerItem): self.displayLayout.setObjectName(u'displayLayout') self.displayTypeLabel = QtGui.QLabel(self.presentationWidget) self.displayTypeLabel.setObjectName(u'displayTypeLabel') - self.displayTypeComboBox = QtGui.QComboBox(self.presentationWidget) - self.displayTypeComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.displayTypeComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.displayTypeComboBox.setObjectName(u'displayTypeComboBox') + self.displayTypeComboBox = media_item_combo_box( + self.presentationWidget, u'displayTypeComboBox') self.displayTypeLabel.setBuddy(self.displayTypeComboBox) self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox) From 6751aa41b1fff255e2dcccf0d4e76e7bf5911742 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 03:50:04 +0000 Subject: [PATCH 070/104] Stop reloading songs all the time --- openlp/core/lib/plugin.py | 2 +- openlp/core/ui/servicemanager.py | 7 ++++--- openlp/plugins/songs/lib/mediaitem.py | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8b12004d3..fb31006b5 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -118,7 +118,7 @@ class Plugin(QtCore.QObject): class MyPlugin(Plugin): def __init__(self): - Plugin.__init(self, u'MyPlugin', u'0.1') + Plugin.__init__(self, u'MyPlugin', u'0.1') ``name`` Defaults to *None*. The name of the plugin. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ace678c75..4d36f4aec 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -506,6 +506,8 @@ class ServiceManager(QtGui.QWidget): if filePath.endswith(u'osd'): p_file = filePath if 'p_file' in locals(): + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') fileTo = open(p_file, u'r') items = cPickle.load(fileTo) fileTo.close() @@ -520,6 +522,7 @@ class ServiceManager(QtGui.QWidget): Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem) delete_file(p_file) + Receiver.send_message(u'cursor_normal') else: critical_error_message_box( message=translate('OpenLP.ServiceManager', @@ -536,9 +539,7 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.addRecentFile(fileName) self.setModified(False) QtCore.QSettings(). \ - setValue(u'service/last file',QtCore.QVariant(fileName)) - # Refresh Plugin lists - Receiver.send_message(u'plugin_list_refresh') + setValue(u'service/last file', QtCore.QVariant(fileName)) def loadLastFile(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a62471c2d..95337b29f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -95,8 +95,6 @@ class SongMediaItem(MediaManagerItem): self.searchLayout.addLayout(self.searchButtonLayout) self.pageLayout.addWidget(self.searchWidget) # Signals and slots - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'plugin_list_refresh'), self.onSearchTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClick) QtCore.QObject.connect(self.searchTextButton, @@ -433,6 +431,7 @@ class SongMediaItem(MediaManagerItem): if add_song: if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) + self.onSearchTextButtonClick() # Update service with correct song id. if editId: Receiver.send_message(u'service_item_update', From c0de5cfd8880c3277be6e2f4ad1255676c5d8e15 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 17:11:20 +0000 Subject: [PATCH 071/104] Fix up exception form --- openlp.pyw | 1 + openlp/core/ui/exceptiondialog.py | 23 ++++ openlp/core/ui/exceptionform.py | 30 ++++- resources/forms/exceptiondialog.ui | 194 ++++++++++++++++++----------- 4 files changed, 170 insertions(+), 78 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 8d20080c9..4704a8740 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -196,6 +196,7 @@ class OpenLP(QtGui.QApplication): self.mainWindow.repaint() update_check = QtCore.QSettings().value( u'general/update check', QtCore.QVariant(True)).toBool() + a=c if update_check: VersionThread(self.mainWindow, app_version).start() return self.exec_() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 69035dc4d..9e9b558df 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -46,6 +46,15 @@ class Ui_ExceptionDialog(object): self.messageLabel.setObjectName(u'messageLabel') self.messageLayout.addWidget(self.messageLabel) self.exceptionLayout.addLayout(self.messageLayout) + self.descriptionExplanation = QtGui.QLabel(exceptionDialog) + self.descriptionExplanation.setObjectName(u'descriptionExplanation') + self.exceptionLayout.addWidget(self.descriptionExplanation) + self.descriptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) + self.descriptionTextEdit.setObjectName(u'descriptionTextEdit') + self.exceptionLayout.addWidget(self.descriptionTextEdit) + self.descriptionWordCount = QtGui.QLabel(exceptionDialog) + self.descriptionWordCount.setObjectName(u'descriptionWordCount') + self.exceptionLayout.addWidget(self.descriptionWordCount) self.exceptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) self.exceptionTextEdit.setReadOnly(True) self.exceptionTextEdit.setObjectName(u'exceptionTextEdit') @@ -65,19 +74,31 @@ class Ui_ExceptionDialog(object): self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) + self.attachFileButton = QtGui.QPushButton(exceptionDialog) + self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) + self.attachFileButton.setObjectName(u'attachFileButton') + self.exceptionButtonBox.addButton(self.attachFileButton, + QtGui.QDialogButtonBox.ActionRole) self.retranslateUi(exceptionDialog) + QtCore.QObject.connect(self.descriptionTextEdit, + QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated) QtCore.QObject.connect(self.exceptionButtonBox, QtCore.SIGNAL(u'rejected()'), exceptionDialog.reject) QtCore.QObject.connect(self.sendReportButton, QtCore.SIGNAL(u'pressed()'), self.onSendReportButtonPressed) QtCore.QObject.connect(self.saveReportButton, QtCore.SIGNAL(u'pressed()'), self.onSaveReportButtonPressed) + QtCore.QObject.connect(self.attachFileButton, + QtCore.SIGNAL(u'pressed()'), self.onAttachFileButtonPressed) QtCore.QMetaObject.connectSlotsByName(exceptionDialog) def retranslateUi(self, exceptionDialog): exceptionDialog.setWindowTitle( translate('OpenLP.ExceptionDialog', 'Error Occurred')) + self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', + 'Please enter a description of what you were doing to cause this ' + 'error')) self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' 'below contains information that might be helpful to the OpenLP ' @@ -88,3 +109,5 @@ class Ui_ExceptionDialog(object): 'Send E-Mail')) self.saveReportButton.setText(translate('OpenLP.ExceptionDialog', 'Save to File')) + self.attachFileButton.setText(translate('OpenLP.ExceptionDialog', + 'Attach File')) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 347bcf8f1..ff37770d2 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -70,8 +70,13 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.setupUi(self) self.settingsSection = u'crashreport' + def exec_(self): + self.onDescriptionUpdated() + return QtGui.QDialog.exec_(self) + def _createReport(self): openlp_version = self.parent().applicationVersion[u'full'] + description = unicode(self.descriptionTextEdit.toPlainText()) traceback = unicode(self.exceptionTextEdit.toPlainText()) system = unicode(translate('OpenLP.ExceptionForm', 'Platform: %s\n')) % platform.platform() @@ -90,7 +95,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): system = system + u'Desktop: KDE SC\n' elif os.environ.get(u'GNOME_DESKTOP_SESSION_ID'): system = system + u'Desktop: GNOME\n' - return (openlp_version, traceback, system, libraries) + return (openlp_version, description, traceback, system, libraries) def onSaveReportButtonPressed(self): """ @@ -99,6 +104,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): report = unicode(translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' 'Version: %s\n\n' + '--- Details of the Exception. ---\n\n%s\n\n ' '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n')) @@ -129,10 +135,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): Opening systems default email client and inserting exception log and system informations. """ + attach = None body = unicode(translate('OpenLP.ExceptionForm', '*OpenLP Bug Report*\n' 'Version: %s\n\n' - '--- Please enter the report below this line. ---\n\n\n' + '--- Details of the Exception. ---\n\n%s\n\n ' '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n', @@ -145,5 +152,20 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): if u':' in line: exception = line.split(u'\n')[-1].split(u':')[0] subject = u'Bug report: %s in %s' % (exception, source) - mailto(address=u'bugs@openlp.org', subject=subject, - body=body % content) + if attach: + mailto(address=u'bugs@openlp.org', subject=subject, + body=body % content, attach=attach) + else: + mailto(address=u'bugs@openlp.org', subject=subject, + body=body % content) + + def onDescriptionUpdated(self): + count = int(20 - len(self.descriptionTextEdit.toPlainText())) + if count < 0: + count = 0 + self.descriptionWordCount.setText( + unicode(translate('OpenLP.ExceptionDialog', + 'Characters to Enter : %s')) % count ) + + def onAttachFileButtonPressed(self): + print self.descriptionTextEdit.toPlainText() diff --git a/resources/forms/exceptiondialog.ui b/resources/forms/exceptiondialog.ui index f6f15cdc7..9fd138092 100644 --- a/resources/forms/exceptiondialog.ui +++ b/resources/forms/exceptiondialog.ui @@ -13,82 +13,128 @@ Dialog - - - 8 + + + + 8 + 194 + 564 + 171 + - - 8 + + true - - - - 0 - - - 0 - - - 0 - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/graphics/exception.png - - - Qt::AlignCenter - - - - - - - Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred. - - - true - - - - - - - - - true - - - false - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - + + false + + + + + + 8 + 373 + 83 + 26 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + 8 + 103 + 561 + 71 + + + + + 0 + 0 + + + + + + + 10 + 170 + 301 + 17 + + + + TextLabel + + + + + + 10 + 80 + 59 + 17 + + + + TextLabel + + + + + + 0 + + + 0 + + + 0 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/graphics/exception.png + + + Qt::AlignCenter + + + + + + + Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred. + + + true + + + + + From fb6d3e7724ae6364430f36f8f7ab9cec130425db Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 3 Feb 2011 18:11:41 +0100 Subject: [PATCH 072/104] fixed docs --- openlp/plugins/songs/lib/db.py | 94 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index fa42971b3..2bbf818b3 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -71,6 +71,7 @@ class Topic(BaseModel): def init_schema(url): + """ Setup the songs database connection and initialise the database schema. @@ -78,6 +79,7 @@ def init_schema(url): The database to setup The song database contains the following tables: + * authors * authors_songs * media_files @@ -87,76 +89,74 @@ def init_schema(url): * songs_topics * topics - *authors* Table - --------------- + **authors** Table This table holds the names of all the authors. It has the following columns: - * id - * first_name - * last_name - * display_name - *authors_songs* Table - --------------------- + * id + * first_name + * last_name + * display_name + + **authors_songs Table** This is a bridging table between the *authors* and *songs* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * author_id - * song_id - *media_files* Table - ------------------- - * id - * file_name - * type + * author_id + * song_id - *media_files_songs* Table - ------------------------- - * media_file_id - * song_id + **media_files Table** + * id + * file_name + * type - *song_books* Table - ------------------ + **media_files_songs Table** + * media_file_id + * song_id + + **song_books Table** The *song_books* table holds a list of books that a congregation gets their songs from, or old hymnals now no longer used. This table has the following columns: - * id - * name - * publisher - *songs* Table - ------------- + * id + * name + * publisher + + **songs Table** This table contains the songs, and each song has a list of attributes. The *songs* table has the following columns: - * id - * song_book_id - * title - * alternate_title - * lyrics - * verse_order - * copyright - * comments - * ccli_number - * song_number - * theme_name - * search_title - * search_lyrics - *songs_topics* Table - -------------------- + * id + * song_book_id + * title + * alternate_title + * lyrics + * verse_order + * copyright + * comments + * ccli_number + * song_number + * theme_name + * search_title + * search_lyrics + + **songs_topics Table** This is a bridging table between the *songs* and *topics* tables, which serves to create a many-to-many relationship between the two tables. It has the following columns: - * song_id - * topic_id - *topics* Table - -------------- + * song_id + * topic_id + + **topics Table** The topics table holds a selection of topics that songs can cover. This is useful when a worship leader wants to select songs with a certain theme. This table has the following columns: - * id - * name + + * id + * name """ session, metadata = init_db(url) From 8dcf86882747c93860d42745bc584b909004f5ce Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 3 Feb 2011 18:14:00 +0100 Subject: [PATCH 073/104] fixed bible doc --- openlp/plugins/bibles/lib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index f2797e16d..070c9fe56 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -91,7 +91,7 @@ def parse_reference(reference): ``range_string`` is a regular expression which matches for verse range declarations: - 1. ``(?:(?P[0-9]+)%(sep_v)s)?' + 1. ``(?:(?P[0-9]+)%(sep_v)s)?`` It starts with a optional chapter reference ``from_chapter`` followed by a verse separator. 2. ``(?P[0-9]+)`` From 52a465b90a5e566154c63afa7c46ace39fe2f0af Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 3 Feb 2011 18:20:41 +0100 Subject: [PATCH 074/104] removed white spaces --- openlp/plugins/bibles/lib/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 070c9fe56..cd04d632f 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -77,9 +77,9 @@ def parse_reference(reference): - After a verse reference all further single values are treat as verse in the last selected chapter. ``John 3:16-18`` refers to John chapter 3 verses 16 to 18 - - After a list separator it is possible to refer to additional verses. They - are build analog to the first ones. This way it is possible to define - each number of verse references. It is not possible to refer to verses in + - After a list separator it is possible to refer to additional verses. They + are build analog to the first ones. This way it is possible to define each + number of verse references. It is not possible to refer to verses in additional books. ``John 3:16,18`` refers to John chapter 3 verses 16 and 18 ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 and 20 @@ -105,15 +105,15 @@ def parse_reference(reference): 5. ``(?P[0-9]+)`` The ``to_verse`` reference is equivalent to group 2. - The full reference is matched against get_reference_match(u'full'). This + The full reference is matched against get_reference_match(u'full'). This regular expression looks like this: 1. ``^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:`` + range_string + ``(?:%(sep_l)s|(?=\s*$)))+)\s*$`` - The second group contains all ``ranges``. This can be multiple + The second group contains all ``ranges``. This can be multiple declarations of a range_string separated by a list separator. The reference list is a list of tuples, with each tuple structured like From ccfc9abc734e416ce1a538fce7109c179fd80a7e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 17:23:24 +0000 Subject: [PATCH 075/104] Fix up exception form - part 2 --- openlp.pyw | 1 + openlp/core/ui/exceptionform.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index 4704a8740..695d6e09f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -217,6 +217,7 @@ class OpenLP(QtGui.QApplication): Sets the Busy Cursor for the Application """ self.setOverrideCursor(QtCore.Qt.BusyCursor) + self.processEvents() def setNormalCursor(self): """ diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ff37770d2..f9a9c59e0 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -146,7 +146,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): 'Please add the information that bug reports are favoured written ' 'in English.')) content = self._createReport() - for line in content[1].split(u'\n'): + for line in content[2].split(u'\n'): if re.search(r'[/\\]openlp[/\\]', line): source = re.sub(r'.*[/\\]openlp[/\\](.*)".*', r'\1', line) if u':' in line: From 32b5f0f33dab784e74c346e9f231a54c8c1cf770 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 3 Feb 2011 18:28:48 +0100 Subject: [PATCH 076/104] --- openlp/plugins/songs/forms/songmaintenanceform.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 737d63204..28b03ec7d 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -484,19 +484,19 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorsListRowChanged(self, row): """ - Called when the *authorsListWidget*s current row has changed. + Called when the *authorsListWidget*'s current row has changed. """ self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton) def onTopicsListRowChanged(self, row): """ - Called when the *topicsListWidget*s current row has changed. + Called when the *topicsListWidget*'s current row has changed. """ self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton) def onBooksListRowChanged(self, row): """ - Called when the *booksListWidget*s current row has changed. + Called when the *booksListWidget*'s current row has changed. """ self.__rowChange(row, self.booksEditButton, self.booksDeleteButton) From eb9364b45e17d049c15a4b1fd2abd50c985b8f17 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 17:56:22 +0000 Subject: [PATCH 077/104] UI library - delete_push_button --- openlp/core/lib/ui.py | 17 ++++++++++++++++- openlp/core/ui/serviceitemeditdialog.py | 7 ++----- openlp/core/ui/serviceitemeditform.py | 4 +--- openlp/plugins/alerts/forms/alertdialog.py | 7 ++----- openlp/plugins/alerts/forms/alertform.py | 4 +--- openlp/plugins/custom/forms/editcustomdialog.py | 10 ++-------- openlp/plugins/custom/forms/editcustomform.py | 4 +--- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 8cfffef45..2c8853744 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import build_icon, translate log = logging.getLogger(__name__) @@ -108,3 +108,18 @@ def media_item_combo_box(parent, name): combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) return combo + +def delete_push_button(parent, icon=None): + """ + Return a standard push button with delete label. + """ + delete_button = QtGui.QPushButton(parent) + delete_button.setObjectName(u'deleteButton') + delete_icon = icon if icon else u':/general/general_delete.png' + delete_button.setIcon(build_icon(delete_icon)) + delete_button.setText(translate('OpenLP.Ui', '&Delete')) + delete_button.setToolTip( + translate('OpenLP.Ui', 'Delete the selected item.')) + QtCore.QObject.connect(delete_button, + QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) + return delete_button diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index d4c86fa61..44304f8e6 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -40,8 +40,7 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = QtGui.QPushButton(serviceItemEditDialog) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(serviceItemEditDialog) @@ -61,5 +60,3 @@ class Ui_ServiceItemEditDialog(object): def retranslateUi(self, serviceItemEditDialog): serviceItemEditDialog.setWindowTitle( translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) - self.deleteButton.setText(translate('OpenLP.ServiceItemEditForm', - 'Delete')) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 0621a44bd..808c0c179 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -44,8 +44,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtCore.SIGNAL(u'clicked()'), self.onItemUp) QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'clicked()'), self.onItemDown) - QtCore.QObject.connect(self.deleteButton, - QtCore.SIGNAL(u'clicked()'), self.onItemDelete) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -77,7 +75,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): item_name = QtGui.QListWidgetItem(frame[u'title']) self.listWidget.addItem(item_name) - def onItemDelete(self): + def onDeleteButtonClicked(self): """ Delete the current row. """ diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 272a96f3d..7a824c4d6 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate +from openlp.core.lib.ui import delete_push_button class Ui_AlertDialog(object): def setupUi(self, alertDialog): @@ -65,9 +66,7 @@ class Ui_AlertDialog(object): self.saveButton.setIcon(build_icon(u':/general/general_save.png')) self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) - self.deleteButton = QtGui.QPushButton(alertDialog) - self.deleteButton.setIcon(build_icon(u':/general/general_delete.png')) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(alertDialog) self.manageButtonLayout.addWidget(self.deleteButton) self.manageButtonLayout.addStretch() self.alertDialogLayout.addLayout(self.manageButtonLayout, 1, 1) @@ -101,8 +100,6 @@ class Ui_AlertDialog(object): translate('AlertsPlugin.AlertForm', '&New')) self.saveButton.setText( translate('AlertsPlugin.AlertForm', '&Save')) - self.deleteButton.setText( - translate('AlertsPlugin.AlertForm', '&Delete')) self.displayButton.setText( translate('AlertsPlugin.AlertForm', 'Displ&ay')) self.displayCloseButton.setText( diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index f1a0f7fea..6b3b2a9e0 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -52,8 +52,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged) QtCore.QObject.connect(self.newButton, QtCore.SIGNAL(u'clicked()'), self.onNewClick) - QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'), - self.onDeleteClick) QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL(u'clicked()'), self.onSaveClick) QtCore.QObject.connect(self.alertListWidget, @@ -83,7 +81,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): if self.triggerAlert(unicode(self.alertTextEdit.text())): self.close() - def onDeleteClick(self): + def onDeleteButtonClicked(self): """ Deletes the selected item. """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 75717c082..d7de805dd 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -64,8 +64,7 @@ class Ui_CustomEditDialog(object): self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = QtGui.QPushButton(customEditDialog) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(customEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(customEditDialog) @@ -125,11 +124,6 @@ class Ui_CustomEditDialog(object): self.editAllButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Edit all the slides at ' 'once.')) - self.deleteButton.setText( - translate('CustomPlugin.EditCustomForm', '&Delete')) - self.deleteButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Delete the selected ' - 'slide.')) self.themeLabel.setText( translate('CustomPlugin.EditCustomForm', 'The&me:')) self.creditLabel.setText( diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e8dfa20aa..896100d67 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -62,8 +62,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed) - QtCore.QObject.connect(self.deleteButton, - QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed) QtCore.QObject.connect(self.upButton, QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.QObject.connect(self.downButton, @@ -243,7 +241,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.addItem(slide) self.slideListView.repaint() - def onDeleteButtonPressed(self): + def onDeleteButtonClicked(self): self.slideListView.takeItem(self.slideListView.currentRow()) self.editButton.setEnabled(True) self.editAllButton.setEnabled(True) From b73a429ab23266677d63a79104c74e05eb600edf Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 18:19:56 +0000 Subject: [PATCH 078/104] UI library - up_down_push_button_set --- openlp/core/lib/ui.py | 20 +++++++++++++++++++ openlp/core/ui/serviceitemeditdialog.py | 11 ++++------ openlp/core/ui/serviceitemeditform.py | 9 ++------- .../plugins/custom/forms/editcustomdialog.py | 17 ++++------------ openlp/plugins/custom/forms/editcustomform.py | 8 ++------ 5 files changed, 32 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 2c8853744..334aaff2b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -123,3 +123,23 @@ def delete_push_button(parent, icon=None): QtCore.QObject.connect(delete_button, QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) return delete_button + +def up_down_push_button_set(parent): + """ + Return a standard set of two push buttons for up and down use with lists. + """ + up_button = QtGui.QPushButton(parent) + up_button.setIcon(build_icon(u':/services/service_up.png')) + up_button.setObjectName(u'upButton') + up_button.setToolTip( + translate('OpenLP.Ui', 'Move selection up one position.')) + down_button = QtGui.QPushButton(parent) + down_button.setIcon(build_icon(u':/services/service_down.png')) + down_button.setObjectName(u'downButton') + down_button.setToolTip( + translate('OpenLP.Ui', 'Move selection down one position.')) + QtCore.QObject.connect(up_button, + QtCore.SIGNAL(u'clicked()'), parent.onUpButtonClicked) + QtCore.QObject.connect(down_button, + QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) + return up_button, down_button diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 44304f8e6..be7072026 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,7 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ + up_down_push_button_set class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -43,13 +44,9 @@ class Ui_ServiceItemEditDialog(object): self.deleteButton = delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton = QtGui.QPushButton(serviceItemEditDialog) - self.upButton.setIcon(build_icon(u':/services/service_up.png')) - self.upButton.setObjectName(u'upButton') + self.upButton, self.downButton = up_down_push_button_set( + serviceItemEditDialog) self.buttonLayout.addWidget(self.upButton) - self.downButton = QtGui.QPushButton(serviceItemEditDialog) - self.downButton.setIcon(build_icon(u':/services/service_down.png')) - self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 808c0c179..70518f30c 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -39,11 +39,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.itemList = [] - # enable drop - QtCore.QObject.connect(self.upButton, - QtCore.SIGNAL(u'clicked()'), self.onItemUp) - QtCore.QObject.connect(self.downButton, - QtCore.SIGNAL(u'clicked()'), self.onItemDown) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -90,13 +85,13 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): else: self.listWidget.setCurrentRow(row) - def onItemUp(self): + def onUpButtonClicked(self): """ Move the current row up in the list. """ self.__moveItem(u'up') - def onItemDown(self): + def onDownButtonClicked(self): """ Move the current row down in the list """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index d7de805dd..b73899057 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,7 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ + up_down_push_button_set class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -67,13 +68,9 @@ class Ui_CustomEditDialog(object): self.deleteButton = delete_push_button(customEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton = QtGui.QPushButton(customEditDialog) - self.upButton.setIcon(build_icon(u':/services/service_up.png')) - self.upButton.setObjectName(u'upButton') + self.upButton, self.downButton = up_down_push_button_set( + customEditDialog) self.buttonLayout.addWidget(self.upButton) - self.downButton = QtGui.QPushButton(customEditDialog) - self.downButton.setIcon(build_icon(u':/services/service_down.png')) - self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.centralLayout.addLayout(self.buttonLayout) self.dialogLayout.addLayout(self.centralLayout) @@ -101,12 +98,6 @@ class Ui_CustomEditDialog(object): def retranslateUi(self, customEditDialog): customEditDialog.setWindowTitle( translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) - self.upButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Move slide up one ' - 'position.')) - self.downButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Move slide down one ' - 'position.')) self.titleLabel.setText( translate('CustomPlugin.EditCustomForm', '&Title:')) self.addButton.setText( diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 896100d67..5a32d6cc1 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -62,10 +62,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed) - QtCore.QObject.connect(self.upButton, - QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) - QtCore.QObject.connect(self.downButton, - QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onSlideListViewPressed) @@ -166,14 +162,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) return self.manager.save_object(self.customSlide) - def onUpButtonPressed(self): + def onUpButtonClicked(self): selectedRow = self.slideListView.currentRow() if selectedRow != 0: qw = self.slideListView.takeItem(selectedRow) self.slideListView.insertItem(selectedRow - 1, qw) self.slideListView.setCurrentRow(selectedRow - 1) - def onDownButtonPressed(self): + def onDownButtonClicked(self): selectedRow = self.slideListView.currentRow() # zero base arrays if selectedRow != self.slideListView.count() - 1: From 2069737e1f00cd2934abc826ecd38b3180950b64 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 18:48:41 +0000 Subject: [PATCH 079/104] remove extra post events --- openlp/core/ui/servicemanager.py | 1 - openlp/plugins/bibles/lib/http.py | 1 - openlp/plugins/songs/forms/songmaintenanceform.py | 1 - 3 files changed, 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4d36f4aec..bddd150b8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -507,7 +507,6 @@ class ServiceManager(QtGui.QWidget): p_file = filePath if 'p_file' in locals(): Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') fileTo = open(p_file, u'r') items = cPickle.load(fileTo) fileTo.close() diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8db214140..7cba6facb 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -443,7 +443,6 @@ class HTTPBible(BibleDB): book = db_book.name if BibleDB.get_verse_count(self, book, reference[1]) == 0: Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): ## We have found a book of the bible lets check to see diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 737d63204..2aeb30228 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -372,7 +372,6 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Utility method to merge two objects to leave one in the database. """ Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') merge(dbObject) reset() Receiver.send_message(u'songs_load_list') From 999f40ffc9ab0b5ca204fe6a5d3c759f8612802e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 19:07:27 +0000 Subject: [PATCH 080/104] Exception Form has attachments --- openlp/core/ui/exceptionform.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index f9a9c59e0..a92967b6c 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -72,6 +72,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def exec_(self): self.onDescriptionUpdated() + self.fileAttachment = None return QtGui.QDialog.exec_(self) def _createReport(self): @@ -152,9 +153,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): if u':' in line: exception = line.split(u'\n')[-1].split(u':')[0] subject = u'Bug report: %s in %s' % (exception, source) - if attach: + if self.fileAttachment: mailto(address=u'bugs@openlp.org', subject=subject, - body=body % content, attach=attach) + body=body % content, attach=self.fileAttachment) else: mailto(address=u'bugs@openlp.org', subject=subject, body=body % content) @@ -163,9 +164,24 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): count = int(20 - len(self.descriptionTextEdit.toPlainText())) if count < 0: count = 0 + self.__buttonState(True) + else: + self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', 'Characters to Enter : %s')) % count ) def onAttachFileButtonPressed(self): - print self.descriptionTextEdit.toPlainText() + files = QtGui.QFileDialog.getOpenFileName( + self,translate('ImagePlugin.ExceptionDialog', + 'Select Attachment'), + SettingsManager.get_last_dir(u'exceptions'), + u'%s (*.*) (*)' % + unicode(translate('ImagePlugin.MediaItem', 'All Files'))) + log.info(u'New files(s) %s', unicode(files)) + if files: + self.fileAttachment = unicode(files) + + def __buttonState(self, state): + self.saveReportButton.setEnabled(state) + self.sendReportButton.setEnabled(state) From 1f4c26e466a1e4c19a7f700b012831120f712be0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 3 Feb 2011 20:11:27 +0100 Subject: [PATCH 081/104] --- openlp/plugins/alerts/forms/alertdialog.py | 3 ++ openlp/plugins/alerts/forms/alertform.py | 44 +++++++++++++++------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 272a96f3d..2e7e19176 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -66,6 +66,7 @@ class Ui_AlertDialog(object): self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) self.deleteButton = QtGui.QPushButton(alertDialog) + self.deleteButton.setEnabled(False) self.deleteButton.setIcon(build_icon(u':/general/general_delete.png')) self.deleteButton.setObjectName(u'deleteButton') self.manageButtonLayout.addWidget(self.deleteButton) @@ -75,11 +76,13 @@ class Ui_AlertDialog(object): self.buttonBox.addButton(QtGui.QDialogButtonBox.Close) displayIcon = build_icon(u':/general/general_live.png') self.displayButton = QtGui.QPushButton(alertDialog) + self.displayButton.setEnabled(False) self.displayButton.setIcon(displayIcon) self.displayButton.setObjectName(u'displayButton') self.buttonBox.addButton(self.displayButton, QtGui.QDialogButtonBox.ActionRole) self.displayCloseButton = QtGui.QPushButton(alertDialog) + self.displayCloseButton.setEnabled(False) self.displayCloseButton.setIcon(displayIcon) self.displayCloseButton.setObjectName(u'displayCloseButton') self.buttonBox.addButton(self.displayCloseButton, diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index f1a0f7fea..1d10b99a9 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -44,22 +44,24 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.item_id = None QtGui.QDialog.__init__(self, plugin.formparent) self.setupUi(self) - QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), - self.onDisplayClicked) + QtCore.QObject.connect(self.displayButton, + QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked) QtCore.QObject.connect(self.alertTextEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged) - QtCore.QObject.connect(self.newButton, QtCore.SIGNAL(u'clicked()'), - self.onNewClick) - QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'), - self.onDeleteClick) - QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL(u'clicked()'), - self.onSaveClick) + QtCore.QObject.connect(self.newButton, + QtCore.SIGNAL(u'clicked()'), self.onNewClick) + QtCore.QObject.connect(self.deleteButton, + QtCore.SIGNAL(u'clicked()'), self.onDeleteClick) + QtCore.QObject.connect(self.saveButton, + QtCore.SIGNAL(u'clicked()'), self.onSaveClick) QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onDoubleClick) QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSingleClick) + QtCore.QObject.connect(self.alertListWidget, + QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def loadList(self): """ @@ -72,8 +74,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): item_name = QtGui.QListWidgetItem(alert.text) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) self.alertListWidget.addItem(item_name) - self.saveButton.setEnabled(False) - self.deleteButton.setEnabled(False) def onDisplayClicked(self): if self.triggerAlert(unicode(self.alertTextEdit.text())): @@ -95,8 +95,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertListWidget.takeItem(row) self.item_id = None self.alertTextEdit.setText(u'') - self.saveButton.setEnabled(False) - self.deleteButton.setEnabled(False) def onNewClick(self): if len(self.alertTextEdit.text()) == 0: @@ -142,7 +140,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertTextEdit.setText(unicode(bitem.text())) self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] self.saveButton.setEnabled(False) - self.deleteButton.setEnabled(True) def onSingleClick(self): """ @@ -158,7 +155,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): if unicode(self.alertTextEdit.text()).find(u'<>') == -1: self.parameterEdit.setText(u'') self.saveButton.setEnabled(False) - self.deleteButton.setEnabled(True) def triggerAlert(self, text): """ @@ -194,3 +190,23 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.parent.alertsmanager.displayAlert(text) return True return False + + def onCurrentRowChanged(self, row): + """ + Called when the *alertListWidget*'s current row has been changed. This + enables or disables buttons which require an item to act on. + + ``row`` + The row (int). If there is no current row, the value is -1. + """ + if row == -1: + self.displayButton.setEnabled(False) + self.displayCloseButton.setEnabled(False) + self.saveButton.setEnabled(False) + self.deleteButton.setEnabled(False) + else: + self.displayButton.setEnabled(True) + self.displayCloseButton.setEnabled(True) + self.deleteButton.setEnabled(True) + # We do not need to enable the save button, as it is only enabled + # when typing text in the "alertTextEdit". From 842e4ba5f3f8af7fb3b1f5748f22a50f122e7f45 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 19:44:03 +0000 Subject: [PATCH 082/104] Cleanup bible import form --- .../plugins/bibles/forms/bibleimportform.py | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a2509ba97..882e5c586 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -162,6 +162,8 @@ class BibleImportForm(OpenLPWizard): self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer) self.selectPageLayout.addLayout(self.formatLayout) + self.typeSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) self.selectStack = QtGui.QStackedLayout() self.selectStack.setObjectName(u'SelectStack') self.osisWidget = QtGui.QWidget(self.selectPage) @@ -181,9 +183,7 @@ class BibleImportForm(OpenLPWizard): self.osisBrowseButton.setObjectName(u'OsisBrowseButton') self.osisFileLayout.addWidget(self.osisBrowseButton) self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer) + self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.typeSpacer) self.selectStack.addWidget(self.osisWidget) self.csvWidget = QtGui.QWidget(self.selectPage) self.csvWidget.setObjectName(u'CsvWidget') @@ -226,9 +226,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesButton.setObjectName(u'CsvVersesButton') self.csvVersesLayout.addWidget(self.csvVersesButton) self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.csvSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.typeSpacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -248,10 +246,8 @@ class BibleImportForm(OpenLPWizard): self.openSongFileLayout.addWidget(self.openSongBrowseButton) self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openSongSpacer) + self.typeSpacer) self.selectStack.addWidget(self.openSongWidget) self.webTabWidget = QtGui.QTabWidget(self.selectPage) self.webTabWidget.setObjectName(u'WebTabWidget') @@ -330,10 +326,8 @@ class BibleImportForm(OpenLPWizard): self.openlp1DisabledLabel.setWordWrap(True) self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') self.openlp1Layout.addRow(self.openlp1DisabledLabel) - self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openlp1Spacer) + self.typeSpacer) self.selectStack.addWidget(self.openlp1Widget) self.selectPageLayout.addLayout(self.selectStack) self.addPage(self.selectPage) @@ -401,17 +395,17 @@ class BibleImportForm(OpenLPWizard): self.formatComboBox.setItemText(4, translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x')) self.openlp1FileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.osisFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.csvTestamentsLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Testaments location:')) + translate('BiblesPlugin.ImportWizardForm', 'Testaments file:')) self.csvBooksLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Books location:')) + translate('BiblesPlugin.ImportWizardForm', 'Books file:')) self.csvVersesLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Verse location:')) + translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) self.openSongFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Bible filename:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.webSourceLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Location:')) self.webSourceComboBox.setItemText(0, @@ -462,19 +456,14 @@ class BibleImportForm(OpenLPWizard): # Align all QFormLayouts towards each other. labelWidth = max(self.formatLabel.minimumSizeHint().width(), self.osisFileLabel.minimumSizeHint().width(), + self.csvTestamentsLabel.minimumSizeHint().width(), self.csvBooksLabel.minimumSizeHint().width(), self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), self.openlp1FileLabel.minimumSizeHint().width()) self.formatSpacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.osisSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.csvSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openSongSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openlp1Spacer.changeSize(labelWidth, 0, + self.typeSpacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): From 1ecaab4fa9b23251daa1bb27c5056f62a7b5a9d8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 20:12:06 +0000 Subject: [PATCH 083/104] Cleanup import wizard spacers --- .../plugins/bibles/forms/bibleimportform.py | 21 +++++++------------ openlp/plugins/songs/forms/songimportform.py | 7 ++++--- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 882e5c586..f21dd0e07 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -157,13 +157,10 @@ class BibleImportForm(OpenLPWizard): self.formatComboBox.addItems([u'', u'', u'', u'', u'']) self.formatComboBox.setObjectName(u'FormatComboBox') self.formatLayout.addRow(self.formatLabel, self.formatComboBox) - self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.formatSpacer) + self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectPageLayout.addLayout(self.formatLayout) - self.typeSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.selectStack = QtGui.QStackedLayout() self.selectStack.setObjectName(u'SelectStack') self.osisWidget = QtGui.QWidget(self.selectPage) @@ -183,7 +180,7 @@ class BibleImportForm(OpenLPWizard): self.osisBrowseButton.setObjectName(u'OsisBrowseButton') self.osisFileLayout.addWidget(self.osisBrowseButton) self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.typeSpacer) + self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.osisWidget) self.csvWidget = QtGui.QWidget(self.selectPage) self.csvWidget.setObjectName(u'CsvWidget') @@ -226,7 +223,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesButton.setObjectName(u'CsvVersesButton') self.csvVersesLayout.addWidget(self.csvVersesButton) self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.typeSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -246,8 +243,7 @@ class BibleImportForm(OpenLPWizard): self.openSongFileLayout.addWidget(self.openSongBrowseButton) self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.typeSpacer) + self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.openSongWidget) self.webTabWidget = QtGui.QTabWidget(self.selectPage) self.webTabWidget.setObjectName(u'WebTabWidget') @@ -326,8 +322,7 @@ class BibleImportForm(OpenLPWizard): self.openlp1DisabledLabel.setWordWrap(True) self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') self.openlp1Layout.addRow(self.openlp1DisabledLabel) - self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, - self.typeSpacer) + self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.openlp1Widget) self.selectPageLayout.addLayout(self.selectStack) self.addPage(self.selectPage) @@ -461,9 +456,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), self.openlp1FileLabel.minimumSizeHint().width()) - self.formatSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.typeSpacer.changeSize(labelWidth, 0, + self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index f1e1f82ed..a9af7f6b2 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -162,6 +162,8 @@ class SongImportForm(OpenLPWizard): self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer) self.sourceLayout.addLayout(self.formatLayout) + self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Expanding) self.formatStack = QtGui.QStackedLayout() self.formatStack.setObjectName(u'FormatStack') # OpenLP 2.0 @@ -807,10 +809,8 @@ class SongImportForm(OpenLPWizard): browseButton.setIcon(self.openIcon) browseButton.setObjectName(obj_prefix + u'BrowseButton') fileLayout.addWidget(browseButton) - formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Expanding) importLayout.addLayout(fileLayout) - importLayout.addSpacerItem(formSpacer) + importLayout.addSpacerItem(self.stackSpacer) else: fileListWidget = QtGui.QListWidget(importWidget) fileListWidget.setSelectionMode( @@ -859,6 +859,7 @@ class SongImportForm(OpenLPWizard): disabledLabel.setWordWrap(True) disabledLabel.setObjectName(obj_prefix + u'DisabledLabel') disabledLayout.addWidget(disabledLabel) + disabledLayout.addSpacerItem(self.stackSpacer) layout.addWidget(disabledWidget) importWidget = QtGui.QWidget(page) importWidget.setObjectName(obj_prefix + u'ImportWidget') From 004a38fd7fb4007f7878905659f4c2b2af2b523a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 21:32:32 +0000 Subject: [PATCH 084/104] Cleanup theme wizard spacers --- openlp/core/ui/themewizard.py | 39 +++++++++++------------------------ 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index e8765b9e2..49522df70 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -36,6 +36,8 @@ class Ui_ThemeWizard(object): themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) + self.spacer = QtGui.QSpacerItem(10, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) # Welcome Page add_welcome_page(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page @@ -52,10 +54,8 @@ class Ui_ThemeWizard(object): self.backgroundComboBox.setObjectName(u'BackgroundComboBox') self.backgroundTypeLayout.addRow(self.backgroundLabel, self.backgroundComboBox) - self.backgroundTypeSpacer = QtGui.QSpacerItem(10, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.backgroundTypeLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.backgroundTypeSpacer) + self.spacer) self.backgroundLayout.addLayout(self.backgroundTypeLayout) self.backgroundStack = QtGui.QStackedLayout() self.backgroundStack.setObjectName(u'BackgroundStack') @@ -69,10 +69,7 @@ class Ui_ThemeWizard(object): self.colorButton = QtGui.QPushButton(self.colorWidget) self.colorButton.setObjectName(u'ColorButton') self.colorLayout.addRow(self.colorLabel, self.colorButton) - self.colorSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.colorLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.colorSpacer) + self.colorLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.colorWidget) self.gradientWidget = QtGui.QWidget(self.backgroundPage) self.gradientWidget.setObjectName(u'GradientWidget') @@ -98,10 +95,7 @@ class Ui_ThemeWizard(object): self.gradientComboBox.addItems([u'', u'', u'', u'', u'']) self.gradientLayout.addRow(self.gradientTypeLabel, self.gradientComboBox) - self.gradientSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.gradientLayout.setItem(3, QtGui.QFormLayout.LabelRole, - self.gradientSpacer) + self.gradientLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.gradientWidget) self.imageWidget = QtGui.QWidget(self.backgroundPage) self.imageWidget.setObjectName(u'ImageWidget') @@ -121,10 +115,7 @@ class Ui_ThemeWizard(object): build_icon(u':/general/general_open.png')) self.imageFileLayout.addWidget(self.imageBrowseButton) self.imageLayout.addRow(self.imageLabel, self.imageFileLayout) - self.imageSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.imageLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.imageSpacer) + self.imageLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.imageWidget) self.backgroundLayout.addLayout(self.backgroundStack) themeWizard.addPage(self.backgroundPage) @@ -236,6 +227,8 @@ class Ui_ThemeWizard(object): self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox') self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox) + self.footerAreaLayout.setItem(3, QtGui.QFormLayout.LabelRole, + self.spacer) themeWizard.addPage(self.footerAreaPage) # Alignment Page self.alignmentPage = QtGui.QWizardPage() @@ -261,6 +254,8 @@ class Ui_ThemeWizard(object): self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox') self.alignmentLayout.addRow(self.transitionsLabel, self.transitionsCheckBox) + self.alignmentLayout.setItem(3, QtGui.QFormLayout.LabelRole, + self.spacer) themeWizard.addPage(self.alignmentPage) # Area Position Page self.areaPositionPage = QtGui.QWizardPage() @@ -552,16 +547,6 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Theme name:')) # Align all QFormLayouts towards each other. labelWidth = max(self.backgroundLabel.minimumSizeHint().width(), - self.colorLabel.minimumSizeHint().width(), - self.gradientStartLabel.minimumSizeHint().width(), - self.gradientEndLabel.minimumSizeHint().width(), - self.gradientTypeLabel.minimumSizeHint().width(), - self.imageLabel.minimumSizeHint().width()) - self.backgroundTypeSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.colorSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.gradientSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.imageSpacer.changeSize(labelWidth, 0, + self.horizontalLabel.minimumSizeHint().width()) + self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) From 7bd9d8a10b2dd1ed64f3724be75a02b7d3e842c5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 21:37:00 +0000 Subject: [PATCH 085/104] Importers have replaced scripts --- scripts/bible-1to2-converter.py | 308 ----------------------------- scripts/openlp-1to2-converter.py | 323 ------------------------------- 2 files changed, 631 deletions(-) delete mode 100755 scripts/bible-1to2-converter.py delete mode 100755 scripts/openlp-1to2-converter.py diff --git a/scripts/bible-1to2-converter.py b/scripts/bible-1to2-converter.py deleted file mode 100755 index ebf246608..000000000 --- a/scripts/bible-1to2-converter.py +++ /dev/null @@ -1,308 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import sys -import os -import sqlite -import sqlite3 - -from optparse import OptionParser -from traceback import format_tb as get_traceback - -# Some global options to be used throughout the import process -verbose = False -debug = False -old_cursor = None -new_cursor = None - -# SQL create statments -create_statements = [ - (u'table "book"', u"""CREATE TABLE book ( - id INTEGER NOT NULL, - testament_id INTEGER, - name VARCHAR(30), - abbreviation VARCHAR(5), - PRIMARY KEY (id), - FOREIGN KEY(testament_id) REFERENCES testament (id) -)"""), - (u'table "metadata"', u"""CREATE TABLE metadata ( - "key" VARCHAR(255) NOT NULL, - value VARCHAR(255), - PRIMARY KEY ("key") -)"""), - (u'table "testament"', u"""CREATE TABLE testament ( - id INTEGER NOT NULL, - name VARCHAR(30), - PRIMARY KEY (id) -)"""), - (u'table "verse"', u"""CREATE TABLE verse ( - id INTEGER NOT NULL, - book_id INTEGER, - chapter INTEGER, - verse INTEGER, - text TEXT, - PRIMARY KEY (id), - FOREIGN KEY(book_id) REFERENCES book (id) -)"""), - (u'index "idx_abbrev"', - u"""CREATE INDEX idx_abbrev ON book (abbreviation, id)"""), - (u'index "idx_chapter_verse_book', - u"""CREATE INDEX idx_chapter_verse_book ON verse (chapter, verse, book_id, id)"""), - (u'index "idx_chapter_verse_text"', - u"""CREATE INDEX idx_chapter_verse_text ON verse (text, verse, book_id, id)"""), - (u'index "idx_name"', - u"""CREATE INDEX idx_name ON book (name, id)""") -] - -def display_sql(sql, params): - prepared_params = [] - for param in params: - if isinstance(param, basestring): - prepared_params.append(u'"%s"' % param) - elif isinstance(param, (int, long)): - prepared_params.append(u'%d' % param) - elif isinstance(param, (float, complex)): - prepared_params.append(u'%f' % param) - else: - prepared_params.append(u'"%s"' % str(param)) - for prepared_param in prepared_params: - sql = sql.replace(u'?', prepared_param, 1) - return sql - -def create_database(): - global new_cursor, create_statements - if debug or verbose: - print 'Creating new database:' - else: - print 'Creating new database...', - for statement_type, sql_create in create_statements: - if debug: - print '... ', sql_create.replace('\n', ' ').replace(' ', ' ') - elif verbose: - print '... creating %s...' % statement_type, - new_cursor.execute(sql_create) - if verbose and not debug: - print 'done.' - if not verbose and not debug: - print 'done.' - -def import_bible(): - global old_cursor, new_cursor, debug, verbose - if debug or verbose: - print 'Importing metadata:' - else: - print 'Importing metadata...', - if debug: - print '... SELECT "key", "value" FROM metadata' - elif verbose: - print '... fetching metadata from old database...', - old_cursor.execute(u'SELECT "key", "value" FROM metadata') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - key = unicode(row[0], u'cp1252') - value = unicode(row[1], u'cp1252') - if key == u'Permission': - key = u'Permissions' - sql_insert = u'INSERT INTO metadata '\ - '("key", "value") '\ - 'VALUES (?, ?)' - sql_params = (key, value) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % key - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing testaments:' - else: - print 'Importing testaments...', - if debug: - print '... SELECT id, name FROM testament' - elif verbose: - print '... fetching testaments from old database...', - old_cursor.execute(u'SELECT id, name FROM testament') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - id = int(row[0]) - name = unicode(row[1], u'cp1252') - sql_insert = u'INSERT INTO testament '\ - '(id, name) '\ - 'VALUES (?, ?)' - sql_params = (id, name) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % name - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing books:' - else: - print 'Importing books...', - if debug: - print '... SELECT id, testament_id, name, abbreviation FROM book' - elif verbose: - print '... fetching books from old database...', - old_cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - book_map = {} - for row in rows: - testament_id = int(row[1]) - name = unicode(row[2], u'cp1252') - abbreviation = unicode(row[3], u'cp1252') - sql_insert = u'INSERT INTO book '\ - '(id, testament_id, name, abbreviation) '\ - 'VALUES (NULL, ?, ?, ?)' - sql_params = (testament_id, name, abbreviation) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % name - new_cursor.execute(sql_insert, sql_params) - book_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> (old) books.id =', row[0], ' (new) books.id =', book_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing verses:' - else: - print 'Importing verses...', - if debug: - print '... SELECT id, book_id, chapter, verse, text || \'\' AS text FROM verse...', - elif verbose: - print '... fetching verses from old database...', - old_cursor.execute(u'SELECT id, book_id, chapter, verse, text || \'\' AS text FROM verse') - rows = old_cursor.fetchall() - if debug or verbose: - print 'done.' - for row in rows: - book_id = int(row[1]) - chapter = int(row[2]) - verse = int(row[3]) - text = unicode(row[4], u'cp1252') - sql_insert = u'INSERT INTO verse '\ - '(id, book_id, chapter, verse, text) '\ - 'VALUES (NULL, ?, ?, ?, ?)' - sql_params = (book_map[book_id], chapter, verse, text) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s..."' % text[:17] - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - -def main(old_db, new_db): - global old_cursor, new_cursor, debug - old_connection = None - new_connection = None - try: - old_connection = sqlite.connect(old_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem connecting to the old database:', errormsg - return 1 - try: - new_connection = sqlite3.connect(new_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the new database:', errormsg - return 1 - old_cursor = old_connection.cursor() - new_cursor = new_connection.cursor() - try: - create_database() - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the database:', errormsg - return 1 - try: - import_bible() - new_connection.commit() - except: - new_connection.rollback() - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem importing songs:', errormsg - return 1 - print 'Import complete.' - -if __name__ == u'__main__': - option_parser = OptionParser(usage='Usage: %prog [options] OLDDATABASE NEWDATABASE') - option_parser.add_option('-o', '--overwrite', dest='overwrite', default=False, - action=u'store_true', help='Overwrite database file if it already exists.') - option_parser.add_option('-v', '--verbose', dest='verbose', default=False, - action=u'store_true', help='Outputs additional progress data.') - option_parser.add_option('-d', '--debug', dest='debug', default=False, - action=u'store_true', help='Outputs raw SQL statements (overrides verbose).') - options, arguments = option_parser.parse_args() - if len(arguments) < 2: - if len(arguments) == 0: - option_parser.error('Please specify an old database and a new database.') - else: - option_parser.error('Please specify a new database.') - old_db = os.path.abspath(arguments[0]) - new_db = os.path.abspath(arguments[1]) - if not os.path.isfile(old_db): - option_parser.error('Old database file ("%s") is not a file.' % old_db) - if not os.path.exists(old_db): - option_parser.error('Old database file ("%s") does not exist.' % old_db) - if os.path.exists(new_db): - if not options.overwrite: - option_parser.error('New database file ("%s") exists. If you want to overwrite it, specify the --overwrite option.' % new_db) - else: - if not os.path.isfile(new_db): - option_parser.error('New database file ("%s") is not a file.' % new_db) - os.unlink(new_db) - verbose = options.verbose - debug = options.debug - main(old_db, new_db) diff --git a/scripts/openlp-1to2-converter.py b/scripts/openlp-1to2-converter.py deleted file mode 100755 index bd554aa70..000000000 --- a/scripts/openlp-1to2-converter.py +++ /dev/null @@ -1,323 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import sys -import os -import sqlite -import sqlite3 -import re -from optparse import OptionParser -from traceback import format_tb as get_traceback - -# Some global options to be used throughout the import process -dirty_chars = re.compile(r'\W ', re.UNICODE) -verbose = False -debug = False -old_cursor = None -new_cursor = None - -# SQL create statments -create_statements = [ - (u'table "authors"', u"""CREATE TABLE authors ( - id INTEGER NOT NULL, - first_name VARCHAR(128), - last_name VARCHAR(128), - display_name VARCHAR(255) NOT NULL, - PRIMARY KEY (id) -)"""), - (u'table "song_books"', u"""CREATE TABLE song_books ( - id INTEGER NOT NULL, - name VARCHAR(128) NOT NULL, - publisher VARCHAR(128), - PRIMARY KEY (id) -)"""), - (u'table "songs"', u"""CREATE TABLE songs ( - id INTEGER NOT NULL, - song_book_id INTEGER, - title VARCHAR(255) NOT NULL, - alternate_title VARCHAR(255), - lyrics TEXT NOT NULL, - verse_order VARCHAR(128), - copyright VARCHAR(255), - comments TEXT, - ccli_number VARCHAR(64), - song_number VARCHAR(64), - theme_name VARCHAR(128), - search_title VARCHAR(255) NOT NULL, - search_lyrics TEXT NOT NULL, - PRIMARY KEY (id), - FOREIGN KEY(song_book_id) REFERENCES song_books (id) -)"""), - (u'table "topics"', u"""CREATE TABLE topics ( - id INTEGER NOT NULL, - name VARCHAR(128) NOT NULL, - PRIMARY KEY (id) -)"""), - (u'index "ix_songs_search_lyrics"', - u"""CREATE INDEX ix_songs_search_lyrics ON songs (search_lyrics)"""), - (u'index "ix_songs_search_title', - u"""CREATE INDEX ix_songs_search_title ON songs (search_title)"""), - (u'table "authors_songs"', u"""CREATE TABLE authors_songs ( - author_id INTEGER NOT NULL, - song_id INTEGER NOT NULL, - PRIMARY KEY (author_id, song_id), - FOREIGN KEY(author_id) REFERENCES authors (id), - FOREIGN KEY(song_id) REFERENCES songs (id) -)"""), - (u'table "songs_topics"', u"""CREATE TABLE songs_topics ( - song_id INTEGER NOT NULL, - topic_id INTEGER NOT NULL, - PRIMARY KEY (song_id, topic_id), - FOREIGN KEY(song_id) REFERENCES songs (id), - FOREIGN KEY(topic_id) REFERENCES topics (id) -)""") -] - -def prepare_string(dirty): - return dirty_chars.sub(u'', dirty.replace(u'\r\n', u' ').replace(u'\n', u' ')) - -def display_sql(sql, params): - prepared_params = [] - for param in params: - if isinstance(param, basestring): - prepared_params.append(u'"%s"' % param) - elif isinstance(param, (int, long)): - prepared_params.append(u'%d' % param) - elif isinstance(param, (float, complex)): - prepared_params.append(u'%f' % param) - else: - prepared_params.append(u'"%s"' % str(param)) - for prepared_param in prepared_params: - sql = sql.replace(u'?', prepared_param, 1) - return sql - -def create_database(): - global new_cursor, create_statements - if debug or verbose: - print 'Creating new database:' - else: - print 'Creating new database...', - for statement_type, sql_create in create_statements: - if debug: - print '... ', sql_create.replace('\n', ' ').replace(' ', ' ') - elif verbose: - print '... creating %s...' % statement_type, - new_cursor.execute(sql_create) - if verbose and not debug: - print 'done.' - if not verbose and not debug: - print 'done.' - -def import_songs(): - global old_cursor, new_cursor, debug, verbose - if debug or verbose: - print 'Importing authors:' - else: - print 'Importing authors...', - if debug: - print '... SELECT authorid AS id, authorname AS displayname FROM authors' - elif verbose: - print '... fetching authors from old database...', - old_cursor.execute(u'SELECT authorid AS id, authorname AS displayname FROM authors') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - author_map = {} - for row in rows: - display_name = unicode(row[1], u'cp1252') - names = display_name.split(u' ') - first_name = names[0] - last_name = u' '.join(names[1:]) - if last_name is None: - last_name = u'' - sql_insert = u'INSERT INTO authors '\ - '(id, first_name, last_name, display_name) '\ - 'VALUES (NULL, ?, ?, ?)' - sql_params = (first_name, last_name, display_name) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % display_name - new_cursor.execute(sql_insert, sql_params) - author_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> authors.authorid =', row[0], 'authors.id =', author_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing songs:' - else: - print 'Importing songs...', - if debug: - print '... SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs...', - elif verbose: - print '... fetching songs from old database...', - old_cursor.execute(u'SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs') - rows = old_cursor.fetchall() - if debug or verbose: - print 'done.' - song_map = {} - xml_lyrics_template = u'%s' - xml_verse_template = u'' - for row in rows: - clean_title = unicode(row[1], u'cp1252') - clean_lyrics = unicode(row[2], u'cp1252').replace(u'\r\n', u'\n') - clean_copyright = unicode(row[3], u'cp1252') - verse_order = u'' - text_lyrics = clean_lyrics.split(u'\n\n') - xml_verse = u'' - verses = [] - for line, verse in enumerate(text_lyrics): - if not verse: - continue - xml_verse += (xml_verse_template % (line + 1, verse)) - verses.append(u'V%d' % (line + 1)) - verse_order = u' '.join(verses) - xml_lyrics = xml_lyrics_template % xml_verse - search_title = prepare_string(clean_title) - search_lyrics = prepare_string(clean_lyrics) - sql_insert = u'INSERT INTO songs '\ - '(id, song_book_id, title, lyrics, verse_order, copyright, search_title, search_lyrics) '\ - 'VALUES (NULL, 0, ?, ?, ?, ?, ?, ?)' - sql_params = (clean_title, xml_lyrics, verse_order, clean_copyright, search_title, search_lyrics) - if debug: - print '...', display_sql(sql_insert, (sql_params[0], u'%s...' % clean_lyrics[:7], sql_params[2], sql_params[3], sql_params[4], u'%s...' % search_lyrics[:7])) - elif verbose: - print '... importing "%s"' % clean_title - new_cursor.execute(sql_insert, sql_params) - song_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> songs.songid =', row[0], 'songs.id =', song_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing song-to-author mapping:' - else: - print 'Importing song-to-author mapping...', - if debug: - print '... SELECT authorid AS author_id, songid AS song_id FROM songauthors' - elif verbose: - print '... fetching song-to-author mapping from old database...', - old_cursor.execute(u'SELECT authorid AS author_id, songid AS song_id FROM songauthors') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - sql_insert = u'INSERT INTO authors_songs '\ - '(author_id, song_id) '\ - 'VALUES (?, ?)' - sql_params = (author_map[row[0]], song_map[row[1]]) - if debug: - print '... ', display_sql(sql_insert, sql_params) - elif verbose: - print '... Author %d (was %d) => Song %d (was %d)'\ - % (int(row[0]), author_map[row[0]], - int(row[1]), song_map[row[1]]) - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - -def main(old_db, new_db): - global old_cursor, new_cursor, debug - old_connection = None - new_connection = None - try: - old_connection = sqlite.connect(old_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem connecting to the old database:', errormsg - return 1 - try: - new_connection = sqlite3.connect(new_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the new database:', errormsg - return 1 - old_cursor = old_connection.cursor() - new_cursor = new_connection.cursor() - try: - create_database() - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the database:', errormsg - return 1 - try: - import_songs() - new_connection.commit() - except: - new_connection.rollback() - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem importing songs:', errormsg - return 1 - print 'Import complete.' - -if __name__ == u'__main__': - option_parser = OptionParser(usage='Usage: %prog [options] OLDDATABASE NEWDATABASE') - option_parser.add_option('-o', '--overwrite', dest='overwrite', default=False, - action=u'store_true', help='Overwrite database file if it already exists.') - option_parser.add_option('-v', '--verbose', dest='verbose', default=False, - action=u'store_true', help='Outputs additional progress data.') - option_parser.add_option('-d', '--debug', dest='debug', default=False, - action=u'store_true', help='Outputs raw SQL statements (overrides verbose).') - options, arguments = option_parser.parse_args() - if len(arguments) < 2: - if len(arguments) == 0: - option_parser.error('Please specify an old database and a new database.') - else: - option_parser.error('Please specify a new database.') - old_db = os.path.abspath(arguments[0]) - new_db = os.path.abspath(arguments[1]) - if not os.path.isfile(old_db): - option_parser.error('Old database file ("%s") is not a file.' % old_db) - if not os.path.exists(old_db): - option_parser.error('Old database file ("%s") does not exist.' % old_db) - if os.path.exists(new_db): - if not options.overwrite: - option_parser.error('New database file ("%s") exists. If you want to overwrite it, specify the --overwrite option.' % new_db) - else: - if not os.path.isfile(new_db): - option_parser.error('New database file ("%s") is not a file.' % new_db) - os.unlink(new_db) - verbose = options.verbose - debug = options.debug - main(old_db, new_db) From ea479bb67a8a2b2b1db2d20b9b9e84be37f30293 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 22:00:14 +0000 Subject: [PATCH 086/104] Fix missing import --- openlp/core/lib/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 334aaff2b..399f75a9c 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, Receiver, translate log = logging.getLogger(__name__) From a2994fb7d7d75aeeb52bfa1db1d5dbfee98c1814 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 22:39:18 +0000 Subject: [PATCH 087/104] Unused import --- openlp/core/ui/serviceitemeditdialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index be7072026..4046e94ab 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon +from openlp.core.lib import translate from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ up_down_push_button_set From d029fb81a781cb4f386efb98755fbfef938d89f8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 23:25:52 +0000 Subject: [PATCH 088/104] MediaItem cleanups --- openlp/core/lib/mediamanageritem.py | 41 +++++++++++++++----------- openlp/plugins/images/lib/mediaitem.py | 10 +++---- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 39c37e2a9..683459825 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -366,33 +366,34 @@ class MediaManagerItem(QtGui.QWidget): count += 1 return filelist - def validate(self, file, thumb): + def validate(self, image, thumb): """ - Validates to see if the file still exists or thumbnail is up to date + Validates whether an image still exists and, if it does, is the + thumbnail representation of the image up to date. """ - if not os.path.exists(file): + if not os.path.exists(image): return False if os.path.exists(thumb): - filedate = os.stat(file).st_mtime - thumbdate = os.stat(thumb).st_mtime - # if file updated rebuild icon - if filedate > thumbdate: - self.iconFromFile(file, thumb) + imageDate = os.stat(image).st_mtime + thumbDate = os.stat(thumb).st_mtime + # If image has been updated rebuild icon + if imageDate > thumbDate: + self.iconFromFile(image, thumb) else: - self.iconFromFile(file, thumb) + self.iconFromFile(image, thumb) return True - def iconFromFile(self, file, thumb): + def iconFromFile(self, image, thumb): """ - Create a thumbnail icon from a given file + Create a thumbnail icon from a given image. - ``file`` - The file to create the icon from + ``image`` + The image file to create the icon from. ``thumb`` The filename to save the thumbnail to """ - icon = build_icon(unicode(file)) + icon = build_icon(unicode(image)) pixmap = icon.pixmap(QtCore.QSize(88, 50)) ext = os.path.splitext(thumb)[1].lower() pixmap.save(thumb, ext[1:]) @@ -403,12 +404,16 @@ class MediaManagerItem(QtGui.QWidget): u'defined by the plugin') def onNewClick(self): - raise NotImplementedError(u'MediaManagerItem.onNewClick needs to be ' - u'defined by the plugin') + """ + Hook for plugins to define behaviour for adding new items. + """ + pass def onEditClick(self): - raise NotImplementedError(u'MediaManagerItem.onEditClick needs to be ' - u'defined by the plugin') + """ + Hook for plugins to define behaviour for editing items. + """ + pass def onDeleteClick(self): raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to ' diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index cbefc7171..71027881c 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -123,19 +123,19 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection, self.getFileList()) def loadList(self, list): - for file in list: - filename = os.path.split(unicode(file))[1] + for imageFile in list: + filename = os.path.split(unicode(imageFile))[1] thumb = os.path.join(self.servicePath, filename) if os.path.exists(thumb): - if self.validate(file, thumb): + if self.validate(imageFile, thumb): icon = build_icon(thumb) else: icon = build_icon(u':/general/general_delete.png') else: - icon = self.iconFromFile(file, thumb) + icon = self.iconFromFile(imageFile, thumb) item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(icon) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) + item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) self.listView.addItem(item_name) def generateSlideData(self, service_item, item=None, xmlVersion=False): From 8fd9111f99a7789f2ef1d1eebdbb16a03b9512db Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 01:56:19 +0000 Subject: [PATCH 089/104] UI library - actions --- openlp/core/lib/dockwidget.py | 4 +- openlp/core/lib/ui.py | 29 ++++++ openlp/core/ui/mainwindow.py | 164 ++++++++++++---------------------- 3 files changed, 91 insertions(+), 106 deletions(-) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 24841ec33..32d6ce765 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -31,6 +31,8 @@ import logging from PyQt4 import QtGui +from openlp.core.lib import build_icon + log = logging.getLogger(__name__) class OpenLPDockWidget(QtGui.QDockWidget): @@ -47,4 +49,4 @@ class OpenLPDockWidget(QtGui.QDockWidget): if name: self.setObjectName(name) if icon: - self.setWindowIcon(icon) + self.setWindowIcon(build_icon(icon)) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 399f75a9c..03590d5d9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -143,3 +143,32 @@ def up_down_push_button_set(parent): QtCore.QObject.connect(down_button, QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) return up_button, down_button + +def base_action(parent, name): + """ + Return the most basic action with the object name set. + """ + action = QtGui.QAction(parent) + action.setObjectName(name) + return action + +def checkable_action(parent, name, checked=None): + """ + Return a standard action with the checkable attribute set. + """ + action = base_action(parent, name) + action.setCheckable(True) + if checked is not None: + action.setChecked(checked) + return action + +def icon_action(parent, name, icon, checked=None): + """ + Return a standard action with an icon. + """ + if checked is not None: + action = checkable_action(parent, name, checked) + else: + action = base_action(parent, name) + action.setIcon(build_icon(icon)) + return action diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6f57861c4..9af4931fb 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -28,11 +28,12 @@ import logging from PyQt4 import QtCore, QtGui +from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ + SettingsManager, PluginManager, Receiver, translate +from openlp.core.lib.ui import base_action, checkable_action, icon_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm -from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ - SettingsManager, PluginManager, Receiver, translate from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ ActionList @@ -124,9 +125,8 @@ class Ui_MainWindow(object): self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = OpenLPDockWidget( - mainWindow, u'MediaManagerDock', - build_icon(u':/system/system_mediamanager.png')) + self.MediaManagerDock = OpenLPDockWidget(mainWindow, + u'MediaManagerDock', u':/system/system_mediamanager.png') self.MediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) self.MediaManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_left) @@ -137,9 +137,8 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.MediaManagerDock) # Create the service manager - self.ServiceManagerDock = OpenLPDockWidget( - mainWindow, u'ServiceManagerDock', - build_icon(u':/system/system_servicemanager.png')) + self.ServiceManagerDock = OpenLPDockWidget(mainWindow, + u'ServiceManagerDock', u':/system/system_servicemanager.png') self.ServiceManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ServiceManagerContents = ServiceManager(mainWindow, @@ -148,9 +147,8 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.ServiceManagerDock) # Create the theme manager - self.ThemeManagerDock = OpenLPDockWidget( - mainWindow, u'ThemeManagerDock', - build_icon(u':/system/system_thememanager.png')) + self.ThemeManagerDock = OpenLPDockWidget(mainWindow, + u'ThemeManagerDock', u':/system/system_thememanager.png') self.ThemeManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ThemeManagerContents = ThemeManager(mainWindow, @@ -160,103 +158,70 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.ThemeManagerDock) # Create the menu items - self.FileNewItem = QtGui.QAction(mainWindow) - self.FileNewItem.setIcon(build_icon(u':/general/general_new.png')) - self.FileNewItem.setObjectName(u'FileNewItem') + self.FileNewItem = icon_action(mainWindow, u'FileNewItem', + u':/general/general_new.png') mainWindow.actionList.add_action(self.FileNewItem, u'File') - self.FileOpenItem = QtGui.QAction(mainWindow) - self.FileOpenItem.setIcon(build_icon(u':/general/general_open.png')) - self.FileOpenItem.setObjectName(u'FileOpenItem') + self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', + u':/general/general_open.png') mainWindow.actionList.add_action(self.FileOpenItem, u'File') - self.FileSaveItem = QtGui.QAction(mainWindow) - self.FileSaveItem.setIcon(build_icon(u':/general/general_save.png')) - self.FileSaveItem.setObjectName(u'FileSaveItem') + self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', + u':/general/general_save.png') mainWindow.actionList.add_action(self.FileSaveItem, u'File') - self.FileSaveAsItem = QtGui.QAction(mainWindow) - self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') + self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') - self.printServiceOrderItem = QtGui.QAction(mainWindow) - self.printServiceOrderItem.setObjectName(u'printServiceItem') + self.printServiceOrderItem = base_action( + mainWindow, u'printServiceItem') mainWindow.actionList.add_action( self.printServiceOrderItem, u'Print Service Order') - self.FileExitItem = QtGui.QAction(mainWindow) - self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) - self.FileExitItem.setObjectName(u'FileExitItem') + self.FileExitItem = icon_action(mainWindow, u'FileExitItem', + u':/system/system_exit.png') mainWindow.actionList.add_action(self.FileExitItem, u'File') - self.ImportThemeItem = QtGui.QAction(mainWindow) - self.ImportThemeItem.setObjectName(u'ImportThemeItem') + self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem') mainWindow.actionList.add_action(self.ImportThemeItem, u'Import') - self.ImportLanguageItem = QtGui.QAction(mainWindow) - self.ImportLanguageItem.setObjectName(u'ImportLanguageItem') + self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem') mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import') - self.ExportThemeItem = QtGui.QAction(mainWindow) - self.ExportThemeItem.setObjectName(u'ExportThemeItem') + self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem') mainWindow.actionList.add_action(self.ExportThemeItem, u'Export') - self.ExportLanguageItem = QtGui.QAction(mainWindow) - self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') + self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem') mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') - self.ViewMediaManagerItem = QtGui.QAction(mainWindow) - self.ViewMediaManagerItem.setCheckable(True) - self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible()) - self.ViewMediaManagerItem.setIcon( - build_icon(u':/system/system_mediamanager.png')) - self.ViewMediaManagerItem.setObjectName(u'ViewMediaManagerItem') - self.ViewThemeManagerItem = QtGui.QAction(mainWindow) - self.ViewThemeManagerItem.setCheckable(True) - self.ViewThemeManagerItem.setChecked(self.ThemeManagerDock.isVisible()) - self.ViewThemeManagerItem.setIcon( - build_icon(u':/system/system_thememanager.png')) - self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem') + self.ViewMediaManagerItem = icon_action(mainWindow, + u'ViewMediaManagerItem', u':/system/system_mediamanager.png', + self.MediaManagerDock.isVisible()) + self.ViewThemeManagerItem = icon_action(mainWindow, + u'ViewThemeManagerItem', u':/system/system_thememanager.png', + self.ThemeManagerDock.isVisible()) mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') - self.ViewServiceManagerItem = QtGui.QAction(mainWindow) - self.ViewServiceManagerItem.setCheckable(True) - self.ViewServiceManagerItem.setChecked( + self.ViewServiceManagerItem = icon_action(mainWindow, + u'ViewServiceManagerItem', u':/system/system_servicemanager.png', self.ServiceManagerDock.isVisible()) - self.ViewServiceManagerItem.setIcon( - build_icon(u':/system/system_servicemanager.png')) - self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') - self.ViewPreviewPanel = QtGui.QAction(mainWindow) - self.ViewPreviewPanel.setCheckable(True) - self.ViewPreviewPanel.setChecked(previewVisible) - self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') + self.ViewPreviewPanel = checkable_action(mainWindow, + u'ViewPreviewPanel', previewVisible) mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View') - self.ViewLivePanel = QtGui.QAction(mainWindow) - self.ViewLivePanel.setCheckable(True) - self.ViewLivePanel.setChecked(liveVisible) - self.ViewLivePanel.setObjectName(u'ViewLivePanel') + self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel', + liveVisible) mainWindow.actionList.add_action(self.ViewLivePanel, u'View') - self.ModeDefaultItem = QtGui.QAction(mainWindow) - self.ModeDefaultItem.setCheckable(True) - self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') + self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem') mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode') - self.ModeSetupItem = QtGui.QAction(mainWindow) - self.ModeSetupItem.setCheckable(True) - self.ModeSetupItem.setObjectName(u'ModeLiveItem') + self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem') mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode') - self.ModeLiveItem = QtGui.QAction(mainWindow) - self.ModeLiveItem.setCheckable(True) - self.ModeLiveItem.setObjectName(u'ModeLiveItem') + self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem') mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode') self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) - self.ToolsAddToolItem = QtGui.QAction(mainWindow) - self.ToolsAddToolItem.setIcon(build_icon(u':/tools/tools_add.png')) - self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') + self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', + u':/tools/tools_add.png') mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools') - self.SettingsPluginListItem = QtGui.QAction(mainWindow) - self.SettingsPluginListItem.setIcon( - build_icon(u':/system/settings_plugin_list.png')) - self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem') + self.SettingsPluginListItem = icon_action(mainWindow, + u'SettingsPluginListItem', u':/system/settings_plugin_list.png') mainWindow.actionList.add_action(self.SettingsPluginListItem, u'Settings') # i18n Language Items - self.AutoLanguageItem = QtGui.QAction(mainWindow) - self.AutoLanguageItem.setObjectName(u'AutoLanguageItem') - self.AutoLanguageItem.setCheckable(True) + self.AutoLanguageItem = checkable_action(mainWindow, + u'AutoLanguageItem') mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup.setExclusive(True) @@ -266,39 +231,28 @@ class Ui_MainWindow(object): qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() for key in sorted(qmList.keys()): - languageItem = QtGui.QAction(mainWindow) - languageItem.setObjectName(key) - languageItem.setCheckable(True) + languageItem = checkable_action(mainWindow, key) if qmList[key] == savedLanguage: languageItem.setChecked(True) add_actions(self.LanguageGroup, [languageItem]) - self.SettingsShortcutsItem = QtGui.QAction(mainWindow) - self.SettingsShortcutsItem.setIcon( - build_icon(u':/system/system_configure_shortcuts.png')) - self.SettingsShortcutsItem.setObjectName(u'SettingsShortcutsItem') - self.SettingsConfigureItem = QtGui.QAction(mainWindow) - self.SettingsConfigureItem.setIcon( - build_icon(u':/system/system_settings.png')) - self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem') + self.SettingsShortcutsItem = icon_action(mainWindow, + u'SettingsShortcutsItem', + u':/system/system_configure_shortcuts.png') + self.SettingsConfigureItem = icon_action(mainWindow, + u'SettingsConfigureItem', u':/system/system_settings.png') mainWindow.actionList.add_action(self.SettingsShortcutsItem, u'Settings') - self.HelpDocumentationItem = QtGui.QAction(mainWindow) - self.HelpDocumentationItem.setIcon( - build_icon(u':/system/system_help_contents.png')) - self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem') + self.HelpDocumentationItem = icon_action(mainWindow, + u'HelpDocumentationItem', u':/system/system_help_contents.png') self.HelpDocumentationItem.setEnabled(False) mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help') - self.HelpAboutItem = QtGui.QAction(mainWindow) - self.HelpAboutItem.setIcon( - build_icon(u':/system/system_about.png')) - self.HelpAboutItem.setObjectName(u'HelpAboutItem') + self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', + u':/system/system_about.png') mainWindow.actionList.add_action(self.HelpAboutItem, u'Help') - self.HelpOnlineHelpItem = QtGui.QAction(mainWindow) - self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') + self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem') self.HelpOnlineHelpItem.setEnabled(False) mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help') - self.HelpWebSiteItem = QtGui.QAction(mainWindow) - self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') + self.HelpWebSiteItem = base_action(mainWindow, u'HelpWebSiteItem') mainWindow.actionList.add_action(self.HelpWebSiteItem, u'Help') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) @@ -999,8 +953,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0] self.FileMenu.clear() add_actions(self.FileMenu, self.FileMenuActions[:-1]) - existingRecentFiles = [file for file in self.recentFiles - if QtCore.QFile.exists(file)] + existingRecentFiles = [recentFile for recentFile in self.recentFiles + if QtCore.QFile.exists(recentFile)] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] if recentFilesToDisplay: self.FileMenu.addSeparator() From 70e7b549d526497c3419fc3715555f7adbedbcc5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 02:56:59 +0000 Subject: [PATCH 090/104] UI library - shortcut_action --- openlp/core/lib/ui.py | 10 ++++++++++ openlp/core/ui/slidecontroller.py | 32 +++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 03590d5d9..f388e03b4 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -172,3 +172,13 @@ def icon_action(parent, name, icon, checked=None): action = base_action(parent, name) action.setIcon(build_icon(icon)) return action + +def shortcut_action(parent, text, shortcuts, function): + """ + Return a shortcut enabled action. + """ + action = QtGui.QAction(text, parent) + action.setShortcuts(shortcuts) + action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) + QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) + return action diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ab8a656ff..d0a0a6bf8 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -30,9 +30,10 @@ import os from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon -from openlp.core.ui import HideMode, MainDisplay from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate +from openlp.core.lib.ui import shortcut_action +from openlp.core.ui import HideMode, MainDisplay log = logging.getLogger(__name__) @@ -390,28 +391,17 @@ class SlideController(QtGui.QWidget): self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) actionList.add_action(self.nextItem, u'Live') - self.previousService = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Previous Service'), parent) - self.previousService.setShortcuts([QtCore.Qt.Key_Left, 0]) - self.previousService.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.previousService, - QtCore.SIGNAL(u'triggered()'), self.servicePrevious) + self.previousService = shortcut_action(parent, + translate('OpenLP.SlideController', 'Previous Service'), + [QtCore.Qt.Key_Left, 0], self.servicePrevious) actionList.add_action(self.previousService, u'Live') - self.nextService = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Next Service'), parent) - self.nextService.setShortcuts([QtCore.Qt.Key_Right, 0]) - self.nextService.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.nextService, - QtCore.SIGNAL(u'triggered()'), self.serviceNext) + self.nextService = shortcut_action(parent, + translate('OpenLP.SlideController', 'Next Service'), + [QtCore.Qt.Key_Right, 0], self.serviceNext) actionList.add_action(self.nextService, u'Live') - self.escapeItem = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Escape Item'), parent) - self.escapeItem.setShortcuts([QtCore.Qt.Key_Escape, 0]) - self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.escapeItem, - QtCore.SIGNAL(u'triggered()'), self.liveEscape) + self.escapeItem = shortcut_action(parent, + translate('OpenLP.SlideController', 'Escape Item'), + [QtCore.Qt.Key_Escape, 0], self.liveEscape) actionList.add_action(self.escapeItem, u'Live') def liveEscape(self): From 3831e5d1c957b1b1ee4dc254f5de5c6c53ec7b03 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 03:31:06 +0000 Subject: [PATCH 091/104] Slim down slidecontroller --- openlp/core/ui/slidecontroller.py | 63 +++++++++++-------------------- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d0a0a6bf8..bf0453e05 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -318,18 +318,8 @@ class SlideController(QtGui.QWidget): self.mediabar.setVisible(False) if self.isLive: self.setLiveHotkeys(self) - self.previewListWidget.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) - self.display.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) + self.__addActionsToWidget(self.previewListWidget) + self.__addActionsToWidget(self.display) else: self.setPreviewHotkeys() self.previewListWidget.addActions( @@ -425,12 +415,7 @@ class SlideController(QtGui.QWidget): self.display.alertTab = self.alertTab self.display.setup() if self.isLive: - self.display.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) + self.__addActionsToWidget(self.display) # The SlidePreview's ratio. self.ratio = float(self.screens.current[u'size'].width()) / \ float(self.screens.current[u'size'].height()) @@ -438,6 +423,12 @@ class SlideController(QtGui.QWidget): if self.serviceItem: self.refreshServiceItem() + def __addActionsToWidget(self, widget): + widget.addActions([ + self.previousItem, self.nextItem, + self.previousService, self.nextService, + self.escapeItem]) + def previewSizeChanged(self): """ Takes care of the SlidePreview's size. Is called when one of the the @@ -565,10 +556,7 @@ class SlideController(QtGui.QWidget): slideno = 0 # If service item is the same as the current on only change slide if item.__eq__(self.serviceItem): - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__checkUpdateSelectedSlide(slideno) self.onSlideSelected() return self._processItem(item, slideno) @@ -667,10 +655,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.selectRow( self.previewListWidget.rowCount() - 1) else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__checkUpdateSelectedSlide(slideno) def onTextRequest(self): """ @@ -719,10 +704,7 @@ class SlideController(QtGui.QWidget): [self.serviceItem, self.isLive, index]) self.updatePreview() else: - if index + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(index + 1, 0)) - self.previewListWidget.selectRow(index) + self.__checkUpdateSelectedSlide(index) self.onSlideSelected() def mainDisplaySetBackground(self): @@ -881,10 +863,7 @@ class SlideController(QtGui.QWidget): """ The slide has been changed. Update the slidecontroller accordingly """ - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.updatePreview() Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row) @@ -935,10 +914,7 @@ class SlideController(QtGui.QWidget): else: Receiver.send_message('servicemanager_next_item') return - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.onSlideSelected() def onSlideSelectedPreviousNoloop(self): @@ -961,12 +937,15 @@ class SlideController(QtGui.QWidget): row = self.previewListWidget.rowCount() - 1 else: row = 0 - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.onSlideSelected() + def __checkUpdateSelectedSlide(self, row): + if row + 1 < self.previewListWidget.rowCount(): + self.previewListWidget.scrollToItem( + self.previewListWidget.item(row + 1, 0)) + self.previewListWidget.selectRow(row) + def onSlideSelectedLast(self): """ Go to the last slide. From 90023bb8537266f21b8314b1bfef4691160ebe22 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:39:01 +0000 Subject: [PATCH 092/104] For updates --- openlp.pyw | 2 +- openlp/core/ui/exceptiondialog.py | 3 +++ openlp/core/ui/exceptionform.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 695d6e09f..15f2c8788 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -76,7 +76,7 @@ class OpenLP(QtGui.QApplication): """ Load and store current Application Version """ - if u'--dev-version' in sys.argv: + if u'--dev-version' in sys.argv or u'-d' in sys.argv: # If we're running the dev version, let's use bzr to get the version try: # If bzrlib is availble, use it diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 9e9b558df..2279e5272 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -63,17 +63,20 @@ class Ui_ExceptionDialog(object): self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.exceptionButtonBox.setObjectName(u'exceptionButtonBox') self.exceptionLayout.addWidget(self.exceptionButtonBox) + self.sendReportButton = QtGui.QPushButton(exceptionDialog) self.sendReportButton.setIcon(build_icon( u':/general/general_email.png')) self.sendReportButton.setObjectName(u'sendReportButton') self.exceptionButtonBox.addButton(self.sendReportButton, QtGui.QDialogButtonBox.ActionRole) + self.saveReportButton = QtGui.QPushButton(exceptionDialog) self.saveReportButton.setIcon(build_icon(u':/general/general_save.png')) self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) + self.attachFileButton = QtGui.QPushButton(exceptionDialog) self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) self.attachFileButton.setObjectName(u'attachFileButton') diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index a92967b6c..0a2d7acee 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -169,7 +169,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', - 'Characters to Enter : %s')) % count ) + 'Description characters to Enter : %s')) % count ) def onAttachFileButtonPressed(self): files = QtGui.QFileDialog.getOpenFileName( From 7369a0391c5282622945448d026cfa771f27a795 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:41:02 +0000 Subject: [PATCH 093/104] Fix setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a435c5496..205688f1e 100755 --- a/setup.py +++ b/setup.py @@ -69,8 +69,7 @@ OpenLP (previously openlp.org) is free church presentation software, or lyrics p url='http://openlp.org/', license='GNU General Public License', packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - scripts=['openlp.pyw', 'scripts/openlp-1to2-converter.py', - 'scripts/bible-1to2-converter.py','scripts/openlp-remoteclient.py'], + scripts=['openlp.pyw', 'scripts/openlp-remoteclient.py'], include_package_data=True, zip_safe=False, install_requires=[ From 396037c0a3cbe583b38227f2f1ee13152fcf0343 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:49:30 +0000 Subject: [PATCH 094/104] Clean up time --- openlp.pyw | 1 - openlp/core/ui/exceptiondialog.py | 5 +---- openlp/core/ui/exceptionform.py | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 15f2c8788..100c3336f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -196,7 +196,6 @@ class OpenLP(QtGui.QApplication): self.mainWindow.repaint() update_check = QtCore.QSettings().value( u'general/update check', QtCore.QVariant(True)).toBool() - a=c if update_check: VersionThread(self.mainWindow, app_version).start() return self.exec_() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 2279e5272..ba7bab496 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -63,20 +63,17 @@ class Ui_ExceptionDialog(object): self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.exceptionButtonBox.setObjectName(u'exceptionButtonBox') self.exceptionLayout.addWidget(self.exceptionButtonBox) - self.sendReportButton = QtGui.QPushButton(exceptionDialog) self.sendReportButton.setIcon(build_icon( u':/general/general_email.png')) self.sendReportButton.setObjectName(u'sendReportButton') self.exceptionButtonBox.addButton(self.sendReportButton, QtGui.QDialogButtonBox.ActionRole) - self.saveReportButton = QtGui.QPushButton(exceptionDialog) self.saveReportButton.setIcon(build_icon(u':/general/general_save.png')) self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) - self.attachFileButton = QtGui.QPushButton(exceptionDialog) self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) self.attachFileButton.setObjectName(u'attachFileButton') @@ -101,7 +98,7 @@ class Ui_ExceptionDialog(object): translate('OpenLP.ExceptionDialog', 'Error Occurred')) self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this ' - 'error')) + 'error \n(Minimum 20 characters)')) self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' 'below contains information that might be helpful to the OpenLP ' diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 0a2d7acee..ef3c84f18 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -169,7 +169,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', - 'Description characters to Enter : %s')) % count ) + 'Description characters to enter : %s')) % count ) def onAttachFileButtonPressed(self): files = QtGui.QFileDialog.getOpenFileName( From 6577f6c25e0803e611545d53d957b868e7b24fea Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 17:15:48 +0000 Subject: [PATCH 095/104] Fixes --- openlp/core/ui/exceptionform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ef3c84f18..7f9e23c61 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -71,6 +71,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.settingsSection = u'crashreport' def exec_(self): + self.descriptionTextEdit.setPlainText(u'') self.onDescriptionUpdated() self.fileAttachment = None return QtGui.QDialog.exec_(self) @@ -136,7 +137,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): Opening systems default email client and inserting exception log and system informations. """ - attach = None body = unicode(translate('OpenLP.ExceptionForm', '*OpenLP Bug Report*\n' 'Version: %s\n\n' From c3ac82a934ff1c09230f9cbaf4998d4a25b9571c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 18:17:28 +0000 Subject: [PATCH 096/104] UI library - add_widget_completer --- openlp/core/lib/ui.py | 8 ++++ openlp/plugins/bibles/lib/mediaitem.py | 7 ++-- openlp/plugins/songs/forms/editsongform.py | 45 ++++++++-------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index f388e03b4..983d278b0 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -182,3 +182,11 @@ def shortcut_action(parent, text, shortcuts, function): action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action + +def add_widget_completer(cache, widget): + """ + Add a text autocompleter to a widget. + """ + completer = QtGui.QCompleter(cache) + completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) + widget.setCompleter(completer) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 26f45b6b3..c162447b2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -30,7 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate -from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box +from openlp.core.lib.ui import add_widget_completer, media_item_combo_box, \ + critical_error_message_box from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import get_reference_match @@ -379,9 +380,7 @@ class BibleMediaItem(MediaManagerItem): book_data = bibles[bible].get_books() books = [book.name for book in book_data] books.sort() - completer = QtGui.QCompleter(books) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.quickSearchEdit.setCompleter(completer) + add_widget_completer(books, self.quickSearchEdit) def onAdvancedVersionComboBox(self): self.initialiseBible( diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index bf94503ff..57ad13f38 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import add_widget_completer, critical_error_message_box from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib import SongXML, VerseType from openlp.plugins.songs.lib.db import Book, Song, Author, Topic @@ -129,37 +129,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.authorsComboBox.setItemData( row, QtCore.QVariant(author.id)) self.authors.append(author.display_name) - completer = QtGui.QCompleter(self.authors) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.authorsComboBox.setCompleter(completer) + add_widget_completer(self.authors, self.authorsComboBox) def loadTopics(self): - topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) - self.topicsComboBox.clear() - self.topicsComboBox.addItem(u'') self.topics = [] - for topic in topics: - row = self.topicsComboBox.count() - self.topicsComboBox.addItem(topic.name) - self.topics.append(topic.name) - self.topicsComboBox.setItemData(row, QtCore.QVariant(topic.id)) - completer = QtGui.QCompleter(self.topics) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.topicsComboBox.setCompleter(completer) + self.__loadObjects(Topic, self.topicsComboBox, self.topics) def loadBooks(self): - books = self.manager.get_all_objects(Book, order_by_ref=Book.name) - self.songBookComboBox.clear() - self.songBookComboBox.addItem(u'') self.books = [] - for book in books: - row = self.songBookComboBox.count() - self.songBookComboBox.addItem(book.name) - self.books.append(book.name) - self.songBookComboBox.setItemData(row, QtCore.QVariant(book.id)) - completer = QtGui.QCompleter(self.books) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.songBookComboBox.setCompleter(completer) + self.__loadObjects(Book, self.songBookComboBox, self.books) + + def __loadObjects(self, class, combo, cache): + objects = self.manager.get_all_objects(class, order_by_ref=class.name) + combo.clear() + combo.addItem(u'') + for object in objects: + row = combo.count() + combo.addItem(object.name) + cache.append(object.name) + combo.setItemData(row, QtCore.QVariant(object.id)) + add_widget_completer(cache, combo) def loadThemes(self, theme_list): self.themeComboBox.clear() @@ -168,9 +157,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for theme in theme_list: self.themeComboBox.addItem(theme) self.themes.append(theme) - completer = QtGui.QCompleter(self.themes) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.themeComboBox.setCompleter(completer) + add_widget_completer(self.themes, self.themeComboBox) def newSong(self): log.debug(u'New Song') From 20e05efd394caae670f49e5d6f4c4185d043da21 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 18:42:37 +0000 Subject: [PATCH 097/104] Fix inherited method name --- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index ec915b0a9..908c4e18d 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -69,7 +69,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) def initialise(self): - self.loadCustomListView(self.manager.get_all_objects( + self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) # Called to redisplay the custom list screen edith from a search # or from the exit of the Custom edit dialog. If remote editing is @@ -80,7 +80,7 @@ class CustomMediaItem(MediaManagerItem): self.onPreviewClick() self.onRemoteEditClear() - def loadCustomListView(self, list): + def loadList(self, list): self.listView.clear() for customSlide in list: custom_name = QtGui.QListWidgetItem(customSlide.title) From ead4f958356d9b5d3fe080bcc38e483a3074c0c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 19:51:20 +0100 Subject: [PATCH 098/104] --- .../plugins/custom/forms/editcustomdialog.py | 9 ++ openlp/plugins/custom/forms/editcustomform.py | 136 +++++++++--------- 2 files changed, 81 insertions(+), 64 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 75717c082..542f41410 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -59,20 +59,24 @@ class Ui_CustomEditDialog(object): 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 = QtGui.QPushButton(customEditDialog) + self.deleteButton.setEnabled(False) self.deleteButton.setObjectName(u'deleteButton') self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(customEditDialog) + self.upButton.setEnabled(False) self.upButton.setIcon(build_icon(u':/services/service_up.png')) self.upButton.setObjectName(u'upButton') self.buttonLayout.addWidget(self.upButton) self.downButton = QtGui.QPushButton(customEditDialog) + self.downButton.setEnabled(False) self.downButton.setIcon(build_icon(u':/services/service_down.png')) self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) @@ -95,6 +99,9 @@ class Ui_CustomEditDialog(object): self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) self.buttonBox = save_cancel_button_box(customEditDialog) + self.previewButton = QtGui.QPushButton() + self.buttonBox.addButton( + self.previewButton, QtGui.QDialogButtonBox.ActionRole) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog) @@ -134,3 +141,5 @@ class Ui_CustomEditDialog(object): translate('CustomPlugin.EditCustomForm', 'The&me:')) self.creditLabel.setText( translate('CustomPlugin.EditCustomForm', '&Credits:')) + self.previewButton.setText( + translate('CustomPlugin.EditCustomForm', 'Save && Preview')) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e8dfa20aa..c5a31c5ad 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -48,14 +48,12 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + # Create other objects and forms. + self.manager = manager + self.editSlideForm = EditCustomSlideForm(self) # Connecting signals and slots - self.previewButton = QtGui.QPushButton() - self.previewButton.setText( - translate('CustomPlugin.EditCustomForm', 'Save && Preview')) - self.buttonBox.addButton( - self.previewButton, QtGui.QDialogButtonBox.ActionRole) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview) + QtCore.QObject.connect(self.previewButton, + QtCore.SIGNAL(u'pressed()'), self.onPreviewButtonPressed) QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed) QtCore.QObject.connect(self.editButton, @@ -68,32 +66,10 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) - QtCore.QObject.connect(self.slideListView, - QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), - self.onSlideListViewPressed) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) - # Create other objects and forms. - self.manager = manager - self.editSlideForm = EditCustomSlideForm(self) - self.initialise() - - def onPreview(self, button): - log.debug(u'onPreview') - if button.text() == unicode(translate('CustomPlugin.EditCustomForm', - 'Save && Preview')) and self.saveCustom(): - Receiver.send_message(u'custom_preview') - - def initialise(self): - self.addButton.setEnabled(True) - self.deleteButton.setEnabled(False) - self.editButton.setEnabled(False) - self.editAllButton.setEnabled(True) - self.titleEdit.setText(u'') - self.creditEdit.setText(u'') - self.slideListView.clear() - # Make sure we have a new item. - self.customSlide = CustomSlide() + QtCore.QObject.connect(self.slideListView, + QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def loadThemes(self, themelist): self.themeComboBox.clear() @@ -112,9 +88,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): States whether the custom is edited while being previewed in the preview panel. """ - self.customSlide = CustomSlide() - self.initialise() - if id != 0: + self.slideListView.clear() + if id == 0: + self.customSlide = CustomSlide() + self.titleEdit.setText(u'') + self.creditEdit.setText(u'') + self.themeComboBox.setCurrentIndex(0) + else: self.customSlide = self.manager.get_object(CustomSlide, id) self.titleEdit.setText(self.customSlide.title) self.creditEdit.setText(self.customSlide.credits) @@ -128,9 +108,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if id == -1: id = 0 self.themeComboBox.setCurrentIndex(id) - else: - self.themeComboBox.setCurrentIndex(0) - self.editAllButton.setEnabled(False) # If not preview hide the preview button. self.previewButton.setVisible(False) if preview: @@ -150,9 +127,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Saves the custom. """ - valid, message = self._validate() - if not valid: - critical_error_message_box(message=message) + if not self._validate(): return False sxml = CustomXMLBuilder() sxml.new_document() @@ -183,16 +158,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.insertItem(selectedRow + 1, qw) self.slideListView.setCurrentRow(selectedRow + 1) - def onSlideListViewPressed(self, item): - self.deleteButton.setEnabled(True) - self.editButton.setEnabled(True) - def onAddButtonPressed(self): self.editSlideForm.setText(u'') if self.editSlideForm.exec_(): for slide in self.editSlideForm.getText(): self.slideListView.addItem(slide) - self.editAllButton.setEnabled(True) def onEditButtonPressed(self): self.editSlideForm.setText(self.slideListView.currentItem().text()) @@ -203,16 +173,23 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Edits all slides. """ - if self.slideListView.count() > 0: - slide_list = u'' - for row in range(0, self.slideListView.count()): - item = self.slideListView.item(row) - slide_list += item.text() - if row != self.slideListView.count() - 1: - slide_list += u'\n[---]\n' - self.editSlideForm.setText(slide_list) - if self.editSlideForm.exec_(): - self.updateSlideList(self.editSlideForm.getText(), True) + slide_list = u'' + for row in range(0, self.slideListView.count()): + item = self.slideListView.item(row) + slide_list += item.text() + if row != self.slideListView.count() - 1: + slide_list += u'\n[---]\n' + self.editSlideForm.setText(slide_list) + if self.editSlideForm.exec_(): + self.updateSlideList(self.editSlideForm.getText(), True) + + def onPreviewButtonPressed(self): + """ + Save the custom item and preview it. + """ + log.debug(u'onPreview') + if self.saveCustom(): + Receiver.send_message(u'custom_preview') def updateSlideList(self, slides, edit_all=False): """ @@ -244,13 +221,40 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.repaint() def onDeleteButtonPressed(self): + """ + Removes the current row from the list. + """ self.slideListView.takeItem(self.slideListView.currentRow()) - self.editButton.setEnabled(True) - self.editAllButton.setEnabled(True) - if self.slideListView.count() == 0: + if self.slideListView.currentRow() == 0: + self.upButton.setEnabled(False) + if self.slideListView.currentRow() == self.slideListView.count(): + self.downButton.setEnabled(False) + + def onCurrentRowChanged(self, row): + """ + Called when the *slideListView*'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.editAllButton.setEnabled(False) + self.upButton.setEnabled(False) + self.downButton.setEnabled(False) + else: + self.deleteButton.setEnabled(True) + self.editButton.setEnabled(True) + # Decide if the up/down buttons should be enabled or not. + if self.slideListView.count() - 1 == row: + self.downButton.setEnabled(False) + else: + self.downButton.setEnabled(True) + if row == 0: + self.upButton.setEnabled(False) + else: + self.upButton.setEnabled(True) def _validate(self): """ @@ -259,10 +263,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): # We must have a title. if len(self.titleEdit.displayText()) == 0: self.titleEdit.setFocus() - return False, translate('CustomPlugin.EditCustomForm', - 'You need to type in a title.') + 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: - return False, translate('CustomPlugin.EditCustomForm', - 'You need to add at least one slide') - return True, u'' + critical_error_message_box( + message=translate('CustomPlugin.EditCustomForm', + 'You need to add at least one slide')) + return False + return True From dae7dff242f73e497868483380d5ccf7a912aeb4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 19:58:44 +0000 Subject: [PATCH 099/104] Fix last commit Speed up OpenSong bible importer --- openlp/plugins/bibles/lib/opensong.py | 8 +++----- openlp/plugins/songs/forms/editsongform.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 12a6562bc..9a0fd110d 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -38,7 +38,6 @@ class OpenSongBible(BibleDB): """ OpenSong Bible format importer class. """ - def __init__(self, parent, **kwargs): """ Constructor to create and set up an instance of the OpenSongBible @@ -81,14 +80,13 @@ class OpenSongBible(BibleDB): db_book.id, int(chapter.attrib[u'n'].split()[-1]), int(verse.attrib[u'n']), - unicode(verse.text) - ) - Receiver.send_message(u'openlp_process_events') + unicode(verse.text)) self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.Opensong', 'Importing %s %s...', 'Importing ...')) % (db_book.name, int(chapter.attrib[u'n'].split()[-1]))) - self.session.commit() + self.session.commit() + Receiver.send_message(u'openlp_process_events') except (IOError, AttributeError): log.exception(u'Loading bible from OpenSong file failed') success = False diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 57ad13f38..8536d38b8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -139,8 +139,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.books = [] self.__loadObjects(Book, self.songBookComboBox, self.books) - def __loadObjects(self, class, combo, cache): - objects = self.manager.get_all_objects(class, order_by_ref=class.name) + def __loadObjects(self, cls, combo, cache): + objects = self.manager.get_all_objects(cls, order_by_ref=cls.name) combo.clear() combo.addItem(u'') for object in objects: From a32cf1df433682625344f0f41e28421559d4e18d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 21:35:57 +0000 Subject: [PATCH 100/104] Catch failure to start process (Bug #712140) --- openlp/plugins/presentations/presentationplugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 8afed6022..17417df58 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -74,7 +74,11 @@ class PresentationPlugin(Plugin): self.insertToolboxItem() for controller in self.controllers: if self.controllers[controller].enabled(): - self.controllers[controller].start_process() + try: + self.controllers[controller].start_process() + except: + log.exception(u'Failed to start controller process') + self.controllers[controller].available = False self.mediaItem.buildFileMaskString() def finalise(self): From baf18ea1c7efca013c4df8dcd384496f54e17ae5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 01:24:19 +0000 Subject: [PATCH 101/104] Start deobfuscating UI library --- openlp/core/lib/ui.py | 43 ++++++++++++++++--- openlp/core/ui/serviceitemeditdialog.py | 10 ++--- openlp/core/ui/servicenoteform.py | 4 +- openlp/plugins/alerts/forms/alertdialog.py | 4 +- .../plugins/custom/forms/editcustomdialog.py | 10 ++--- .../custom/forms/editcustomslidedialog.py | 4 +- openlp/plugins/songs/forms/authorsdialog.py | 5 ++- openlp/plugins/songs/forms/editsongdialog.py | 4 +- openlp/plugins/songs/forms/editversedialog.py | 5 ++- openlp/plugins/songs/forms/songbookdialog.py | 5 ++- openlp/plugins/songs/forms/topicsdialog.py | 5 ++- 11 files changed, 66 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 983d278b0..4a346b3e1 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -38,6 +38,9 @@ def add_welcome_page(parent, image): """ Generate an opening welcome page for a wizard using a provided image. + ``parent`` + A ``QWizard`` object to add the welcome page to. + ``image`` A splash image for the wizard. """ @@ -58,9 +61,14 @@ def add_welcome_page(parent, image): parent.welcomeLayout.addStretch() parent.addPage(parent.welcomePage) -def save_cancel_button_box(parent): +def create_save_cancel_button_box(parent): """ - Return a standard dialog button box with save and cancel buttons. + Creates a standard dialog button box with save and cancel buttons. The + button box is connected to the parent's ``accept()`` and ``reject()`` + methods to handle the default ``accepted()`` and ``rejected()`` signals. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. """ button_box = QtGui.QDialogButtonBox(parent) button_box.setStandardButtons( @@ -109,9 +117,18 @@ def media_item_combo_box(parent, name): combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) return combo -def delete_push_button(parent, icon=None): +def create_delete_push_button(parent, icon=None): """ - Return a standard push button with delete label. + Creates a standard push button with a delete label and optional icon. The + button is connected to the parent's ``onDeleteButtonClicked()`` method to + handle the ``clicked()`` signal. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. + + ``icon`` + An icon to display on the button. This can be either a ``QIcon``, a + resource path or a file name. """ delete_button = QtGui.QPushButton(parent) delete_button.setObjectName(u'deleteButton') @@ -124,9 +141,15 @@ def delete_push_button(parent, icon=None): QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) return delete_button -def up_down_push_button_set(parent): +def create_up_down_push_button_set(parent): """ - Return a standard set of two push buttons for up and down use with lists. + Creates a standard set of two push buttons, one for up and the other for + down, for use with lists. The buttons use arrow icons and no text and are + connected to the parent's ``onUpButtonClicked()`` and + ``onDownButtonClicked()`` to handle their respective ``clicked()`` signals. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. """ up_button = QtGui.QPushButton(parent) up_button.setIcon(build_icon(u':/services/service_up.png')) @@ -185,7 +208,13 @@ def shortcut_action(parent, text, shortcuts, function): def add_widget_completer(cache, widget): """ - Add a text autocompleter to a widget. + Adds a text autocompleter to a widget. + + ``cache`` + The list of items to use as suggestions. + + ``widget`` + The object to use the completer. """ completer = QtGui.QCompleter(cache) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 4046e94ab..f22f3dcf5 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,8 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ - up_down_push_button_set +from openlp.core.lib.ui import create_save_cancel_button_box, \ + create_delete_push_button, create_up_down_push_button_set class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -41,16 +41,16 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = delete_push_button(serviceItemEditDialog) + self.deleteButton = create_delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton, self.downButton = up_down_push_button_set( + self.upButton, self.downButton = create_up_down_push_button_set( serviceItemEditDialog) self.buttonLayout.addWidget(self.upButton) self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( - save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) + create_save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index e659e50db..473cc1685 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class ServiceNoteForm(QtGui.QDialog): """ @@ -48,7 +48,7 @@ class ServiceNoteForm(QtGui.QDialog): self.textEdit = QtGui.QTextEdit(self) self.textEdit.setObjectName(u'textEdit') self.dialogLayout.addWidget(self.textEdit) - self.dialogLayout.addWidget(save_cancel_button_box(self)) + self.dialogLayout.addWidget(create_save_cancel_button_box(self)) QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self): diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 1a8a1fc58..93f7ead06 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import delete_push_button +from openlp.core.lib.ui import create_delete_push_button class Ui_AlertDialog(object): def setupUi(self, alertDialog): @@ -66,7 +66,7 @@ class Ui_AlertDialog(object): self.saveButton.setIcon(build_icon(u':/general/general_save.png')) self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) - self.deleteButton = delete_push_button(alertDialog) + self.deleteButton = create_delete_push_button(alertDialog) self.deleteButton.setEnabled(False) self.manageButtonLayout.addWidget(self.deleteButton) self.manageButtonLayout.addStretch() diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index a3b09310c..b7887aa90 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,8 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ - up_down_push_button_set +from openlp.core.lib.ui import create_save_cancel_button_box, \ + create_delete_push_button, create_up_down_push_button_set class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -66,11 +66,11 @@ class Ui_CustomEditDialog(object): self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = delete_push_button(customEditDialog) + self.deleteButton = create_delete_push_button(customEditDialog) self.deleteButton.setEnabled(False) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton, self.downButton = up_down_push_button_set( + self.upButton, self.downButton = create_up_down_push_button_set( customEditDialog) self.upButton.setEnabled(False) self.downButton.setEnabled(False) @@ -94,7 +94,7 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = save_cancel_button_box(customEditDialog) + self.buttonBox = create_save_cancel_button_box(customEditDialog) self.previewButton = QtGui.QPushButton() self.buttonBox.addButton( self.previewButton, QtGui.QDialogButtonBox.ActionRole) diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 93bff68b8..24c40d6e6 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, SpellTextEdit -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -37,7 +37,7 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = save_cancel_button_box(customSlideEditDialog) + self.buttonBox = create_save_cancel_button_box(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 3fd3c5fef..0b3f791d1 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -56,7 +56,8 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(authorsDialog) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index c44b42d46..e9be62830 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -241,7 +241,7 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = save_cancel_button_box(editSongDialog) + self.buttonBox = create_save_cancel_button_box(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) QtCore.QMetaObject.connectSlotsByName(editSongDialog) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index deaf952e2..b4bc4551f 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate, SpellTextEdit -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): @@ -60,7 +60,8 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(editVerseDialog)) self.retranslateUi(editVerseDialog) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index fcd6bd364..89b8941b5 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -50,7 +50,8 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(songBookDialog) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index f2c9fdeba..596597034 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -44,7 +44,8 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(topicsDialog) From c7d31937624af26face82f3aac69b41b5852e5ff Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 07:54:23 +0000 Subject: [PATCH 102/104] Lets not delete the image before we copy it. Doh Fixes: https://launchpad.net/bugs/712097 --- openlp/core/ui/thememanager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f403d7441..2bb30c5d1 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -268,8 +268,8 @@ class ThemeManager(QtGui.QWidget): newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) if self.checkIfThemeExists(newThemeName): oldThemeData = self.getThemeData(oldThemeName) - self.deleteTheme(oldThemeName) self.cloneThemeData(oldThemeData, newThemeName) + self.deleteTheme(oldThemeName) for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(oldThemeName): plugin.renameTheme(oldThemeName, newThemeName) @@ -295,11 +295,13 @@ class ThemeManager(QtGui.QWidget): log.debug(u'cloneThemeData') saveTo = None saveFrom = None + print themeData.background_type if themeData.background_type == u'image': saveTo = os.path.join(self.path, newThemeName, os.path.split(unicode(themeData.background_filename))[1]) saveFrom = themeData.background_filename themeData.theme_name = newThemeName + themeData.extend_image_filename(self.path) self.saveTheme(themeData, saveFrom, saveTo) def onEditTheme(self): @@ -349,7 +351,7 @@ class ThemeManager(QtGui.QWidget): shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) except OSError: log.exception(u'Error deleting theme %s', theme) - # As we do not reload the themes push out the change + # As we do not reload the themes, push out the change # Reaload the list as the internal lists and events need # to be triggered self.pushThemes() @@ -577,6 +579,7 @@ class ThemeManager(QtGui.QWidget): theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') + print imageTo, self.oldBackgroundImage if imageTo and self.oldBackgroundImage and \ imageTo != self.oldBackgroundImage: delete_file(self.oldBackgroundImage) @@ -589,6 +592,7 @@ class ThemeManager(QtGui.QWidget): finally: if outfile: outfile.close() + print imageFrom, imageTo if imageFrom and imageFrom != imageTo: try: encoding = get_filesystem_encoding() @@ -603,7 +607,7 @@ class ThemeManager(QtGui.QWidget): def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) - theme_xml = theme.extract_xml() + #theme_xml = theme.extract_xml() frame = self.generateImage(theme) samplepathname = os.path.join(self.path, name + u'.png') if os.path.exists(samplepathname): From fecad94099eaa832abe1a24cd4fc63177d37d726 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 09:30:59 +0000 Subject: [PATCH 103/104] Fix up theme handing with rename and copy --- openlp/core/ui/thememanager.py | 28 ++++++++++++++++------------ openlp/plugins/bibles/bibleplugin.py | 3 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 2bb30c5d1..e71eae486 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -241,7 +241,7 @@ class ThemeManager(QtGui.QWidget): QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) - self.pushThemes() + self._pushThemes() def onAddTheme(self): """ @@ -273,6 +273,7 @@ class ThemeManager(QtGui.QWidget): for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(oldThemeName): plugin.renameTheme(oldThemeName, newThemeName) + self.loadThemes() def onCopyTheme(self): """ @@ -295,7 +296,6 @@ class ThemeManager(QtGui.QWidget): log.debug(u'cloneThemeData') saveTo = None saveFrom = None - print themeData.background_type if themeData.background_type == u'image': saveTo = os.path.join(self.path, newThemeName, os.path.split(unicode(themeData.background_filename))[1]) @@ -334,6 +334,10 @@ class ThemeManager(QtGui.QWidget): row = self.themeListWidget.row(item) self.themeListWidget.takeItem(row) self.deleteTheme(theme) + # As we do not reload the themes, push out the change + # Reaload the list as the internal lists and events need + # to be triggered + self._pushThemes() def deleteTheme(self, theme): """ @@ -351,10 +355,6 @@ class ThemeManager(QtGui.QWidget): shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) except OSError: log.exception(u'Error deleting theme %s', theme) - # As we do not reload the themes, push out the change - # Reaload the list as the internal lists and events need - # to be triggered - self.pushThemes() def onExportTheme(self): """ @@ -451,9 +451,9 @@ class ThemeManager(QtGui.QWidget): QtCore.QVariant(textName)) self.themeListWidget.addItem(item_name) self.themelist.append(textName) - self.pushThemes() + self._pushThemes() - def pushThemes(self): + def _pushThemes(self): """ Notify listeners that the theme list has been updated """ @@ -573,13 +573,20 @@ class ThemeManager(QtGui.QWidget): Called by thememaintenance Dialog to save the theme and to trigger the reload of the theme list """ + self._writeTheme(theme, imageFrom, imageTo) + self.loadThemes() + + def _writeTheme(self, theme, imageFrom, imageTo): + """ + Writes the theme to the disk and handles the background image if + necessary + """ name = theme.theme_name theme_pretty_xml = theme.extract_formatted_xml() log.debug(u'saveTheme %s %s', name, theme_pretty_xml) theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') - print imageTo, self.oldBackgroundImage if imageTo and self.oldBackgroundImage and \ imageTo != self.oldBackgroundImage: delete_file(self.oldBackgroundImage) @@ -592,7 +599,6 @@ class ThemeManager(QtGui.QWidget): finally: if outfile: outfile.close() - print imageFrom, imageTo if imageFrom and imageFrom != imageTo: try: encoding = get_filesystem_encoding() @@ -602,8 +608,6 @@ class ThemeManager(QtGui.QWidget): except IOError: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) - self.loadThemes() - self.pushThemes() def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 15181e871..e3b2ad4aa 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -102,7 +102,7 @@ class BiblePlugin(Plugin): Called to find out if the bible plugin is currently using a theme. Returns True if the theme is being used, otherwise returns False. """ - if self.settings_tab.bible_theme == theme: + if unicode(self.settings_tab.bible_theme) == theme: return True return False @@ -119,6 +119,7 @@ class BiblePlugin(Plugin): The new name the plugin should now use. """ self.settings_tab.bible_theme = newTheme + self.settings_tab.save() def setPluginTextStrings(self): """ From 5c3c7e0c7008df2ce11151ffcb9858ed65df095c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 09:40:04 +0000 Subject: [PATCH 104/104] Remove line --- openlp/core/ui/thememanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e71eae486..7a4dda882 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -611,7 +611,6 @@ class ThemeManager(QtGui.QWidget): def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) - #theme_xml = theme.extract_xml() frame = self.generateImage(theme) samplepathname = os.path.join(self.path, name + u'.png') if os.path.exists(samplepathname):