From 00fd0ed41018ddf2cbb9d6bb0d4f6619889fc9e4 Mon Sep 17 00:00:00 2001 From: mnt Date: Thu, 10 May 2018 11:22:35 +0300 Subject: [PATCH] 0023552: Unable to use the contextual menu of Object Browser window - Attempt 2: re-implement simplifySeparators() function --- src/Qtx/Qtx.cxx | 65 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 0fe626c72..61d36d7c4 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -276,34 +276,53 @@ void Qtx::simplifySeparators( QWidget* wid, const bool recursive ) if ( !wid ) return; - QList items = wid->actions(); - if ( items.isEmpty() ) - return; - - bool action = false; - for ( int i = 0; i < items.count(); i++ ) + if ( wid->inherits( "QMenu") || wid->inherits( "QMenuBar") ) { - QAction* a = items[i]; - if ( a->isSeparator() ) { - a->setVisible(action); - action = false; - } - else if ( a->isVisible() ) { - action = true; - if ( recursive && a->menu() ) - simplifySeparators( a->menu(), recursive ); + if ( qobject_cast( wid ) ) + qobject_cast( wid )->setSeparatorsCollapsible( true ); + if ( recursive ) + { + foreach ( QAction* action, wid->actions() ) + { + if ( action->menu() ) + simplifySeparators( action->menu(), recursive ); + } } } + else + { + QList actions = wid->actions(); + if ( actions.isEmpty() ) + return; - action = false; - for ( int i = items.count() - 1; i > 0; i-- ) { - QAction* a = items[i]; - if ( a->isSeparator() ) { - a->setVisible(action); - action = false; + bool is_action = false; + for ( int i = 0; i < actions.count(); i++ ) + { + QAction* action = actions[i]; + if ( action->isSeparator() ) + { + action->setVisible( is_action ); + is_action = false; + } + else if ( action->isVisible() ) + { + is_action = true; + } + } + is_action = false; + for ( int i = actions.count() - 1; i > 0; i-- ) + { + QAction* action = actions[i]; + if ( action->isSeparator() ) + { + action->setVisible( is_action ); + is_action = false; + } + else if ( action->isVisible() ) + { + is_action = true; + } } - else if ( a->isVisible() ) - action = true; } } -- 2.39.2