/* -*- C++ -*-

Copyright (C) 2002 Francesco Bresciani <fbresciani@users.sourceforge.net>
This file is part of Kemistry

Kemistry is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

Kemistry is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
NU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Kemistry; see the file COPYING.  If not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/


#include <kaboutdata.h>
#include <kaboutdialog.h>
#include <kaboutapplication.h>
#include <kapp.h>
#include <kbugreport.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <khelpmenu.h>
#include <kpopupmenu.h>


#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qradiobutton.h>

#include "kembabel.h"

KemBabelWin::KemBabelWin()
{

    _widget = new KemBabelWidget(this);

        connect(_widget->_btnClose, SIGNAL(clicked()),
            this, SLOT(close()));
    setCentralWidget(_widget);

    adjustSize();
}



KemBabelWin::~KemBabelWin()
{
}

void KemBabelWidget::slotAddHpHChecked(  bool on )
{
	if ( on )
	// check the Add Hydrogens check box and disable it
	{
            _checkAddH->setChecked( true );
            _checkAddH->setEnabled( false );
	}
	else
	// enable the Add Hydrogens check box
            _checkAddH->setEnabled( true );
}

KemBabelWidget::KemBabelWidget( QWidget * parent ) :
KemBabelWidgetBase( parent, "KEMBABELWIDGET" )
{
    _config = kapp->config();
    loadConfig();

    KHelpMenu * helpMenu = new KHelpMenu(this,  KGlobal::instance()->aboutData(),  false);
    _btnHelp->setPopup(helpMenu->menu());

    _KURLReqOutput->setMode( KFile::File );

    fillCombos();
}


void KemBabelWidget::loadConfig()
{
    _config->setGroup( "UI" );
    //first page (Transformations)
    _checkDeleteH->setChecked( _config->readBoolEntry( "DeleteH" ) );
    _checkAddH->setChecked( _config->readBoolEntry( "AddH" ) );
    _checkAddHpH->setChecked( _config->readBoolEntry( "AddHpH" ) );
}

void KemBabelWidget::saveConfig()
{
    _config->setGroup( "UI" );
    _config->writeEntry( "DeleteH", _checkDeleteH->isChecked() );
    _config->writeEntry( "AddH", _checkAddH->isChecked() );
    _config->writeEntry( "AddHpH", _checkAddHpH->isChecked() );
}

KemBabelWidget::~KemBabelWidget()
{
    saveConfig();
}

#include "kembabel.moc"
