Salome HOME
NRI : Add message (GUI lib not found).
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_AboutDlg.cxx
1 using namespace std;
2 //  File      : SALOMEGUI_AboutDlg.cxx
3 //  Created   : Fri Sep 14 09:56:23 2001
4 //  Author    : Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : SALOMEGUI
7 //  Copyright : Open CASCADE
8 //  $Header$
9
10 #include "SALOMEGUI_AboutDlg.h"
11 #include "QAD_Desktop.h"
12 #include "QAD_Tools.h"
13 #include <qlayout.h>
14 #include <qpixmap.h>
15 #include <qmessagebox.h>
16
17 /* 
18  * Constructor
19  */
20 SALOMEGUI_AboutDlg::SALOMEGUI_AboutDlg(QWidget* parent, const char* name )
21     : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
22 {
23   QPalette pal = palette();
24   QColorGroup cg;
25   cg.setColor( QColorGroup::Foreground, Qt::black );
26   cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) );
27   cg.setColor( QColorGroup::Light, Qt::white );
28   cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) );
29   cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) );
30   cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) );
31   cg.setColor( QColorGroup::Text, Qt::black );
32   cg.setColor( QColorGroup::BrightText, Qt::white );
33   cg.setColor( QColorGroup::ButtonText, Qt::black );
34   cg.setColor( QColorGroup::Base, Qt::white ); 
35   cg.setColor( QColorGroup::Background, Qt::white );
36   cg.setColor( QColorGroup::Shadow, Qt::black );
37   cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) );
38   cg.setColor( QColorGroup::HighlightedText, Qt::white );
39   pal.setActive( cg );
40   pal.setInactive( cg );
41   pal.setDisabled( cg );
42   setPalette(pal);
43
44   setCaption( tr("ABOUT_TLT") );
45   setSizeGripEnabled( false );
46   QVBoxLayout* SALOMEGUI_AboutDlgLayout = new QVBoxLayout( this ); 
47   SALOMEGUI_AboutDlgLayout->setSpacing( 6 );
48   SALOMEGUI_AboutDlgLayout->setMargin( 11 );
49   
50   AboutPicLab = new QLabel( this, "AboutPicLab" );
51   AboutPicLab->setFrameStyle( QLabel::Plain | QLabel::Box );
52   QPixmap icon1 ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", 
53                                                                 tr("ICON_ABOUT") ));
54
55   QString msg;
56   if(!QAD_Desktop::getResourceManager()->loadResources( "CLIENT", msg ))
57     {
58       QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
59     }
60
61   AboutPicLab->setPixmap( icon1 );
62   AboutPicLab->setScaledContents( false );
63   AboutPicLab->setAlignment( AlignCenter );
64   AboutPicLab->installEventFilter(this);
65   SALOMEGUI_AboutDlgLayout->addWidget( AboutPicLab );
66   
67   VersionLab = new QLabel( this, "VersionLab" );
68   VersionLab->setText( tr( "INF_VERSION"  ) );
69   VersionLab->setAlignment( AlignCenter );
70   VersionLab->installEventFilter(this);
71   SALOMEGUI_AboutDlgLayout->addWidget( VersionLab );
72   
73   CopyrightLab = new QLabel( this, "CopyrightLab" );
74   CopyrightLab->setText( tr( "INF_COPYRIGHT"  ) );
75   CopyrightLab->setAlignment( AlignCenter );
76   CopyrightLab->installEventFilter(this);
77   SALOMEGUI_AboutDlgLayout->addWidget( CopyrightLab );
78   
79   LicenseLab = new QLabel( this, "LicenseLab" );
80   LicenseLab->setText( tr( "INF_LICENSE"  ) );
81   LicenseLab->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
82   QFont LicenseLabFont(  LicenseLab->font() );
83   LicenseLabFont.setPointSize( 10 );
84   LicenseLab->setFont( LicenseLabFont ); 
85   LicenseLab->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
86   LicenseLab->installEventFilter(this);
87   SALOMEGUI_AboutDlgLayout->addWidget( LicenseLab );
88   LicenseLab->polish();
89
90   setMaximumSize(minimumSize());  
91
92   QAD_Tools::alignWidget(this, parent, AlignCenter);
93 }
94
95 /*  
96  * Destroys the object and frees any allocated resources
97  */
98 SALOMEGUI_AboutDlg::~SALOMEGUI_AboutDlg()
99 {
100   // no need to delete child widgets, Qt does it all for us
101 }
102
103 /*  
104  *  Main event handler. Reimplemented to handle application
105  *  font changes
106  */
107 bool SALOMEGUI_AboutDlg::event( QEvent* ev )
108 {
109   bool ret = QDialog::event( ev ); 
110   if ( ev->type() == QEvent::ApplicationFontChange ) {
111     QFont LicenseLabFont(  LicenseLab->font() );
112     LicenseLabFont.setPointSize( 10 );
113     LicenseLab->setFont( LicenseLabFont ); 
114   } 
115   else if ( ev->type() == QEvent::MouseButtonRelease ) {
116     accept();
117   }
118   return ret;
119 }
120
121 bool SALOMEGUI_AboutDlg::eventFilter( QObject* o,  QEvent* e)
122 {
123   if (e->type() == QEvent::MouseButtonRelease) {
124     accept();
125   }
126   return QDialog::eventFilter(o, e);
127 }