20 #include "kmwpassword.h"
22 #include "kmprinter.h"
25 #include <tqlineedit.h>
26 #include <tqvbuttongroup.h>
27 #include <tqradiobutton.h>
29 #include <tdelocale.h>
34 KMWPassword::KMWPassword(TQWidget *parent,
const char *name)
35 : KMWizardPage(parent,name)
37 m_title = i18n(
"User Identification");
38 m_ID = KMWizard::Password;
39 m_nextpage = KMWizard::SMB;
42 TQLabel *infotext_ =
new TQLabel(
this);
43 infotext_->setText(i18n(
"<p>This backend may require a login/password to work properly. "
44 "Select the type of access to use and fill in the login and password entries if needed.</p>"));
45 m_login =
new TQLineEdit(
this);
46 m_login->setText(TQString::fromLocal8Bit(getenv(
"USER")));
47 m_password =
new TQLineEdit(
this);
48 m_password->setEchoMode(TQLineEdit::Password);
49 TQLabel *loginlabel_ =
new TQLabel(i18n(
"&Login:"),
this);
50 TQLabel *passwdlabel_ =
new TQLabel(i18n(
"&Password:"),
this);
51 m_btngroup =
new TQVButtonGroup(
this );
52 m_btngroup->setFrameStyle( TQFrame::NoFrame );
53 TQRadioButton *btn1 =
new TQRadioButton( i18n(
"&Anonymous (no login/password)" ), m_btngroup );
54 TQRadioButton *btn2 =
new TQRadioButton( i18n(
"&Guest account (login=\"guest\")" ), m_btngroup );
55 TQRadioButton *btn3 =
new TQRadioButton( i18n(
"Nor&mal account" ), m_btngroup );
56 btn1->setCursor( KCursor::handCursor() );
57 btn2->setCursor( KCursor::handCursor() );
58 btn3->setCursor( KCursor::handCursor() );
59 m_btngroup->setButton( 0 );
61 loginlabel_->setBuddy(m_login);
62 passwdlabel_->setBuddy(m_password);
64 m_login->setEnabled(
false);
65 m_password->setEnabled(
false);
66 connect(btn3,TQ_SIGNAL(toggled(
bool)),m_login,TQ_SLOT(setEnabled(
bool)));
67 connect(btn3,TQ_SIGNAL(toggled(
bool)),m_password,TQ_SLOT(setEnabled(
bool)));
70 TQVBoxLayout *main_ =
new TQVBoxLayout(
this, 0, 0 );
71 main_->addWidget( infotext_ );
72 main_->addSpacing( 10 );
73 main_->addWidget( m_btngroup );
74 TQGridLayout *l1 =
new TQGridLayout( 0, 2, 3 );
75 main_->addLayout( l1 );
76 main_->addStretch( 1 );
77 l1->setColSpacing( 0, 35 );
78 l1->setColStretch( 2, 1 );
79 l1->addWidget( loginlabel_, 0, 1 );
80 l1->addWidget( passwdlabel_, 1, 1 );
81 l1->addWidget( m_login, 0, 2 );
82 l1->addWidget( m_password, 1, 2 );
85 bool KMWPassword::isValid(TQString& msg)
87 if ( !m_btngroup->selected() )
88 msg = i18n(
"Select one option" );
89 else if (m_btngroup->selectedId() == 2 && m_login->text().isEmpty())
90 msg = i18n(
"User name is empty.");
96 void KMWPassword::initPrinter( KMPrinter* p )
99 if ( p->option(
"kde-backend" ).toInt() != KMWizard::SMB )
101 int ID = m_btngroup->selectedId();
102 m_btngroup->find( 1 )->hide();
104 m_btngroup->setButton( 0 );
107 m_btngroup->find( 1 )->show();
110 void KMWPassword::updatePrinter(KMPrinter *p)
112 TQString s = p->option(
"kde-backend");
114 setNextPage(s.toInt());
116 setNextPage(KMWizard::Error);
117 switch ( m_btngroup->selectedId() )
120 p->setOption(
"kde-login", TQString::null );
121 p->setOption(
"kde-password", TQString::null );
124 p->setOption(
"kde-login", TQString::fromLatin1(
"guest" ) );
125 p->setOption(
"kde-password", TQString::null );
128 p->setOption(
"kde-login", m_login->text() );
129 p->setOption(
"kde-password", m_password->text() );