Salome HOME
0023552: Unable to use the contextual menu of Object Browser window V8_5_BR V8_5_0 V8_5_0rc2
authormnt <mnt@opencascade.com>
Thu, 10 May 2018 08:22:35 +0000 (11:22 +0300)
committervsr <vsr@opencascade.com>
Mon, 14 May 2018 16:32:43 +0000 (19:32 +0300)
- Fix regression appearing with Qt 5.9 when dynamically changing visibility of separators in popup menus

src/Qtx/Qtx.cxx
src/Qtx/QtxMenu.cxx
src/Qtx/QtxMenu.h

index 0fe626c72be3b9b63541fdce106925ac203f2d99..61d36d7c4cd36f0fe1b4dd102f6e4bafd6db364e 100755 (executable)
@@ -276,34 +276,53 @@ void Qtx::simplifySeparators( QWidget* wid, const bool recursive )
   if ( !wid )
     return;
 
-  QList<QAction*> 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<QMenu*>( wid ) )
+      qobject_cast<QMenu*>( wid )->setSeparatorsCollapsible( true );
+    if ( recursive )
+    {
+      foreach ( QAction* action, wid->actions() )
+      {
+       if ( action->menu() )
+         simplifySeparators( action->menu(), recursive );
+      }
     }
   }
+  else
+  {
+    QList<QAction*> 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;
   }
 }
 
index f3e961d749af51b956e72d50b4358c339fa593f4..a70f1f392f3fa9b8d5c046332441c2b0d3cbfdcd 100644 (file)
@@ -30,7 +30,6 @@
 #include <QWidgetAction>
 #include <QLinearGradient>
 #include <QAbstractTextDocumentLayout>
-#include <QTimer>
 
 /*!
   \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() );
-}
index 7a15d38ad958fa8585d2c6c2f8986ef489457493..493a348e4bb58981be64a40718785d6587b8ff7d 100644 (file)
@@ -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;