Theme preview resizing for the ThemeWizard

This commit is contained in:
M2j 2010-12-28 22:24:21 +01:00
parent 557a66db9d
commit 31721c51d6
3 changed files with 33 additions and 15 deletions

View File

@ -215,6 +215,25 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', \
'(%d lines per slide)' % int(lines))))
def resizeEvent(self, event=None):
"""
Rescale the theme preview thumbnail on resize events.
"""
if not event:
event = QtGui.QResizeEvent(self.size(), self.size())
QtGui.QWizard.resizeEvent(self, event)
if self.currentPage() == self.previewPage:
frameWidth = self.previewBoxLabel.lineWidth()
pixmapWidth = self.previewArea.width() - 2 * frameWidth
pixmapHeight = self.previewArea.height() - 2 * frameWidth
aspectRatio = float(pixmapWidth) / pixmapHeight
if aspectRatio < self.displayAspectRatio:
pixmapHeight = int(pixmapWidth / self.displayAspectRatio + 0.5)
else:
pixmapWidth = int(pixmapHeight * self.displayAspectRatio + 0.5)
self.previewBoxLabel.setFixedSize(pixmapWidth + 2 * frameWidth,
pixmapHeight + 2 * frameWidth)
def onCurrentIdChanged(self, pageId):
"""
Detects Page changes and updates as approprate.
@ -223,6 +242,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.updateTheme()
frame = self.thememanager.generateImage(self.theme)
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
self.displayAspectRatio = float(frame.width()) / frame.height()
self.resizeEvent()
def onOutlineCheckCheckBoxStateChanged(self, state):
"""

View File

@ -363,22 +363,19 @@ class Ui_ThemeWizard(object):
self.themeNameEdit.setObjectName(u'ThemeNameEdit')
self.themeNameLayout.addRow(self.themeNameLabel, self.themeNameEdit)
self.previewLayout.addLayout(self.themeNameLayout)
self.previewPaneLayout = QtGui.QHBoxLayout()
self.previewPaneLayout.setObjectName(u'PreviewPaneLayout')
self.previewPaneLayout.addStretch()
self.previewBoxLabel = QtGui.QLabel(self.previewPage)
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.previewBoxLabel.setSizePolicy(sizePolicy)
self.previewBoxLabel.setMinimumSize(QtCore.QSize(100, 150))
self.previewBoxLabel.setFrameShape(QtGui.QFrame.WinPanel)
self.previewBoxLabel.setFrameShadow(QtGui.QFrame.Sunken)
self.previewBoxLabel.setLineWidth(1)
self.previewArea = QtGui.QWidget(self.previewPage)
self.previewArea.setObjectName(u'PreviewArea')
self.previewAreaLayout = QtGui.QGridLayout(self.previewArea)
self.previewAreaLayout.setMargin(0)
self.previewAreaLayout.setColumnStretch(0, 1)
self.previewAreaLayout.setRowStretch(0, 1)
self.previewAreaLayout.setObjectName(u'PreviewAreaLayout')
self.previewBoxLabel = QtGui.QLabel(self.previewArea)
self.previewBoxLabel.setFrameShape(QtGui.QFrame.Box)
self.previewBoxLabel.setScaledContents(True)
self.previewBoxLabel.setObjectName(u'PreviewBoxLabel')
self.previewPaneLayout.addWidget(self.previewBoxLabel)
self.previewPaneLayout.addStretch()
self.previewLayout.addLayout(self.previewPaneLayout)
self.previewAreaLayout.addWidget(self.previewBoxLabel)
self.previewLayout.addWidget(self.previewArea)
ThemeWizard.addPage(self.previewPage)
self.retranslateUi(ThemeWizard)

View File

@ -144,7 +144,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
"""
if self.currentPage() == self.welcomePage:
return True
elif self.currentId() == self.sourcePage:
elif self.currentPage() == self.sourcePage:
source_format = self.formatComboBox.currentIndex()
if source_format == SongFormat.OpenLP2:
if self.openLP2FilenameEdit.text().isEmpty():