From 01881808e9b55e6619708996f375737fd00e1909 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 3 Jun 2005 11:23:56 +0000 Subject: [PATCH] Added new About dialog box --- src/SalomeApp/Makefile.in | 7 +- src/SalomeApp/SalomeApp_AboutDlg.cxx | 112 ++++++++++++++++++++ src/SalomeApp/SalomeApp_AboutDlg.h | 37 +++++++ src/SalomeApp/SalomeApp_Application.cxx | 68 ++++++++---- src/SalomeApp/SalomeApp_Application.h | 1 + src/SalomeApp/resources/SalomeApp_images.po | 3 +- src/SalomeApp/resources/SalomeApp_msg_en.po | 20 +++- 7 files changed, 219 insertions(+), 29 deletions(-) create mode 100644 src/SalomeApp/SalomeApp_AboutDlg.cxx create mode 100644 src/SalomeApp/SalomeApp_AboutDlg.h diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index bd86b37be..5dfba1490 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -13,6 +13,7 @@ VPATH=.:@srcdir@:@srcdir@/resources # header files EXPORT_HEADERS= SalomeApp.h \ + SalomeApp_AboutDlg.h \ SalomeApp_Application.h \ SalomeApp_DataModel.h \ SalomeApp_DataObject.h \ @@ -45,7 +46,8 @@ PO_FILES = SalomeApp_images.po \ # Libraries targets LIB = libSalomeApp.la -LIB_SRC= SalomeApp_Application.cxx \ +LIB_SRC= SalomeApp_AboutDlg.cxx \ + SalomeApp_Application.cxx \ SalomeApp_DataModel.cxx \ SalomeApp_DataObject.cxx \ SalomeApp_DataOwner.cxx \ @@ -71,7 +73,8 @@ LIB_SRC= SalomeApp_Application.cxx \ SalomeApp_TypeFilter.cxx \ SalomeApp_OBFilter.cxx -LIB_MOC = SalomeApp_Application.h \ +LIB_MOC = SalomeApp_AboutDlg.h \ + SalomeApp_Application.h \ SalomeApp_DataModel.h \ SalomeApp_OBSelector.h \ SalomeApp_OCCSelector.h \ diff --git a/src/SalomeApp/SalomeApp_AboutDlg.cxx b/src/SalomeApp/SalomeApp_AboutDlg.cxx new file mode 100644 index 000000000..2f142db91 --- /dev/null +++ b/src/SalomeApp/SalomeApp_AboutDlg.cxx @@ -0,0 +1,112 @@ +// File: SalomeApp_AboutDlg.cxx +// Created: 03.06.2005 13:52:45 +// Author: Sergey TELKOV +// Copyright (C) CEA 2005 + +#include "SalomeApp_AboutDlg.h" + +#include +#include + +#include +#include +#include +#include + +SalomeApp_AboutDlg::SalomeApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent ) +: QtxDialog( parent, "salome_about_dialog", true, false, None ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + QPixmap ico = resMgr->loadPixmap( "SalomeApp", tr( "ICO_ABOUT" ) ); + if ( !ico.isNull() ) + setIcon( ico ); + + + QVBoxLayout* main = new QVBoxLayout( mainFrame() ); + QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() ); + base->setFrameStyle( QFrame::NoFrame ); + base->setInsideMargin( 0 ); + main->addWidget( base ); + + QLabel* screen = new QLabel( base ); + screen->setScaledContents( true ); + screen->setAlignment( Qt::AlignCenter ); + screen->setFrameStyle( QFrame::Box | QFrame::Plain ); + + QLabel* title = new QLabel( base ); + title->setAlignment( Qt::AlignCenter ); + changeFont( title, true, false, false, 5 ); + + QLabel* version = new QLabel( base ); + version->setAlignment( Qt::AlignCenter ); + changeFont( version, false, true, false, 2 ); + + QLabel* copyright = new QLabel( base ); + copyright->setAlignment( Qt::AlignCenter ); + changeFont( copyright, false, false, false, 1 ); + + QLabel* license = new QLabel( base ); + license->setAlignment( Qt::AlignCenter ); + changeFont( license, false, false, false, 1 ); + + screen->setPixmap( resMgr->loadPixmap( "SalomeApp", tr( "ABOUT" ) ) ); + checkLabel( screen ); + + QString titleText = tr( "ABOUT_TITLE" ); + if ( titleText == "ABOUT_TITLE" ) + titleText = defName; + title->setText( titleText ); + checkLabel( title ); + + QString verText = tr( "ABOUT_VERSION" ); + if ( verText.contains( "%1" ) ) + verText = verText.arg( defVer ); + version->setText( verText ); + checkLabel( version ); + + copyright->setText( tr( "ABOUT_COPYRIGHT" ) ); + checkLabel( copyright ); + + license->setText( tr( "ABOUT_LICENSE" ) ); + checkLabel( license ); + + QString capText = tr( "ABOUT_VERSION" ); + if ( capText.contains( "%1" ) ) + capText = capText.arg( defName ); + setCaption( capText ); + + setSizeGripEnabled( false ); +} + +SalomeApp_AboutDlg::~SalomeApp_AboutDlg() +{ +} + +void SalomeApp_AboutDlg::mousePressEvent( QMouseEvent* ) +{ + accept(); +} + +void SalomeApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic, + const bool underline, const int inc ) const +{ + if ( !wid ) + return; + + QFont widFont = wid->font(); + widFont.setBold( bold ); + widFont.setItalic( italic ); + widFont.setUnderline( underline ); + widFont.setPointSize( widFont.pointSize() + inc ); +} + +void SalomeApp_AboutDlg::checkLabel( QLabel* lab ) const +{ + if ( !lab ) + return; + + bool vis = !lab->text().stripWhiteSpace().isEmpty() || + ( lab->pixmap() && !lab->pixmap()->isNull() ); + vis ? lab->show() : lab->hide(); +} diff --git a/src/SalomeApp/SalomeApp_AboutDlg.h b/src/SalomeApp/SalomeApp_AboutDlg.h new file mode 100644 index 000000000..8ad794f1c --- /dev/null +++ b/src/SalomeApp/SalomeApp_AboutDlg.h @@ -0,0 +1,37 @@ +// File: SalomeApp_AboutDlg.h +// Created: 03.06.2005 13:49:25 +// Author: Sergey TELKOV +// Copyright (C) CEA 2005 + +#ifndef SALOMEAPP_ABOUTDLG_H +#define SALOMEAPP_ABOUTDLG_H + +#include "SalomeApp.h" + +#include + +/* + Class: SalomeApp_AboutDlg + Descr: Salome help about dialog +*/ + +class QLabel; + +class SALOMEAPP_EXPORT SalomeApp_AboutDlg : public QtxDialog +{ + Q_OBJECT + +public: + SalomeApp_AboutDlg( const QString&, const QString&, QWidget* = 0 ); + virtual ~SalomeApp_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; +}; + +#endif diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 40f68ee2a..bf2e7a342 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -9,16 +9,18 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Module.h" +#include "SalomeApp_OBFilter.h" +#include "SalomeApp_EventFilter.h" +#include "SalomeApp_WidgetContainer.h" + +#include "SalomeApp_AboutDlg.h" +#include "SalomeApp_ModuleDlg.h" + #include "SalomeApp_GLSelector.h" #include "SalomeApp_OBSelector.h" #include "SalomeApp_OCCSelector.h" #include "SalomeApp_VTKSelector.h" -#include "SalomeApp_EventFilter.h" #include "SalomeApp_SelectionMgr.h" -#include "SalomeApp_EventFilter.h" -#include "SalomeApp_WidgetContainer.h" -#include "SalomeApp_ModuleDlg.h" -#include "SalomeApp_OBFilter.h" #include @@ -54,6 +56,7 @@ #include #include +#include #include #include #include @@ -161,7 +164,40 @@ void SalomeApp_Application::start() QString SalomeApp_Application::applicationName() const { - return "SalomeApp"; + return tr( "APP_NAME" ); +} + +QString SalomeApp_Application::applicationVersion() const +{ + static QString _app_version; + + if ( _app_version.isEmpty() ) + { + QString path( ::getenv( "GUI_ROOT_DIR" ) ); + if ( !path.isEmpty() ) + path += QDir::separator(); + path += QString( "bin/salome/VERSION" ); + + QFile vf( path ); + if ( vf.open( IO_ReadOnly ) ) + { + QString line; + vf.readLine( line, 1024 ); + vf.close(); + + if ( !line.isEmpty() ) + { + while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) + line.remove( line.length() - 1, 1 ); + + int idx = line.findRev( ":" ); + if ( idx != -1 ) + _app_version = line.mid( idx + 1 ).stripWhiteSpace(); + } + } + } + + return _app_version; } CAM_Module* SalomeApp_Application::loadModule( const QString& name ) @@ -470,21 +506,9 @@ void SalomeApp_Application::updateCommandsStatus() //======================================================================= void SalomeApp_Application::onHelpAbout() { - QMessageBox aDlg( desktop(), "AboutDlg" ); - - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QPixmap aPixmap = aResMgr->loadPixmap( "SalomeApp", tr( "ABOUT_ICO" ) ); - - QFontMetrics m( aDlg.font() ); - QImage anImage = aPixmap.convertToImage(); - int w = m.height() * 5; - anImage = anImage.scale( w, w ); - aPixmap.convertFromImage( anImage ); - - aDlg.setCaption( tr( "ABOUT" ) ); - aDlg.setText( tr( "APP_NAME_LONG" ).arg( APP_VERSION ) ); - aDlg.setIconPixmap( aPixmap ); - aDlg.exec(); + SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() ); + dlg->exec(); + delete dlg; } QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const @@ -775,6 +799,7 @@ void SalomeApp_Application::defaultWindows( QMap& aMap ) const { aMap.insert( WT_ObjectBrowser, Qt::DockLeft ); aMap.insert( WT_PyConsole, Qt::DockBottom ); + aMap.insert( WT_LogWindow, Qt::DockBottom ); } void SalomeApp_Application::defaultViewManagers( QStringList& ) const @@ -924,7 +949,6 @@ void SalomeApp_Application::loadWindowsGeometry() if ( !modName.isEmpty() ) section += QString( "." ) + modName; - dockMgr->loadGeometry( resourceMgr(), section, false ); dockMgr->restoreGeometry(); } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 152adac40..10283e970 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -55,6 +55,7 @@ public: virtual ~SalomeApp_Application(); virtual QString applicationName() const; + virtual QString applicationVersion() const; virtual CAM_Module* loadModule( const QString& ); virtual bool activateModule( const QString& ); diff --git a/src/SalomeApp/resources/SalomeApp_images.po b/src/SalomeApp/resources/SalomeApp_images.po index ec8ea5573..5e14f391e 100644 --- a/src/SalomeApp/resources/SalomeApp_images.po +++ b/src/SalomeApp/resources/SalomeApp_images.po @@ -14,7 +14,7 @@ msgstr "" msgid "APP_LOGO_ICO" msgstr "icon_applogo.png" -msgid "ABOUT_ICO" +msgid "ABOUT" msgstr "icon_about.png" msgid "APP_DEFAULT_ICO" @@ -22,4 +22,3 @@ msgstr "icon_default.png" msgid "APP_MODULE_ICO" msgstr "icon_module.png" - diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 4b8df5a01..804fa093e 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -30,6 +30,23 @@ msgstr "&Cancel" //======================================================================================= +msgid "APP_NAME" +msgstr "SALOME" + +msgid "ABOUT_CAPTION" +msgstr "About %1" + +msgid "ABOUT_VERSION" +msgstr "Version %1" + +msgid "ABOUT_COPYRIGHT" +msgstr "Copyright (C) 2003-2005 OPEN CASCADE, EADS/CCR, LIP6,\nCEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS" + +msgid "ABOUT_LICENSE" +msgstr "GNU LGPL" + +//======================================================================================= + msgid "SalomeApp_Application::OBJECT_BROWSER" msgstr "Object Browser" @@ -54,9 +71,6 @@ msgstr "OCC view" msgid "SalomeApp_Application::NEW_WINDOW_3" msgstr "VTK view" -msgid "SalomeApp_Application::APP_NAME" -msgstr "SALOME" - msgid "SalomeApp_Application::ABOUT" msgstr "About" -- 2.39.2