From: GiWoong Kim Date: Tue, 30 Sep 2014 05:52:54 +0000 (+0900) Subject: controller: make docking areas X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db7bafd94d974f1e2b7f3eda265ecf17ed12e6f4;p=sdk%2Femulator%2Fqemu.git controller: make docking areas Change-Id: I6ece1e4e00a27b06c74e23b75b567c35f58f2d2a Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/dockingcontroller.cpp b/tizen/src/ui/dockingcontroller.cpp index d5d7d6fd5c..d1b29db86a 100644 --- a/tizen/src/ui/dockingcontroller.cpp +++ b/tizen/src/ui/dockingcontroller.cpp @@ -44,11 +44,15 @@ DockingController::DockingController(ControllerForm *conForm, QGraphicsScene *co void DockingController::showEvent(QShowEvent *event) { - menu->setChecked(true); + if (menu != NULL) { + menu->setChecked(true); + } } void DockingController::closeEvent(QCloseEvent *event) { - menu->setChecked(false); + if (menu != NULL) { + menu->setChecked(false); + } MainWindow *win = ((MainWindow *)this->parent()); win->getUIState()->conState.dockingCon = NULL; diff --git a/tizen/src/ui/dockingconview.cpp b/tizen/src/ui/dockingconview.cpp index 128622ea08..adcc8707e0 100644 --- a/tizen/src/ui/dockingconview.cpp +++ b/tizen/src/ui/dockingconview.cpp @@ -101,11 +101,12 @@ void DockingConView::mouseReleaseEvent(QMouseEvent *event) rubberBand->hide(); } + /* toggle */ MainWindow *win = ((MainWindow *)this->parent()); win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos; - win->openController(win->getUIState()->conState.conFormIndex, false); - grabPos = QPoint(-1, -1); + win->openController(win->getUIState()->conState.conFormIndex, false); + return; } } diff --git a/tizen/src/ui/floatingcontroller.cpp b/tizen/src/ui/floatingcontroller.cpp index 422402b598..f4889b26b9 100644 --- a/tizen/src/ui/floatingcontroller.cpp +++ b/tizen/src/ui/floatingcontroller.cpp @@ -57,12 +57,17 @@ FloatingController::FloatingController(ControllerForm *conForm, void FloatingController::showEvent(QShowEvent *event) { - menu->setChecked(true); + if (menu != NULL) { + menu->setChecked(true); + } + setRegion(conForm->conImg[ControllerForm::normal]); } void FloatingController::closeEvent(QCloseEvent *event) { - menu->setChecked(false); + if (menu != NULL) { + menu->setChecked(false); + } MainWindow *win = ((MainWindow *)this->parent()); win->getUIState()->conState.floatingCon = NULL; diff --git a/tizen/src/ui/floatingconview.cpp b/tizen/src/ui/floatingconview.cpp index 604fa8fb2b..4a9d70e022 100644 --- a/tizen/src/ui/floatingconview.cpp +++ b/tizen/src/ui/floatingconview.cpp @@ -31,6 +31,8 @@ #include "mainwindow.h" #include "skinkeyitem.h" +#define DOCKABLE_AREA_WIDTH 30 + FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent) { @@ -42,7 +44,7 @@ FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setAlignment(Qt::AlignLeft | Qt::AlignTop); - winPos = QPoint(-1, -1); + conPos = QPoint(-1, -1); grabPos = QPoint(-1, -1); createItems(conForm); @@ -77,10 +79,10 @@ void FloatingConView::resizeEvent(QResizeEvent *event) void FloatingConView::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - QWidget *win = ((QWidget *) this->parent()); + QWidget *con = ((QWidget *) this->parent()); grabPos = event->globalPos(); - winPos = win->pos(); + conPos = con->pos(); } QGraphicsView::mousePressEvent(event); @@ -92,15 +94,35 @@ void FloatingConView::mouseReleaseEvent(QMouseEvent *event) grabPos = QPoint(-1, -1); } + QWidget *con = ((QWidget *)this->parent()); + QRect conDockable( + con->pos().x() - 1, + con->pos().y(), + DOCKABLE_AREA_WIDTH, + size().height()); + + MainWindow *win = ((MainWindow *)con->parent()); + QRect mainDockable( + win->pos().x() + win->uiInfo->getMainSize().width() - 1, + win->pos().y(), + DOCKABLE_AREA_WIDTH, + win->uiInfo->getMainSize().height()); + + if (conDockable.intersects(mainDockable) == true) { + /* toggle */ + win->openController(win->getUIState()->conState.conFormIndex, true); + return; + } + QGraphicsView::mouseReleaseEvent(event); } void FloatingConView::mouseMoveEvent(QMouseEvent *event) { - QWidget *win = ((QWidget *)this->parent()); + QWidget *con = ((QWidget *)this->parent()); if (grabPos != QPoint(-1, -1)) { - win->move(winPos + (event->globalPos() - grabPos)); + con->move(conPos + (event->globalPos() - grabPos)); } QGraphicsView::mouseMoveEvent(event); diff --git a/tizen/src/ui/floatingconview.h b/tizen/src/ui/floatingconview.h index 9ae330d568..e717e8c92d 100644 --- a/tizen/src/ui/floatingconview.h +++ b/tizen/src/ui/floatingconview.h @@ -47,7 +47,7 @@ protected: void mouseMoveEvent(QMouseEvent *event); QPoint grabPos; - QPoint winPos; + QPoint conPos; private: void createItems(ControllerForm *conForm); diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index f7bc27a760..b663dfc771 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -209,15 +209,18 @@ void MainWindow::openController(int index, bool docking) return; } + QAction *action = NULL; + if (popupMenu != NULL) { + action = (QAction *)popupMenu->getControllerMapper()->mapping(index); + } + /* create */ if (docking == true) { - QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index); conScene = new QGraphicsScene(this); conScene->setBackgroundBrush(Qt::black); getUIState()->conState.dockingCon = new DockingController(conForm, conScene, action, this); } else { - QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index); getUIState()->conState.floatingCon = new FloatingController(conForm, action, this); }