Salome HOME
689d4165cbab78017d36df04d391fc9320a6c53d
[modules/gui.git] / src / LightApp / LightApp_AboutDlg.cxx
1 // File:      LightApp_AboutDlg.cxx
2 // Created:   03.06.2005 13:52:45
3 // Author:    Sergey TELKOV
4 // Copyright (C) CEA 2005
5
6 #include "LightApp_AboutDlg.h"
7
8 #include <SUIT_Session.h>
9 #include <SUIT_ResourceMgr.h>
10
11 #include <qlabel.h>
12 #include <qlayout.h>
13 #include <qpixmap.h>
14 #include <qgroupbox.h>
15
16 /*!Constructor.*/
17 LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
18 : QtxDialog( parent, "salome_about_dialog", true, false, None )
19 {
20   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
21
22   QPixmap ico = resMgr->loadPixmap( "LightApp", tr( "ICO_ABOUT" ), false );
23   if ( !ico.isNull() )
24     setIcon( ico );
25
26   QPalette pal = palette();
27   QColorGroup cg = pal.active();
28   cg.setColor( QColorGroup::Foreground, Qt::darkBlue ); 
29   cg.setColor( QColorGroup::Background, Qt::white );
30   pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
31   setPalette(pal);
32
33   QVBoxLayout* main = new QVBoxLayout( mainFrame() );
34   QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() );
35   base->setFrameStyle( QFrame::NoFrame );
36   base->setInsideMargin( 0 );
37   main->addWidget( base );
38
39   QLabel* screen = new QLabel( base );
40   screen->setScaledContents( true );
41   screen->setAlignment( Qt::AlignCenter );
42   screen->setFrameStyle( QFrame::Box | QFrame::Plain );
43
44   QLabel* title = new QLabel( base );
45   title->setAlignment( Qt::AlignCenter );
46   changeFont( title, true, false, false, 5 );
47
48   QLabel* version = new QLabel( base );
49   version->setAlignment( Qt::AlignCenter );
50   changeFont( version, false, true, false, 2 );
51   
52   QLabel* copyright = new QLabel( base );
53   copyright->setAlignment( Qt::AlignCenter );
54   changeFont( copyright, false, false, false, 1 );
55
56   QLabel* license = new QLabel( base );
57   license->setAlignment( Qt::AlignCenter );
58   changeFont( license, false, false, false, 1 );
59
60   screen->setPixmap( resMgr->loadPixmap( "LightApp", tr( "ABOUT" ), false ) );
61   checkLabel( screen );
62
63   QString titleText = tr( "ABOUT_TITLE" );
64   if ( titleText == "ABOUT_TITLE" )
65     titleText = defName;
66   title->setText( titleText );
67   checkLabel( title );
68
69   QString verText = tr( "ABOUT_VERSION" );
70   if ( verText.contains( "%1" ) )
71     verText = verText.arg( defVer );
72   version->setText( verText );
73   checkLabel( version );
74
75   copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
76   checkLabel( copyright );
77
78   license->setText( tr( "ABOUT_LICENSE" ) );
79   checkLabel( license );
80
81   QString capText = tr( "ABOUT_CAPTION" );
82   if ( capText.contains( "%1" ) )
83     capText = capText.arg( defName );
84   setCaption( capText );
85
86   setSizeGripEnabled( false );
87 }
88
89 /*!Destructor.*/
90 LightApp_AboutDlg::~LightApp_AboutDlg()
91 {
92   //! Do nothing.
93 }
94
95 /*!On mouse press event.*/
96 void LightApp_AboutDlg::mousePressEvent( QMouseEvent* )
97 {
98   accept();
99 }
100
101 /*!Change font of widget \a wid.
102  *\param wid - QWidget
103  *\param bold - boolean value
104  *\param italic - boolean value
105  *\param underline - boolean value
106  *\param inc - integer increment for font point size.
107  */
108 void LightApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
109                                      const bool underline, const int inc ) const
110 {
111   if ( !wid )
112     return;
113
114   QFont widFont = wid->font();
115   widFont.setBold( bold );
116   widFont.setItalic( italic );
117   widFont.setUnderline( underline );
118   widFont.setPointSize( widFont.pointSize() + inc );
119 }
120
121 /*!Check lable \a lab.*/
122 void LightApp_AboutDlg::checkLabel( QLabel* lab ) const
123 {
124   if ( !lab )
125     return;
126
127   bool vis = !lab->text().stripWhiteSpace().isEmpty() ||
128              ( lab->pixmap() && !lab->pixmap()->isNull() );
129   vis ? lab->show() : lab->hide();
130 }