ui: declare some getter/setter wrapper fucntions for UiState class
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 14 Sep 2015 06:21:18 +0000 (15:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 15 Sep 2015 04:50:59 +0000 (13:50 +0900)
Change-Id: Ie6b97283ea8cfe39cd58a5e7e9bb8166e7ed791f
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/controller/dockingcontroller.cpp
tizen/src/ui/controller/dockingconview.cpp
tizen/src/ui/controller/floatingcontroller.cpp
tizen/src/ui/controller/floatingconview.cpp
tizen/src/ui/mainwindow.cpp
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/uiinformation.cpp
tizen/src/ui/uiinformation.h
tizen/src/ui/uistate.cpp
tizen/src/ui/uistate.h

index 77b07ae..3e9a983 100644 (file)
@@ -100,7 +100,7 @@ void DockingController::closeEvent(QCloseEvent *event) {
         menu->setChecked(false);
     }
 
-    win->getUiState()->conState.dockingCon = NULL;
+    win->getUiState()->getConState()->setDockingCon(NULL);
 
     deleteLater();
     event->accept();
index 09b2727..b2c4dca 100644 (file)
@@ -150,11 +150,14 @@ void DockingConView::mouseReleaseEvent(QMouseEvent *event)
                 rubberBand->hide();
             }
 
-            if (getConViewStatus() != CONVIEW_PRESSED && getConViewStatus() != CONVIEW_DOUBLECLICKED) {
+            if (getConViewStatus() != CONVIEW_PRESSED &&
+                getConViewStatus() != CONVIEW_DOUBLECLICKED) {
                 /* toggle */
                 MainWindow *win = ((MainWindow *)parent->parent());
-                win->getUiState()->conState.recentlyFloatPos = event->globalPos() - eventPos;
-                win->openController(win->getUiState()->conState.conFormIndex, -1);
+                win->getUiState()->getConState()->setRecentlyFloatPos(
+                    event->globalPos() - eventPos);
+                win->openController(
+                    win->getUiState()->getConState()->getConFormIndex(), -1);
             }
         }
     }
index 03d64da..bc9d76b 100644 (file)
@@ -98,7 +98,7 @@ void FloatingController::closeEvent(QCloseEvent *event) {
     }
 
     MainWindow *win = ((MainWindow *)this->parent());
-    win->getUiState()->conState.floatingCon = NULL;
+    win->getUiState()->getConState()->setFloatingCon(NULL);
 
     deleteLater();
     event->accept();
index 40c584a..416d7f5 100644 (file)
@@ -187,7 +187,8 @@ void FloatingConView::mouseReleaseEvent(QMouseEvent *event)
     int dockPos = isDockable((QWidget *)win, (QWidget *)parent);
     if (dockPos != -1) {
         /* toggle */
-        win->openController(win->getUiState()->conState.conFormIndex, dockPos);
+        win->openController(
+            win->getUiState()->getConState()->getConFormIndex(), dockPos);
         return;
     }
 }
index f6fd4ed..b2f676a 100644 (file)
@@ -211,7 +211,7 @@ UIInformation *MainWindow::getUiInfo()
 
 UIState *MainWindow::getUiState()
 {
-    return &(uiInfo->uiState);
+    return uiInfo->getUiState();
 }
 
 const QMatrix &MainWindow::getDisplayMatrix()
@@ -236,12 +236,12 @@ DisplayBase *MainWindow::getDisplay()
 
 DockingController *MainWindow::getDockingCon()
 {
-    return getUiState()->conState.dockingCon;
+    return getUiState()->getConState()->getDockingCon();
 }
 
 FloatingController *MainWindow::getFloatingCon()
 {
-    return getUiState()->conState.floatingCon;
+    return getUiState()->getConState()->getFloatingCon();
 }
 
 void MainWindow::openController(int index, int dockPos)
@@ -272,7 +272,7 @@ void MainWindow::openController(int index, int dockPos)
         return;
     }
 
