1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
# -*- coding: utf-8 -*-
#
# (c) Copyright 2001-2015 HP Development Company, L.P.
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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
#
# Author: Don Welch
#
# Std Lib
# Local
from base.g import *
from .ui_utils import load_pixmap
# Qt
from qt import *
class AlignForm(QDialog):
def __init__(self, parent, line_id, orientation, colors, line_count,
choice_count, name = None, modal = 0, fl = 0):
QDialog.__init__(self, parent, name, modal, fl)
# line_id: 'A', 'B', etc.
# orientation: 'v' or 'h'
# colors: 'k' or 'c' or 'kc'
# line_count: 2 or 3
# choice_count: 5, 7, 9, 11, etc. (odd)
mid_point = (choice_count+1)/2
if not name:
self.setProperty("name", QVariant("AlignForm"))
AlignFormLayout = QGridLayout(self,1,1,11,6,"AlignFormLayout")
#self.helpButton = QPushButton(self,"helpButton")
#AlignFormLayout.addWidget(self.helpButton,1,0)
self.CancelButton = QPushButton(self,"CancelButton")
AlignFormLayout.addWidget(self.CancelButton,1,2)
self.ContinueButton = QPushButton(self,"ContinueButton")
AlignFormLayout.addWidget(self.ContinueButton,1,3)
spacer1 = QSpacerItem(270,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
AlignFormLayout.addItem(spacer1,1,1)
self.buttonGroup = QButtonGroup(self,"buttonGroup")
self.buttonGroup.setColumnLayout(0,Qt.Vertical)
self.buttonGroup.layout().setSpacing(6)
self.buttonGroup.layout().setMargin(11)
buttonGroupLayout = QGridLayout(self.buttonGroup.layout())
buttonGroupLayout.setAlignment(Qt.AlignTop)
ChoiceLayout = QHBoxLayout(None,0,6,"ChoiceLayout")
for x in range(1, choice_count+1):
exec('self.radioButton%d = QRadioButton( self.buttonGroup, "radioButton%d" )' % (x, x))
exec('self.radioButton%d.setText( "%s%d" )' % (x, line_id, x))
if x == mid_point:
exec('self.radioButton%d.setChecked( 1 )' % x)
exec('ChoiceLayout.addWidget( self.radioButton%d )' % x)
buttonGroupLayout.addMultiCellLayout(ChoiceLayout, 1, 1, 0, 1)
self.Icon = QLabel(self.buttonGroup,"Icon")
self.Icon.setProperty("sizePolicy",QVariant(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.Icon.sizePolicy().hasHeightForWidth())))
self.Icon.setProperty("scaledContents",QVariant(QVariant(1,0)))
buttonGroupLayout.addWidget(self.Icon,0,0)
self.textLabel2_2 = QLabel(self.buttonGroup,"textLabel2_2")
self.textLabel2_2.setProperty("alignment",QVariant(QLabel.WordBreak | QLabel.AlignVCenter))
buttonGroupLayout.addWidget(self.textLabel2_2,0,1)
AlignFormLayout.addMultiCellWidget(self.buttonGroup,0,0,0,3)
self.languageChange()
self.resize(QSize(608,222).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
self.connect(self.CancelButton,SIGNAL("clicked()"),self,SLOT("reject()"))
self.connect(self.ContinueButton,SIGNAL("clicked()"),self,SLOT("accept()"))
self.connect(self.buttonGroup,SIGNAL("clicked(int)"),self.buttonGroup_clicked)
self.Icon.setPixmap(load_pixmap('%s-%s-%d.png' % (orientation, colors, line_count), 'other'))
self.buttonGroup.setTitle(line_id)
self.value = (choice_count + 1) / 2
def buttonGroup_clicked(self,a0):
self.value = a0 + 1
log.debug(self.value)
def languageChange(self):
self.setProperty("caption",QVariant(self.__tr("HP Device Manager - Alignment")))
#self.helpButton.setProperty("text",QVariant(self.__tr("Help")))
self.CancelButton.setProperty("text",QVariant(self.__tr("Cancel")))
self.ContinueButton.setProperty("text",QVariant(self.__tr("Next >")))
self.buttonGroup.setProperty("title",QVariant(self.__tr("")))
self.textLabel2_2.setProperty("text",QVariant(self.__tr("Choose the set of lines where the line segments are <b>best</b> aligned.")))
def __tr(self,s,c = None):
return qApp.translate("AlignForm",s,c)
|