summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp96
-rw-r--r--noncore/apps/checkbook/checkbook.h9
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp26
-rw-r--r--noncore/apps/checkbook/mainwindow.h2
-rw-r--r--noncore/apps/checkbook/password.cpp99
-rw-r--r--noncore/apps/checkbook/password.h55
-rw-r--r--noncore/apps/checkbook/transaction.cpp2
-rw-r--r--noncore/apps/checkbook/transaction.h4
9 files changed, 264 insertions, 31 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 09b0b46..5a6d607 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -32,2 +32,3 @@
32#include "graphinfo.h" 32#include "graphinfo.h"
33#include "password.h"
33 34
@@ -39,2 +40,3 @@
39 40
41#include <qcheckbox.h>
40#include <qcombobox.h> 42#include <qcombobox.h>
@@ -50,3 +52,3 @@
50 52
51Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) 53Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, const QString &symbol )
52 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 54 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
@@ -118,2 +120,8 @@ QWidget *Checkbook::initInfo()
118 120
121 // Password protection
122 passwordCB = new QCheckBox( tr( "Password protect" ), container );
123 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
124 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
125 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
126
119 // Account name 127 // Account name
@@ -121,3 +129,3 @@ QWidget *Checkbook::initInfo()
121 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 129 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
122 layout->addWidget( label, 0, 0 ); 130 layout->addWidget( label, 1, 0 );
123 nameEdit = new QLineEdit( container ); 131 nameEdit = new QLineEdit( container );
@@ -126,3 +134,3 @@ QWidget *Checkbook::initInfo()
126 this, SLOT( slotNameChanged( const QString & ) ) ); 134 this, SLOT( slotNameChanged( const QString & ) ) );
127 layout->addWidget( nameEdit, 0, 1 ); 135 layout->addWidget( nameEdit, 1, 1 );
128 136
@@ -131,3 +139,3 @@ QWidget *Checkbook::initInfo()
131 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 139 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
132 layout->addWidget( label, 1, 0 ); 140 layout->addWidget( label, 2, 0 );
133 typeList = new QComboBox( container ); 141 typeList = new QComboBox( container );
@@ -140,3 +148,3 @@ QWidget *Checkbook::initInfo()
140 typeList->insertItem( tr( "Other" ) ); // 5 148 typeList->insertItem( tr( "Other" ) ); // 5
141 layout->addWidget( typeList, 1, 1 ); 149 layout->addWidget( typeList, 2, 1 );
142 150
@@ -145,6 +153,6 @@ QWidget *Checkbook::initInfo()
145 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); 153 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
146 layout->addWidget( label, 2, 0 ); 154 layout->addWidget( label, 3, 0 );
147 bankEdit = new QLineEdit( container ); 155 bankEdit = new QLineEdit( container );
148 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); 156 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
149 layout->addWidget( bankEdit, 2, 1 ); 157 layout->addWidget( bankEdit, 3, 1 );
150 158
@@ -153,6 +161,6 @@ QWidget *Checkbook::initInfo()
153 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 161 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
154 layout->addWidget( label, 3, 0 ); 162 layout->addWidget( label, 4, 0 );
155 acctNumEdit = new QLineEdit( container ); 163 acctNumEdit = new QLineEdit( container );
156 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 164 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
157 layout->addWidget( acctNumEdit, 3, 1 ); 165 layout->addWidget( acctNumEdit, 4, 1 );
158 166
@@ -161,6 +169,6 @@ QWidget *Checkbook::initInfo()
161 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 169 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
162 layout->addWidget( label, 4, 0 ); 170 layout->addWidget( label, 5, 0 );
163 pinNumEdit = new QLineEdit( container ); 171 pinNumEdit = new QLineEdit( container );
164 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 172 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
165 layout->addWidget( pinNumEdit, 4, 1 ); 173 layout->addWidget( pinNumEdit, 5, 1 );
166 174
@@ -169,3 +177,3 @@ QWidget *Checkbook::initInfo()
169 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); 177 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
170 layout->addWidget( label, 5, 0 ); 178 layout->addWidget( label, 6, 0 );
171 balanceEdit = new QLineEdit( container ); 179 balanceEdit = new QLineEdit( container );
@@ -174,3 +182,3 @@ QWidget *Checkbook::initInfo()
174 this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); 182 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
175 layout->addWidget( balanceEdit, 5, 1 ); 183 layout->addWidget( balanceEdit, 6, 1 );
176 184
@@ -179,7 +187,8 @@ QWidget *Checkbook::initInfo()
179 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); 187 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
180 layout->addWidget( label, 6, 0 ); 188 layout->addWidget( label, 7, 0 );
181 notesEdit = new QMultiLineEdit( container ); 189 notesEdit = new QMultiLineEdit( container );
182 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); 190 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
183 notesEdit->setMaximumHeight( 85 ); 191 notesEdit->setMinimumHeight( 25 );
184 layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); 192 notesEdit->setMaximumHeight( 65 );
193 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
185 194
@@ -268,3 +277,3 @@ void Checkbook::loadCheckbook()
268 277
269 Config config(filename, Config::File); 278 Config config( filename, Config::File );
270 279
@@ -272,2 +281,5 @@ void Checkbook::loadCheckbook()
272 config.setGroup( "Account" ); 281 config.setGroup( "Account" );
282
283 password = config.readEntryCrypt( "Password", "" );
284 passwordCB->setChecked( password != "" );
273 nameEdit->setText( name ); 285 nameEdit->setText( name );
@@ -312,3 +324,3 @@ void Checkbook::loadCheckbook()
312 currBalance += amount; 324 currBalance += amount;
313 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 325 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
314 326
@@ -362,2 +374,3 @@ void Checkbook::accept()
362 config->setGroup( "Account" ); 374 config->setGroup( "Account" );
375 config->writeEntryCrypt( "Password", password );
363 config->writeEntry( "Type", typeList->currentText() ); 376 config->writeEntry( "Type", typeList->currentText() );
@@ -381,2 +394,44 @@ void Checkbook::accept()
381 394
395void Checkbook::slotPasswordClicked()
396{
397 if ( password == "" && passwordCB->isChecked() )
398 {
399 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
400 if ( pw->exec() != QDialog::Accepted )
401 {
402 passwordCB->setChecked( FALSE );
403 delete pw;
404 return;
405 }
406 password = pw->password;
407 delete pw;
408
409 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
410 if ( pw->exec() != QDialog::Accepted || pw->password != password )
411 {
412 passwordCB->setChecked( FALSE );
413 password = "";
414 }
415
416 delete pw;
417 }
418 else if ( password != "" && !passwordCB->isChecked() )
419 {
420 Password *pw = new Password( this, tr( "Enter password" ),
421 tr( "Please enter your password to confirm removal of password protection:" ) );
422 if ( pw->exec() == QDialog::Accepted && pw->password == password )
423 {
424 password = "";
425 delete pw;
426 return;
427 }
428 else
429 {
430 passwordCB->setChecked( TRUE );
431 }
432
433 delete pw;
434 }
435}
436
382void Checkbook::slotNameChanged( const QString &newname ) 437void Checkbook::slotNameChanged( const QString &newname )
@@ -418,3 +473,3 @@ void Checkbook::slotNewTran()
418 QString stramount; 473 QString stramount;
419 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 474 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
420 475
@@ -438,3 +493,2 @@ void Checkbook::slotEditTran()
438{ 493{
439 bool ok;
440 QListViewItem *curritem = tranTable->currentItem(); 494 QListViewItem *curritem = tranTable->currentItem();
@@ -470,3 +524,3 @@ void Checkbook::slotEditTran()
470 QString stramount; 524 QString stramount;
471 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 525 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
472 curritem->setText( 3, stramount ); 526 curritem->setText( 3, stramount );
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
index 0260b43..27658ff 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -40,2 +40,3 @@ class Graph;
40class GraphInfo; 40class GraphInfo;
41class QCheckBox;
41class QComboBox; 42class QComboBox;
@@ -52,3 +53,4 @@ class Checkbook : public QDialog
52 public: 53 public:
53 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); 54 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0,
55 const QString & = "$" );
54 ~Checkbook(); 56 ~Checkbook();
@@ -62,3 +64,4 @@ class Checkbook : public QDialog
62 QString filedir; 64 QString filedir;
63 char currencySymbol; 65 QString currencySymbol;
66 QString password;
64 int highTranNum; 67 int highTranNum;
@@ -72,2 +75,3 @@ class Checkbook : public QDialog
72 QWidget *initInfo(); 75 QWidget *initInfo();
76 QCheckBox *passwordCB;
73 QLineEdit *nameEdit; 77 QLineEdit *nameEdit;
@@ -100,2 +104,3 @@ class Checkbook : public QDialog
100 private slots: 104 private slots:
105 void slotPasswordClicked();
101 void slotNameChanged( const QString & ); 106 void slotNameChanged( const QString & );
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index bd69939..53b5ff4 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -5,2 +5,3 @@ HEADERS = mainwindow.h \
5 graphinfo.h \ 5 graphinfo.h \
6 password.h \
6 checkbook.h \ 7 checkbook.h \
@@ -12,2 +13,3 @@ SOURCES = main.cpp \
12 graphinfo.cpp \ 13 graphinfo.cpp \
14 password.cpp \
13 checkbook.cpp \ 15 checkbook.cpp \
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 567b8ad..2c0abf1 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -29,4 +29,6 @@
29#include "mainwindow.h" 29#include "mainwindow.h"
30#include "password.h"
30#include "checkbook.h" 31#include "checkbook.h"
31 32
33#include <qpe/config.h>
32#include <qpe/global.h> 34#include <qpe/global.h>
@@ -107,3 +109,3 @@ MainWindow::MainWindow()
107 109
108 currencySymbol = '$'; 110 currencySymbol = "$";
109} 111}
@@ -129,2 +131,21 @@ void MainWindow::slotEdit()
129 QString currname = cbList->currentText(); 131 QString currname = cbList->currentText();
132
133 QString tempstr = cbDir;
134 tempstr.append( currname );
135 tempstr.append( ".qcb" );
136
137 Config config( tempstr, Config::File );
138 config.setGroup( "Account" );
139 QString password = config.readEntryCrypt( "Password", "" );
140 if ( password != "" )
141 {
142 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
143 if ( pw->exec() != QDialog::Accepted || pw->password != password )
144 {
145 delete pw;
146 return;
147 }
148 delete pw;
149 }
150
130 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); 151 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol );
@@ -139,5 +160,2 @@ void MainWindow::slotEdit()
139 160
140 QString tempstr = cbDir;
141 tempstr.append( currname );
142 tempstr.append( ".qcb" );
143 QFile f( tempstr ); 161 QFile f( tempstr );
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h
index 1b460fa..11a3343 100644
--- a/noncore/apps/checkbook/mainwindow.h
+++ b/noncore/apps/checkbook/mainwindow.h
@@ -51,3 +51,3 @@ class MainWindow : public QMainWindow
51 QAction *actionDelete; 51 QAction *actionDelete;
52 char currencySymbol; 52 QString currencySymbol;
53 53
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}
diff --git a/noncore/apps/checkbook/password.h b/noncore/apps/checkbook/password.h
new file mode 100644
index 0000000..87d64d9
--- a/dev/null
+++ b/noncore/apps/checkbook/password.h
@@ -0,0 +1,55 @@
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#ifndef PASSWORD_H
30#define PASSWORD_H
31
32#include <qdialog.h>
33
34class QLineEdit;
35class QWidget;
36
37class Password : public QDialog
38{
39 Q_OBJECT
40
41 public:
42 Password( QWidget *, const char *, const char * );
43 ~Password();
44
45 QString password;
46
47 private:
48 QLineEdit *pw;
49
50 protected slots:
51 void accept();
52 void slotTogglePassword( bool );
53};
54
55#endif
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 122c8d6..17be669 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -48,3 +48,3 @@
48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, 48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
49 char symbol ) 49 const QString &symbol )
50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h
index 89ca8e4..000aee7 100644
--- a/noncore/apps/checkbook/transaction.h
+++ b/noncore/apps/checkbook/transaction.h
@@ -49,3 +49,3 @@ class Transaction : public QDialog
49 Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, 49 Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0,
50 char = '$' ); 50 const QString & = "$" );
51 ~Transaction(); 51 ~Transaction();
@@ -55,3 +55,3 @@ class Transaction : public QDialog
55 55
56 char currencySymbol; 56 QString currencySymbol;
57 57