/*
 *  Copyright (C) 2007-2008 CMM Sigma Andrzej Chmielowiec <cmmsigma@cmmsigma.eu>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  This program 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
 *  GNU General Public License for more details.
 */

// AboutBox.cpp: implementation of the AboutBox class.
//
//////////////////////////////////////////////////////////////////////

#include "AboutBox.h"

AboutBox::AboutBox(QWidget *parent): QDialog(parent)
{
	setWindowTitle(tr("About"));
	
	QGridLayout *layout;
	
	mAbout = new QWidget;
	mAboutPixmap = new QLabel;
	mAboutPixmap->setAlignment(Qt::AlignTop);
	mAboutInfo = new QLabel;
	mAboutInfo->setOpenExternalLinks(true);
	mAboutInfo->setWordWrap(true);
	mAboutInfo->setAlignment(Qt::AlignLeft | Qt::AlignTop);
	
	layout = new QGridLayout;
	layout->addWidget(mAboutPixmap, 0, 0);
	layout->addWidget(mAboutInfo, 1, 0);
	mAbout->setLayout(layout);
	
	mHelp = new QWidget;
	mHelpPixmap = new QLabel;
	mHelpPixmap->setAlignment(Qt::AlignTop);
	mHelpInfo = new QLabel;
	mHelpInfo->setOpenExternalLinks(true);
	mHelpInfo->setWordWrap(true);
	mHelpInfo->setAlignment(Qt::AlignLeft | Qt::AlignTop);
	
	layout = new QGridLayout;
	layout->addWidget(mHelpPixmap, 0, 0);
	layout->addWidget(mHelpInfo, 1, 0);
	mHelp->setLayout(layout);
	
	mLicense = new QTextEdit;
	mLicense->setFontFamily(QString("Sans Serif"));
	
	mThanks = new QWidget;
	mThanksPixmap = new QLabel;
	mThanksPixmap->setAlignment(Qt::AlignTop);
	mThanksInfo = new QLabel;
	mThanksInfo->setOpenExternalLinks(true);
	mThanksInfo->setWordWrap(true);
	mThanksInfo->setAlignment(Qt::AlignLeft | Qt::AlignTop);
	
	layout = new QGridLayout;
	layout->addWidget(mThanksPixmap, 0, 0);
	layout->addWidget(mThanksInfo, 1, 0);
	mThanks->setLayout(layout);
	
	mMainTab = new QTabWidget;
	mMainTab->setTabPosition(QTabWidget::East);
	mMainTab->addTab(mAbout, tr("About"));
	mMainTab->addTab(mHelp, tr("Help"));
	mMainTab->addTab(mLicense, tr("License"));
	mMainTab->addTab(mThanks, tr("Thanks"));
	
	QPushButton *btnOK = new QPushButton(tr("OK"));
	connect(btnOK, SIGNAL(clicked()), this, SLOT(accept()));
	
	layout = new QGridLayout;
	layout->addWidget(mMainTab);
	layout->addWidget(btnOK, 1, 0, Qt::AlignRight);
	setLayout(layout);
	
	setMinimumHeight(400);
}

void
AboutBox::setAboutPixmap(const QPixmap &pixmap)
{
	mAboutPixmap->setPixmap(pixmap);
}

void
AboutBox::setAboutInfo(const QString &info)
{
	mAboutInfo->setText(info);
}

void
AboutBox::setHelpPixmap(const QPixmap &pixmap)
{
	mHelpPixmap->setPixmap(pixmap);
}

void
AboutBox::setHelpInfo(const QString &info)
{
	mHelpInfo->setText(info);
}

void
AboutBox::setLicense(const QString &license)
{
	mLicense->setHtml(license);
}

void
AboutBox::setThanksPixmap(const QPixmap &pixmap)
{
	mThanksPixmap->setPixmap(pixmap);
}

void
AboutBox::setThanksInfo(const QString &info)
{
	mThanksInfo->setText(info);
}

void
AboutBox::setActiveAbout()
{
	mMainTab->setCurrentWidget(mAbout);
}

void
AboutBox::setActiveHelp()
{
	mMainTab->setCurrentWidget(mHelp);
}

void
AboutBox::setActiveLicense()
{
	mMainTab->setCurrentWidget(mLicense);
}

void
AboutBox::setActiveThanks()
{
	mMainTab->setCurrentWidget(mThanks);
}
