/**********************************************************************

	--- Qt Architect generated file ---

	File: DeviceDlg.cpp
	Last generated: Mon Feb 8 20:10:15 1999

	DO NOT EDIT!!!  This file will be automatically
	regenerated by qtarch.  All changes will be lost.

 *********************************************************************/

#include "DeviceDlg.h"

#define Inherited QDialog

#include <qpushbt.h>
#include <qframe.h>
#include <unistd.h>
#include <kapp.h>

DeviceDlg::DeviceDlg
(
	QWidget* parent,
	const char* name
)
	:
	Inherited( parent, name, TRUE, 0 )
{
	dlgedit_LabelType = new QLabel( this, "LabelType" );
	dlgedit_LabelType->setGeometry( 20, 10, 80, 25 );
	dlgedit_LabelType->setMinimumSize( 10, 10 );
	dlgedit_LabelType->setMaximumSize( 32767, 32767 );
	dlgedit_LabelType->setText( i18n("Type :") );
	dlgedit_LabelType->setAlignment( 289 );
	dlgedit_LabelType->setMargin( -1 );

	dlgedit_DeviceType = new QComboBox( FALSE, this, "DeviceType" );
	dlgedit_DeviceType->setGeometry( 100, 10, 100, 25 );
	dlgedit_DeviceType->setMinimumSize( 10, 10 );
	dlgedit_DeviceType->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceType->setSizeLimit( 10 );
	dlgedit_DeviceType->setAutoResize( FALSE );
	dlgedit_DeviceType->insertItem( i18n("Folder") );
	dlgedit_DeviceType->insertItem( i18n("Mountable") );
	dlgedit_DeviceType->insertItem( i18n("Ftp") );
	dlgedit_DeviceType->insertItem( i18n("Trash") );
	connect(dlgedit_DeviceType,SIGNAL(activated(int)),SLOT(typeChanged(int)));

	dlgedit_LabelName = new QLabel( this, "LabelName" );
	dlgedit_LabelName->setGeometry( 20, 45, 80, 25 );
	dlgedit_LabelName->setMinimumSize( 10, 10 );
	dlgedit_LabelName->setMaximumSize( 32767, 32767 );
	dlgedit_LabelName->setText( i18n("Name :") );
	dlgedit_LabelName->setAlignment( 289 );
	dlgedit_LabelName->setMargin( -1 );

	dlgedit_DeviceName = new QLineEdit( this, "DeviceName" );
	dlgedit_DeviceName->setGeometry( 100, 45, 100, 25 );
	dlgedit_DeviceName->setMinimumSize( 10, 10 );
	dlgedit_DeviceName->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceName->setText( "" );
	dlgedit_DeviceName->setMaxLength( 32767 );
	dlgedit_DeviceName->setEchoMode( QLineEdit::Normal );
	dlgedit_DeviceName->setFrame( TRUE );

	dlgedit_LabelPath = new QLabel( this, "LabelPath" );
	dlgedit_LabelPath->setGeometry( 20, 80, 80, 25 );
	dlgedit_LabelPath->setMinimumSize( 10, 10 );
	dlgedit_LabelPath->setMaximumSize( 32767, 32767 );
	dlgedit_LabelPath->setText( i18n("Path :") );
	dlgedit_LabelPath->setAlignment( 289 );
	dlgedit_LabelPath->setMargin( -1 );

	dlgedit_DevicePath = new QLineEdit( this, "DevicePath" );
	dlgedit_DevicePath->setGeometry( 100, 80, 100, 25 );
	dlgedit_DevicePath->setMinimumSize( 10, 10 );
	dlgedit_DevicePath->setMaximumSize( 32767, 32767 );
	dlgedit_DevicePath->setText( "" );
	dlgedit_DevicePath->setMaxLength( 32767 );
	dlgedit_DevicePath->setEchoMode( QLineEdit::Normal );
	dlgedit_DevicePath->setFrame( TRUE );

	dlgedit_LabelHost = new QLabel( this, "LabelHost" );
	dlgedit_LabelHost->setGeometry( 240, 10, 80, 25 );
	dlgedit_LabelHost->setMinimumSize( 10, 10 );
	dlgedit_LabelHost->setMaximumSize( 32767, 32767 );
	dlgedit_LabelHost->setText( i18n("Host :") );
	dlgedit_LabelHost->setAlignment( 289 );
	dlgedit_LabelHost->setMargin( -1 );

	dlgedit_DeviceHost = new QLineEdit( this, "DeviceHost" );
	dlgedit_DeviceHost->setGeometry( 340, 10, 100, 25 );
	dlgedit_DeviceHost->setMinimumSize( 10, 10 );
	dlgedit_DeviceHost->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceHost->setText( "" );
	dlgedit_DeviceHost->setMaxLength( 32767 );
	dlgedit_DeviceHost->setEchoMode( QLineEdit::Normal );
	dlgedit_DeviceHost->setFrame( TRUE );
	dlgedit_DeviceHost->setEnabled(FALSE);

	dlgedit_LabelLogin = new QLabel( this, "LabelLogin" );
	dlgedit_LabelLogin->setGeometry( 240, 45, 90, 25 );
	dlgedit_LabelLogin->setMinimumSize( 10, 10 );
	dlgedit_LabelLogin->setMaximumSize( 32767, 32767 );
	dlgedit_LabelLogin->setText( i18n("Login :") );
	dlgedit_LabelLogin->setAlignment( 289 );
	dlgedit_LabelLogin->setMargin( -1 );

	dlgedit_DeviceLogin = new QLineEdit( this, "DeviceLogin" );
	dlgedit_DeviceLogin->setGeometry( 340, 45, 100, 25 );
	dlgedit_DeviceLogin->setMinimumSize( 10, 10 );
	dlgedit_DeviceLogin->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceLogin->setText( "" );
	dlgedit_DeviceLogin->setMaxLength( 32767 );
	dlgedit_DeviceLogin->setEchoMode( QLineEdit::Normal );
	dlgedit_DeviceLogin->setFrame( TRUE );
	dlgedit_DeviceLogin->setEnabled(FALSE);

	dlgedit_LabelPasswd = new QLabel( this, "LabelPasswd" );
	dlgedit_LabelPasswd->setGeometry( 240, 80, 90, 25 );
	dlgedit_LabelPasswd->setMinimumSize( 10, 10 );
	dlgedit_LabelPasswd->setMaximumSize( 32767, 32767 );
	dlgedit_LabelPasswd->setText( i18n("Password :") );
	dlgedit_LabelPasswd->setAlignment( 289 );
	dlgedit_LabelPasswd->setMargin( -1 );

	dlgedit_DevicePasswd = new QLineEdit( this, "DevicePasswd" );
	dlgedit_DevicePasswd->setGeometry( 340, 80, 100, 25 );
	dlgedit_DevicePasswd->setMinimumSize( 10, 10 );
	dlgedit_DevicePasswd->setMaximumSize( 32767, 32767 );
	dlgedit_DevicePasswd->setText( "" );
	dlgedit_DevicePasswd->setMaxLength( 32767 );
	dlgedit_DevicePasswd->setEchoMode( QLineEdit::Password );
	dlgedit_DevicePasswd->setFrame( TRUE );
	dlgedit_DevicePasswd->setEnabled(FALSE);

	dlgedit_LabelPort = new QLabel( this, "LabelPort" );
	dlgedit_LabelPort->setGeometry( 240, 115, 80, 25 );
	dlgedit_LabelPort->setMinimumSize( 10, 10 );
	dlgedit_LabelPort->setMaximumSize( 32767, 32767 );
	dlgedit_LabelPort->setText( i18n("Port :") );
	dlgedit_LabelPort->setAlignment( 289 );
	dlgedit_LabelPort->setMargin( -1 );

	dlgedit_DevicePort = new QLineEdit( this, "DevicePort" );
	dlgedit_DevicePort->setGeometry( 340, 115, 100, 25 );
	dlgedit_DevicePort->setMinimumSize( 10, 10 );
	dlgedit_DevicePort->setMaximumSize( 32767, 32767 );
	dlgedit_DevicePort->setText( "21" );
	dlgedit_DevicePort->setMaxLength( 32767 );
	dlgedit_DevicePort->setEchoMode( QLineEdit::Normal );
	dlgedit_DevicePort->setFrame( TRUE );
	dlgedit_DevicePort->setEnabled(FALSE);

	QFrame* dlgedit_Frame_1;
	dlgedit_Frame_1 = new QFrame( this, "Frame_1" );
	dlgedit_Frame_1->setGeometry( 220, 10, 10, 170 );
	dlgedit_Frame_1->setMinimumSize( 10, 10 );
	dlgedit_Frame_1->setMaximumSize( 32767, 32767 );
	dlgedit_Frame_1->setFrameStyle( 53 );

	dlgedit_DeviceKeep = new QCheckBox( this, "DeviceKeep" );
	dlgedit_DeviceKeep->setGeometry( 20, 150, 160, 30 );
	dlgedit_DeviceKeep->setMinimumSize( 10, 10 );
	dlgedit_DeviceKeep->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceKeep->setText( i18n("Restore on opening") );
	dlgedit_DeviceKeep->setAutoRepeat( FALSE );
	dlgedit_DeviceKeep->setAutoResize( FALSE );

	dlgedit_CheckAnonymous = new QCheckBox( this, "CheckAnonymous" );
	dlgedit_CheckAnonymous->setGeometry( 240, 150, 160, 30 );
	dlgedit_CheckAnonymous->setMinimumSize( 10, 10 );
	dlgedit_CheckAnonymous->setMaximumSize( 32767, 32767 );
	dlgedit_CheckAnonymous->setText( i18n("Anonymous login") );
	dlgedit_CheckAnonymous->setAutoRepeat( FALSE );
	dlgedit_CheckAnonymous->setAutoResize( FALSE );
	dlgedit_CheckAnonymous->setEnabled(FALSE);
	connect(dlgedit_CheckAnonymous,SIGNAL(clicked()),SLOT(anonymousClicked()));

	QPushButton* dlgedit_ButtonOk;
	dlgedit_ButtonOk = new QPushButton( this, "ButtonOk" );
	dlgedit_ButtonOk->setGeometry( 60, 190, 90, 30 );
	dlgedit_ButtonOk->setMinimumSize( 10, 10 );
	dlgedit_ButtonOk->setMaximumSize( 32767, 32767 );
	connect( dlgedit_ButtonOk, SIGNAL(clicked()), SLOT(accept()) );
	dlgedit_ButtonOk->setText( i18n("OK") );
	dlgedit_ButtonOk->setAutoRepeat( FALSE );
	dlgedit_ButtonOk->setAutoResize( FALSE );

	QPushButton* dlgedit_ButtonCancel;
	dlgedit_ButtonCancel = new QPushButton( this, "ButtonCancel" );
	dlgedit_ButtonCancel->setGeometry( 280, 190, 90, 30 );
	dlgedit_ButtonCancel->setMinimumSize( 10, 10 );
	dlgedit_ButtonCancel->setMaximumSize( 32767, 32767 );
	connect( dlgedit_ButtonCancel, SIGNAL(clicked()), SLOT(reject()) );
	dlgedit_ButtonCancel->setText( i18n("Cancel") );
	dlgedit_ButtonCancel->setAutoRepeat( FALSE );
	dlgedit_ButtonCancel->setAutoResize( FALSE );

	dlgedit_LabelIcon = new QLabel( this, "LabelIcon" );
	dlgedit_LabelIcon->setGeometry( 20, 115, 80, 25 );
	dlgedit_LabelIcon->setMinimumSize( 10, 10 );
	dlgedit_LabelIcon->setMaximumSize( 32767, 32767 );
	dlgedit_LabelIcon->setText( i18n("Icon :") );
	dlgedit_LabelIcon->setAlignment( 289 );
	dlgedit_LabelIcon->setMargin( -1 );

	dlgedit_DeviceIcon = new QComboBox( FALSE, this, "DeviceIcon" );
	dlgedit_DeviceIcon->setGeometry( 100, 115, 50, 25 );
	dlgedit_DeviceIcon->setMinimumSize( 10, 10 );
	dlgedit_DeviceIcon->setMaximumSize( 32767, 32767 );
	dlgedit_DeviceIcon->setSizeLimit( 10 );
	dlgedit_DeviceIcon->setAutoResize( FALSE );

	resize( 460,230 );
	setMinimumSize( 0, 0 );
	setMaximumSize( 32767, 32767 );
	setCaption(i18n("Device properties"));
}


