Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_AboutDlg.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEGUI_AboutDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "SALOMEGUI_AboutDlg.h"
31 #include "QAD_Desktop.h"
32 #include "QAD_Tools.h"
33 #include <qlayout.h>
34 #include <qpixmap.h>
35 #include <qmessagebox.h>
36
37 /* 
38  * Constructor
39  */
40 SALOMEGUI_AboutDlg::SALOMEGUI_AboutDlg(QWidget* parent, const char* name )
41     : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
42 {
43   QPalette pal = palette();
44   QColorGroup cg;
45   cg.setColor( QColorGroup::Foreground, Qt::black );
46   cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) );
47   cg.setColor( QColorGroup::Light, Qt::white );
48   cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) );
49   cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) );
50   cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) );
51   cg.setColor( QColorGroup::Text, Qt::black );
52   cg.setColor( QColorGroup::BrightText, Qt::white );
53   cg.setColor( QColorGroup::ButtonText, Qt::black );
54   cg.setColor( QColorGroup::Base, Qt::white ); 
55   cg.setColor( QColorGroup::Background, Qt::white );
56   cg.setColor( QColorGroup::Shadow, Qt::black );
57   cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) );
58   cg.setColor( QColorGroup::HighlightedText, Qt::white );
59   pal.setActive( cg );
60   pal.setInactive( cg );
61   pal.setDisabled( cg );
62   setPalette(pal);
63
64   setCaption( tr("ABOUT_TLT") );
65   setSizeGripEnabled( false );
66   QVBoxLayout* SALOMEGUI_AboutDlgLayout = new QVBoxLayout( this ); 
67   SALOMEGUI_AboutDlgLayout->setSpacing( 6 );
68   SALOMEGUI_AboutDlgLayout->setMargin( 11 );
69   
70   AboutPicLab = new QLabel( this, "AboutPicLab" );
71   AboutPicLab->setFrameStyle( QLabel::Plain | QLabel::Box );
72   QPixmap icon1 ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", 
73                                                                 tr("ICON_ABOUT") ));
74
75   QString msg;
76   if(!QAD_Desktop::getResourceManager()->loadResources( "CLIENT", msg ))
77     {
78       QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
79     }
80
81   AboutPicLab->setPixmap( icon1 );
82   AboutPicLab->setScaledContents( false );
83   AboutPicLab->setAlignment( AlignCenter );
84   AboutPicLab->installEventFilter(this);
85   SALOMEGUI_AboutDlgLayout->addWidget( AboutPicLab );
86   
87   VersionLab = new QLabel( this, "VersionLab" );
88   VersionLab->setText( tr( "INF_VERSION"  ) );
89   VersionLab->setAlignment( AlignCenter );
90   VersionLab->installEventFilter(this);
91   SALOMEGUI_AboutDlgLayout->addWidget( VersionLab );
92   
93   CopyrightLab = new QLabel( this, "CopyrightLab" );
94   CopyrightLab->setText( tr( "INF_COPYRIGHT"  ) );
95   CopyrightLab->setAlignment( AlignCenter );
96   CopyrightLab->installEventFilter(this);
97   SALOMEGUI_AboutDlgLayout->addWidget( CopyrightLab );
98   
99   LicenseLab = new QLabel( this, "LicenseLab" );
100   LicenseLab->setText( tr( "INF_LICENSE"  ) );
101   LicenseLab->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
102   QFont LicenseLabFont(  LicenseLab->font() );
103   LicenseLabFont.setPointSize( 10 );
104   LicenseLab->setFont( LicenseLabFont ); 
105   LicenseLab->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
106   LicenseLab->installEventFilter(this);
107   SALOMEGUI_AboutDlgLayout->addWidget( LicenseLab );
108   LicenseLab->polish();
109
110   setMaximumSize(minimumSize());  
111
112   QAD_Tools::alignWidget(this, parent, AlignCenter);
113 }
114
115 /*  
116  * Destroys the object and frees any allocated resources
117  */
118 SALOMEGUI_AboutDlg::~SALOMEGUI_AboutDlg()
119 {
120   // no need to delete child widgets, Qt does it all for us
121 }
122
123 /*  
124  *  Main event handler. Reimplemented to handle application
125  *  font changes
126  */
127 bool SALOMEGUI_AboutDlg::event( QEvent* ev )
128 {
129   bool ret = QDialog::event( ev ); 
130   if ( ev->type() == QEvent::ApplicationFontChange ) {
131     QFont LicenseLabFont(  LicenseLab->font() );
132     LicenseLabFont.setPointSize( 10 );
133     LicenseLab->setFont( LicenseLabFont ); 
134   } 
135   else if ( ev->type() == QEvent::MouseButtonRelease ) {
136     accept();
137   }
138   return ret;
139 }
140
141 bool SALOMEGUI_AboutDlg::eventFilter( QObject* o,  QEvent* e)
142 {
143   if (e->type() == QEvent::MouseButtonRelease) {
144     accept();
145   }
146   return QDialog::eventFilter(o, e);
147 }