From: mnt Date: Sat, 28 Apr 2018 08:46:46 +0000 (+0300) Subject: 0023552: Unable to use the contextual menu of Object Browser window X-Git-Tag: V8_5_0rc2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fvsr%2F23552;p=modules%2Fgui.git 0023552: Unable to use the contextual menu of Object Browser window - Attempt 1: force resizeEvent() from paintEvent for QtxMenu --- diff --git a/src/Qtx/QtxMenu.cxx b/src/Qtx/QtxMenu.cxx index a70f1f392..f3e961d74 100644 --- a/src/Qtx/QtxMenu.cxx +++ b/src/Qtx/QtxMenu.cxx @@ -30,6 +30,7 @@ #include #include #include +#include /*! \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() ); +} diff --git a/src/Qtx/QtxMenu.h b/src/Qtx/QtxMenu.h index 493a348e4..7a15d38ad 100644 --- a/src/Qtx/QtxMenu.h +++ b/src/Qtx/QtxMenu.h @@ -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;