Salome HOME
Object browser reference text color was corrected.
[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
26   QVBoxLayout* main = new QVBoxLayout( mainFrame() );
27   QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() );
28   base->setFrameStyle( QFrame::NoFrame );
29   base->setInsideMargin( 0 );
30   main->addWidget( base );
31
32   QLabel* screen = new QLabel( base );
33   screen->setScaledContents( true );
34   screen->setAlignment( Qt::AlignCenter );
35   screen->setFrameStyle( QFrame::Box | QFrame::Plain );
36
37   QLabel* title = new QLabel( base );
38   title->setAlignment( Qt::AlignCenter );
39   changeFont( title, true, false, false, 5 );
40
41   QLabel* version = new QLabel( base );
42   version->setAlignment( Qt::AlignCenter );
43   changeFont( version, false, true, false, 2 );
44   
45   QLabel* copyright = new QLabel( base );
46   copyright->setAlignment( Qt::AlignCenter );
47   changeFont( copyright, false, false, false, 1 );
48
49   QLabel* license = new QLabel( base );
50   license->setAlignment( Qt::AlignCenter );
51   changeFont( license, false, false, false, 1 );
52
53   screen->setPixmap( resMgr->loadPixmap( "SalomeApp", tr( "ABOUT" ) ) );
54   checkLabel( screen );
55
56   QString titleText = tr( "ABOUT_TITLE" );
57   if ( titleText == "ABOUT_TITLE" )
58     titleText = defName;
59   title->setText( titleText );
60   checkLabel( title );
61
62   QString verText = tr( "ABOUT_VERSION" );
63   if ( verText.contains( "%1" ) )
64     verText = verText.arg( defVer );
65   version->setText( verText );
66   checkLabel( version );
67
68   copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
69   checkLabel( copyright );
70
71   license->setText( tr( "ABOUT_LICENSE" ) );
72   checkLabel( license );
73
74   QString capText = tr( "ABOUT_CAPTION" );
75   if ( capText.contains( "%1" ) )
76     capText = capText.arg( defName );
77   setCaption( capText );
78
79   setSizeGripEnabled( false );
80 }
81
82 SalomeApp_AboutDlg::~SalomeApp_AboutDlg()
83 {
84 }
85
86 void SalomeApp_AboutDlg::mousePressEvent( QMouseEvent* )
87 {
88   accept();
89 }
90
91 void SalomeApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
92                                      const bool underline, const int inc ) const
93 {
94   if ( !wid )
95     return;
96
97   QFont widFont = wid->font();
98   widFont.setBold( bold );
99   widFont.setItalic( italic );
100   widFont.setUnderline( underline );
101   widFont.setPointSize( widFont.pointSize() + inc );
102 }
103
104 void SalomeApp_AboutDlg::checkLabel( QLabel* lab ) const
105 {
106   if ( !lab )
107     return;
108
109   bool vis = !lab->text().stripWhiteSpace().isEmpty() ||
110              ( lab->pixmap() && !lab->pixmap()->isNull() );
111   vis ? lab->show() : lab->hide();
112 }