1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_AboutDlg.cxx
24 // Created: 03.06.2005 13:52:45
25 // Author: Sergey TELKOV
27 #include "LightApp_AboutDlg.h"
28 #include "LightApp_Application.h"
30 #include <SUIT_Session.h>
31 #include <SUIT_ResourceMgr.h>
33 #include <QtxGridBox.h>
36 #include <QVBoxLayout>
41 #include <QPushButton>
44 LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
45 : QtxDialog( parent, true, false, None )
47 setObjectName( "salome_about_dialog" );
49 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
51 QPixmap ico = resMgr->loadPixmap( "LightApp", tr( "ICO_ABOUT" ), false );
55 QPalette pal = palette();
57 pal.setBrush( QPalette::Active, QPalette::WindowText, QBrush( Qt::darkBlue ) );
58 pal.setBrush( QPalette::Active, QPalette::Window, QBrush( Qt::white ) );
60 pal.setBrush( QPalette::Inactive, QPalette::WindowText, QBrush( Qt::darkBlue ) );
61 pal.setBrush( QPalette::Inactive, QPalette::Window, QBrush( Qt::white ) );
64 pal.setBrush( QPalette::Disabled, QPalette::WindowText, QBrush( Qt::darkBlue ) );
65 pal.setBrush( QPalette::Disabled, QPalette::Window, QBrush( Qt::white ) );
71 QTabWidget* tw = new QTabWidget( mainFrame() );
73 QGridLayout* main = new QGridLayout( mainFrame() );
74 main->addWidget( tw, 0, 0, 1, 3 );
76 QtxGridBox* base = new QtxGridBox( 1, Qt::Horizontal, tw, 0, 0 );
77 base->setInsideMargin( 0 );
79 tw->addTab(base, tr("ABOUT_BASE") );
81 tw->addTab(getModulesInfoWidget(tw), tr("ABOUT_MODULE_INFOS") );
83 QPushButton * btn = new QPushButton( tr("ABOUT_CLOSE"), mainFrame() );
85 main->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 1, 0, 1, 1);
87 main->addWidget( btn, 1, 1, 1, 1);
89 main->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 1, 2, 1, 1);
91 connect(btn, SIGNAL( clicked() ), this, SLOT( accept()) );
94 QLabel* screen = new QLabel( base );
95 screen->setScaledContents( true );
96 screen->setAlignment( Qt::AlignCenter );
97 screen->setFrameStyle( QFrame::Box | QFrame::Plain );
99 QLabel* title = new QLabel( base );
100 title->setAlignment( Qt::AlignCenter );
101 changeFont( title, true, false, false, 5 );
103 QLabel* version = new QLabel( base );
104 version->setAlignment( Qt::AlignCenter );
105 changeFont( version, false, true, false, 2 );
107 QLabel* copyright = new QLabel( base );
108 copyright->setAlignment( Qt::AlignCenter );
109 changeFont( copyright, false, false, false, 1 );
111 QLabel* license = new QLabel( base );
112 license->setAlignment( Qt::AlignCenter );
113 changeFont( license, false, false, false, 1 );
115 screen->setPixmap( resMgr->loadPixmap( "LightApp", tr( "ABOUT" ), false ) );
116 checkLabel( screen );
118 QString titleText = tr( "ABOUT_TITLE" );
119 if ( titleText == "ABOUT_TITLE" )
121 title->setText( titleText );
124 QString verText = tr( "ABOUT_VERSION" );
125 if ( verText.contains( "%1" ) )
126 verText = verText.arg( defVer );
127 version->setText( verText );
128 checkLabel( version );
130 copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
131 checkLabel( copyright );
133 license->setText( tr( "ABOUT_LICENSE" ) );
134 checkLabel( license );
136 QString capText = tr( "ABOUT_CAPTION" );
137 if ( capText.contains( "%1" ) )
138 capText = capText.arg( defName );
139 setWindowTitle( capText );
141 setSizeGripEnabled( false );
145 LightApp_AboutDlg::~LightApp_AboutDlg()
150 /*!Change font of widget \a wid.
151 *\param wid - QWidget
152 *\param bold - boolean value
153 *\param italic - boolean value
154 *\param underline - boolean value
155 *\param inc - integer increment for font point size.
157 void LightApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
158 const bool underline, const int inc ) const
163 QFont widFont = wid->font();
164 widFont.setBold( bold );
165 widFont.setItalic( italic );
166 widFont.setUnderline( underline );
167 widFont.setPointSize( widFont.pointSize() + inc );
170 /*!Check lable \a lab.*/
171 void LightApp_AboutDlg::checkLabel( QLabel* lab ) const
176 bool vis = !lab->text().trimmed().isEmpty() ||
177 ( lab->pixmap() && !lab->pixmap()->isNull() );
178 vis ? lab->show() : lab->hide();
181 /*! Return widget with info about versions of modules */
182 QWidget* LightApp_AboutDlg::getModulesInfoWidget(QWidget* parent) const {
184 QWidget* modulesInfo = new QWidget(parent);
185 QGridLayout* gridLayout = new QGridLayout(modulesInfo);
187 LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
190 CAM_Application::ModuleShortInfoList info = app->getVersionInfo();
192 CAM_Application::ModuleShortInfoList::const_iterator it = info.constBegin();
195 QString unknownVersion = tr("ABOUT_UNKNOWN_VERSION");
197 while (it != info.constEnd()) {
198 QLabel * name = new QLabel( "<h4>" + (*it).name + ":</h4>", modulesInfo);
199 QString v = (*it).version.isEmpty() ? unknownVersion : (*it).version;
200 QLabel * version = new QLabel("<h4>" + v + "</h4>",modulesInfo);
201 gridLayout->addWidget(name , i, 0);
202 gridLayout->addWidget(version , i, 1);
203 gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), i, 2);
207 gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 0);
208 gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 1);