1.2.16
by Till Kamppeter
Import upstream version 2.8.5 |
1 |
# -*- coding: utf-8 -*-
|
2 |
#
|
|
3 |
# (c) Copyright 2001-2007 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 |
# Local
|
|
23 |
from base.g import * |
|
24 |
from base import utils |
|
25 |
from prnt import cups |
|
26 |
||
27 |
# Qt
|
|
28 |
from qt import * |
|
29 |
||
30 |
class PINValidator(QValidator): |
|
31 |
def __init__(self, parent=None, name=None): |
|
32 |
QValidator.__init__(self, parent, name) |
|
33 |
||
34 |
def validate(self, input, pos): |
|
35 |
for x in unicode(input)[pos-1:]: |
|
36 |
if x not in u'0123456789': |
|
37 |
return QValidator.Invalid, pos |
|
38 |
||
39 |
return QValidator.Acceptable, pos |
|
40 |
||
41 |
class TextValidator(QValidator): |
|
42 |
def __init__(self, parent=None, name=None): |
|
43 |
QValidator.__init__(self, parent, name) |
|
44 |
||
45 |
def validate(self, input, pos): |
|
46 |
for x in unicode(input)[pos-1:]: |
|
47 |
if x not in u'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -': |
|
48 |
return QValidator.Invalid, pos |
|
49 |
||
50 |
return QValidator.Acceptable, pos |
|
51 |
||
52 |
||
53 |
class JobStorageMixin(object): |
|
54 |
def __init__(self): |
|
55 |
pass
|
|
56 |
||
57 |
def initJobStorage(self, print_settings_mode=False): |
|
58 |
self.print_settings_mode = print_settings_mode |
|
59 |
self.job_storage_mode = JOB_STORAGE_TYPE_OFF |
|
60 |
self.job_storage_pin = u"0000" |
|
61 |
self.job_storage_use_pin = False |
|
62 |
self.job_storage_username = unicode(prop.username[:16]) |
|
63 |
self.job_storage_auto_username = True |
|
64 |
self.job_storage_jobname = u"Untitled" |
|
65 |
self.job_storage_auto_jobname = True |
|
66 |
self.job_storage_job_exist = 0 |
|
67 |
||
68 |
||
69 |
def addJobStorage(self, current_options=None): |
|
70 |
self.addJobStorageMode() |
|
71 |
self.addJobStoragePIN() |
|
72 |
self.addJobStorageUsername() |
|
73 |
self.addJobStorageID() |
|
74 |
self.addJobStorageIDExists() |
|
75 |
self.jobStorageDisable() |
|
76 |
||
77 |
if current_options is None: |
|
78 |
cups.resetOptions() |
|
79 |
cups.openPPD(self.cur_printer) |
|
80 |
current_options = dict(cups.getOptions()) |
|
81 |
cups.closePPD() |
|
82 |
||
83 |
self.job_storage_pin = unicode(current_options.get('HOLDKEY', '0000')[:4]) |
|
84 |
self.jobStoragePINEdit.setText(self.job_storage_pin) |
|
85 |
||
86 |
self.job_storage_username = unicode(current_options.get('USERNAME', prop.username)[:16]) |
|
87 |
self.jobStorageUsernameEdit.setText(self.job_storage_username) |
|
88 |
||
89 |
self.job_storage_jobname = unicode(current_options.get('JOBNAME', u"Untitled")[:16]) |
|
90 |
self.jobStorageIDEdit.setText(self.job_storage_jobname) |
|
91 |
||
92 |
hold = current_options.get('HOLD', 'OFF') |
|
93 |
holdtype = current_options.get('HOLDTYPE', 'PUBLIC') |
|
94 |
||
95 |
if hold == 'OFF': |
|
96 |
self.job_storage_mode = JOB_STORAGE_TYPE_OFF |
|
97 |
||
98 |
elif hold == 'ON': |
|
99 |
if holdtype == 'PUBLIC': |
|
100 |
self.job_storage_mode = JOB_STORAGE_TYPE_QUICK_COPY |
|
101 |
||
102 |
else: # 'PRIVATE' |
|
103 |
self.job_storage_mode = JOB_STORAGE_TYPE_PERSONAL |
|
104 |
self.job_storage_use_pin = True |
|
105 |
||
106 |
elif hold == 'PROOF': |
|
107 |
if holdtype == 'PUBLIC': |
|
108 |
self.job_storage_mode = JOB_STORAGE_TYPE_PROOF_AND_HOLD |
|
109 |
else: |
|
110 |
self.job_storage_mode = JOB_STORAGE_TYPE_PERSONAL |
|
111 |
self.job_storage_use_pin = True |
|
112 |
||
113 |
elif hold == 'STORE': |
|
114 |
self.job_storage_mode = JOB_STORAGE_TYPE_STORE |
|
115 |
self.job_storage_use_pin = (holdtype == 'PRIVATE') |
|
116 |
||
117 |
self.jobStorageModeComboBox.setCurrentItem(self.job_storage_mode) |
|
118 |
self.jobStorageModeDefaultPushButton.setEnabled(self.job_storage_mode != JOB_STORAGE_TYPE_OFF) |
|
119 |
self.setModeTooltip() |
|
120 |
self.setPrinterOptionHold() |
|
121 |
||
122 |
duplicate = current_options.get('DUPLICATEJOB', 'REPLACE') |
|
123 |
||
124 |
if duplicate == 'REPLACE': |
|
125 |
self.job_storage_job_exist = 0 |
|
126 |
else: |
|
127 |
self.job_storage_job_exist = 1 |
|
128 |
||
129 |
self.jobStorageIDExistsComboBox.setCurrentItem(self.job_storage_job_exist) |
|
130 |
self.setPrinterOptionIDExists() |
|
131 |
||
132 |
#
|
|
133 |
||
134 |
if self.job_storage_mode == JOB_STORAGE_TYPE_OFF: |
|
135 |
self.jobStorageDisable() |
|
136 |
else: |
|
137 |
self.jobStorageUserJobEnable() |
|
138 |
self.setPrinterOptionID() |
|
139 |
self.setPrinterOptionPIN() |
|
140 |
self.setPrinterOptionUsername() |
|
141 |
||
142 |
self.jobStoragePINButtonGroup.setButton(self.job_storage_use_pin) |
|
143 |
self.jobStoragePINEnable(self.job_storage_mode in (JOB_STORAGE_TYPE_PERSONAL, JOB_STORAGE_TYPE_STORE)) |
|
144 |
||
145 |
||
146 |
def addJobStorageMode(self): |
|
147 |
widget = self.getWidget() |
|
148 |
||
149 |
layout34 = QHBoxLayout(widget,5,10,"layout34") |
|
150 |
||
151 |
self.jobStorageModeLabel = QLabel(widget,"jobStorageModeLabel") |
|
152 |
layout34.addWidget(self.jobStorageModeLabel) |
|
153 |
spacer20_4 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) |
|
154 |
layout34.addItem(spacer20_4) |
|
155 |
||
156 |
self.jobStorageModeComboBox = QComboBox(0,widget,"jobStorageModeComboBox") |
|
157 |
layout34.addWidget(self.jobStorageModeComboBox) |
|
158 |
||
159 |
self.jobStorageModeDefaultPushButton = QPushButton(widget,"pagesetDefaultPushButton") |
|
160 |
layout34.addWidget(self.jobStorageModeDefaultPushButton) |
|
161 |
||
162 |
self.jobStorageModeLabel.setText(self.__tr("Job Storage Mode:")) |
|
163 |
self.jobStorageModeComboBox.clear() |
|
164 |
self.jobStorageModeComboBox.insertItem(self.__tr("Off")) |
|
165 |
self.jobStorageModeComboBox.insertItem(self.__tr("Proof and Hold")) |
|
166 |
self.jobStorageModeComboBox.insertItem(self.__tr("Personal/Private Job")) |
|
167 |
self.jobStorageModeComboBox.insertItem(self.__tr("Quick Copy")) |
|
168 |
self.jobStorageModeComboBox.insertItem(self.__tr("Stored Job")) |
|
169 |
||
170 |
self.jobStorageModeDefaultPushButton.setText(self.__tr("Default")) |
|
171 |
self.jobStorageModeDefaultPushButton.setEnabled(False) |
|
172 |
||
173 |
self.connect(self.jobStorageModeComboBox, SIGNAL("activated(int)"), self.jobStorageModeComboBox_activated) |
|
174 |
self.connect(self.jobStorageModeDefaultPushButton, SIGNAL("clicked()"), self.jobStorageModeDefaultPushButton_clicked) |
|
175 |
||
176 |
self.addWidget(widget, "job_storage_mode") |
|
177 |
||
178 |
def jobStorageModeComboBox_activated(self, a): |
|
179 |
#print a
|
|
180 |
self.job_storage_mode = a |
|
181 |
self.jobStorageModeDefaultPushButton.setEnabled(a != JOB_STORAGE_TYPE_OFF) |
|
182 |
||
183 |
if a == JOB_STORAGE_TYPE_OFF: |
|
184 |
#print "off!"
|
|
185 |
self.jobStorageDisable() |
|
186 |
else: |
|
187 |
self.jobStorageUserJobEnable() |
|
188 |
||
189 |
self.setPrinterOptionHold() |
|
190 |
self.jobStoragePINEnable(a in (JOB_STORAGE_TYPE_PERSONAL, JOB_STORAGE_TYPE_STORE)) |
|
191 |
self.setModeTooltip() |
|
192 |
||
193 |
||
194 |
def setModeTooltip(self): |
|
195 |
QToolTip.remove(self.jobStorageModeComboBox) |
|
196 |
||
197 |
if self.job_storage_mode == JOB_STORAGE_TYPE_OFF: |
|
198 |
QToolTip.add(self.jobStorageModeComboBox, |
|
199 |
self.__tr("""Your job will be printed but not stored on the printer.""")) |
|
200 |
||
201 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_PERSONAL: |
|
202 |
QToolTip.add(self.jobStorageModeComboBox, |
|
203 |
self.__tr("""Your job will be stored on the printer and nothing will be printed until you request the job from the printer's control panel.<br>Once the job is printed, it will automatically be removed from the printer's job storage. For Private print jobs, add a 4-digit PIN.""")) |
|
204 |
||
205 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_PROOF_AND_HOLD: |
|
206 |
QToolTip.add(self.jobStorageModeComboBox, |
|
207 |
self.__tr("""When multiples copies are requested, the first copy will be printed.<br>The remaining copies will be held on the printer until you release them using the printer's control panel.""")) |
|
208 |
||
209 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_QUICK_COPY: |
|
210 |
QToolTip.add(self.jobStorageModeComboBox, |
|
211 |
self.__tr("""After your job prints, you can use the printer's control panel to print additional copies of your job.""")) |
|
212 |
||
213 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_STORE: |
|
214 |
QToolTip.add(self.jobStorageModeComboBox, |
|
215 |
self.__tr("""Your job will not immediately print, but instead be stored in the printer. <br>You can request copies of this job from the printer's control panel. Use this for storage of forms and other common or shared documents.""")) |
|
216 |
||
217 |
||
218 |
def setPrinterOptionHold(self): |
|
219 |
if self.print_settings_mode: |
|
220 |
if self.job_storage_mode == JOB_STORAGE_TYPE_OFF: |
|
221 |
#print "off!!!"
|
|
222 |
self.setPrinterOption('HOLD', 'OFF') |
|
223 |
self.removePrinterOption('HOLDTYPE') |
|
224 |
self.removePrinterOption('HOLDKEY') |
|
225 |
self.removePrinterOption('USERNAME') |
|
226 |
self.removePrinterOption('JOBNAME') |
|
227 |
self.removePrinterOption('DUPLICATEJOB') |
|
228 |
||
229 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_PROOF_AND_HOLD: |
|
230 |
#print "proof"
|
|
231 |
self.job_storage_use_pin = False |
|
232 |
self.setPrinterOption('HOLD', 'PROOF') |
|
233 |
self.removePrinterOption('HOLDTYPE') |
|
234 |
self.removePrinterOption('HOLDKEY') |
|
235 |
||
236 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_PERSONAL: |
|
237 |
#print "personal"
|
|
238 |
#self.setPrinterOption('HOLDTYPE', 'PRIVATE')
|
|
239 |
||
240 |
if self.job_storage_use_pin: |
|
241 |
self.setPrinterOption('HOLD', 'ON') |
|
242 |
self.setPrinterOption('HOLDTYPE', 'PRIVATE') |
|
243 |
else: |
|
244 |
self.setPrinterOption('HOLD', 'PROOF') |
|
245 |
self.setPrinterOption('HOLDTYPE', 'PUBLIC') |
|
246 |
self.removePrinterOption('HOLDKEY') |
|
247 |
||
248 |
||
249 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_QUICK_COPY: |
|
250 |
#print "qc"
|
|
251 |
self.job_storage_use_pin = False |
|
252 |
self.setPrinterOption('HOLD', 'ON') |
|
253 |
self.setPrinterOption('HOLDTYPE', 'PUBLIC') |
|
254 |
self.removePrinterOption('HOLDKEY') |
|
255 |
||
256 |
elif self.job_storage_mode == JOB_STORAGE_TYPE_STORE: |
|
257 |
#print "store"
|
|
258 |
||
259 |
self.setPrinterOption('HOLD', 'STORE') |
|
260 |
||
261 |
if self.job_storage_use_pin: |
|
262 |
self.setPrinterOption('HOLDTYPE', 'PRIVATE') |
|
263 |
else: |
|
264 |
self.removePrinterOption('HOLDTYPE') |
|
265 |
self.removePrinterOption('HOLDKEY') |
|
266 |
||
267 |
||
268 |
def jobStorageModeDefaultPushButton_clicked(self): |
|
269 |
self.jobStorageModeComboBox.setCurrentItem(0) |
|
270 |
self.job_storage_mode = JOB_STORAGE_TYPE_OFF |
|
271 |
self.setPrinterOptionHold() |
|
272 |
self.setModeTooltip() |
|
273 |
||
274 |
def jobStorageDisable(self): # Off: Turn off all options |
|
275 |
self.jobStorageModeDefaultPushButton.setEnabled(False) |
|
276 |
self.jobStoragePINEnable(False) |
|
277 |
self.jobStorageUserJobEnable(False) |
|
278 |
#self.setPrinterOptionHold()
|
|
279 |
||
280 |
def jobStoragePINEnable(self, e=True): # PIN On/Off |
|
281 |
t = e and self.jobStoragePINButtonGroup.selectedId() == 1 |
|
282 |
self.jobStoragePINButtonGroup.setEnabled(e) |
|
283 |
self.jobStoragePINEdit.setEnabled(t) |
|
284 |
self.jobStoragePINDefaultPushButton.setEnabled(t) |
|
285 |
self.setPrinterOptionPIN() |
|
286 |
||
287 |
def jobStorageUserJobEnable(self, e=True): # Username/Job ID/Job ID Exists On/Off |
|
288 |
t = e and self.jobStorageUsernameButtonGroup.selectedId() == 1 |
|
289 |
self.jobStorageUsernameButtonGroup.setEnabled(e) |
|
290 |
self.jobStorageUsernameDefaultPushButton.setEnabled(t) |
|
291 |
self.jobStorageUsernameEdit.setEnabled(t) |
|
292 |
if e: self.setPrinterOptionUsername() |
|
293 |
||
294 |
t = e and self.jobStorageIDButtonGroup.selectedId() == 1 |
|
295 |
self.jobStorageIDButtonGroup.setEnabled(e) |
|
296 |
self.jobStorageIDDefaultPushButton.setEnabled(t) |
|
297 |
self.jobStorageIDEdit.setEnabled(t) |
|
298 |
if e: self.setPrinterOptionID() |
|
299 |
||
300 |
t = e and self.jobStorageIDExistsComboBox.currentItem() == 1 |
|
301 |
self.jobStorageIDExistsComboBox.setEnabled(e) |
|
302 |
self.jobStorageIDExistsDefaultPushButton.setEnabled(t) |
|
303 |
if e: self.setPrinterOptionIDExists() |
|
304 |
||
305 |
||
306 |
# PIN
|
|
307 |
||
308 |
||
309 |
def addJobStoragePIN(self): |
|
310 |
widget = self.getWidget() |
|
311 |
||
312 |
layout39 = QGridLayout(widget,1,1,5,10,"layout39") |
|
313 |
||
314 |
self.jobStoragePINEdit = QLineEdit(widget,"self.jobStoragePINEdit") |
|
315 |
self.jobStoragePINEdit.setMaxLength(4) |
|
316 |
self.jobStoragePINEdit.setInputMask(QString("9999")) |
|
317 |
self.jobStoragePINEdit.setText(self.job_storage_pin) |
|
318 |
layout39.addWidget(self.jobStoragePINEdit,0,3) |
|
319 |
||
320 |
spacer20_2 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) |
|
321 |
layout39.addItem(spacer20_2,0,1) |
|
322 |
||
323 |
textLabel5_2 = QLabel(widget,"textLabel5_2") |
|
324 |
layout39.addWidget(textLabel5_2,0,0) |
|
325 |
||
326 |
self.jobStoragePINDefaultPushButton = QPushButton(widget,"jobStoragePINDefaultPushButton") |
|
327 |
layout39.addWidget(self.jobStoragePINDefaultPushButton,0,4) |
|
328 |
||
329 |
self.jobStoragePINButtonGroup = QButtonGroup(widget,"self.jobStoragePINButtonGroup") |
|
330 |
self.jobStoragePINButtonGroup.setLineWidth(0) |
|
331 |
self.jobStoragePINButtonGroup.setColumnLayout(0,Qt.Vertical) |
|
332 |
self.jobStoragePINButtonGroup.layout().setSpacing(0) |
|
333 |
self.jobStoragePINButtonGroup.layout().setMargin(0) |
|
334 |
self.jobStoragePINButtonGroupLayout = QGridLayout(self.jobStoragePINButtonGroup.layout()) |
|
335 |
self.jobStoragePINButtonGroupLayout.setAlignment(Qt.AlignTop) |
|
336 |
||
337 |
radioButton3_2 = QRadioButton(self.jobStoragePINButtonGroup,"radioButton3_2") |
|
338 |
radioButton3_2.setChecked(1) |
|
339 |
self.jobStoragePINButtonGroup.insert( radioButton3_2,0) |
|
340 |
self.jobStoragePINButtonGroupLayout.addWidget(radioButton3_2,0,0) |
|
341 |
||
342 |
radioButton4_2 = QRadioButton(self.jobStoragePINButtonGroup,"radioButton4_2") |
|
343 |
self.jobStoragePINButtonGroup.insert( radioButton4_2,1) |
|
344 |
self.jobStoragePINButtonGroupLayout.addWidget(radioButton4_2,0,1) |
|
345 |
||
346 |
layout39.addWidget(self.jobStoragePINButtonGroup,0,2) |
|
347 |
||
348 |
self.bg = self.jobStoragePINEdit.paletteBackgroundColor() |
|
349 |
self.invalid_page_range = False |
|
350 |
||
351 |
self.jobStoragePINEdit.setValidator(PINValidator(self.jobStoragePINEdit)) |
|
352 |
||
353 |
textLabel5_2.setText(self.__tr("Make Job Private (use PIN to print):")) |
|
354 |
radioButton3_2.setText(self.__tr("Public/Off")) |
|
355 |
radioButton4_2.setText(self.__tr("Private/Use PIN:")) |
|
356 |
||
357 |
self.jobStoragePINDefaultPushButton.setText(self.__tr("Default")) |
|
358 |
||
359 |
self.connect(self.jobStoragePINButtonGroup, SIGNAL("clicked(int)"), self.jobStoragePINButtonGroup_clicked) |
|
360 |
self.connect(self.jobStoragePINEdit,SIGNAL("lostFocus()"),self.jobStoragePINEdit_lostFocus) |
|
361 |
self.connect(self.jobStoragePINEdit,SIGNAL("textChanged(const QString&)"),self.jobStoragePINEdit_textChanged) |
|
362 |
self.connect(self.jobStoragePINDefaultPushButton, SIGNAL("clicked()"), self.jobStoragePINDefaultPushButton_clicked) |
|
363 |
||
364 |
self.addWidget(widget, "job_storage_pin") |
|
365 |
||
366 |
def jobStoragePINButtonGroup_clicked(self, a): |
|
367 |
if a == 0: # Public/Off |
|
368 |
self.jobStoragePINDefaultPushButton.setEnabled(False) |
|
369 |
self.jobStoragePINEdit.setEnabled(False) |
|
370 |
self.job_storage_use_pin = False |
|
371 |
self.job_storage_pin = u"0000" |
|
372 |
self.setPrinterOptionPIN() |
|
373 |
||
374 |
else: # On/Private/Use PIN |
|
375 |
self.jobStoragePINDefaultPushButton.setEnabled(True) |
|
376 |
self.jobStoragePINEdit.setEnabled(True) |
|
377 |
self.job_storage_use_pin = True |
|
378 |
self.job_storage_pin = unicode(self.jobStoragePINEdit.text()) |
|
379 |
self.setPrinterOptionPIN() |
|
380 |
||
381 |
def setPrinterOptionPIN(self): |
|
382 |
if self.print_settings_mode : |
|
383 |
if self.job_storage_use_pin: |
|
384 |
||
385 |
self.setPrinterOption('HOLDKEY', self.job_storage_pin.encode('ascii')) |
|
386 |
#self.setPrinterOption('HOLD', 'ON')
|
|
387 |
else: |
|
388 |
self.removePrinterOption('HOLDKEY') |
|
389 |
#self.setPrinterOption('HOLD', 'PROOF')
|
|
390 |
||
391 |
||
392 |
def jobStoragePINEdit_lostFocus(self): |
|
393 |
#self.setPrinterOptionPIN()
|
|
394 |
pass
|
|
395 |
||
396 |
def jobStoragePINEdit_textChanged(self, a): |
|
397 |
self.job_storage_pin = unicode(a) |
|
398 |
self.setPrinterOptionPIN() |
|
399 |
||
400 |
def jobStoragePINDefaultPushButton_clicked(self): |
|
401 |
self.jobStoragePINButtonGroup.setButton(0) |
|
402 |
self.jobStoragePINDefaultPushButton.setEnabled(False) |
|
403 |
self.jobStoragePINEdit.setEnabled(False) |
|
404 |
self.job_storage_use_pin = False |
|
405 |
||
406 |
# Username
|
|
407 |
||
408 |
def addJobStorageUsername(self): |
|
409 |
widget = self.getWidget() |
|
410 |
||
411 |
layout39 = QGridLayout(widget,1,1,5,10,"layout39") |
|
412 |
||
413 |
self.jobStorageUsernameEdit = QLineEdit(widget,"self.jobStorageUsernameEdit") |
|
414 |
self.jobStorageUsernameEdit.setMaxLength(16) |
|
415 |
self.jobStorageUsernameEdit.setText(self.job_storage_username) |
|
416 |
layout39.addWidget(self.jobStorageUsernameEdit,0,3) |
|
417 |
||
418 |
spacer20_2 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) |
|
419 |
layout39.addItem(spacer20_2,0,1) |
|
420 |
||
421 |
textLabel5_2 = QLabel(widget,"textLabel5_2") |
|
422 |
layout39.addWidget(textLabel5_2,0,0) |
|
423 |
||
424 |
self.jobStorageUsernameDefaultPushButton = QPushButton(widget,"jobStorageUsernameDefaultPushButton") |
|
425 |
layout39.addWidget(self.jobStorageUsernameDefaultPushButton,0,4) |
|
426 |
||
427 |
self.jobStorageUsernameButtonGroup = QButtonGroup(widget,"self.jobStorageUsernameButtonGroup") |
|
428 |
self.jobStorageUsernameButtonGroup.setLineWidth(0) |
|
429 |
self.jobStorageUsernameButtonGroup.setColumnLayout(0,Qt.Vertical) |
|
430 |
self.jobStorageUsernameButtonGroup.layout().setSpacing(0) |
|
431 |
self.jobStorageUsernameButtonGroup.layout().setMargin(0) |
|
432 |
self.jobStorageUsernameButtonGroupLayout = QGridLayout(self.jobStorageUsernameButtonGroup.layout()) |
|
433 |
self.jobStorageUsernameButtonGroupLayout.setAlignment(Qt.AlignTop) |
|
434 |
||
435 |
radioButton3_2 = QRadioButton(self.jobStorageUsernameButtonGroup,"radioButton3_2") |
|
436 |
radioButton3_2.setChecked(1) |
|
437 |
self.jobStorageUsernameButtonGroup.insert( radioButton3_2,0) |
|
438 |
self.jobStorageUsernameButtonGroupLayout.addWidget(radioButton3_2,0,0) |
|
439 |
||
440 |
radioButton4_2 = QRadioButton(self.jobStorageUsernameButtonGroup,"radioButton4_2") |
|
441 |
self.jobStorageUsernameButtonGroup.insert( radioButton4_2,1) |
|
442 |
self.jobStorageUsernameButtonGroupLayout.addWidget(radioButton4_2,0,1) |
|
443 |
||
444 |
layout39.addWidget(self.jobStorageUsernameButtonGroup,0,2) |
|
445 |
||
446 |
self.bg = self.jobStorageUsernameEdit.paletteBackgroundColor() |
|
447 |
self.invalid_page_range = False |
|
448 |
||
449 |
self.jobStorageUsernameEdit.setValidator(TextValidator(self.jobStorageUsernameEdit)) |
|
450 |
||
451 |
textLabel5_2.setText(self.__tr("User name (for job identification):")) |
|
452 |
radioButton3_2.setText(self.__tr("Automatic")) |
|
453 |
radioButton4_2.setText(self.__tr("Custom:")) |
|
454 |
||
455 |
self.jobStorageUsernameDefaultPushButton.setText(self.__tr("Default")) |
|
456 |
||
457 |
self.connect(self.jobStorageUsernameButtonGroup, SIGNAL("clicked(int)"), self.jobStorageUsernameButtonGroup_clicked) |
|
458 |
self.connect(self.jobStorageUsernameEdit,SIGNAL("lostFocus()"),self.jobStorageUsernameEdit_lostFocus) |
|
459 |
self.connect(self.jobStorageUsernameEdit,SIGNAL("textChanged(const QString&)"),self.jobStorageUsernameEdit_textChanged) |
|
460 |
self.connect(self.jobStorageUsernameDefaultPushButton, SIGNAL("clicked()"), self.jobStorageUsernameDefaultPushButton_clicked) |
|
461 |
||
462 |
self.addWidget(widget, "job_storage_username") |
|
463 |
||
464 |
def jobStorageUsernameButtonGroup_clicked(self, a): |
|
465 |
if a == 0: # Automatic |
|
466 |
self.jobStorageUsernameDefaultPushButton.setEnabled(False) |
|
467 |
self.jobStorageUsernameEdit.setEnabled(False) |
|
468 |
self.job_storage_auto_username = True |
|
469 |
self.job_storage_username = unicode(prop.username[:16]) |
|
470 |
self.setPrinterOptionUsername() |
|
471 |
||
472 |
else: # Custom |
|
473 |
self.jobStorageUsernameDefaultPushButton.setEnabled(True) |
|
474 |
self.jobStorageUsernameEdit.setEnabled(True) |
|
475 |
self.job_storage_auto_username = False |
|
476 |
self.job_storage_username = unicode(self.jobStorageUsernameEdit.text()) |
|
477 |
self.setPrinterOptionUsername() |
|
478 |
||
479 |
def jobStorageUsernameEdit_lostFocus(self): |
|
480 |
#self.setPrinterOptionUsername()
|
|
481 |
pass
|
|
482 |
||
483 |
def jobStorageUsernameEdit_textChanged(self, a): |
|
484 |
self.job_storage_username = unicode(a) |
|
485 |
self.setPrinterOptionUsername() |
|
486 |
||
487 |
def jobStorageUsernameDefaultPushButton_clicked(self): |
|
488 |
self.jobStorageUsernameButtonGroup.setButton(0) |
|
489 |
self.jobStorageUsernameDefaultPushButton.setEnabled(False) |
|
490 |
self.jobStorageUsernameEdit.setEnabled(False) |
|
491 |
self.job_storage_auto_username = True |
|
492 |
self.job_storage_username = unicode(prop.username[:16]) |
|
493 |
self.setPrinterOptionUsername() |
|
494 |
||
495 |
def setPrinterOptionUsername(self): |
|
496 |
if self.print_settings_mode: |
|
497 |
self.setPrinterOption('USERNAME', self.job_storage_username.encode('ascii').replace(' ', '_')) |
|
498 |
||
499 |
||
500 |
# Job ID
|
|
501 |
||
502 |
def addJobStorageID(self): |
|
503 |
widget = self.getWidget() |
|
504 |
||
505 |
layout39 = QGridLayout(widget,1,1,5,10,"layout39") |
|
506 |
||
507 |
self.jobStorageIDEdit = QLineEdit(widget,"self.jobStorageIDEdit") |
|
508 |
self.jobStorageIDEdit.setMaxLength(16) |
|
509 |
self.jobStorageIDEdit.setText(self.job_storage_jobname) |
|
510 |
layout39.addWidget(self.jobStorageIDEdit,0,3) |
|
511 |
||
512 |
spacer20_2 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) |
|
513 |
layout39.addItem(spacer20_2,0,1) |
|
514 |
||
515 |
textLabel5_2 = QLabel(widget,"textLabel5_2") |
|
516 |
layout39.addWidget(textLabel5_2,0,0) |
|
517 |
||
518 |
self.jobStorageIDDefaultPushButton = QPushButton(widget,"jobStorageIDDefaultPushButton") |
|
519 |
layout39.addWidget(self.jobStorageIDDefaultPushButton,0,4) |
|
520 |
||
521 |
self.jobStorageIDButtonGroup = QButtonGroup(widget,"self.jobStorageIDButtonGroup") |
|
522 |
self.jobStorageIDButtonGroup.setLineWidth(0) |
|
523 |
self.jobStorageIDButtonGroup.setColumnLayout(0,Qt.Vertical) |
|
524 |
self.jobStorageIDButtonGroup.layout().setSpacing(0) |
|
525 |
self.jobStorageIDButtonGroup.layout().setMargin(0) |
|
526 |
self.jobStorageIDButtonGroupLayout = QGridLayout(self.jobStorageIDButtonGroup.layout()) |
|
527 |
self.jobStorageIDButtonGroupLayout.setAlignment(Qt.AlignTop) |
|
528 |
||
529 |
radioButton3_2 = QRadioButton(self.jobStorageIDButtonGroup,"radioButton3_2") |
|
530 |
radioButton3_2.setChecked(1) |
|
531 |
self.jobStorageIDButtonGroup.insert( radioButton3_2,0) |
|
532 |
self.jobStorageIDButtonGroupLayout.addWidget(radioButton3_2,0,0) |
|
533 |
||
534 |
radioButton4_2 = QRadioButton(self.jobStorageIDButtonGroup,"radioButton4_2") |
|
535 |
self.jobStorageIDButtonGroup.insert( radioButton4_2,1) |
|
536 |
self.jobStorageIDButtonGroupLayout.addWidget(radioButton4_2,0,1) |
|
537 |
||
538 |
layout39.addWidget(self.jobStorageIDButtonGroup,0,2) |
|
539 |
||
540 |
self.bg = self.jobStorageIDEdit.paletteBackgroundColor() |
|
541 |
self.invalid_page_range = False |
|
542 |
||
543 |
self.jobStorageIDEdit.setValidator(TextValidator(self.jobStorageIDEdit)) |
|
544 |
||
545 |
textLabel5_2.setText(self.__tr("Job name (for job identification):")) |
|
546 |
radioButton3_2.setText(self.__tr("Automatic")) |
|
547 |
radioButton4_2.setText(self.__tr("Custom:")) |
|
548 |
||
549 |
self.jobStorageIDDefaultPushButton.setText(self.__tr("Default")) |
|
550 |
||
551 |
self.connect(self.jobStorageIDButtonGroup, SIGNAL("clicked(int)"), self.jobStorageIDButtonGroup_clicked) |
|
552 |
self.connect(self.jobStorageIDEdit,SIGNAL("lostFocus()"),self.jobStorageIDEdit_lostFocus) |
|
553 |
self.connect(self.jobStorageIDEdit,SIGNAL("textChanged(const QString&)"),self.jobStorageIDEdit_textChanged) |
|
554 |
self.connect(self.jobStorageIDDefaultPushButton, SIGNAL("clicked()"), self.jobStorageIDDefaultPushButton_clicked) |
|
555 |
||
556 |
self.addWidget(widget, "job_storage_ID") |
|
557 |
||
558 |
def jobStorageIDButtonGroup_clicked(self, a): |
|
559 |
if a == 0: # Automatic |
|
560 |
self.jobStorageIDDefaultPushButton.setEnabled(False) |
|
561 |
self.jobStorageIDEdit.setEnabled(False) |
|
562 |
self.job_storage_auto_jobname = True |
|
563 |
self.job_storage_jobname = u"Untitled" |
|
564 |
self.setPrinterOptionID() |
|
565 |
||
566 |
else: # Custom |
|
567 |
self.jobStorageIDDefaultPushButton.setEnabled(True) |
|
568 |
self.jobStorageIDEdit.setEnabled(True) |
|
569 |
self.job_storage_auto_jobname = False |
|
570 |
self.job_storage_jobname = unicode(self.jobStorageIDEdit.text()) |
|
571 |
self.setPrinterOptionID() |
|
572 |
||
573 |
def jobStorageIDEdit_lostFocus(self): |
|
574 |
#self.setPrinterOptionID()
|
|
575 |
pass
|
|
576 |
||
577 |
def jobStorageIDEdit_textChanged(self, a): |
|
578 |
self.job_storage_jobname = unicode(a) |
|
579 |
self.setPrinterOptionID() |
|
580 |
||
581 |
def jobStorageIDDefaultPushButton_clicked(self): |
|
582 |
self.jobStorageIDButtonGroup.setButton(0) |
|
583 |
self.jobStorageIDDefaultPushButton.setEnabled(False) |
|
584 |
self.jobStorageIDEdit.setEnabled(False) |
|
585 |
self.job_storage_auto_jobname = True |
|
586 |
self.job_storage_jobname = u"Untitled" |
|
587 |
self.setPrinterOptionID() |
|
588 |
||
589 |
def setPrinterOptionID(self): |
|
590 |
if self.print_settings_mode: |
|
591 |
self.setPrinterOption('JOBNAME', self.job_storage_jobname.encode('ascii').replace(' ', '_')) |
|
592 |
||
593 |
# Job ID Exists
|
|
594 |
||
595 |
def addJobStorageIDExists(self): |
|
596 |
widget = self.getWidget() |
|
597 |
||
598 |
layout34 = QHBoxLayout(widget,5,10,"layout34") |
|
599 |
||
600 |
self.jobStorageIDExistsLabel = QLabel(widget,"jobStorageIDExistsLabel") |
|
601 |
layout34.addWidget(self.jobStorageIDExistsLabel) |
|
602 |
spacer20_4 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) |
|
603 |
layout34.addItem(spacer20_4) |
|
604 |
||
605 |
self.jobStorageIDExistsComboBox = QComboBox(0,widget,"jobStorageIDExistsComboBox") |
|
606 |
layout34.addWidget(self.jobStorageIDExistsComboBox) |
|
607 |
||
608 |
self.jobStorageIDExistsDefaultPushButton = QPushButton(widget,"pagesetDefaultPushButton") |
|
609 |
layout34.addWidget(self.jobStorageIDExistsDefaultPushButton) |
|
610 |
||
611 |
self.jobStorageIDExistsLabel.setText(self.__tr("If Job Name already exists:")) |
|
612 |
self.jobStorageIDExistsComboBox.clear() |
|
613 |
self.jobStorageIDExistsComboBox.insertItem(self.__tr("Replace existing job")) |
|
614 |
self.jobStorageIDExistsComboBox.insertItem(self.__tr("Use Job Name + (1-99)")) |
|
615 |
||
616 |
self.jobStorageIDExistsDefaultPushButton.setText(self.__tr("Default")) |
|
617 |
||
618 |
self.connect(self.jobStorageIDExistsComboBox, SIGNAL("activated(int)"), self.jobStorageIDExistsComboBox_activated) |
|
619 |
self.connect(self.jobStorageIDExistsDefaultPushButton, SIGNAL("clicked()"), self.jobStorageIDExistsDefaultPushButton_clicked) |
|
620 |
||
621 |
self.addWidget(widget, "job_storage_id_exists") |
|
622 |
||
623 |
def jobStorageIDExistsComboBox_activated(self, a): |
|
624 |
self.jobStorageIDExistsDefaultPushButton.setEnabled(a==1) |
|
625 |
self.job_storage_job_exist = a |
|
626 |
self.setPrinterOptionIDExists() |
|
627 |
||
628 |
def jobStorageIDExistsDefaultPushButton_clicked(self): |
|
629 |
self.jobStorageIDExistsComboBox.setCurrentItem(0) |
|
630 |
self.jobStorageIDExistsDefaultPushButton.setEnabled(False) |
|
631 |
self.job_storage_job_exist = 0 |
|
632 |
self.setPrinterOptionIDExists() |
|
633 |
||
634 |
def setPrinterOptionIDExists(self): |
|
635 |
if self.print_settings_mode: |
|
636 |
if self.job_storage_job_exist == 0: |
|
637 |
self.setPrinterOption('DUPLICATEJOB', 'REPLACE') |
|
638 |
else: |
|
639 |
self.setPrinterOption('DUPLICATEJOB', 'APPEND') |
|
640 |
||
641 |
def __tr(self,s,c = None): |
|
642 |
return qApp.translate("JobStorage",s,c) |
|
643 |