Initial stab

Fixes: https://launchpad.net/bugs/814201
This commit is contained in:
Tim Bentley 2011-09-27 20:37:34 +01:00
parent 8e8e76e708
commit 3e2e87bb2c
2 changed files with 49 additions and 0 deletions

View File

@ -229,6 +229,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
Detects Page changes and updates as approprate.
"""
if self.page(pageId) == self.areaPositionPage:
self._generate_layout()
if self.page(pageId) == self.previewPage:
self.updateTheme()
frame = self.thememanager.generateImage(self.theme)
@ -236,6 +238,38 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.displayAspectRatio = float(frame.width()) / frame.height()
self.resizeEvent()
def _generate_layout(self):
width = self.thememanager.mainwindow.renderer.width
height = self.thememanager.mainwindow.renderer.height
footer_start = int(height * 0.90)
pixmap = QtGui.QPixmap(width, height)
pixmap.fill(QtCore.Qt.white)
paint = QtGui.QPainter(pixmap)
paint.setPen(QtCore.Qt.blue)
if not self.theme.font_main_override:
main_rect = QtCore.QRect(10, 0, width - 20, footer_start)
else:
main_rect = QtCore.QRect(self.theme.font_main_x, self.theme.font_main_y,
self.theme.font_main_width - 1, self.theme.font_main_height - 1)
paint.drawRect(main_rect)
paint.setPen(QtCore.Qt.red)
if not self.theme.font_footer_override:
footer_rect = QtCore.QRect(10, footer_start, width - 20,
height - footer_start)
else:
footer_rect = QtCore.QRect(self.theme.font_footer_x,
self.theme.font_footer_y, self.theme.font_footer_width - 1,
self.theme.font_footer_height - 1)
print footer_rect
paint.drawRect(footer_rect)
paint.end()
pixmap = pixmap.scaled(100, 100 *
self.thememanager.mainwindow.renderer.screen_ratio,
QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
self.themeLayoutLabel.setPixmap(pixmap)
self.displayAspectRatio = float(pixmap.width()) / pixmap.height()
self.resizeEvent()
def onOutlineCheckCheckBoxStateChanged(self, state):
"""
Change state as Outline check box changed

View File

@ -336,6 +336,21 @@ class Ui_ThemeWizard(object):
self.footerPositionLayout.addRow(self.footerHeightLabel,
self.footerHeightSpinBox)
self.areaPositionLayout.addWidget(self.footerPositionGroupBox)
self.layoutArea = QtGui.QWidget(self.areaPositionPage)
self.layoutArea.setObjectName(u'LayoutArea')
self.themeLayoutPreview = QtGui.QGridLayout(self.layoutArea)
self.themeLayoutPreview.setMargin(0)
self.themeLayoutPreview.setColumnStretch(0, 1)
self.themeLayoutPreview.setRowStretch(0, 1)
self.themeLayoutLabel = QtGui.QLabel(self.areaPositionPage)
self.themeLayoutLabel.setObjectName(u'ThemeLayoutPreview')
self.themeLayoutLabel.setObjectName(u'ThemeLayoutPreview')
self.themeLayoutLabel = QtGui.QLabel(self.layoutArea)
self.themeLayoutLabel.setFrameShape(QtGui.QFrame.Box)
self.themeLayoutLabel.setScaledContents(True)
self.themeLayoutLabel.setObjectName(u'ThemeLayoutLabel')
self.areaPositionLayout.addWidget(self.themeLayoutLabel)
self.areaPositionLayout.addWidget(self.layoutArea)
themeWizard.addPage(self.areaPositionPage)
# Preview Page
self.previewPage = QtGui.QWizardPage()