controller: added docking controller 82/29082/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Thu, 25 Sep 2014 05:47:15 +0000 (14:47 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 22 Oct 2014 04:49:01 +0000 (21:49 -0700)
Change-Id: Iaf2e99bd876dc1481155f3f121e5d7d343812dd1
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/Makefile.objs
tizen/src/ui/dockingcontroller.cpp [new file with mode: 0644]
tizen/src/ui/dockingcontroller.h [new file with mode: 0644]
tizen/src/ui/floatingcontroller.cpp
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h
tizen/src/ui/uistate.h

index 01a36bdb82eba9b846ddf1a0d0236fc7696d1b56..882329bf293ba244ab4f1d1f1cbbe69af661d9a5 100644 (file)
@@ -6,6 +6,7 @@ $(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc
        rcc -name resource $< -o $@
 
 obj-$(CONFIG_QT) += controllerform.o
+obj-$(CONFIG_QT) += dockingcontroller.o moc_dockingcontroller.o
 obj-$(CONFIG_QT) += floatingcontroller.o moc_floatingcontroller.o
 obj-$(CONFIG_QT) += displaybase.o
 obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o
@@ -26,6 +27,9 @@ obj-$(CONFIG_QT) += xml/
 
 obj-$(CONFIG_QT) += menu/
 
+$(obj)/moc_dockingcontroller.o: $(obj)/moc_dockingcontroller.cpp
+$(obj)/moc_dockingcontroller.cpp: $(obj)/dockingcontroller.h
+       moc $< -o $@
 $(obj)/moc_floatingcontroller.o: $(obj)/moc_floatingcontroller.cpp
 $(obj)/moc_floatingcontroller.cpp: $(obj)/floatingcontroller.h
        moc $< -o $@
diff --git a/tizen/src/ui/dockingcontroller.cpp b/tizen/src/ui/dockingcontroller.cpp
new file mode 100644 (file)
index 0000000..f112377
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <QtWidgets>
+
+#include "dockingcontroller.h"
+#include "mainwindow.h"
+
+DockingController::DockingController(ControllerForm *conForm, QGraphicsScene *conScene,
+    QAction *menu, QWidget *parent) : SkinControllerView(conForm, conScene, parent)
+{
+    this->conForm = conForm;
+    this->menu = menu;
+
+    setAttribute(Qt::WA_DeleteOnClose);
+    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+}
+
+void DockingController::showEvent(QShowEvent *event)
+{
+    menu->setChecked(true);
+    //setRegion(conForm->conImg[ControllerForm::normal]);
+}
+
+void DockingController::closeEvent(QCloseEvent *event) {
+    menu->setChecked(false);
+
+    MainWindow *win = ((MainWindow *)this->parent());
+    win->getUIState()->conState.dockingCon = NULL;
+}
+
+void DockingController::setRegion(QImage baseImage)
+{
+    qDebug("set region");
+
+    /*
+    if (baseImage.isNull() == true) {
+        qWarning("invalid image for region");
+        return;
+    }
+
+    QImage region = baseImage.createAlphaMask();
+    setMask(QRegion(QBitmap::fromImage(region)));
+    */
+}
+
+DockingController::~DockingController()
+{
+    qDebug("destroy docking contoller");
+}
diff --git a/tizen/src/ui/dockingcontroller.h b/tizen/src/ui/dockingcontroller.h
new file mode 100644 (file)
index 0000000..765c8a1
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef DOCKINGCONTROLLER_H
+#define DOCKINGCONTROLLER_H
+
+#include <QDialog>
+
+#include "controllerform.h"
+#include "skincontrollerview.h"
+
+class DockingController : public SkinControllerView
+{
+    Q_OBJECT
+
+public:
+    explicit DockingController(ControllerForm *conForm, QGraphicsScene *conScene,
+        QAction *menu, QWidget *parent = 0);
+    ~DockingController();
+
+protected:
+    void showEvent(QShowEvent *event);
+    void closeEvent(QCloseEvent *event);
+
+    void setRegion(QImage baseImage);
+
+private:
+    ControllerForm *conForm;
+    QAction *menu;
+};
+
+#endif // DOCKINGCONTROLLER_H
index fd2a6ca6a2b7e69381c06784abd86ed1564dc23c..9188d5327242cc94f143d8f3b9c535ee81e74139 100644 (file)
@@ -83,5 +83,5 @@ void FloatingController::setRegion(QImage baseImage)
 
 FloatingController::~FloatingController()
 {
-    qDebug("destroy contoller");
+    qDebug("destroy floating contoller");
 }
index cbde5f5689534ffe664a6e78a64aef23f0dfce6a..b597adb6257c9b94e9af3605462041ef613be637 100644 (file)
@@ -81,7 +81,6 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
     popupMenu = NULL;
     skinView = NULL;
     display = NULL;
-    conView = NULL;
 
     /* windowing */
     setWindowTitle("Emulator");
@@ -183,6 +182,11 @@ UIState *MainWindow::getUIState()
     return &(uiInfo->uiState);
 }
 
+DockingController *MainWindow::getDockingCon()
+{
+    return getUIState()->conState.dockingCon;
+}
+
 FloatingController *MainWindow::getFloatingCon()
 {
     return getUIState()->conState.floatingCon;
@@ -206,14 +210,16 @@ void MainWindow::openController(int index, bool docking)
     }
 
     if (docking == true) {
+        QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index);
         conScene = new QGraphicsScene(this);
-        conView = new SkinControllerView(conForm, conScene, this);
-        conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+        getUIState()->conState.dockingCon =
+            new DockingController(conForm, conScene, action, this);
 
-        winLayout->addWidget(conView);
+        winLayout->addWidget(getDockingCon());
     } else {
         QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index);
