From: san Date: Mon, 25 Oct 2010 08:26:23 +0000 (+0000) Subject: Contribution from KALLISTO: X-Git-Tag: V5_1_10~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b3e08ccf4438969f668509d915801711981a8f5d;p=modules%2Fgui.git Contribution from KALLISTO: Virtual initialize() method added to application classes in order to enable customization of base app behavior in derived classes. Example: access from modules auto-loaded by CAM_Application to standard GUI actions created by STD_Application. It is no longer necessary to redefine start() method, redefining initialize() is a prefereed way to customize application start-up. --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 555cdd9f8..2a150abcc 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -91,18 +91,18 @@ CAM_Application::~CAM_Application() } /*! - \brief Start an application. + \brief Initializes an application. Load all modules, if "auto loading" flag has been set to \c true. \sa CAM_Application() */ -void CAM_Application::start() +void CAM_Application::initialize() { + STD_Application::initialize(); + if ( myAutoLoad ) loadModules(); - - STD_Application::start(); } /*! diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index e04876078..3313c5a4d 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -45,8 +45,6 @@ public: CAM_Application( const bool = true ); virtual ~CAM_Application(); - virtual void start(); - CAM_Module* activeModule() const; CAM_Module* module( const QString& ) const; @@ -70,6 +68,7 @@ public: virtual void createEmptyStudy(); protected: + virtual void initialize(); virtual SUIT_Study* createNewStudy(); virtual void updateCommandsStatus(); diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 645206233..1b3212088 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -78,9 +78,11 @@ QString STD_Application::applicationName() const return QString( "StdApplication" ); } -/*!Start STD_Application*/ -void STD_Application::start() +/*!Prepare STD_Application*/ +void STD_Application::initialize() { + SUIT_Application::initialize(); + createActions(); updateDesktopTitle(); @@ -88,7 +90,15 @@ void STD_Application::start() setEditEnabled( myEditEnabled ); loadPreferences(); +} +/*!Start STD_Application*/ +void STD_Application::start() +{ + // san: Need this simple implementation, as some applications + // call STD_Application::start() explicitly + // so we need to provide at least some implementation at this level + // to avoid link errors SUIT_Application::start(); } diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 5c12b4b65..3db33af3f 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -141,6 +141,7 @@ protected: enum { CloseCancel, CloseSave, CloseDiscard }; protected: + virtual void initialize(); virtual void createActions(); virtual void updateCommandsStatus(); diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index ead59e4c4..c9d410ac1 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -117,10 +117,19 @@ QString SUIT_Application::applicationVersion() const */ void SUIT_Application::start() { + initialize(); + if ( desktop() ) desktop()->show(); } +/*! + Prepares the contents of the application's main widget, does nothing by default. +*/ +void SUIT_Application::initialize() +{ +} + /*! Opens document into active Study. If Study is empty - creates it. \param theFileName - name of document file diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index f20dc5633..6fb1b8917 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -124,6 +124,9 @@ protected: //! Creates a new Study instance. Must be redefined in new application according to its Study type. virtual SUIT_Study* createNewStudy(); virtual void setActiveStudy( SUIT_Study* ); + + //! Prepares the contents of the application's main widget, does nothing by default. + virtual void initialize(); /** @name Create tool functions*/ //@{ int createTool( const QString& );