1 // Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "splash_screen.h"
23 #include <QStyleOptionProgressBarV2>
24 #include <QCoreApplication>
27 SplashScreen::SplashScreen() :
39 SplashScreen::~SplashScreen()
43 void SplashScreen::setPixmap( const QPixmap
&pixmap
)
45 QSplashScreen::setPixmap( pixmap
);
47 if( this->pixmap().width() > 0 )
48 pbWidth
= this->pixmap().width() - 4;
50 if( this->pixmap().height() > 0 )
51 pbTop
= this->pixmap().height() - pbHeight
- 2;
53 textY
= pbTop
- pbHeight
/ 2;
56 void SplashScreen::setText( const QString
&text
)
60 QCoreApplication::instance()->processEvents();
63 void SplashScreen::clearText()
68 void SplashScreen::setProgress( int percent
)
72 QCoreApplication::instance()->processEvents();
75 void SplashScreen::advanceProgress( int percent
)
79 QCoreApplication::instance()->processEvents();
82 void SplashScreen::drawContents( QPainter
*painter
)
84 QSplashScreen::drawContents( painter
);
86 if( progressBarEnabled
)
88 QStyleOptionProgressBarV2 pbStyle
;
89 pbStyle
.initFrom( this );
90 pbStyle
.state
= QStyle::State_Enabled
;
91 pbStyle
.textVisible
= false;
93 pbStyle
.maximum
= 100;
94 pbStyle
.progress
= progress
;
95 pbStyle
.invertedAppearance
= false;
96 pbStyle
.rect
= QRect( pbLeft
, pbTop
, pbWidth
, pbHeight
);
98 style()->drawControl( QStyle::CE_ProgressBar
, &pbStyle
, painter
, this );
101 if( !text
.isEmpty() )
103 QPen oldPen
= painter
->pen();
105 pen
.setColor( Qt::white
);
106 painter
->setPen( pen
);
107 painter
->drawText( textX
, textY
, text
);
108 painter
->setPen( oldPen
);