skin: define menu XML schema 19/35119/4
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 6 Feb 2015 07:41:21 +0000 (16:41 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 9 Feb 2015 11:44:28 +0000 (20:44 +0900)
Change-Id: Ia516cab92ae28d9c9b484d2d88b50cc66f3cbb9e
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
15 files changed:
tizen/src/display/qt5_supplement.cpp
tizen/src/display/xmllayoutparser.cpp
tizen/src/display/xmllayoutparser.h
tizen/src/ui/menu/Makefile.objs
tizen/src/ui/menu/advancedmenuitem.cpp [new file with mode: 0644]
tizen/src/ui/menu/advancedmenuitem.h [new file with mode: 0644]
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/contextmenu.h
tizen/src/ui/menu/menuitem.cpp [new file with mode: 0644]
tizen/src/ui/menu/menuitem.h [new file with mode: 0644]
tizen/src/ui/menu/scalemenuitem.cpp [new file with mode: 0644]
tizen/src/ui/menu/scalemenuitem.h [new file with mode: 0644]
tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml
tizen/src/ui/uiinformation.cpp
tizen/src/ui/uiinformation.h

index ad0c64c85969a6d0e016aa2a926442e44cb33e18..4321bef6d13211dea1c7168b4b8f29826a1594f9 100644 (file)
@@ -380,7 +380,7 @@ void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
     QFileInfo fileInfo(*file);
     QXmlStreamReader xml(file);
 
-    XmlLayoutParser parser(fileInfo.absolutePath());
+    XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
 
     QXmlStreamReader::TokenType token;
     while (xml.atEnd() == false && xml.hasError() == false) {
@@ -395,12 +395,15 @@ void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
                 continue;
             }
 
-            if (xml.name() == "version") {
-                qDebug() << "xml version :" << xml.readElementText();
+            if (xml.name() == "layoutVersion") {
+                qDebug() << "layout version :" << xml.readElementText();
                 continue;
             } else if (xml.name() == "formList") {
                 int cnt = parser.parseMainFormList(xml, uiInfo->mainFormList);
                 qDebug("- formList : %d", cnt);
+            } else if (xml.name() == "menuList") {
+                int cnt = parser.parseMenuList(xml, uiInfo->menuList);
+                qDebug("- menuList : %d", cnt);
             }
         }
     }
@@ -433,7 +436,7 @@ void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
     QFileInfo fileInfo(*file);
     QXmlStreamReader xml(file);
 
-    XmlLayoutParser parser(fileInfo.absolutePath());
+    XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
 
     ControllerForm *form = NULL;
     QXmlStreamReader::TokenType token;
@@ -449,8 +452,8 @@ void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
                 continue;
             }
 
