~tomasgroth/openlp/presentation-load-speedup

« back to all changes in this revision

Viewing changes to openlp/core/widgets/views.py

  • Committer: Tomas Groth
  • Date: 2019-09-15 09:05:21 UTC
  • mfrom: (2815.1.87 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190915090521-pzze809hy4xv3rlk
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        An empty ``ServiceItem`` is used by default. replace_service_manager_item() needs to be called to make this
81
81
        widget display something.
82
82
        """
83
 
        super(QtWidgets.QTableWidget, self).__init__(parent)
 
83
        super().__init__(parent)
84
84
        self._setup(screen_ratio)
85
85
 
86
86
    def _setup(self, screen_ratio):
124
124
                max_img_row_height = Settings().value('advanced/slide max height')
125
125
                # Adjust for row height cap if in use.
126
126
                if isinstance(max_img_row_height, int):
127
 
                    if max_img_row_height > 0 and height > max_img_row_height:
 
127
                    if 0 < max_img_row_height < height:
128
128
                        height = max_img_row_height
129
129
                    elif max_img_row_height < 0:
130
130
                        # If auto setting, show that number of slides, or if the resulting slides too small, 100px.
210
210
                            pixmap = QtGui.QPixmap(str(slide['image']))
211
211
                else:
212
212
                    pixmap = QtGui.QPixmap(str(slide['path']))
 
213
                if pixmap.height() > 0:
 
214
                    pixmap_ratio = pixmap.width() / pixmap.height()
 
215
                else:
 
216
                    pixmap_ratio = 1
213
217
                label.setPixmap(pixmap)
214
218
                container = QtWidgets.QWidget()
215
 
                layout = AspectRatioLayout(container, self.screen_ratio)
 
219
                layout = AspectRatioLayout(container, pixmap_ratio)
216
220
                layout.setContentsMargins(0, 0, 0, 0)
217
221
                layout.addWidget(label)
218
222
                container.setLayout(layout)
219
223
                slide_height = width // self.screen_ratio
220
224
                max_img_row_height = Settings().value('advanced/slide max height')
221
225
                if isinstance(max_img_row_height, int):
222
 
                    if max_img_row_height > 0 and slide_height > max_img_row_height:
 
226
                    if 0 < max_img_row_height < slide_height:
223
227
                        slide_height = max_img_row_height
224
228
                    elif max_img_row_height < 0:
225
229
                        # If auto setting, show that number of slides, or if the resulting slides too small, 100px.