/****************************************************************************
** Form implementation generated from reading ui file 'playername.ui'
**
** Created: Sat Sep 15 20:04:50 2001
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include <kiconloader.h>
#include <kconfig.h>
#include <kapp.h>

#include <unistd.h>

#include "playername.h"

/*
 *  Constructs a CPlayerName which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
CPlayerName::CPlayerName( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
	KIconLoader icone;
	QString playername;
	
  if ( !name )
		setName( "Form1" );
  setFixedSize( 220, 75 );
  setCaption( tr( "KSlide... Who's playing ?" ) );
	setIcon(icone.loadIcon("kslide",KIcon::Small));

  TextLabel1 = new QLabel( this, "TextLabel1" );
  TextLabel1->setGeometry( QRect( 10, 10, 130, 20 ) );
  TextLabel1->setText( tr( "Enter your name" ) );

  KConfig *config = kapp->config();
  config->setGroup("Player");
  playername=config->readEntry("playername",QString(getlogin()) );

  LineEdit1 = new QLineEdit( this, "LineEdit1" );
  LineEdit1->setGeometry( QRect( 10, 30, 131, 22 ) );
  LineEdit1->setFocus();
  LineEdit1->setText(playername);
  connect(LineEdit1, SIGNAL(returnPressed()), this, SLOT(slotEnteredPlayerName()));

  PushButton1 = new QPushButton( this, "PushButton1" );
  PushButton1->setGeometry( QRect( 160, 20, 41, 30 ) );
  PushButton1->setText( tr( "OK" ) );
  connect(PushButton1, SIGNAL(clicked()), this, SLOT(accept()));
}

/*  
 *  Destroys the object and frees any allocated resources
 */
CPlayerName::~CPlayerName()
{
    // no need to delete child widgets, Qt does it all for us
}

/** return the player's name */
QString CPlayerName::getPlayerName(){
	return LineEdit1->text();
}

/** Write the player name and close the dialog box */
void CPlayerName::slotEnteredPlayerName(){
  KConfig *config = kapp->config();
  config->setGroup("Player");
  config->writeEntry("playername",LineEdit1->text() );
  config->sync();
	accept();
}

//#include "playername.moc.cpp"
