1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2001-2007 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
23 from base.codes import *
24 from base import utils
26 from settingsdialog_base import SettingsDialog_base
28 class SettingsDialog(SettingsDialog_base):
29 def __init__(self, parent = None,name = None,modal = 0,fl = 0):
30 SettingsDialog_base.__init__(self,parent,name,modal,fl)
31 self.DefaultsButton.setEnabled(False)
32 #self.sendmail = utils.which('sendmail')
34 #if not self.sendmail:
35 # self.EmailTestButton.setEnabled(False)
37 self.user_settings = utils.UserSettings()
40 def updateControls(self):
41 self.autoRefreshCheckBox.setChecked(self.user_settings.auto_refresh)
42 self.AutoRefreshRate.setValue(self.user_settings.auto_refresh_rate) # min
43 self.refreshScopeButtonGroup.setButton(self.user_settings.auto_refresh_type)
45 ## self.EmailCheckBox.setChecked(self.user_settings.email_alerts)
46 ## self.EmailAddress.setText(self.user_settings.email_to_addresses)
47 ## self.senderLineEdit.setText(self.user_settings.email_from_address)
49 self.PrintCommand.setText(self.user_settings.cmd_print)
50 #self.PrintCommand.setEnabled(not self.user_settings.cmd_print_int)
52 ## if self.user_settings.cmd_print_int:
53 ## self.printButtonGroup.setButton(0)
55 ## self.printButtonGroup.setButton(1)
57 self.ScanCommand.setText(self.user_settings.cmd_scan)
58 #self.ScanCommand.setEnabled(not self.user_settings.cmd_scan_int)
60 ## if self.user_settings.cmd_scan_int:
61 ## self.scanButtonGroup.setButton(0)
63 ## self.scanButtonGroup.setButton(1)
65 self.AccessPCardCommand.setText(self.user_settings.cmd_pcard)
66 #self.AccessPCardCommand.setEnabled(not self.user_settings.cmd_pcard_int)
68 ## if self.user_settings.cmd_pcard_int:
69 ## self.pcardButtonGroup.setButton(0)
71 ## self.pcardButtonGroup.setButton(1)
73 self.SendFaxCommand.setText(self.user_settings.cmd_fax)
74 #self.SendFaxCommand.setEnabled(not self.user_settings.cmd_fax_int)
76 ## if self.user_settings.cmd_fax_int:
77 ## self.faxButtonGroup.setButton(0)
79 ## self.faxButtonGroup.setButton(1)
81 self.MakeCopiesCommand.setText(self.user_settings.cmd_copy)
82 #self.MakeCopiesCommand.setEnabled(not self.user_settings.cmd_copy_int)
84 ## if self.user_settings.cmd_copy_int:
85 ## self.copyButtonGroup.setButton(0)
87 ## self.copyButtonGroup.setButton(1)
90 self.user_settings.cmd_print = unicode(self.PrintCommand.text())
91 #self.user_settings.cmd_print_int = (self.printButtonGroup.selectedId() == 0)
93 self.user_settings.cmd_scan = unicode(self.ScanCommand.text())
94 #self.user_settings.cmd_scan_int = (self.scanButtonGroup.selectedId() == 0)
96 self.user_settings.cmd_pcard = unicode(self.AccessPCardCommand.text())
97 #self.user_settings.cmd_pcard_int = (self.pcardButtonGroup.selectedId() == 0)
99 self.user_settings.cmd_fax = unicode(self.SendFaxCommand.text())
100 #self.user_settings.cmd_fax_int = (self.faxButtonGroup.selectedId() == 0)
102 self.user_settings.cmd_copy = unicode(self.MakeCopiesCommand.text())
103 #self.user_settings.cmd_copy_int = (self.copyButtonGroup.selectedId() == 0)
105 ## self.user_settings.email_alerts = bool(self.EmailCheckBox.isChecked())
106 ## self.user_settings.email_to_addresses = unicode(self.EmailAddress.text())
107 ## self.user_settings.email_from_address = unicode(self.senderLineEdit.text())
109 self.user_settings.auto_refresh = str(self.autoRefreshCheckBox.isChecked())
110 self.user_settings.auto_refresh_type = str(self.refreshScopeButtonGroup.selectedId())
111 self.user_settings.auto_refresh_rate = str(self.AutoRefreshRate.value())
113 ## def PrintCmdChangeButton_clicked(self):
116 ## def ScanCmdChangeButton_clicked(self):
119 ## def AccessPCardCmdChangeButton_clicked(self):
122 ## def SendFaxCmdChangeButton_clicked(self):
125 ## def MakeCopiesCmdChangeButton_clicked(self):
128 def DefaultsButton_clicked(self):
129 self.user_settings.loadDefaults()
130 self.updateControls()
132 def TabWidget_currentChanged(self,a0):
133 name = str(a0.name())
135 if name == 'FunctionCommands':
136 self.DefaultsButton.setEnabled(True)
138 self.DefaultsButton.setEnabled(False)
140 ## def EmailTestButton_clicked(self):
141 ## email_to_addresses = unicode(self.EmailAddress.text())
142 ## email_from_address = unicode(self.senderLineEdit.text())
144 ## if not email_to_addresses or not email_from_address:
145 ## QMessageBox.warning(self,
147 ## self.__tr("<b>One or more email addresses are missing.</b><p>Please enter this information and try again."),
149 ## QMessageBox.NoButton,
150 ## QMessageBox.NoButton)
154 #### service.setAlerts(self.hpssd_sock,
156 #### email_from_address,
157 #### email_to_addresses)
159 ## #result_code = service.testEmail(self.hpssd_sock, prop.username)
160 ## log.debug(result_code)
162 ## QMessageBox.information(self,
164 ## self.__tr("<p><b>Please check your email for a test message.</b><p>If the message doesn't arrive, please check your settings and try again."),
166 ## QMessageBox.NoButton,
167 ## QMessageBox.NoButton)
170 def autoRefreshCheckBox_clicked(self):
173 ## def CleaningLevel_clicked(self,a0):
176 def refreshScopeButtonGroup_clicked(self,a0):
177 self.auto_refresh_type = int(a0)
179 ## def printButtonGroup_clicked(self,a0):
180 ## self.PrintCommand.setEnabled(a0)
182 ## def scanButtonGroup_clicked(self,a0):
183 ## self.ScanCommand.setEnabled(a0)
185 ## def faxButtonGroup_clicked(self,a0):
186 ## self.SendFaxCommand.setEnabled(a0)
188 ## def pcardButtonGroup_clicked(self,a0):
189 ## self.AccessPCardCommand.setEnabled(a0)
191 ## def copyButtonGroup_clicked(self,a0):
192 ## self.MakeCopiesCommand.setEnabled(a0)
196 self.user_settings.save()
197 SettingsDialog_base.accept(self)
199 def __tr(self,s,c = None):
200 return qApp.translate("SettingsDialog",s,c)