From: rnv Date: Tue, 13 Sep 2011 07:55:09 +0000 (+0000) Subject: Implementation of the "20494: EDF 1123 KERNEL/GUI : Improvment of 'About' dialog... X-Git-Tag: OpenCV_demo1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86a522fd380111056a5e6353d3a6df2442860ebc;p=modules%2Fgui.git Implementation of the "20494: EDF 1123 KERNEL/GUI : Improvment of 'About' dialog box" issue. --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index d60ce80f7..117c2878d 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -31,6 +31,9 @@ #include #include +#include +#include + #include #include @@ -288,6 +291,7 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show QString err; GET_MODULE_FUNC crtInst = 0; + GET_VERSION_FUNC getVersion = 0; #ifdef WIN32 HINSTANCE modLib = ::LoadLibrary( libName.toLatin1() ); @@ -310,6 +314,8 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show err = QString( "Failed to find %1 function. %2" ).arg( GET_MODULE_NAME ).arg( (LPTSTR)lpMsgBuf ); ::LocalFree( lpMsgBuf ); } + + getVersion = (GET_VERSION_FUNC)::GetProcAddress( modLib, GET_VERSION_NAME ); } #else void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY ); @@ -320,6 +326,8 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show crtInst = (GET_MODULE_FUNC)dlsym( modLib, GET_MODULE_NAME ); if ( !crtInst ) err = QString( "Failed to find function %1. %2" ).arg( GET_MODULE_NAME ).arg( dlerror() ); + + getVersion = (GET_VERSION_FUNC)dlsym( modLib, GET_VERSION_NAME ); } #endif @@ -337,6 +345,19 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show qWarning( qPrintable( err ) ); } + char* version = getVersion ? getVersion() : 0; + + if(version) { + for ( ModuleInfoList::iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) { + if ( (*it).title == modName ) { + if( (*it).version.isEmpty() ) { + (*it).version = QString(version); + } + break; + } + } + } + return module; } @@ -691,12 +712,15 @@ void CAM_Application::readModuleList() bool aIsSingleton = resMgr->booleanValue(*it, "singleton", false); + QString ver = resMgr->stringValue(*it, modName + "_VERSION", QString()); + ModuleInfo inf; inf.name = modName; inf.title = modTitle; inf.internal = modLibrary; inf.icon = modIcon; inf.isSingleton = aIsSingleton; + inf.version = ver; myInfoList.append( inf ); } @@ -736,3 +760,29 @@ void CAM_Application::createEmptyStudy() /*SUIT_Study* study = */activeStudy(); STD_Application::createEmptyStudy(); } + +/*! + \brief Return information about version of the each module. +*/ +CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() const { + + ModuleShortInfoList info; + + ModuleShortInfo kernel; + kernel.name = "KERNEL"; + kernel.version = GUI_VERSION_STR; + info.append(kernel); + + ModuleShortInfo gui; + gui.name = "GUI"; + gui.version = GUI_VERSION_STR; + info.append(gui); + + for(int i = 0; i < myInfoList.size(); i++) { + ModuleShortInfo infoItem; + infoItem.name = myInfoList.at(i).title; + infoItem.version = myInfoList.at(i).version; + info.append(infoItem); + } + return info; +} diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index d2b020f0a..6471b9730 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -41,6 +41,8 @@ class CAM_EXPORT CAM_Application : public STD_Application public: typedef QList ModuleList; + typedef struct { QString name; QString version; } ModuleShortInfo; + typedef QList ModuleShortInfoList; public: CAM_Application( const bool = true ); @@ -71,6 +73,8 @@ public: virtual void createEmptyStudy(); + ModuleShortInfoList getVersionInfo() const; + protected: virtual SUIT_Study* createNewStudy(); virtual void updateCommandsStatus(); @@ -88,7 +92,7 @@ private: void readModuleList(); private: - typedef struct { QString name, title, internal, icon; bool isSingleton; } ModuleInfo; + typedef struct { QString name, title, internal, icon; bool isSingleton; QString version; } ModuleInfo; typedef QList ModuleInfoList; private: diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index e464e876f..67ede6f94 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -152,8 +152,9 @@ private: extern "C" { typedef CAM_Module* (*GET_MODULE_FUNC)(); + typedef char* (*GET_VERSION_FUNC)(); } #define GET_MODULE_NAME "createModule" - +#define GET_VERSION_NAME "getModuleVersion" #endif diff --git a/src/CAM/Makefile.am b/src/CAM/Makefile.am index e78ce0a93..da4c90977 100755 --- a/src/CAM/Makefile.am +++ b/src/CAM/Makefile.am @@ -53,6 +53,6 @@ nodist_libCAM_la_SOURCES = $(MOC_FILES) nodist_salomeres_DATA = CAM_msg_en.qm CAM_msg_fr.qm -libCAM_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../STD -I$(srcdir)/../Qtx +libCAM_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../STD -I$(srcdir)/../Qtx -I$(top_builddir) libCAM_la_LDFLAGS = $(QT_MT_LIBS) libCAM_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../STD/libstd.la diff --git a/src/LightApp/LightApp_AboutDlg.cxx b/src/LightApp/LightApp_AboutDlg.cxx index 2c1834ad1..09d0a070f 100644 --- a/src/LightApp/LightApp_AboutDlg.cxx +++ b/src/LightApp/LightApp_AboutDlg.cxx @@ -25,6 +25,7 @@ // Author: Sergey TELKOV // #include "LightApp_AboutDlg.h" +#include "LightApp_Application.h" #include #include @@ -36,6 +37,8 @@ #include #include #include +#include +#include /*!Constructor.*/ LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent ) @@ -57,15 +60,36 @@ LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& def pal.setBrush( QPalette::Inactive, QPalette::WindowText, QBrush( Qt::darkBlue ) ); pal.setBrush( QPalette::Inactive, QPalette::Window, QBrush( Qt::white ) ); + pal.setBrush( QPalette::Disabled, QPalette::WindowText, QBrush( Qt::darkBlue ) ); pal.setBrush( QPalette::Disabled, QPalette::Window, QBrush( Qt::white ) ); + + setPalette(pal); - QVBoxLayout* main = new QVBoxLayout( mainFrame() ); - QtxGridBox* base = new QtxGridBox( 1, Qt::Horizontal, mainFrame(), 0, 0 ); + QTabWidget* tw = new QTabWidget( mainFrame() ); + + QGridLayout* main = new QGridLayout( mainFrame() ); + main->addWidget( tw, 0, 0, 1, 3 ); + + QtxGridBox* base = new QtxGridBox( 1, Qt::Horizontal, tw, 0, 0 ); base->setInsideMargin( 0 ); - main->addWidget( base ); + + tw->addTab(base, tr("ABOUT_BASE") ); + + tw->addTab(getModulesInfoWidget(tw), tr("ABOUT_MODULE_INFOS") ); + + QPushButton * btn = new QPushButton( tr("ABOUT_CLOSE"), mainFrame() ); + + main->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 1, 0, 1, 1); + + main->addWidget( btn, 1, 1, 1, 1); + + main->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 1, 2, 1, 1); + + connect(btn, SIGNAL( clicked() ), this, SLOT( accept()) ); + QLabel* screen = new QLabel( base ); screen->setScaledContents( true ); @@ -123,12 +147,6 @@ LightApp_AboutDlg::~LightApp_AboutDlg() //! Do nothing. } -/*!On mouse press event.*/ -void LightApp_AboutDlg::mousePressEvent( QMouseEvent* ) -{ - accept(); -} - /*!Change font of widget \a wid. *\param wid - QWidget *\param bold - boolean value @@ -159,3 +177,35 @@ void LightApp_AboutDlg::checkLabel( QLabel* lab ) const ( lab->pixmap() && !lab->pixmap()->isNull() ); vis ? lab->show() : lab->hide(); } + +/*! Return widget with info about versions of modules */ +QWidget* LightApp_AboutDlg::getModulesInfoWidget(QWidget* parent) const { + + QWidget* modulesInfo = new QWidget(parent); + QGridLayout* gridLayout = new QGridLayout(modulesInfo); + + LightApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); + if(app) { + + CAM_Application::ModuleShortInfoList info = app->getVersionInfo(); + + CAM_Application::ModuleShortInfoList::const_iterator it = info.constBegin(); + int i = 0; + + QString unknownVersion = tr("ABOUT_UNKNOWN_VERSION"); + + while (it != info.constEnd()) { + QLabel * name = new QLabel( "

