Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 96 |
1 files changed, 75 insertions, 21 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 @@ #include "graphinfo.h" +#include "password.h" @@ -39,2 +40,3 @@ +#include <qcheckbox.h> #include <qcombobox.h> @@ -50,3 +52,3 @@ -Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) +Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, const QString &symbol ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) @@ -118,2 +120,8 @@ QWidget *Checkbook::initInfo() + // Password protection + passwordCB = new QCheckBox( tr( "Password protect" ), container ); + QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); + connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); + layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); + // Account name @@ -121,3 +129,3 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); - layout->addWidget( label, 0, 0 ); + layout->addWidget( label, 1, 0 ); nameEdit = new QLineEdit( container ); @@ -126,3 +134,3 @@ QWidget *Checkbook::initInfo() this, SLOT( slotNameChanged( const QString & ) ) ); - layout->addWidget( nameEdit, 0, 1 ); + layout->addWidget( nameEdit, 1, 1 ); @@ -131,3 +139,3 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); - layout->addWidget( label, 1, 0 ); + layout->addWidget( label, 2, 0 ); typeList = new QComboBox( container ); @@ -140,3 +148,3 @@ QWidget *Checkbook::initInfo() typeList->insertItem( tr( "Other" ) ); // 5 - layout->addWidget( typeList, 1, 1 ); + layout->addWidget( typeList, 2, 1 ); @@ -145,6 +153,6 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); - layout->addWidget( label, 2, 0 ); + layout->addWidget( label, 3, 0 ); bankEdit = new QLineEdit( container ); QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); - layout->addWidget( bankEdit, 2, 1 ); + layout->addWidget( bankEdit, 3, 1 ); @@ -153,6 +161,6 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); - layout->addWidget( label, 3, 0 ); + layout->addWidget( label, 4, 0 ); acctNumEdit = new QLineEdit( container ); QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); - layout->addWidget( acctNumEdit, 3, 1 ); + layout->addWidget( acctNumEdit, 4, 1 ); @@ -161,6 +169,6 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); - layout->addWidget( label, 4, 0 ); + layout->addWidget( label, 5, 0 ); pinNumEdit = new QLineEdit( container ); QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); - layout->addWidget( pinNumEdit, 4, 1 ); + layout->addWidget( pinNumEdit, 5, 1 ); @@ -169,3 +177,3 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); - layout->addWidget( label, 5, 0 ); + layout->addWidget( label, 6, 0 ); balanceEdit = new QLineEdit( container ); @@ -174,3 +182,3 @@ QWidget *Checkbook::initInfo() this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); - layout->addWidget( balanceEdit, 5, 1 ); + layout->addWidget( balanceEdit, 6, 1 ); @@ -179,7 +187,8 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); - layout->addWidget( label, 6, 0 ); + layout->addWidget( label, 7, 0 ); notesEdit = new QMultiLineEdit( container ); QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); - notesEdit->setMaximumHeight( 85 ); - layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); + notesEdit->setMinimumHeight( 25 ); + notesEdit->setMaximumHeight( 65 ); + layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); @@ -268,3 +277,3 @@ void Checkbook::loadCheckbook() - Config config(filename, Config::File); + Config config( filename, Config::File ); @@ -272,2 +281,5 @@ void Checkbook::loadCheckbook() config.setGroup( "Account" ); + + password = config.readEntryCrypt( "Password", "" ); + passwordCB->setChecked( password != "" ); nameEdit->setText( name ); @@ -312,3 +324,3 @@ void Checkbook::loadCheckbook() currBalance += amount; - stramount.sprintf( "%c%.2f", currencySymbol, amount ); + stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); @@ -362,2 +374,3 @@ void Checkbook::accept() config->setGroup( "Account" ); + config->writeEntryCrypt( "Password", password ); config->writeEntry( "Type", typeList->currentText() ); @@ -381,2 +394,44 @@ void Checkbook::accept() +void Checkbook::slotPasswordClicked() +{ + if ( password == "" && passwordCB->isChecked() ) + { + Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); + if ( pw->exec() != QDialog::Accepted ) + { + passwordCB->setChecked( FALSE ); + delete pw; + return; + } + password = pw->password; + delete pw; + + pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); + if ( pw->exec() != QDialog::Accepted || pw->password != password ) + { + passwordCB->setChecked( FALSE ); + password = ""; + } + + delete pw; + } + else if ( password != "" && !passwordCB->isChecked() ) + { + Password *pw = new Password( this, tr( "Enter password" ), + tr( "Please enter your password to confirm removal of password protection:" ) ); + if ( pw->exec() == QDialog::Accepted && pw->password == password ) + { + password = ""; + delete pw; + return; + } + else + { + passwordCB->setChecked( TRUE ); + } + + delete pw; + } +} + void Checkbook::slotNameChanged( const QString &newname ) @@ -418,3 +473,3 @@ void Checkbook::slotNewTran() QString stramount; - stramount.sprintf( "%c%.2f", currencySymbol, amount ); + stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); @@ -438,3 +493,2 @@ void Checkbook::slotEditTran() { - bool ok; QListViewItem *curritem = tranTable->currentItem(); @@ -470,3 +524,3 @@ void Checkbook::slotEditTran() QString stramount; - stramount.sprintf( "%c%.2f", currencySymbol, amount ); + stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); curritem->setText( 3, stramount ); |