kmwpassword.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kmwpassword.h"
00021 #include "kmwizard.h"
00022 #include "kmprinter.h"
00023
00024 #include <qlabel.h>
00025 #include <qlineedit.h>
00026 #include <qcheckbox.h>
00027 #include <qlayout.h>
00028 #include <klocale.h>
00029 #include <kcursor.h>
00030
00031 #include <stdlib.h>
00032
00033 KMWPassword::KMWPassword(QWidget *parent, const char *name)
00034 : KMWizardPage(parent,name)
00035 {
00036 m_title = i18n("User Identification");
00037 m_ID = KMWizard::Password;
00038 m_nextpage = KMWizard::SMB;
00039
00040
00041 QLabel *infotext_ = new QLabel(this);
00042 infotext_->setText(i18n("<p>This backend may require a login/password to work properly. "
00043 "Fill in the required entries or enable <b>Guest account</b> to "
00044 "use anonymous access.</p>"));
00045 m_login = new QLineEdit(this);
00046 m_login->setText(QString::fromLocal8Bit(getenv("USER")));
00047 m_password = new QLineEdit(this);
00048 m_password->setEchoMode(QLineEdit::Password);
00049 QLabel *loginlabel_ = new QLabel(i18n("&Login:"),this);
00050 QLabel *passwdlabel_ = new QLabel(i18n("&Password:"),this);
00051 m_guest = new QCheckBox(i18n("&Guest account"),this);
00052 m_guest->setCursor(KCursor::handCursor());
00053
00054 loginlabel_->setBuddy(m_login);
00055 passwdlabel_->setBuddy(m_password);
00056
00057 m_guest->setChecked(true);
00058 m_login->setEnabled(false);
00059 m_password->setEnabled(false);
00060 connect(m_guest,SIGNAL(toggled(bool)),m_login,SLOT(setDisabled(bool)));
00061 connect(m_guest,SIGNAL(toggled(bool)),m_password,SLOT(setDisabled(bool)));
00062
00063
00064 QGridLayout *main_ = new QGridLayout(this, 7, 2, 0, 5);
00065 main_->setRowStretch(6,1);
00066 main_->setColStretch(1,1);
00067 main_->addRowSpacing(1,20);
00068 main_->addRowSpacing(4,20);
00069 main_->addMultiCellWidget(infotext_, 0, 0, 0, 1);
00070 main_->addWidget(loginlabel_, 2, 0);
00071 main_->addWidget(passwdlabel_, 3, 0);
00072 main_->addWidget(m_login, 2, 1);
00073 main_->addWidget(m_password, 3, 1);
00074 main_->addMultiCellWidget(m_guest, 5, 5, 0, 1);
00075 }
00076
00077 bool KMWPassword::isValid(QString& msg)
00078 {
00079 if (!m_guest->isChecked() && m_login->text().isEmpty())
00080 {
00081 msg = i18n("User name is empty!");
00082 return false;
00083 }
00084 return true;
00085 }
00086
00087 void KMWPassword::updatePrinter(KMPrinter *p)
00088 {
00089 QString s = p->option("kde-backend");
00090 if (!s.isEmpty()) setNextPage(s.toInt());
00091 else setNextPage(KMWizard::Error);
00092 if (m_guest->isChecked())
00093 {
00094 p->setOption("kde-login",QString::null);
00095 p->setOption("kde-password",QString::null);
00096 }
00097 else
00098 {
00099 p->setOption("kde-login",m_login->text());
00100 p->setOption("kde-password",m_password->text());
00101 }
00102 }
00103
This file is part of the documentation for kdeprint Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:45:13 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003