00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdio.h>
00029 #include <qapplication.h>
00030 #include "pwentry.h"
00031
00032 PWEntry::PWEntry( QWidget *parent, const char *name )
00033 : QWidget(NULL, name) {
00034
00035 if(parent){
00036
00037 QPoint point = this->mapToGlobal (QPoint (0,0));
00038 QRect pos = this->geometry();
00039
00040 setGeometry(point.x() + pos.width()/2 - 300/2,
00041 point.y() + pos.height()/2 - 90/2,
00042 300,
00043 90);
00044 }
00045
00046
00047
00048
00049
00050
00051 frame = new QGroupBox(name, this );
00052
00053 this->setFocusPolicy( QWidget::StrongFocus );
00054
00055 pw = new QLineEdit( this, "le" );
00056 pw->setEchoMode( QLineEdit::Password );
00057 connect( pw, SIGNAL(returnPressed()), this, SLOT(hide()) );
00058
00059 isconsumed = TRUE;
00060 }
00061
00062 QString PWEntry::text() { return (pw->text()); }
00063
00064 void PWEntry::focusInEvent( QFocusEvent *){
00065
00066 pw->setFocus();
00067
00068 }
00069
00070 void PWEntry::setEchoModeNormal() {
00071
00072 pw->setEchoMode(QLineEdit::Normal);
00073
00074 }
00075
00076 void PWEntry::setEchoModePassword() {
00077
00078 pw->setEchoMode(QLineEdit::Password);
00079
00080 }
00081
00082 void PWEntry::setPrompt(const QString &p) {
00083
00084 frame->setTitle(p);
00085
00086 }
00087
00088 void PWEntry::resizeEvent(QResizeEvent* ){
00089
00090 pw->setGeometry( 15,35, this->width() - 30, 25 );
00091 frame->setGeometry(5,5,this->width() - 10, this->height() - 10 );
00092
00093 }
00094
00095
00096 void PWEntry::show() {
00097
00098 pw->setText("");
00099 isconsumed = FALSE;
00100 QWidget::show();
00101 }
00102
00103 bool PWEntry::Consumed() {
00104 return(isconsumed);
00105 }
00106
00107 void PWEntry::setConsumed() {
00108 isconsumed = TRUE;
00109 }
00110
00111 void PWEntry::hide() {
00112 QWidget::hide();
00113 return;
00114 }
00115
00116