From 64ab5c29b407e1d13eb4f6e638e04c8442f496f4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 19:17:48 +0000 Subject: [PATCH] Start UI component library - add_welcome_page --- openlp/core/lib/ui.py | 57 +++++++++++++++++++++++++++++++++++ openlp/core/ui/themewizard.py | 4 +-- openlp/core/ui/wizard.py | 27 ++--------------- 3 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 openlp/core/lib/ui.py diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py new file mode 100644 index 000000000..1b4ed206c --- /dev/null +++ b/openlp/core/lib/ui.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`ui` module provides standard UI components for OpenLP. +""" +import logging + +from PyQt4 import QtGui + +log = logging.getLogger(__name__) + +def add_welcome_page(parent, image): + """ + Generate an opening welcome page for a wizard using a provided image. + + ``image`` + A splash image for the wizard. + """ + parent.welcomePage = QtGui.QWizardPage() + parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(image)) + parent.welcomePage.setObjectName(u'WelcomePage') + parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) + parent.welcomeLayout.setObjectName(u'WelcomeLayout') + parent.titleLabel = QtGui.QLabel(parent.welcomePage) + parent.titleLabel.setObjectName(u'TitleLabel') + parent.welcomeLayout.addWidget(parent.titleLabel) + parent.welcomeLayout.addSpacing(40) + parent.informationLabel = QtGui.QLabel(parent.welcomePage) + parent.informationLabel.setWordWrap(True) + parent.informationLabel.setObjectName(u'InformationLabel') + parent.welcomeLayout.addWidget(parent.informationLabel) + parent.welcomeLayout.addStretch() + parent.addPage(parent.welcomePage) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index fe5305454..e8765b9e2 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.ui.wizard import addWelcomePage +from openlp.core.lib.ui import add_welcome_page class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -37,7 +37,7 @@ class Ui_ThemeWizard(object): themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page - addWelcomePage(themeWizard, u':/wizards/wizard_createtheme.bmp') + add_welcome_page(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index f57253d0e..2fa448db8 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -31,6 +31,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, Receiver +from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) @@ -63,7 +64,7 @@ class OpenLPWizard(QtGui.QWizard): self.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) - addWelcomePage(self, image) + add_welcome_page(self, image) self.addCustomPages() self.addProgressPage() self.retranslateUi() @@ -145,27 +146,3 @@ class OpenLPWizard(QtGui.QWizard): self.finishButton.setVisible(True) self.cancelButton.setVisible(False) Receiver.send_message(u'openlp_process_events') - -def addWelcomePage(parent, image): - """ - Generate an opening welcome page for a wizard using a provided image. - - ``image`` - A splash image for the wizard. - """ - parent.welcomePage = QtGui.QWizardPage() - parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(image)) - parent.welcomePage.setObjectName(u'WelcomePage') - parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) - parent.welcomeLayout.setObjectName(u'WelcomeLayout') - parent.titleLabel = QtGui.QLabel(parent.welcomePage) - parent.titleLabel.setObjectName(u'TitleLabel') - parent.welcomeLayout.addWidget(parent.titleLabel) - parent.welcomeLayout.addSpacing(40) - parent.informationLabel = QtGui.QLabel(parent.welcomePage) - parent.informationLabel.setWordWrap(True) - parent.informationLabel.setObjectName(u'InformationLabel') - parent.welcomeLayout.addWidget(parent.informationLabel) - parent.welcomeLayout.addStretch() - parent.addPage(parent.welcomePage)