/***************************************************************************
                          dcsplash.cpp  -  description
                             -------------------
    begin                : Fre Apr 12 2002
    copyright            : (C) 2002 by Mathias Küster
    email                : mathen@users.berlios.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qtranslator.h>
#include <qlabel.h>
#include <qpixmap.h>
//Added by qt3to4:
#include <QEvent>

#include "dciconloader.h"

#include "dcsplash.h"

#include <dclib/dcos.h>

#if QT_VERSION >= 0x030200
#define WSTYLE_SPLASH	Qt::WStyle_Splash
#else
#define WSTYLE_SPLASH	Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WStyle_Tool | Qt::WWinOwnDC | Qt::WX11BypassWM
#endif

/** */
DCSplash::DCSplash(QWidget *parent, const char *name, int /*wflags*/ ) : QWidget(parent,name,WSTYLE_SPLASH)
{
	setupUi(this);
	
	Frame_PIXMAP->setAutoFillBackground(TRUE);
	
	QPixmap pm(g_pIconLoader->GetPixmap(eiSPLASH));

	QPalette palette = Frame_PIXMAP->palette();
	palette.setBrush( Frame_PIXMAP->backgroundRole(), QBrush(pm) );
	palette.setColor( Frame_PIXMAP->foregroundRole(), QColor(255, 255, 255) );
	
	Frame_PIXMAP->setPalette(palette);
	
	// no tr() since translator hasn't been loaded yet
	// WARNING replace fromLatin1 if sources are converted to UTF-8 encoding
	Frame_PIXMAP->setText(  QString("Valknut ") + QString(VERSION) + QString("\n\n") +
				QString::fromLatin1("Original Author: Mathias Küster\n") +
				QString("Current Maintainer: Edward Sheldrake\n") +
				QString::fromLatin1("Logo: Mathias Küster\n\n") +
				QString("http://wxdcgui.sourceforge.net") );

	Frame_PIXMAP->installEventFilter(this);
}

/** */
DCSplash::~DCSplash()
{
}

/** event filter */
bool DCSplash::eventFilter(QObject* object, QEvent* event)
{
	if ( (event->type() == QEvent::MouseButtonPress) ||
	     (event->type() == QEvent::MouseButtonRelease) ||
	     (event->type() == QEvent::MouseButtonDblClick) )
	{
		hide();
	}

	return QWidget::eventFilter( object, event );    // standard event processing
}
