Salome HOME
0023552: Unable to use the contextual menu of Object Browser window vsr/23552
authormnt <mnt@opencascade.com>
Sat, 28 Apr 2018 08:46:46 +0000 (11:46 +0300)
committermnt <mnt@opencascade.com>
Sat, 28 Apr 2018 08:47:38 +0000 (11:47 +0300)
- Attempt 1: force resizeEvent() from paintEvent for QtxMenu

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

index a70f1f392f3fa9b8d5c046332441c2b0d3cbfdcd..f3e961d749af51b956e72d50b4358c339fa593f4 100644 (file)
@@ -30,6 +30,7 @@
 #include <QWidgetAction>
 #include <QLinearGradient>
 #include <QAbstractTextDocumentLayout>
+#include <QTimer>
 
 /*!
   \class QtxMenu::Title
@@ -439,3 +440,22 @@ 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 493a348e4bb58981be64a40718785d6587b8ff7d..7a15d38ad958fa8585d2c6c2f8986ef489457493 100644 (file)
@@ -65,11 +65,17 @@ 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;