/*
    knetd, KDE Network Daemon

    Copyright (c) 2005 by Engin AYDOGAN		<engin @ bzzzt.biz>

    *************************************************************************
    *                                                                       *
    * 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.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "popup.h"

#include <kdebug.h>

#include <qpainter.h>

#include <qpushbutton.h> 
#include <qlayout.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qlabel.h>
#include <qbitmap.h>

/**
 * TODO: USE SVG KDE BACKGROUNDS FOR TOOLTIPS
 */

static const int POPUP_FLAGS = Qt::WStyle_Customize | Qt::WDestructiveClose | Qt::WX11BypassWM
				| Qt::WStyle_StaysOnTop | Qt::WStyle_Tool | Qt::WStyle_NoBorder;

Popup::Popup( const QString& text, const QString& caption,
		  const QPixmap& icon, const QPixmap& bg,
		  QWidget* p, const char*n )
 : QFrame( p, n, POPUP_FLAGS ), m_text( text ), m_caption( caption ), 
   m_icon( icon ), m_bg( bg )
{
	kdWarning() << k_funcinfo << "I live once more [ " << m_text << " ]" << endl;

	QVBoxLayout *lay = new QVBoxLayout( this );
	QLabel* l = new QLabel( m_text, this );
	l->setFrameStyle( QFrame::Box| QFrame::Plain );
	l->setLineWidth( 2 );
	lay->addWidget( l );
	resize( lay->sizeHint() );
// you can set a pixmap here and see some fancy popup
// this will be -- of course -- configurable
// 	m_bg = QPixmap( "/home/engin/bg.png" );
	if( !m_bg.isNull() )
	{
		kdWarning() << k_funcinfo << "We have bg!" << endl;
		setMask( *m_bg.mask() );
		setPaletteBackgroundPixmap( m_bg );
		lay->setGeometry( m_bg.rect() );
		resize( m_bg.size() );
	}
}

Popup::~Popup()
{
	kdWarning() << k_funcinfo << "I'm dying [ " << m_text << " ]" << endl;
}