" + (*it).name + ":

", modulesInfo); + QString v = (*it).version.isEmpty() ? unknownVersion : (*it).version; + QLabel * version = new QLabel("

" + v + "

",modulesInfo); + gridLayout->addWidget(name , i, 0); + gridLayout->addWidget(version , i, 1); + gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), i, 2); + it++; + i++; + } + gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 0); + gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 1); + } + return modulesInfo; +} diff --git a/src/LightApp/LightApp_AboutDlg.h b/src/LightApp/LightApp_AboutDlg.h index 6101316be..38fc2d5c0 100644 --- a/src/LightApp/LightApp_AboutDlg.h +++ b/src/LightApp/LightApp_AboutDlg.h @@ -45,13 +45,12 @@ public: LightApp_AboutDlg( const QString&, const QString&, QWidget* = 0 ); virtual ~LightApp_AboutDlg(); -protected: - virtual void mousePressEvent( QMouseEvent* ); - private: void checkLabel( QLabel* ) const; void changeFont( QWidget*, const bool = false, const bool = false, const bool = false, const int = 0 ) const; + + QWidget* getModulesInfoWidget(QWidget* parent) const; }; #endif diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 5f68a1ab4..574878f81 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -18,6 +18,22 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASABOUT_CAPTION About %1 + + ABOUT_BASE + Base information + + + ABOUT_MODULE_INFOS + Modules information + + + ABOUT_UNKNOWN_VERSION + Unknown + + + ABOUT_CLOSE + &Close + APP_NAME SALOME