DeviceDlg::~DeviceDlg()
{
}

void DeviceDlg::typeChanged(int index)
{
	switch (index) {
	   case 0:	// Folder device
		dlgedit_DeviceHost->setEnabled(FALSE);
		dlgedit_DeviceLogin->setEnabled(FALSE);
		dlgedit_DevicePasswd->setEnabled(FALSE);
		dlgedit_DevicePort->setEnabled(FALSE);
		dlgedit_CheckAnonymous->setEnabled(FALSE);
		dlgedit_LabelPath->setText(i18n("Path :"));
		dlgedit_DeviceIcon->setEnabled(TRUE);
		dlgedit_DeviceName->setEnabled(TRUE);
		break;
	   case 1:	// Mount device
		dlgedit_LabelPath->setText(i18n("Device :"));
		dlgedit_LabelHost->setText(i18n("Mount :"));
		dlgedit_LabelLogin->setText(i18n("FS Type :"));
		if (getuid() == 0) {
			dlgedit_DeviceHost->setEnabled(TRUE);
			dlgedit_DeviceLogin->setEnabled(TRUE);
		}
		else {
			dlgedit_DeviceHost->setEnabled(FALSE);
			dlgedit_DeviceLogin->setEnabled(FALSE);
		}
		dlgedit_DevicePasswd->setEnabled(FALSE);
		dlgedit_DevicePort->setEnabled(FALSE);
		dlgedit_CheckAnonymous->setEnabled(FALSE);
		dlgedit_DeviceIcon->setEnabled(TRUE);
		dlgedit_DeviceName->setEnabled(TRUE);
		break;
	   case 2:	// Ftp device
		dlgedit_LabelPath->setText(i18n("Path :"));
		dlgedit_LabelHost->setText(i18n("Host :"));
		dlgedit_LabelLogin->setText(i18n("Login :"));
		dlgedit_DeviceHost->setEnabled(TRUE);
		dlgedit_DeviceLogin->setEnabled(FALSE);
		dlgedit_DevicePasswd->setEnabled(FALSE);
		dlgedit_DevicePort->setEnabled(TRUE);
		dlgedit_CheckAnonymous->setChecked(TRUE);
		dlgedit_CheckAnonymous->setEnabled(TRUE);
		dlgedit_DeviceIcon->setEnabled(TRUE);
		dlgedit_DeviceName->setEnabled(TRUE);
		break;
	   case 3:	// Trash device
		dlgedit_DeviceHost->setEnabled(FALSE);
		dlgedit_DeviceLogin->setEnabled(FALSE);
		dlgedit_DevicePasswd->setEnabled(FALSE);
		dlgedit_DevicePort->setEnabled(FALSE);
		dlgedit_CheckAnonymous->setEnabled(FALSE);
		dlgedit_LabelPath->setText(i18n("Path :"));
		dlgedit_DeviceIcon->setEnabled(FALSE);
		dlgedit_DeviceName->setEnabled(FALSE);
		break;
	}
}

void DeviceDlg::anonymousClicked()
{
	if (dlgedit_CheckAnonymous->isChecked()) {
		dlgedit_DeviceLogin->setEnabled(FALSE);
		dlgedit_DevicePasswd->setEnabled(FALSE);
	}
	else {
		dlgedit_DeviceLogin->setEnabled(TRUE);
		dlgedit_DevicePasswd->setEnabled(TRUE);
	}
}
