controller: make docking areas 91/29291/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 30 Sep 2014 05:52:54 +0000 (14:52 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Fri, 24 Oct 2014 05:46:33 +0000 (14:46 +0900)
Change-Id: I6ece1e4e00a27b06c74e23b75b567c35f58f2d2a
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/dockingcontroller.cpp
tizen/src/ui/dockingconview.cpp
tizen/src/ui/floatingcontroller.cpp
tizen/src/ui/floatingconview.cpp
tizen/src/ui/floatingconview.h
tizen/src/ui/mainwindow.cpp

index d5d7d6fd5c392591f1c6faba0f882e1492412770..d1b29db86adf9ad097b6f4a9d3d4a0c7cfc9cbc7 100644 (file)
@@ -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;
index 128622ea080aa9c773680c105f6e503dee310fca..adcc8707e03a56a4ee4ddb7c063f4ba2cf96065b 100644 (file)
@@ -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;
         }
     }
 
index 422402b59808ab87cf9f282dc05d1d9edc726b37..f4889b26b97d1a04f20a1fff76033d9c800364a2 100644 (file)
@@ -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;
index 604fa8fb2b8ce9157f5fabe1b9cb523dda614981..4a9d70e022210f3cbeb22fdc9840c70369ef0bb3 100644 (file)
@@ -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);
index 9ae330d568e38d259a03b583fde8a6ba613f8c0f..e717e8c92df90227523029de020e44a319406c01 100644 (file)
@@ -47,7 +47,7 @@ protected:
     void mouseMoveEvent(QMouseEvent *event);
 
     QPoint grabPos;
-    QPoint winPos;
+    QPoint conPos;
 
 private:
     void createItems(ControllerForm *conForm);
index f7bc27a7608fb1896b3452a655994af10a13d9b9..b663dfc771549170b8e99d82a3ecc357551519de 100644 (file)
@@ -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);
     }