-            if (xml.name() == "version") {
-                qDebug() << "xml version :" << xml.readElementText();
+            if (xml.name() == "layoutVersion") {
+                qDebug() << "layout version :" << xml.readElementText();
                 continue;
             } else if (xml.name() == "form") {
                 form = parser.parseControllerForm(xml);
index 9719e5ae88217f091ba3c35fcfdce10abe2b9aed..00b250b4fdb1ee9aed5a8b6fb6e7e9a4ac2e438c 100644 (file)
  */
 
 #include "xmllayoutparser.h"
+#include "menu/advancedmenuitem.h"
+#include "menu/scalemenuitem.h"
 
-XmlLayoutParser::XmlLayoutParser(QString path)
+XmlLayoutParser::XmlLayoutParser(QString path, UIInformation *uiInfo)
 {
-    xmlPath = path;
+    this->xmlPath = path;
+    this->uiInfo = uiInfo;
 }
 
 QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml)
@@ -223,6 +226,163 @@ int XmlLayoutParser::parseMainFormList(
     return list.count();
 }
 
+/* menu */
+int XmlLayoutParser::parseFactorList(
+    QXmlStreamReader &xml, QList<int> &list)
+{
+    int factor = 0;
+    QXmlStreamReader::TokenType token = xml.readNext();
+
+    while (xml.atEnd() == false && (xml.name() == "factorList" &&
+        token == QXmlStreamReader::EndElement) == false) /* ~ </factorList> */
+    {
+        if (token == QXmlStreamReader::StartElement) {
+            if (xml.name() == "factor") {
+                factor = xml.readElementText().toInt();
+                if (factor > 0) {
+                    list.append(factor);
+                }
+            }
+        }
+
+        token = xml.readNext();
+    }
+
+    return list.count();
+}
+
+MenuItem *XmlLayoutParser::parseMenuItem(QXmlStreamReader &xml, int menuType)
+{
+    QString menuName = "";
+
+    /* attribute */
+    QXmlStreamAttributes attributes = xml.attributes();
+    if (attributes.hasAttribute("name")) {
+        menuName = attributes.value("name").toString();
+    }
+
+    // TODO: shortcut
+
+    switch (menuType) {
+    case MenuItemType::advancedItem:
+        return (MenuItem *)new AdvancedMenuItem(menuName);
+    case MenuItemType::scaleItem:
+        return (MenuItem *)new ScaleMenuItem(menuName);
+    }
+
+    return new MenuItem(menuType, menuName);
+}
+
+int XmlLayoutParser::parseMenuListItems(QXmlStreamReader &xml,
+    const QString &keyword, QList<MenuItem *> &list)
+{
+    MenuItem *item = NULL;
+    QXmlStreamReader::TokenType token = xml.readNext();
+
+    while (xml.atEnd() == false && (xml.name().compare(keyword) == 0 &&
+        token == QXmlStreamReader::EndElement) == false)
+    {
+        if (token == QXmlStreamReader::StartElement) {
+            if (xml.name() == "separator") {
+                item = new MenuItem(MenuItemType::separator, NULL);
+                list.append(item);
+
+                item = NULL;
+            } else if (xml.name() == "advancedList") {
+                item = parseMenuItem(xml, MenuItemType::advancedItem);
+                if (item != NULL) {
+                    list.append(item);
+
+                    int cnt = parseAdvancedMenuList(xml,
+                        ((AdvancedMenuItem *)item)->getMenuList());
+                    qDebug("- advanced menuList : %d", cnt);
+                }
+            } else if (xml.name() == "infoItem") {
+                item = parseMenuItem(xml, MenuItemType::infoItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "onTopItem") {
+                item = parseMenuItem(xml, MenuItemType::onTopItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "switchItem") {
+                item = parseMenuItem(xml, MenuItemType::switchItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "scaleItem") {
+                item = parseMenuItem(xml, MenuItemType::scaleItem);
+                if (item != NULL) {
+                    list.append(item);
+
+                    int cnt = parseFactorList(xml,
+                        ((ScaleMenuItem *)item)->getFactorList());
+                    qDebug("- scale factorList : %d", cnt);
+                }
+            } else if (xml.name() == "controllerItem") {
+                item = parseMenuItem(xml, MenuItemType::controllerItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "hostKeyboardItem") {
+                item = parseMenuItem(xml, MenuItemType::hostKeyboardItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "shellItem") {
+                item = parseMenuItem(xml, MenuItemType::shellItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "controlPanelItem") {
+                item = parseMenuItem(xml, MenuItemType::controlPanelItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "screenShotItem") {
+                item = parseMenuItem(xml, MenuItemType::screenShotItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "aboutItem") {
+                item = parseMenuItem(xml, MenuItemType::aboutItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "forceCloseItem") {
+                item = parseMenuItem(xml, MenuItemType::forceCloseItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            } else if (xml.name() == "closeItem") {
+                item = parseMenuItem(xml, MenuItemType::closeItem);
+                if (item != NULL) {
+                    list.append(item);
+                }
+            }
+        }
+
+        token = xml.readNext();
+    }
+
+    return list.count();
+}
+
+int XmlLayoutParser::parseAdvancedMenuList(
+    QXmlStreamReader &xml, QList<MenuItem *> &list)
+{
+    return parseMenuListItems(xml, "advancedList", list);
+}
+
+int XmlLayoutParser::parseMenuList(
+    QXmlStreamReader &xml, QList<MenuItem *> &list)
+{
+    return parseMenuListItems(xml, "menuList", list);
+}
+
+/* controller */
 ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
 {
     QString formName = "";
index 749e6133e75be61beb948303e1a5cc9cd9322d71..99a6d4a272abde2f5c74557aa459d52a6cc16f8b 100644 (file)
 #ifndef XMLLAYOUTPARSER_H
 #define XMLLAYOUTPARSER_H
 
- #include <QXmlStreamReader>
+#include <QXmlStreamReader>
 
+#include "uiinformation.h"
 #include "mainform.h"
+#include "menu/menuitem.h"
 #include "controllerform.h"
 
 class XmlLayoutParser
 {
 public:
-    XmlLayoutParser(QString path);
+    XmlLayoutParser(QString path, UIInformation *uiInfo /* out */);
 
+    int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list);
+    int parseMenuList(QXmlStreamReader &xml, QList<MenuItem *> &list);
+    ControllerForm *parseControllerForm(QXmlStreamReader &xml);
+
+private:
     QRect parseRegion(QXmlStreamReader &xml);
     DisplayType *parseDisplay(QXmlStreamReader &xml);
     HardwareKey *parseKey(QXmlStreamReader &xml);
     int parseKeyList(QXmlStreamReader &xml, QList<HardwareKey *> &list);
     MainForm *parseMainForm(QXmlStreamReader &xml);
-    int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list);
-    ControllerForm *parseControllerForm(QXmlStreamReader &xml);
 
-private:
+    int parseFactorList(QXmlStreamReader &xml, QList<int> &list);
+    MenuItem *parseMenuItem(QXmlStreamReader &xml, int menuType);
+    int parseMenuListItems(QXmlStreamReader &xml,
+        const QString &keyword, QList<MenuItem *> &list);
+    int parseAdvancedMenuList(
+        QXmlStreamReader &xml, QList<MenuItem *> &list);
+
     QString xmlPath;
+    UIInformation *uiInfo;
 };
 
 #endif // XMLLAYOUTPARSER_H
index 7e5454e15dcea0ea63208de070a6638b9972af4d..087c0405f49a59c00579695056a79d59dd183456 100644 (file)
@@ -2,6 +2,9 @@ obj-$(CONFIG_QT) += aboutdialog.o moc_aboutdialog.o
 obj-$(CONFIG_QT) += screenshot.o moc_screenshot.o
 obj-$(CONFIG_QT) += detailedinfodialog.o moc_detailedinfodialog.o
 obj-$(CONFIG_QT) += contextmenu.o moc_contextmenu.o
+obj-$(CONFIG_QT) += menuitem.o
+obj-$(CONFIG_QT) += advancedmenuitem.o
+obj-$(CONFIG_QT) += scalemenuitem.o
 obj-$(CONFIG_QT) += screenshotview.o
 
 $(obj)/moc_aboutdialog.o: $(obj)/moc_aboutdialog.cpp
diff --git a/tizen/src/ui/menu/advancedmenuitem.cpp b/tizen/src/ui/menu/advancedmenuitem.cpp
new file mode 100644 (file)
index 0000000..5f4eea4
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 "advancedmenuitem.h"
+
+AdvancedMenuItem::AdvancedMenuItem(QString name) :
+    MenuItem(MenuItemType::advancedItem, name)
+{
+    /* do nothing */
+}
+
+QList<MenuItem *> &AdvancedMenuItem::getMenuList()
+{
+    return menuList;
+}
+
+AdvancedMenuItem::~AdvancedMenuItem()
+{
+    qDebug("destroy an advanced menu item");
+
+    for (int i = 0; i < menuList.count(); i++) {
+        delete menuList.at(i);
+    }
+    menuList.clear();
+}
diff --git a/tizen/src/ui/menu/advancedmenuitem.h b/tizen/src/ui/menu/advancedmenuitem.h
new file mode 100644 (file)
index 0000000..5ff6d4f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 ADVANCEDMENUITEM_H
+#define ADVANCEDMENUITEM_H
+
+#include <QList>
+
+#include "menu/menuitem.h"
+
+class AdvancedMenuItem : MenuItem
+{
+public:
+    AdvancedMenuItem(QString name);
+    ~AdvancedMenuItem();
+
+    QList<MenuItem *> &getMenuList();
+
+private:
+    QList<MenuItem *> menuList;
+};
+
+#endif // ADVANCEDMENUITEM_H
index c3d11dc261988ea0122bc17e91cfec46f3ab9f8a..8c3e6e553225dbb0a211c0fb96387ba2e4cae871 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "contextmenu.h"
 #include "mainwindow.h"
+#include "menu/advancedmenuitem.h"
+#include "menu/scalemenuitem.h"
 
 #ifdef CONFIG_WIN32
 #include <windows.h>
@@ -46,132 +48,222 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent)
     this->infoDialog = NULL;
     this->aboutDialog = NULL;
     this->screenshotDialog = NULL;
-    this->vmName = ((MainWindow *)parent)->uiInfo->vmName + " : "
+    this->vmName = this->parent->uiInfo->vmName + " : "
         + QString::number(get_device_serial_number());
 
+    advancedMenu = NULL;
+    switchMenu = NULL;
+    scaleMenu = NULL;
+    controllerMenu = NULL;
+
     actionDetailedInfo = NULL;
     actionTopMost = NULL;
     actionShell = NULL;
     actionControlPanel = NULL;
+    actionScreenShot = NULL;
     actionAbout = NULL;
     actionForceClose = NULL;
     actionClose = NULL;
 
     longPressTimer = new QTimer(this);
 
-    createItems();
+    createItems(this, this->parent->uiInfo->menuList);
 
     installEventFilter(this);
 }
 
-void ContextMenu::createItems() {
-    MainWindow *win = parent;
-    QAction *action = NULL;
+void ContextMenu::createItems(QMenu *menu, QList<MenuItem *> &list)
+{
+    MenuItem *item = NULL;
+
+    for (int i = 0; i < list.count(); i++) {
+        item = list.at(i);
+
+        switch (item->getType()) {
+        case MenuItemType::separator:
+            createSeparator(menu);
+            break;
+        case MenuItemType::advancedItem:
+            /* Advanced menu */
+            createAdvancedItem(menu, item);
+            break;
+        case MenuItemType::infoItem:
+            /* Detailed Info menu */
+            createInfoItem(menu, item);
+            break;
+        case MenuItemType::onTopItem:
+            /* Always On Top menu */
+            createOnTopItem(menu, item);
+            break;
+        case MenuItemType::switchItem:
+            /* Rotate menu */
+            createSwitchItem(menu, item);
+            break;
+        case MenuItemType::scaleItem:
+            /* Scale menu */
+            createScaleItem(menu, item);
+            break;
+        case MenuItemType::controllerItem:
+            /* Controller menu */
+            createControllerItem(menu, item);
+            break;
+        case MenuItemType::hostKeyboardItem:
+            /* Host Keyboard menu */
+            createHostKeyboardItem(menu, item);
+            break;
+        case MenuItemType::shellItem:
+            /* Shell menu */
+            createShellItem(menu, item);
+            break;
+        case MenuItemType::controlPanelItem:
+            /* Control Panel menu */
+            createControlPanelItem(menu, item);
+            break;
+        case MenuItemType::screenShotItem:
+            /* Screen Shot menu */
+            createScreenShotItem(menu, item);
+            break;
+        case MenuItemType::aboutItem:
+            /* About menu */
+            createAboutItem(menu, item);
+            break;
+        case MenuItemType::forceCloseItem:
+            /* Force Close menu */
+            createForceCloseItem(menu, item);
+            break;
+        case MenuItemType::closeItem:
+            /* Close menu */
+            createCloseItem(menu, item);
+            break;
+        default:
+            qWarning("unknown menu item type : %d", item->getType());
+        }
+    }
+}
 
-    /* Detailed Info menu */
-    actionDetailedInfo = addGeneralAction(this, vmName,
-        QIcon(QPixmap(":/icons/detailed_info.png")), SLOT(slotDetailedInfo()));
+void ContextMenu::createSeparator(QMenu *menu)
+{
+    menu->addSeparator();
+}
 
-    addSeparator();
+void ContextMenu::createAdvancedItem(QMenu *menu, MenuItem *item)
+{
+    QString menuName = item->getName();
+    advancedMenu = menu->addMenu(QIcon(QPixmap(":/icons/advanced.png")),
+        menuName.isEmpty() ? "Advanced" : menuName);
+
+    createItems(advancedMenu, ((AdvancedMenuItem *)item)->getMenuList());
+}
+
+void ContextMenu::createInfoItem(QMenu *menu, MenuItem *item)
+{
+    QString menuName = item->getName();
+    actionDetailedInfo = addGeneralAction(menu, menuName.isEmpty() ? vmName : menuName,
+        QIcon(QPixmap(":/icons/detailed_info.png")), SLOT(slotDetailedInfo()));
+}
 
-    /* Always On Top menu */
-    actionTopMost = addAction("&Always on Top");
+void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item)
+{
+    actionTopMost = menu->addAction(item->getName());
     actionTopMost->setCheckable(true);
     connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool)));
+}
+
+void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item)
+{
+    QList<MainForm *> mainFormList = parent->uiInfo->mainFormList;
 
-    /* = Rotate menu = */
-    if (win->uiInfo->mainFormList.isEmpty() == false) {
-        QMenu *switchMenu = addMenu(QIcon(QPixmap(":/icons/rotate.png")), "&Rotate");
+    if (mainFormList.isEmpty() == false) {
+        switchMenu = menu->addMenu(
+            QIcon(QPixmap(":/icons/rotate.png")), item->getName());
         QActionGroup *switchGroup = new QActionGroup(this);
         switchMapper = new QSignalMapper(this);
         connect(switchMapper, SIGNAL(mapped(int)), this, SLOT(slotSwitch(int)));
 
-        for (int i = 0; i < win->uiInfo->mainFormList.count(); i++) {
-            action = switchMenu->addAction(win->uiInfo->mainFormList.at(i)->getName());
+        QAction *action = NULL;
+        for (int i = 0; i < mainFormList.count(); i++) {
+            action = switchMenu->addAction(mainFormList.at(i)->getName());
             action->setActionGroup(switchGroup);
             action->setCheckable(true);
             switchMapper->setMapping(action, i);
             connect(action, SIGNAL(triggered()), switchMapper, SLOT(map()));
         }
 
-        action = (QAction *)switchMapper->mapping(win->getUIState()->getMainFormIndex());
+        action = (QAction *) switchMapper->mapping(
+            parent->getUIState()->getMainFormIndex());
         action->setChecked(true);
+    } else {
+        qWarning("cannot create a switchItem");
     }
-    /* =============== */
-
-    /* = Scale menu = */
-    QMenu *scaleMenu = addMenu(QIcon(QPixmap(":/icons/scale.png")), "&Scale");
-    QActionGroup *scaleGroup = new QActionGroup(this);
-    scaleMapper = new QSignalMapper(this);
-    connect(scaleMapper, SIGNAL(mapped(int)), this, SLOT(slotScale(int)));
-
-    action = scaleMenu->addAction("1x");
-    action->setActionGroup(scaleGroup);
-    action->setCheckable(true);
-    scaleMapper->setMapping(action, 100);
-    connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
-
-    action = scaleMenu->addAction("3/4x");
-    action->setActionGroup(scaleGroup);
-    action->setCheckable(true);
-    scaleMapper->setMapping(action, 75);
-    connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
+}
 
-    action = scaleMenu->addAction("1/2x");
-    action->setActionGroup(scaleGroup);
-    action->setCheckable(true);
-    scaleMapper->setMapping(action, 50);
-    connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
+void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item)
+{
+    QList<int> factorList = ((ScaleMenuItem *)item)->getFactorList();
+
+    if (factorList.isEmpty() == false) {
+        scaleMenu = menu->addMenu(
+            QIcon(QPixmap(":/icons/scale.png")), item->getName());
+        QActionGroup *scaleGroup = new QActionGroup(this);
+        scaleMapper = new QSignalMapper(this);
+        connect(scaleMapper, SIGNAL(mapped(int)), this, SLOT(slotScale(int)));
+
+        QAction *action = NULL;
+        for (int i = 0; i < factorList.count(); i++) {
+            action = scaleMenu->addAction(QString::number(factorList.at(i)) + "%");
+            action->setActionGroup(scaleGroup);
+            action->setCheckable(true);
+            scaleMapper->setMapping(action, factorList.at(i));
+            connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
+        }
 
-    action = scaleMenu->addAction("1/4x");
-    action->setActionGroup(scaleGroup);
-    action->setCheckable(true);
-    scaleMapper->setMapping(action, 25);
-    connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
+        // TODO: interpolation
 
-    // TODO: interpolation
+        action = (QAction *) scaleMapper->mapping(
+            parent->getUIState()->mainFormScale);
+        action->setChecked(true);
+    } else {
+        qWarning("cannot create a scaleItem");
+    }
+}
 
-    action = (QAction *)scaleMapper->mapping(win->getUIState()->mainFormScale);
-    action->setChecked(true);
-    /* ============== */
+void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item)
+{
+    QList<ControllerForm *> conFormList = parent->uiInfo->conFormList;
 
-    /* = Controller menu = */
-    if (win->uiInfo->conFormList.isEmpty() == false) {
-        QMenu *controllerMenu = addMenu("Con&troller");
+    if (conFormList.isEmpty() == false) {
+        controllerMenu = menu->addMenu(item->getName());
         QActionGroup *controllerGroup = new QActionGroup(this);
         controllerMapper = new QSignalMapper(this);
-        connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int)));
+        connect(controllerMapper, SIGNAL(mapped(int)), this,
+            SLOT(slotController(int)));
 
+        QAction *action = NULL;
         action = controllerMenu->addAction("None");
         action->setActionGroup(controllerGroup);
         action->setCheckable(true);
         action->setChecked(true);
         connect(action, SIGNAL(triggered()), this, SLOT(slotCloseCon()));
 
-        for (int i = 0; i < win->uiInfo->conFormList.count(); i++) {
-            action = controllerMenu->addAction(win->uiInfo->conFormList.at(i)->getName());
+        for (int i = 0; i < conFormList.count(); i++) {
+            action = controllerMenu->addAction(conFormList.at(i)->getName());
             action->setActionGroup(controllerGroup);
             action->setCheckable(true);
             controllerMapper->setMapping(action, i);
             connect(action, SIGNAL(triggered()), controllerMapper, SLOT(map()));
         }
+    } else {
+        qWarning("cannot create a controllerItem");
     }
+}
 
-    addSeparator();
-
-    /* = Advanced menu = */
-    QMenu *advancedMenu = addMenu(QIcon(QPixmap(":/icons/advanced.png")), "Ad&vanced");
-
-    /* Advanced > Screen Shot menu */
-    action = addGeneralAction(advancedMenu, "&Screen Shot",
-        QIcon(QPixmap(":/icons/screen_shot.png")), SLOT(slotRequestScreenshot()));
-
-    /* = Host Keyboard menu = */
-    QMenu *keyboardMenu = advancedMenu->addMenu(
-        QIcon(QPixmap(":/icons/host_keyboard.png")), "&Host Keyboard");
+void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item)
+{
+    QMenu *keyboardMenu = menu->addMenu(
+        QIcon(QPixmap(":/icons/host_keyboard.png")), item->getName());
     QActionGroup *keyboardGroup = new QActionGroup(this);
 
-    action = keyboardMenu->addAction("On");
+    QAction *action = keyboardMenu->addAction("On");
     action->setActionGroup(keyboardGroup);
     action->setCheckable(true);
     connect(action, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool)));
@@ -180,30 +272,42 @@ void ContextMenu::createItems() {
     action->setActionGroup(keyboardGroup);
     action->setCheckable(true);
     action->setChecked(true);
+}
 
-    advancedMenu->addSeparator();
-
-    /* Advanced > About menu */
-    actionAbout = addGeneralAction(advancedMenu, "&About",
-        QIcon(QPixmap(":/icons/about.png")), SLOT(slotAbout()));
-
-    /* Advanced > Force Close menu */
-    actionForceClose = addGeneralAction(advancedMenu, "&Force Close",
-        QIcon(QPixmap(":/icons/force_close.png")), SLOT(slotForceClose()));
-    /* ================= */
-
-    /* Shell menu */
-    actionShell = addGeneralAction(this, "S&hell",
+void ContextMenu::createShellItem(QMenu *menu, MenuItem *item)
+{
+    actionShell = addGeneralAction(menu, item->getName(),
         QIcon(QPixmap(":/icons/shell.png")), SLOT(slotShell()));
+}
 
-    /* Control Panel menu */
-    actionControlPanel = addGeneralAction(this, "Control &Panel",
+void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item)
+{
+    actionControlPanel = addGeneralAction(menu, item->getName(),
         QIcon(QPixmap(":/icons/control_panel.png")), SLOT(slotControlPanel()));
+}
+
+void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item)
+{
+    actionScreenShot = addGeneralAction(menu, item->getName(),
+        QIcon(QPixmap(":/icons/screen_shot.png")),
+        SLOT(slotRequestScreenshot()));
+}
 
-    addSeparator();
+void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item)
+{
+    actionAbout = addGeneralAction(menu, item->getName(),
+        QIcon(QPixmap(":/icons/about.png")), SLOT(slotAbout()));
+}
+
+void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item)
+{
+    actionForceClose = addGeneralAction(menu, item->getName(),
+        QIcon(QPixmap(":/icons/force_close.png")), SLOT(slotForceClose()));
+}
 
