From 0ca4a098e184fcfdd69364e93c264e0336c9d4a0 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 24 Dec 2017 23:56:08 +0100 Subject: [PATCH] Fixed tooltip now closing properly. Fixes #159 --- src/widgets/basewidget.cpp | 9 ++++++++- src/widgets/basewidget.hpp | 3 ++- src/widgets/window.cpp | 14 -------------- src/widgets/window.hpp | 5 ----- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index 69e5e78b7..5dfb5d4a4 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -104,7 +104,14 @@ bool BaseWidget::nativeEvent(const QByteArray &eventType, void *message, long *r } #endif -void BaseWidget::focusOutEvent(QFocusEvent *) +void BaseWidget::changeEvent(QEvent *) +{ + if (this->isWindow) { + TooltipWidget::getInstance()->hide(); + } +} + +void BaseWidget::leaveEvent(QEvent *) { if (this->isWindow) { TooltipWidget::getInstance()->hide(); diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index 98c433bf4..0d400bb18 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -28,7 +28,8 @@ protected: virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; #endif - virtual void focusOutEvent(QFocusEvent *) override; + virtual void changeEvent(QEvent *) override; + virtual void leaveEvent(QEvent *) override; // XXX: Should this be pure virtual? // fourtf: hell no diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 8254b63e2..628d238e7 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -107,20 +107,6 @@ void Window::closeEvent(QCloseEvent *) this->closed(); } -// void Window::changeEvent(QEvent *event) -//{ -// if (!this->isActiveWindow()) { -// this->lostFocus.invoke(); -// } -// BaseWidget::changeEvent(event); -//} - -// void Window::leaveEvent(QEvent *event) -//{ -// this->lostFocus.invoke(); -// BaseWidget::leaveEvent(event); -//} - void Window::refreshTheme() { QPalette palette; diff --git a/src/widgets/window.hpp b/src/widgets/window.hpp index f7902857b..870446295 100644 --- a/src/widgets/window.hpp +++ b/src/widgets/window.hpp @@ -56,14 +56,9 @@ public: boost::signals2::signal closed; - // pajlada::Signals::NoArgSignal lostFocus; - protected: virtual void closeEvent(QCloseEvent *event) override; - // virtual void changeEvent(QEvent *event) override; - // virtual void leaveEvent(QEvent *event) override; - private: float dpi;