From b52ead934d0ba612c748836d105fc0155ce7822a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Jan 2011 11:44:16 +0000 Subject: [PATCH 1/3] Add Cursor management --- openlp.pyw | 21 ++++++++++++++++++- openlp/core/ui/mainwindow.py | 2 ++ openlp/core/ui/servicemanager.py | 4 +++- openlp/plugins/images/lib/mediaitem.py | 6 ++---- openlp/plugins/presentations/lib/mediaitem.py | 2 ++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 8cc7a16a6..888cdae9f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -162,6 +162,10 @@ class OpenLP(QtGui.QApplication): #provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor) self.setOrganizationName(u'OpenLP') self.setOrganizationDomain(u'openlp.org') self.setApplicationName(u'OpenLP') @@ -203,6 +207,21 @@ class OpenLP(QtGui.QApplication): ''.join(format_exception(exctype, value, traceback))) self.exceptionForm.exec_() + def setBusyCursor(self): + """ + Sets the Busy Cursor on the Main Window + """ + #a=c + self.setOverrideCursor(QtCore.Qt.BusyCursor) + #self.processEvents() + + def setNormalCursor(self): + """ + Sets the Normal Cursor on the Main Window + """ + self.restoreOverrideCursor() + #self.processEvents() + def main(): """ The main function which parses command line options and then runs @@ -264,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/mainwindow.py b/openlp/core/ui/mainwindow.py index a378dd633..88b4305a2 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -612,6 +612,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage) + Receiver.send_message(u'cursor_busy') # warning cyclic dependency # RenderManager needs to call ThemeManager and # ThemeManager needs to call RenderManager @@ -659,6 +660,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if savedPlugin != -1: self.MediaToolBox.setCurrentIndex(savedPlugin) self.settingsForm.postSetUp() + Receiver.send_message(u'cursor_normal') def setAutoLanguage(self, value): self.LanguageGroup.setDisabled(value) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e2c1a765b..0e104a0eb 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -571,6 +571,7 @@ class ServiceManager(QtGui.QWidget): Used when moving items as the move takes place in supporting array, and when regenerating all the items due to theme changes """ + Receiver.send_message(u'cursor_busy') # Correct order of items in array count = 1 for item in self.serviceItems: @@ -614,6 +615,7 @@ class ServiceManager(QtGui.QWidget): self.serviceManagerList.setCurrentItem(treewidgetitem1) item[u'expanded'] = temp treewidgetitem.setExpanded(item[u'expanded']) + Receiver.send_message(u'cursor_normal') def onSaveService(self, quick=False): """ @@ -1119,4 +1121,4 @@ class ServiceManager(QtGui.QWidget): data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) data.append(data_item) - Receiver.send_message(u'servicemanager_list_response', data) \ No newline at end of file + Receiver.send_message(u'servicemanager_list_response', data) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 170ac3b74..1c48e3eb6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -139,8 +139,7 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection, self.getFileList()) def loadList(self, list): - self.listView.setCursor(QtCore.Qt.BusyCursor) - Receiver.send_message(u'openlp_process_events') + Receiver.send_message(u'cursor_busy') for file in list: filename = os.path.split(unicode(file))[1] thumb = os.path.join(self.servicePath, filename) @@ -155,8 +154,7 @@ class ImageMediaItem(MediaManagerItem): item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) self.listView.addItem(item_name) - self.listView.setCursor(QtCore.Qt.ArrowCursor) - Receiver.send_message(u'openlp_process_events') + Receiver.send_message(u'cursor_normal') def generateSlideData(self, service_item, item=None, xmlVersion=False): items = self.listView.selectedIndexes() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e832f1a10..9b8c2c1a9 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -171,6 +171,7 @@ class PresentationMediaItem(MediaManagerItem): This is called both on initial load of the plugin to populate with existing files, and when the user adds new files via the media manager """ + Receiver.send_message(u'cursor_busy') currlist = self.getFileList() titles = [] for file in currlist: @@ -215,6 +216,7 @@ class PresentationMediaItem(MediaManagerItem): item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setIcon(icon) self.listView.addItem(item_name) + Receiver.send_message(u'cursor_normal') def onDeleteClick(self): """ From fd92d47057850a73cd16c32c23927e50cf851ccf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Jan 2011 12:20:42 +0000 Subject: [PATCH 2/3] More changes to cursors --- openlp/core/lib/eventreceiver.py | 17 ++++++++++++++++- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/servicemanager.py | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 4f69c519f..d3cbf41f7 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -220,6 +220,21 @@ class EventReceiver(QtCore.QObject): Waits for openlp to do something "interesting" and sends a remotes_poll_response signal when it does + ``openlp_critical_message`` + Displays a standalong Critical Message + + ``openlp_error_message`` + Displays a standalong Error Message + + ``openlp_information_message`` + Displays a standalong Information Message + + ``cursor_busy`` + Makes the cursor got to a busy form + + ``cursor_normal`` + Resets the cursor to default + """ def __init__(self): """ @@ -278,4 +293,4 @@ class Receiver(object): """ Get the global ``eventreceiver`` instance. """ - return Receiver.eventreceiver \ No newline at end of file + return Receiver.eventreceiver diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d44b43574..1a32d0df3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1013,7 +1013,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QFileInfo(filename).fileName()), self) action.setData(QtCore.QVariant(filename)) self.connect(action, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.loadService) + self.ServiceManagerContents.loadFile) self.FileMenu.addAction(action) self.FileMenu.addSeparator() self.FileMenu.addAction(self.FileMenuActions[-1]) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 076e50c11..2397df1b3 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -787,7 +787,6 @@ class ServiceManager(QtGui.QWidget): ``serviceItemCount`` The number of items in the service. """ - Receiver.send_message(u'cursor_busy') # Correct order of items in array count = 1 for item in self.serviceItems: @@ -831,7 +830,6 @@ class ServiceManager(QtGui.QWidget): self.serviceManagerList.setCurrentItem(treewidgetitem1) item[u'expanded'] = temp treewidgetitem.setExpanded(item[u'expanded']) - Receiver.send_message(u'cursor_normal') def validateItem(self, serviceItem): """ @@ -885,6 +883,7 @@ class ServiceManager(QtGui.QWidget): Rebuild the service list as things have changed and a repaint is the easiest way to do this. """ + Receiver.send_message(u'cursor_busy') log.debug(u'regenerateServiceItems') # force reset of renderer as theme data has changed self.parent.renderManager.themedata = None @@ -899,6 +898,7 @@ class ServiceManager(QtGui.QWidget): # Set to False as items may have changed rendering # does not impact the saved song so True may also be valid self.setModified(True) + Receiver.send_message(u'cursor_normal') def serviceItemUpdate(self, message): """ From fd5e173d21347ce73363240481049dd19ef231de Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Jan 2011 12:49:38 +0000 Subject: [PATCH 3/3] Cleanups --- openlp.pyw | 8 +++----- openlp/core/lib/mediamanageritem.py | 2 ++ openlp/plugins/images/lib/mediaitem.py | 2 -- openlp/plugins/presentations/lib/mediaitem.py | 2 -- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 888cdae9f..f3455962d 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -205,22 +205,20 @@ class OpenLP(QtGui.QApplication): self.exceptionForm = ExceptionForm(self.mainWindow) self.exceptionForm.exceptionTextEdit.setPlainText( ''.join(format_exception(exctype, value, traceback))) + self.setNormalCursor() self.exceptionForm.exec_() def setBusyCursor(self): """ - Sets the Busy Cursor on the Main Window + Sets the Busy Cursor for the Application """ - #a=c self.setOverrideCursor(QtCore.Qt.BusyCursor) - #self.processEvents() def setNormalCursor(self): """ - Sets the Normal Cursor on the Main Window + Sets the Normal Cursor forthe Application """ self.restoreOverrideCursor() - #self.processEvents() def main(): """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 6147be608..a9484795b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -349,11 +349,13 @@ class MediaManagerItem(QtGui.QWidget): self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: + Receiver.send_message(u'cursor_busy') self.loadList(files) lastDir = os.path.split(unicode(files[0]))[0] SettingsManager.set_last_dir(self.settingsSection, lastDir) SettingsManager.set_list(self.settingsSection, self.settingsSection, self.getFileList()) + Receiver.send_message(u'cursor_normal') def getFileList(self): """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 1c48e3eb6..7281bb091 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -139,7 +139,6 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection, self.getFileList()) def loadList(self, list): - Receiver.send_message(u'cursor_busy') for file in list: filename = os.path.split(unicode(file))[1] thumb = os.path.join(self.servicePath, filename) @@ -154,7 +153,6 @@ class ImageMediaItem(MediaManagerItem): item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) self.listView.addItem(item_name) - Receiver.send_message(u'cursor_normal') def generateSlideData(self, service_item, item=None, xmlVersion=False): items = self.listView.selectedIndexes() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 9b8c2c1a9..e832f1a10 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -171,7 +171,6 @@ class PresentationMediaItem(MediaManagerItem): This is called both on initial load of the plugin to populate with existing files, and when the user adds new files via the media manager """ - Receiver.send_message(u'cursor_busy') currlist = self.getFileList() titles = [] for file in currlist: @@ -216,7 +215,6 @@ class PresentationMediaItem(MediaManagerItem): item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setIcon(icon) self.listView.addItem(item_name) - Receiver.send_message(u'cursor_normal') def onDeleteClick(self): """