-    getUiState()->conState.conFormIndex = index;
+    getUiState()->getConState()->setConFormIndex(index);
 
     QAction *action = NULL;
     if (popupMenu != NULL && popupMenu->getControllerMapper() != NULL) {
@@ -282,20 +282,22 @@ void MainWindow::openController(int index, int dockPos)
 
     /* create */
     if (dockPos == -1) {
-        getUiState()->conState.floatingCon =
-            new FloatingController(conForm, action, this);
+        getUiState()->getConState()->setFloatingCon(
+            new FloatingController(conForm, action, this));
     } else {
-        getUiState()->conState.dockingCon =
-            new DockingController(conForm, action, dockPos, this);
-        getUiState()->conState.recentlyDockPos = dockPos;
+        getUiState()->getConState()->setDockingCon(
+            new DockingController(conForm, action, dockPos, this));
+        getUiState()->getConState()->setRecentlyDockPos(dockPos);
 
 #ifdef CONFIG_WIN32
         /* W/A: Sometimes, QGrahpicsItem's update() does not work with QGLWidget
          * on Windows Aero theme. We need to indirectly repaint the items
          * through these lines. */
         const QSize conViewSize = uiInfo->getConSize();
-        getUiState()->conState.dockingCon->getConView()->resize(conViewSize / 2);
-        getUiState()->conState.dockingCon->getConView()->resize(conViewSize);
+        getUiState()->getConState()->
+            getDockingCon()->getConView()->resize(conViewSize / 2);
+        getUiState()->getConState()->
+            getDockingCon()->getConView()->resize(conViewSize);
 #endif
     }
 
@@ -307,12 +309,12 @@ void MainWindow::openController(int index, int dockPos)
 
     /* arrange */
     if (dockPos == -1) {
-        if (getUiState()->conState.recentlyFloatPos == QPoint(-1, -1)) {
+        if (getUiState()->getConState()->getRecentlyFloatPos() == QPoint(-1, -1)) {
             QPoint globalPos = mapToGlobal(QPoint(0, 0));
             getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y());
         } else {
-            getFloatingCon()->move(getUiState()->conState.recentlyFloatPos);
-            getUiState()->conState.recentlyFloatPos = QPoint(-1, -1);
+            getFloatingCon()->move(getUiState()->getConState()->getRecentlyFloatPos());
+            getUiState()->getConState()->setRecentlyFloatPos(QPoint(-1, -1));
         }
 
         getFloatingCon()->show();
@@ -339,7 +341,7 @@ void MainWindow::closeController()
             getDockingCon()->getConForm()->getKeyList());
         getDockingCon()->close();
 
-        getUiState()->conState.dockingCon = NULL;
+        getUiState()->getConState()->setDockingCon(NULL);
 
         resize(uiInfo->getUiSize());
     }
@@ -347,14 +349,14 @@ void MainWindow::closeController()
     if (getFloatingCon() != NULL) {
         qDebug("close floating controller");
 
-        getUiState()->conState.recentlyFloatPos = getFloatingCon()->pos();
+        getUiState()->getConState()->setRecentlyFloatPos(getFloatingCon()->pos());
 
         /* cancel controller's HW key shortcuts */
         keyboardShortcut->cancelHwKeyShortcuts(
             getFloatingCon()->getConForm()->getKeyList());
         getFloatingCon()->close();
 
-        getUiState()->conState.floatingCon = NULL;
+        getUiState()->getConState()->setFloatingCon(NULL);
     }
 
     /* Some part of QGLWidget's surface might be lost on Windows when view changing.
@@ -415,7 +417,7 @@ void MainWindow::switchForm(int index)
     keyboardShortcut->cancelHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
 
     /* layout switching */
-    getUiState()->mainFormIndex = index;
+    getUiState()->setMainFormIndex(index);
 
     /* register new HW key shortcuts */
     keyboardShortcut->registerHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
@@ -446,7 +448,7 @@ void MainWindow::scaleForm(int scale)
     qDebug("window scale: %d", scale);
 
     /* scale changing */
-    getUiState()->mainFormScale = scale;
+    getUiState()->setScalePct(scale);
 
     updateDisplayMatrix();
 
index 3c7a26d..11fa525 100644 (file)
@@ -341,7 +341,7 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item)
         // TODO: interpolation
 
         action = (QAction *) scaleMapper->mapping(
-            parent->getUiState()->mainFormScale);
+            parent->getUiState()->getScalePct());
         action->setChecked(true);
     } else {
         qWarning("cannot create a scaleItem");
@@ -755,7 +755,7 @@ void ContextMenu::slotController(int index)
     qDebug("controller: %d", index);
 
     parent->openController(index,
-        parent->getUiState()->conState.recentlyDockPos);
+        parent->getUiState()->getConState()->getRecentlyDockPos());
 
     if (infoDialog != NULL && infoDialog->isVisible() == true) {
         /* update controller shortcut info */
@@ -768,7 +768,7 @@ void ContextMenu::slotCloseCon()
     qDebug("controller: None");
 
     parent->closeController();
-    parent->getUiState()->conState.conFormIndex = -1;
+    parent->getUiState()->getConState()->setConFormIndex(-1);
 
     if (infoDialog != NULL && infoDialog->isVisible() == true) {
         /* update controller shortcut info */
index f1d529d..0d7b2f1 100644 (file)
@@ -195,8 +195,8 @@ void qt5_gui_init(void)
             }
         }
     }
