From: mnt Date: Thu, 10 May 2018 08:22:35 +0000 (+0300) Subject: 0023552: Unable to use the contextual menu of Object Browser window X-Git-Tag: V8_5_0rc2^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f72fb2160fa146cd424b31b5dc3c8f6b691ef3c;p=modules%2Fgui.git 0023552: Unable to use the contextual menu of Object Browser window - Fix regression appearing with Qt 5.9 when dynamically changing visibility of separators in popup menus --- 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; } } diff --git a/src/Qtx/QtxMenu.cxx b/src/Qtx/QtxMenu.cxx index f3e961d74..a70f1f392 100644 --- a/src/Qtx/QtxMenu.cxx +++ b/src/Qtx/QtxMenu.cxx @@ -30,7 +30,6 @@ #include #include #include -#include /*! \class QtxMenu::Title @@ -440,22 +439,3 @@ void QtxMenu::updateTitle() removeTitle(); insertTitle(); } - -/*! - \brief Paint event -*/ -void QtxMenu::paintEvent( QPaintEvent* e ) -{ - // Force menu resizing, see resizeAfterRepaint(). - QMenu::paintEvent(e); - QTimer::singleShot( 0, this, SLOT( resizeAfterRepaint() ) ); -} - -void QtxMenu::resizeAfterRepaint() -{ - // this slot is used as a workaround about annoying problem - // on some X window System desktops like KDE 5, Unity and other - // that causes setting incorrect menu's geometry - // after it appears on a screen. - resize( sizeHint() ); -} diff --git a/src/Qtx/QtxMenu.h b/src/Qtx/QtxMenu.h index 7a15d38ad..493a348e4 100644 --- a/src/Qtx/QtxMenu.h +++ b/src/Qtx/QtxMenu.h @@ -65,17 +65,11 @@ public: public slots: virtual void setVisible( bool ); -protected: - virtual void paintEvent( QPaintEvent* ); - private: void updateTitle(); void insertTitle(); void removeTitle(); -private slots: - void resizeAfterRepaint(); - private: TitleMode myMode; Title* myTitle;