openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #23003
[Merge] lp:~sam92/openlp/pdf-fixes into lp:openlp
Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/pdf-fixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~sam92/openlp/pdf-fixes/+merge/214919
PDF Fixes
- Changed some types to float instead of int because the string conversion failed: int('1.1') doesnt work
- Check if files exist before deleting them
- Replace 'pass' with 'continue'. 'pass' is like return, it stops the whole method.
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/261/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/222/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/171/
[SUCCESS] http://ci.openlp.org/job/Branch-04-Windows_Tests/132/
[FAILURE] http://ci.openlp.org/job/Branch-05-Code-Analysis/88/
--
https://code.launchpad.net/~sam92/openlp/pdf-fixes/+merge/214919
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/pdf-fixes into lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2014-03-26 11:26:16 +0000
+++ openlp/core/ui/slidecontroller.py 2014-04-09 11:18:13 +0000
@@ -495,14 +495,14 @@
self.on_theme_display(False)
self.on_hide_display(False)
- def service_previous(self):
+ def service_previous(self, field=None):
"""
Live event to select the previous service item from the service manager.
"""
self.keypress_queue.append(ServiceItemAction.Previous)
self._process_queue()
- def service_next(self):
+ def service_next(self, field=None):
"""
Live event to select the next service item from the service manager.
"""
=== modified file 'openlp/plugins/presentations/lib/pdfcontroller.py'
--- openlp/plugins/presentations/lib/pdfcontroller.py 2014-03-21 21:38:08 +0000
+++ openlp/plugins/presentations/lib/pdfcontroller.py 2014-04-09 11:18:13 +0000
@@ -204,19 +204,19 @@
log.debug(' '.join(e.cmd))
log.debug(e.output)
# Extract the pdf resolution from output, the format is " Size: x: <width>, y: <height>"
- width = 0
- height = 0
+ width = 0.0
+ height = 0.0
for line in runlog.splitlines():
try:
- width = int(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
- height = int(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
+ width = float(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
+ height = float(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
break
except AttributeError:
- pass
+ continue
# Calculate the ratio from pdf to screen
if width > 0 and height > 0:
- width_ratio = size.right() / float(width)
- height_ratio = size.bottom() / float(height)
+ width_ratio = size.right() / width
+ height_ratio = size.bottom() / height
# return the resolution that should be used. 72 is default.
if width_ratio > height_ratio:
return int(height_ratio * 72)
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2014-03-18 20:36:02 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2014-04-09 11:18:13 +0000
@@ -122,8 +122,10 @@
a file, e.g. thumbnails
"""
try:
- shutil.rmtree(self.get_thumbnail_folder())
- shutil.rmtree(self.get_temp_folder())
+ if os.path.exists(self.get_thumbnail_folder()):
+ shutil.rmtree(self.get_thumbnail_folder())
+ if os.path.exists(self.get_temp_folder()):
+ shutil.rmtree(self.get_temp_folder())
except OSError:
log.exception('Failed to delete presentation controller files')
=== modified file 'tests/functional/openlp_core_lib/test_ui.py'
--- tests/functional/openlp_core_lib/test_ui.py 2014-03-26 12:06:48 +0000
+++ tests/functional/openlp_core_lib/test_ui.py 2014-04-09 11:18:13 +0000
@@ -81,3 +81,28 @@
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
self.assertEqual(1, len(btnbox.buttons()))
self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
+
+ def test_create_action(self):
+ """
+ Test creating an action
+ """
+ # GIVEN: A dialog
+ dialog = QtGui.QDialog()
+
+ # WHEN: We create an action
+ action = create_action(dialog, 'my_action')
+
+ # THEN: We should get a QAction
+ self.assertIsInstance(action, QtGui.QAction)
+ self.assertEqual('my_action', action.objectName())
+
+ # WHEN: We create an action with some properties
+ action = create_action(dialog, 'my_action', text='my text', icon=':/wizards/wizard_firsttime.bmp',
+ tooltip='my tooltip', statustip='my statustip')
+
+ # THEN: These properties should be set
+ self.assertIsInstance(action, QtGui.QAction)
+ self.assertEqual('my text', action.text())
+ self.assertIsInstance(action.icon(), QtGui.QIcon)
+ self.assertEqual('my tooltip', action.toolTip())
+ self.assertEqual('my statustip', action.statusTip())