-    uiInfo->uiState.mainFormScale = scale;
-    qDebug("default scale value is %d", uiInfo->uiState.mainFormScale);
+    uiInfo->getUiState()->setScalePct(scale);
+    qDebug("default scale value is %d", uiInfo->getUiState()->getScalePct());
 
     /* GUI */
     qDebug("start!");
@@ -234,7 +234,7 @@ void qt5_gui_init(void)
 
     /* controller */
     const int defaultDockPos = Qt::AlignRight | Qt::AlignCenter;
-    mainwindow->getUiState()->conState.recentlyDockPos = defaultDockPos;
+    mainwindow->getUiState()->getConState()->setRecentlyDockPos(defaultDockPos);
 
     int conIndex = mruInfo.value(SKIN_PROPERTY_CONTROLLER_INDEX).toInt();
     if (conIndex >= 0 && conIndex < uiInfo->conFormList.count()) {
@@ -271,11 +271,14 @@ void qt5_destroy()
     QSettings mruInfo(path, QSettings::IniFormat);
     mruInfo.setValue(SKIN_PROPERTY_WINDOW_X, mainwindow->pos().x());
     mruInfo.setValue(SKIN_PROPERTY_WINDOW_Y, mainwindow->pos().y());
-    mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE, uiInfo->uiState.mainFormScale);
-    mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST, uiInfo->uiState.isOnTop());
-    mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX, uiInfo->uiState.conState.conFormIndex);
-
-    DockingController *con = uiInfo->uiState.conState.dockingCon;
+    mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE,
+        uiInfo->getUiState()->getScalePct());
+    mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST,
+        uiInfo->getUiState()->isOnTop());
+    mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX,
+        uiInfo->getUiState()->getConState()->getConFormIndex());
+
+    DockingController *con = uiInfo->getUiState()->getConState()->getDockingCon();
     if (con != NULL) {
         mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, con->getDockPos());
     } else {
index 5f5095d..4db95f1 100644 (file)
@@ -37,6 +37,11 @@ UIInformation::UIInformation() :
     skinPath = "./";
 }
 
