From: Viktor UZLOV Date: Fri, 20 Nov 2020 11:53:08 +0000 (+0300) Subject: Add InfoPanel to SalomePyQt X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0944c176efdd1ff94df2b217df1e0e167f8a07c;p=modules%2Fgui.git Add InfoPanel to SalomePyQt --- diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 04b9bece8..1f3c74c80 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -56,6 +56,7 @@ #include "QtxActionMenuMgr.h" #include "QtxWorkstack.h" #include "QtxTreeView.h" +#include "QtxInfoPanel.h" #include "SALOME_Event.h" #include "STD_TabDesktop.h" #include "SUIT_DataBrowser.h" @@ -2888,6 +2889,256 @@ void SalomePyQt::message( const QString& msg, bool addSeparator ) ProcessVoidEvent( new TEvent( msg, addSeparator ) ); } +/*! + \brief Set the title in InfoPanel + \param title title text +*/ +void SalomePyQt::infoSetTitle( const QString& title ) +{ + class TEvent: public SALOME_Event + { + QString myTitle; + public: + TEvent( const QString& title ) + : myTitle( title ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + ip->setTitle( myTitle ); + } + } + }; + ProcessVoidEvent( new TEvent( title ) ); +} + +/*! + \fn int SalomePyQt::addLabel( const QString& text, const int groupId ); + \brief Add QLabel in the InfoPanel. + \param text label text + \param groupId conteiner identifier + \return widget identifier +*/ + +class TInfoAddLabel2paramEvent: public SALOME_Event +{ +public: + typedef int TResult; + TResult myResult; + QString myText; + int myGroupId; + TInfoAddLabel2paramEvent( const QString& text, const int groupId ) + : myText( text ), myGroupId( groupId ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + myResult = ip->addLabel( myText, myGroupId ); + } + } +}; +int SalomePyQt::infoAddLabel( const QString& text, const int groupId ) +{ + return ProcessEvent( new TInfoAddLabel2paramEvent( text, groupId ) ); +} + +/*! + \fn int SalomePyQt::addLabel( const QString& text, Qt::Alignment alignment, const int groupId ); + \brief Add QLabel in the InfoPanel. + \param text label text + \param alignment label align + \param groupId conteiner identifier + \return widget identifier +*/ + +class TInfoAddLabel3paramEvent: public SALOME_Event +{ +public: + typedef int TResult; + TResult myResult; + QString myText; + Qt::Alignment myAlignment; + int myGroupId; + TInfoAddLabel3paramEvent( const QString& text, Qt::Alignment alignment, const int groupId ) + : myText( text ), myAlignment( alignment ), myGroupId( groupId ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + myResult = ip->addLabel( myText, myAlignment, myGroupId ); + } + } +}; +int SalomePyQt::infoAddLabel( const QString& text, Qt::Alignment alignment, const int groupId ) +{ + return ProcessEvent( new TInfoAddLabel3paramEvent( text, alignment, groupId ) ); +} + +/*! + \fn int SalomePyQt::addAction( QAction* action, const int groupId ); + \brief Add QAction in the InfoPanel. + \param action object to add + \param groupId conteiner identifier + \return widget identifier +*/ + +class TInfoAddActionEvent: public SALOME_Event +{ +public: + typedef int TResult; + TResult myResult; + QAction* myAction; + int myGroupId; + TInfoAddActionEvent( QAction* action, const int groupId ) + : myAction( action ), myGroupId( groupId ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + myResult = ip->addAction( myAction, myGroupId ); + } + } +}; +int SalomePyQt::infoAddAction( QAction* action, const int groupId ) +{ + return ProcessEvent( new TInfoAddActionEvent( action, groupId ) ); +} + +/*! + \fn int SalomePyQt::addGroup( const QString& text, const int groupId ); + \brief Add container in the InfoPanel. + \param text title for container + \param groupId conteiner identifier + \return widget identifier +*/ + +class TInfoAddGroupEvent: public SALOME_Event +{ +public: + typedef int TResult; + TResult myResult; + QString myText; + int myGroupId; + TInfoAddGroupEvent( const QString& text, const int groupId ) + : myText( text ), myGroupId( groupId ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + myResult = ip->addGroup( myText, myGroupId ); + } + } +}; +int SalomePyQt::infoAddGroup( const QString& text, const int groupId ) +{ + return ProcessEvent( new TInfoAddGroupEvent( text, groupId ) ); +} + +/*! + \brief Remove widget from the InfoPanel + \param id widget identifier +*/ +void SalomePyQt::infoRemove( const int id ) +{ + class TEvent: public SALOME_Event + { + int myId; + public: + TEvent( const int id ) + : myId( id ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + ip->remove( myId ); + } + } + }; + ProcessVoidEvent( new TEvent( id ) ); +} + +/*! + \brief Clear container in the InfoPanel + \param id container identifier +*/ +void SalomePyQt::infoClear( const int id ) +{ + class TEvent: public SALOME_Event + { + int myId; + public: + TEvent( const int id ) + : myId( id ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + ip->clear( myId ); + } + } + }; + ProcessVoidEvent( new TEvent( id ) ); +} + +/*! + \brief Set widget visibility in the InfoPanel + \param id widget identifier + \param visialbe state of visibility +*/ +void SalomePyQt::infoSetVisible( const int id, bool visible ) +{ + class TEvent: public SALOME_Event + { + int myId; + bool myVisible; + public: + TEvent( const int id, bool visible ) + : myId( id ), myVisible( visible ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + ip->setVisible( myId, myVisible ); + } + } + }; + ProcessVoidEvent( new TEvent( id, visible ) ); +} + +/*! + \brief Set widget enable in the InfoPanel + \param id widget identifier + \param enebled state of enable +*/ +void SalomePyQt::infoSetEnabled( const int id, bool enabled ) +{ + class TEvent: public SALOME_Event + { + int myId; + bool myEnabled; + public: + TEvent( const int id, bool enabled ) + : myId( id ), myEnabled( enabled ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + QtxInfoPanel* ip = anApp->infoPanel(); + if ( ip ) + ip->setEnabled( myId, myEnabled ); + } + } + }; + ProcessVoidEvent( new TEvent( id, enabled ) ); +} + /*! \brief Remove all the messages from the Log messages output window. */ diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 34089b95b..82ecb8173 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -89,6 +89,7 @@ enum { WT_ObjectBrowser = LightApp_Application::WT_ObjectBrowser, WT_PyConsole = LightApp_Application::WT_PyConsole, WT_LogWindow = LightApp_Application::WT_LogWindow, + WT_InfoPanel = LightApp_Application::WT_InfoPanel, #ifndef GUI_DISABLE_CORBA WT_NoteBook = SalomeApp_Application::WT_NoteBook, WT_User = SalomeApp_Application::WT_User @@ -199,6 +200,18 @@ public: static void registerModule( const QString& ); static void updateObjBrowser(); + static void infoSetTitle( const QString& ); + static int infoAddLabel( const QString&, const int = -1 ); + static int infoAddLabel( const QString&, Qt::Alignment, const int = -1 ); + static int infoAddAction( QAction*, const int = -1 ); + static int infoAddGroup( const QString&, const int = -1 ); + + static void infoRemove( const int ); + static void infoClear( const int = -1 ); + + static void infoSetVisible( const int, bool ); + static void infoSetEnabled( const int, bool ); + static void putInfo( const QString&, const int = 0 ); static int showNotification( const QString&, const QString&, const int = -1 ); static void hideNotification( const QString& ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index ed20aafac..bc30e3450 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -79,6 +79,7 @@ enum WindowType { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, + WT_InfoPanel, %If (ENABLE_CORBA) WT_NoteBook, %End @@ -310,6 +311,18 @@ public: static void registerModule( const QString& ) /ReleaseGIL/ ; static void updateObjBrowser() /ReleaseGIL/ ; + static void infoSetTitle( const QString& ) /ReleaseGIL/ ; + static int infoAddLabel( const QString&, const int = -1 ) /ReleaseGIL/ ; + static int infoAddLabel( const QString&, Qt::Alignment, const int = -1 ) /ReleaseGIL/ ; + static int infoAddAction( QAction*, const int = -1 ) /ReleaseGIL/ ; + static int infoAddGroup( const QString&, const int = -1 ) /ReleaseGIL/ ; + + static void infoRemove( const int ) /ReleaseGIL/ ; + static void infoClear( const int = -1 ) /ReleaseGIL/ ; + + static void infoSetVisible( const int, bool ) /ReleaseGIL/ ; + static void infoSetEnabled( const int, bool ) /ReleaseGIL/ ; + static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ; static int showNotification( const QString&, const QString&, const int = -1 ) /ReleaseGIL/ ; static void hideNotification( const QString& ) /ReleaseGIL/ ;