more performance improvements
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Syping 2020-08-24 17:44:32 +02:00
parent 3c124f9f27
commit 1038f000f7

View file

@ -1626,7 +1626,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
contextMenuOpened = true; contextMenuOpened = true;
contextMenu.exec(ev->globalPos()); contextMenu.exec(ev->globalPos());
contextMenuOpened = false; contextMenuOpened = false;
hoverProfileWidgetCheck(); QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
} }
void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev) void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
@ -1659,7 +1659,7 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
contextMenuOpened = true; contextMenuOpened = true;
contextMenu.exec(ev->globalPos()); contextMenu.exec(ev->globalPos());
contextMenuOpened = false; contextMenuOpened = false;
hoverProfileWidgetCheck(); QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
} }
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData) void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
@ -1690,6 +1690,7 @@ void ProfileInterface::retranslateUi()
bool ProfileInterface::eventFilter(QObject *watched, QEvent *event) bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
{ {
qDebug() << "event filter" << event;
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress)
{ {
if (isProfileLoaded) if (isProfileLoaded)
@ -1780,19 +1781,27 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
return true; return true;
} }
} }
#ifdef GTA5SYNC_WIN
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::WindowActivate) else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::WindowActivate)
#else
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
#endif
{ {
if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded) if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded)
{ {
ProfileWidget *pWidget = nullptr; ProfileWidget *pWidget = nullptr;
for (ProfileWidget *widget : widgets.keys()) QMap<ProfileWidget*, QString>::const_iterator it = widgets.constBegin();
QMap<ProfileWidget*, QString>::const_iterator end = widgets.constEnd();
while (it != end)
{ {
ProfileWidget *widget = it.key();
QPoint mousePos = widget->mapFromGlobal(QCursor::pos()); QPoint mousePos = widget->mapFromGlobal(QCursor::pos());
if (widget->rect().contains(mousePos)) if (widget->rect().contains(mousePos))
{ {
pWidget = widget; pWidget = widget;
break; break;
} }
it++;
} }
if (pWidget != nullptr) if (pWidget != nullptr)
{ {
@ -1826,7 +1835,7 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
} }
else if (event->type() == QEvent::WindowDeactivate && isProfileLoaded) else if (event->type() == QEvent::WindowDeactivate && isProfileLoaded)
{ {
if (previousWidget != nullptr) if (previousWidget != nullptr && watched == previousWidget)
{ {
previousWidget->setStyleSheet(QLatin1String("")); previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr; previousWidget = nullptr;