Tizen 2.1 base
[platform/upstream/hplip.git] / ui4 / loadpapergroupbox.py
1 # -*- coding: utf-8 -*-
2 #
3 # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # Author: Don Welch
20 #
21
22 # Std Lib
23 import sys
24
25 # Local
26 from base.g import *
27 from ui_utils import *
28
29 # Qt
30 from PyQt4.QtCore import *
31 from PyQt4.QtGui import *
32
33
34 LOADPAPER_TYPE_PLAIN_PAPER = 0
35 LOADPAPER_TYPE_PHOTO_PAPER = 1
36
37
38 class LoadPaperGroupBox(QGroupBox):
39     def __init__(self, parent):
40         QWidget.__init__(self, parent)
41
42         self.initUi()
43         self.typ = LOADPAPER_TYPE_PLAIN_PAPER
44         self.button_name = self.__tr("Next >")
45
46
47     def initUi(self):
48         #print "LoadPaperWidget.initUi()"
49
50         self.GridLayout = QGridLayout(self)
51         self.GridLayout.setObjectName("GridLayout")
52
53         self.LoadPaperPix = QLabel(self)
54
55         sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
56         sizePolicy.setHorizontalStretch(0)
57         sizePolicy.setVerticalStretch(0)
58         sizePolicy.setHeightForWidth(self.LoadPaperPix.sizePolicy().hasHeightForWidth())
59         self.LoadPaperPix.setSizePolicy(sizePolicy)
60         self.LoadPaperPix.setMinimumSize(QSize(96,96))
61         self.LoadPaperPix.setMaximumSize(QSize(96,96))
62         #self.LoadPaperPix.setFrameShape(QFrame.Box)
63         self.LoadPaperPix.setObjectName("LoadPaperPix")
64         self.GridLayout.addWidget(self.LoadPaperPix,0,0,1,1)
65
66         spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
67         self.GridLayout.addItem(spacerItem,0,1,1,1)
68
69         self.Text = QLabel(self)
70
71         sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding)
72         sizePolicy.setHorizontalStretch(0)
73         sizePolicy.setVerticalStretch(0)
74         sizePolicy.setHeightForWidth(self.Text.sizePolicy().hasHeightForWidth())
75         self.Text.setSizePolicy(sizePolicy)
76         self.Text.setWordWrap(True)
77         self.Text.setObjectName("Text")
78         self.GridLayout.addWidget(self.Text,0,2,1,1)
79
80         self.LoadPaperPix.setPixmap(load_pixmap("load_paper", "other"))
81
82
83     def updateUi(self):
84         #print "LoadPaperWidget.updateUi()"
85         if self.typ == LOADPAPER_TYPE_PLAIN_PAPER:
86             paper_name = self.__tr("plain paper")
87         else:
88             paper_name = self.__tr("photo paper")
89
90         self.Text.setText(self.__tr("Please load <b>%1</b> in the printer and then click <i>%2</i> to continue.").arg(paper_name).arg(self.button_name))
91
92
93     def setType(self, typ):
94         if typ in (LOADPAPER_TYPE_PHOTO_PAPER, LOADPAPER_TYPE_PHOTO_PAPER):
95             self.typ = typ
96
97
98     def setButtonName(self, b):
99         self.button_name = b
100
101
102     def __tr(self,s,c = None):
103         return qApp.translate("LoadPaperWidget",s,c)