~wgrant/openlp/openlyrics_test

« back to all changes in this revision

Viewing changes to openlp/core/ui/themeform.py

  • Committer: Martin Zibricky
  • Date: 2011-10-06 16:16:29 UTC
  • mfrom: (1186.2.584 openlp)
  • Revision ID: mzibr.public@gmail.com-20111006161629-17tyvvq60h3h15dd
[merge] r1770, rename testing dir to tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from openlp.core.lib import Receiver, translate
34
34
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
35
35
from openlp.core.lib.ui import UiStrings, critical_error_message_box
 
36
from openlp.core.ui import ThemeLayoutForm
36
37
from openlp.core.utils import get_images_filter
37
38
from themewizard import Ui_ThemeWizard
38
39
 
58
59
        self.registerFields()
59
60
        self.updateThemeAllowed = True
60
61
        self.temp_background_filename = u''
 
62
        self.themeLayoutForm = ThemeLayoutForm(self)
61
63
        QtCore.QObject.connect(self.backgroundComboBox,
62
64
            QtCore.SIGNAL(u'currentIndexChanged(int)'),
63
65
            self.onBackgroundComboBoxCurrentIndexChanged)
88
90
            self.onShadowCheckCheckBoxStateChanged)
89
91
        QtCore.QObject.connect(self.footerColorButton,
90
92
            QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked)
 
93
        QtCore.QObject.connect(self,
 
94
            QtCore.SIGNAL(u'customButtonClicked(int)'),
 
95
            self.onCustom1ButtonClicked)
91
96
        QtCore.QObject.connect(self.mainPositionCheckBox,
92
97
            QtCore.SIGNAL(u'stateChanged(int)'),
93
98
            self.onMainPositionCheckBoxStateChanged)
229
234
        """
230
235
        Detects Page changes and updates as approprate.
231
236
        """
 
237
        if self.page(pageId) == self.areaPositionPage:
 
238
            self.setOption(QtGui.QWizard.HaveCustomButton1, True)
 
239
        else:
 
240
            self.setOption(QtGui.QWizard.HaveCustomButton1, False)
232
241
        if self.page(pageId) == self.previewPage:
233
242
            self.updateTheme()
234
243
            frame = self.thememanager.generateImage(self.theme)
235
 
            self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
 
244
            self.previewBoxLabel.setPixmap(frame)
236
245
            self.displayAspectRatio = float(frame.width()) / frame.height()
237
246
            self.resizeEvent()
238
247
 
 
248
    def onCustom1ButtonClicked(self, number):
 
249
        """
 
250
        Generate layout preview and display the form.
 
251
        """
 
252
        self.updateTheme()
 
253
        width = self.thememanager.mainwindow.renderer.width
 
254
        height = self.thememanager.mainwindow.renderer.height
 
255
        pixmap = QtGui.QPixmap(width, height)
 
256
        pixmap.fill(QtCore.Qt.white)
 
257
        paint = QtGui.QPainter(pixmap)
 
258
        paint.setPen(QtGui.QPen(QtCore.Qt.blue, 2))
 
259
        paint.drawRect(self.thememanager.mainwindow.renderer.
 
260
            get_main_rectangle(self.theme))
 
261
        paint.setPen(QtGui.QPen(QtCore.Qt.red, 2))
 
262
        paint.drawRect(self.thememanager.mainwindow.renderer.
 
263
            get_footer_rectangle(self.theme))
 
264
        paint.end()
 
265
        self.themeLayoutForm.exec_(pixmap)
 
266
 
239
267
    def onOutlineCheckCheckBoxStateChanged(self, state):
240
268
        """
241
269
        Change state as Outline check box changed