#include "infodialog.h"
#include <QTimer>
#include <qdebug.h>
InfoDialog::InfoDialog( int time ) : DialogBase()
{
    setButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
    hideCancel();

	if (time > 0)
	{
		m_timeout = new QTimer(this);
		m_timeout->setSingleShot(true);
		connect( m_timeout, SIGNAL(timeout()), this, SLOT(close()));
		this->m_timeout->start( time * 1000  );
	}
}

DialogBase *InfoDialog::createWidget( const QString &text, const QString &timeout )
{
    bool isNumber = false;
    int time = timeout.toInt(&isNumber);

    if( isNumber == false )
        return 0;

    InfoDialog *dlg = new InfoDialog( time );
    dlg->setText(text);

    return dlg;
}

