moved the tooltip close logic to basewidget

This commit is contained in:
fourtf 2017-12-24 16:01:01 +01:00
parent 72ed52c35c
commit 91099c028e
5 changed files with 29 additions and 17 deletions

View file

@ -1,6 +1,7 @@
#include "widgets/basewidget.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "widgets/tooltipwidget.hpp"
#include <QDebug>
#include <QLayout>
@ -61,6 +62,8 @@ void BaseWidget::init()
void BaseWidget::initAsWindow()
{
this->isWindow = true;
#ifdef USEWINSDK
auto dpi = util::getWindowDpi(this->winId());
@ -101,5 +104,11 @@ bool BaseWidget::nativeEvent(const QByteArray &eventType, void *message, long *r
}
#endif
void BaseWidget::focusOutEvent(QFocusEvent *)
{
if (this->isWindow) {
TooltipWidget::getInstance()->hide();
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -28,13 +28,17 @@ protected:
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
virtual void focusOutEvent(QFocusEvent *) override;
// XXX: Should this be pure virtual?
// fourtf: hell no
virtual void dpiMultiplierChanged(float /*oldDpi*/, float /*newDpi*/)
{
}
void initAsWindow();
private:
bool isWindow = false;
float dpiMultiplier = 1.f;
void init();

View file

@ -82,7 +82,6 @@ ChannelView::ChannelView(BaseWidget *parent)
Window *_window = dynamic_cast<Window *>(this->window());
if (_window) {
_window->lostFocus.connect([this] { TooltipWidget::getInstance()->hide(); });
}
}

View file

@ -107,20 +107,19 @@ void Window::closeEvent(QCloseEvent *)
this->closed();
}
void Window::changeEvent(QEvent *event)
{
if(!this->isActiveWindow())
{
this->lostFocus.invoke();
}
BaseWidget::changeEvent(event);
}
// 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::leaveEvent(QEvent *event)
//{
// this->lostFocus.invoke();
// BaseWidget::leaveEvent(event);
//}
void Window::refreshTheme()
{

View file

@ -56,13 +56,14 @@ public:
boost::signals2::signal<void()> closed;
pajlada::Signals::NoArgSignal lostFocus;
// pajlada::Signals::NoArgSignal lostFocus;
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent *event) override;
virtual void leaveEvent(QEvent *event) override;
// virtual void changeEvent(QEvent *event) override;
// virtual void leaveEvent(QEvent *event) override;
private:
float dpi;