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) {
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);
}
}
}
QFileInfo fileInfo(*file);
QXmlStreamReader xml(file);
- XmlLayoutParser parser(fileInfo.absolutePath());
+ XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
ControllerForm *form = NULL;
QXmlStreamReader::TokenType token;
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);
*/
#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)
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 = "";
#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
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
--- /dev/null
+/*
+ * 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();
+}
--- /dev/null
+/*
+ * 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
#include "contextmenu.h"
#include "mainwindow.h"
+#include "menu/advancedmenuitem.h"
+#include "menu/scalemenuitem.h"
#ifdef CONFIG_WIN32
#include <windows.h>
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)));
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()));
}
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 */
{
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
#include "detailedinfodialog.h"
#include "aboutdialog.h"
#include "screenshot.h"
+#include "menu/menuitem.h"
class MainWindow;
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:
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
--- /dev/null
+/*
+ * 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 */
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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();
+}
--- /dev/null
+/*
+ * 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
<?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>
delete conFormList.at(i);
}
conFormList.clear();
+
+ for (int i = 0; i < menuList.count(); i++) {
+ delete menuList.at(i);
+ }
+ menuList.clear();
}
#include "mainform.h"
#include "uistate.h"
#include "controllerform.h"
+#include "menu/menuitem.h"
class UIInformation
{
QString skinName;
QList<MainForm *> mainFormList;
QList<ControllerForm *> conFormList;
+ QList<MenuItem *> menuList;
QColor hoverColor;
UIState uiState; /* runtime information */