home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1266 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.3 KB  |  55 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  6. import re
  7. from PyQt4.QtGui import QDialog, QLineEdit
  8. from PyQt4.QtCore import SIGNAL, Qt
  9. from calibre.gui2.dialogs.password_ui import Ui_Dialog
  10. from calibre.gui2 import dynamic
  11.  
  12. class PasswordDialog(QDialog, Ui_Dialog):
  13.     
  14.     def __init__(self, window, name, msg):
  15.         QDialog.__init__(self, window)
  16.         Ui_Dialog.__init__(self)
  17.         self.setupUi(self)
  18.         self.cfg_key = re.sub('[^0-9a-zA-Z]', '_', name)
  19.         un = dynamic[self.cfg_key + '__un']
  20.         pw = dynamic[self.cfg_key + '__pw']
  21.         if not un:
  22.             un = ''
  23.         
  24.         if not pw:
  25.             pw = ''
  26.         
  27.         self.gui_username.setText(un)
  28.         self.gui_password.setText(pw)
  29.         self.sname = name
  30.         self.msg.setText(msg)
  31.         self.connect(self.show_password, SIGNAL('stateChanged(int)'), self.toggle_password)
  32.  
  33.     
  34.     def toggle_password(self, state):
  35.         if state == Qt.Unchecked:
  36.             self.gui_password.setEchoMode(QLineEdit.Password)
  37.         else:
  38.             self.gui_password.setEchoMode(QLineEdit.Normal)
  39.  
  40.     
  41.     def username(self):
  42.         return unicode(self.gui_username.text())
  43.  
  44.     
  45.     def password(self):
  46.         return unicode(self.gui_password.text())
  47.  
  48.     
  49.     def accept(self):
  50.         dynamic.set(self.cfg_key + '__un', unicode(self.gui_username.text()))
  51.         dynamic.set(self.cfg_key + '__pw', unicode(self.gui_password.text()))
  52.         QDialog.accept(self)
  53.  
  54.  
  55.