// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// (emit signals when popup menu is pre-activated)
// Currently this support is disabled.
//#define ENABLE_DYNAMIC_MENU
-
+
/*!
Service functions
Level: Internal
/*
bool QtxActionMenuMgr::MenuAction::addTo( QWidget* w )
{
- if ( !w )
+ if ( !w )
return false; // bad widget
if ( !w->inherits( "QPopupMenu" ) && !w->inherits( "QMenuBar" ) )
{
QPopupMenu* pm = (QPopupMenu*)w;
myIds[ w ] = pm->idAt( idx );
- if ( myId != -1 )
+ if ( myId != -1 )
pm->setId( idx, myId );
setPopup( pm, myId != -1 ? myId : myIds[ w ], myPopup );
}
{
QMenuBar* mb = (QMenuBar*)w;
myIds[ w ] = mb->idAt( idx );
- if ( myId != -1 )
+ if ( myId != -1 )
mb->setId( idx, myId );
setPopup( mb, myId != -1 ? myId : myIds[ w ], myPopup );
}
/*
bool QtxActionMenuMgr::MenuAction::removeFrom( QWidget* w )
{
- if ( !w )
+ if ( !w )
return false; // bad widget
if ( !w->inherits( "QPopupMenu" ) && !w->inherits( "QMenuBar" ) )
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param id - identificator of action
\param menus - few names of parent menu items, separated by '|'. It means sequence of menu items,
for example "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param a - action
\param menus - few names of parent menu items, separated by '|'. It means sequence of menu items,
for example "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param id - identificator of action
\param menus - list of names of parent menu items, separated by |. It means sequence of menu items,
for example "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param a - action
\param menus - list of names of parent menu items. It means sequence of menu items,
for example "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param id - identificator of action
\param pId - identificator of action corresponding to parent menu item
\param group - group identificator
}
/*!
- Insert action as children menu item
+ Insert action as children menu item
\param a - action
\param pId - identificator of action corresponding to parent menu item
\param group - group identificator
}
/*!
- Create and insert action as children menu item
+ Create and insert action as children menu item
\return identificator of inserted action
\param title - menu text of action
\param pId - identificator of action corresponding to parent menu item
QAction* ma = new QAction( title, this );
ma->setMenu( new QMenu( myMenu ) );
+
+ connect( ma->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( ma->menu(), SIGNAL( aboutToHide() ), this, SLOT( onAboutToHide() ) );
#ifdef ENABLE_DYNAMIC_MENU
connect( ma->menu(), SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
#endif
}
/*!
- Create and insert action as children menu item
+ Create and insert action as children menu item
\return identificator of inserted action
\param title - menu text of action
\param menus - string list of parents' menu texts, separated by |
}
/*!
- Create and insert action as children menu item
+ Create and insert action as children menu item
\return identificator of inserted action
\param title - menu text of action
\param menus - list of parents menu items
a->setText( title );
}
+void QtxActionMenuMgr::onAboutToShow()
+{
+ QMenu* m = ::qobject_cast<QMenu*>( sender() );
+ if ( m )
+ emit menuAboutToShow( m );
+}
+
+void QtxActionMenuMgr::onAboutToHide()
+{
+ QMenu* m = ::qobject_cast<QMenu*>( sender() );
+ if ( m )
+ emit menuAboutToHide( m );
+}
+
/*!
SLOT: called when corresponding menu is destroyed, clears internal pointer to menu
*/
}
/*!
- Removes excess separators of menu
+ Removes excess separators of menu
\param wid - menu to be processed
*/
void QtxActionMenuMgr::simplifySeparators( QWidget* wid )
}
/*!
- Creates and inserts many menu items
+ Creates and inserts many menu items
\param lst - list of menu texts
\param pId - id of action corresponding to parent menu item
*/
set = QIcon( pix );
QtxAction* newAct = new QtxAction( strValue( attr, tooltip ), set,
- strValue( attr, label ),
+ strValue( attr, label ),
QKeySequence( strValue( attr, accel ) ),
myMgr );
newAct->setToolTip( strValue( attr, tooltip ) );
QString toggleact = strValue( attr, toggle );
newAct->setCheckable( !toggleact.isEmpty() );
newAct->setChecked( toggleact.toLower() == "true" );
-
+
connect( newAct );
int aid = myMgr->registerAction( newAct, actId );
res = myMgr->insert( aid, pId, intValue( attr, group, 0 ), intValue( attr, pos, -1 ) );