-        getUIState()->conState.floatingCon = new FloatingController(conForm, action, this);
+        getUIState()->conState.floatingCon =
+            new FloatingController(conForm, action, this);
 
         QPoint globalPos = mapToGlobal(QPoint(0, 0));
         getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y());
@@ -223,14 +229,15 @@ void MainWindow::openController(int index, bool docking)
 
 void MainWindow::closeController()
 {
-    if (conView != NULL) {
+    if (getDockingCon() != NULL) {
         qDebug("close docking controller");
 
-        conView->close();
-        conScene->clear();
+        winLayout->removeWidget(getDockingCon());
+
+        getDockingCon()->close();
+        getUIState()->conState.dockingCon = NULL;
 
-        delete conView;
-        conView = NULL;
+        conScene->clear();
         delete conScene;
         conScene = NULL;
     }
@@ -239,6 +246,7 @@ void MainWindow::closeController()
         qDebug("close floating controller");
 
         getFloatingCon()->close();
+        getUIState()->conState.floatingCon = NULL;
     }
 }
 
index 816f51be99a2ce83c0e12e9c5f6e73fa4f5f7d4d..74b5e37e5ce29de9004f19f530ed63b2197e478b 100644 (file)
@@ -42,6 +42,7 @@
 #include "skinbezelitem.h"
 #include "uiinformation.h"
 #include "skincontrollerview.h"
+#include "dockingcontroller.h"
 #include "floatingcontroller.h"
 
 extern "C" {
@@ -76,6 +77,7 @@ public:
     UIState *getUIState(void);
     void rotate(int angle);
     void scale(int scale);
+    DockingController *getDockingCon();
     FloatingController *getFloatingCon();
     void openController(int index, bool docking);
     void closeController();
@@ -99,10 +101,10 @@ private:
     QHBoxLayout *winLayout;
     QGraphicsScene *skinScene;
     QGraphicsScene *conScene;
-    ContextMenu *popupMenu;
     SkinView* skinView;
     DisplayBase *display;
-    SkinControllerView *conView;
+    ContextMenu *popupMenu;
+
     QThread *swapperThread;
     DisplaySwapper *swapper;
 };
index cd80091b93f6d0e56bd89c03d62660edab21df22..280ee37b33f54ddef34282c594787d8839d73e9a 100644 (file)
 
 #include <QtWidgets>
 
+#include "dockingcontroller.h"
 #include "floatingcontroller.h"
 
 class ControllerState
 {
 public:
+    DockingController *dockingCon;
     FloatingController *floatingCon;
 };