summaryrefslogtreecommitdiffstats
path: root/src/kbfxspinxtop.cpp
blob: d2a651a3922ebec24e9e7842f1039846eba6da7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 *   Copyright (C) 2006
 *   Siraj Razick <siraj@kdemail.net>
 *   PhobosK <phobosk@mail.kbfx.org>
 *   see Also AUTHORS
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License version 2 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
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "kbfxspinxtop.h"

KbfxSpinxTop::KbfxSpinxTop ( TQWidget * parent,const char * name ) :TQWidget ( parent,name,TQt::WNoAutoErase | WStaticContents | TQt::WPaintClever | TQt::WNoAutoErase )
{

	m_background = ( *KbfxPlasmaPixmapProvider::pixmap ( "topbg" ) );
	m_currentTextBuffer = "";

	this->resize ( ConfigInit().m_topBar_w,ConfigInit().m_topBar_h );
//	this->resize(m_background.size());
	loadFaceIcon();
	createDudeBox();
	m_userName=getUserName();

}

KbfxSpinxTop::~KbfxSpinxTop()
{}

void
KbfxSpinxTop::mousePressEvent ( TQMouseEvent * e )
{
	e = e;
	emit sizeChange ( 10 );
}

void
KbfxSpinxTop::createDudeBox()
{
	m_dudeBox = ( *KbfxPlasmaPixmapProvider::pixmap ( "dudebox" ) );
//  int padding = ((m_dudeBox.height()-m_faceIcon.height()))/2;

	TQPainter p;
	p.begin ( &m_dudeBox );
//  p.drawPixmap(TQRect(padding,padding,m_faceIcon.width(),m_faceIcon.height()),m_faceIcon);
	p.drawPixmap ( TQRect ( ConfigInit().m_faceIconX,ConfigInit().m_faceIconY,ConfigInit().m_faceIconW,ConfigInit().m_faceIconH ),m_faceIcon );
	p.end();

}


TQString
KbfxSpinxTop::getUserName ()
{
	KUser *user = new KUser ();
	TQString logInName ( user->fullName () );
// Nookie says some might find it discriminating... We don't want that.
	if ( logInName == "root" )
		logInName = TQString ( "Administrator" );
	delete user;
	return logInName.upper ();
}



void
KbfxSpinxTop::loadFaceIcon()
{
	TQImage UserImage ( ConfigInit().m_SpinxDudeImage );
	UserImage = UserImage.smoothScale ( 48, 48 );
	m_faceIcon = TQPixmap ( UserImage );
}


void
KbfxSpinxTop::paintEvent ( TQPaintEvent * pe )
{
	pe = pe;
	TQRect * r = new TQRect ( 0,0,ConfigInit().m_topBar_w,ConfigInit().m_topBar_h );

	m_pixmapbuff = new TQPixmap();
	m_pixmapbuff->resize ( r->size() );
	m_pixmapbuff->fill ( this, r->topLeft() );

	TQPainter p;
	p.tqbegin ( m_pixmapbuff,this );
// Draw commands are here
	p.drawPixmap ( *r,m_background );
	p.setPen ( TQColor ( ConfigInit().m_userNameColor ) );

	p.drawPixmap ( TQRect ( ConfigInit().m_facePos_x,ConfigInit().m_facePos_y,m_dudeBox.width(),m_dudeBox.height() ),m_dudeBox );
	if ( !ConfigInit().m_faceBoxHideText )
	{
		TQFont * _font = new TQFont(ConfigInit().m_userNameFont);
		p.setFont ( *_font );
//	      p.setPen(TQColor(199,187,206));
//	      p.drawText(ConfigInit().m_userNamePos_x+1,ConfigInit().m_userNamePos_y+2,m_userName);
		p.setPen ( TQColor ( ConfigInit().m_userNameColor ) );
		p.drawText ( ConfigInit().m_userNamePos_x,ConfigInit().m_userNamePos_y,m_userName );
		delete _font;
	}
	p.end();

	bitBlt ( this, r->x(), r->y(),m_pixmapbuff, 0, 0,
	         r->width(), r->height() );

//	delete [] pe;
	delete m_pixmapbuff;
	delete r;
}

#include "kbfxspinxtop.moc"