1# -*- coding: utf-8 -*- 2# 3# (c) Copyright 2001-2015 HP 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 23from base.g import * 24from base import device 25from prnt import cups 26from .ui_utils import * 27 28# Qt 29from PyQt4.QtCore import * 30from PyQt4.QtGui import * 31 32# Ui 33from .printsettingsdialog_base import Ui_Dialog 34from .printsettingstoolbox import PrintSettingsToolbox 35from .printernamecombobox import PRINTERNAMECOMBOBOX_TYPE_PRINTER_AND_FAX, PRINTERNAMECOMBOBOX_TYPE_FAX_ONLY 36 37#signal 38import signal 39 40class PrintSettingsDialog(QDialog, Ui_Dialog): 41 def __init__(self, parent, printer_name, fax_mode=False): 42 QDialog.__init__(self, parent) 43 self.setupUi(self) 44 self.fax_mode = fax_mode 45 self.printer_name = printer_name 46 self.device_uri = None 47 self.devices = {} 48 self.printer_index = {} 49 50 # User settings 51 self.user_settings = UserSettings() 52 self.user_settings.load() 53 self.user_settings.debug() 54 #self.cur_printer = self.user_settings.last_used_printer 55 56 self.initUi(printer_name) 57 QTimer.singleShot(0, self.updateUi) 58 59 60 def initUi(self, printer_name=None): 61 self.OptionsToolBox.include_print_options = False 62 63 if self.printer_name: 64 self.PrinterName.setInitialPrinter(self.printer_name) 65 66 if self.fax_mode: 67 self.PrinterName.setType(PRINTERNAMECOMBOBOX_TYPE_FAX_ONLY) 68 self.TitleLabel.setText(self.__tr("Fax Settings")) 69 else: 70 self.PrinterName.setType(PRINTERNAMECOMBOBOX_TYPE_PRINTER_AND_FAX) 71 72 self.connect(self.CloseButton, SIGNAL("clicked()"), self.CloseButton_clicked) 73 74 self.connect(self.PrinterName, SIGNAL("PrinterNameComboBox_currentChanged"), 75 self.PrinterNameComboBox_currentChanged) 76 77 self.connect(self.PrinterName, SIGNAL("PrinterNameComboBox_noPrinters"), 78 self.PrinterNameComboBox_noPrinters) 79 80 signal.signal(signal.SIGINT, signal.SIG_DFL) 81 82 # Application icon 83 self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128'))) 84 85 86 87 def updateUi(self): 88 self.PrinterName.updateUi() 89 90 91 def PrinterNameComboBox_noPrinters(self): 92 FailureUI(self, self.__tr("<b>No printers or faxes found.</b><p>Please setup a printer or fax and try again.")) 93 self.close() 94 95 96 def PrinterNameComboBox_currentChanged(self, device_uri, printer_name): 97 self.printer_name = printer_name 98 self.device_uri = device_uri 99 try: 100 self.devices[device_uri] 101 except KeyError: 102 self.devices[device_uri] = device.Device(device_uri) 103 104 self.OptionsToolBox.updateUi(self.devices[device_uri], self.printer_name) 105 106 107 # 108 # Misc 109 # 110 111 def CloseButton_clicked(self): 112 self.close() 113 114 115 def __tr(self,s,c = None): 116 return qApp.translate("PrintSettingsDialog",s,c) 117 118 119