KDevelop API Documentation

splashscreen.cpp

Go to the documentation of this file.
00001 
00002 #include "splashscreen.h"
00003 #include "splashscreen.moc"
00004 
00005 #include <config.h>
00006 
00007 #include <qtimer.h>
00008 #include <qfont.h>
00009 
00010 SplashScreen::SplashScreen(const QPixmap& pixmap, WFlags f) : QSplashScreen(pixmap, f)
00011 {
00012     QTimer *timer = new QTimer( this );
00013     QObject::connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
00014     timer->start(150);
00015 
00016     state = 0;
00017     progress_bar_size = 3;
00018 }
00019 
00020 
00021 SplashScreen::~SplashScreen()
00022 {
00023 }
00024 
00025 
00026 void SplashScreen::animate()
00027 {
00028     state = ((state + 1) % (2*progress_bar_size-1));
00029     repaint();
00030 }
00031 
00032 
00033 void SplashScreen::message( const QString &str, int flags, const QColor &color)
00034 {
00035     QSplashScreen::message(str,flags,color);
00036     animate();
00037     m_string = str;
00038 }
00039 
00040 
00041 void SplashScreen::drawContents (QPainter* painter)
00042 {
00043     int position;
00044     QColor base_color (201,229,165); // Base green color
00045     
00046     // Draw background circles
00047     painter->setPen(NoPen);
00048     painter->setBrush(QColor(215,234,181)); 
00049     painter->drawEllipse(51,7,9,9);
00050     painter->drawEllipse(62,7,9,9);
00051     painter->drawEllipse(73,7,9,9);
00052 
00053     // Draw animated circles, increments are chosen 
00054     // to get close to background's color 
00055     // (didn't work well with QColor::light function)
00056     for (int i=0; i < progress_bar_size; i++)
00057     {
00058         position = (state+i)%(2*progress_bar_size-1);
00059         painter->setBrush(QColor(base_color.red()-18*i, 
00060                                  base_color.green()-10*i, 
00061                                  base_color.blue()-28*i));
00062 
00063         if (position < 3) painter->drawEllipse(51+position*11,7,9,9);
00064     }
00065 
00066     painter->setPen(QColor(74,112,18));
00067     painter->setFont(QFont("Helvetica", 8));
00068     
00069     // Draw version number
00070     QRect r = rect();
00071     r.setRect(r.x() + 5, r.y() + 5, r.width() - 10, r.height() - 10);
00072     painter->drawText(r, Qt::AlignRight, QString ("Version ") + VERSION);
00073 
00074     // Draw message at given position, limited to 43 chars
00075     // If message is too long, string is truncated
00076     if (m_string.length() > 40) {m_string.truncate(39); m_string += "...";}
00077     painter->drawText (90, 16, m_string, 42);
00078     
00079 }
00080 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:59 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003