mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
moved the tooltip close logic to basewidget
This commit is contained in:
parent
72ed52c35c
commit
91099c028e
5 changed files with 29 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -82,7 +82,6 @@ ChannelView::ChannelView(BaseWidget *parent)
|
|||
Window *_window = dynamic_cast<Window *>(this->window());
|
||||
|
||||
if (_window) {
|
||||
_window->lostFocus.connect([this] { TooltipWidget::getInstance()->hide(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue