KIO
passworddialog.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 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"
KDE 4.6 API Reference