3 #include <SUIT_MessageBox.h>
4 #include <SUIT_ResourceMgr.h>
5 #include <SalomeApp_Application.h>
7 #include <SALOME_LifeCycleCORBA.hxx>
10 #include <qinputdialog.h>
15 HELLOGUI::HELLOGUI() :
16 SalomeApp_Module( "HELLO" ) // default name
20 // Gets an reference to the module's engine
21 HELLO_ORB::HELLO_Gen_ptr HELLOGUI::InitHELLOGen( SalomeApp_Application* app )
23 Engines::Component_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HELLO" );
24 HELLO_ORB::HELLO_Gen_ptr clr = HELLO_ORB::HELLO_Gen::_narrow(comp);
25 ASSERT(!CORBA::is_nil(clr));
29 // Module's initialization
30 void HELLOGUI::initialize( CAM_Application* app )
33 SalomeApp_Module::initialize( app );
35 InitHELLOGen( dynamic_cast<SalomeApp_Application*>( app ) );
37 QWidget* aParent = app->desktop();
38 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
41 createAction( 190, tr( "TLT_MY_NEW_ITEM" ), QIconSet(), tr( "MEN_MY_NEW_ITEM" ), tr( "STS_MY_NEW_ITEM" ), 0, aParent, false,
42 this, SLOT( OnMyNewItem() ) );
43 QPixmap aPixmap = aResourceMgr->loadPixmap( "HELLO",tr( "ICON_GET_BANNER" ) );
44 createAction( 901, tr( "TLT_GET_BANNER" ), QIconSet( aPixmap ), tr( "MEN_GET_BANNER" ), tr( "STS_GET_BANNER" ), 0, aParent, false,
45 this, SLOT( OnGetBanner() ) );
49 aMenuId = createMenu( tr( "MEN_FILE" ), -1, -1 );
50 createMenu( separator(), aMenuId, -1, 10 );
51 aMenuId = createMenu( tr( "MEN_FILE_HELLO" ), aMenuId, -1, 10 );
52 createMenu( 190, aMenuId );
54 aMenuId = createMenu( tr( "MEN_HELLO" ), -1, -1, 30 );
55 createMenu( 901, aMenuId, 10 );
58 int aToolId = createTool ( tr( "TOOL_HELLO" ) );
59 createTool( 901, aToolId );
62 // Module's engine IOR
63 QString HELLOGUI::engineIOR() const
65 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHELLOGen( getApp() ) );
66 return QString( anIOR.in() );
69 // Module's activation
70 bool HELLOGUI::activateModule( SUIT_Study* theStudy )
72 bool bOk = SalomeApp_Module::activateModule( theStudy );
80 // Module's deactivation
81 bool HELLOGUI::deactivateModule( SUIT_Study* theStudy )
83 setMenuShown( false );
84 setToolShown( false );
86 return SalomeApp_Module::deactivateModule( theStudy );
90 void HELLOGUI::windows( QMap<int, int>& theMap ) const
93 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
94 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
98 void HELLOGUI::OnMyNewItem()
100 SUIT_MessageBox::warn1( getApp()->desktop(),tr( "INF_HELLO_BANNER" ), tr( "INF_HELLO_MENU" ), tr( "BUT_OK" ) );
104 void HELLOGUI::OnGetBanner()
106 // Dialog to get the Name
108 QString myName = QInputDialog::getText( tr( "QUE_HELLO_LABEL" ), tr( "QUE_HELLO_NAME" ),
109 QLineEdit::Normal, QString::null, &ok );
111 if ( ok && !myName.isEmpty()) // if we got a name, get a HELLO component and ask for makeBanner
113 HELLO_ORB::HELLO_Gen_ptr hellogen = HELLOGUI::InitHELLOGen( getApp() );
114 QString banner = hellogen->makeBanner( myName );
115 SUIT_MessageBox::info1( getApp()->desktop(), tr( "INF_HELLO_BANNER" ), banner, tr( "BUT_OK" ) );
121 CAM_Module* createModule()
123 return new HELLOGUI();