certmanager/lib
passphrasedialog.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef HAVE_CONFIG_H
00050 #include <config.h>
00051 #endif
00052
00053 #include "passphrasedialog.h"
00054
00055 #include <kpassdlg.h>
00056 #include <kiconloader.h>
00057 #include <klocale.h>
00058
00059 #include <qlabel.h>
00060 #include <qlayout.h>
00061 #include <qfontmetrics.h>
00062
00063 struct Kleo::PassphraseDialog::Private {
00064 KPasswordEdit * lineedit;
00065 };
00066
00067
00068 Kleo::PassphraseDialog::PassphraseDialog( const QString & msg, const QString & caption,
00069 QWidget * parent, const char * name, bool modal )
00070 : KDialogBase( parent, name, modal, caption, Ok|Cancel, Ok ), d( 0 )
00071 {
00072 d = new Private();
00073
00074 QWidget * w = new QWidget( this );
00075 setMainWidget( w );
00076
00077 QHBoxLayout * hlay = new QHBoxLayout( w, 0, spacingHint() );
00078
00079 QLabel * label = new QLabel( w );
00080 label->setPixmap( DesktopIcon( "pgp-keys", KIcon::SizeMedium ) );
00081 hlay->addWidget( label, 0, AlignTop );
00082
00083 QVBoxLayout * vlay = new QVBoxLayout( hlay );
00084
00085 vlay->addWidget( new QLabel( msg.isEmpty() ? i18n("Please enter your passphrase:") : msg, w ) );
00086
00087 d->lineedit = new KPasswordEdit( KPasswordEdit::OneStar, w, "d->lineedit" );
00088 d->lineedit->setMinimumWidth( fontMetrics().width("*") * 20 );
00089 d->lineedit->setFocus();
00090
00091 vlay->addWidget( d->lineedit );
00092
00093 connect( d->lineedit, SIGNAL(returnPressed()), SLOT(slotOk()) );
00094
00095 disableResize();
00096 }
00097
00098
00099 Kleo::PassphraseDialog::~PassphraseDialog() {
00100 delete d; d = 0;
00101 }
00102
00103 const char * Kleo::PassphraseDialog::passphrase() const {
00104 return d->lineedit->password();
00105 }
00106
00107 void Kleo::PassphraseDialog::slotOk() {
00108 const char * pass = passphrase();
00109 emit finished( pass ? pass : "" );
00110 KDialogBase::slotOk();
00111 }
00112
00113 void Kleo::PassphraseDialog::slotCancel() {
00114 emit canceled();
00115 KDialogBase::slotCancel();
00116 }
00117
00118
00119 void Kleo::PassphraseDialog::virtual_hook( int id, void * data ) {
00120 return KDialogBase::virtual_hook( id, data );
00121 }
00122
00123 #include "passphrasedialog.moc"
|