1
# -*- coding: utf-8 -*-
3
# (c) Copyright 2001-2015 HP 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
19
# Author: Don Welch, Yashwant Kumar Sahu
24
from base import utils
25
from base.sixext import to_unicode
27
from .jobstoragemixin import JobStorageMixin
31
from .scrollview import ScrollView
38
class RangeValidator(QValidator):
39
def __init__(self, parent=None, name=None):
40
QValidator.__init__(self, parent, name)
42
def validate(self, input, pos):
43
for x in to_unicode(input)[pos-1:]:
44
if x not in '0123456789,- ':
45
return QValidator.Invalid, pos
47
return QValidator.Acceptable, pos
50
class OptionComboBox(QComboBox):
51
def __init__(self, rw, parent, name, group, option, choices, default, typ=cups.PPD_UI_PICKONE, other=None):
52
QComboBox.__init__(self, rw, parent, name)
55
self.choices = choices
56
self.default = default
60
def setDefaultPushbutton(self, pushbutton):
61
self.pushbutton = pushbutton
63
def setOther(self, other):
67
class OptionSpinBox(QSpinBox):
68
def __init__(self, parent, name, group, option, default):
69
QSpinBox.__init__(self, parent, name)
72
self.default = default
74
def setDefaultPushbutton(self, pushbutton):
75
self.pushbutton = pushbutton
78
class OptionButtonGroup(QButtonGroup):
79
def __init__(self, parent, name, group, option, default):
80
QButtonGroup.__init__(self, parent, name)
83
self.default = default
85
def setDefaultPushbutton(self, pushbutton):
86
self.pushbutton = pushbutton
89
class DefaultPushButton(QPushButton):
90
def __init__(self, parent, name, group, option, choices, default, control, typ):
91
QPushButton.__init__(self, parent, name)
94
self.default = default
95
self.control = control
97
self.choices = choices
101
class ScrollPrintSettingsView(ScrollView):
102
utils.mixin(JobStorageMixin)
104
def __init__(self, service, parent=None, name=None, fl=0):
105
ScrollView.__init__(self, service, parent, name, fl)
107
self.initJobStorage(True)
111
def fillControls(self):
112
QApplication.setOverrideCursor(QApplication.waitCursor)
114
ScrollView.fillControls(self)
118
cups.openPPD(self.cur_printer)
125
current_options = dict(cups.getOptions())
127
if not self.cur_device.device_type == DEVICE_TYPE_FAX:
128
self.addGroupHeading("basic", self.__tr("Basic"))
129
log.debug("Group: Basic")
132
# PageSize (in PPD section)
133
# orientation-requested
139
current = current_options.get('orientation-requested', '3')
141
self.addItem("basic", "orientation-requested", self.__tr("Page Orientation"),
142
cups.PPD_UI_PICKONE, current,
143
[('3', self.__tr('Portrait')),
144
('4', self.__tr('Landscape')),
145
('5', self.__tr('Reverse landscape')),
146
('6', self.__tr('Reverse portrait'))], '3')
148
log.debug("Option: orientation-requested")
149
log.debug("Current value: %s" % current)
151
duplexer = self.cur_device.dq.get('duplexer', 0)
152
log.debug("Duplexer = %d" % duplexer)
155
current = current_options.get('sides', 'one-sided')
156
self.addItem("basic", "sides",
157
self.__tr("Duplex (Print on both sides of the page)"),
158
cups.PPD_UI_PICKONE, current,
159
[('one-sided',self.__tr('Single sided')),
160
('two-sided-long-edge', self.__tr('Two sided (long edge)')),
161
('two-sided-short-edge', self.__tr('Two sided (short edge)'))], 'one-sided')
163
log.debug("Option: sides")
164
log.debug("Current value: %s" % current)
166
current = current_options.get('outputorder', 'normal')
168
self.addItem("basic", "outputorder",
169
self.__tr("Output Order (Print last page first)"),
170
cups.PPD_UI_PICKONE, current,
171
[('normal', self.__tr('Normal (Print first page first)')),
172
('reverse', self.__tr('Reversed (Print last page first)'))], 'normal')
174
log.debug("Option: outputorder")
175
log.debug("Current value: %s" % current)
177
current = utils.to_bool(current_options.get('Collate', '0'))
179
self.addItem("basic", "Collate",
180
self.__tr("Collate (Group together multiple copies)"),
181
cups.PPD_UI_BOOLEAN, current,
184
log.debug("Option: Collate")
185
log.debug("Current value: %s" % current)
187
groups = cups.getGroupList()
190
log.debug("Group: %s" % repr(g))
192
if 'jobretention' in g.lower():
193
log.debug("HPJobRetention skipped.")
196
text, num_subgroups = cups.getGroup(g)
197
read_only = 'install' in g.lower()
200
text = text.decode('utf-8')
201
except UnicodeDecodeError:
204
if g.lower() == 'printoutmode':
205
text = self.__tr("Quality")
207
self.addGroupHeading(g, text, read_only)
209
log.debug(" Text: %s" % repr(text))
210
log.debug("Num subgroups: %d" % num_subgroups)
212
options = cups.getOptionList(g)
215
log.debug(" Option: %s" % repr(o))
217
if 'pageregion' in o.lower():
218
log.debug("Page Region skipped.")
223
option_text, defchoice, conflicted, ui = cups.getOption(g, o)
226
option_text = option_text.decode('utf-8')
227
except UnicodeDecodeError:
230
if o.lower() == 'quality':
231
option_text = self.__tr("Quality")
233
log.debug(" Text: %s" % repr(option_text))
234
log.debug(" Defchoice: %s" % repr(defchoice))
236
choices = cups.getChoiceList(g, o)
241
log.debug(" Choice: %s" % repr(c))
243
# TODO: Add custom paper size controls
244
if 'pagesize' in o.lower() and 'custom' in c.lower():
245
log.debug("Skipped.")
248
choice_text, marked = cups.getChoice(g, o, c)
251
choice_text = choice_text.decode('utf-8')
252
except UnicodeDecodeError:
255
log.debug(" Text: %s" % repr(choice_text))
260
choice_data.append((c, choice_text))
262
if o.lower() == 'outputmode':
263
if value is not None:
264
cur_outputmode = value
266
cur_outputmode = defchoice
268
self.addItem(g, o, option_text, ui, value, choice_data, defchoice, read_only)
270
## if 'pagesize' in o.lower(): # and 'custom' in c.lower():
272
## width_widget = self.addItem("custom", "custom-width", self.__tr("Custom Paper Width"), cups.UI_UNITS_SPINNER,
273
## current, (0.0, 0.0), 0.0)
276
## height_widget = self.addItem("custom", "custom-height", self.__tr("Custom Paper Height"), cups.UI_UNITS_SPINNER,
277
## current, (0.0, 0.0), 0.0)
279
## if value.lower() == 'custom':
287
self.addGroupHeading("nup",
288
self.__tr("N-Up (Multiple document pages per printed page)"))
290
log.debug("Group: N-Up")
292
current = current_options.get('number-up', '1')
294
self.addItem("nup", "number-up", self.__tr("Pages per Sheet"),
295
cups.PPD_UI_PICKONE, current,
296
[('1', self.__tr('1 page per sheet')),
297
('2', self.__tr('2 pages per sheet')),
298
('4', self.__tr('4 pages per sheet'))], '1')
300
log.debug(" Option: number-up")
301
log.debug(" Current value: %s" % current)
303
current = current_options.get('number-up-layout', 'lrtb')
305
self.addItem("nup", "number-up-layout", self.__tr("Layout"),
306
cups.PPD_UI_PICKONE, current,
307
[('btlr', self.__tr('Bottom to top, left to right')),
308
('btrl', self.__tr('Bottom to top, right to left')),
309
('lrbt', self.__tr('Left to right, bottom to top')),
310
('lrtb', self.__tr('Left to right, top to bottom')),
311
('rlbt', self.__tr('Right to left, bottom to top')),
312
('rltb', self.__tr('Right to left, top to bottom')),
313
('tblr', self.__tr('Top to bottom, left to right')),
314
('tbrl', self.__tr('Top to bottom, right to left')) ], 'lrtb')
316
log.debug(" Option: number-up-layout")
317
log.debug(" Current value: %s" % current)
319
current = current_options.get('page-border', 'none')
321
self.addItem("nup", "page-border",
322
self.__tr("Printed Border Around Each Page"),
323
cups.PPD_UI_PICKONE, current,
324
[('double', self.__tr("Two thin borders")),
325
("double-thick", self.__tr("Two thick borders")),
326
("none", self.__tr("No border")),
327
("single", self.__tr("One thin border")),
328
("single-thick", self.__tr("One thick border"))], 'none')
330
log.debug(" Option: page-border")
331
log.debug(" Current value: %s" % current)
337
if not self.cur_device.device_type == DEVICE_TYPE_FAX:
338
self.addGroupHeading("adjustment", self.__tr("Printout Appearance"))
340
current = int(current_options.get('brightness', 100))
342
log.debug(" Option: brightness")
343
log.debug(" Current value: %s" % current)
345
self.addItem("adjustment", "brightness", self.__tr("Brightness"),
346
cups.UI_SPINNER, current, (0, 200), 100, suffix=" %")
348
current = int(current_options.get('gamma', 1000))
350
log.debug(" Option: gamma")
351
log.debug(" Current value: %s" % current)
353
self.addItem("adjustment", "gamma", self.__tr("Gamma"), cups.UI_SPINNER, current,
363
## # TODO: cupsPPDPageSize() fails on LaserJets. How do we get margins in this case? Defaults?
364
## # PPD file for LJs has a HWMargin entry...
365
## page, page_width, page_len, left, bottom, right, top = cups.getPPDPageSize()
367
## right = page_width - right
368
## top = page_len - top
370
## self.addGroupHeading("margins", self.__tr("Margins"))
371
## current_top = current_options.get('page-top', 0) # pts
372
## current_bottom = current_options.get('page-bottom', 0) # pts
373
## current_left = current_options.get('page-left', 0) # pts
374
## current_right = current_options.get('page-right', 0) # pts
376
## log.debug(" Option: page-top")
377
## log.debug(" Current value: %s" % current_top)
379
## self.addItem("margins", "page-top", self.__tr("Top margin"),
380
## cups.UI_UNITS_SPINNER, current_top,
381
## (0, page_len), top)
383
## self.addItem("margins", "page-bottom", self.__tr("Bottom margin"),
384
## cups.UI_UNITS_SPINNER, current_bottom,
385
## (0, page_len), bottom)
387
## self.addItem("margins", "page-left", self.__tr("Right margin"),
388
## cups.UI_UNITS_SPINNER, current_left,
389
## (0, page_width), left)
391
## self.addItem("margins", "page-right", self.__tr("Left margin"),
392
## cups.UI_UNITS_SPINNER, current_right,
393
## (0, page_width), right)
401
self.addGroupHeading("image", self.__tr("Image Printing"))
403
current = utils.to_bool(current_options.get('fitplot', 'false'))
405
self.addItem("image", "fitplot",
406
self.__tr("Fit to Page"),
407
cups.PPD_UI_BOOLEAN, current,
411
current = current_options.get('position', 'center')
413
self.addItem("image", "position", self.__tr("Position on Page"),
414
cups.PPD_UI_PICKONE, current,
415
[('center', self.__tr('Centered')),
416
('top', self.__tr('Top')),
417
('left', self.__tr('Left')),
418
('right', self.__tr('Right')),
419
('top-left', self.__tr('Top left')),
420
('top-right', self.__tr('Top right')),
421
('bottom', self.__tr('Bottom')),
422
('bottom-left', self.__tr('Bottom left')),
423
('bottom-right', self.__tr('Bottom right'))], 'center')
425
log.debug(" Option: position")
426
log.debug(" Current value: %s" % current)
428
if not self.cur_device.device_type == DEVICE_TYPE_FAX:
429
current = int(current_options.get('saturation', 100))
431
log.debug(" Option: saturation")
432
log.debug(" Current value: %s" % current)
434
self.addItem("image", "saturation", self.__tr("Saturation"),
435
cups.UI_SPINNER, current, (0, 200), 100, suffix=" %")
437
current = int(current_options.get('hue', 0))
439
log.debug(" Option: hue")
440
log.debug(" Current value: %s" % current)
442
self.addItem("image", "hue", self.__tr("Hue (color shift/rotation)"),
443
cups.UI_SPINNER, current,
446
current = int(current_options.get('natural-scaling', 100))
448
log.debug(" Option: natural-scaling")
449
log.debug(" Current value: %s" % current)
451
self.addItem("image", "natural-scaling",
452
self.__tr('"Natural" Scaling (relative to image)'),
453
cups.UI_SPINNER, current, (1, 800), 100, suffix=" %")
455
current = int(current_options.get('scaling', 100))
457
log.debug(" Option: scaling")
458
log.debug(" Current value: %s" % current)
460
self.addItem("image", "scaling", self.__tr("Scaling (relative to page)"),
461
cups.UI_SPINNER, current,
462
(1, 800), 100, suffix=" %")
469
self.addGroupHeading("misc", self.__tr("Miscellaneous"))
471
log.debug("Group: Misc")
473
current = utils.to_bool(current_options.get('prettyprint', '0'))
475
self.addItem("misc", "prettyprint",
476
self.__tr('"Pretty Print" Text Documents (Add headers and formatting)'),
477
cups.PPD_UI_BOOLEAN, current, [], 0)
479
log.debug(" Option: prettyprint")
480
log.debug(" Current value: %s" % current)
482
if not self.cur_device.device_type == DEVICE_TYPE_FAX:
483
current = current_options.get('job-sheets', 'none').split(',')
495
# TODO: Look for locally installed banner pages beyond the default CUPS ones?
496
self.addItem("misc", "job-sheets", self.__tr("Banner Pages"), cups.UI_BANNER_JOB_SHEETS,
498
[("none", self.__tr("No banner page")),
499
('classified', self.__tr("Classified")),
500
('confidential', self.__tr("Confidential")),
501
('secret', self.__tr("Secret")),
502
('standard', self.__tr("Standard")),
503
('topsecret', self.__tr("Top secret")),
504
('unclassified', self.__tr("Unclassified"))], ('none', 'none'))
506
log.debug(" Option: job-sheets")
507
log.debug(" Current value: %s,%s" % (start, end))
509
current = utils.to_bool(current_options.get('mirror', '0'))
511
self.addItem("misc", "mirror", self.__tr('Mirror Printing'),
512
cups.PPD_UI_BOOLEAN, current, [], 0)
514
log.debug(" Option: mirror")
515
log.debug(" Current value: %s" % current)
520
quality_attr_name = "OutputModeDPI"
521
cur_outputmode_dpi = cups.findPPDAttribute(quality_attr_name, cur_outputmode)
522
if cur_outputmode_dpi is not None:
523
log.debug("Adding Group: Summary outputmode is : %s" % cur_outputmode)
524
log.debug("Adding Group: Summary outputmode dpi is : %s" % str (cur_outputmode_dpi))
525
self.addGroupHeading("summry", self.__tr("Summary"))
526
self.addItem("summry", "colorinput", self.__tr('Color Input / Black Render'),
527
cups.UI_INFO, cur_outputmode_dpi, [], 0)
528
self.addItem("summry", "quality", self.__tr('Print Quality'),
529
cups.UI_INFO, cur_outputmode, [], 0)
531
self.job_storage_avail = 0 #self.cur_device.mq['job-storage'] == JOB_STORAGE_ENABLE
533
#print current_options
535
if self.job_storage_avail:
536
self.addGroupHeading("jobstorage", self.__tr("Job Storage and Secure Printing"))
537
self.addJobStorage(current_options)
540
#except Exception, e:
547
QApplication.restoreOverrideCursor()
549
def ComboBox_indexChanged(self, currentItem):
550
sender = self.sender()
551
currentItem = to_unicode(currentItem)
552
# Checking for summary control
553
labelPQValaue = getattr(self, 'PQValueLabel', None)
554
labelPQColorInput = getattr(self, 'PQColorInputLabel', None)
555
# When output mode combo item is changed, we need to update the summary information
556
if currentItem is not None and sender.option == 'OutputMode' and labelPQValaue is not None and labelPQColorInput is not None:
557
# Setting output mode
558
self.PQValueLabel.setText(currentItem)
560
# Getting DPI custom attributefrom the PPD
561
# Setting color input
562
quality_attr_name = "OutputModeDPI"
563
cups.openPPD(self.cur_printer)
564
outputmode_dpi = cups.findPPDAttribute(quality_attr_name, currentItem)
565
log.debug("Outputmode changed, setting outputmode_dpi: %s" % outputmode_dpi)
567
self.PQColorInputLabel.setText(outputmode_dpi)
569
log.debug("Outputmode changed, setting value outputmode: %s" % currentItem)
571
def optionComboBox_activated(self, a):
573
sender = self.sender()
576
if sender.typ == cups.UI_BANNER_JOB_SHEETS:
577
start, end = None, None
578
for c, t in sender.choices:
583
for c, t in sender.other.choices:
584
if t == sender.other.currentText():
588
if sender.option == 'end':
589
start, end = end, start
591
if start is not None and \
592
end is not None and \
593
start.lower() == sender.default[0].lower() and \
594
end.lower() == sender.default[1].lower():
595
self.removePrinterOption('job-sheets')
596
sender.pushbutton.setEnabled(False)
598
sender.pushbutton.setEnabled(True)
600
if start is not None and \
603
self.setPrinterOption('job-sheets', ','.join([start, end]))
607
for c, t in sender.choices:
612
if choice is not None and choice.lower() == sender.default.lower():
613
self.removePrinterOption(sender.option)
614
sender.pushbutton.setEnabled(False)
616
sender.pushbutton.setEnabled(True)
618
if choice is not None:
619
self.setPrinterOption(sender.option, choice)
621
self.linkPrintoutModeAndQuality(sender.option, choice)
624
def linkPrintoutModeAndQuality(self, option, choice):
625
if option.lower() == 'quality' and \
629
c = self.items['o:PrintoutMode'].control
634
if choice.lower() == 'fromprintoutmode':
635
# from printoutmode selected
636
# determine printoutmode option combo enable state
639
a = to_unicode(c.currentText())
641
# determine printoutmode default button state
643
for x, t in c.choices:
648
if link_choice is not None and \
649
link_choice.lower() == c.default.lower():
651
c.pushbutton.setEnabled(False)
653
c.pushbutton.setEnabled(True)
655
else: # fromprintoutmode not selected, disable printoutmode
657
QToolTip.add(c, self.__tr("""Set Quality to "Controlled by 'Printout Mode'" to enable."""))
658
c.pushbutton.setEnabled(False)
662
def optionSpinBox_valueChanged(self, i):
663
sender = self.sender()
665
if i == sender.default:
666
self.removePrinterOption(sender.option)
667
sender.pushbutton.setEnabled(False)
669
sender.pushbutton.setEnabled(True)
670
self.setPrinterOption(sender.option, str(i))
673
def optionButtonGroup_clicked(self, b):
674
sender = self.sender()
677
if b == sender.default:
678
self.removePrinterOption(sender.option)
679
sender.pushbutton.setEnabled(False)
681
sender.pushbutton.setEnabled(True)
684
self.setPrinterOption(sender.option, "true")
686
self.setPrinterOption(sender.option, "false")
690
def defaultPushButton_clicked(self):
691
sender = self.sender()
692
sender.setEnabled(False)
694
if sender.typ == cups.PPD_UI_BOOLEAN:
696
sender.control.setButton(1)
698
sender.control.setButton(0)
700
self.removePrinterOption(sender.option)
702
elif sender.typ == cups.PPD_UI_PICKONE:
703
choice, text = None, None
705
for c, t in sender.choices:
706
if c == sender.default:
711
if choice is not None:
712
self.removePrinterOption(sender.option)
713
sender.control.setCurrentText(text)
715
self.linkPrintoutModeAndQuality(sender.option, choice)
717
elif sender.typ == cups.UI_SPINNER:
718
sender.control.setValue(sender.default)
719
self.removePrinterOption(sender.option)
721
elif sender.typ == cups.UI_BANNER_JOB_SHEETS:
722
start, end, start_text, end_text = None, None, None, None
723
for c, t in sender.choices:
724
if c == sender.default[0]:
728
if c == sender.default[1]:
732
if start is not None:
733
sender.control[0].setCurrentText(start_text)
736
sender.control[1].setCurrentText(end_text)
738
self.removePrinterOption('job-sheets')
741
def setPrinterOption(self, option, value):
742
cups.openPPD(self.cur_printer)
745
cups.addOption("%s=%s" % (option, value))
750
def removePrinterOption(self, option):
751
cups.openPPD(self.cur_printer)
754
cups.removeOption(option)
760
def addItem(self, group, option, text, typ, value, choices, default, read_only=False, suffix=""):
761
widget, control = None, None
763
if typ == cups.PPD_UI_BOOLEAN: # () On (*) Off widget
764
widget = self.getWidget()
765
layout = QGridLayout(widget, 1, 1, 5, 10, "layout")
766
default = int(utils.to_bool(str(default)))
767
value = int(utils.to_bool(str(value)))
769
textLabel1 = QLabel(widget, "textLabel1")
770
layout.addWidget(textLabel1, 0, 0)
772
buttonGroup = OptionButtonGroup(widget, "buttonGroup", group, option, default)
773
buttonGroup.setLineWidth(0)
774
buttonGroup.setColumnLayout(0,Qt.Vertical)
775
buttonGroup.layout().setSpacing(1)
776
buttonGroup.layout().setMargin(5)
777
buttonGroupLayout = QHBoxLayout(buttonGroup.layout())
778
buttonGroupLayout.setAlignment(Qt.AlignTop)
780
defaultPushButton = DefaultPushButton(widget,"defaultPushButton", group, option,
781
choices, default, buttonGroup, typ)
783
buttonGroup.setDefaultPushbutton(defaultPushButton)
785
layout.addWidget(defaultPushButton, 0, 3)
787
spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
788
layout.addItem(spacer1, 0, 1)
790
onRadioButton = QRadioButton(buttonGroup,"onRadioButton")
791
buttonGroup.insert(onRadioButton, 1)
792
buttonGroupLayout.addWidget(onRadioButton)
794
offRadioButton = QRadioButton(buttonGroup,"offRadioButton")
795
buttonGroup.insert(offRadioButton, 0)
796
buttonGroupLayout.addWidget(offRadioButton)
798
layout.addWidget(buttonGroup, 0, 2)
800
textLabel1.setText(text)
801
onRadioButton.setText(self.__tr("On"))
802
offRadioButton.setText(self.__tr("Off"))
805
defaultPushButton.setEnabled(False)
807
self.connect(defaultPushButton, SIGNAL("clicked()"), self.defaultPushButton_clicked)
808
self.connect(buttonGroup, SIGNAL("clicked(int)"), self.optionButtonGroup_clicked)
815
buttonGroup.setButton(1)
817
buttonGroup.setButton(0)
820
onRadioButton.setEnabled(False)
821
offRadioButton.setEnabled(False)
822
defaultPushButton.setEnabled(False)
824
QToolTip.add(defaultPushButton, self.__tr('Set to default value of "%1".').arg(x))
826
defaultPushButton.setText("Default")
828
elif typ == cups.PPD_UI_PICKONE: # Combo box widget
829
widget = self.getWidget()
831
layout1 = QHBoxLayout(widget,5,10,"layout1")
833
textLabel1 = QLabel(widget,"textLabel1")
834
layout1.addWidget(textLabel1)
836
spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
837
layout1.addItem(spacer1)
839
optionComboBox = OptionComboBox(0, widget, "optionComboBox", group, option, choices, default)
840
layout1.addWidget(optionComboBox)
842
defaultPushButton = DefaultPushButton(widget,"defaultPushButton", group, option,
843
choices, default, optionComboBox, typ)
845
optionComboBox.setDefaultPushbutton(defaultPushButton)
847
layout1.addWidget(defaultPushButton)
849
textLabel1.setText(text)
850
defaultPushButton.setText("Default")
855
if value is not None and d == value.lower():
858
if d == default.lower():
861
optionComboBox.insertItem(t)
864
optionComboBox.setCurrentText(x)
866
if value is not None and value.lower() == default.lower():
867
defaultPushButton.setEnabled(False)
869
self.linkPrintoutModeAndQuality(option, value)
872
optionComboBox.setEnabled(False)
873
defaultPushButton.setEnabled(False)
875
QToolTip.add(defaultPushButton, self.__tr('Set to default value of "%1".').arg(y))
877
self.connect(defaultPushButton, SIGNAL("clicked()"), self.defaultPushButton_clicked)
878
self.connect(optionComboBox, SIGNAL("activated(const QString&)"), self.optionComboBox_activated)
879
self.connect(optionComboBox, SIGNAL("activated(const QString &)"), self.ComboBox_indexChanged)
881
control = optionComboBox
883
elif typ == cups.UI_SPINNER: # Spinner widget
884
widget = self.getWidget()
886
layout1 = QHBoxLayout(widget,5,10, "layout1")
888
textLabel1 = QLabel(widget, "textLabel1")
889
layout1.addWidget(textLabel1)
891
spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
892
layout1.addItem(spacer1)
894
optionSpinBox = OptionSpinBox(widget,"optionSpinBox", group, option, default)
895
layout1.addWidget(optionSpinBox)
897
defaultPushButton = DefaultPushButton(widget, "defaultPushButton", group, option, choices,
898
default, optionSpinBox, typ)
900
optionSpinBox.setDefaultPushbutton(defaultPushButton)
902
layout1.addWidget(defaultPushButton)
905
optionSpinBox.setMinValue(min)
906
optionSpinBox.setMaxValue(max)
907
optionSpinBox.setValue(value)
910
optionSpinBox.setSuffix(suffix)
912
textLabel1.setText(text)
913
defaultPushButton.setText("Default")
915
self.connect(optionSpinBox, SIGNAL("valueChanged(int)"), self.optionSpinBox_valueChanged)
916
self.connect(defaultPushButton, SIGNAL("clicked()"), self.defaultPushButton_clicked)
919
defaultPushButton.setEnabled(False)
922
self.optionSpinBox.setEnabled(False)
923
self.defaultPushButton.setEnabled()
925
QToolTip.add(defaultPushButton,
926
self.__tr('Set to default value of "%1".').arg(default))
928
elif typ == cups.UI_BANNER_JOB_SHEETS: # Job sheets widget
929
widget = self.getWidget()
931
layout1 = QGridLayout(widget,1,1,5,10,"layout1")
933
startComboBox = OptionComboBox(0, widget, "startComboBox", group,
934
"start", choices, default, typ)
936
layout1.addWidget(startComboBox,0,3)
938
startTextLabel = QLabel(widget,"startTextLabel")
939
layout1.addWidget(startTextLabel,0,2)
941
endTextLabel = QLabel(widget,"endTextLabel")
942
layout1.addWidget(endTextLabel,0,4)
944
endComboBox = OptionComboBox(0, widget, "endComboBox", group, "end", choices,
945
default, typ, startComboBox)
947
layout1.addWidget(endComboBox,0,5)
949
startComboBox.setOther(endComboBox)
951
defaultPushButton = DefaultPushButton(widget, "defaultPushButton", group, option, choices,
952
default, (startComboBox, endComboBox), typ)
954
layout1.addWidget(defaultPushButton,0,6)
956
startComboBox.setDefaultPushbutton(defaultPushButton)
957
endComboBox.setDefaultPushbutton(defaultPushButton)
959
textLabel1 = QLabel(widget,"textLabel1")
960
layout1.addWidget(textLabel1,0,0)
962
spacer1 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
963
layout1.addItem(spacer1,0,1)
965
textLabel1.setText(text)
966
defaultPushButton.setText("Default")
968
startTextLabel.setText(self.__tr("Start:"))
969
endTextLabel.setText(self.__tr("End:"))
971
s, e, y, z = None, None, None, None
974
if value is not None:
975
if d == value[0].lower():
978
if d == value[1].lower():
981
if d == default[0].lower():
984
if d == default[1].lower():
987
startComboBox.insertItem(t)
988
endComboBox.insertItem(t)
991
startComboBox.setCurrentText(s)
994
endComboBox.setCurrentText(e)
996
if value is not None and \
997
value[0].lower() == default[0].lower() and \
998
value[1].lower() == default[1].lower():
1000
defaultPushButton.setEnabled(False)
1002
if y is not None and z is not None:
1003
QToolTip.add(defaultPushButton, self.__tr('Set to default value of "Start: %1, End: %2".').arg(y).arg(z))
1005
self.connect(startComboBox, SIGNAL("activated(const QString&)"), self.optionComboBox_activated)
1006
self.connect(endComboBox, SIGNAL("activated(const QString&)"), self.optionComboBox_activated)
1007
self.connect(defaultPushButton, SIGNAL("clicked()"), self.defaultPushButton_clicked)
1009
elif typ == cups.PPD_UI_PICKMANY:
1010
log.error("Unrecognized type: pickmany")
1012
elif typ == cups.UI_UNITS_SPINNER:
1013
widget = self.getWidget()
1015
layout1 = QHBoxLayout(widget,5,10,"layout1")
1017
textLabel1 = QLabel(widget,"textLabel1")
1018
layout1.addWidget(textLabel1)
1020
spacer1 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
1021
layout1.addItem(spacer1)
1023
lineEdit1 = QLineEdit(widget,"lineEdit1")
1024
layout1.addWidget(lineEdit1)
1026
comboBox1 = QComboBox(0,widget,"comboBox1")
1027
layout1.addWidget(comboBox1)
1029
defaultPushButton = QPushButton(widget,"defaultPushButton")
1030
layout1.addWidget(defaultPushButton)
1032
textLabel1.setText(text)
1033
defaultPushButton.setText("Default")
1035
elif typ == cups.UI_INFO:
1036
widget = self.getWidget()
1038
layout1 = QHBoxLayout(widget,5,10,"layout1")
1040
textPropName = QLabel(widget,"textPropName")
1041
layout1.addWidget(textPropName)
1042
textPropName.setText(text)
1044
spacer1 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
1045
layout1.addItem(spacer1)
1047
if text == 'Print Quality':
1048
self.PQValueLabel = QLabel(widget,"textPropValue")
1049
layout1.addWidget(self.PQValueLabel)
1050
self.PQValueLabel.setText(value)
1051
elif text == 'Color Input / Black Render':
1052
self.PQColorInputLabel = QLabel(widget,"textPropValue")
1053
layout1.addWidget(self.PQColorInputLabel)
1054
self.PQColorInputLabel.setText(value)
1056
textPropValue = QLabel(widget,"textPropValue")
1057
layout1.addWidget(textPropValue)
1058
textPropValue.setText(value)
1061
log.error("Invalid UI value: %s/%s" % (group, option))
1063
if widget is not None:
1064
self.addWidget(widget, "o:"+option, control)
1069
def __tr(self,s,c = None):
1070
return qApp.translate("ScrollPrintSettingsView",s,c)