#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
+#include <KERNEL_version.h>
+#include <GUI_version.h>
+
#include <QApplication>
#include <QRegExp>
QString err;
GET_MODULE_FUNC crtInst = 0;
+ GET_VERSION_FUNC getVersion = 0;
#ifdef WIN32
HINSTANCE modLib = ::LoadLibrary( libName.toLatin1() );
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 );
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
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;
}
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 );
}
/*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;
+}
public:
typedef QList<CAM_Module*> ModuleList;
+ typedef struct { QString name; QString version; } ModuleShortInfo;
+ typedef QList<ModuleShortInfo> ModuleShortInfoList;
public:
CAM_Application( const bool = true );
virtual void createEmptyStudy();
+ ModuleShortInfoList getVersionInfo() const;
+
protected:
virtual SUIT_Study* createNewStudy();
virtual void updateCommandsStatus();
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<ModuleInfo> ModuleInfoList;
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
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
// Author: Sergey TELKOV
//
#include "LightApp_AboutDlg.h"
+#include "LightApp_Application.h"
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <QPixmap>
#include <QIcon>
#include <QGroupBox>
+#include <QTabWidget>
+#include <QPushButton>
/*!Constructor.*/
LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
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 );
//! 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
( 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<LightApp_Application*>(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( "<h4>" + (*it).name + ":</h4>", modulesInfo);
+ QString v = (*it).version.isEmpty() ? unknownVersion : (*it).version;
+ QLabel * version = new QLabel("<h4>" + v + "</h4>",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;
+}
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
<source>ABOUT_CAPTION</source>
<translation>About %1</translation>
</message>
+ <message>
+ <source>ABOUT_BASE</source>
+ <translation>Base information</translation>
+ </message>
+ <message>
+ <source>ABOUT_MODULE_INFOS</source>
+ <translation>Modules information</translation>
+ </message>
+ <message>
+ <source>ABOUT_UNKNOWN_VERSION</source>
+ <translation>Unknown</translation>
+ </message>
+ <message>
+ <source>ABOUT_CLOSE</source>
+ <translation>&Close</translation>
+ </message>
<message>
<source>APP_NAME</source>
<translation>SALOME</translation>