Check if resize area is null

This commit is contained in:
Ilya Fedin 2021-02-17 22:04:52 +04:00 committed by John Preston
parent b3660f1ed8
commit a9c08552c8
1 changed files with 14 additions and 10 deletions

View File

@ -351,29 +351,33 @@ QMargins TitleWidgetQt::resizeArea() const {
} }
Qt::Edges TitleWidgetQt::edgesFromPos(const QPoint &pos) const { Qt::Edges TitleWidgetQt::edgesFromPos(const QPoint &pos) const {
if (pos.x() <= resizeArea().left()) { const auto area = resizeArea();
if (pos.y() <= resizeArea().top()) {
if (area.isNull()) {
return Qt::Edges();
} else if (pos.x() <= area.left()) {
if (pos.y() <= area.top()) {
return Qt::LeftEdge | Qt::TopEdge; return Qt::LeftEdge | Qt::TopEdge;
} else if (pos.y() >= (window()->height() - resizeArea().bottom())) { } else if (pos.y() >= (window()->height() - area.bottom())) {
return Qt::LeftEdge | Qt::BottomEdge; return Qt::LeftEdge | Qt::BottomEdge;
} }
return Qt::LeftEdge; return Qt::LeftEdge;
} else if (pos.x() >= (window()->width() - resizeArea().right())) { } else if (pos.x() >= (window()->width() - area.right())) {
if (pos.y() <= resizeArea().top()) { if (pos.y() <= area.top()) {
return Qt::RightEdge | Qt::TopEdge; return Qt::RightEdge | Qt::TopEdge;
} else if (pos.y() >= (window()->height() - resizeArea().bottom())) { } else if (pos.y() >= (window()->height() - area.bottom())) {
return Qt::RightEdge | Qt::BottomEdge; return Qt::RightEdge | Qt::BottomEdge;
} }
return Qt::RightEdge; return Qt::RightEdge;
} else if (pos.y() <= resizeArea().top()) { } else if (pos.y() <= area.top()) {
return Qt::TopEdge; return Qt::TopEdge;
} else if (pos.y() >= (window()->height() - resizeArea().bottom())) { } else if (pos.y() >= (window()->height() - area.bottom())) {
return Qt::BottomEdge; return Qt::BottomEdge;
} else {
return Qt::Edges();
} }
return Qt::Edges();
} }
void TitleWidgetQt::updateCursor(Qt::Edges edges) { void TitleWidgetQt::updateCursor(Qt::Edges edges) {