• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

kmwpassword.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kmwpassword.h"
00021 #include "kmwizard.h"
00022 #include "kmprinter.h"
00023 
00024 #include <tqlabel.h>
00025 #include <tqlineedit.h>
00026 #include <tqvbuttongroup.h>
00027 #include <tqradiobutton.h>
00028 #include <tqlayout.h>
00029 #include <tdelocale.h>
00030 #include <kcursor.h>
00031 
00032 #include <stdlib.h>
00033 
00034 KMWPassword::KMWPassword(TQWidget *parent, const char *name)
00035 : KMWizardPage(parent,name)
00036 {
00037     m_title = i18n("User Identification");
00038     m_ID = KMWizard::Password;
00039     m_nextpage = KMWizard::SMB;
00040 
00041     // create widgets
00042     TQLabel *infotext_ = new TQLabel(this);
00043     infotext_->setText(i18n("<p>This backend may require a login/password to work properly. "
00044                 "Select the type of access to use and fill in the login and password entries if needed.</p>"));
00045     m_login = new TQLineEdit(this);
00046     m_login->setText(TQString::fromLocal8Bit(getenv("USER")));
00047     m_password = new TQLineEdit(this);
00048     m_password->setEchoMode(TQLineEdit::Password);
00049     TQLabel *loginlabel_ = new TQLabel(i18n("&Login:"),this);
00050     TQLabel *passwdlabel_ = new TQLabel(i18n("&Password:"),this);
00051     m_btngroup = new TQVButtonGroup( this );
00052     m_btngroup->setFrameStyle( TQFrame::NoFrame );
00053     TQRadioButton *btn1 = new TQRadioButton( i18n( "&Anonymous (no login/password)" ), m_btngroup );
00054     TQRadioButton *btn2 = new TQRadioButton( i18n( "&Guest account (login=\"guest\")" ), m_btngroup );
00055     TQRadioButton *btn3 = new TQRadioButton( i18n( "Nor&mal account" ), m_btngroup );
00056     btn1->setCursor( KCursor::handCursor() );
00057     btn2->setCursor( KCursor::handCursor() );
00058     btn3->setCursor( KCursor::handCursor() );
00059     m_btngroup->setButton( 0 );
00060 
00061     loginlabel_->setBuddy(m_login);
00062     passwdlabel_->setBuddy(m_password);
00063 
00064     m_login->setEnabled(false);
00065     m_password->setEnabled(false);
00066     connect(btn3,TQT_SIGNAL(toggled(bool)),m_login,TQT_SLOT(setEnabled(bool)));
00067     connect(btn3,TQT_SIGNAL(toggled(bool)),m_password,TQT_SLOT(setEnabled(bool)));
00068 
00069     // layout
00070     TQVBoxLayout *main_ = new TQVBoxLayout( this, 0, 0 );
00071     main_->addWidget( infotext_ );
00072     main_->addSpacing( 10 );
00073     main_->addWidget( m_btngroup );
00074     TQGridLayout *l1 = new TQGridLayout( 0, 2, 3 );
00075     main_->addLayout( TQT_TQLAYOUT(l1) );
00076     main_->addStretch( 1 );
00077     l1->setColSpacing( 0, 35 );
00078     l1->setColStretch( 2, 1 );
00079     l1->addWidget( loginlabel_, 0, 1 );
00080     l1->addWidget( passwdlabel_, 1, 1 );
00081     l1->addWidget( m_login, 0, 2 );
00082     l1->addWidget( m_password, 1, 2 );
00083 }
00084 
00085 bool KMWPassword::isValid(TQString& msg)
00086 {
00087     if ( !m_btngroup->selected() )
00088         msg = i18n( "Select one option" );
00089     else if (m_btngroup->selectedId() == 2 && m_login->text().isEmpty())
00090         msg = i18n("User name is empty.");
00091     else
00092         return true;
00093     return false;
00094 }
00095 
00096 void KMWPassword::initPrinter( KMPrinter* p )
00097 {
00098     /* guest account only for SMB backend */
00099     if ( p->option( "kde-backend" ).toInt() != KMWizard::SMB )
00100     {
00101         int ID = m_btngroup->selectedId();
00102         m_btngroup->find( 1 )->hide();
00103         if ( ID == 1 )
00104             m_btngroup->setButton( 0 );
00105     }
00106     else
00107         m_btngroup->find( 1 )->show();
00108 }
00109 
00110 void KMWPassword::updatePrinter(KMPrinter *p)
00111 {
00112     TQString    s = p->option("kde-backend");
00113     if (!s.isEmpty())
00114         setNextPage(s.toInt());
00115     else
00116         setNextPage(KMWizard::Error);
00117     switch ( m_btngroup->selectedId() )
00118     {
00119         case 0:
00120             p->setOption( "kde-login", TQString::null );
00121             p->setOption( "kde-password", TQString::null );
00122             break;
00123         case 1:
00124             p->setOption( "kde-login", TQString::fromLatin1( "guest" ) );
00125             p->setOption( "kde-password", TQString::null );
00126             break;
00127         case 2:
00128             p->setOption( "kde-login", m_login->text() );
00129             p->setOption( "kde-password", m_password->text() );
00130             break;
00131     }
00132 }
00133 

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.