Fixed build error by changing buildrequires from pkgconfig(turbo-jpeg) to libjpeg...
[platform/upstream/hplip.git] / ui / settingsdialog.py
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 from base.g import *
23 from base.codes import *
24 from base import utils
25 from qt import *
26 from settingsdialog_base import SettingsDialog_base
27
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')
33
34         #if not self.sendmail:
35         #    self.EmailTestButton.setEnabled(False)
36
37         self.user_settings = utils.UserSettings()
38         self.updateControls()
39
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)
44
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)
48
49         self.PrintCommand.setText(self.user_settings.cmd_print)
50         #self.PrintCommand.setEnabled(not self.user_settings.cmd_print_int)
51
52 ##        if self.user_settings.cmd_print_int:
53 ##            self.printButtonGroup.setButton(0)
54 ##        else:
55 ##            self.printButtonGroup.setButton(1)
56
57         self.ScanCommand.setText(self.user_settings.cmd_scan)
58         #self.ScanCommand.setEnabled(not self.user_settings.cmd_scan_int)
59
60 ##        if self.user_settings.cmd_scan_int:
61 ##            self.scanButtonGroup.setButton(0)
62 ##        else:
63 ##            self.scanButtonGroup.setButton(1)
64
65         self.AccessPCardCommand.setText(self.user_settings.cmd_pcard)
66         #self.AccessPCardCommand.setEnabled(not self.user_settings.cmd_pcard_int)
67
68 ##        if self.user_settings.cmd_pcard_int:
69 ##            self.pcardButtonGroup.setButton(0)
70 ##        else:
71 ##            self.pcardButtonGroup.setButton(1)
72
73         self.SendFaxCommand.setText(self.user_settings.cmd_fax)
74         #self.SendFaxCommand.setEnabled(not self.user_settings.cmd_fax_int)
75
76 ##        if self.user_settings.cmd_fax_int:
77 ##            self.faxButtonGroup.setButton(0)
78 ##        else:
79 ##            self.faxButtonGroup.setButton(1)
80
81         self.MakeCopiesCommand.setText(self.user_settings.cmd_copy)
82         #self.MakeCopiesCommand.setEnabled(not self.user_settings.cmd_copy_int)
83
84 ##        if self.user_settings.cmd_copy_int:
85 ##            self.copyButtonGroup.setButton(0)
86 ##        else:
87 ##            self.copyButtonGroup.setButton(1)    
88
89     def updateData(self):
90         self.user_settings.cmd_print = unicode(self.PrintCommand.text())
91         #self.user_settings.cmd_print_int = (self.printButtonGroup.selectedId() == 0)
92
93         self.user_settings.cmd_scan = unicode(self.ScanCommand.text())
94         #self.user_settings.cmd_scan_int = (self.scanButtonGroup.selectedId() == 0)
95
96         self.user_settings.cmd_pcard = unicode(self.AccessPCardCommand.text())
97         #self.user_settings.cmd_pcard_int = (self.pcardButtonGroup.selectedId() == 0)
98
99         self.user_settings.cmd_fax   = unicode(self.SendFaxCommand.text())
100         #self.user_settings.cmd_fax_int = (self.faxButtonGroup.selectedId() == 0)
101
102         self.user_settings.cmd_copy  = unicode(self.MakeCopiesCommand.text())
103         #self.user_settings.cmd_copy_int = (self.copyButtonGroup.selectedId() == 0)
104
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())
108
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())
112
113 ##    def PrintCmdChangeButton_clicked(self):
114 ##        pass
115 ##
116 ##    def ScanCmdChangeButton_clicked(self):
117 ##        pass
118 ##
119 ##    def AccessPCardCmdChangeButton_clicked(self):
120 ##        pass
121 ##
122 ##    def SendFaxCmdChangeButton_clicked(self):
123 ##        pass
124 ##
125 ##    def MakeCopiesCmdChangeButton_clicked(self):
126 ##        pass
127
128     def DefaultsButton_clicked(self):
129         self.user_settings.loadDefaults()
130         self.updateControls()
131
132     def TabWidget_currentChanged(self,a0):
133         name = str(a0.name())
134
135         if name == 'FunctionCommands':
136             self.DefaultsButton.setEnabled(True)
137         else:
138             self.DefaultsButton.setEnabled(False)
139
140 ##    def EmailTestButton_clicked(self): 
141 ##        email_to_addresses = unicode(self.EmailAddress.text())
142 ##        email_from_address = unicode(self.senderLineEdit.text())
143 ##
144 ##        if not email_to_addresses or not email_from_address:
145 ##            QMessageBox.warning(self,
146 ##                                 self.caption(),
147 ##                                 self.__tr("<b>One or more email addresses are missing.</b><p>Please enter this information and try again."),
148 ##                                  QMessageBox.Ok,
149 ##                                  QMessageBox.NoButton,
150 ##                                  QMessageBox.NoButton)
151 ##            return
152 ##        
153 ##        # TODO:
154 ####        service.setAlerts(self.hpssd_sock, 
155 ####                          True,
156 ####                          email_from_address,
157 ####                          email_to_addresses)
158 ##
159 ##        #result_code = service.testEmail(self.hpssd_sock, prop.username)
160 ##        log.debug(result_code)
161 ##
162 ##        QMessageBox.information(self,
163 ##                     self.caption(),
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."),
165 ##                      QMessageBox.Ok,
166 ##                      QMessageBox.NoButton,
167 ##                      QMessageBox.NoButton)
168
169
170     def autoRefreshCheckBox_clicked(self):
171         pass
172
173 ##    def CleaningLevel_clicked(self,a0):
174 ##        pass
175
176     def refreshScopeButtonGroup_clicked(self,a0):
177         self.auto_refresh_type = int(a0)
178
179 ##    def printButtonGroup_clicked(self,a0):
180 ##        self.PrintCommand.setEnabled(a0)
181 ##
182 ##    def scanButtonGroup_clicked(self,a0):
183 ##        self.ScanCommand.setEnabled(a0)
184 ##
185 ##    def faxButtonGroup_clicked(self,a0):
186 ##        self.SendFaxCommand.setEnabled(a0)
187 ##
188 ##    def pcardButtonGroup_clicked(self,a0):
189 ##        self.AccessPCardCommand.setEnabled(a0)
190 ##
191 ##    def copyButtonGroup_clicked(self,a0):
192 ##        self.MakeCopiesCommand.setEnabled(a0)
193
194     def accept(self):
195         self.updateData()
196         self.user_settings.save()
197         SettingsDialog_base.accept(self)
198
199     def __tr(self,s,c = None):
200         return qApp.translate("SettingsDialog",s,c)
201
202