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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
/*
cwloadingwidget.cpp - Widget to be shown while loading data
copyright : (c) 2001 by Martijn Klingens
email : klingens@kde.org
*************************************************************************
* *
* 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 "cwloadingwidget.h"
#include <tqpainter.h>
#include <tqpixmap.h>
#include <kpixmap.h>
#include <kpixmapeffect.h>
#include <kstandarddirs.h>
#include <klocale.h>
#include <kglobalsettings.h>
using namespace KBugBusterMainWindow;
CWLoadingWidget::CWLoadingWidget( WidgetMode mode, TQWidget *parent,
const char * name )
: TQFrame( parent, name )
{
init( mode );
}
CWLoadingWidget::CWLoadingWidget( const TQString &text, WidgetMode mode,
TQWidget *parent, const char * name )
: TQFrame( parent, name )
{
init( mode );
setText( text );
}
void CWLoadingWidget::init( WidgetMode mode )
{
m_mode = mode;
TQPalette pal = palette();
pal.setColor( TQPalette::Active, TQColorGroup::Background,
TQColor( 49, 121, 173 ) );
pal.setColor( TQPalette::Inactive, TQColorGroup::Background,
TQColor( 49, 121, 173 ) );
pal.setColor( TQPalette::Disabled, TQColorGroup::Background,
TQColor( 49, 121, 173 ) );
setPalette( pal );
setFrameShape( StyledPanel );
setFrameShadow( Sunken );
setLineWidth( 2 );
setBackgroundMode( NoBackground ); // no flicker
// Load images and prepare pixmap effect
if( m_mode == TopFrame )
{
m_logoPixmap =
new TQPixmap( locate( "data", "kbugbuster/pics/logo.png" ) );
m_topRightPixmap =
new TQPixmap( locate( "data", "kbugbuster/pics/top-right.png" ) );
m_barsPixmap =
new TQPixmap( locate( "data", "kbugbuster/pics/bars.png" ) );
m_toolsPixmap = 0L;
m_toolsPixmapEffect = 0L;
}
else
{
m_toolsPixmap =
new TQPixmap( locate( "data", "kbugbuster/pics/tools.png" ) );
m_toolsPixmapEffect = new KPixmap( m_toolsPixmap->size() );
TQPainter pb;
pb.begin( m_toolsPixmapEffect );
pb.fillRect( 0, 0, m_toolsPixmap->width(), m_toolsPixmap->height(),
TQBrush( TQColor( 49, 121, 172 ) ) );
pb.drawPixmap( 0, 0, *m_toolsPixmap );
pb.end();
KPixmapEffect::fade( *m_toolsPixmapEffect, 0.75, white );
m_logoPixmap = 0L;
m_topRightPixmap = 0L;
m_barsPixmap = 0L;
}
// Create and fill the buffer
m_buffer = new TQPixmap;
}
void CWLoadingWidget::resizeEvent( TQResizeEvent * )
{
updatePixmap();
}
void CWLoadingWidget::setText( const TQString &text )
{
m_text = text;
updatePixmap();
tqrepaint();
}
void CWLoadingWidget::updatePixmap()
{
TQRect cr = contentsRect();
cr.setWidth( cr.width() + 2 );
cr.setHeight( cr.height() + 2 );
m_buffer->resize( cr.width(), cr.height() );
TQPainter p( m_buffer );
// fill background
p.fillRect( 0, 0, cr.width(), cr.height(),
TQBrush( TQColor( 49, 121, 173 ) ) );
if( m_mode == TopFrame )
{
TQFont bigFont = TQFont( KGlobalSettings::generalFont().family(),
28, TQFont::Bold, true );
int xoffset = m_logoPixmap->width();
// Draw bars tiled
int xpos = xoffset;
if( width() > xpos )
p.drawTiledPixmap( xpos, 0, cr.width() - xpos,
m_barsPixmap->height(), *m_barsPixmap );
// Draw logo
p.drawPixmap(width() - m_topRightPixmap->width(), 0, *m_topRightPixmap);
p.drawPixmap( 0, 0, *m_logoPixmap );
// Draw title text
p.setPen( black );
p.drawText( 150, 84, cr.width() - 150, 108 - 84,
AlignAuto | AlignVCenter, m_text );
// Draw intro text
TQString desc = i18n( "Welcome to KBugBuster, a tool to manage the "
"KDE Bug Report System. With KBugBuster you can "
"manage outstanding bug reports for KDE from a "
"convenient front end." );
p.setPen( black );
p.drawText( 28, 128, cr.width() - 28, 184 - 128,
AlignAuto | AlignVCenter | WordBreak, desc );
// Draw the caption text
TQString caption = i18n( "KBugBuster" );
p.setFont( bigFont );
p.setPen( TQColor(139, 183, 222) );
p.drawText( 220, 60, caption );
p.setPen( black );
p.drawText( 217, 57, caption );
}
else
{
// draw tools image
if( cr.height() <= 24 )
return;
int toolsEffectY = cr.height() - m_toolsPixmap->height();
int toolsEffectX = cr.width() - m_toolsPixmap->width();
if ( toolsEffectX < 0)
toolsEffectX = 0;
if ( height() < 24 + m_toolsPixmap->height() )
toolsEffectY = 24;
p.drawPixmap( toolsEffectX, toolsEffectY, *m_toolsPixmap );
// draw textbox
if( cr.height() <= 24 + 50 )
return;
int fheight = fontMetrics().height();
int boxX = 25;
int boxY = 24 + 50;
int boxW = cr.width() - 2 * boxX - 2 * 10;
if( boxW > 500 )
boxW = 500;
TQRect br = fontMetrics().boundingRect( boxX, boxY,
boxW, cr.height() - boxY - 10 - 2 * fheight,
AlignAuto | AlignTop | WordBreak, m_text );
TQRect box = br;
box.setHeight( box.height() + 2 * fheight );
box.setWidth( box.width() + 2 * 10 );
if( box.width() < cr.width() - 2 * boxX )
box.setWidth( TQMIN( cr.width() - 2 * boxX, 500 + 2 * 10 ) );
if( box.height() < 100 )
box.setHeight( TQMIN( cr.height() - boxY - 2 * fheight - 10, 100 ) );
p.setClipRect( box );
p.fillRect( box, TQBrush( TQColor( 204, 222, 234 ) ) );
p.drawPixmap( toolsEffectX, toolsEffectY, *m_toolsPixmapEffect );
p.setViewport( box );
p.setWindow( 0, 0, box.width(), box.height() );
p.drawText( 10, fheight, br.width(),
TQMAX( br.height(), box.height() - 2 * fheight ),
AlignAuto | AlignVCenter | WordBreak, m_text );
}
}
CWLoadingWidget::~CWLoadingWidget()
{
if( m_toolsPixmap )
delete m_toolsPixmap;
if( m_logoPixmap )
delete m_logoPixmap;
if( m_topRightPixmap )
delete m_topRightPixmap;
if( m_barsPixmap )
delete m_barsPixmap;
if( m_toolsPixmapEffect )
delete m_toolsPixmapEffect;
delete m_buffer;
m_toolsPixmap = 0L;
m_logoPixmap = 0L;
m_topRightPixmap = 0L;
m_barsPixmap = 0L;
m_toolsPixmapEffect = 0L;
m_buffer = 0L;
}
void CWLoadingWidget::mouseReleaseEvent( TQMouseEvent * )
{
emit clicked();
}
void CWLoadingWidget::drawContents( TQPainter *p )
{
if( !m_buffer || m_buffer->isNull() )
p->fillRect( contentsRect(), TQBrush( TQColor( 255, 121, 172 ) ) );
else
p->drawPixmap( TQPoint( contentsRect().x(), contentsRect().y()),
*m_buffer, contentsRect() );
}
#include "cwloadingwidget.moc"
/* vim: set et ts=4 sw=4 softtabstop=4: */
|