1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
# -*- coding: utf-8 -*-
#
# (c) Copyright 2001-2015 HP Development Company, L.P.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Don Welch
#
from base.g import *
from base.codes import *
from base import utils
from base.sixext import to_unicode
from qt import *
from .settingsdialog_base import SettingsDialog_base
class SettingsDialog(SettingsDialog_base):
def __init__(self, parent = None,name = None,modal = 0,fl = 0):
SettingsDialog_base.__init__(self,parent,name,modal,fl)
self.DefaultsButton.setEnabled(False)
#self.sendmail = utils.which('sendmail')
#if not self.sendmail:
# self.EmailTestButton.setEnabled(False)
self.user_settings = utils.UserSettings()
self.updateControls()
def updateControls(self):
self.autoRefreshCheckBox.setChecked(self.user_settings.auto_refresh)
self.AutoRefreshRate.setValue(self.user_settings.auto_refresh_rate) # min
self.refreshScopeButtonGroup.setButton(self.user_settings.auto_refresh_type)
## self.EmailCheckBox.setChecked(self.user_settings.email_alerts)
## self.EmailAddress.setText(self.user_settings.email_to_addresses)
## self.senderLineEdit.setText(self.user_settings.email_from_address)
self.PrintCommand.setText(self.user_settings.cmd_print)
#self.PrintCommand.setEnabled(not self.user_settings.cmd_print_int)
## if self.user_settings.cmd_print_int:
## self.printButtonGroup.setButton(0)
## else:
## self.printButtonGroup.setButton(1)
self.ScanCommand.setText(self.user_settings.cmd_scan)
#self.ScanCommand.setEnabled(not self.user_settings.cmd_scan_int)
## if self.user_settings.cmd_scan_int:
## self.scanButtonGroup.setButton(0)
## else:
## self.scanButtonGroup.setButton(1)
self.AccessPCardCommand.setText(self.user_settings.cmd_pcard)
#self.AccessPCardCommand.setEnabled(not self.user_settings.cmd_pcard_int)
## if self.user_settings.cmd_pcard_int:
## self.pcardButtonGroup.setButton(0)
## else:
## self.pcardButtonGroup.setButton(1)
self.SendFaxCommand.setText(self.user_settings.cmd_fax)
#self.SendFaxCommand.setEnabled(not self.user_settings.cmd_fax_int)
## if self.user_settings.cmd_fax_int:
## self.faxButtonGroup.setButton(0)
## else:
## self.faxButtonGroup.setButton(1)
self.MakeCopiesCommand.setText(self.user_settings.cmd_copy)
#self.MakeCopiesCommand.setEnabled(not self.user_settings.cmd_copy_int)
## if self.user_settings.cmd_copy_int:
## self.copyButtonGroup.setButton(0)
## else:
## self.copyButtonGroup.setButton(1)
def updateData(self):
self.user_settings.cmd_print = to_unicode(self.PrintCommand.text())
#self.user_settings.cmd_print_int = (self.printButtonGroup.selectedId() == 0)
self.user_settings.cmd_scan = to_unicode(self.ScanCommand.text())
#self.user_settings.cmd_scan_int = (self.scanButtonGroup.selectedId() == 0)
self.user_settings.cmd_pcard = to_unicode(self.AccessPCardCommand.text())
#self.user_settings.cmd_pcard_int = (self.pcardButtonGroup.selectedId() == 0)
self.user_settings.cmd_fax = to_unicode(self.SendFaxCommand.text())
#self.user_settings.cmd_fax_int = (self.faxButtonGroup.selectedId() == 0)
self.user_settings.cmd_copy = to_unicode(self.MakeCopiesCommand.text())
#self.user_settings.cmd_copy_int = (self.copyButtonGroup.selectedId() == 0)
## self.user_settings.email_alerts = bool(self.EmailCheckBox.isChecked())
## self.user_settings.email_to_addresses = unicode(self.EmailAddress.text())
## self.user_settings.email_from_address = unicode(self.senderLineEdit.text())
self.user_settings.auto_refresh = str(self.autoRefreshCheckBox.isChecked())
self.user_settings.auto_refresh_type = str(self.refreshScopeButtonGroup.selectedId())
self.user_settings.auto_refresh_rate = str(self.AutoRefreshRate.value())
## def PrintCmdChangeButton_clicked(self):
## pass
##
## def ScanCmdChangeButton_clicked(self):
## pass
##
## def AccessPCardCmdChangeButton_clicked(self):
## pass
##
## def SendFaxCmdChangeButton_clicked(self):
## pass
##
## def MakeCopiesCmdChangeButton_clicked(self):
## pass
def DefaultsButton_clicked(self):
self.user_settings.loadDefaults()
self.updateControls()
def TabWidget_currentChanged(self,a0):
name = str(a0.name())
if name == 'FunctionCommands':
self.DefaultsButton.setEnabled(True)
else:
self.DefaultsButton.setEnabled(False)
## def EmailTestButton_clicked(self):
## email_to_addresses = unicode(self.EmailAddress.text())
## email_from_address = unicode(self.senderLineEdit.text())
##
## if not email_to_addresses or not email_from_address:
## QMessageBox.warning(self,
## self.caption(),
## self.__tr("<b>One or more email addresses are missing.</b><p>Please enter this information and try again."),
## QMessageBox.Ok |\
## QMessageBox.NoButton,
## QMessageBox.NoButton)
## return
##
## # TODO:
#### service.setAlerts(self.hpssd_sock,
#### True,
#### email_from_address,
#### email_to_addresses)
##
## #result_code = service.testEmail(self.hpssd_sock, prop.username)
## log.debug(result_code)
##
## QMessageBox.information(self,
## self.caption(),
## 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."),
## QMessageBox.Ok |\
## QMessageBox.NoButton,
## QMessageBox.NoButton)
def autoRefreshCheckBox_clicked(self):
pass
## def CleaningLevel_clicked(self,a0):
## pass
def refreshScopeButtonGroup_clicked(self,a0):
self.auto_refresh_type = int(a0)
## def printButtonGroup_clicked(self,a0):
## self.PrintCommand.setEnabled(a0)
##
## def scanButtonGroup_clicked(self,a0):
## self.ScanCommand.setEnabled(a0)
##
## def faxButtonGroup_clicked(self,a0):
## self.SendFaxCommand.setEnabled(a0)
##
## def pcardButtonGroup_clicked(self,a0):
## self.AccessPCardCommand.setEnabled(a0)
##
## def copyButtonGroup_clicked(self,a0):
## self.MakeCopiesCommand.setEnabled(a0)
def accept(self):
self.updateData()
self.user_settings.save()
SettingsDialog_base.accept(self)
def __tr(self,s,c = None):
return qApp.translate("SettingsDialog",s,c)
|