~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to ui4/printsettingstoolbox.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-10-06 15:03:44 UTC
  • mfrom: (1.6.1) (20.1.16 quantal)
  • Revision ID: package-import@ubuntu.com-20121006150344-2p3xz26br0t3hu2q
Tags: 3.12.10-1
* New upstream release
  - Fixes "Network scanning fails (Closes: #683033)
* quilt refresh hplip-syslog-fix-debug-messages-to-error.dpatch
* Fix "error in clean build env" updated debian/rules (Closes: #687129)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
18
#
19
 
# Authors: Don Welch
 
19
# Authors: Don Welch, Yashwant Kumar Sahu, Sanjay Kumar Sharma
20
20
#
21
21
 
22
22
# Std Lib
320
320
        #print "updateUi(%s, %s)" % (cur_device, cur_printer)
321
321
        self.cur_device = cur_device
322
322
        self.cur_printer = cur_printer
323
 
 
 
323
        
324
324
        while self.count():
325
325
            self.removeItem(0)
326
326
 
327
327
        self.loading = True
328
328
        cups.resetOptions()
329
329
        cups.openPPD(self.cur_printer)
 
330
        cur_outputmode = ""
330
331
 
331
332
        try:
332
333
            if 1:
355
356
                    self.job_options['pagerange'] = current
356
357
 
357
358
                    # page set (COMBO/PICKONE)
358
 
                    current = current_options.get('pageset', '')
 
359
                    current = current_options.get('pageset', 'all')
359
360
                    self.addControlRow("pageset", self.__tr("Page Set"),
360
361
                        cups.PPD_UI_PICKONE, current,
361
 
                        [('all', self.__tr("All pages")),
362
 
                         ('even', self.__tr("Even pages")),
363
 
                         ('odd', self.__tr("Odd pages"))], 'all', job_option=True)
 
362
                        [('all', self.__tr("AllPages")),
 
363
                         ('even', self.__tr("Even")),
 
364
                         ('odd', self.__tr("Odd"))], 'all', job_option=True)
364
365
 
365
366
                    self.job_options['pageset'] = current
366
367
#                    if current == u'even':
516
517
 
517
518
                            choice_data.append((c, choice_text))
518
519
 
 
520
                        if o.lower() == 'outputmode':
 
521
                            if value is not None:
 
522
                                cur_outputmode = value
 
523
                            else:
 
524
                                cur_outputmode = defchoice                                
 
525
 
519
526
                        self.addControlRow(o, option_text, ui, value, choice_data, defchoice, read_only)
520
527
 
521
528
                    self.endControlGroup()
769
776
                log.debug("  Current value: %s" % current)
770
777
 
771
778
                self.endControlGroup()
 
779
                
 
780
                #Summary
 
781
                    #color input
 
782
                    #quality
 
783
                quality_attr_name = "OutputModeDPI"
 
784
                cur_outputmode_dpi = cups.findPPDAttribute(quality_attr_name, cur_outputmode)
 
785
                if cur_outputmode_dpi is not None:
 
786
                    log.debug("Adding Group: Summary outputmode is : %s" % cur_outputmode)
 
787
                    log.debug("Adding Group: Summary outputmode dpi is : %s" % unicode (cur_outputmode_dpi))                                    
 
788
                    self.beginControlGroup("sumry", self.__tr("Summary"))
 
789
                    self.addControlRow("colorinput", self.__tr('Color Input / Black Render'),
 
790
                        cups.UI_INFO, unicode (cur_outputmode_dpi), [], read_only)
 
791
                    self.addControlRow("quality", self.__tr('Print Quality'),
 
792
                        cups.UI_INFO, cur_outputmode, [], read_only)
 
793
                    self.endControlGroup()
 
794
                    log.debug("End adding Group: Summary")
 
795
                   
772
796
 
773
797
                self.job_storage_enable = self.cur_device.mq.get('job-storage', JOB_STORAGE_DISABLE) == JOB_STORAGE_ENABLE
774
798
 
910
934
 
