KIO
passworddialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "passworddialog.h"
00019
00020 #include <QCheckBox>
00021 #include <QLabel>
00022 #include <QLayout>
00023 #include <QTextDocument>
00024 #include <QTextLayout>
00025
00026 #include <kapplication.h>
00027 #include <kcombobox.h>
00028 #include <kconfig.h>
00029 #include <kiconloader.h>
00030 #include <klineedit.h>
00031 #include <klocale.h>
00032 #include <khbox.h>
00033
00034 using namespace KIO;
00035
00036 PasswordDialog::PasswordDialog( const QString& prompt, const QString& user,
00037 bool enableKeep, bool modal, QWidget* parent )
00038 :KPasswordDialog( parent , enableKeep ? (ShowUsernameLine | ShowKeepPassword) : ShowUsernameLine )
00039 {
00040 setModal( modal );
00041 setPrompt(prompt);
00042 setUsername( user );
00043 }
00044
00045 PasswordDialog::~PasswordDialog()
00046 {
00047 }
00048
00049
00050 int PasswordDialog::getNameAndPassword( QString& user, QString& pass, bool* keep,
00051 const QString& prompt, bool readOnly,
00052 const QString& caption,
00053 const QString& comment,
00054 const QString& label )
00055 {
00056 PasswordDialog* dlg;
00057 dlg = new PasswordDialog( prompt, user, keep );
00058
00059 if ( !caption.isEmpty() )
00060 dlg->setCaption( caption );
00061 else
00062 dlg->setCaption( i18n("Authorization Dialog") );
00063
00064 if ( !comment.isEmpty() )
00065 dlg->addCommentLine( label, comment );
00066
00067 if ( readOnly )
00068 dlg->setUsernameReadOnly( readOnly );
00069
00070 if ( keep )
00071 dlg->setKeepPassword( *keep );
00072
00073 int ret = dlg->exec();
00074 if ( ret == Accepted )
00075 {
00076 user = dlg->username();
00077 pass = dlg->password();
00078 if ( keep ) { (*keep) = dlg->keepPassword(); }
00079 }
00080 delete dlg;
00081 return ret;
00082 }
00083
00084
00085 #include "passworddialog.moc"