← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tcf38012/openlp/stretchimage into lp:openlp

 

Theodore Frederick has proposed merging lp:~tcf38012/openlp/stretchimage into lp:openlp.

Commit message:
Add option to ignore aspect ratio and stretch image.

Requested reviews:
  Raoul Snyman (raoul-snyman)

For more details, see:
https://code.launchpad.net/~tcf38012/openlp/stretchimage/+merge/323440

Adds option to ignore aspect ratio and stretch image.
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/common/settings.py'
--- openlp/core/common/settings.py	2017-02-18 07:23:15 +0000
+++ openlp/core/common/settings.py	2017-04-30 09:36:45 +0000
@@ -121,6 +121,7 @@
         'advanced/enable exit confirmation': True,
         'advanced/expand service item': False,
         'advanced/hide mouse': True,
+        'advanced/ignore aspect ratio': False,
         'advanced/is portable': False,
         'advanced/max recent files': 20,
         'advanced/print file meta data': False,

=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2016-12-31 11:01:36 +0000
+++ openlp/core/lib/__init__.py	2017-04-30 09:36:45 +0000
@@ -227,7 +227,7 @@
     return image_date <= thumb_date
 
 
-def resize_image(image_path, width, height, background='#000000'):
+def resize_image(image_path, width, height, background='#000000', ignore_aspect_ratio=False):
     """
     Resize an image to fit on the current screen.
 
@@ -244,7 +244,7 @@
     image_ratio = reader.size().width() / reader.size().height()
     resize_ratio = width / height
     # Figure out the size we want to resize the image to (keep aspect ratio).
-    if image_ratio == resize_ratio:
+    if image_ratio == resize_ratio or ignore_aspect_ratio:
         size = QtCore.QSize(width, height)
     elif image_ratio < resize_ratio:
         # Use the image's height as reference for the new size.

=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py	2016-12-31 11:01:36 +0000
+++ openlp/core/lib/imagemanager.py	2017-04-30 09:36:45 +0000
@@ -31,7 +31,7 @@
 
 from PyQt5 import QtCore
 
-from openlp.core.common import Registry
+from openlp.core.common import Registry, Settings
 from openlp.core.lib import ScreenList, resize_image, image_to_byte
 
 log = logging.getLogger(__name__)
@@ -306,7 +306,8 @@
             # Let's see if the image was requested with specific dimensions
             width = self.width if image.width == -1 else image.width
             height = self.height if image.height == -1 else image.height
-            image.image = resize_image(image.path, width, height, image.background)
+            image.image = resize_image(image.path, width, height, image.background,
+                                       Settings().value('advanced/ignore aspect ratio'))
             # 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.modify_priority(image, Priority.Lowest)

=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py	2016-12-31 11:01:36 +0000
+++ openlp/core/ui/advancedtab.py	2017-04-30 09:36:45 +0000
@@ -224,6 +224,9 @@
         self.display_workaround_group_box.setObjectName('display_workaround_group_box')
         self.display_workaround_layout = QtWidgets.QVBoxLayout(self.display_workaround_group_box)
         self.display_workaround_layout.setObjectName('display_workaround_layout')
+        self.ignore_aspect_ratio_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box)
+        self.ignore_aspect_ratio_check_box.setObjectName('ignore_aspect_ratio_check_box')
+        self.display_workaround_layout.addWidget(self.ignore_aspect_ratio_check_box)
         self.x11_bypass_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box)
         self.x11_bypass_check_box.setObjectName('x11_bypass_check_box')
         self.display_workaround_layout.addWidget(self.x11_bypass_check_box)
@@ -333,6 +336,7 @@
             translate('OpenLP.AdvancedTab', '<strong>WARNING:</strong> New data directory location contains '
                       'OpenLP data files.  These files WILL be replaced during a copy.'))
         self.display_workaround_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds'))
+        self.ignore_aspect_ratio_check_box.setText(translate('OpenLP.AdvancedTab', 'Ignore Aspect Ratio'))
         self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager'))
         self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists'))
         # Slide Limits
@@ -377,6 +381,7 @@
         default_service_enabled = settings.value('default service enabled')
         self.service_name_check_box.setChecked(default_service_enabled)
         self.service_name_check_box_toggled(default_service_enabled)
+        self.ignore_aspect_ratio_check_box.setChecked(settings.value('ignore aspect ratio'))
         self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
         self.slide_limits = settings.value('slide limits')
         self.is_search_as_you_type_enabled = settings.value('search as type')
@@ -433,6 +438,7 @@
         settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
         settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
         settings.setValue('slide limits', self.slide_limits)
+        settings.setValue('ignore aspect ratio', self.ignore_aspect_ratio_check_box.isChecked())
         if self.x11_bypass_check_box.isChecked() != settings.value('x11 bypass wm'):
             settings.setValue('x11 bypass wm', self.x11_bypass_check_box.isChecked())
             self.settings_form.register_post_process('config_screen_changed')


Follow ups