From: GiWoong Kim Date: Wed, 4 Feb 2015 03:03:14 +0000 (+0900) Subject: menu: some code cleanup X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~579 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f02742853c4af164cfbc33c749798ec62a7445e2;p=sdk%2Femulator%2Fqemu.git menu: some code cleanup add formList XML parsing declare addGeneralAction func add layout.xml file for wearable skin delete unused qml files Change-Id: Ib7f2e09e073ca1a8c352345332e7c347eb8bcbd2 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 9ed9938325..ad0c64c859 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -380,9 +380,8 @@ void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */) QFileInfo fileInfo(*file); QXmlStreamReader xml(file); - XmlLayoutParser parser; + XmlLayoutParser parser(fileInfo.absolutePath()); - MainForm *form = NULL; QXmlStreamReader::TokenType token; while (xml.atEnd() == false && xml.hasError() == false) { token = xml.readNext(); @@ -399,11 +398,9 @@ void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */) if (xml.name() == "version") { qDebug() << "xml version :" << xml.readElementText(); continue; - } else if (xml.name() == "form") { // TODO: formList - form = parser.parseMainForm(xml, fileInfo.absolutePath()); - if (form != NULL) { - uiInfo->mainFormList.append(form); - } + } else if (xml.name() == "formList") { + int cnt = parser.parseMainFormList(xml, uiInfo->mainFormList); + qDebug("- formList : %d", cnt); } } } @@ -436,7 +433,7 @@ void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */) QFileInfo fileInfo(*file); QXmlStreamReader xml(file); - XmlLayoutParser parser; + XmlLayoutParser parser(fileInfo.absolutePath()); ControllerForm *form = NULL; QXmlStreamReader::TokenType token; @@ -456,7 +453,7 @@ void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */) qDebug() << "xml version :" << xml.readElementText(); continue; } else if (xml.name() == "form") { - form = parser.parseControllerForm(xml, fileInfo.absolutePath()); + form = parser.parseControllerForm(xml); if (form != NULL) { uiInfo->conFormList.append(form); } diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp index f824aad511..9719e5ae88 100644 --- a/tizen/src/display/xmllayoutparser.cpp +++ b/tizen/src/display/xmllayoutparser.cpp @@ -29,9 +29,9 @@ #include "xmllayoutparser.h" -XmlLayoutParser::XmlLayoutParser() +XmlLayoutParser::XmlLayoutParser(QString path) { - /* do nothing */ + xmlPath = path; } QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml) @@ -149,8 +149,7 @@ int XmlLayoutParser::parseKeyList( return list.count(); } -MainForm *XmlLayoutParser::parseMainForm( - QXmlStreamReader &xml, QString skinPath) +MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml) { QString formName = ""; @@ -177,14 +176,14 @@ MainForm *XmlLayoutParser::parseMainForm( qDebug() << "- normalImage :" << normalImageFileName; form->skinImg[MainForm::normal].load( - skinPath + QDir::separator() + normalImageFileName); + xmlPath + QDir::separator() + normalImageFileName); } else if (xml.name() == "pressedImage") { /* key pressed image */ QString pressedImageFileName = xml.readElementText(); qDebug() << "- pressedImage :" << pressedImageFileName; form->skinImg[MainForm::pressed].load( - skinPath + QDir::separator() + pressedImageFileName); + xmlPath + QDir::separator() + pressedImageFileName); } else if (xml.name() == "keyList") { /* HW keys */ int cnt = parseKeyList(xml, form->keyList); @@ -200,8 +199,31 @@ MainForm *XmlLayoutParser::parseMainForm( return form; } -ControllerForm *XmlLayoutParser::parseControllerForm( - QXmlStreamReader &xml, QString skinPath) +int XmlLayoutParser::parseMainFormList( + QXmlStreamReader &xml, QList &list) +{ + MainForm *form = NULL; + QXmlStreamReader::TokenType token = xml.readNext(); + + while (xml.atEnd() == false && (xml.name() == "formList" && + token == QXmlStreamReader::EndElement) == false) /* ~ */ + { + if (token == QXmlStreamReader::StartElement) { + if (xml.name() == "form") { + form = parseMainForm(xml); + if (form != NULL) { + list.append(form); + } + } + } + + token = xml.readNext(); + } + + return list.count(); +} + +ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml) { QString formName = ""; @@ -212,7 +234,7 @@ ControllerForm *XmlLayoutParser::parseControllerForm( } ControllerForm *form = new ControllerForm( - formName.isEmpty() ? skinPath.section(QDir::separator(), -1) : formName); + formName.isEmpty() ? xmlPath.section(QDir::separator(), -1) : formName); QXmlStreamReader::TokenType token = xml.readNext(); @@ -226,14 +248,14 @@ ControllerForm *XmlLayoutParser::parseControllerForm( qDebug() << "- normalImage :" << normalImageFileName; form->conImg[ControllerForm::normal].load( - skinPath + QDir::separator() + normalImageFileName); + xmlPath + QDir::separator() + normalImageFileName); } else if (xml.name() == "pressedImage") { /* key pressed image */ QString pressedImageFileName = xml.readElementText(); qDebug() << "- pressedImage :" << pressedImageFileName; form->conImg[ControllerForm::pressed].load( - skinPath + QDir::separator() + pressedImageFileName); + xmlPath + QDir::separator() + pressedImageFileName); } else if (xml.name() == "keyList") { /* HW keys */ int cnt = parseKeyList(xml, form->keyList); diff --git a/tizen/src/display/xmllayoutparser.h b/tizen/src/display/xmllayoutparser.h index c187eb511c..749e6133e7 100644 --- a/tizen/src/display/xmllayoutparser.h +++ b/tizen/src/display/xmllayoutparser.h @@ -38,17 +38,18 @@ class XmlLayoutParser { public: - XmlLayoutParser(); + XmlLayoutParser(QString path); QRect parseRegion(QXmlStreamReader &xml); DisplayType *parseDisplay(QXmlStreamReader &xml); HardwareKey *parseKey(QXmlStreamReader &xml); int parseKeyList(QXmlStreamReader &xml, QList &list); - MainForm *parseMainForm(QXmlStreamReader &xml, QString skinPath); - ControllerForm *parseControllerForm(QXmlStreamReader &xml, QString skinPath); + MainForm *parseMainForm(QXmlStreamReader &xml); + int parseMainFormList(QXmlStreamReader &xml, QList &list); + ControllerForm *parseControllerForm(QXmlStreamReader &xml); private: - + QString xmlPath; }; #endif // XMLLAYOUTPARSER_H diff --git a/tizen/src/ui/controllerform.cpp b/tizen/src/ui/controllerform.cpp index 7e6f47fcaf..d9a3e4976b 100644 --- a/tizen/src/ui/controllerform.cpp +++ b/tizen/src/ui/controllerform.cpp @@ -29,7 +29,7 @@ #include "controllerform.h" -ControllerForm::ControllerForm(QString name) +ControllerForm::ControllerForm(const QString &name) { this->name = name; } diff --git a/tizen/src/ui/controllerform.h b/tizen/src/ui/controllerform.h index e6e2183486..a78e58fe09 100644 --- a/tizen/src/ui/controllerform.h +++ b/tizen/src/ui/controllerform.h @@ -39,7 +39,7 @@ class ControllerForm Q_ENUMS(ConImgType) public: - ControllerForm(QString name); + ControllerForm(const QString &name); ~ControllerForm(); QString getName(); diff --git a/tizen/src/ui/mainform.cpp b/tizen/src/ui/mainform.cpp index 6bb55237b8..94e30e77aa 100644 --- a/tizen/src/ui/mainform.cpp +++ b/tizen/src/ui/mainform.cpp @@ -29,7 +29,7 @@ #include "mainform.h" -MainForm::MainForm(QString name) +MainForm::MainForm(const QString &name) { this->name = name; this->displayType = NULL; diff --git a/tizen/src/ui/mainform.h b/tizen/src/ui/mainform.h index 4462277998..c06eb5c70c 100644 --- a/tizen/src/ui/mainform.h +++ b/tizen/src/ui/mainform.h @@ -40,7 +40,7 @@ class MainForm Q_ENUMS(SkinImgType) public: - MainForm(QString name); + MainForm(const QString &name); ~MainForm(); QString getName(); diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index e5d255e423..c3d11dc261 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -69,9 +69,8 @@ void ContextMenu::createItems() { QAction *action = NULL; /* Detailed Info menu */ - actionDetailedInfo = addAction(vmName); - actionDetailedInfo->setIcon(QIcon(QPixmap(":/icons/detailed_info.png"))); - connect(actionDetailedInfo, SIGNAL(triggered()), this, SLOT(slotDetailedInfo())); + actionDetailedInfo = addGeneralAction(this, vmName, + QIcon(QPixmap(":/icons/detailed_info.png")), SLOT(slotDetailedInfo())); addSeparator(); @@ -138,7 +137,7 @@ void ContextMenu::createItems() { /* = Controller menu = */ if (win->uiInfo->conFormList.isEmpty() == false) { - QMenu *controllerMenu = addMenu("Controller"); + QMenu *controllerMenu = addMenu("Con&troller"); QActionGroup *controllerGroup = new QActionGroup(this); controllerMapper = new QSignalMapper(this); connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int))); @@ -164,9 +163,8 @@ void ContextMenu::createItems() { QMenu *advancedMenu = addMenu(QIcon(QPixmap(":/icons/advanced.png")), "Ad&vanced"); /* Advanced > Screen Shot menu */ - action = advancedMenu->addAction("Screen Shot"); - action->setIcon(QIcon(QPixmap(":/icons/screen_shot.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotRequestScreenshot())); + action = addGeneralAction(advancedMenu, "&Screen Shot", + QIcon(QPixmap(":/icons/screen_shot.png")), SLOT(slotRequestScreenshot())); /* = Host Keyboard menu = */ QMenu *keyboardMenu = advancedMenu->addMenu( @@ -186,32 +184,37 @@ void ContextMenu::createItems() { advancedMenu->addSeparator(); /* Advanced > About menu */ - actionAbout = advancedMenu->addAction("&About"); - actionAbout->setIcon(QIcon(QPixmap(":/icons/about.png"))); - connect(actionAbout, SIGNAL(triggered()), this, SLOT(slotAbout())); + actionAbout = addGeneralAction(advancedMenu, "&About", + QIcon(QPixmap(":/icons/about.png")), SLOT(slotAbout())); /* Advanced > Force Close menu */ - actionForceClose = advancedMenu->addAction("&Force Close"); - actionForceClose->setIcon(QIcon(QPixmap(":/icons/force_close.png"))); - connect(actionForceClose, SIGNAL(triggered()), this, SLOT(slotForceClose())); + actionForceClose = addGeneralAction(advancedMenu, "&Force Close", + QIcon(QPixmap(":/icons/force_close.png")), SLOT(slotForceClose())); /* ================= */ /* Shell menu */ - actionShell = addAction("S&hell"); - actionShell->setIcon(QIcon(QPixmap(":/icons/shell.png"))); - connect(actionShell, SIGNAL(triggered()), this, SLOT(slotShell())); + actionShell = addGeneralAction(this, "S&hell", + QIcon(QPixmap(":/icons/shell.png")), SLOT(slotShell())); /* Control Panel menu */ - actionControlPanel = addAction("Control &Panel"); - actionControlPanel->setIcon(QIcon(QPixmap(":/icons/control_panel.png"))); - connect(actionControlPanel, SIGNAL(triggered()), this, SLOT(slotControlPanel())); + actionControlPanel = addGeneralAction(this, "Control &Panel", + QIcon(QPixmap(":/icons/control_panel.png")), SLOT(slotControlPanel())); addSeparator(); /* Close menu */ - actionClose = addAction("&Close"); - actionClose->setIcon(QIcon(QPixmap(":/icons/close.png"))); - connect(actionClose, SIGNAL(triggered()), this, SLOT(slotClose())); + actionClose = addGeneralAction(this, "&Close", + QIcon(QPixmap(":/icons/close.png")), SLOT(slotClose())); +} + +QAction *ContextMenu::addGeneralAction(QMenu *menu, + const QString &text, const QIcon &icon, const char *slot) +{ + QAction *action = menu->addAction(text); + action->setIcon(icon); + connect(action, SIGNAL(triggered()), this, slot); + + return action; } bool ContextMenu::eventFilter(QObject *obj, QEvent *event) @@ -380,7 +383,7 @@ void ContextMenu::slotShell() try { QProcess::startDetached(command, arguments); - } catch (QString error) { + } catch (QString &error) { QString msg = "Failed to open Shell : " + error; qDebug() << msg; @@ -535,7 +538,7 @@ void ContextMenu::slotControlPanel() try { QProcess::startDetached(command, arguments); - } catch (QString error) { + } catch (QString &error) { showPopup("Failed to open Control Panel : " + error); return; } diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 3ee839956b..20f5f83200 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -58,6 +58,7 @@ public: QSignalMapper *getSwitchMapper(); QSignalMapper *getScaleMapper(); QSignalMapper *getControllerMapper(); + Screenshot *screenshotDialog; signals: @@ -85,8 +86,11 @@ protected: bool eventFilter(QObject *obj, QEvent *event); private: - MainWindow *parent; + QAction *addGeneralAction(QMenu *menu, + const QString &text, const QIcon &icon, const char *slot); + void showPopup(QString msg); + MainWindow *parent; QString vmName; DetailedInfoDialog *infoDialog; AboutDialog *aboutDialog; @@ -103,7 +107,5 @@ private: QAction *actionAbout; QAction *actionForceClose; QAction *actionClose; - - void showPopup(QString msg); }; #endif // CONTEXTMENU_H diff --git a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.qml b/tizen/src/ui/resource/mobile-720x1280-3btn/layout.qml deleted file mode 100644 index 012075db3d..0000000000 --- a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.qml +++ /dev/null @@ -1,147 +0,0 @@ -import EmulatorComponent 1.0 - -EmulatorUI { - property string version: "1.0" - - FormList { - Form { - objectName: "portrait" - display: Region { left: 67; top: 116; width: 720; height: 1280 } - - mainImage: "default_0.png" - pressedImage: "default_0_p.png" - - KeyList { - Key { objectName: "Menu"; keycode: 169 - Region { left: 210; top: 1401; width: 84; height: 84 } - tooltip: "Menu" - } - Key { objectName: "Home"; keycode: 139 - Region { left: 390; top: 1401; width: 84; height: 84 } - tooltip: "Home" - } - Key { objectName: "Back"; keycode: 158 - Region { left: 570; top: 1401; width: 84; height: 84 } - tooltip: "Back" - } - Key { objectName: "Power"; keycode: 116 - Region { left: 841; top: 1309; width: 24; height: 96 } - tooltip: "Power" - } - Key { objectName: "Volume +"; keycode: 115 - Region { left: 841; top: 108; width: 24; height: 96 } - tooltip: "Volume +" - } - Key { objectName: "Volume -"; keycode: 114 - Region { left: 841; top: 219; width: 24; height: 96 } - tooltip: "Volume -" - } - } - } - - Form { - objectName: "landscape" - display: Region { left: 116; top: 78; width: 1280; height: 720 } - - mainImage: "default_L90.png" - pressedImage: "default_L90_p.png" - - KeyList { - Key { objectName: "Menu"; keycode: 169 - Region { left: 1400; top: 570; width: 84; height: 84 } - tooltip: "Menu" - } - Key { objectName: "Home"; keycode: 139 - Region { left: 1400; top: 392; width: 84; height: 84 } - tooltip: "Home" - } - Key { objectName: "Back"; keycode: 158 - Region { left: 1400; top: 210; width: 84; height: 84 } - tooltip: "Back" - } - Key { objectName: "Power"; keycode: 116 - Region { left: 1308; top: 2; width: 96; height: 24 } - tooltip: "Power" - } - Key { objectName: "Volume +"; keycode: 115 - Region { left: 108; top: 2; width: 96; height: 24 } - tooltip: "Volume +" - } - Key { objectName: "Volume -"; keycode: 114 - Region { left: 217; top: 2; width: 96; height: 24 } - tooltip: "Volume -" - } - } - } - - Form { - objectName: "reverse portrait" - display: Region { left: 78; top: 117; width: 720; height: 1280 } - - mainImage: "default_180.png" - pressedImage: "default_180_p.png" - - KeyList { - Key { objectName: "Menu"; keycode: 169 - Region { left: 570; top: 30; width: 84; height: 84 } - tooltip: "Menu" - } - Key { objectName: "Home"; keycode: 139 - Region { left: 390; top: 30; width: 84; height: 84 } - tooltip: "Home" - } - Key { objectName: "Back"; keycode: 158 - Region { left: 210; top: 30; width: 84; height: 84 } - tooltip: "Back" - } - Key { objectName: "Power"; keycode: 116 - Region { left: 2; top: 110; width: 24; height: 96 } - tooltip: "Power" - } - Key { objectName: "Volume +"; keycode: 115 - Region { left: 2; top: 1310; width: 24; height: 96 } - tooltip: "Volume +" - } - Key { objectName: "Volume -"; keycode: 114 - Region { left: 2; top: 1200; width: 24; height: 96 } - tooltip: "Volume -" - } - } - } - - Form { - objectName: "reverse landscape" - display: Region { left: 117; top: 67; width: 1280; height: 720 } - - mainImage: "default_R90.png" - pressedImage: "default_R90_p.png" - - KeyList { - Key { objectName: "Menu"; keycode: 169 - Region { left: 28; top: 209; width: 84; height: 84 } - tooltip: "Menu" - } - Key { objectName: "Home"; keycode: 139 - Region { left: 28; top: 391; width: 84; height: 84 } - tooltip: "Home" - } - Key { objectName: "Back"; keycode: 158 - Region { left: 28; top: 568; width: 84; height: 84 } - tooltip: "Back" - } - Key { objectName: "Power"; keycode: 116 - Region { left: 109; top: 841; width: 96; height: 24 } - tooltip: "Power" - } - Key { objectName: "Volume +"; keycode: 115 - Region { left: 1309; top: 841; width: 96; height: 24 } - tooltip: "Volume +" - } - Key { objectName: "Volume -"; keycode: 114 - Region { left: 1199; top: 841; width: 96; height: 24 } - tooltip: "Volume -" - } - } - } - } -} diff --git a/tizen/src/ui/resource/wearable-320x320-1btn/layout.qml b/tizen/src/ui/resource/wearable-320x320-1btn/layout.qml deleted file mode 100644 index 9fee04421d..0000000000 --- a/tizen/src/ui/resource/wearable-320x320-1btn/layout.qml +++ /dev/null @@ -1,67 +0,0 @@ -import EmulatorComponent 1.0 - -EmulatorUI { - property string version: "1.0" - - FormList { - Form { - objectName: "portrait" - display: Region { left: 26; top: 60; width: 320; height: 320 } - - mainImage: "default_0.png" - pressedImage: "default_0_p.png" - - KeyList { - Key { objectName: "Power"; keycode: 116 - Region { left: 372; top: 116; width: 12; height: 80 } - tooltip: "Power" - } - } - } - - Form { - objectName: "landscape" - display: Region { left: 60; top: 38; width: 320; height: 320 } - - mainImage: "default_L90.png" - pressedImage: "default_L90_p.png" - - KeyList { - Key { objectName: "Power"; keycode: 116 - Region { left: 116; top: 0; width: 80; height: 12 } - tooltip: "Power" - } - } - } - - Form { - objectName: "reverse portrait" - display: Region { left: 38; top: 60; width: 320; height: 320 } - - mainImage: "default_180.png" - pressedImage: "default_180_p.png" - - KeyList { - Key { objectName: "Power"; keycode: 116 - Region { left: 0; top: 244; width: 12; height: 80 } - tooltip: "Power" - } - } - } - - Form { - objectName: "reverse landscape" - display: Region { left: 60; top: 26; width: 320; height: 320 } - - mainImage: "default_R90.png" - pressedImage: "default_R90_p.png" - - KeyList { - Key { objectName: "Power"; keycode: 116 - Region { left: 244; top: 372; width: 80; height: 12 } - tooltip: "Power" - } - } - } - } -} diff --git a/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml b/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml new file mode 100644 index 0000000000..d43acca471 --- /dev/null +++ b/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml @@ -0,0 +1,66 @@ + + + 2.4 + +
+ + + 0 + + default_0.png + default_0_p.png + + + + 116 + Power + + +
+
+ + + 270 + + default_L90.png + default_L90_p.png + + + + 116 + Power + + +
+
+ + + 180 + + default_180.png + default_180_p.png + + + + 116 + Power + + +
+
+ + + 90 + + default_R90.png + default_R90_p.png + + + + 116 + Power + + +
+
+