mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-24 07:46:20 +00:00
First iteration of the new splash screen.
This commit is contained in:
parent
30069bcf0e
commit
62246d284c
4 changed files with 137 additions and 3 deletions
|
@ -11,7 +11,8 @@ FILE(GLOB STUDIO_SRC extension_system/*.h
|
|||
|
||||
SET(STUDIO_HDR extension_system/iplugin_manager.h
|
||||
extension_system/plugin_manager.h
|
||||
settings_dialog.h )
|
||||
settings_dialog.h
|
||||
splash_screen.h )
|
||||
|
||||
SET(STUDIO_RCS studio.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
|
||||
|
|
|
@ -37,11 +37,12 @@
|
|||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QSplashScreen>
|
||||
//#include <QtGui/QSplashScreen>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QInputDialog>
|
||||
|
||||
#include "settings_dialog.h"
|
||||
#include "splash_screen.h"
|
||||
|
||||
#ifdef HAVE_OVQT_CONFIG_H
|
||||
#include "ovqt_config.h"
|
||||
|
@ -141,8 +142,11 @@ int main(int argc, char **argv)
|
|||
QApplication app(argc, argv);
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
||||
QSplashScreen *splash = new QSplashScreen();
|
||||
SplashScreen *splash = new SplashScreen();
|
||||
splash->setPixmap(QPixmap(":/images/studio_splash.png"));
|
||||
splash->setProgressBarEnabled( true );
|
||||
splash->setText( "Starting up..." );
|
||||
splash->setProgress( 0 );
|
||||
splash->show();
|
||||
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
|
@ -184,6 +188,8 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
pluginManager.setPluginPaths(pluginPaths);
|
||||
splash->setText( "Loading plugins..." );
|
||||
splash->setProgress( 20 );
|
||||
pluginManager.loadPlugins();
|
||||
|
||||
splash->hide();
|
||||
|
|
85
code/studio/src/splash_screen.cpp
Normal file
85
code/studio/src/splash_screen.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
#include "splash_screen.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionProgressBarV2>
|
||||
#include <QCoreApplication>
|
||||
#include <QPixmap>
|
||||
|
||||
SplashScreen::SplashScreen() :
|
||||
QSplashScreen()
|
||||
{
|
||||
progress = 0;
|
||||
textX = 5;
|
||||
textY = 20;
|
||||
pbLeft = 0;
|
||||
pbTop = 0;
|
||||
pbWidth = 100;
|
||||
pbHeight = 20;
|
||||
}
|
||||
|
||||
SplashScreen::~SplashScreen()
|
||||
{
|
||||
}
|
||||
|
||||
void SplashScreen::setPixmap( const QPixmap &pixmap )
|
||||
{
|
||||
QSplashScreen::setPixmap( pixmap );
|
||||
|
||||
if( this->pixmap().width() > 0 )
|
||||
pbWidth = this->pixmap().width();
|
||||
|
||||
if( this->pixmap().height() > 0 )
|
||||
pbTop = this->pixmap().height() - pbHeight;
|
||||
|
||||
textY = pbTop - pbHeight;
|
||||
}
|
||||
|
||||
void SplashScreen::setText( const QString &text )
|
||||
{
|
||||
this->text = text;
|
||||
repaint();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
|
||||
void SplashScreen::clearText()
|
||||
{
|
||||
setText( "" );
|
||||
}
|
||||
|
||||
void SplashScreen::setProgress( int percent )
|
||||
{
|
||||
progress = percent;
|
||||
repaint();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
|
||||
void SplashScreen::drawContents( QPainter *painter )
|
||||
{
|
||||
QSplashScreen::drawContents( painter );
|
||||
|
||||
if( progressBarEnabled )
|
||||
{
|
||||
QStyleOptionProgressBarV2 pbStyle;
|
||||
pbStyle.initFrom( this );
|
||||
pbStyle.state = QStyle::State_Enabled;
|
||||
pbStyle.textVisible = false;
|
||||
pbStyle.minimum = 0;
|
||||
pbStyle.maximum = 100;
|
||||
pbStyle.progress = progress;
|
||||
pbStyle.invertedAppearance = false;
|
||||
pbStyle.rect = QRect( 0, pbTop, pbWidth, pbHeight );
|
||||
|
||||
style()->drawControl( QStyle::CE_ProgressBar, &pbStyle, painter, this );
|
||||
}
|
||||
|
||||
if( !text.isEmpty() )
|
||||
{
|
||||
QPen oldPen = painter->pen();
|
||||
QPen pen;
|
||||
pen.setColor( Qt::white );
|
||||
painter->setPen( pen );
|
||||
painter->drawText( textX, textY, text );
|
||||
painter->setPen( oldPen );
|
||||
}
|
||||
}
|
||||
|
||||
|
42
code/studio/src/splash_screen.h
Normal file
42
code/studio/src/splash_screen.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef SPLASH_SCREEN_H
|
||||
#define SPLASH_SCREEN_H
|
||||
|
||||
|
||||
#include <QSplashScreen>
|
||||
|
||||
class SplashScreen : public QSplashScreen
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SplashScreen();
|
||||
~SplashScreen();
|
||||
|
||||
void setPixmap( const QPixmap &pixmap );
|
||||
|
||||
void setText( const QString &text );
|
||||
void clearText();
|
||||
void setTextXY( int x, int y ){ textX = x; textY = y; }
|
||||
void setProgress( int percent );
|
||||
|
||||
void setProgressBarEnabled( bool b ){ progressBarEnabled = b; }
|
||||
void setProgressBarRect( int left, int top, int width, int height ){}
|
||||
|
||||
protected:
|
||||
void drawContents( QPainter *painter );
|
||||
|
||||
private:
|
||||
int progress;
|
||||
int pbLeft;
|
||||
int pbTop;
|
||||
int pbWidth;
|
||||
int pbHeight;
|
||||
|
||||
QString text;
|
||||
int textX;
|
||||
int textY;
|
||||
|
||||
bool progressBarEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in a new issue