-    /* Close menu */
-    actionClose = addGeneralAction(this, "&Close",
+void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item)
+{
+    actionClose = addGeneralAction(menu, item->getName(),
         QIcon(QPixmap(":/icons/close.png")), SLOT(slotClose()));
 }
 
@@ -224,7 +328,7 @@ bool ContextMenu::eventFilter(QObject *obj, QEvent *event)
     if (menu != NULL &&
         (event->type() == QEvent::MouseButtonPress ||
             event->type() == QEvent::MouseButtonRelease)) {
-        QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
+        QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>(event);
 
         if (mouseEvent != NULL && mouseEvent->button() == Qt::RightButton) {
             mouseEvent->ignore(); /* filtering */
@@ -486,9 +590,8 @@ void ContextMenu::slotControlPanel()
 {
     qDebug("Control Panel");
 
-    MainWindow *win = (MainWindow *)parent;
-    QString basePortOpt = "base.port=" + QString::number(win->uiInfo->basePort);
-    QString vmNameOpt = "vmname=" + win->uiInfo->vmName;
+    QString basePortOpt = "base.port=" + QString::number(parent->uiInfo->basePort);
+    QString vmNameOpt = "vmname=" + parent->uiInfo->vmName;
 
     QString ecpPath = QCoreApplication::applicationDirPath();
 #ifdef CONFIG_WIN32
index 20f5f832009cad8491934a90d28346b0ff2c1527..a6d7cbb85d788a63c8c35054ff71f8907194c1dd 100644 (file)
@@ -36,6 +36,7 @@
 #include "detailedinfodialog.h"
 #include "aboutdialog.h"
 #include "screenshot.h"
+#include "menu/menuitem.h"
 
 class MainWindow;
 
@@ -82,7 +83,22 @@ public slots:
     void slotPwkeyRelease();
 
 protected:
-    void createItems();
+    void createItems(QMenu *menu, QList<MenuItem *> &list);
+    void createSeparator(QMenu *menu);
+    void createAdvancedItem(QMenu *menu, MenuItem *item);
+
+    void createInfoItem(QMenu *menu, MenuItem *item);
+    void createOnTopItem(QMenu *menu, MenuItem *item);
+    void createSwitchItem(QMenu *menu, MenuItem *item);
+    void createScaleItem(QMenu *menu, MenuItem *item);
+    void createControllerItem(QMenu *menu, MenuItem *item);
+    void createHostKeyboardItem(QMenu *menu, MenuItem *item);
+    void createShellItem(QMenu *menu, MenuItem *item);
+    void createControlPanelItem(QMenu *menu, MenuItem *item);
+    void createScreenShotItem(QMenu *menu, MenuItem *item);
+    void createAboutItem(QMenu *menu, MenuItem *item);
+    void createForceCloseItem(QMenu *menu, MenuItem *item);
+    void createCloseItem(QMenu *menu, MenuItem *item);
     bool eventFilter(QObject *obj, QEvent *event);
 
 private:
@@ -96,16 +112,22 @@ private:
     AboutDialog *aboutDialog;
     QTimer *longPressTimer;
 
-    QSignalMapper *switchMapper;
-    QSignalMapper *scaleMapper;
-    QSignalMapper *controllerMapper;
+    QMenu *advancedMenu;
+    QMenu *switchMenu;
+    QMenu *scaleMenu;
+    QMenu *controllerMenu;
 
     QAction *actionDetailedInfo;
     QAction *actionTopMost;
     QAction *actionShell;
     QAction *actionControlPanel;
+    QAction *actionScreenShot;
     QAction *actionAbout;
     QAction *actionForceClose;
     QAction *actionClose;
+
+    QSignalMapper *switchMapper;
+    QSignalMapper *scaleMapper;
+    QSignalMapper *controllerMapper;
 };
 #endif // CONTEXTMENU_H
diff --git a/tizen/src/ui/menu/menuitem.cpp b/tizen/src/ui/menu/menuitem.cpp
new file mode 100644 (file)
index 0000000..68fd3a5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 "menuitem.h"
+
+MenuItem::MenuItem(int type, QString name)
+{
+    this->type = type;
+    this->name = name;
+}
+
+int MenuItem::getType()
+{
+    return type;
+}
+
+QString MenuItem::getName()
+{
+    return name;
+}
+
+MenuItem::~MenuItem()
+{
+    /* do nothing */
+}
diff --git a/tizen/src/ui/menu/menuitem.h b/tizen/src/ui/menu/menuitem.h
new file mode 100644 (file)
index 0000000..a1586d1
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 MENUITEM_H
+#define MENUITEM_H
+
+#include <QString>
+
+namespace MenuItemType
+{
+    enum {
+        separator,
+        advancedItem,
+        infoItem,
+        onTopItem,
+        switchItem,
+        scaleItem,
+        controllerItem,
+        hostKeyboardItem,
+        shellItem,
+        controlPanelItem,
+        screenShotItem,
+        aboutItem,
+        forceCloseItem,
+        closeItem,
+    };
+}
+
+class MenuItem
+{
+public:
+    MenuItem(int type, QString name);
+    ~MenuItem();
+
+    int getType();
+    QString getName();
+
+private:
+    int type;
+    QString name;
+};
+
+#endif // MENUITEM_H
diff --git a/tizen/src/ui/menu/scalemenuitem.cpp b/tizen/src/ui/menu/scalemenuitem.cpp
new file mode 100644 (file)
index 0000000..ecd45ca
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 "scalemenuitem.h"
+
+ScaleMenuItem::ScaleMenuItem(QString name) :
+    MenuItem(MenuItemType::scaleItem, name)
+{
+    /* do nothing */
+}
+
+QList<int> &ScaleMenuItem::getFactorList()
+{
+    return factorList;
+}
+
+ScaleMenuItem::~ScaleMenuItem()
+{
+    qDebug("destroy a scale menu item");
+
+    factorList.clear();
+}
diff --git a/tizen/src/ui/menu/scalemenuitem.h b/tizen/src/ui/menu/scalemenuitem.h
new file mode 100644 (file)
index 0000000..f413d81
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 SCALEMENUITEM_H
+#define SCALEMENUITEM_H
+
+#include <QList>
+
+#include "menu/menuitem.h"
+
+class ScaleMenuItem : MenuItem
+{
+public:
+    ScaleMenuItem(QString name);
+    ~ScaleMenuItem();
+
+    QList<int> &getFactorList();
+
+private:
+    QList<int> factorList;
+};
+
+#endif // SCALEMENUITEM_H
index 3516246c07ebc394b5fd0f3d3b652347481be2e4..50051c786e1aa1fb20e2d62fc877398c9d8563f3 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <EmulatorUI xmlns="http://www.tizen.org/emulator/ui/layout">
-    <dbi_version>2.4</dbi_version>
+    <layoutVersion>2.4</layoutVersion>
     <formList>
         <form name="Portrait">
             <display>
             </keyList>
         </form>
     </formList>
+
+    <menuList>
+        <infoItem>
+            <shortcut>Ctrl+F1</shortcut>
+        </infoItem>
+        <separator/>
+        <onTopItem name="Always on Top">
+            <shortcut>Ctrl+F2</shortcut>
+        </onTopItem>
+        <switchItem name="Rotate">
+            <shortcut property="up">Ctrl+Num7</shortcut>
+            <shortcut property="down">Ctrl+Num9</shortcut>
+        </switchItem>
+        <scaleItem name="Scale">
+            <shortcut property="up">Ctrl+F9</shortcut>
+            <shortcut property="down">Ctrl+F10</shortcut>
+            <factorList>
+                <factor>100</factor>
+                <factor>75</factor>
+                <factor>50</factor>
+                <factor>25</factor>
+            </factorList>
+        </scaleItem>
+        <separator/>
+        <advancedList>
+            <screenShotItem name="Screen Shot">
+                <shortcut>Ctrl+F7</shortcut>
+            </screenShotItem>
+            <separator/>
+            <aboutItem name="About"/>
+            <forceCloseItem name="Force Close">
+                <shortcut>Ctrl+F4</shortcut>
+            </forceCloseItem>
+        </advancedList>
+        <shellItem name="Shell">
+            <shortcut>Ctrl+F5</shortcut>
+        </shellItem>
+        <controlPanelItem name="Control Panel">
+            <shortcut>Ctrl+F6</shortcut>
+        </controlPanelItem>
+        <closeItem name="Close">
+            <shortcut>F4</shortcut>
+        </closeItem>
+    </menuList>
+
 </EmulatorUI>
index aae6c92550cbab506aeb0fc569e99299c49f4eaa..44d1d22e3181a2380c7791f1eb04007875b5cc9b 100644 (file)
@@ -173,4 +173,9 @@ UIInformation::~UIInformation()
         delete conFormList.at(i);
     }
     conFormList.clear();
+
+    for (int i = 0; i < menuList.count(); i++) {
+        delete menuList.at(i);
+    }
+    menuList.clear();
 }
index 4c172b960d63ab2f30d3ef79832524ab1dd5cd5e..0bc0436d46ad9d20827b1b39d34e3a1f763eb86c 100644 (file)
@@ -35,6 +35,7 @@
 #include "mainform.h"
 #include "uistate.h"
 #include "controllerform.h"
+#include "menu/menuitem.h"
 
 class UIInformation
 {
@@ -51,6 +52,7 @@ public:
     QString skinName;
     QList<MainForm *> mainFormList;
     QList<ControllerForm *> conFormList;
+    QList<MenuItem *> menuList;
     QColor hoverColor;
 
     UIState uiState; /* runtime information */