From: GiWoong Kim Date: Thu, 30 Jul 2015 06:05:02 +0000 (+0900) Subject: ui: stop the window moving when context menu is opened X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c60b7088b2b79ecaf927ef13d9d40c9cbba4af40;p=sdk%2Femulator%2Fqemu.git ui: stop the window moving when context menu is opened Change-Id: Id8c157fe12621e7db9b3f571bf4fdb87c9a12ebc Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 0bc1b29eb0..6b9e4110ab 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -440,18 +440,24 @@ QAction *ContextMenu::addGeneralAction(QMenu *menu, return action; } +/* override */ bool ContextMenu::eventFilter(QObject *obj, QEvent *event) { ContextMenu *menu = dynamic_cast(obj); - if (menu != NULL && - (event->type() == QEvent::MouseButtonPress || - event->type() == QEvent::MouseButtonRelease)) { - QMouseEvent *mouseEvent = dynamic_cast(event); + if (menu != NULL) { + if (event->type() == QEvent::MouseButtonPress || + event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = dynamic_cast(event); - if (mouseEvent != NULL && mouseEvent->button() == Qt::RightButton) { - mouseEvent->ignore(); /* filtering */ - return true; + if (mouseEvent != NULL && mouseEvent->button() == Qt::RightButton) { + mouseEvent->ignore(); /* filtering */ + return true; + } + } else if (event->type() == QEvent::Show) { + if (parent->getSkinView()->isGrabWindow() == true) { + parent->getSkinView()->releaseWindow(); + } } } diff --git a/tizen/src/ui/skinview.cpp b/tizen/src/ui/skinview.cpp index cbd3a83752..92152e2952 100644 --- a/tizen/src/ui/skinview.cpp +++ b/tizen/src/ui/skinview.cpp @@ -74,6 +74,22 @@ KeyboardHelper *SkinView::getKbdHelper() return kbdHelper; } +bool SkinView::isGrabWindow() +{ + return (grabPos != QPoint(-1, -1)); +} + +void SkinView::grabWindow(QPoint globalPos) +{ + grabWinPos = parentWidget()->pos(); + grabPos = globalPos; +} + +void SkinView::releaseWindow() +{ + grabPos = QPoint(-1, -1); +} + void SkinView::updateLayout() { qDebug("update skin view layout"); @@ -103,11 +119,8 @@ void SkinView::resizeEvent(QResizeEvent *event) /* override */ void SkinView::mousePressEvent(QMouseEvent *event) { - //qDebug("pressed %dx%d", event->x(), event->y()); - if (event->button() == Qt::LeftButton) { - grabWinPos = parentWidget()->pos(); - grabPos = event->globalPos(); + grabWindow(event->globalPos()); } QGraphicsView::mousePressEvent(event); @@ -116,10 +129,8 @@ void SkinView::mousePressEvent(QMouseEvent *event) /* override */ void SkinView::mouseReleaseEvent(QMouseEvent *event) { - //qDebug("released %dx%d", event->x(), event->y()); - if (event->button() == Qt::LeftButton) { - grabPos = QPoint(-1, -1); + releaseWindow(); } QGraphicsView::mouseReleaseEvent(event); @@ -128,7 +139,7 @@ void SkinView::mouseReleaseEvent(QMouseEvent *event) /* override */ void SkinView::mouseMoveEvent(QMouseEvent *event) { - if (grabPos != QPoint(-1, -1)) { + if (isGrabWindow() == true) { win->move(grabWinPos + (event->globalPos() - grabPos)); } diff --git a/tizen/src/ui/skinview.h b/tizen/src/ui/skinview.h index 7d9387dc06..0c4575becb 100644 --- a/tizen/src/ui/skinview.h +++ b/tizen/src/ui/skinview.h @@ -44,6 +44,9 @@ public: ~SkinView(); KeyboardHelper *getKbdHelper(); + bool isGrabWindow(); + void grabWindow(QPoint globalPos); + void releaseWindow(); void updateLayout(); protected: