Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / LightApp / LightApp_AboutDlg.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File:      LightApp_AboutDlg.cxx
20 // Created:   03.06.2005 13:52:45
21 // Author:    Sergey TELKOV
22 // Copyright (C) CEA 2005
23
24 #include "LightApp_AboutDlg.h"
25
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
28
29 #include <qlabel.h>
30 #include <qlayout.h>
31 #include <qpixmap.h>
32 #include <qgroupbox.h>
33
34 /*!Constructor.*/
35 LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
36 : QtxDialog( parent, "salome_about_dialog", true, false, None )
37 {
38   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
39
40   QPixmap ico = resMgr->loadPixmap( "LightApp", tr( "ICO_ABOUT" ), false );
41   if ( !ico.isNull() )
42     setIcon( ico );
43
44   QPalette pal = palette();
45   QColorGroup cg = pal.active();
46   cg.setColor( QColorGroup::Foreground, Qt::darkBlue ); 
47   cg.setColor( QColorGroup::Background, Qt::white );
48   pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
49   setPalette(pal);
50
51   QVBoxLayout* main = new QVBoxLayout( mainFrame() );
52   QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() );
53   base->setFrameStyle( QFrame::NoFrame );
54   base->setInsideMargin( 0 );
55   main->addWidget( base );
56
57   QLabel* screen = new QLabel( base );
58   screen->setScaledContents( true );
59   screen->setAlignment( Qt::AlignCenter );
60   screen->setFrameStyle( QFrame::Box | QFrame::Plain );
61
62   QLabel* title = new QLabel( base );
63   title->setAlignment( Qt::AlignCenter );
64   changeFont( title, true, false, false, 5 );
65
66   QLabel* version = new QLabel( base );
67   version->setAlignment( Qt::AlignCenter );
68   changeFont( version, false, true, false, 2 );
69   
70   QLabel* copyright = new QLabel( base );
71   copyright->setAlignment( Qt::AlignCenter );
72   changeFont( copyright, false, false, false, 1 );
73
74   QLabel* license = new QLabel( base );
75   license->setAlignment( Qt::AlignCenter );
76   changeFont( license, false, false, false, 1 );
77
78   screen->setPixmap( resMgr->loadPixmap( "LightApp", tr( "ABOUT" ), false ) );
79   checkLabel( screen );
80
81   QString titleText = tr( "ABOUT_TITLE" );
82   if ( titleText == "ABOUT_TITLE" )
83     titleText = defName;
84   title->setText( titleText );
85   checkLabel( title );
86
87   QString verText = tr( "ABOUT_VERSION" );
88   if ( verText.contains( "%1" ) )
89     verText = verText.arg( defVer );
90   version->setText( verText );
91   checkLabel( version );
92
93   copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
94   checkLabel( copyright );
95
96   license->setText( tr( "ABOUT_LICENSE" ) );
97   checkLabel( license );
98
99   QString capText = tr( "ABOUT_CAPTION" );
100   if ( capText.contains( "%1" ) )
101     capText = capText.arg( defName );
102   setCaption( capText );
103
104   setSizeGripEnabled( false );
105 }
106
107 /*!Destructor.*/
108 LightApp_AboutDlg::~LightApp_AboutDlg()
109 {
110   //! Do nothing.
111 }
112
113 /*!On mouse press event.*/
114 void LightApp_AboutDlg::mousePressEvent( QMouseEvent* )
115 {
116   accept();
117 }
118
119 /*!Change font of widget \a wid.
120  *\param wid - QWidget
121  *\param bold - boolean value
122  *\param italic - boolean value
123  *\param underline - boolean value
124  *\param inc - integer increment for font point size.
125  */
126 void LightApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
127                                      const bool underline, const int inc ) const
128 {
129   if ( !wid )
130     return;
131
132   QFont widFont = wid->font();
133   widFont.setBold( bold );
134   widFont.setItalic( italic );
135   widFont.setUnderline( underline );
136   widFont.setPointSize( widFont.pointSize() + inc );
137 }
138
139 /*!Check lable \a lab.*/
140 void LightApp_AboutDlg::checkLabel( QLabel* lab ) const
141 {
142   if ( !lab )
143     return;
144
145   bool vis = !lab->text().stripWhiteSpace().isEmpty() ||
146              ( lab->pixmap() && !lab->pixmap()->isNull() );
147   vis ? lab->show() : lab->hide();
148 }