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

tdeprint

  • tdeprint
  • management
kmwpassword.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kmwpassword.h"
21 #include "kmwizard.h"
22 #include "kmprinter.h"
23 
24 #include <tqlabel.h>
25 #include <tqlineedit.h>
26 #include <tqvbuttongroup.h>
27 #include <tqradiobutton.h>
28 #include <tqlayout.h>
29 #include <tdelocale.h>
30 #include <kcursor.h>
31 
32 #include <stdlib.h>
33 
34 KMWPassword::KMWPassword(TQWidget *parent, const char *name)
35 : KMWizardPage(parent,name)
36 {
37  m_title = i18n("User Identification");
38  m_ID = KMWizard::Password;
39  m_nextpage = KMWizard::SMB;
40 
41  // create widgets
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 );
60 
61  loginlabel_->setBuddy(m_login);
62  passwdlabel_->setBuddy(m_password);
63 
64  m_login->setEnabled(false);
65  m_password->setEnabled(false);
66  connect(btn3,TQT_SIGNAL(toggled(bool)),m_login,TQT_SLOT(setEnabled(bool)));
67  connect(btn3,TQT_SIGNAL(toggled(bool)),m_password,TQT_SLOT(setEnabled(bool)));
68 
69  // layout
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( TQT_TQLAYOUT(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 );
83 }
84 
85 bool KMWPassword::isValid(TQString& msg)
86 {
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.");
91  else
92  return true;
93  return false;
94 }
95 
96 void KMWPassword::initPrinter( KMPrinter* p )
97 {
98  /* guest account only for SMB backend */
99  if ( p->option( "kde-backend" ).toInt() != KMWizard::SMB )
100  {
101  int ID = m_btngroup->selectedId();
102  m_btngroup->find( 1 )->hide();
103  if ( ID == 1 )
104  m_btngroup->setButton( 0 );
105  }
106  else
107  m_btngroup->find( 1 )->show();
108 }
109 
110 void KMWPassword::updatePrinter(KMPrinter *p)
111 {
112  TQString s = p->option("kde-backend");
113  if (!s.isEmpty())
114  setNextPage(s.toInt());
115  else
116  setNextPage(KMWizard::Error);
117  switch ( m_btngroup->selectedId() )
118  {
119  case 0:
120  p->setOption( "kde-login", TQString::null );
121  p->setOption( "kde-password", TQString::null );
122  break;
123  case 1:
124  p->setOption( "kde-login", TQString::fromLatin1( "guest" ) );
125  p->setOption( "kde-password", TQString::null );
126  break;
127  case 2:
128  p->setOption( "kde-login", m_login->text() );
129  p->setOption( "kde-password", m_password->text() );
130  break;
131  }
132 }
133 

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.