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>
20 #include <QMouseEvent>
21 #include <QPaintEvent>
22 #include <QDesktopWidget>
24 Splash::Splash(const QString
& imagePath
)
25 : QWidget(0, Qt::SplashScreen
| Qt::X11BypassWindowManagerHint
)
27 cachedPixmap
= QPixmap(imagePath
);
28 if (!cachedPixmap
.mask().isNull())
30 QBitmap
mask(cachedPixmap
.size());
31 mask
.fill(Qt::color0
);
32 QBitmap pixMask
= cachedPixmap
.mask();
34 p
.drawPixmap((mask
.width() - pixMask
.width())/2, (mask
.height() - pixMask
.height())/2,
41 QWidget
*d
= QApplication::desktop()->screen();
42 move( (d
->width() - cachedPixmap
.width ()) / 2,
43 (d
->height() - cachedPixmap
.height()) / 2 );
44 resize( cachedPixmap
.size() );
45 setFocusPolicy( Qt::NoFocus
);
50 QTimer::singleShot( SPLASH_DURATION
, this, SLOT(hide()) );
53 void Splash::removeSplash( int timeout
)
55 QTimer::singleShot( timeout
, this, SLOT(hide()) );
58 void Splash::paintEvent( QPaintEvent
* )
61 const QRect r
= rect();
62 p
.drawPixmap(r
.x() + (r
.width() - cachedPixmap
.width())/2,
63 r
.y() + (r
.height() - cachedPixmap
.height())/2,
67 void Splash::mousePressEvent( QMouseEvent
* )