Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

password.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the OPIE Project
00003                =.
00004              .=l.            Copyright (c)  2002 Dan Williams <drw@handhelds.org>
00005            .>+-=
00006  _;:,     .>    :=|.         This file is free software; you can
00007 .> <`_,   >  .   <=          redistribute it and/or modify it under
00008 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00009 .="- .-=="i,     .._         License as published by the Free Software
00010  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00011      ._= =}       :          or (at your option) any later version.
00012     .%`+i>       _;_.
00013     .i_,=:_.      -<s.       This file is distributed in the hope that
00014      +  .  -:.       =       it will be useful, but WITHOUT ANY WARRANTY;
00015     : ..    .:,     . . .    without even the implied warranty of
00016     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00017   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU General
00018 ..}^=.=       =       ;      Public License for more details.
00019 ++=   -.     .`     .:
00020  :     =  ...= . :.=-        You should have received a copy of the GNU
00021  -.   .:....=;==+<;          General Public License along with this file;
00022   -_. . .   )=.  =           see the file COPYING. If not, write to the
00023     --        :-=`           Free Software Foundation, Inc.,
00024                              59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
00026 
00027 */
00028 
00029 #include "password.h"
00030 
00031 #include <qlabel.h>
00032 #include <qlayout.h>
00033 #include <qlineedit.h>
00034 #include <qpushbutton.h>
00035 
00036 static const char* const showhideimage_data[] = {
00037 "16 16 2 1",
00038 ". c None",
00039 "# c #000000",
00040 "................",
00041 "...#...###...##.",
00042 "..#.#..#..#.##..",
00043 "..###..###.##...",
00044 ".#...#.#..##....",
00045 ".#...#.#.##.....",
00046 "........##.#..#.",
00047 "..##...##...##..",
00048 ".#..#.###...##..",
00049 ".#...##..#.#..#.",
00050 ".#..##..........",
00051 ".#.##.#..#.#..#.",
00052 "..##...##...##..",
00053 ".##....##...##..",
00054 ".#....#..#.#..#.",
00055 "................"};
00056 
00057 Password::Password( QWidget *parent, const char *caption, const char *prompt )
00058         : QDialog( parent, 0x0, TRUE, 0x0 )
00059 {
00060         setCaption( caption );
00061 
00062         QGridLayout *layout = new QGridLayout( this );
00063         layout->setSpacing( 2 );
00064         layout->setMargin( 4 );
00065 
00066         QLabel *label = new QLabel( prompt, this );
00067         label->setAlignment( AlignLeft | AlignTop | WordBreak );
00068         layout->addMultiCellWidget( label, 0, 0, 0, 1 );
00069 
00070         pw = new QLineEdit( this );
00071         pw->setEchoMode( QLineEdit::Password );
00072         layout->addWidget( pw, 1, 0 );
00073 
00074         QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data );
00075         QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this );
00076         btn->setMaximumSize( pic->width() + 10, pic->height() + 10 );
00077         btn->setToggleButton( TRUE );
00078         connect( btn, SIGNAL( toggled(bool) ), this, SLOT( slotTogglePassword(bool) ) );
00079         layout->addWidget( btn, 1, 1 );
00080         
00081         password == "";
00082 }
00083 
00084 Password::~Password()
00085 {
00086 }
00087 
00088 void Password::accept()
00089 {
00090         password = pw->text();
00091         QDialog::accept();
00092 }
00093 
00094 void Password::slotTogglePassword( bool showPW )
00095 {
00096         showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password );
00097 }

Generated on Sat Nov 5 16:16:37 2005 for OPIE by  doxygen 1.4.2