911
935
            DefaultButton.setText("Default")
912
936
 
 
937
            #type of 'value' and 'default' can be unicode (ppd values), str, int or boolean, so we need to typecast it to bool for easy comparison
 
938
            if value == True or value == 'True' or value == 'true':
 
939
               value = True;
 
940
            else:
 
941
               value = False;
 
942
 
 
943
            if default == True or default == 'True' or default == 'true':
 
944
               default = True;
 
945
            else:
 
946
               default = False;
 
947
 
913
948
            if value == default:
914
949
                DefaultButton.setEnabled(False)
915
950
            self.connect(DefaultButton, SIGNAL("clicked()"), self.DefaultButton_clicked)
985
1020
#
986
1021
 
987
1022
            self.connect(DefaultButton, SIGNAL("clicked()"), self.DefaultButton_clicked)
 
1023
            self.connect(ComboBox, SIGNAL("currentIndexChanged(const QString &)"), self.ComboBox_indexChanged)            
988
1024
            self.connect(ComboBox, SIGNAL("highlighted(const QString &)"), self.ComboBox_highlighted)
989
1025
 
990
1026
            control = ComboBox
1394
1430
 
1395
1431
            self.connect(self.JobStorageExistingDefaultButton, SIGNAL("clicked()"),
1396
1432
                        self.JobStorageExistingDefaultButton_clicked)
 
1433
                        
 
1434
        elif typ == cups.UI_INFO:
 
1435
            HBoxLayout = QHBoxLayout()
 
1436
            HBoxLayout.setObjectName("HBoxLayout")
 
1437
 
 
1438
            OptionName = QLabel(self.widget)
 
1439
            OptionName.setObjectName("OptionLabel")
 
1440
            HBoxLayout.addWidget(OptionName)
 
1441
            OptionName.setText(text)
 
1442
 
 
1443
            SpacerItem = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
 
1444
            HBoxLayout.addItem(SpacerItem)
 
1445
            
 
1446
            if text == 'Print Quality':
 
1447
                self.PQValueLabel = QLabel(self.widget)
 
1448
                self.PQValueLabel.setObjectName("PQValueLabel")
 
1449
                HBoxLayout.addWidget(self.PQValueLabel)
 
1450
                self.PQValueLabel.setText(value)
 
1451
            elif text == 'Color Input / Black Render':
 
1452
                self.PQColorInputLabel = QLabel(self.widget)
 
1453
                self.PQColorInputLabel.setObjectName("PQColorInputLabel")
 
1454
                HBoxLayout.addWidget(self.PQColorInputLabel)
 
1455
                self.PQColorInputLabel.setText(value)
 
1456
            else:
 
1457
                OptionValue = QLabel(self.widget)
 
1458
                OptionValue.setObjectName("OptionValue")
 
1459
                HBoxLayout.addWidget(OptionValue)
 
1460
                OptionValue.setText(value)
 
1461
                
 
1462
            self.gridlayout.addLayout(HBoxLayout, self.row, 0, 1, 1)
1397
1463
 
1398
1464
        else:
1399
1465
            log.error("Invalid UI value: %s/%s" % (self.group, option))
1527
1593
    def BoolRadioButtons_clicked(self, b): # cups.PPD_UI_BOOLEAN
1528
1594
        sender = self.sender()
1529
1595
        b = int(b)
 
1596
        if sender.default == True or sender.default == "True" or sender.default == "true":
 
1597
            sender.default = int(True)
 
1598
        else:
 
1599
            sender.default = int(False)
1530
1600
 
1531
1601
        if b == sender.default:
1532
1602
            self.removePrinterOption(sender.option)
1539
1609
            else:
1540
1610
                self.setPrinterOption(sender.option, "false")
1541
1611
 
 
1612
    def ComboBox_indexChanged(self, currentItem):
 
1613
        sender = self.sender()
 
1614
        currentItem = unicode(currentItem)
 
1615
        # Checking for summary control
 
1616
        labelPQValaue = getattr(self, 'PQValueLabel', None)
 
