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