MenuNode();
MenuNode( MenuNode*, const int, const int, const int );
~MenuNode();
-
+
MenuNode* parent; //!< parent menu node
int id; //!< menu nodeID
- int idx; //!< menu node index
+ int idx; //!< menu node index
int group; //!< menu group ID
bool visible; //!< visibility status
int emptyEnabled; //!< enable empty menu flag
\param p parent main window
*/
QtxActionMenuMgr::QtxActionMenuMgr( QMainWindow* p )
-: QtxActionMgr( p ),
+: QtxActionMgr( p ),
myRoot( new MenuNode() ),
myMenu( p ? p->menuBar() : 0 ),
myCollapse( false )
\param p parent object
*/
QtxActionMenuMgr::QtxActionMenuMgr( QWidget* mw, QObject* p )
-: QtxActionMgr( p ),
+: QtxActionMgr( p ),
myRoot( new MenuNode() ),
myMenu( mw ),
myCollapse( false )
/*!
\brief Insert action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu name: it can be a sequence of strings, separated by '|' symbol.
For example, "File|Edit" means \c File->Edit submenu.
If submenu doesn't exist, it will be created.
/*!
\brief Insert action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu name: it can be a sequence of strings, separated by '|' symbol.
For example, "File|Edit" means \c File->Edit submenu.
If submenu doesn't exist, it will be created.
/*!
\brief Insert action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu names list.
For example, string list consisting from two items "File" and "Edit"
means \c File->Edit submenu.
/*!
\brief Insert action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu names list.
For example, string list consisting from two items "File" and "Edit"
means \c File->Edit submenu.
/*!
\brief Create and insert menu item action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu name: it can be a sequence of strings, separated by '|' symbol.
For example, "File|Edit" means \c File->Edit submenu.
If submenu doesn't exist, it will be created.
/*!
\brief Create and insert menu item action to the menu.
- Insert an action to the named menu. The \a menus parameter represents
+ Insert an action to the named menu. The \a menus parameter represents
the menu names list.
For example, string list consisting from two items "File" and "Edit"
means \c File->Edit submenu.
/*!
\brief Called when the submenu is about to show.
-
+
Emits the signal menuAboutToShow(QMenu*).
*/
void QtxActionMenuMgr::onAboutToShow()
/*!
\brief Called when the submenu is about to hide.
-
+
Emits the signal menuAboutToHide(QMenu*).
*/
void QtxActionMenuMgr::onAboutToHide()
\brief Called when the corresponding menu object is destroyed.
Clears internal pointer to menu to disable crashes.
-
+
\param obj (menu) object being destroyed
*/
void QtxActionMenuMgr::onDestroyed( QObject* obj )
foreach( a, formapit.value() )
mw->insertAction( preva, a );
}
-
+
// remove extra separators
simplifySeparators( mw );
/*!
\brief Internal update.
-
+
Customizes the menu update processing.
*/
void QtxActionMenuMgr::internalUpdate()
MenuNode* node = find( id );
if ( node && menuAction( id ) )
return node->emptyEnabled > 0;
-
+
return false;
}
}
}
+/*!
+ \brief Returns the priority for specified menu.
+ \param id - menu id.
+*/
+int QtxActionMenuMgr::menuPriority( const int id ) const
+{
+ return QtxMenu::actionPriority( menuAction( id ) );
+}
+
+/*!
+ \brief Sets the priority for specified menu. Menu with negative value of priority
+ will be always displayed in menu (permanent menus).
+ \param id - menu id.
+ \param p - priority value.
+*/
+void QtxActionMenuMgr::setMenuPriority( const int id, const int p )
+{
+ return QtxMenu::setActionPriority( menuAction( id ), p );
+}
+
/*!
\brief Perform delayed menu update.
\param id menu item ID
{
// Warning: For correct updating it is necessary to update the most enclosed submenu in first turn
// because not updated empty submenu will be skipped. Now the submenus are iterated in
- // ascending order according to their identifiers. For a submenus with automatically generated
+ // ascending order according to their identifiers. For a submenus with automatically generated
// identifiers this will work correctly since the uppermost submenus have the biggest number
// (identifiers are generated by decrementing 1 starting from -1). In general, if any submenu
// have positive identifiers this method might not work correctly. In this case it would be
- // necessary to improve this method and to add preliminary sorting a submenus by depth of an
+ // necessary to improve this method and to add preliminary sorting a submenus by depth of an
// enclosure.
for ( QMap<int, bool>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
{
pix.setMask( bm );
}
-
+
if ( !pix.mask().isNull() )
setMask( pix.mask() );
*/
: QMenu( parent ),
myTitleMode( TitleOff ),
myTitleAlign( Qt::AlignVCenter | Qt::AlignLeft ),
- myLimit( 7 ),
- myLimitMode( LimitAuto ),
+ myLimit( 3 ),
+ myLimitMode( LimitFrequent ),
+ myHighlightMode( HighlightFrequent ),
myExpandAction( 0 )
{
myTitleAction = new TitleMgr( this );
myLimitMode = mode;
}
+/*!
+ \brief Returns highlight mode.
+*/
+QtxMenu::HighlightMode QtxMenu::highlightMode() const
+{
+ return myHighlightMode;
+}
+
+/*!
+ \brief Sets highlight items mode. If mode is 'HighlightPermanent' then permanently visible
+ menu items will be highlighted. If mode is 'HighlightFrequent' then menu will highlight
+ frequently used menu items only. If mode is 'HighlightNone' then menu doesn't highlight any items.
+ \param mode - setted highlight mode.
+*/
+void QtxMenu::setHighlightMode( HighlightMode mode )
+{
+ myHighlightMode = mode;
+}
+
/*!
\brief Returns 'true' if the menu in expanded (full) state.
*/
if ( _actionPriority.contains( a ) )
p = _actionPriority[a];
- if ( a->menu() )
+ if ( p >= 0 && a->menu() )
{
QList<QAction*> lst = a->menu()->actions();
for ( QList<QAction*>::iterator it = lst.begin(); it != lst.end(); ++it )
if ( menuCollapsible() ) {
QPainter::restoreRedirected( this );
- if ( isTopLevelMenu() ) {
+ HighlightMode hm = highlightMode();
+ if ( isTopLevelMenu() && hm != HighlightNone ) {
QRgb bg = palette().color( QPalette::Light ).rgb();
QImage img = pix.toImage();
QList<QAction*> lst = actions();
QSet<QAction*> visible = collapsedActions();
-
+
for ( QList<QAction*>::iterator it = lst.begin(); it != lst.end(); ++it ) {
QAction* a = *it;
QRect r = actionGeometry( a );
int x, y, w, h;
r.getRect( &x, &y, &w, &h );
- if ( a == myExpandAction || a == myTitleAction || !visible.contains( a ) || a == activeAction() )
+ if ( a == myExpandAction || a == myTitleAction || a == activeAction() )
+ continue;
+
+ if ( ( hm == HighlightPermanent ) != visible.contains( a ) )
continue;
QRgb rc = img.pixel( x, y );