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

Correct for Maximized window

This commit is contained in:
PKEv 2015-03-19 22:24:06 +03:00
parent e3946b4435
commit e940459596
2 changed files with 32 additions and 2 deletions

View File

@ -84,6 +84,7 @@ Widget::Widget(QWidget *parent)
eventFlag(false),
eventIcon(false)
{
installEventFilter(this);
translator = new QTranslator;
setTranslation();
}
@ -223,6 +224,23 @@ void Widget::setTranslation()
QCoreApplication::installTranslator(translator);
}
bool Widget::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::WindowStateChange && obj != NULL)
{
QWindowStateChangeEvent * ce = static_cast<QWindowStateChangeEvent*>(event);
if (windowState() & Qt::WindowMinimized)
{
if (ce->oldState() & Qt::WindowMaximized)
wasMaximized = true;
else
wasMaximized = false;
}
}
event->accept();
return false;
}
void Widget::updateIcons()
{
QString status;
@ -459,16 +477,23 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
{
show();
activateWindow();
if (wasMaximized)
showMaximized();
else
showNormal();
}
else if (isMinimized())
{
forceShow();
activateWindow();
if (wasMaximized)
showMaximized();
else
showNormal();
}
else
{
wasMaximized = isMaximized();
if (Settings::getInstance().getMinimizeToTray())
hide();
else
@ -479,6 +504,7 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
break;
}
case QSystemTrayIcon::MiddleClick:
wasMaximized = isMaximized();
if (Settings::getInstance().getMinimizeToTray())
hide();
else

View File

@ -51,6 +51,9 @@ class Widget : public QMainWindow
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event);
public:
explicit Widget(QWidget *parent = 0);
void init();
@ -176,6 +179,7 @@ private:
QRegExp nameMention, sanitizedNameMention;
bool eventFlag;
bool eventIcon;
bool wasMaximized = false;
};
bool toxActivateEventHandler(const QByteArray& data);