1 /* This file is part of the KDE project
3 Copyright (C) 2004 - 2005 KGet Developers <kget@kde.org>
4 Splash.cpp/.h taken from Amarok. Thanks to Amarok's authors, cool piece
5 of code.. and our favourite player!
6 Copyright (C) 2003 by Christian Muehlhaeuser <muesli@chareit.net>
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
16 #include <QApplication>
21 #include <QMouseEvent>
22 #include <QPaintEvent>
23 #include <QDesktopWidget>
25 Splash::Splash(const QString
& imagePath
)
26 : QWidget(0, Qt::SplashScreen
| Qt::X11BypassWindowManagerHint
)
28 cachedPixmap
= QPixmap(imagePath
);
29 if (!cachedPixmap
.mask().isNull())
31 QBitmap
mask(cachedPixmap
.size());
32 mask
.fill(Qt::color0
);
33 QBitmap pixMask
= cachedPixmap
.mask();
35 p
.drawPixmap((mask
.width() - pixMask
.width())/2, (mask
.height() - pixMask
.height())/2,
42 QWidget
*d
= QApplication::desktop()->screen();
43 move( (d
->width() - cachedPixmap
.width ()) / 2,
44 (d
->height() - cachedPixmap
.height()) / 2 );
45 resize( cachedPixmap
.size() );
46 setFocusPolicy( Qt::NoFocus
);
51 QTimer::singleShot( SPLASH_DURATION
, this, SLOT(hide()) );
54 void Splash::removeSplash( int timeout
)
56 QTimer::singleShot( timeout
, this, SLOT(hide()) );
59 void Splash::paintEvent( QPaintEvent
* )
62 const QRect r
= rect();
63 p
.drawPixmap(r
.x() + (r
.width() - cachedPixmap
.width())/2,
64 r
.y() + (r
.height() - cachedPixmap
.height())/2,
68 void Splash::mousePressEvent( QMouseEvent
* )