From 870d0b51e98066e507d346447f7109145313baf9 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 29 Jun 2011 22:04:08 +0100 Subject: [PATCH 01/19] Move SongUsage active to toolbar --- openlp/plugins/songusage/songusageplugin.py | 43 ++++++++++++-------- resources/images/openlp-2.qrc | 4 ++ resources/images/song_usage_active.png | Bin 0 -> 757 bytes resources/images/song_usage_inactive.png | Bin 0 -> 716 bytes 4 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 resources/images/song_usage_active.png create mode 100644 resources/images/song_usage_inactive.png diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7304b5196..c600aece3 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -48,6 +48,8 @@ class SongUsagePlugin(Plugin): Plugin.__init__(self, u'SongUsage', plugin_helpers) self.weight = -4 self.icon = build_icon(u':/plugins/plugin_songusage.png') + self.activeIcon = QtGui.QIcon(u':/songusage/song_usage_active.png') + self.inactiveIcon = QtGui.QIcon(u':/songusage/song_usage_inactive.png') self.manager = None self.songusageActive = False @@ -79,22 +81,21 @@ class SongUsagePlugin(Plugin): self.songUsageReport.setStatusTip( translate('SongUsagePlugin', 'Generate a report on song usage.')) # SongUsage activation - self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus', - [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False) - self.songUsageStatus.setText(translate( - 'SongUsagePlugin', 'Toggle Tracking')) - self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', - 'Toggle the tracking of song usage.')) - #Add Menus together + # Add Menus together self.toolsMenu.addAction(self.songUsageMenu.menuAction()) - self.songUsageMenu.addAction(self.songUsageStatus) - self.songUsageMenu.addSeparator() self.songUsageMenu.addAction(self.songUsageDelete) self.songUsageMenu.addAction(self.songUsageReport) + self.songUsageStatus = QtGui.QToolButton(self.formparent.statusBar) + self.songUsageStatus.setCheckable(True) + self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', + 'Toggle the tracking of song usage.')) + self.songUsageStatus.setObjectName(u'songUsageStatus') + self.formparent.statusBar.insertPermanentWidget(1, self.songUsageStatus) + self.songUsageStatus.hide() # Signals and slots QtCore.QObject.connect(self.songUsageStatus, - QtCore.SIGNAL(u'visibilityChanged(bool)'), - self.songUsageStatus.setChecked) + QtCore.SIGNAL(u'toggled(bool)'), + self.toggleSongUsageState) QtCore.QObject.connect(self.songUsageDelete, QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) QtCore.QObject.connect(self.songUsageReport, @@ -116,14 +117,14 @@ class SongUsagePlugin(Plugin): translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) - action_list.add_action(self.songUsageStatus, - translate('SongUsagePlugin', 'Song Usage')) if self.manager is None: self.manager = Manager(u'songusage', init_schema) self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formparent) self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent) self.songUsageMenu.menuAction().setVisible(True) + self.songUsageStatus.show() + self.songUsageStatus.setIcon(self.activeIcon) def finalise(self): """ @@ -138,22 +139,32 @@ class SongUsagePlugin(Plugin): translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) - action_list.remove_action(self.songUsageStatus, - translate('SongUsagePlugin', 'Song Usage')) - #stop any events being processed + self.songUsageStatus.hide() + # stop any events being processed self.SongUsageActive = False def toggleSongUsageState(self): + """ + Manage the state of the audit collection and amend + the UI when necessary, + """ + print "toggle state" self.SongUsageActive = not self.SongUsageActive QtCore.QSettings().setValue(self.settingsSection + u'/active', QtCore.QVariant(self.SongUsageActive)) + if self.SongUsageActive: + self.songUsageStatus.setIcon(self.activeIcon) + else: + self.songUsageStatus.setIcon(self.inactiveIcon) def onReceiveSongUsage(self, item): """ Song Usage for live song from SlideController """ audit = item[0].audit + print audit if self.SongUsageActive and audit: + print "here" song_usage_item = SongUsageItem() song_usage_item.usagedate = datetime.today() song_usage_item.usagetime = datetime.now().time() diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index fc76ad434..89be90056 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -137,6 +137,10 @@ messagebox_info.png messagebox_warning.png + + song_usage_active.png + song_usage_inactive.png + tools_add.png tools_alert.png diff --git a/resources/images/song_usage_active.png b/resources/images/song_usage_active.png new file mode 100644 index 0000000000000000000000000000000000000000..1221e13103a3066b11a821e82e26f441fac9dc5d GIT binary patch literal 757 zcmV( zu7%a2Roh&aSgW9Is}@mYfvfg@U<>=ej6$bT8Fkc|dGF18_vGV=jf8)=+{HQP z$GzvAzo;tpvhG-?8{w8(j0g+^C@hF!&WD%gh516A4gqpTti(CFe=^6#=*=W z>Goa#^4lvc<`;SO>9zko|KmYzMxW|uHHUzx*dCFO_paQ{T_3%MZ3|)nLM#PU2x`jP znRh(<@O(O$)5{UW25892_>Bu!a~FrsvsKH3p$(u z2Cyq7Qe8MffiYWzY*VZ9wKPkA@)QV^i?I1qz#>)wx(1Y%ju^1K_l;yqk#))1z_8=M zYGsLFr%HGG309W{Zx66Q00p*|Ad^)#%j*=}Rh$+;7`6eB_-yP4w##c2Hk%2`32eIo z1VR&H2Q}Pkg}@IG`PX0@SnynOEd~I>Fd)&p!^XTEc|m4K2}3~RMtW61S+G=@b@znO z2R&#~TMwkOO0pf29grDS+R~tY91mTnmIO7-irkiHjPscRby7WGwSY8%I3NkY0t{#k z)B{t7ojh3Ynh6)-MnB~CVb2X_U+ay;JRFTwYih-#0la%(5K zuC&tJ2@OqP*?`1colW>@>#!uLAC_P%7dDJ`d~7 nbgZ4lVnnUj&SF^5W92nAaxE{#x9n?dXzXmN3N z(4{(baH^BELc6q3a2Dy%#nnkDbna+11at}oF(G2BVxpJ(``*6ar5p;S&3N7^7N z=77Ct%ggT2=qN15ffAC4C?SXdX6Psa3*#U_yVb(?^>zP>dD3=)`8?pN)6?Epvsuu< z0F)~$nM^7`VF>N};BFW8#Rc+~GP#ORb zA044kD4-v-8x3U5>4KnSr*D<&Tc9I*Av7@8st-VGjecSFcB2TU);1aH5LHIxMO}j9 zj|o0eyXq@bVI&{J_9CA+~~f*Lp$Jl-rks%(iO+WLdocnG+e?d_O6U zuC5XWoes|1Z8Sa4_n2SVOOox+O0Bix_=DqlAf3qx7Il;Va6cC}tJ zwYQ>tSEd2a{yWY@RDyubI5Yoqoc{m~r92WwE;k{~O literal 0 HcmV?d00001 From 0b41274f8e7e37e078d19b81aaeb731e6ab58360 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 30 Jun 2011 19:59:51 +0100 Subject: [PATCH 02/19] Fix up button --- openlp/plugins/songusage/songusageplugin.py | 54 ++++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c600aece3..ff7a691f7 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -51,7 +51,7 @@ class SongUsagePlugin(Plugin): self.activeIcon = QtGui.QIcon(u':/songusage/song_usage_active.png') self.inactiveIcon = QtGui.QIcon(u':/songusage/song_usage_inactive.png') self.manager = None - self.songusageActive = False + self.songUsageActive = False def addToolsMenuItem(self, tools_menu): """ @@ -85,15 +85,17 @@ class SongUsagePlugin(Plugin): self.toolsMenu.addAction(self.songUsageMenu.menuAction()) self.songUsageMenu.addAction(self.songUsageDelete) self.songUsageMenu.addAction(self.songUsageReport) - self.songUsageStatus = QtGui.QToolButton(self.formparent.statusBar) - self.songUsageStatus.setCheckable(True) - self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', - 'Toggle the tracking of song usage.')) - self.songUsageStatus.setObjectName(u'songUsageStatus') - self.formparent.statusBar.insertPermanentWidget(1, self.songUsageStatus) - self.songUsageStatus.hide() + self.songUsageActiveButton = QtGui.QToolButton( + self.formparent.statusBar) + self.songUsageActiveButton.setCheckable(True) + self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', + 'Toggle the tracking of song usage.')) + self.songUsageActiveButton.setObjectName(u'songUsageActiveButton') + self.formparent.statusBar.insertPermanentWidget(1, + self.songUsageActiveButton) + self.songUsageActiveButton.hide() # Signals and slots - QtCore.QObject.connect(self.songUsageStatus, + QtCore.QObject.connect(self.songUsageActiveButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState) QtCore.QObject.connect(self.songUsageDelete, @@ -108,10 +110,15 @@ class SongUsagePlugin(Plugin): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) - self.SongUsageActive = QtCore.QSettings().value( + self.songUsageActive = QtCore.QSettings().value( self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() - self.songUsageStatus.setChecked(self.SongUsageActive) + # Set the correct state and icon turn of signals as the state + # will get messed up + self.songUsageActiveButton.blockSignals(True) + self.songUsageActiveButton.setChecked(self.songUsageActive) + self.setButtonState() + self.songUsageActiveButton.blockSignals(False) action_list = ActionList.get_instance() action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) @@ -123,8 +130,7 @@ class SongUsagePlugin(Plugin): self.formparent) self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent) self.songUsageMenu.menuAction().setVisible(True) - self.songUsageStatus.show() - self.songUsageStatus.setIcon(self.activeIcon) + self.songUsageActiveButton.show() def finalise(self): """ @@ -139,32 +145,32 @@ class SongUsagePlugin(Plugin): translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) - self.songUsageStatus.hide() + self.songUsageActiveButton.hide() # stop any events being processed - self.SongUsageActive = False + self.songUsageActive = False def toggleSongUsageState(self): """ Manage the state of the audit collection and amend the UI when necessary, """ - print "toggle state" - self.SongUsageActive = not self.SongUsageActive + self.songUsageActive = not self.songUsageActive QtCore.QSettings().setValue(self.settingsSection + u'/active', - QtCore.QVariant(self.SongUsageActive)) - if self.SongUsageActive: - self.songUsageStatus.setIcon(self.activeIcon) + QtCore.QVariant(self.songUsageActive)) + self.setButtonState() + + def setButtonState(self): + if self.songUsageActive: + self.songUsageActiveButton.setIcon(self.activeIcon) else: - self.songUsageStatus.setIcon(self.inactiveIcon) + self.songUsageActiveButton.setIcon(self.inactiveIcon) def onReceiveSongUsage(self, item): """ Song Usage for live song from SlideController """ audit = item[0].audit - print audit - if self.SongUsageActive and audit: - print "here" + if self.songUsageActive and audit: song_usage_item = SongUsageItem() song_usage_item.usagedate = datetime.today() song_usage_item.usagetime = datetime.now().time() From 222d4c228cbe9ef97776f4a82eefd391d3f994c0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Jul 2011 06:43:32 +0100 Subject: [PATCH 03/19] Method fix --- openlp/plugins/songusage/songusageplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index ff7a691f7..c40935430 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -48,8 +48,8 @@ class SongUsagePlugin(Plugin): Plugin.__init__(self, u'SongUsage', plugin_helpers) self.weight = -4 self.icon = build_icon(u':/plugins/plugin_songusage.png') - self.activeIcon = QtGui.QIcon(u':/songusage/song_usage_active.png') - self.inactiveIcon = QtGui.QIcon(u':/songusage/song_usage_inactive.png') + self.activeIcon = build_icon(u':/songusage/song_usage_active.png') + self.inactiveIcon = build_icon(u':/songusage/song_usage_inactive.png') self.manager = None self.songUsageActive = False From 4d82e55ca0c34ba3f0c1c9ed2ac9d7f4824dfe4a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Jul 2011 18:45:48 +0100 Subject: [PATCH 04/19] Correct code --- openlp/plugins/songusage/songusageplugin.py | 30 +++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c40935430..3b5d11b63 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -81,8 +81,16 @@ class SongUsagePlugin(Plugin): self.songUsageReport.setStatusTip( translate('SongUsagePlugin', 'Generate a report on song usage.')) # SongUsage activation + self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus', + [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False) + self.songUsageStatus.setText(translate( + 'SongUsagePlugin', 'Toggle Tracking')) + self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', + 'Toggle the tracking of song usage.')) # Add Menus together self.toolsMenu.addAction(self.songUsageMenu.menuAction()) + self.songUsageMenu.addAction(self.songUsageStatus) + self.songUsageMenu.addSeparator() self.songUsageMenu.addAction(self.songUsageDelete) self.songUsageMenu.addAction(self.songUsageReport) self.songUsageActiveButton = QtGui.QToolButton( @@ -95,6 +103,9 @@ class SongUsagePlugin(Plugin): self.songUsageActiveButton) self.songUsageActiveButton.hide() # Signals and slots + QtCore.QObject.connect(self.songUsageStatus, + QtCore.SIGNAL(u'visibilityChanged(bool)'), + self.songUsageStatus.setChecked) QtCore.QObject.connect(self.songUsageActiveButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState) @@ -113,12 +124,8 @@ class SongUsagePlugin(Plugin): self.songUsageActive = QtCore.QSettings().value( self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() - # Set the correct state and icon turn of signals as the state - # will get messed up - self.songUsageActiveButton.blockSignals(True) - self.songUsageActiveButton.setChecked(self.songUsageActive) + # Set the button and checkbox state self.setButtonState() - self.songUsageActiveButton.blockSignals(False) action_list = ActionList.get_instance() action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) @@ -160,10 +167,23 @@ class SongUsagePlugin(Plugin): self.setButtonState() def setButtonState(self): + """ + Keep buttons inline. Turn of signals to stop dead loop but we need the + button and check box set correctly. + """ + self.songUsageActiveButton.blockSignals(True) + self.songUsageStatus.blockSignals(True) if self.songUsageActive: self.songUsageActiveButton.setIcon(self.activeIcon) + self.songUsageStatus.setChecked(True) + self.songUsageActiveButton.setChecked(True) else: self.songUsageActiveButton.setIcon(self.inactiveIcon) + self.songUsageStatus.setChecked(False) + self.songUsageActiveButton.setChecked(False) + self.songUsageActiveButton.blockSignals(False) + self.songUsageStatus.blockSignals(False) + def onReceiveSongUsage(self, item): """ From b2b8dd1d4d48e5e8dd3ee7464132f5912034adfe Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Jul 2011 19:33:04 +0100 Subject: [PATCH 05/19] Extra fix --- openlp/plugins/songusage/songusageplugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 3b5d11b63..ad79870b8 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -127,6 +127,8 @@ class SongUsagePlugin(Plugin): # Set the button and checkbox state self.setButtonState() action_list = ActionList.get_instance() + action_list.add_action(self.songUsageStatus, + translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageReport, @@ -148,6 +150,8 @@ class SongUsagePlugin(Plugin): Plugin.finalise(self) self.songUsageMenu.menuAction().setVisible(False) action_list = ActionList.get_instance() + action_list.remove_action(self.songUsageStatus, + translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageReport, From 439b5592698bcda0cb195a1ee5e8576b2bd674c3 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 5 Jul 2011 22:17:17 +0200 Subject: [PATCH 06/19] Add main script path, make paths more readable. --- scripts/windows-builder.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index d6f4d42e3..f1d53e600 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -96,7 +96,7 @@ psvince.dll the install will fail. The dll can be obtained from here: http://www.vincenzo.net/isxkb/index.php?title=PSVince) -Mako +Mako Mako Templates for Python. This package is required for building the remote plugin. It can be installed by going to your python_directory\scripts\.. and running "easy_install Mako". If you do not @@ -319,17 +319,19 @@ def main(): import sys for arg in sys.argv: if arg == u'-v' or arg == u'--verbose': - print "Script path:", script_path - print "Branch path:", branch_path - print "Source path:", source_path - print "\"dist\" path:", dist_path - print "PyInstaller:", pyi_build + print "OpenLP main script: ......", openlp_main_script + print "Script path: .............", script_path + print "Branch path: .............", branch_path + print "Source path: .............", source_path + print "\"dist\" path: .............", dist_path + print "PyInstaller: .............", pyi_build print "Documentation branch path:", doc_branch_path - print "Help file build path;", helpfile_path - print "Inno Setup path:", innosetup_exe - print "Windows resources:", winres_path - print "VCBuild path:", vcbuild_exe - print "PPTVIEWLIB path:", pptviewlib_path + print "Help file build path: ....", helpfile_path + print "Inno Setup path: .........", innosetup_exe + print "Windows resources: .......", winres_path + print "VCBuild path: ............", vcbuild_exe + print "PPTVIEWLIB path: .........", pptviewlib_path + print "" elif arg == u'--skip-update': skip_update = True elif arg == u'/?' or arg == u'-h' or arg == u'--help': From 447016c1892247fc7a32619546bc110c82614269 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 6 Jul 2011 20:36:33 +0200 Subject: [PATCH 07/19] Updated Windows build script to work with new PyInstaller and PyQt4 locations. --- scripts/windows-builder.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index f1d53e600..be1a5fd3e 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -133,7 +133,10 @@ site_packages = os.path.join(os.path.split(python_exe)[0], u'Lib', pyi_build = os.path.abspath(os.path.join(branch_path, u'..', u'..', u'pyinstaller', u'pyinstaller.py')) openlp_main_script = os.path.abspath(os.path.join(branch_path, 'openlp.pyw')) -lrelease_exe = os.path.join(site_packages, u'PyQt4', u'bin', u'lrelease.exe') +if os.path.exists(os.path.join(site_packages, u'PyQt4', u'bin')): + lrelease_exe = os.path.join(site_packages, u'PyQt4', u'bin', u'lrelease.exe') +else: + lrelease_exe = os.path.join(site_packages, u'PyQt4', u'lrelease.exe') i18n_utils = os.path.join(script_path, u'translation_utils.py') win32_icon = os.path.join(branch_path, u'resources', u'images', 'OpenLP.ico') @@ -145,7 +148,7 @@ helpfile_path = os.path.join(manual_build_path, u'htmlhelp') i18n_path = os.path.join(branch_path, u'resources', u'i18n') winres_path = os.path.join(branch_path, u'resources', u'windows') build_path = os.path.join(branch_path, u'build') -dist_path = os.path.join(build_path, u'dist', u'OpenLP') +dist_path = os.path.join(branch_path, u'dist', u'OpenLP') pptviewlib_path = os.path.join(source_path, u'plugins', u'presentations', u'lib', u'pptviewlib') @@ -172,7 +175,7 @@ def run_pyinstaller(): pyinstaller = Popen((python_exe, pyi_build, u'--noconfirm', u'--windowed', - u'-o', build_path, + u'-o', branch_path, #build_path, u'-i', win32_icon, u'-p', branch_path, u'-n', 'OpenLP', From 3e8c91cbd593c47d655c086f85331837e7c7e5e4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Jul 2011 16:53:05 +0200 Subject: [PATCH 08/19] refactor some code --- openlp/core/lib/imagemanager.py | 45 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 5970efd4f..61be16b91 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -112,17 +112,29 @@ class PriorityQueue(Queue.PriorityQueue): """ Customised ``Queue.PriorityQueue``. """ - def remove(self, item): + def modify_priority(self, image, new_priority): """ - Removes the given ``item`` from the queue. + Modifies the priority of the given ``image``. - ``item`` - The item to remove. This should be a tuple:: + ``image`` + The image to remove. This should be an ``Image`` instance. - ``(Priority, Image)`` + ``new_priority`` + The new priority for the image. """ - if item in self.queue: - self.queue.remove(item) + self.remove(image) + image.priority = new_priority + self.put((image.priority, image)) + + def remove(self, image): + """ + Removes the given ``image`` from the queue. + + ``image`` + The image to remove. This should be an ``Image`` instance. + """ + if (image.priority, image) in self.queue: + self.queue.remove((image.priority, image)) class ImageManager(QtCore.QObject): @@ -168,9 +180,7 @@ class ImageManager(QtCore.QObject): log.debug(u'get_image %s' % name) image = self._cache[name] if image.image is None: - self._conversion_queue.remove((image.priority, image)) - image.priority = Priority.High - self._conversion_queue.put((image.priority, image)) + self._conversion_queue.modify_priority(image, Priority.High) while image.image is None: log.debug(u'get_image - waiting') time.sleep(0.1) @@ -184,9 +194,7 @@ class ImageManager(QtCore.QObject): log.debug(u'get_image_bytes %s' % name) image = self._cache[name] if image.image_bytes is None: - self._conversion_queue.remove((image.priority, image)) - image.priority = Priority.Urgent - self._conversion_queue.put((image.priority, image)) + self._conversion_queue.modify_priority(image, Priority.Urgent) while image.image_bytes is None: log.debug(u'get_image_bytes - waiting') time.sleep(0.1) @@ -198,8 +206,7 @@ class ImageManager(QtCore.QObject): """ log.debug(u'del_image %s' % name) if name in self._cache: - self._conversion_queue.remove( - (self._cache[name].priority, self._cache[name])) + self._conversion_queue.remove(self._cache[name]) del self._cache[name] def add_image(self, name, path): @@ -238,18 +245,14 @@ class ImageManager(QtCore.QObject): # Set the priority to Lowest and stop here as we need to process # more important images first. if image.priority == Priority.Normal: - self._conversion_queue.remove((image.priority, image)) - image.priority = Priority.Lowest - self._conversion_queue.put((image.priority, image)) + self._conversion_queue.modify_priority(image, Priority.Lowest) return # For image with high priority we set the priority to Low, as the # byte stream might be needed earlier the byte stream of image with # Normal priority. We stop here as we need to process more important # images first. elif image.priority == Priority.High: - self._conversion_queue.remove((image.priority, image)) - image.priority = Priority.Low - self._conversion_queue.put((image.priority, image)) + self._conversion_queue.modify_priority(image, Priority.Low) return # Generate the byte stream for the image. if image.image_bytes is None: From 2b419d8a4eb279ca5a4af5f3f73561539f540c62 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Jul 2011 17:15:48 +0200 Subject: [PATCH 09/19] implementation fix: set priority to low instead of lowerest when the image was requested --- openlp/core/lib/imagemanager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 61be16b91..bde464586 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -184,6 +184,12 @@ class ImageManager(QtCore.QObject): while image.image is None: log.debug(u'get_image - waiting') time.sleep(0.1) + elif image.image_bytes is None: + # Set the priority to Low, because the image was requested but the + # byte stream was not generated yet. However, we only need to do + # this, when the image was generated before it was requested + # (otherwise this is already taken care of). + self._conversion_queue.modify_priority(image, Priority.Low) return image.image def get_image_bytes(self, name): From f7ab82518bad72f66cc96540b28137412e2988f0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Jul 2011 17:37:43 +0200 Subject: [PATCH 10/19] doc --- openlp/core/lib/imagemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index bde464586..37d1de79c 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -120,7 +120,7 @@ class PriorityQueue(Queue.PriorityQueue): The image to remove. This should be an ``Image`` instance. ``new_priority`` - The new priority for the image. + The image's new priority. """ self.remove(image) image.priority = new_priority From e6cf76b7b98f6ed966ee880a99cc3a4c6a8e4229 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 7 Jul 2011 20:18:35 +0200 Subject: [PATCH 11/19] Added comments for explanation of some code. Fixed the build directory due to the new way PyInstaller works. --- scripts/windows-builder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index be1a5fd3e..9c96fe251 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -134,8 +134,12 @@ pyi_build = os.path.abspath(os.path.join(branch_path, u'..', u'..', u'pyinstaller', u'pyinstaller.py')) openlp_main_script = os.path.abspath(os.path.join(branch_path, 'openlp.pyw')) if os.path.exists(os.path.join(site_packages, u'PyQt4', u'bin')): + # Older versions of the PyQt4 Windows installer put their binaries in the + # "bin" directory lrelease_exe = os.path.join(site_packages, u'PyQt4', u'bin', u'lrelease.exe') else: + # Newer versions of the PyQt4 Windows installer put their binaries in the + # base directory of the installation lrelease_exe = os.path.join(site_packages, u'PyQt4', u'lrelease.exe') i18n_utils = os.path.join(script_path, u'translation_utils.py') win32_icon = os.path.join(branch_path, u'resources', u'images', 'OpenLP.ico') @@ -175,7 +179,7 @@ def run_pyinstaller(): pyinstaller = Popen((python_exe, pyi_build, u'--noconfirm', u'--windowed', - u'-o', branch_path, #build_path, + u'-o', branch_path, u'-i', win32_icon, u'-p', branch_path, u'-n', 'OpenLP', From ce1abaf3322ffd09a03461b7365a950f0ab6445b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 8 Jul 2011 07:57:39 +0200 Subject: [PATCH 12/19] Fixed bug #803031: If UTF-8 decoding fails, try the standard Windows codepage. --- openlp/plugins/bibles/lib/http.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 03b094e82..28ceaad68 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -147,7 +147,10 @@ class BGExtract(object): send_error_message(u'download') return None page_source = page.read() - page_source = unicode(page_source, 'utf8') + try: + page_source = unicode(page_source, u'utf8') + except UnicodeDecodeError: + page_source = unicode(page_source, u'cp1251') page_source_temp = re.search(u'.*?'\ u'
', page_source, re.DOTALL) if page_source_temp: From 1a611dcd6088d1edd1f56807bd9301a64e020212 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 8 Jul 2011 07:03:09 +0100 Subject: [PATCH 13/19] Add tooltip --- openlp/plugins/songusage/songusageplugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index ad79870b8..b94c57346 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -181,10 +181,14 @@ class SongUsagePlugin(Plugin): self.songUsageActiveButton.setIcon(self.activeIcon) self.songUsageStatus.setChecked(True) self.songUsageActiveButton.setChecked(True) + self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', + 'Song usage is active.')) else: self.songUsageActiveButton.setIcon(self.inactiveIcon) self.songUsageStatus.setChecked(False) self.songUsageActiveButton.setChecked(False) + self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', + 'Song usage is inactive.')) self.songUsageActiveButton.blockSignals(False) self.songUsageStatus.blockSignals(False) From 897f7a7dbbda3b379b8b33ca7f9aa725e63a06ee Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 8 Jul 2011 08:31:34 +0200 Subject: [PATCH 14/19] Fixed bug #794971: Typecast the buffer object to a unicode object. --- openlp/plugins/songs/lib/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 308ff6aa1..409564553 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -267,6 +267,10 @@ def clean_song(manager, song): ``song`` The song object. """ + if not isinstance(song.title, basestring): + song.title = unicode(song.title) + if not isinstance(song.lyrics, basestring): + song.lyrics = unicode(song.lyrics) song.title = song.title.rstrip() if song.title else u'' if song.alternate_title is None: song.alternate_title = u'' From 5581a74034097a98abd8d5c055daba4a1afc123d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 8 Jul 2011 08:40:50 +0200 Subject: [PATCH 15/19] Changed typecast to rather check for buffer. --- openlp/plugins/songs/lib/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 409564553..e2996ff8f 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -267,9 +267,11 @@ def clean_song(manager, song): ``song`` The song object. """ - if not isinstance(song.title, basestring): + if isinstance(song.title, buffer): song.title = unicode(song.title) - if not isinstance(song.lyrics, basestring): + if isinstance(song.alternate_title, buffer): + song.alternate_title = unicode(song.alternate_title) + if isinstance(song.lyrics, buffer): song.lyrics = unicode(song.lyrics) song.title = song.title.rstrip() if song.title else u'' if song.alternate_title is None: From f264cc4c4e0be7f2d6880eb1254a26ca78f1a067 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 8 Jul 2011 16:07:53 +0100 Subject: [PATCH 16/19] correct tooltip text --- openlp/plugins/songusage/songusageplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index b94c57346..575295f37 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -182,13 +182,13 @@ class SongUsagePlugin(Plugin): self.songUsageStatus.setChecked(True) self.songUsageActiveButton.setChecked(True) self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', - 'Song usage is active.')) + 'Song usage tracking is active.')) else: self.songUsageActiveButton.setIcon(self.inactiveIcon) self.songUsageStatus.setChecked(False) self.songUsageActiveButton.setChecked(False) self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', - 'Song usage is inactive.')) + 'Song usage tracking is inactive.')) self.songUsageActiveButton.blockSignals(False) self.songUsageStatus.blockSignals(False) From a71ea86e4d93bde6ecb7d4e48e4456fbfae3021c Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sat, 9 Jul 2011 16:51:06 +0200 Subject: [PATCH 17/19] add script to check openlp dependencies --- scripts/check_dependencies.py | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100755 scripts/check_dependencies.py diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py new file mode 100755 index 000000000..967ff2185 --- /dev/null +++ b/scripts/check_dependencies.py @@ -0,0 +1,148 @@ +#!/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) 2011 Raoul Snyman # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +""" +This script is used to check dependencies of OpenLP. It checks availability +of required python modules and their version. To verify availability of Python +modules, simply run this script:: + + @:~$ ./check_dependencies.py + +""" +import os +import sys + +is_win = sys.platform.startswith('win') + +VERS = { + 'Python': '2.6', + 'PyQt4': '4.6', + 'Qt4': '4.6', + 'sqlalchemy': '0.5', + # pyenchant 1.6 required on Windows + 'enchant': '1.6' if is_win else '1.3' + } + +# pywin32 +WIN32_MODULES = [ + 'win32com', + 'win32ui', + 'pywintypes', + ] + +MODULES = [ + 'PyQt4', + 'PyQt4.QtCore', + 'PyQt4.QtGui', + 'PyQt4.QtNetwork', + 'PyQt4.QtOpenGL', + 'PyQt4.QtSvg', + 'PyQt4.QtTest', + 'PyQt4.QtWebKit', + 'PyQt4.phonon', + 'sqlalchemy', + 'sqlite3', + 'lxml', + 'chardet', + 'enchant', + 'BeautifulSoup', + 'mako', + ] + + +OPTIONAL_MODULES = [ + ('sqlite', ' (SQLite 2 support)'), + ('MySQLdb', ' (MySQL support)'), + ('psycopg2', ' (PostgreSQL support)'), + ] + +w = sys.stdout.write + + +def check_vers(version, required, text): + if type(version) is str: + version = version.split('.') + version = [int(x) for x in version] + if type(required) is str: + required = required.split('.') + required = [int(x) for x in required] + w(' %s >= %s ... ' % (text, '.'.join([str(x) for x in required]))) + if version >= required: + w('.'.join([str(x) for x in version]) + os.linesep) + return True + else: + w('FAIL' + os.linesep) + return False + + +def verify_python(): + if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): + exit(1) + + +def verify_versions(): + print('Verifying version of modules...') + from PyQt4 import QtCore + check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], + 'PyQt4') + check_vers(QtCore.qVersion(), VERS['Qt4'], + 'Qt4') + check_vers(__import__('sqlalchemy').__version__, VERS['sqlalchemy'], + 'sqlalchemy') + check_vers(__import__('enchant').__version__, VERS['enchant'], + 'enchant') + + +def check_module(mod, text='', indent=' '): + space = (30 - len(mod) - len(text)) * ' ' + w(indent + '%s%s... ' % (mod, text) + space) + try: + __import__(mod) + w('OK') + except ImportError: + w('FAIL') + w(os.linesep) + + +def main(): + + verify_python() + + print('Checking for modules...') + for m in MODULES: + check_module(m) + + print('Checking for optional modules...') + for m in OPTIONAL_MODULES: + check_module(m[0], text=m[1]) + + if sys.platform.startswith('win'): + print('Checking for Windows specific modules...') + for m in WIN32_MODULES: + check_module(m) + + verify_versions() + + +if __name__ == u'__main__': + main() From 5951d2c2a32f90f611f4402dab60cc5919ad41c8 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sat, 9 Jul 2011 22:13:33 +0200 Subject: [PATCH 18/19] Update script to check openlp dependecies by info about supported image formats, enchant backends and available languages --- scripts/check_dependencies.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 967ff2185..c60bf6842 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -107,10 +107,10 @@ def verify_versions(): 'PyQt4') check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4') - check_vers(__import__('sqlalchemy').__version__, VERS['sqlalchemy'], - 'sqlalchemy') - check_vers(__import__('enchant').__version__, VERS['enchant'], - 'enchant') + import sqlalchemy + check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') + import enchant + check_vers(enchant.__version__, VERS['enchant'], 'enchant') def check_module(mod, text='', indent=' '): @@ -124,6 +124,27 @@ def check_module(mod, text='', indent=' '): w(os.linesep) +def verify_pyenchant(): + print('Enchant...') + import enchant + backends = ', '.join([x.name for x in enchant.Broker().describe()]) + print(' available backends: %s' % backends) + langs = ', '.join(enchant.list_languages()) + print(' available languages: %s' % langs) + + +def verify_pyqt(): + print('Qt4 image formats...') + from PyQt4 import QtGui + read_f = ', '.join([unicode(format).lower() \ + for format in QtGui.QImageReader.supportedImageFormats()]) + write_f= ', '.join([unicode(format).lower() \ + for format in QtGui.QImageWriter.supportedImageFormats()]) + print(' read: %s' % read_f) + print(' write: %s' % write_f) + from PyQt4 import phonon + + def main(): verify_python() @@ -142,6 +163,8 @@ def main(): check_module(m) verify_versions() + verify_pyqt() + verify_pyenchant() if __name__ == u'__main__': From cfb1a06bd3fc2398a1c1f94a1dd8b987aeb37794 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sun, 10 Jul 2011 14:00:58 +0200 Subject: [PATCH 19/19] Update script to check openlp dependecies - catching all imports properly --- scripts/check_dependencies.py | 71 +++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index c60bf6842..4abd1504d 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -95,6 +95,10 @@ def check_vers(version, required, text): return False +def print_vers_fail(required, text): + print(' %s >= %s ... FAIL' % (text, required)) + + def verify_python(): if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): exit(1) @@ -102,15 +106,25 @@ def verify_python(): def verify_versions(): print('Verifying version of modules...') - from PyQt4 import QtCore - check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], - 'PyQt4') - check_vers(QtCore.qVersion(), VERS['Qt4'], - 'Qt4') - import sqlalchemy - check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') - import enchant - check_vers(enchant.__version__, VERS['enchant'], 'enchant') + try: + from PyQt4 import QtCore + check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], + 'PyQt4') + check_vers(QtCore.qVersion(), VERS['Qt4'], + 'Qt4') + except ImportError: + print_vers_fail(VERS['PyQt4'], 'PyQt4') + print_vers_fail(VERS['Qt4'], 'Qt4') + try: + import sqlalchemy + check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') + except ImportError: + print_vers_fail(VERS['sqlalchemy'], 'sqlalchemy') + try: + import enchant + check_vers(enchant.__version__, VERS['enchant'], 'enchant') + except ImportError: + print_vers_fail(VERS['enchant'], 'enchant') def check_module(mod, text='', indent=' '): @@ -125,24 +139,31 @@ def check_module(mod, text='', indent=' '): def verify_pyenchant(): - print('Enchant...') - import enchant - backends = ', '.join([x.name for x in enchant.Broker().describe()]) - print(' available backends: %s' % backends) - langs = ', '.join(enchant.list_languages()) - print(' available languages: %s' % langs) + w('Enchant (spell checker)... ') + try: + import enchant + w(os.linesep) + backends = ', '.join([x.name for x in enchant.Broker().describe()]) + print(' available backends: %s' % backends) + langs = ', '.join(enchant.list_languages()) + print(' available languages: %s' % langs) + except ImportError: + w('FAIL' + os.linesep) def verify_pyqt(): - print('Qt4 image formats...') - from PyQt4 import QtGui - read_f = ', '.join([unicode(format).lower() \ - for format in QtGui.QImageReader.supportedImageFormats()]) - write_f= ', '.join([unicode(format).lower() \ - for format in QtGui.QImageWriter.supportedImageFormats()]) - print(' read: %s' % read_f) - print(' write: %s' % write_f) - from PyQt4 import phonon + w('Qt4 image formats... ') + try: + from PyQt4 import QtGui + read_f = ', '.join([unicode(format).lower() \ + for format in QtGui.QImageReader.supportedImageFormats()]) + write_f= ', '.join([unicode(format).lower() \ + for format in QtGui.QImageWriter.supportedImageFormats()]) + w(os.linesep) + print(' read: %s' % read_f) + print(' write: %s' % write_f) + except ImportError: + w('FAIL' + os.linesep) def main(): @@ -157,7 +178,7 @@ def main(): for m in OPTIONAL_MODULES: check_module(m[0], text=m[1]) - if sys.platform.startswith('win'): + if is_win: print('Checking for Windows specific modules...') for m in WIN32_MODULES: check_module(m)