~mimose/+junk/hplip-3.16.11

« back to all changes in this revision

Viewing changes to ui/settingsdialog.py

  • Committer: guoyalong
  • Date: 2017-09-20 10:13:05 UTC
  • Revision ID: guoyalong@kylinos.cn-20170920101305-82zaolzpv1qghz29
Modified debian/control & debian/rules.

Show diffs side-by-side

added added

removed removed

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