1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(widget): Added saving window state before closing

It's needed if user setup `Close to tray`
Fix #3397.
This commit is contained in:
Diadlo 2016-06-29 13:28:51 +03:00
parent 2c49ada955
commit bfb5dae6fa
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -411,21 +411,29 @@ void Widget::init()
bool Widget::eventFilter(QObject *obj, QEvent *event) bool Widget::eventFilter(QObject *obj, QEvent *event)
{ {
if (event->type() == QEvent::WindowStateChange && obj != NULL) QWindowStateChangeEvent *ce = nullptr;
Qt::WindowStates state = windowState();
switch (event->type())
{ {
QWindowStateChangeEvent * ce = static_cast<QWindowStateChangeEvent*>(event); case QEvent::Close:
if (windowState() & Qt::WindowMinimized) // It's needed if user enable `Close to tray`
{ wasMaximized = state & Qt::WindowMaximized;
if (ce->oldState() & Qt::WindowMaximized) break;
wasMaximized = true;
else case QEvent::WindowStateChange:
wasMaximized = false; ce = static_cast<QWindowStateChangeEvent*>(event);
} if (state & Qt::WindowMinimized && obj)
wasMaximized = ce->oldState() & Qt::WindowMaximized;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
emit windowStateChanged(windowState()); emit windowStateChanged(windowState());
#endif #endif
break;
default:
break;
} }
return false; return false;
} }