+UIState *UIInformation::getUiState()
+{
+    return &uiState;
+}
+
 QColor UIInformation::getVMColor()
 {
     switch(basePort % 10) {
@@ -73,7 +78,8 @@ MainForm *UIInformation::getMainForm()
     if (index > (mainFormList.count() - 1) || index < 0) {
         qWarning("invalid form found");
 
-        index = uiState.mainFormIndex = 0;
+        uiState.setMainFormIndex(0);
+        index = uiState.getMainFormIndex();
     }
 
     MainForm *mainForm = mainFormList.at(index);
@@ -91,7 +97,7 @@ DisplayType *UIInformation::getMainFormDpyType()
 
 ControllerForm *UIInformation::getConForm()
 {
-    int index = uiState.conState.getConFormIndex();
+    int index = uiState.getConState()->getConFormIndex();
 
     if (index > (conFormList.count() - 1) || index < 0) {
         qWarning("invalid form found");
@@ -125,7 +131,7 @@ QSize UIInformation::getUiSize()
     QSize uiSize = getMainSize();
 
     /* docking controller */
-    if (uiState.conState.dockingCon != NULL) {
+    if (uiState.getConState()->getDockingCon() != NULL) {
         QSize conSize = getConSize();
         uiSize.setWidth(uiSize.width() + conSize.width());
         uiSize.setHeight(qMax(uiSize.height(), conSize.height()));
@@ -163,7 +169,7 @@ QRegion UIInformation::getUiRegion()
     QRegion uiRegion = getMainRegion();
 
     /* docking controller */
-    DockingController *con = uiState.conState.dockingCon;
+    DockingController *con = uiState.getConState()->getDockingCon();
     if (con != NULL) {
         QRegion conRegion = getConRegion();
 
@@ -212,7 +218,7 @@ QRegion UIInformation::getConKeyRegion(
     QRegion baseRegion;
     QRegion keyRegion;
 
-    if (uiState.conState.dockingCon != NULL) {
+    if (uiState.getConState()->getDockingCon() != NULL) {
         /* docking controller */
         const int shiftW = getMainSize().width();
 
index e56b51c..5377d8f 100644 (file)
@@ -53,9 +53,8 @@ public:
     QList<MainForm *> mainFormList;
     QList<ControllerForm *> conFormList;
     QList<MenuItem *> menuList;
-    QColor hoverColor;
 
-    UIState uiState; /* runtime information */
+    UIState *getUiState();
 
     QColor getVMColor();
     MainForm *getMainForm(); /* current */
@@ -70,6 +69,9 @@ public:
     QRegion getUiRegion(); /* main + docking con */
     QRegion getMainKeyRegion(QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type);
     QRegion getConKeyRegion(QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type);
+
+private:
+    UIState uiState; /* runtime information */
 };
 
 #endif // UIINFORMATION_H
index 7fed73a..7aea30f 100644 (file)
 
 #include "uistate.h"
 
-UIState::UIState() :
-    mainFormIndex(0), mainFormScale(100)
+ControllerState::ControllerState()
 {
-    onTop = false;
-    conState.conFormIndex = 0;
-    conState.dockingCon = NULL;
-    conState.floatingCon = NULL;
-    conState.recentlyDockPos = -1;
-    conState.recentlyFloatPos = QPoint(-1, -1);
+    this->conFormIndex = 0;
+    this->dockingCon = NULL;
+    this->recentlyDockPos = -1;
+    this->floatingCon = NULL;
+    this->recentlyFloatPos = QPoint(-1, -1);
+}
+
+void ControllerState::setConFormIndex(int index) {
+    conFormIndex = index;
+}
+
+int ControllerState::getConFormIndex() {
+    return conFormIndex;
+}
+
+/* docking controller */
+void ControllerState::setDockingCon(DockingController *con)
+{
+    dockingCon = con;
+}
+
+DockingController *ControllerState::getDockingCon()
+{
+    return dockingCon;
+}
+
+void ControllerState::setRecentlyDockPos(int pos)
+{
+    recentlyDockPos = pos;
+}
+
+int ControllerState::getRecentlyDockPos()
+{
+    return recentlyDockPos;
+}
+
+/* floating controller */
+void ControllerState::setFloatingCon(FloatingController *con)
+{
+  floatingCon = con;
+}
+
+FloatingController *ControllerState::getFloatingCon()
+{
+    return floatingCon;
+}
+
+void ControllerState::setRecentlyFloatPos(QPoint pos)
+{
+    recentlyFloatPos = pos;
+}
+
+QPoint ControllerState::getRecentlyFloatPos()
+{
+    return recentlyFloatPos;
+}
+
+
+UIState::UIState()
+{
+    this->mainFormIndex = 0;
+    this->mainFormScalePct = 100;
+    this->onTop = false;
+}
+
+void UIState::setMainFormIndex(int index)
+{
+    mainFormIndex = index;
 }
 
 int UIState::getMainFormIndex()
@@ -45,6 +106,16 @@ int UIState::getMainFormIndex()
     return mainFormIndex;
 }
 
+void UIState::setScalePct(int scalePct)
+{
+    mainFormScalePct = scalePct;
+}
+
+int UIState::getScalePct()
+{
+    return mainFormScalePct;
+}
+
 qreal UIState::getScaleFactor(int scale)
 {
     return ((qreal)scale) / 100;
@@ -52,12 +123,12 @@ qreal UIState::getScaleFactor(int scale)
 
 qreal UIState::getScaleFactor()
 {
-    return getScaleFactor(this->mainFormScale);
+    return getScaleFactor(mainFormScalePct);
 }
 
 void UIState::setOnTop(bool on)
 {
-    qDebug("set on top : %d", on);
+    qDebug("set on top: %d", on);
 
     onTop = on;
 }
@@ -66,3 +137,8 @@ bool UIState::isOnTop()
 {
     return onTop;
 }
+
+ControllerState *UIState::getConState()
+{
+    return &conState;
+}
index 9d0bf0d..d1fe792 100644 (file)
 class ControllerState
 {
 public:
-    inline int getConFormIndex() {
-        return conFormIndex;
-    }
+    ControllerState();
 
+    void setConFormIndex(int index);
+    int getConFormIndex();
+
+    void setDockingCon(DockingController *con);
+    DockingController *getDockingCon();
+    void setRecentlyDockPos(int pos);
+    int getRecentlyDockPos();
+
+    void setFloatingCon(FloatingController *con);
+    FloatingController *getFloatingCon();
+    void setRecentlyFloatPos(QPoint pos);
+    QPoint getRecentlyFloatPos();
+
+private:
     int conFormIndex;
     DockingController *dockingCon;
-    FloatingController *floatingCon;
     int recentlyDockPos;
+    FloatingController *floatingCon;
     QPoint recentlyFloatPos;
 };
 
@@ -52,20 +64,22 @@ class UIState
 public:
     UIState();
 
+    void setMainFormIndex(int index);
     int getMainFormIndex(); /* current */
+    void setScalePct(int scalePct);
+    int getScalePct();
     qreal getScaleFactor(int scale);
     qreal getScaleFactor(); /* current */
-
     void setOnTop(bool on);
     bool isOnTop();
 
-    int mainFormIndex;
-    int mainFormScale; /* percentage */
-
-    ControllerState conState;
+    ControllerState *getConState();
 
 private:
+    int mainFormIndex;
+    int mainFormScalePct; /* percentage */
     bool onTop;
+    ControllerState conState;
 };
 
 #endif // UISTATE_H