1617
        labelPQColorInput = getattr(self, 'PQColorInputLabel', None)
 
1618
        # When output mode combo item is changed, we need to update the summary information      
 
1619
        if currentItem is not None and sender.option == 'OutputMode' and labelPQValaue is not None and labelPQColorInput is not None:
 
1620
            # Setting output mode
 
1621
            self.PQValueLabel.setText(currentItem)
 
1622
            
 
1623
            # Getting DPI custom attributefrom the PPD
 
1624
            # Setting color input
 
1625
            quality_attr_name = "OutputModeDPI"
 
1626
            cups.openPPD(self.cur_printer)
 
1627
            outputmode_dpi = cups.findPPDAttribute(quality_attr_name, currentItem)
 
1628
            log.debug("Outputmode changed, setting outputmode_dpi: %s" % outputmode_dpi)
 
1629
            cups.closePPD()            
 
1630
            self.PQColorInputLabel.setText(outputmode_dpi)
 
1631
            
 
1632
            log.debug("Outputmode changed, setting value outputmode: %s" % currentItem)            
1542
1633
 
1543
1634
    def DefaultButton_clicked(self):
1544
1635
        sender = self.sender()
1545
1636
        sender.setEnabled(False)
1546
1637
 
1547
1638
        if sender.typ == cups.PPD_UI_BOOLEAN: # () On  (*) Off
 
1639
            if sender.default == True or sender.default == 'True' or sender.default == 'true': 
 
1640
                sender.default = True
 
1641
            else:
 
1642
                sender.default = False
1548
1643
            if sender.default:
1549
1644
                sender.control[0].setChecked(True)
1550
1645
                sender.control[0].setFocus(Qt.OtherFocusReason)
1628
1723
 
1629
1724
 
1630
1725
    def PageRangeEdit_editingFinished(self):
1631
 
        sender, x = self.sender(), []
1632
 
        t, ok = unicode(sender.text()), True
 
1726
        sender = self.sender()
 
1727
        t, ok, x = self.job_options['pagerange'], True, []
 
1728
 
 
1729
        #[Sanjay]Start Range Validation here as the editing is finished
1633
1730
        try:
1634
 
            x = utils.expand_range(t)
 
1731
            x = utils.expand_range(t)   
1635
1732
        except ValueError:
1636
1733
            ok = False
1637
1734
 
 
1735
        if t == '':
 
1736
            ok = False
 
1737
 
1638
1738
        if ok:
1639
1739
            if 0 in x:
1640
1740
                ok = False
1645
1745
                        ok = False
1646
1746
                        break
1647
1747
 
1648
 
        if ok:
1649
 
            t = utils.collapse_range(x)
1650
 
            sender.setText(QString(t))
1651
 
            self.job_options['pagerange'] = t
1652
 
 
1653
 
        else:
 
1748
        if not ok:
1654
1749
            self.job_options['pagerange'] = ''
1655
1750
            log.error("Invalid page range: %s" % t)
1656
1751
            FailureUI(self, self.__tr("<b>Invalid page range.</b><p>Please enter a range using page numbers (1-999), dashes, and commas. For example: 1-2,3,5-7</p>"))
1658
1753
 
1659
1754
 
1660
1755
    def PageRangeEdit_textChanged(self, t):
1661
 
        sender, x, t = self.sender(), [], unicode(t)
1662
 
        try:
1663
 
            x = utils.expand_range(t)
1664
 
        except ValueError:
1665
 
            self.job_options['pagerange'] = ''
1666
 
            log.error("Invalid page range: %s" % t)
1667
 
        else:
1668
 
            self.job_options['pagerange'] = t
1669
 
 
 
1756
        self.job_options['pagerange'] = unicode(t) # Do range validation only in PageRangeEdit_editingFinished method
1670
1757
 
1671
1758
    #
1672
1759
    # Job Storage
1942
2029
 
1943
2030
    def __tr(self,s,c = None):
1944
2031
        return qApp.translate("PrintSettingsToolbox",s,c)
 
2032