|
|
@ -71,25 +71,10 @@ void ContextMenu::menuAboutToHide()
|
|
|
|
emit menuChanged();
|
|
|
|
emit menuChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QPoint ContextMenu::popUpTopLeft(const QRect &parentItem, const QRect popUpRect)
|
|
|
|
QPoint ContextMenu::popUpRelevantToParent(const QRect &parentItem, const QRect popUpRect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QPoint resultPoint;
|
|
|
|
QPoint resultPoint;
|
|
|
|
|
|
|
|
|
|
|
|
if (m_latteView->behaveAsPlasmaPanel() && m_latteView->normalThickness() > 96) {
|
|
|
|
|
|
|
|
if (m_latteView->location() == Plasma::Types::TopEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x());
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y() + 1);
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::BottomEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x());
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y() - popUpRect.height() - 1);
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::LeftEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x() + 1);
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y());
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::RightEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x() - popUpRect.width() - 1);
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (m_latteView->location() == Plasma::Types::TopEdge) {
|
|
|
|
if (m_latteView->location() == Plasma::Types::TopEdge) {
|
|
|
|
resultPoint.setX(parentItem.left());
|
|
|
|
resultPoint.setX(parentItem.left());
|
|
|
|
resultPoint.setY(parentItem.bottom());
|
|
|
|
resultPoint.setY(parentItem.bottom());
|
|
|
@ -103,23 +88,49 @@ QPoint ContextMenu::popUpTopLeft(const QRect &parentItem, const QRect popUpRect)
|
|
|
|
resultPoint.setX(parentItem.left() - popUpRect.width());
|
|
|
|
resultPoint.setX(parentItem.left() - popUpRect.width());
|
|
|
|
resultPoint.setY(parentItem.top());
|
|
|
|
resultPoint.setY(parentItem.top());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultPoint;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPoint ContextMenu::popUpRelevantToGlobalPoint(const QRect &parentItem, const QRect popUpRect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QPoint resultPoint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_latteView->location() == Plasma::Types::TopEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x());
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y() + 1);
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::BottomEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x());
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y() - popUpRect.height() - 1);
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::LeftEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x() + 1);
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y());
|
|
|
|
|
|
|
|
} else if (m_latteView->location() == Plasma::Types::RightEdge) {
|
|
|
|
|
|
|
|
resultPoint.setX(popUpRect.x() - popUpRect.width() - 1);
|
|
|
|
|
|
|
|
resultPoint.setY(popUpRect.y());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return resultPoint;
|
|
|
|
return resultPoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QPoint ContextMenu::popUpTopLeft(const Plasma::Applet *applet, const QRect popUpRect)
|
|
|
|
QPoint ContextMenu::popUpTopLeft(Plasma::Applet *applet, const QRect popUpRect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
|
|
|
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
|
|
|
|
|
|
|
|
|
|
|
QRect globalItemRect;
|
|
|
|
QRect globalItemRect = m_latteView->absoluteGeometry();
|
|
|
|
|
|
|
|
|
|
|
|
if (ai) {
|
|
|
|
if (ai && applet != m_latteView->containment()) {
|
|
|
|
QPointF appletGlobalTopLeft = ai->mapToGlobal(QPointF(ai->x(), ai->y()));
|
|
|
|
QPointF appletGlobalTopLeft = ai->mapToGlobal(QPointF(ai->x(), ai->y()));
|
|
|
|
globalItemRect = QRect(appletGlobalTopLeft.x(), appletGlobalTopLeft.y(), ai->width(), ai->height());
|
|
|
|
globalItemRect = QRect(appletGlobalTopLeft.x(), appletGlobalTopLeft.y(), ai->width(), ai->height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return popUpTopLeft(globalItemRect, popUpRect);
|
|
|
|
if ((m_latteView->behaveAsPlasmaPanel() && m_latteView->normalThickness() > 96)
|
|
|
|
|
|
|
|
|| (applet == m_latteView->containment())
|
|
|
|
|
|
|
|
|| (m_latteView && m_latteView->layout() && m_latteView->layout()->isInternalContainment(applet)) ) {
|
|
|
|
|
|
|
|
return popUpRelevantToGlobalPoint(globalItemRect, popUpRect);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return popUpRelevantToParent(globalItemRect, popUpRect);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -306,7 +317,7 @@ bool ContextMenu::mousePressEvent(QMouseEvent *event)
|
|
|
|
if (applet) {
|
|
|
|
if (applet) {
|
|
|
|
globalPos = popUpTopLeft(applet, popUpRect);
|
|
|
|
globalPos = popUpTopLeft(applet, popUpRect);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
globalPos = popUpTopLeft(QRect(0,0,0,0), popUpRect);
|
|
|
|
globalPos = popUpRelevantToGlobalPoint(QRect(0,0,0,0), popUpRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug() << "7...";
|
|
|
|
//qDebug() << "7...";
|
|
|
|