forked from openlp/openlp
Theme preview resizing for the ThemeWizard
This commit is contained in:
parent
557a66db9d
commit
31721c51d6
@ -215,6 +215,25 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
|||||||
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', \
|
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', \
|
||||||
'(%d lines per slide)' % int(lines))))
|
'(%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):
|
def onCurrentIdChanged(self, pageId):
|
||||||
"""
|
"""
|
||||||
Detects Page changes and updates as approprate.
|
Detects Page changes and updates as approprate.
|
||||||
@ -223,6 +242,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
|||||||
self.updateTheme()
|
self.updateTheme()
|
||||||
frame = self.thememanager.generateImage(self.theme)
|
frame = self.thememanager.generateImage(self.theme)
|
||||||
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
self.displayAspectRatio = float(frame.width()) / frame.height()
|
||||||
|
self.resizeEvent()
|
||||||
|
|
||||||
def onOutlineCheckCheckBoxStateChanged(self, state):
|
def onOutlineCheckCheckBoxStateChanged(self, state):
|
||||||
"""
|
"""
|
||||||
|
@ -363,22 +363,19 @@ class Ui_ThemeWizard(object):
|
|||||||
self.themeNameEdit.setObjectName(u'ThemeNameEdit')
|
self.themeNameEdit.setObjectName(u'ThemeNameEdit')
|
||||||
self.themeNameLayout.addRow(self.themeNameLabel, self.themeNameEdit)
|
self.themeNameLayout.addRow(self.themeNameLabel, self.themeNameEdit)
|
||||||
self.previewLayout.addLayout(self.themeNameLayout)
|
self.previewLayout.addLayout(self.themeNameLayout)
|
||||||
self.previewPaneLayout = QtGui.QHBoxLayout()
|
self.previewArea = QtGui.QWidget(self.previewPage)
|
||||||
self.previewPaneLayout.setObjectName(u'PreviewPaneLayout')
|
self.previewArea.setObjectName(u'PreviewArea')
|
||||||
self.previewPaneLayout.addStretch()
|
self.previewAreaLayout = QtGui.QGridLayout(self.previewArea)
|
||||||
self.previewBoxLabel = QtGui.QLabel(self.previewPage)
|
self.previewAreaLayout.setMargin(0)
|
||||||
sizePolicy = QtGui.QSizePolicy(
|
self.previewAreaLayout.setColumnStretch(0, 1)
|
||||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
self.previewAreaLayout.setRowStretch(0, 1)
|
||||||
self.previewBoxLabel.setSizePolicy(sizePolicy)
|
self.previewAreaLayout.setObjectName(u'PreviewAreaLayout')
|
||||||
self.previewBoxLabel.setMinimumSize(QtCore.QSize(100, 150))
|
self.previewBoxLabel = QtGui.QLabel(self.previewArea)
|
||||||
self.previewBoxLabel.setFrameShape(QtGui.QFrame.WinPanel)
|
self.previewBoxLabel.setFrameShape(QtGui.QFrame.Box)
|
||||||
self.previewBoxLabel.setFrameShadow(QtGui.QFrame.Sunken)
|
|
||||||
self.previewBoxLabel.setLineWidth(1)
|
|
||||||
self.previewBoxLabel.setScaledContents(True)
|
self.previewBoxLabel.setScaledContents(True)
|
||||||
self.previewBoxLabel.setObjectName(u'PreviewBoxLabel')
|
self.previewBoxLabel.setObjectName(u'PreviewBoxLabel')
|
||||||
self.previewPaneLayout.addWidget(self.previewBoxLabel)
|
self.previewAreaLayout.addWidget(self.previewBoxLabel)
|
||||||
self.previewPaneLayout.addStretch()
|
self.previewLayout.addWidget(self.previewArea)
|
||||||
self.previewLayout.addLayout(self.previewPaneLayout)
|
|
||||||
ThemeWizard.addPage(self.previewPage)
|
ThemeWizard.addPage(self.previewPage)
|
||||||
|
|
||||||
self.retranslateUi(ThemeWizard)
|
self.retranslateUi(ThemeWizard)
|
||||||
|
@ -144,7 +144,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
|||||||
"""
|
"""
|
||||||
if self.currentPage() == self.welcomePage:
|
if self.currentPage() == self.welcomePage:
|
||||||
return True
|
return True
|
||||||
elif self.currentId() == self.sourcePage:
|
elif self.currentPage() == self.sourcePage:
|
||||||
source_format = self.formatComboBox.currentIndex()
|
source_format = self.formatComboBox.currentIndex()
|
||||||
if source_format == SongFormat.OpenLP2:
|
if source_format == SongFormat.OpenLP2:
|
||||||
if self.openLP2FilenameEdit.text().isEmpty():
|
if self.openLP2FilenameEdit.text().isEmpty():
|
||||||
|
Loading…
Reference in New Issue
Block a user