[Menu] Harmonize openRelative placement

Use the enums in a consistent way to place the menu around the parent item.

Test Plan:
Tested with plasma-pa and task manager context menu.

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D4921
This commit is contained in:
Roman Gilg 2017-03-22 11:16:33 +01:00
parent ff78b9e531
commit 28ad7879d3

View File

@ -372,36 +372,40 @@ Q_INVOKABLE void QMenuProxy::openRelative()
switch(m_placement) { switch(m_placement) {
case Types::TopPosedLeftAlignedPopup: { case Types::TopPosedLeftAlignedPopup: {
pos = parentItem->mapToScene(QPointF(0, -m_menu->height())); pos = parentItem->mapToScene(QPointF(0, -m_menu->height()));
boundaryCorrection(- m_menu->width() + parentItem->width(), m_menu->height() + parentItem->height()); boundaryCorrection(-m_menu->width() + parentItem->width(), m_menu->height() + parentItem->height());
break; break;
} }
case Types::LeftPosedTopAlignedPopup: { case Types::LeftPosedTopAlignedPopup: {
pos = parentItem->mapToScene(QPointF(-m_menu->width(), 0)); pos = parentItem->mapToScene(QPointF(-m_menu->width(), 0));
boundaryCorrection(m_menu->width() + parentItem->width(), - m_menu->height() + parentItem->height()); boundaryCorrection(m_menu->width() + parentItem->width(), -m_menu->height() + parentItem->height());
break; break;
} }
case Types::TopPosedRightAlignedPopup: case Types::TopPosedRightAlignedPopup:
pos = parentItem->mapToScene(QPointF(parentItem->width(), -m_menu->height())); pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), -m_menu->height()));
boundaryCorrection(- m_menu->width() + parentItem->width(), m_menu->height()); // in top right corner this will cover the parent item boundaryCorrection(m_menu->width() - parentItem->width(), m_menu->height() + parentItem->height());
break; break;
case Types::RightPosedTopAlignedPopup: { case Types::RightPosedTopAlignedPopup: {
pos = parentItem->mapToScene(QPointF(parentItem->width(), 0)); pos = parentItem->mapToScene(QPointF(parentItem->width(), 0));
boundaryCorrection(- m_menu->width() - parentItem->width(), m_menu->height() + parentItem->height()); boundaryCorrection(-m_menu->width() - parentItem->width(), -m_menu->height() + parentItem->height());
break; break;
} }
case Types::LeftPosedBottomAlignedPopup: case Types::LeftPosedBottomAlignedPopup:
pos = parentItem->mapToScene(QPointF(-m_menu->width(), parentItem->height())); pos = parentItem->mapToScene(QPointF(-m_menu->width(), -m_menu->height() + parentItem->height()));
boundaryCorrection(m_menu->width(), - m_menu->height()); // in lower left corner this will cover the parent item boundaryCorrection(m_menu->width() + parentItem->width(), m_menu->height() - parentItem->height());
break; break;
case Types::BottomPosedLeftAlignedPopup: { case Types::BottomPosedLeftAlignedPopup: {
pos = parentItem->mapToScene(QPointF(0, parentItem->height())); pos = parentItem->mapToScene(QPointF(0, parentItem->height()));
boundaryCorrection(- m_menu->width() + parentItem->width(), - m_menu->height() - parentItem->height()); boundaryCorrection(-m_menu->width() + parentItem->width(), -m_menu->height() - parentItem->height());
break;
}
case Types::BottomPosedRightAlignedPopup: {
pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), parentItem->height()));
boundaryCorrection(m_menu->width() - parentItem->width(), -m_menu->height() - parentItem->height());
break; break;
} }
case Types::BottomPosedRightAlignedPopup:
case Types::RightPosedBottomAlignedPopup: { case Types::RightPosedBottomAlignedPopup: {
pos = parentItem->mapToScene(QPointF(parentItem->width(), parentItem->height())); pos = parentItem->mapToScene(QPointF(parentItem->width(), -m_menu->height() + parentItem->height()));
boundaryCorrection(- m_menu->width() + parentItem->width(), - m_menu->height() + parentItem->height()); boundaryCorrection(-m_menu->width() - parentItem->width(), m_menu->height() - parentItem->height());
break; break;
} }
default: default: