~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to DataManagerII/classLogin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************
 
2
 *
 
3
 *
 
4
 **************************************************
 
5
 * This code was created by Peter Harvey @ CodeByDesign.
 
6
 * Released under GPL 18.FEB.99
 
7
 *
 
8
 * Contributions from...
 
9
 * -----------------------------------------------
 
10
 * Peter Harvey         - pharvey@codebydesign.com
 
11
 **************************************************/
 
12
 
 
13
#include "classLogin.h"
 
14
#include <qpushbutton.h>
 
15
#include <qpixmap.h>
 
16
#include <unistd.h>
 
17
#include <pwd.h>
 
18
#include <sys/types.h>
 
19
#include "LinuxODBC.xpm"
 
20
 
 
21
#include <classODBC.h>
 
22
 
 
23
classLogin::classLogin( QWidget *pParent, ConnectionScoper &dbc, const QString &dataSource )
 
24
    : QDialog( pParent, "classLogin", TRUE ) , dbc( dbc ) , qsDataSourceName( dataSource )
 
25
{
 
26
    QLabel      *lblUID;
 
27
    QLabel      *lblPWD;
 
28
    QPushButton *pbOk;
 
29
    QPushButton *pbCancel;
 
30
 
 
31
    setCaption( "Login - " + qsDataSourceName );
 
32
    setIcon( QPixmap( LinuxODBC_xpm ) );
 
33
 
 
34
    lblUID      = new QLabel( "ID:", this  );
 
35
    lblPWD      = new QLabel( "PWD:", this  );
 
36
    txtUID      = new QLineEdit( "", this );
 
37
    txtPWD      = new QLineEdit( "", this );
 
38
    pbOk        = new QPushButton( "&Ok", this  );
 
39
    pbCancel    = new QPushButton( "&Cancel", this  );
 
40
 
 
41
    lblUID->setGeometry( 5, 10, 30, 25 );
 
42
    lblPWD->setGeometry( 5, 40, 30, 25 );
 
43
    txtUID->setGeometry( 35, 10, 200, 25 );
 
44
    txtPWD->setGeometry( 35, 40, 200, 25 );
 
45
    pbOk->setGeometry( 35, 70, 100, 25 );
 
46
    pbCancel->setGeometry( 135, 70, 100, 25 );
 
47
 
 
48
    txtUID->setText( ((struct passwd *)getpwuid(getuid()))->pw_name );
 
49
    txtPWD->setEchoMode( QLineEdit::Password );
 
50
 
 
51
    connect( pbOk, SIGNAL(clicked()), this, SLOT(pbOk_Clicked()) );
 
52
    connect( pbCancel, SIGNAL(clicked()), this, SLOT(pbCancel_Clicked()) );
 
53
 
 
54
    pbOk->setDefault( TRUE );
 
55
    txtPWD->setFocus();
 
56
}
 
57
 
 
58
void classLogin::pbOk_Clicked()
 
59
{
 
60
  if ( dbc.connect( qsDataSourceName, txtUID->text(), txtPWD->text() ) )
 
61
  {
 
62
    // Clear security values
 
63
    txtUID->setText( "") ;
 
64
    txtPWD->setText( "") ;
 
65
    accept();
 
66
  }
 
67
}
 
68
 
 
69
void classLogin::pbCancel_Clicked()
 
70
{
 
71
  reject();
 
72
}