From 8561670eeab4ff03dbb6f46c976c99d4d65cf7ed Mon Sep 17 00:00:00 2001 From: mnt Date: Sat, 28 Apr 2018 11:46:46 +0300 Subject: [PATCH] 0023552: Unable to use the contextual menu of Object Browser window - Attempt 1: force resizeEvent() from paintEvent for QtxMenu --- src/Qtx/QtxMenu.cxx | 20 ++++++++++++++++++++ src/Qtx/QtxMenu.h | 6 ++++++ 2 files changed, 26 insertions(+) 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; -- 2.39.2