summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/password.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/password.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/checkbook/password.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp
new file mode 100644
index 0000000..82020d5
--- a/dev/null
+++ b/noncore/apps/checkbook/password.cpp
@@ -0,0 +1,99 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "password.h"
30
31#include <qlabel.h>
32#include <qlayout.h>
33#include <qlineedit.h>
34#include <qpixmap.h>
35#include <qpushbutton.h>
36#include <qwidget.h>
37
38static const char* const showhideimage_data[] = {
39"16 16 2 1",
40". c None",
41"# c #000000",
42"................",
43"...#...###...##.",
44"..#.#..#..#.##..",
45"..###..###.##...",
46".#...#.#..##....",
47".#...#.#.##.....",
48"........##.#..#.",
49"..##...##...##..",
50".#..#.###...##..",
51".#...##..#.#..#.",
52".#..##..........",
53".#.##.#..#.#..#.",
54"..##...##...##..",
55".##....##...##..",
56".#....#..#.#..#.",
57"................"};
58
59Password::Password( QWidget *parent, const char *caption, const char *prompt )
60 : QDialog( parent, 0x0, TRUE, 0x0 )
61{
62 setCaption( caption );
63
64 QGridLayout *layout = new QGridLayout( this );
65 layout->setSpacing( 2 );
66 layout->setMargin( 4 );
67
68 QLabel *label = new QLabel( prompt, this );
69 label->setAlignment( AlignLeft | AlignTop | WordBreak );
70 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
71
72 pw = new QLineEdit( this );
73 pw->setEchoMode( QLineEdit::Password );
74 layout->addWidget( pw, 1, 0 );
75
76 QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data );
77 QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this );
78 btn->setMaximumSize( pic->width() + 10, pic->height() + 10 );
79 btn->setToggleButton( TRUE );
80 connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) );
81 layout->addWidget( btn, 1, 1 );
82
83 password == "";
84}
85
86Password::~Password()
87{
88}
89
90void Password::accept()
91{
92 password = pw->text();
93 QDialog::accept();
94}
95
96void Password::slotTogglePassword( bool showPW )
97{
98 showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password );
99}