1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
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.
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.
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
26 from ui_utils import load_pixmap
32 class AlignForm(QDialog):
33 def __init__(self, parent, line_id, orientation, colors, line_count,
34 choice_count, name = None, modal = 0, fl = 0):
35 QDialog.__init__(self, parent, name, modal, fl)
37 # line_id: 'A', 'B', etc.
38 # orientation: 'v' or 'h'
39 # colors: 'k' or 'c' or 'kc'
41 # choice_count: 5, 7, 9, 11, etc. (odd)
42 mid_point = (choice_count+1)/2
45 self.setProperty("name", QVariant("AlignForm"))
47 AlignFormLayout = QGridLayout(self,1,1,11,6,"AlignFormLayout")
49 #self.helpButton = QPushButton(self,"helpButton")
51 #AlignFormLayout.addWidget(self.helpButton,1,0)
53 self.CancelButton = QPushButton(self,"CancelButton")
55 AlignFormLayout.addWidget(self.CancelButton,1,2)
57 self.ContinueButton = QPushButton(self,"ContinueButton")
59 AlignFormLayout.addWidget(self.ContinueButton,1,3)
60 spacer1 = QSpacerItem(270,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
61 AlignFormLayout.addItem(spacer1,1,1)
63 self.buttonGroup = QButtonGroup(self,"buttonGroup")
64 self.buttonGroup.setColumnLayout(0,Qt.Vertical)
65 self.buttonGroup.layout().setSpacing(6)
66 self.buttonGroup.layout().setMargin(11)
68 buttonGroupLayout = QGridLayout(self.buttonGroup.layout())
69 buttonGroupLayout.setAlignment(Qt.AlignTop)
71 ChoiceLayout = QHBoxLayout(None,0,6,"ChoiceLayout")
73 for x in range(1, choice_count+1):
74 exec 'self.radioButton%d = QRadioButton( self.buttonGroup, "radioButton%d" )' % (x, x)
75 exec 'self.radioButton%d.setText( "%s%d" )' % (x, line_id, x)
77 exec 'self.radioButton%d.setChecked( 1 )' % x
78 exec 'ChoiceLayout.addWidget( self.radioButton%d )' % x
80 buttonGroupLayout.addMultiCellLayout(ChoiceLayout, 1, 1, 0, 1)
82 self.Icon = QLabel(self.buttonGroup,"Icon")
83 self.Icon.setProperty("sizePolicy",QVariant(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.Icon.sizePolicy().hasHeightForWidth())))
84 self.Icon.setProperty("scaledContents",QVariant(QVariant(1,0)))
86 buttonGroupLayout.addWidget(self.Icon,0,0)
88 self.textLabel2_2 = QLabel(self.buttonGroup,"textLabel2_2")
89 self.textLabel2_2.setProperty("alignment",QVariant(QLabel.WordBreak | QLabel.AlignVCenter))
91 buttonGroupLayout.addWidget(self.textLabel2_2,0,1)
93 AlignFormLayout.addMultiCellWidget(self.buttonGroup,0,0,0,3)
97 self.resize(QSize(608,222).expandedTo(self.minimumSizeHint()))
98 self.clearWState(Qt.WState_Polished)
100 self.connect(self.CancelButton,SIGNAL("clicked()"),self,SLOT("reject()"))
101 self.connect(self.ContinueButton,SIGNAL("clicked()"),self,SLOT("accept()"))
102 self.connect(self.buttonGroup,SIGNAL("clicked(int)"),self.buttonGroup_clicked)
104 self.Icon.setPixmap(load_pixmap('%s-%s-%d.png' % (orientation, colors, line_count), 'other'))
106 self.buttonGroup.setTitle(line_id)
108 self.value = (choice_count + 1) / 2
110 def buttonGroup_clicked(self,a0):
112 log.debug(self.value)
114 def languageChange(self):
115 self.setProperty("caption",QVariant(self.__tr("HP Device Manager - Alignment")))
116 #self.helpButton.setProperty("text",QVariant(self.__tr("Help")))
117 self.CancelButton.setProperty("text",QVariant(self.__tr("Cancel")))
118 self.ContinueButton.setProperty("text",QVariant(self.__tr("Next >")))
119 self.buttonGroup.setProperty("title",QVariant(self.__tr("")))
120 self.textLabel2_2.setProperty("text",QVariant(self.__tr("Choose the set of lines where the line segments are <b>best</b> aligned.")))
122 def __tr(self,s,c = None):
123 return qApp.translate("AlignForm",s,c)