1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2001-2008 Hewlett-Packard 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
24 from base import device
26 from ui_utils import *
29 from PyQt4.QtCore import *
30 from PyQt4.QtGui import *
33 from printsettingsdialog_base import Ui_Dialog
34 from printsettingstoolbox import PrintSettingsToolbox
35 from printernamecombobox import PRINTERNAMECOMBOBOX_TYPE_PRINTER_AND_FAX, PRINTERNAMECOMBOBOX_TYPE_FAX_ONLY
38 class PrintSettingsDialog(QDialog, Ui_Dialog):
39 def __init__(self, parent, printer_name, fax_mode=False):
40 QDialog.__init__(self, parent)
42 self.fax_mode = fax_mode
43 self.printer_name = printer_name
44 self.device_uri = None
46 self.printer_index = {}
49 self.user_settings = UserSettings()
50 self.user_settings.load()
51 self.user_settings.debug()
52 #self.cur_printer = self.user_settings.last_used_printer
54 self.initUi(printer_name)
55 QTimer.singleShot(0, self.updateUi)
58 def initUi(self, printer_name=None):
59 self.OptionsToolBox.include_print_options = False
62 self.PrinterName.setInitialPrinter(self.printer_name)
65 self.PrinterName.setType(PRINTERNAMECOMBOBOX_TYPE_FAX_ONLY)
66 self.TitleLabel.setText(self.__tr("Fax Settings"))
68 self.PrinterName.setType(PRINTERNAMECOMBOBOX_TYPE_PRINTER_AND_FAX)
70 self.connect(self.CloseButton, SIGNAL("clicked()"), self.CloseButton_clicked)
72 self.connect(self.PrinterName, SIGNAL("PrinterNameComboBox_currentChanged"),
73 self.PrinterNameComboBox_currentChanged)
75 self.connect(self.PrinterName, SIGNAL("PrinterNameComboBox_noPrinters"),
76 self.PrinterNameComboBox_noPrinters)
79 self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
84 self.PrinterName.updateUi()
87 def PrinterNameComboBox_noPrinters(self):
88 FailureUI(self, self.__tr("<b>No printers or faxes found.</b><p>Please setup a printer or fax and try again."))
92 def PrinterNameComboBox_currentChanged(self, device_uri, printer_name):
93 self.printer_name = printer_name
94 self.device_uri = device_uri
96 self.devices[device_uri]
98 self.devices[device_uri] = device.Device(device_uri)
100 self.OptionsToolBox.updateUi(self.devices[device_uri], self.printer_name)
107 def CloseButton_clicked(self):
111 def __tr(self,s,c = None):
112 return qApp.translate("PrintSettingsDialog",s,c)