Code_TYMPAN  4.2.0
Industrial site acoustic simulation
OSplashScreen.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14 */
15 
23 //Added by qt3to4:
24 #include <qapplication.h>
25 #include <qpainter.h>
26 #include <QMouseEvent>
27 #include <QPixmap>
28 #include <QDesktopWidget>
29 #include <QMessageBox>
30 #include <QLabel>
31 
32 #include "OSplashScreen.h"
33 
34 
35 
36 // WStyle_Splash est dispo que depuis Qt 3.1, il est equivalent a : WStyle_NoBorder|WStyle_StaysOnTop|WX11BypassWM
37 OSplashScreen::OSplashScreen(const QPixmap& pixmap, const QString& msgText) :
38  QWidget(0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint),
39  _pix(pixmap)
40 {
41  // Defini l'image
42  QPalette _palette = palette();
43  _palette.setBrush(backgroundRole(), QBrush(_pix));
44  setPalette(_palette);
45  resize(_pix.size());
46 
47 
48  // Defini le message texte
49  _msgLabel = new QLabel(msgText, this); // "<font color=\"#09367A\"><i><b>TYMPAN "+version+"</i></b></font>", this);
50  _msgLabel->setFont(QFont("Times", 30)); // la police du label
51  _msgLabel->setGeometry(80, 480, 300, 60);
52 
53  // Recupere la taille de l'ecran
54  QRect scr = QApplication::desktop()->screenGeometry();
55  // Centre le splash screen
56  move(scr.center() - rect().center());
57 
58  show();
59  repaint();
60 }
61 
63 {
64 }
65 
66 void OSplashScreen::setStatus(const QString& message, int alignment, const QColor& color)
67 {
68  QPixmap textPix = _pix;
69  QPainter painter(&textPix);
70  painter.setPen(color);
71  QFont tmpFont = painter.font();
72  //RNU : pb de version QT : en version 4.1, il faut donner un petit chiffre, mais pas en version 4.5
73 #if TY_PLATFORM == TY_PLATFORM_LINUX
74  tmpFont.setPointSize(3);
75 #else
76  tmpFont.setPointSize(10);
77 #endif
78  painter.setFont(tmpFont);
79 
80  QRect r = rect();
81  r.setRect(r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20);
82 
83  painter.drawText(r, alignment, message);
84 
85  QPalette _palette = palette();
86 
87  _palette.setBrush(backgroundRole(), QBrush(textPix));
88  setPalette(_palette);
89 
90  repaint();
91 }
92 
93 #if defined(Q_WS_X11)
94 //void qt_wait_for_window_manager(QWidget * widget);
95 #endif
96 
97 void OSplashScreen::finish(QWidget* mainWin)
98 {
99 #if defined(Q_WS_X11)
100  // qt_wait_for_window_manager(mainWin);
101 #endif
102 
103  close();
104 }
105 
107 {
108  QWidget::repaint();
109  QApplication::flush();
110 }
111 
112 void OSplashScreen::mousePressEvent(QMouseEvent* pEvent)
113 {
114  hide();
115 }
Splash screen widget (fichier header)
QPixmap _pix
L&#39;image du splash screen.
Definition: OSplashScreen.h:73
void mousePressEvent(QMouseEvent *pEvent)
OSplashScreen(const QPixmap &pixmap, const QString &msgText)
Constructeur par defaut.
void setStatus(const QString &message, int alignment=Qt::AlignLeft, const QColor &color=Qt::black)
Affiche un nouveau message indiquant le status de l&#39;application.
void finish(QWidget *pMainWin)
Indique que le chargement de l&#39;application est termine.
QLabel * _msgLabel
Definition: OSplashScreen.h:76
void repaint()
Mise a jour.
virtual ~OSplashScreen()
Destructeur.