From 3e2e87bb2c6686753486294f9fb6650a8d921234 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Sep 2011 20:37:34 +0100 Subject: [PATCH] Initial stab Fixes: https://launchpad.net/bugs/814201 --- openlp/core/ui/themeform.py | 34 ++++++++++++++++++++++++++++++++++ openlp/core/ui/themewizard.py | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index dc3c23d0d..5de7a239e 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -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 diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index c7cba0ebd..12ae97d0d 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -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()