1
# -*- coding: utf-8 -*-
3
# (c) Copyright 2001-2015 HP 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
25
from base.sixext import to_unicode
27
from .settingsdialog_base import SettingsDialog_base
29
class SettingsDialog(SettingsDialog_base):
30
def __init__(self, parent = None,name = None,modal = 0,fl = 0):
31
SettingsDialog_base.__init__(self,parent,name,modal,fl)
32
self.DefaultsButton.setEnabled(False)
33
#self.sendmail = utils.which('sendmail')
35
#if not self.sendmail:
36
# self.EmailTestButton.setEnabled(False)
38
self.user_settings = utils.UserSettings()
41
def updateControls(self):
42
self.autoRefreshCheckBox.setChecked(self.user_settings.auto_refresh)
43
self.AutoRefreshRate.setValue(self.user_settings.auto_refresh_rate) # min
44
self.refreshScopeButtonGroup.setButton(self.user_settings.auto_refresh_type)
46
## self.EmailCheckBox.setChecked(self.user_settings.email_alerts)
47
## self.EmailAddress.setText(self.user_settings.email_to_addresses)
48
## self.senderLineEdit.setText(self.user_settings.email_from_address)
50
self.PrintCommand.setText(self.user_settings.cmd_print)
51
#self.PrintCommand.setEnabled(not self.user_settings.cmd_print_int)
53
## if self.user_settings.cmd_print_int:
54
## self.printButtonGroup.setButton(0)
56
## self.printButtonGroup.setButton(1)
58
self.ScanCommand.setText(self.user_settings.cmd_scan)
59
#self.ScanCommand.setEnabled(not self.user_settings.cmd_scan_int)
61
## if self.user_settings.cmd_scan_int:
62
## self.scanButtonGroup.setButton(0)
64
## self.scanButtonGroup.setButton(1)
66
self.AccessPCardCommand.setText(self.user_settings.cmd_pcard)
67
#self.AccessPCardCommand.setEnabled(not self.user_settings.cmd_pcard_int)
69
## if self.user_settings.cmd_pcard_int:
70
## self.pcardButtonGroup.setButton(0)
72
## self.pcardButtonGroup.setButton(1)
74
self.SendFaxCommand.setText(self.user_settings.cmd_fax)
75
#self.SendFaxCommand.setEnabled(not self.user_settings.cmd_fax_int)
77
## if self.user_settings.cmd_fax_int:
78
## self.faxButtonGroup.setButton(0)
80
## self.faxButtonGroup.setButton(1)
82
self.MakeCopiesCommand.setText(self.user_settings.cmd_copy)
83
#self.MakeCopiesCommand.setEnabled(not self.user_settings.cmd_copy_int)
85
## if self.user_settings.cmd_copy_int:
86
## self.copyButtonGroup.setButton(0)
88
## self.copyButtonGroup.setButton(1)
91
self.user_settings.cmd_print = to_unicode(self.PrintCommand.text())
92
#self.user_settings.cmd_print_int = (self.printButtonGroup.selectedId() == 0)
94
self.user_settings.cmd_scan = to_unicode(self.ScanCommand.text())
95
#self.user_settings.cmd_scan_int = (self.scanButtonGroup.selectedId() == 0)
97
self.user_settings.cmd_pcard = to_unicode(self.AccessPCardCommand.text())
98
#self.user_settings.cmd_pcard_int = (self.pcardButtonGroup.selectedId() == 0)
100
self.user_settings.cmd_fax = to_unicode(self.SendFaxCommand.text())
101
#self.user_settings.cmd_fax_int = (self.faxButtonGroup.selectedId() == 0)
103
self.user_settings.cmd_copy = to_unicode(self.MakeCopiesCommand.text())
104
#self.user_settings.cmd_copy_int = (self.copyButtonGroup.selectedId() == 0)
106
## self.user_settings.email_alerts = bool(self.EmailCheckBox.isChecked())
107
## self.user_settings.email_to_addresses = unicode(self.EmailAddress.text())
108
## self.user_settings.email_from_address = unicode(self.senderLineEdit.text())
110
self.user_settings.auto_refresh = str(self.autoRefreshCheckBox.isChecked())
111
self.user_settings.auto_refresh_type = str(self.refreshScopeButtonGroup.selectedId())
112
self.user_settings.auto_refresh_rate = str(self.AutoRefreshRate.value())
114
## def PrintCmdChangeButton_clicked(self):
117
## def ScanCmdChangeButton_clicked(self):
120
## def AccessPCardCmdChangeButton_clicked(self):
123
## def SendFaxCmdChangeButton_clicked(self):
126
## def MakeCopiesCmdChangeButton_clicked(self):
129
def DefaultsButton_clicked(self):
130
self.user_settings.loadDefaults()
131
self.updateControls()
133
def TabWidget_currentChanged(self,a0):
134
name = str(a0.name())
136
if name == 'FunctionCommands':
137
self.DefaultsButton.setEnabled(True)
139
self.DefaultsButton.setEnabled(False)
141
## def EmailTestButton_clicked(self):
142
## email_to_addresses = unicode(self.EmailAddress.text())
143
## email_from_address = unicode(self.senderLineEdit.text())
145
## if not email_to_addresses or not email_from_address:
146
## QMessageBox.warning(self,
148
## self.__tr("<b>One or more email addresses are missing.</b><p>Please enter this information and try again."),
150
## QMessageBox.NoButton,
151
## QMessageBox.NoButton)
155
#### service.setAlerts(self.hpssd_sock,
157
#### email_from_address,
158
#### email_to_addresses)
160
## #result_code = service.testEmail(self.hpssd_sock, prop.username)
161
## log.debug(result_code)
163
## QMessageBox.information(self,
165
## 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."),
167
## QMessageBox.NoButton,
168
## QMessageBox.NoButton)
171
def autoRefreshCheckBox_clicked(self):
174
## def CleaningLevel_clicked(self,a0):
177
def refreshScopeButtonGroup_clicked(self,a0):
178
self.auto_refresh_type = int(a0)
180
## def printButtonGroup_clicked(self,a0):
181
## self.PrintCommand.setEnabled(a0)
183
## def scanButtonGroup_clicked(self,a0):
184
## self.ScanCommand.setEnabled(a0)
186
## def faxButtonGroup_clicked(self,a0):
187
## self.SendFaxCommand.setEnabled(a0)
189
## def pcardButtonGroup_clicked(self,a0):
190
## self.AccessPCardCommand.setEnabled(a0)
192
## def copyButtonGroup_clicked(self,a0):
193
## self.MakeCopiesCommand.setEnabled(a0)
197
self.user_settings.save()
198
SettingsDialog_base.accept(self)
200
def __tr(self,s,c = None):
201
return qApp.translate("SettingsDialog",s,c)