/*************************************************************************** CEncryptedEntryView.cpp - description ------------------- begin : Fri Jan 09 2004 copyright : (C) 2004 by Alexander Theel email : alex.theel@gmx.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "../../global.h" #include "CEncryptedEntryView.h" #include "./../../information/CInformationElement.h" #include #include #include #include #include // ------------------------------------------------------------------------------- CEncryptedEntryView::CEncryptedEntryView( QWidget* pParent ) : QWidget( pParent ) , mpPasswdField( NULLPTR ) , mpResultLabel( NULLPTR ) , mpActiveElement( NULLPTR ) // ------------------------------------------------------------------------------- { QVBoxLayout* pLayout = new QVBoxLayout( this, 10, 5 ); QLabel* pLabel = new QLabel( this ); mpPasswdField = new QLineEdit( this ); mpResultLabel = new QLabel( this ); QHBoxLayout* pMiniLayout = new QHBoxLayout( ); if ( (NULLPTR == pLayout) || (NULLPTR == pLabel) || (NULLPTR == mpPasswdField) || (NULLPTR == mpResultLabel) || (NULLPTR == pMiniLayout) ) { std::cout<<"Constructor 'CEncriptedEntryView': ERROR not enough memory " <<" to create objects!!!"<addWidget( mpPasswdField ); pLayout->addStretch(); pLayout->addWidget( pLabel ); pLayout->addLayout( pMiniLayout ); pLayout->addWidget( mpResultLabel ); pLayout->addStretch(); pLayout->addStretch(); pLayout->addStretch(); pLabel->setText("
" "Encripted Entry
" "To view entry content enter password below and press RETURN." "
"); mpPasswdField->setEchoMode( QLineEdit::Password ); mpPasswdField->setMaximumWidth( 200 ); mpResultLabel->setText(" "); connect( mpPasswdField, SIGNAL(returnPressed()), this, SLOT(passwdEntered()) ); } // ------------------------------------------------------------------------------- CEncryptedEntryView::~CEncryptedEntryView( void ) // ------------------------------------------------------------------------------- { // mpInformationElement = NULLPTR; } // ************** IView ********************************************************* // ------------------------------------------------------------------------------- void CEncryptedEntryView::aboutToRemoveElement( CInformationElement* pIE ) // ------------------------------------------------------------------------------- { if ( mpActiveElement == pIE ) { mpActiveElement = NULLPTR; } } // ************** IView - End **************************************************** // ------------------------------------------------------------------------------- void CEncryptedEntryView::activeInformationElementChanged( CInformationElement* pIE ) // ------------------------------------------------------------------------------- { if ( NULLPTR == pIE ) return; if ( (NULLPTR == mpPasswdField) || (NULLPTR == mpResultLabel) ) return; mpPasswdField->setText(""); mpPasswdField->setFocus(); mpResultLabel->setText(""); mpActiveElement = pIE; } // ------------------------------------------------------------------------------- void CEncryptedEntryView::passwdEntered( void ) // ------------------------------------------------------------------------------- { if ( (NULLPTR == mpPasswdField) || (NULLPTR == mpResultLabel) ) return; if ( NULLPTR == mpActiveElement ) return; // testing passwd if ( 0 == mpPasswdField->text().stripWhiteSpace().length() ) return; bool bCorrectPasswd = mpActiveElement->decrypt( mpPasswdField->text().stripWhiteSpace() ); if ( !bCorrectPasswd ) { mpPasswdField->setText(""); mpResultLabel->setText("
Wrong Passwd. Try again.
"); } else { // every thing is alright mpResultLabel->setText(" "); emit entryDecrypted(); } }